WPF image moving and rotating

2019-02-27 08:00发布

问题:

First of all I place here my situation sreenshot:

So I need to move these cars(cars are Images) where the arrow goes. For driving straight I use this function:

    private static void Eiti(Image target, double naujasX, double naujasY, double greitis, char kelias)
    {
        var top = Canvas.GetTop(target);
        var left = Canvas.GetLeft(target);
        top = Double.IsNaN(top) ? 0 : top;
        left = Double.IsNaN(left) ? 0 : left;
        naujasY = Paveikslas.canvasY(naujasY, kelias);

        var storyboard = new Storyboard();
        greitis = 100 / greitis;                // apverciamas greitis, kad butu logiska
        storyboard.Completed += Storyboard_Completed;

        if (naujasY != -1)                         // isejimo simbolis (escape)
        {
            DoubleAnimation anim1 = new DoubleAnimation(top, naujasY, TimeSpan.FromSeconds(greitis));
            Storyboard.SetTarget(anim1, target);
            Storyboard.SetTargetProperty(anim1, new PropertyPath(Canvas.TopProperty));
            storyboard.Children.Add(anim1);

            DoubleAnimation anim2 = new DoubleAnimation(left, naujasX, TimeSpan.FromSeconds(greitis));
            Storyboard.SetTarget(anim2, target);
            Storyboard.SetTargetProperty(anim2, new PropertyPath(Canvas.LeftProperty));
            storyboard.Children.Add(anim2);
        }

        storyboard.Begin();

    }

and it's working good for me!

But now I have problem with rotating and driving car at the same time (for example like in my screenshot driving through green square).

Is there any function or other ways to solve this ?