I am new to graphical programming with C #. Yesterday I started a new project (WPF). There is a Polyline object that I have to move around the screen with the coordinates that I calculate. I do not know how to move an object and do something like animation. When I click the mouse, I want to run this Move() method after that to go into the while loop and when the condition is complete (end == true) I want to end the loop and complete the animation. And while I'm in a loop, my idea is to move my polyline with slow movements. I tried putting Move() on a thread and using Thread.Sleep(...); , but I could only see the final position in the whole Polyline way. I tried putting it in new Thread(new ThreadStart(Move)); ... and this.Dispatcher.BeginInvoke , the effect was the same. Could you please tell me how can I make this movement?
public void Move() { bool end = false; while (!end) { double x = lastPosX; double y = lastPosY; double a = y1 - y; double b = x - x1; double c = -x * y1 + x1 * y; double u, v; GetC(out u, out v); if (y1 < lastPosY) { GetCoordinates(ref u, ref v); } if (u > width || v > height) { gameEnd = true; } lastPosX = u; lastPosY = v; p.Points.Remove(p.Points.First()); p.Points.Add(new Point(u, v)); } }
user551761
source share