Form1.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Text.RegularExpressions;
  11. // This is the code for your desktop app.
  12. // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
  13. namespace SketchAssistant
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public Form1()
  18. {
  19. InitializeComponent();
  20. fileImporter = new FileImporter();
  21. }
  22. /**********************************/
  23. /*** CLASS VARIABLES START HERE ***/
  24. /**********************************/
  25. //important: add new variables only at the end of the list to keep the order of definition consistent with the order in which they are returned by GetAllVariables()
  26. /// <summary>
  27. /// Different Program States
  28. /// </summary>
  29. public enum ProgramState
  30. {
  31. Idle,
  32. Draw,
  33. Delete
  34. }
  35. /// <summary>
  36. /// Current Program State
  37. /// </summary>
  38. private ProgramState currentState;
  39. /// <summary>
  40. /// instance of FileImporter to handle drawing imports
  41. /// </summary>
  42. private FileImporter fileImporter;
  43. /// <summary>
  44. /// Dialog to select a file.
  45. /// </summary>
  46. OpenFileDialog openFileDialog = new OpenFileDialog();
  47. /// <summary>
  48. /// Image loaded on the left
  49. /// </summary>
  50. private Image leftImage = null;
  51. /// <summary>
  52. /// the graphic shown in the left window, represented as a list of polylines
  53. /// </summary>
  54. private List<Line> leftLineList;
  55. /// <summary>
  56. /// Image on the right
  57. /// </summary>
  58. Image rightImage = null;
  59. /// <summary>
  60. /// Current Line being Drawn
  61. /// </summary>
  62. List<Point> currentLine;
  63. /// <summary>
  64. /// All Lines in the current session
  65. /// </summary>
  66. List<Tuple<bool,Line>> rightLineList = new List<Tuple<bool, Line>>();
  67. /// <summary>
  68. /// Whether the Mouse is currently pressed in the rightPictureBox
  69. /// </summary>
  70. bool mousePressed = false;
  71. /// <summary>
  72. /// The Position of the Cursor in the right picture box
  73. /// </summary>
  74. Point currentCursorPosition;
  75. /// <summary>
  76. /// The Previous Cursor Position in the right picture box
  77. /// </summary>
  78. Point previousCursorPosition;
  79. /// <summary>
  80. /// Queue for the cursorPositions
  81. /// </summary>
  82. Queue<Point> cursorPositions = new Queue<Point>();
  83. /// <summary>
  84. /// The graphic representation of the right image
  85. /// </summary>
  86. Graphics rightGraph = null;
  87. /// <summary>
  88. /// Deletion Matrixes for checking postions of lines in the image
  89. /// </summary>
  90. bool[,] isFilledMatrix;
  91. HashSet<int>[,] linesMatrix;
  92. /// <summary>
  93. /// Size of deletion area
  94. /// </summary>
  95. uint deletionSize = 2;
  96. /// <summary>
  97. /// History of Actions
  98. /// </summary>
  99. ActionHistory historyOfActions;
  100. /******************************************/
  101. /*** FORM SPECIFIC FUNCTIONS START HERE ***/
  102. /******************************************/
  103. private void Form1_Load(object sender, EventArgs e)
  104. {
  105. currentState = ProgramState.Idle;
  106. this.DoubleBuffered = true;
  107. historyOfActions = new ActionHistory(null);
  108. UpdateButtonStatus();
  109. }
  110. //Resize Function connected to the form resize event, will refresh the form when it is resized
  111. private void Form1_Resize(object sender, System.EventArgs e)
  112. {
  113. this.Refresh();
  114. }
  115. //Load button, will open an OpenFileDialog
  116. private void loadToolStripMenuItem_Click(object sender, EventArgs e)
  117. {
  118. openFileDialog.Filter = "Image|*.jpg;*.png;*.jpeg";
  119. if(openFileDialog.ShowDialog() == DialogResult.OK)
  120. {
  121. toolStripLoadStatus.Text = openFileDialog.SafeFileName;
  122. leftImage = Image.FromFile(openFileDialog.FileName);
  123. pictureBoxLeft.Image = leftImage;
  124. //Refresh the left image box when the content is changed
  125. this.Refresh();
  126. }
  127. UpdateButtonStatus();
  128. }
  129. /// <summary>
  130. /// Import example picture button, will open an OpenFileDialog
  131. /// </summary>
  132. private void examplePictureToolStripMenuItem_Click(object sender, EventArgs e)
  133. {
  134. openFileDialog.Filter = "Interactive Sketch-Assistant Drawing|*.isad";
  135. if (openFileDialog.ShowDialog() == DialogResult.OK)
  136. {
  137. toolStripLoadStatus.Text = openFileDialog.SafeFileName;
  138. try
  139. {
  140. (int, int, List<Line>) values = fileImporter.ParseISADInputFile(openFileDialog.FileName);
  141. DrawEmptyCanvasLeft(values.Item1, values.Item2);
  142. BindAndDrawLeftImage(values.Item3);
  143. this.Refresh();
  144. }
  145. catch(FileImporterException ex)
  146. {
  147. ShowInfoMessage(ex.ToString());
  148. }
  149. }
  150. }
  151. /// <summary>
  152. /// Import svg drawing button, will open an OpenFileDialog
  153. /// </summary>
  154. private void SVGDrawingToolStripMenuItem_Click(object sender, EventArgs e)
  155. {
  156. openFileDialog.Filter = "Scalable Vector Graphics|*.svg";
  157. if (openFileDialog.ShowDialog() == DialogResult.OK)
  158. {
  159. toolStripLoadStatus.Text = openFileDialog.SafeFileName;
  160. try
  161. {
  162. (int, int, List<Line>) drawing = fileImporter.ParseSVGInputFile(openFileDialog.FileName, pictureBoxLeft.Width, pictureBoxLeft.Height);
  163. DrawEmptyCanvasLeft(drawing.Item1, drawing.Item2);
  164. BindAndDrawLeftImage(drawing.Item3);
  165. this.Refresh();
  166. }
  167. catch (FileImporterException ex)
  168. {
  169. ShowInfoMessage(ex.ToString());
  170. }
  171. catch (Exception ex)
  172. {
  173. ShowInfoMessage("exception occured while trying to parse svg file:\n\n" + ex.ToString() + "\n\n" + ex.StackTrace);
  174. }
  175. }
  176. }
  177. //Changes the state of the program to drawing
  178. private void drawButton_Click(object sender, EventArgs e)
  179. {
  180. if(rightImage != null)
  181. {
  182. if (currentState.Equals(ProgramState.Draw))
  183. {
  184. ChangeState(ProgramState.Idle);
  185. }
  186. else
  187. {
  188. ChangeState(ProgramState.Draw);
  189. }
  190. }
  191. UpdateButtonStatus();
  192. }
  193. //Changes the state of the program to deletion
  194. private void deleteButton_Click(object sender, EventArgs e)
  195. {
  196. if (rightImage != null)
  197. {
  198. if (currentState.Equals(ProgramState.Delete))
  199. {
  200. ChangeState(ProgramState.Idle);
  201. }
  202. else
  203. {
  204. ChangeState(ProgramState.Delete);
  205. }
  206. }
  207. UpdateButtonStatus();
  208. }
  209. //Undo an action
  210. private void undoButton_Click(object sender, EventArgs e)
  211. {
  212. if (historyOfActions.CanUndo())
  213. {
  214. HashSet<int> affectedLines = historyOfActions.GetCurrentAction().GetLineIDs();
  215. SketchAction.ActionType undoAction = historyOfActions.GetCurrentAction().GetActionType();
  216. switch (undoAction)
  217. {
  218. case SketchAction.ActionType.Delete:
  219. //Deleted Lines need to be shown
  220. ChangeLines(affectedLines, true);
  221. break;
  222. case SketchAction.ActionType.Draw:
  223. //Drawn lines need to be hidden
  224. ChangeLines(affectedLines, false);
  225. break;
  226. default:
  227. break;
  228. }
  229. }
  230. historyOfActions.MoveAction(true);
  231. UpdateButtonStatus();
  232. }
  233. //Redo an action
  234. private void redoButton_Click(object sender, EventArgs e)
  235. {
  236. if (historyOfActions.CanRedo())
  237. {
  238. historyOfActions.MoveAction(false);
  239. HashSet<int> affectedLines = historyOfActions.GetCurrentAction().GetLineIDs();
  240. SketchAction.ActionType redoAction = historyOfActions.GetCurrentAction().GetActionType();
  241. switch (redoAction)
  242. {
  243. case SketchAction.ActionType.Delete:
  244. //Deleted Lines need to be redeleted
  245. ChangeLines(affectedLines, false);
  246. break;
  247. case SketchAction.ActionType.Draw:
  248. //Drawn lines need to be redrawn
  249. ChangeLines(affectedLines, true);
  250. break;
  251. default:
  252. break;
  253. }
  254. }
  255. UpdateButtonStatus();
  256. }
  257. //Detect Keyboard Shortcuts
  258. private void Form1_KeyDown(object sender, KeyEventArgs e)
  259. {
  260. if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Z)
  261. {
  262. undoButton_Click(sender, e);
  263. }
  264. if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Y)
  265. {
  266. redoButton_Click(sender, e);
  267. }
  268. }
  269. //get current Mouse positon within the right picture box
  270. private void pictureBoxRight_MouseMove(object sender, MouseEventArgs e)
  271. {
  272. currentCursorPosition = ConvertCoordinates(new Point(e.X, e.Y));
  273. }
  274. //hold left mouse button to draw.
  275. private void pictureBoxRight_MouseDown(object sender, MouseEventArgs e)
  276. {
  277. mousePressed = true;
  278. if (currentState.Equals(ProgramState.Draw))
  279. {
  280. currentLine = new List<Point>();
  281. }
  282. }
  283. //Lift left mouse button to stop drawing and add a new Line.
  284. private void pictureBoxRight_MouseUp(object sender, MouseEventArgs e)
  285. {
  286. mousePressed = false;
  287. if (currentState.Equals(ProgramState.Draw) && currentLine.Count > 0)
  288. {
  289. Line newLine = new Line(currentLine, rightLineList.Count);
  290. rightLineList.Add(new Tuple<bool, Line>(true, newLine));
  291. newLine.PopulateMatrixes(isFilledMatrix, linesMatrix);
  292. historyOfActions.AddNewAction(new SketchAction(SketchAction.ActionType.Draw, newLine.GetID()));
  293. }
  294. UpdateButtonStatus();
  295. }
  296. //Button to create a new Canvas. Will create an empty image
  297. //which is the size of the left image, if there is one.
  298. //If there is no image loaded the canvas will be the size of the right picture box
  299. private void canvasButton_Click(object sender, EventArgs e)
  300. {
  301. if (!historyOfActions.IsEmpty())
  302. {
  303. if (MessageBox.Show("You have unsaved changes, creating a new canvas will discard these.",
  304. "Attention", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
  305. {
  306. historyOfActions = new ActionHistory(lastActionTakenLabel);
  307. DrawEmptyCanvasRight();
  308. //The following lines cannot be in DrawEmptyCanvas()
  309. isFilledMatrix = new bool[rightImage.Width, rightImage.Height];
  310. linesMatrix = new HashSet<int>[rightImage.Width, rightImage.Height];
  311. rightLineList = new List<Tuple<bool, Line>>();
  312. }
  313. }
  314. else
  315. {
  316. historyOfActions = new ActionHistory(lastActionTakenLabel);
  317. DrawEmptyCanvasRight();
  318. //The following lines cannot be in DrawEmptyCanvas()
  319. isFilledMatrix = new bool[rightImage.Width, rightImage.Height];
  320. linesMatrix = new HashSet<int>[rightImage.Width, rightImage.Height];
  321. rightLineList = new List<Tuple<bool, Line>>();
  322. }
  323. UpdateButtonStatus();
  324. }
  325. //add a Point on every tick to the Drawpath
  326. private void mouseTimer_Tick(object sender, EventArgs e)
  327. {
  328. cursorPositions.Enqueue(currentCursorPosition);
  329. previousCursorPosition = cursorPositions.Dequeue();
  330. if (currentState.Equals(ProgramState.Draw) && mousePressed)
  331. {
  332. currentLine.Add(currentCursorPosition);
  333. Line drawline = new Line(currentLine);
  334. drawline.DrawLine(rightGraph);
  335. pictureBoxRight.Image = rightImage;
  336. }
  337. if (currentState.Equals(ProgramState.Delete) && mousePressed)
  338. {
  339. List<Point> uncheckedPoints = Line.BresenhamLineAlgorithm(previousCursorPosition, currentCursorPosition);
  340. foreach (Point currPoint in uncheckedPoints)
  341. {
  342. HashSet<int> linesToDelete = CheckDeletionMatrixesAroundPoint(currPoint, deletionSize);
  343. if (linesToDelete.Count > 0)
  344. {
  345. historyOfActions.AddNewAction(new SketchAction(SketchAction.ActionType.Delete, linesToDelete));
  346. foreach (int lineID in linesToDelete)
  347. {
  348. rightLineList[lineID] = new Tuple<bool, Line>(false, rightLineList[lineID].Item2);
  349. }
  350. RepopulateDeletionMatrixes();
  351. RedrawRightImage();
  352. }
  353. }
  354. }
  355. }
  356. /***********************************/
  357. /*** HELPER FUNCTIONS START HERE ***/
  358. /***********************************/
  359. /// <summary>
  360. /// Creates an empty Canvas
  361. /// </summary>
  362. private void DrawEmptyCanvasRight()
  363. {
  364. if (leftImage == null)
  365. {
  366. rightImage = new Bitmap(pictureBoxRight.Width, pictureBoxRight.Height);
  367. rightGraph = Graphics.FromImage(rightImage);
  368. rightGraph.FillRectangle(Brushes.White, 0, 0, pictureBoxRight.Width + 10, pictureBoxRight.Height + 10);
  369. pictureBoxRight.Image = rightImage;
  370. }
  371. else
  372. {
  373. rightImage = new Bitmap(leftImage.Width, leftImage.Height);
  374. rightGraph = Graphics.FromImage(rightImage);
  375. rightGraph.FillRectangle(Brushes.White, 0, 0, leftImage.Width + 10, leftImage.Height + 10);
  376. pictureBoxRight.Image = rightImage;
  377. }
  378. this.Refresh();
  379. pictureBoxRight.Refresh();
  380. }
  381. /// <summary>
  382. /// Creates an empty Canvas on the left
  383. /// </summary>
  384. /// <param name="width"> width of the new canvas in pixels </param>
  385. /// <param name="height"> height of the new canvas in pixels </param>
  386. private void DrawEmptyCanvasLeft(int width, int height)
  387. {
  388. if (width == 0)
  389. {
  390. leftImage = new Bitmap(pictureBoxLeft.Width, pictureBoxLeft.Height);
  391. }
  392. else
  393. {
  394. leftImage = new Bitmap(width, height);
  395. }
  396. Graphics.FromImage(leftImage).FillRectangle(Brushes.White, 0, 0, pictureBoxLeft.Width + 10, pictureBoxLeft.Height + 10);
  397. pictureBoxLeft.Image = leftImage;
  398. this.Refresh();
  399. pictureBoxLeft.Refresh();
  400. }
  401. /// <summary>
  402. /// Redraws all lines in lineList, for which their associated boolean value equals true.
  403. /// </summary>
  404. private void RedrawRightImage()
  405. {
  406. DrawEmptyCanvasRight();
  407. foreach (Tuple<bool, Line> lineBoolTuple in rightLineList)
  408. {
  409. if (lineBoolTuple.Item1)
  410. {
  411. lineBoolTuple.Item2.DrawLine(rightGraph);
  412. }
  413. }
  414. pictureBoxRight.Refresh();
  415. }
  416. /// <summary>
  417. /// Change the status of whether or not the lines are shown.
  418. /// </summary>
  419. /// <param name="lines">The HashSet containing the affected Line IDs.</param>
  420. /// <param name="shown">True if the lines should be shown, false if they should be hidden.</param>
  421. private void ChangeLines(HashSet<int> lines, bool shown)
  422. {
  423. foreach (int lineId in lines)
  424. {
  425. if (lineId <= rightLineList.Count - 1 && lineId >= 0)
  426. {
  427. rightLineList[lineId] = new Tuple<bool, Line>(shown, rightLineList[lineId].Item2);
  428. }
  429. }
  430. RedrawRightImage();
  431. }
  432. /// <summary>
  433. /// Updates the active status of buttons. Currently draw, delete, undo and redo button.
  434. /// </summary>
  435. private void UpdateButtonStatus()
  436. {
  437. undoButton.Enabled = historyOfActions.CanUndo();
  438. redoButton.Enabled = historyOfActions.CanRedo();
  439. drawButton.Enabled = (rightImage != null);
  440. deleteButton.Enabled = (rightImage != null);
  441. }
  442. /// <summary>
  443. /// A helper function which handles tasks associated witch changing states,
  444. /// such as checking and unchecking buttons and changing the state.
  445. /// </summary>
  446. /// <param name="newState">The new state of the program</param>
  447. private void ChangeState(ProgramState newState)
  448. {
  449. switch (currentState)
  450. {
  451. case ProgramState.Draw:
  452. drawButton.CheckState = CheckState.Unchecked;
  453. mouseTimer.Enabled = false;
  454. break;
  455. case ProgramState.Delete:
  456. deleteButton.CheckState = CheckState.Unchecked;
  457. mouseTimer.Enabled = false;
  458. break;
  459. default:
  460. break;
  461. }
  462. switch (newState)
  463. {
  464. case ProgramState.Draw:
  465. drawButton.CheckState = CheckState.Checked;
  466. mouseTimer.Enabled = true;
  467. break;
  468. case ProgramState.Delete:
  469. deleteButton.CheckState = CheckState.Checked;
  470. mouseTimer.Enabled = true;
  471. break;
  472. default:
  473. break;
  474. }
  475. currentState = newState;
  476. pictureBoxRight.Refresh();
  477. }
  478. /// <summary>
  479. /// A function that calculates the coordinates of a point on a zoomed in image.
  480. /// </summary>
  481. /// <param name="">The position of the mouse cursor</param>
  482. /// <returns>The real coordinates of the mouse cursor on the image</returns>
  483. private Point ConvertCoordinates(Point cursorPosition)
  484. {
  485. Point realCoordinates = new Point(5,3);
  486. if(pictureBoxRight.Image == null)
  487. {
  488. return cursorPosition;
  489. }
  490. int widthImage = pictureBoxRight.Image.Width;
  491. int heightImage = pictureBoxRight.Image.Height;
  492. int widthBox = pictureBoxRight.Width;
  493. int heightBox = pictureBoxRight.Height;
  494. float imageRatio = (float)widthImage / (float)heightImage;
  495. float containerRatio = (float)widthBox / (float)heightBox;
  496. if (imageRatio >= containerRatio)
  497. {
  498. //Image is wider than it is high
  499. float zoomFactor = (float)widthImage / (float)widthBox;
  500. float scaledHeight = heightImage / zoomFactor;
  501. float filler = (heightBox - scaledHeight) / 2;
  502. realCoordinates.X = (int)(cursorPosition.X * zoomFactor);
  503. realCoordinates.Y = (int)((cursorPosition.Y - filler) * zoomFactor);
  504. }
  505. else
  506. {
  507. //Image is higher than it is wide
  508. float zoomFactor = (float)heightImage / (float)heightBox;
  509. float scaledWidth = widthImage / zoomFactor;
  510. float filler = (widthBox - scaledWidth) / 2;
  511. realCoordinates.X = (int)((cursorPosition.X - filler) * zoomFactor);
  512. realCoordinates.Y = (int)(cursorPosition.Y * zoomFactor);
  513. }
  514. return realCoordinates;
  515. }
  516. /// <summary>
  517. /// A function that populates the matrixes needed for deletion detection with line data.
  518. /// </summary>
  519. private void RepopulateDeletionMatrixes()
  520. {
  521. if(rightImage != null)
  522. {
  523. isFilledMatrix = new bool[rightImage.Width,rightImage.Height];
  524. linesMatrix = new HashSet<int>[rightImage.Width, rightImage.Height];
  525. foreach(Tuple<bool,Line> lineTuple in rightLineList)
  526. {
  527. if (lineTuple.Item1)
  528. {
  529. lineTuple.Item2.PopulateMatrixes(isFilledMatrix, linesMatrix);
  530. }
  531. }
  532. }
  533. }
  534. /// <summary>
  535. /// A function that checks the deletion matrixes at a certain point
  536. /// and returns all Line ids at that point and in a square around it in a certain range.
  537. /// </summary>
  538. /// <param name="p">The point around which to check.</param>
  539. /// <param name="range">The range around the point. If range is 0, only the point is checked.</param>
  540. /// <returns>A List of all lines.</returns>
  541. private HashSet<int> CheckDeletionMatrixesAroundPoint(Point p, uint range)
  542. {
  543. HashSet<int> returnSet = new HashSet<int>();
  544. if (p.X >= 0 && p.Y >= 0 && p.X < rightImage.Width && p.Y < rightImage.Height)
  545. {
  546. if (isFilledMatrix[p.X, p.Y])
  547. {
  548. returnSet.UnionWith(linesMatrix[p.X, p.Y]);
  549. }
  550. }
  551. for (int x_mod = (int)range*(-1); x_mod < range; x_mod++)
  552. {
  553. for (int y_mod = (int)range * (-1); y_mod < range; y_mod++)
  554. {
  555. if (p.X + x_mod >= 0 && p.Y + y_mod >= 0 && p.X + x_mod < rightImage.Width && p.Y + y_mod < rightImage.Height)
  556. {
  557. if (isFilledMatrix[p.X + x_mod, p.Y + y_mod])
  558. {
  559. returnSet.UnionWith(linesMatrix[p.X + x_mod, p.Y + y_mod]);
  560. }
  561. }
  562. }
  563. }
  564. return returnSet;
  565. }
  566. /// <summary>
  567. /// binds the given picture to templatePicture and draws it
  568. /// </summary>
  569. /// <param name="newTemplatePicture"> the new template picture, represented as a list of polylines </param>
  570. /// <returns></returns>
  571. private void BindAndDrawLeftImage(List<Line> newTemplatePicture)
  572. {
  573. leftLineList = newTemplatePicture;
  574. foreach(Line l in leftLineList)
  575. {
  576. l.DrawLine(Graphics.FromImage(leftImage));
  577. }
  578. }
  579. /// <summary>
  580. /// shows the given info message in a popup and asks the user to aknowledge it
  581. /// </summary>
  582. /// <param name="message">the message to show</param>
  583. private void ShowInfoMessage(String message)
  584. {
  585. MessageBox.Show(message);
  586. }
  587. /// <summary>
  588. /// returns all instance variables in the order of their definition for testing
  589. /// </summary>
  590. /// <returns>all instance variables in the order of their definition</returns>
  591. public Object[]/*(ProgramState, FileImporter, OpenFileDialog, Image, List<Line>, Image, List<Point>, List<Tuple<bool, Line>>, bool, Point, Point, Queue<Point>, Graphics, bool[,], HashSet<int>[,], uint, ActionHistory)*/ GetAllVariables()
  592. {
  593. return new Object[] { currentState, fileImporter, openFileDialog, leftImage, leftLineList, rightImage, currentLine, rightLineList, mousePressed, currentCursorPosition, previousCursorPosition, cursorPositions, rightGraph, isFilledMatrix, linesMatrix, deletionSize, historyOfActions };
  594. }
  595. /// <summary>
  596. /// public method wrapper for testing purposes, invoking DrawEmptyCanvas(...) and BindAndDrawLeftImage(...)
  597. /// </summary>
  598. /// <param name="width">width of the parsed image</param>
  599. /// <param name="height">height of the parsed image</param>
  600. /// <param name="newImage">the parsed image</param>
  601. public void CreateCanvasAndSetPictureForTesting(int width, int height, List<Line> newImage)
  602. {
  603. DrawEmptyCanvasLeft(width, height);
  604. BindAndDrawLeftImage(newImage);
  605. }
  606. }
  607. }