MainWindow.xaml.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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. return (Mouse.LeftButton.Equals(MouseButtonState.Pressed) || Mouse.RightButton.Equals(MouseButtonState.Pressed)); }
  247. else return true;
  248. }
  249. /// <summary>
  250. /// Remove the current line.
  251. /// </summary>
  252. public void RemoveCurrLine()
  253. {
  254. RightCanvas.Children.Remove(currentLine);
  255. }
  256. /// <summary>
  257. /// Display the current line.
  258. /// </summary>
  259. /// <param name="line">The current line to display</param>
  260. public void DisplayCurrLine(Polyline line)
  261. {
  262. if (RightCanvas.Children.Contains(currentLine))
  263. {
  264. RemoveCurrLine();
  265. }
  266. RightCanvas.Children.Add(line);
  267. currentLine = line;
  268. }
  269. /// <summary>
  270. /// Removes all Lines from the left canvas.
  271. /// </summary>
  272. public void RemoveAllLeftLines()
  273. {
  274. LeftCanvas.Children.Clear();
  275. }
  276. /// <summary>
  277. /// Removes all lines in the right canvas.
  278. /// </summary>
  279. public void RemoveAllRightLines()
  280. {
  281. RightCanvas.Children.Clear();
  282. }
  283. /// <summary>
  284. /// Adds another Line that will be displayed in the left display.
  285. /// </summary>
  286. /// <param name="newLine">The new Polyline to be added displayed.</param>
  287. public void AddNewLineLeft(Polyline newLine)
  288. {
  289. newLine.Stroke = Brushes.Black;
  290. newLine.StrokeThickness = 2;
  291. LeftCanvas.Children.Add(newLine);
  292. }
  293. /// <summary>
  294. /// Adds another Line that will be displayed in the right display.
  295. /// </summary>
  296. /// <param name="newLine">The new Polyline to be added displayed.</param>
  297. public void AddNewLineRight(Polyline newLine)
  298. {
  299. newLine.Stroke = Brushes.Black;
  300. newLine.StrokeThickness = 2;
  301. RightCanvas.Children.Add(newLine);
  302. }
  303. /// <summary>
  304. /// Adds a point to the right canvas
  305. /// </summary>
  306. /// <param name="newPoint">The point</param>
  307. public void AddNewPointRight(Ellipse newPoint, InternalLine line)
  308. {
  309. newPoint.Height = 3; newPoint.Width = 3;
  310. newPoint.Fill = Brushes.Black;
  311. RightCanvas.Children.Add(newPoint);
  312. newPoint.Margin = new Thickness(line.point.X - 1.5, line.point.Y - 1.5, 0,0);
  313. }
  314. /// <summary>
  315. /// Adds a point to the left canvas
  316. /// </summary>
  317. /// <param name="newPoint">The point</param>
  318. public void AddNewPointLeft(Ellipse newPoint)
  319. {
  320. newPoint.Height = 3; newPoint.Width = 3;
  321. newPoint.Fill = Brushes.Black;
  322. LeftCanvas.Children.Add(newPoint);
  323. }
  324. /// <summary>
  325. /// Enables the timer of the View, which will tick the Presenter.
  326. /// </summary>
  327. public void EnableTimer()
  328. {
  329. dispatcherTimer.Start();
  330. }
  331. /// <summary>
  332. /// A function that opens a file dialog and returns the filename.
  333. /// </summary>
  334. /// <param name="Filter">The filter that should be applied to the new Dialog.</param>
  335. /// <returns>Returns the FileName and the SafeFileName if the user correctly selects a file,
  336. /// else returns a tuple with empty strigns</returns>
  337. public Tuple<string, string> openNewDialog(string Filter)
  338. {
  339. openFileDialog.Filter = Filter;
  340. if (openFileDialog.ShowDialog() == true)
  341. {
  342. return new Tuple<string, string>(openFileDialog.FileName, openFileDialog.SafeFileName);
  343. }
  344. else
  345. {
  346. return new Tuple<string, string>("", "");
  347. }
  348. }
  349. /// <summary>
  350. /// Sets the contents of the last action taken indicator label.
  351. /// </summary>
  352. /// <param name="message">The new contents</param>
  353. public void SetLastActionTakenText(string message)
  354. {
  355. LastActionBox.Text = message;
  356. }
  357. /// <summary>
  358. /// Sets the contents of the status bar label containing
  359. /// the similarity score of the left and right image.
  360. /// </summary>
  361. /// <param name="message">The message to be set,
  362. /// will be set to the default value if left empty.</param>
  363. public void SetImageSimilarityText(string message)
  364. {
  365. if (message.Count() > 0) LineSimilarityBox.Text = message;
  366. else LineSimilarityBox.Text = "-";
  367. }
  368. /// <summary>
  369. /// Changes the states of a tool strip button.
  370. /// </summary>
  371. /// <param name="buttonName">The name of the button.</param>
  372. /// <param name="state">The new state of the button.</param>
  373. public void SetToolStripButtonStatus(string buttonName, MainWindow.ButtonState state)
  374. {
  375. ButtonBase buttonToChange;
  376. bool isToggleable = false;
  377. switch (buttonName)
  378. {
  379. case "canvasButton":
  380. buttonToChange = CanvasButton;
  381. break;
  382. case "drawButton":
  383. buttonToChange = DrawButton;
  384. isToggleable = true;
  385. break;
  386. case "deleteButton":
  387. buttonToChange = DeleteButton;
  388. isToggleable = true;
  389. break;
  390. case "undoButton":
  391. buttonToChange = UndoButton;
  392. break;
  393. case "redoButton":
  394. buttonToChange = RedoButton;
  395. break;
  396. default:
  397. Console.WriteLine("Invalid Button was given to SetToolStripButton. \nMaybe you forgot to add a case?");
  398. return;
  399. }
  400. if (isToggleable)
  401. {
  402. switch (state)
  403. {
  404. case ButtonState.Active:
  405. ((ToggleButton)buttonToChange).IsEnabled = true;
  406. ((ToggleButton)buttonToChange).IsChecked = true;
  407. ((ToggleButton)buttonToChange).Opacity = 1;
  408. ((ToggleButton)buttonToChange).Background = Brushes.SkyBlue;
  409. break;
  410. case ButtonState.Disabled:
  411. ((ToggleButton)buttonToChange).IsEnabled = false;
  412. ((ToggleButton)buttonToChange).IsChecked = false;
  413. ((ToggleButton)buttonToChange).Opacity = 0.5;
  414. ((ToggleButton)buttonToChange).Background = Brushes.LightGray;
  415. break;
  416. case ButtonState.Enabled:
  417. ((ToggleButton)buttonToChange).IsEnabled = true;
  418. ((ToggleButton)buttonToChange).IsChecked = false;
  419. ((ToggleButton)buttonToChange).Opacity = 1;
  420. ((ToggleButton)buttonToChange).Background = Brushes.LightGray;
  421. break;
  422. }
  423. }
  424. else
  425. {
  426. switch (state)
  427. {
  428. case ButtonState.Disabled:
  429. ((Button)buttonToChange).IsEnabled = false;
  430. ((Button)buttonToChange).Opacity = 0.5;
  431. break;
  432. default:
  433. ((Button)buttonToChange).IsEnabled = true;
  434. ((Button)buttonToChange).Opacity = 1;
  435. break;
  436. }
  437. }
  438. }
  439. /// <summary>
  440. /// Sets the contents of the load status indicator label.
  441. /// </summary>
  442. /// <param name="message">The new contents</param>
  443. public void SetToolStripLoadStatus(string message)
  444. {
  445. LoadStatusBox.Text = message;
  446. }
  447. /// <summary>
  448. /// shows the given info message in a popup and asks the user to aknowledge it
  449. /// </summary>
  450. /// <param name="message">the message to show</param>
  451. public void ShowInfoMessage(string message)
  452. {
  453. MessageBox.Show(message);
  454. }
  455. /// <summary>
  456. /// Shows a warning box with the given message (Yes/No Buttons)and returns true if the user aknowledges it.
  457. /// </summary>
  458. /// <param name="message">The message of the warning.</param>
  459. /// <returns>True if the user confirms (Yes), negative if he doesn't (No)</returns>
  460. public bool ShowWarning(string message)
  461. {
  462. MessageBoxResult result = MessageBox.Show(message, "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
  463. return (result.Equals(MessageBoxResult.Yes));
  464. }
  465. /// <summary>
  466. /// Updates the colour of a canvas.
  467. /// </summary>
  468. /// <param name="canvasName">The name of the canvas to be updated.</param>
  469. /// <param name="active">Whether or not the canvas is active.</param>
  470. public void SetCanvasState(string canvasName, bool active)
  471. {
  472. switch (canvasName)
  473. {
  474. case ("LeftCanvas"):
  475. if (active)
  476. {
  477. LeftCanvas.Background = Brushes.White;
  478. }
  479. else
  480. {
  481. LeftCanvas.Background = Brushes.SlateGray;
  482. }
  483. break;
  484. case ("RightCanvas"):
  485. if (active)
  486. {
  487. RightCanvas.Background = Brushes.White;
  488. }
  489. else
  490. {
  491. RightCanvas.Background = Brushes.SlateGray;
  492. }
  493. break;
  494. default:
  495. throw new InvalidOperationException("Unknown canvas name, Check that the canvas passed is either LeftCanvas or RightCanvas");
  496. }
  497. }
  498. /************************/
  499. /*** HELPING FUNCTION ***/
  500. /************************/
  501. /// <summary>
  502. /// A function that generates the overlay elements and sets all their values.
  503. /// </summary>
  504. private void SetupOverlay()
  505. {
  506. DropShadowEffect effect = new DropShadowEffect(); effect.ShadowDepth = 0;
  507. OverlayCanvas.Background = null;
  508. //Startpoint of a line to be redrawn
  509. Ellipse StartPointOverlay = new Ellipse();
  510. StartPointOverlay.Height = markerRadius * 2; StartPointOverlay.Width = markerRadius * 2;
  511. StartPointOverlay.Fill = Brushes.Green;
  512. StartPointOverlay.Effect = effect;
  513. OverlayDictionary.Add("startpoint", StartPointOverlay);
  514. //Endpoint of a line to be redrawn
  515. Ellipse EndPointOverlay = new Ellipse();
  516. EndPointOverlay.Height = markerRadius * 2; EndPointOverlay.Width = markerRadius * 2;
  517. EndPointOverlay.Fill = Brushes.Green;
  518. EndPointOverlay.Effect = effect;
  519. OverlayDictionary.Add("endpoint", EndPointOverlay);
  520. //Pointer of the optitrack system
  521. Ellipse OptitrackMarker = new Ellipse(); OptitrackMarker.Height = 5; OptitrackMarker.Width = 5;
  522. OptitrackMarker.Fill = Brushes.LightGray;
  523. OptitrackMarker.Effect = effect;
  524. OverlayDictionary.Add("optipoint", OptitrackMarker);
  525. //10 Dotted Lines for debugging (if more are needed simply extend the for-loop
  526. for(int x = 0; x < 10; x++)
  527. {
  528. Line dotLine = new Line();
  529. dotLine.Stroke = Brushes.Red;
  530. dotLine.StrokeDashArray = new DoubleCollection { 2 + x, 2 + x };
  531. dotLine.StrokeThickness = 1;
  532. OverlayDictionary.Add("dotLine" + x.ToString(), dotLine);
  533. }
  534. //Common features of all overlay items
  535. foreach (KeyValuePair<String, Shape> s in OverlayDictionary)
  536. {
  537. OverlayCanvas.Children.Add(s.Value);
  538. s.Value.Opacity = 0.00001;
  539. s.Value.IsHitTestVisible = false;
  540. }
  541. //Enable optipoint initially
  542. ProgramPresenter.SetOverlayStatus("optipoint", true, GetCursorPosition());
  543. }
  544. /// <summary>
  545. /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
  546. /// Takes 7000ms
  547. /// </summary>
  548. private void DebugOne_Click(object sender, RoutedEventArgs e)
  549. {
  550. Debug(1);
  551. }
  552. /// <summary>
  553. /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
  554. /// Takes 24000ms
  555. /// </summary>
  556. private void DebugTwo_Click(object sender, RoutedEventArgs e)
  557. {
  558. Debug(2);
  559. }
  560. /// <summary>
  561. /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
  562. /// Takes 4000ms
  563. /// </summary>
  564. private void DebugThree_Click(object sender, RoutedEventArgs e)
  565. {
  566. Debug(3);
  567. }
  568. /// <summary>
  569. /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
  570. /// Takes
  571. /// </summary>
  572. private void DebugFour_Click(object sender, RoutedEventArgs e)
  573. {
  574. Debug(4);
  575. }
  576. /// <summary>
  577. /// A function which simulates canvas input for debugging.
  578. /// </summary>
  579. /// <param name="option"></param>
  580. private async void Debug(int option)
  581. {
  582. Point[] points;
  583. Point start = new Point(50, 50);
  584. switch (option)
  585. {
  586. case 1:
  587. points = debugDat.debugPoints1;
  588. break;
  589. case 2:
  590. points = debugDat.debugPoints2;
  591. break;
  592. case 3:
  593. points = debugDat.debugPoints3;
  594. break;
  595. case 4:
  596. points = debugDat.debugPoints4;
  597. start = new Point(284, 148);
  598. break;
  599. default:
  600. return;
  601. }
  602. dispatcherTimer.Stop();
  603. debugRunning = true;
  604. ProgramPresenter.Tick(); await Task.Delay(10);
  605. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Move, start);
  606. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Down, strokeCollection); await Task.Delay(10);
  607. for (int x = 0; x < points.Length; x++)
  608. {
  609. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Move, points[x]);
  610. await Task.Delay(1);
  611. if (x % 5 == 0)
  612. {
  613. ProgramPresenter.Tick();
  614. await Task.Delay(1);
  615. }
  616. }
  617. ProgramPresenter.MouseEvent(MVP_Presenter.MouseAction.Up, strokeCollection); await Task.Delay(1);
  618. debugRunning = false;
  619. dispatcherTimer.Start();
  620. }
  621. }
  622. }