第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

在 WPF 中一一應(yīng)用時(shí)旋轉(zhuǎn)和變換不起作用

在 WPF 中一一應(yīng)用時(shí)旋轉(zhuǎn)和變換不起作用

C#
紅顏莎娜 2023-08-20 10:03:12
我正在旋轉(zhuǎn)面板(網(wǎng)格)并翻轉(zhuǎn)(變換)面板。當(dāng)我單獨(dú)執(zhí)行此操作時(shí),兩者都工作正常。旋轉(zhuǎn)然后翻轉(zhuǎn)(或)翻轉(zhuǎn)和旋轉(zhuǎn)無法正常工作。我每次都將面板旋轉(zhuǎn)90度。當(dāng)我旋轉(zhuǎn)到 90 度時(shí),面板的高度和寬度會發(fā)生變化。在這種情況下,如果我翻轉(zhuǎn)面板,就會出現(xiàn)問題。180度沒問題。問題步驟 步驟 1:通過單擊示例中的旋轉(zhuǎn)按鈕將圖像旋轉(zhuǎn) 90 度。您將得到以下輸出。步驟2:現(xiàn)在通過“變換”按鈕翻轉(zhuǎn)圖像,并將圖像移動到左側(cè)。預(yù)期輸出是,它應(yīng)該居中并翻轉(zhuǎn)。您可以通過直接單擊“變換”按鈕來查看圖像變換的差異,而無需單擊“旋轉(zhuǎn)”。這是我的代碼。[XAML]:   <Grid>        <Grid.RowDefinitions>            <RowDefinition/>            <RowDefinition  Height="50"/>        </Grid.RowDefinitions>        <Grid x:Name="grid1" Grid.Row="0">        <Image x:Name="image1" Source="Images/Buldingimage.jpeg"/>        </Grid>        <Grid Grid.Row="1">            <Grid.ColumnDefinitions>                <ColumnDefinition/>                <ColumnDefinition/>            </Grid.ColumnDefinitions>            <Button Click="Button_Click_1" Grid.Column="0">Rotate</Button>            <Button Click="Button_Click_2" Grid.Column="1">Transform</Button>        </Grid>    </Grid>[C#]:    double rotationAngle = 0;    private void Button_Click_1(object sender, RoutedEventArgs e)    {        //Rotate        this.rotationAngle += 90;        this.grid1.RenderTransformOrigin = new Point(0.5, 0.5);        this.grid1.LayoutTransform = new RotateTransform() { Angle = this.rotationAngle };    }    bool mIsHorizontalImageflipped = false;    private void Button_Click_2(object sender, RoutedEventArgs e)    {        //Transform        int[] value ;        float[] origin = new float[] { 0.5f, 0.5f };        string path = "(UIElement.RenderTransform).(ScaleTransform.ScaleX)";        if (!this.mIsHorizontalImageflipped)        {            value = new int[] { 1, -1 };            this.mIsHorizontalImageflipped = true;        }        else        {            this.mIsHorizontalImageflipped = false;          value = new int[] { -1, 1 };        }        this.Animate(value, origin, path);    }
查看完整描述

1 回答

?
忽然笑

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超5個(gè)贊

如果將該RenderTransform屬性設(shè)置為 a ScaleTransform,則實(shí)際上會刪除RotateTransform,反之亦然。


為了能夠同時(shí)應(yīng)用兩種轉(zhuǎn)換,您可以使用TransformGroup:


<Grid x:Name="grid1" Grid.Row="0">

    <Image x:Name="image1" Source="Images/Buldingimage.jpeg"/>

    <Grid.RenderTransform>

        <TransformGroup>

            <RotateTransform x:Name="rt" />

            <ScaleTransform x:Name="st" />

        </TransformGroup>

    </Grid.RenderTransform>

</Grid>

然后,您只需像以前一樣更改Angle和RotateTransform動畫ScaleTransform:


double rotationAngle = 0;

private void Button_Click_1(object sender, RoutedEventArgs e)

{

    //Rotate

    this.rotationAngle += 90;

    this.grid1.RenderTransformOrigin = new Point(0.5, 0.5);

    rt.Angle = this.rotationAngle;

}


bool mIsHorizontalImageflipped = false;

private void Button_Click_2(object sender, RoutedEventArgs e)

{

    //Transform

    int[] value;

    float[] origin = new float[] { 0.5f, 0.5f };

    string path = "RenderTransform.Children[1].ScaleX";

    if (!this.mIsHorizontalImageflipped)

    {

        value = new int[] { 1, -1 };

        this.mIsHorizontalImageflipped = true;

    }

    else

    {

        this.mIsHorizontalImageflipped = false;

        value = new int[] { -1, 1 };

    }

    this.Animate(value, origin, path);

}


internal void Animate(int[] value, float[] origin, string path)

{

    Storyboard sb = new Storyboard();

    this.grid1.RenderTransformOrigin = new Point(origin[0], origin[1]);

    DoubleAnimationUsingKeyFrames keyFrames = new DoubleAnimationUsingKeyFrames();


    SplineDoubleKeyFrame keyFrame = new SplineDoubleKeyFrame();

    keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0));

    keyFrame.Value = value[0];

    keyFrames.KeyFrames.Add(keyFrame);

    keyFrame = new SplineDoubleKeyFrame();

    keyFrame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1));


    KeySpline keySpline = new KeySpline();

    keySpline.ControlPoint1 = new Point(0.64, 0.84);

    keySpline.ControlPoint2 = new Point(0, 1);


    keyFrame.KeySpline = keySpline;

    keyFrames.KeyFrames.Add(keyFrame);

    keyFrame.Value = value[1];

    Storyboard.SetTargetProperty(keyFrames, new PropertyPath(path));

    Storyboard.SetTarget(keyFrames, this.grid1);

    sb.Children.Add(keyFrames);

    sb.Begin();

}



查看完整回答
反對 回復(fù) 2023-08-20
  • 1 回答
  • 0 關(guān)注
  • 334 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號