Form1.cs 25 KB

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