MainWindow.xaml.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. using Microsoft.Win32;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Reflection;
  6. using System.Text;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. using System.Timers;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Controls.Primitives;
  13. using System.Windows.Data;
  14. using System.Windows.Documents;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Navigation;
  19. using System.Windows.Shapes;
  20. using System.Windows.Threading;
  21. using System.Windows.Ink;
  22. using System.Windows.Media.Effects;
  23. namespace SketchAssistantWPF
  24. {
  25. /// <summary>
  26. /// Interaction logic for MainWindow.xaml
  27. /// </summary>
  28. public partial class MainWindow : Window, MVP_View
  29. {
  30. public MainWindow()
  31. {
  32. bool InDebugMode = false;
  33. String[] commArgs = Environment.GetCommandLineArgs();
  34. InitializeComponent();
  35. if (commArgs.Length > 1)
  36. {
  37. if (commArgs[1].Equals("-debug"))
  38. {
  39. InDebugMode = true;
  40. }
  41. }
  42. if (!InDebugMode)
  43. {
  44. DebugMode.Visibility = Visibility.Collapsed;
  45. }
  46. ProgramPresenter = new MVP_Presenter(this);
  47. // DispatcherTimer setup
  48. dispatcherTimer = new DispatcherTimer(DispatcherPriority.Render);
  49. dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
  50. dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
  51. ProgramPresenter.Resize(new Tuple<int, int>((int)LeftCanvas.Width, (int)LeftCanvas.Height),
  52. new Tuple<int, int>((int)RightCanvas.Width, (int)RightCanvas.Height));
  53. //Setup overlay items
  54. SetupOverlay();
  55. }
  56. public enum ButtonState
  57. {
  58. Enabled,
  59. Disabled,
  60. Active
  61. }
  62. DispatcherTimer dispatcherTimer;
  63. /// <summary>
  64. /// Dialog to select a file.
  65. /// </summary>
  66. OpenFileDialog openFileDialog = new OpenFileDialog();
  67. /// <summary>
  68. /// All Lines in the current session
  69. /// </summary>
  70. List<Tuple<bool, InternalLine>> rightLineList = new List<Tuple<bool, InternalLine>>();
  71. /// <summary>
  72. /// Queue for the cursorPositions
  73. /// </summary>
  74. Queue<Point> cursorPositions = new Queue<Point>();
  75. /// <summary>
  76. /// The Presenter Component of the MVP-Model
  77. /// </summary>
  78. MVP_Presenter ProgramPresenter;
  79. /// <summary>
  80. /// The line currently being drawn
  81. /// </summary>
  82. Polyline currentLine;
  83. /// <summary>
  84. /// If the debug function is running.
  85. /// </summary>
  86. bool debugRunning = false;
  87. /// <summary>
  88. /// Point collections for debugging.
  89. /// </summary>
  90. DebugData debugDat = new DebugData();
  91. /// <summary>
  92. /// Stores Lines drawn on RightCanvas.
  93. /// </summary>
  94. public StrokeCollection strokeCollection = new StrokeCollection();
  95. /// <summary>
  96. /// Size of areas marking endpoints of lines in the redraw mode.
  97. /// </summary>
  98. public int markerRadius = 5;
  99. /// <summary>
  100. /// Dictionary containing the overlay elements
  101. /// </summary>
  102. public Dictionary<String, Shape> OverlayDictionary = new Dictionary<string, Shape>();
  103. /********************************************/
  104. /*** WINDOW SPECIFIC FUNCTIONS START HERE ***/
  105. /********************************************/
  106. /// <summary>
  107. /// Resize Function connected to the form resize event, will refresh the form when it is resized
  108. /// </summary>
  109. private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
  110. {
  111. ProgramPresenter.Resize(new Tuple<int, int>((int)LeftCanvas.ActualWidth, (int)LeftCanvas.ActualHeight),
  112. new Tuple<int, int>((int)RightCanvas.ActualWidth, (int)RightCanvas.ActualHeight));
  113. }
  114. /// <summary>
  115. /// Collects all Strokes on RightCanvas
  116. /// </summary>
  117. public void RightCanvas_StrokeCollection(object sender, InkCanvasStrokeCollectedEventArgs e)
  118. {
  119. strokeCollection.Add(e.Stroke);
  120. }
  121. /// <summary>
  122. /// Redo an Action.
  123. /// </summary>
  124. private void RedoButton_Click(object sender, RoutedEventArgs e)
  125. {
  126. if (!IsMousePressed()) ProgramPresenter.Redo();
  127. }
  128. /// <summary>
  129. /// Undo an Action.
  130. /// </summary>
  131. private void UndoButton_Click(object sender, RoutedEventArgs e)
  132. {
  133. if (!IsMousePressed()) ProgramPresenter.Undo();
  134. }
  135. /// <summary>
  136. /// Changes the state of the program to deletion
  137. /// </summary>
  138. private void DeleteButton_Click(object sender, RoutedEventArgs e)
  139. {
  140. ProgramPresenter.ChangeState(false);
  141. RightCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
  142. }
  143. /// <summary>
  144. /// Changes the state of the program to drawing
  145. /// </summary>
  146. private void DrawButton_Click(object sender, RoutedEventArgs e)
  147. {
  148. ProgramPresenter.ChangeState(true);
  149. RightCanvas.EditingMode = InkCanvasEditingMode.Ink;
  150. }
  151. /// <summary>
  152. /// Hold left mouse button to start drawing.
  153. /// </summary>
  154. private void RightCanvas_MouseDown(object sender, MouseButtonEventArgs e)
  155. {
  156. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Down, strokeCollection);
  157. }
  158. /// <summary>
  159. /// Lift left mouse button to stop drawing and add a new Line.
  160. /// </summary>
  161. private void RightCanvas_MouseUp(object sender, MouseButtonEventArgs e)
  162. {
  163. if (strokeCollection.Count == 0)
  164. {
  165. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up_Invalid, strokeCollection);
  166. }
  167. else
  168. {
  169. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up, strokeCollection);
  170. RightCanvas.Strokes.RemoveAt(0);
  171. strokeCollection.RemoveAt(0);
  172. }
  173. }
  174. /// <summary>
  175. /// Is called when a stylus is lifted, which has the same effect as releasing the mouse.
  176. /// Lifting the finger when using touch also toggles this, therfore this function is sufficient.
  177. /// </summary>
  178. private void RightCanvas_IsStylusCapturedChanged(object sender, DependencyPropertyChangedEventArgs e)
  179. {
  180. System.Diagnostics.Debug.WriteLine("Stylus Capture is now: {0}", RightCanvas.IsStylusCaptured);
  181. if (!RightCanvas.IsStylusCaptured)
  182. {
  183. if (strokeCollection.Count == 0)
  184. {
  185. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up_Invalid, strokeCollection);
  186. }
  187. else
  188. {
  189. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up, strokeCollection);
  190. RightCanvas.Strokes.RemoveAt(0);
  191. strokeCollection.RemoveAt(0);
  192. }
  193. }
  194. }
  195. /// <summary>
  196. /// Get current Mouse positon within the right picture box.
  197. /// </summary>
  198. private void RightCanvas_MouseMove(object sender, MouseEventArgs e)
  199. {
  200. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Move, e.GetPosition(RightCanvas));
  201. }
  202. /// <summary>
  203. /// Button to create a new Canvas. Will create an empty image
  204. /// which is the size of the left image, if there is one.
  205. /// If there is no image loaded the canvas will be the size of the right picture box
  206. /// </summary>
  207. private void CanvasButton_Click(object sender, RoutedEventArgs e)
  208. {
  209. ProgramPresenter.NewCanvas();
  210. RightCanvas.EditingMode = InkCanvasEditingMode.Ink;
  211. RightCanvas.Strokes.Clear();
  212. }
  213. /// <summary>
  214. /// Ticks the Presenter.
  215. /// </summary>
  216. private void dispatcherTimer_Tick(object sender, EventArgs e)
  217. {
  218. ProgramPresenter.Tick();
  219. }
  220. /// <summary>
  221. /// Import button for .svg file, will open an OpenFileDialog
  222. /// </summary>
  223. private void SVGMenuItem_Click(object sender, RoutedEventArgs e)
  224. {
  225. if (ProgramPresenter.SVGToolStripMenuItemClick())
  226. RightCanvas.EditingMode = InkCanvasEditingMode.Ink;
  227. }
  228. /*************************/
  229. /*** PRESENTER -> VIEW ***/
  230. /*************************/
  231. /// <summary>
  232. /// Returns the cursor position.
  233. /// </summary>
  234. /// <returns>The cursor Position</returns>
  235. public Point GetCursorPosition()
  236. {
  237. return Mouse.GetPosition(RightCanvas);
  238. }
  239. /// <summary>
  240. /// If the mouse is pressed or not.
  241. /// </summary>
  242. /// <returns>Whether or not the mouse is pressed.</returns>
  243. public bool IsMousePressed()
  244. {
  245. if (!debugRunning)
  246. {
  247. return (Mouse.LeftButton.Equals(MouseButtonState.Pressed) || Mouse.RightButton.Equals(MouseButtonState.Pressed));
  248. }
  249. else return true;
  250. }
  251. /// <summary>
  252. /// Remove the current line.
  253. /// </summary>
  254. public void RemoveCurrLine()
  255. {
  256. RightCanvas.Children.Remove(currentLine);
  257. }
  258. /// <summary>
  259. /// Display the current line.
  260. /// </summary>
  261. /// <param name="line">The current line to display</param>
  262. public void DisplayCurrLine(Polyline line)
  263. {
  264. if (RightCanvas.Children.Contains(currentLine))
  265. {
  266. RemoveCurrLine();
  267. }
  268. RightCanvas.Children.Add(line);
  269. currentLine = line;
  270. }
  271. /// <summary>
  272. /// Removes all Lines from the left canvas.
  273. /// </summary>
  274. public void RemoveAllLeftLines()
  275. {
  276. LeftCanvas.Children.Clear();
  277. }
  278. /// <summary>
  279. /// Removes all lines in the right canvas.
  280. /// </summary>
  281. public void RemoveAllRightLines()
  282. {
  283. RightCanvas.Children.Clear();
  284. }
  285. /// <summary>
  286. /// Adds another Line that will be displayed in the left display.
  287. /// </summary>
  288. /// <param name="newLine">The new Polyline to be added displayed.</param>
  289. public void AddNewLineLeft(Polyline newLine)
  290. {
  291. newLine.Stroke = Brushes.Black;
  292. newLine.StrokeThickness = 2;
  293. LeftCanvas.Children.Add(newLine);
  294. }
  295. /// <summary>
  296. /// Adds another Line that will be displayed in the right display.
  297. /// </summary>
  298. /// <param name="newLine">The new Polyline to be added displayed.</param>
  299. public void AddNewLineRight(Polyline newLine)
  300. {
  301. newLine.Stroke = Brushes.Black;
  302. newLine.StrokeThickness = 2;
  303. RightCanvas.Children.Add(newLine);
  304. }
  305. /// <summary>
  306. /// Adds a point to the right canvas
  307. /// </summary>
  308. /// <param name="newPoint">The point</param>
  309. public void AddNewPointRight(Ellipse newPoint, InternalLine line)
  310. {
  311. newPoint.Height = 3; newPoint.Width = 3;
  312. newPoint.Fill = Brushes.Black;
  313. RightCanvas.Children.Add(newPoint);
  314. newPoint.Margin = new Thickness(line.point.X - 1.5, line.point.Y - 1.5, 0, 0);
  315. }
  316. /// <summary>
  317. /// Adds a point to the left canvas
  318. /// </summary>
  319. /// <param name="newPoint">The point</param>
  320. public void AddNewPointLeft(Ellipse newPoint)
  321. {
  322. newPoint.Height = 3; newPoint.Width = 3;
  323. newPoint.Fill = Brushes.Black;
  324. LeftCanvas.Children.Add(newPoint);
  325. }
  326. /// <summary>
  327. /// Enables the timer of the View, which will tick the Presenter.
  328. /// </summary>
  329. public void EnableTimer()
  330. {
  331. dispatcherTimer.Start();
  332. }
  333. /// <summary>
  334. /// A function that opens a file dialog and returns the filename.
  335. /// </summary>
  336. /// <param name="Filter">The filter that should be applied to the new Dialog.</param>
  337. /// <returns>Returns the FileName and the SafeFileName if the user correctly selects a file,
  338. /// else returns a tuple with empty strigns</returns>
  339. public Tuple<string, string> openNewDialog(string Filter)
  340. {
  341. openFileDialog.Filter = Filter;
  342. if (openFileDialog.ShowDialog() == true)
  343. {
  344. return new Tuple<string, string>(openFileDialog.FileName, openFileDialog.SafeFileName);
  345. }
  346. else
  347. {
  348. return new Tuple<string, string>("", "");
  349. }
  350. }
  351. /// <summary>
  352. /// Sets the contents of the last action taken indicator label.
  353. /// </summary>
  354. /// <param name="message">The new contents</param>
  355. public void SetLastActionTakenText(string message)
  356. {
  357. LastActionBox.Text = message;
  358. }
  359. /// <summary>
  360. /// Sets the contents of the status bar label containing
  361. /// the similarity score of the left and right image.
  362. /// </summary>
  363. /// <param name="message">The message to be set,
  364. /// will be set to the default value if left empty.</param>
  365. public void SetImageSimilarityText(string message)
  366. {
  367. if (message.Count() > 0) LineSimilarityBox.Text = message;
  368. else LineSimilarityBox.Text = "-";
  369. }
  370. /// <summary>
  371. /// Changes the states of a tool strip button.
  372. /// </summary>
  373. /// <param name="buttonName">The name of the button.</param>
  374. /// <param name="state">The new state of the button.</param>
  375. public void SetToolStripButtonStatus(string buttonName, MainWindow.ButtonState state)
  376. {
  377. ButtonBase buttonToChange;
  378. bool isToggleable = false;
  379. switch (buttonName)
  380. {
  381. case "canvasButton":
  382. buttonToChange = CanvasButton;
  383. break;
  384. case "drawButton":
  385. buttonToChange = DrawButton;
  386. isToggleable = true;
  387. break;
  388. case "deleteButton":
  389. buttonToChange = DeleteButton;
  390. isToggleable = true;
  391. break;
  392. case "undoButton":
  393. buttonToChange = UndoButton;
  394. break;
  395. case "redoButton":
  396. buttonToChange = RedoButton;
  397. break;
  398. default:
  399. Console.WriteLine("Invalid Button was given to SetToolStripButton. \nMaybe you forgot to add a case?");
  400. return;
  401. }
  402. if (isToggleable)
  403. {
  404. switch (state)
  405. {
  406. case ButtonState.Active:
  407. ((ToggleButton)buttonToChange).IsEnabled = true;
  408. ((ToggleButton)buttonToChange).IsChecked = true;
  409. ((ToggleButton)buttonToChange).Opacity = 1;
  410. ((ToggleButton)buttonToChange).Background = Brushes.SkyBlue;
  411. break;
  412. case ButtonState.Disabled:
  413. ((ToggleButton)buttonToChange).IsEnabled = false;
  414. ((ToggleButton)buttonToChange).IsChecked = false;
  415. ((ToggleButton)buttonToChange).Opacity = 0.5;
  416. ((ToggleButton)buttonToChange).Background = Brushes.LightGray;
  417. break;
  418. case ButtonState.Enabled:
  419. ((ToggleButton)buttonToChange).IsEnabled = true;
  420. ((ToggleButton)buttonToChange).IsChecked = false;
  421. ((ToggleButton)buttonToChange).Opacity = 1;
  422. ((ToggleButton)buttonToChange).Background = Brushes.LightGray;
  423. break;
  424. }
  425. }
  426. else
  427. {
  428. switch (state)
  429. {
  430. case ButtonState.Disabled:
  431. ((Button)buttonToChange).IsEnabled = false;
  432. ((Button)buttonToChange).Opacity = 0.5;
  433. break;
  434. default:
  435. ((Button)buttonToChange).IsEnabled = true;
  436. ((Button)buttonToChange).Opacity = 1;
  437. break;
  438. }
  439. }
  440. }
  441. /// <summary>
  442. /// Sets the contents of the load status indicator label.
  443. /// </summary>
  444. /// <param name="message">The new contents</param>
  445. public void SetToolStripLoadStatus(string message)
  446. {
  447. LoadStatusBox.Text = message;
  448. }
  449. /// <summary>
  450. /// shows the given info message in a popup and asks the user to aknowledge it
  451. /// </summary>
  452. /// <param name="message">the message to show</param>
  453. public void ShowInfoMessage(string message)
  454. {
  455. MessageBox.Show(message);
  456. }
  457. /// <summary>
  458. /// Shows a warning box with the given message (Yes/No Buttons)and returns true if the user aknowledges it.
  459. /// </summary>
  460. /// <param name="message">The message of the warning.</param>
  461. /// <returns>True if the user confirms (Yes), negative if he doesn't (No)</returns>
  462. public bool ShowWarning(string message)
  463. {
  464. MessageBoxResult result = MessageBox.Show(message, "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
  465. return (result.Equals(MessageBoxResult.Yes));
  466. }
  467. /// <summary>
  468. /// Updates the colour of a canvas.
  469. /// </summary>
  470. /// <param name="canvasName">The name of the canvas to be updated.</param>
  471. /// <param name="active">Whether or not the canvas is active.</param>
  472. public void SetCanvasState(string canvasName, bool active)
  473. {
  474. switch (canvasName)
  475. {
  476. case ("LeftCanvas"):
  477. if (active) LeftCanvas.Background = Brushes.White;
  478. else LeftCanvas.Background = Brushes.SlateGray;
  479. break;
  480. case ("RightCanvas"):
  481. if (active) RightCanvas.Background = Brushes.White;
  482. else RightCanvas.Background = Brushes.SlateGray;
  483. break;
  484. default:
  485. throw new InvalidOperationException("Unknown canvas name, Check that the canvas passed is either LeftCanvas or RightCanvas");
  486. }
  487. }
  488. /************************/
  489. /*** HELPING FUNCTION ***/
  490. /************************/
  491. /// <summary>
  492. /// A function that generates the overlay elements and sets all their values.
  493. /// </summary>
  494. private void SetupOverlay()
  495. {
  496. DropShadowEffect effect = new DropShadowEffect(); effect.ShadowDepth = 0;
  497. OverlayCanvas.Background = null;
  498. //Startpoint of a line to be redrawn
  499. Ellipse StartPointOverlay = new Ellipse();
  500. StartPointOverlay.Height = markerRadius * 2; StartPointOverlay.Width = markerRadius * 2;
  501. StartPointOverlay.Fill = Brushes.Green;
  502. StartPointOverlay.Effect = effect;
  503. OverlayDictionary.Add("startpoint", StartPointOverlay);
  504. //Endpoint of a line to be redrawn
  505. Ellipse EndPointOverlay = new Ellipse();
  506. EndPointOverlay.Height = markerRadius * 2; EndPointOverlay.Width = markerRadius * 2;
  507. EndPointOverlay.Fill = Brushes.Green;
  508. EndPointOverlay.Effect = effect;
  509. OverlayDictionary.Add("endpoint", EndPointOverlay);
  510. //Pointer of the optitrack system
  511. Ellipse OptitrackMarker = new Ellipse(); OptitrackMarker.Height = 5; OptitrackMarker.Width = 5;
  512. OptitrackMarker.Fill = Brushes.LightGray;
  513. OptitrackMarker.Effect = effect;
  514. OverlayDictionary.Add("optipoint", OptitrackMarker);
  515. //10 Dotted Lines for debugging (if more are needed simply extend the for-loop
  516. for (int x = 0; x < 10; x++)
  517. {
  518. Line dotLine = new Line();
  519. dotLine.Stroke = Brushes.Red;
  520. dotLine.StrokeDashArray = new DoubleCollection { 2 + x, 2 + x };
  521. dotLine.StrokeThickness = 1;
  522. OverlayDictionary.Add("dotLine" + x.ToString(), dotLine);
  523. }
  524. //Common features of all overlay items
  525. foreach (KeyValuePair<String, Shape> s in OverlayDictionary)
  526. {
  527. OverlayCanvas.Children.Add(s.Value);
  528. s.Value.Opacity = 0.00001;
  529. s.Value.IsHitTestVisible = false;
  530. }
  531. //Enable optipoint initially
  532. ProgramPresenter.SetOverlayStatus("optipoint", true, GetCursorPosition());
  533. }
  534. /// <summary>
  535. /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
  536. /// Takes 7000ms
  537. /// </summary>
  538. private void DebugOne_Click(object sender, RoutedEventArgs e)
  539. {
  540. Debug(1);
  541. }
  542. /// <summary>
  543. /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
  544. /// Takes 24000ms
  545. /// </summary>
  546. private void DebugTwo_Click(object sender, RoutedEventArgs e)
  547. {
  548. Debug(2);
  549. }
  550. /// <summary>
  551. /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
  552. /// Takes 4000ms
  553. /// </summary>
  554. private void DebugThree_Click(object sender, RoutedEventArgs e)
  555. {
  556. Debug(3);
  557. }
  558. /// <summary>
  559. /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
  560. /// Takes
  561. /// </summary>
  562. private void DebugFour_Click(object sender, RoutedEventArgs e)
  563. {
  564. Debug(4);
  565. }
  566. /// <summary>
  567. /// A function which simulates canvas input for debugging.
  568. /// </summary>
  569. /// <param name="option"></param>
  570. private async void Debug(int option)
  571. {
  572. Point[] points;
  573. Point start = new Point(50, 50);
  574. switch (option)
  575. {
  576. case 1:
  577. points = debugDat.debugPoints1;
  578. break;
  579. case 2:
  580. points = debugDat.debugPoints2;
  581. break;
  582. case 3:
  583. points = debugDat.debugPoints3;
  584. break;
  585. case 4:
  586. points = debugDat.debugPoints4;
  587. start = new Point(284, 148);
  588. break;
  589. default:
  590. return;
  591. }
  592. dispatcherTimer.Stop();
  593. debugRunning = true;
  594. ProgramPresenter.Tick(); await Task.Delay(10);
  595. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Move, start);
  596. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Down, strokeCollection); await Task.Delay(10);
  597. for (int x = 0; x < points.Length; x++)
  598. {
  599. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Move, points[x]);
  600. await Task.Delay(1);
  601. if (x % 5 == 0)
  602. {
  603. ProgramPresenter.Tick();
  604. await Task.Delay(1);
  605. }
  606. }
  607. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up, strokeCollection); await Task.Delay(1);
  608. debugRunning = false;
  609. dispatcherTimer.Start();
  610. }
  611. }
  612. }