Browse Source

Added comments to some functions.

Martin Edlund 5 years ago
parent
commit
737efbccad

+ 19 - 31
SketchAssistant/SketchAssistant/MVP_Model.cs

@@ -275,20 +275,6 @@ namespace SketchAssistant
         }
 
         /*
-        /// <summary>
-        /// binds the given picture to templatePicture and draws it
-        /// </summary>
-        /// <param name="newTemplatePicture"> the new template picture, represented as a list of polylines </param>
-        /// <returns></returns>
-        private void BindAndDrawLeftImage(List<Line> newTemplatePicture)
-        {
-            leftLineList = newTemplatePicture;
-            foreach (Line l in leftLineList)
-            {
-                l.DrawLine(Graphics.FromImage(leftImage));
-            }
-        }
-        
         /// <summary>
         /// Will calculate the start and endpoints of the given line on the right canvas.
         /// </summary>
@@ -314,23 +300,6 @@ namespace SketchAssistant
         }
 
 
-        /*
-        /// <summary>
-        /// Checks if there is unsaved progess, and warns the user. Returns True if it safe to continue.
-        /// </summary>
-        /// <returns>true if there is none, or the user wishes to continue without saving.
-        /// false if there is progress, and the user doesn't wish to continue.</returns>
-        private bool CheckSavedStatus()
-        {
-            if (!historyOfActions.IsEmpty())
-            {
-                return (MessageBox.Show("You have unsaved changes, do you wish to continue?",
-                    "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes);
-            }
-            return true;
-        }
-        */
-
         /********************************************/
         /*** FUNCTIONS TO INTERACT WITH PRESENTER ***/
         /********************************************/
@@ -378,6 +347,9 @@ namespace SketchAssistant
             rightLineList = new List<Tuple<bool, Line>>();
         }
 
+        /// <summary>
+        /// Will undo the last action taken, if the action history allows it.
+        /// </summary>
         public void Undo()
         {
             if (historyOfActions.CanUndo())
@@ -408,6 +380,9 @@ namespace SketchAssistant
             UpdateUI();
         }
 
+        /// <summary>
+        /// Will redo the last action undone, if the action history allows it.
+        /// </summary>
         public void Redo()
         {
             if (historyOfActions.CanRedo())
@@ -464,11 +439,18 @@ namespace SketchAssistant
             }
         }
 
+        /// <summary>
+        /// Updates the current cursor position of the model.
+        /// </summary>
+        /// <param name="p">The new cursor position</param>
         public void SetCurrentCursorPosition(Point p)
         {
             currentCursorPosition = p;
         }
 
+        /// <summary>
+        /// Start a new Line, when the Mouse is pressed down.
+        /// </summary>
         public void MouseDown()
         {
             mousePressed = true;
@@ -478,6 +460,9 @@ namespace SketchAssistant
             }
         }
 
+        /// <summary>
+        /// Finish the current Line, when the pressed Mouse is released.
+        /// </summary>
         public void MouseUp()
         {
             mousePressed = false;
@@ -497,6 +482,9 @@ namespace SketchAssistant
             UpdateUI();
         }
 
+        /// <summary>
+        /// Method to be called every tick. Updates the current Line, or checks for Lines to delete, depending on the drawing mode.
+        /// </summary>
         public void Tick()
         {
             if (cursorPositions.Count > 0) { previousCursorPosition = cursorPositions.Dequeue(); }

+ 34 - 0
SketchAssistant/SketchAssistant/MVP_Presenter.cs

@@ -53,6 +53,11 @@ namespace SketchAssistant
         /*** FUNCTIONS VIEW -> PRESENTER ***/
         /***********************************/
 
+        /// <summary>
+        /// Pass-trough function to update the appropriate information of the model, when the window is resized.
+        /// </summary>
+        /// <param name="leftPBS">The new size of the left picture box.</param>
+        /// <param name="rightPBS">The new size of the left picture box.</param>
         public void Resize(Tuple<int, int> leftPBS,Tuple<int, int> rightPBS)
         {
             programModel.leftImageBoxWidth = leftPBS.Item1;
@@ -86,21 +91,34 @@ namespace SketchAssistant
             }
         }
 
+        /// <summary>
+        /// Pass-trough function to change the drawing state of the model.
+        /// </summary>
+        /// <param name="NowDrawing">Indicates if the program is in drawing (true) or deletion (false) mode.</param>
         public void ChangeState(bool NowDrawing)
         {
             programModel.ChangeState(NowDrawing);
         }
 
+        /// <summary>
+        /// Pass-trough function to undo an action.
+        /// </summary>
         public void Undo()
         {
             programModel.Undo();
         }
 
+        /// <summary>
+        /// Pass-trough function to redo an action.
+        /// </summary>
         public void Redo()
         {
             programModel.Redo();
         }
 
+        /// <summary>
+        /// Checks if there is unsaved progress, and promts the model to generate a new canvas if not.
+        /// </summary>
         public void NewCanvas()
         {
             var okToContinue = true;
@@ -116,11 +134,19 @@ namespace SketchAssistant
             }
         }
 
+        /// <summary>
+        /// Pass-trough function for ticking the model.
+        /// </summary>
         public void Tick()
         {
             programModel.Tick();
         }
 
+        /// <summary>
+        /// Pass-trough function that calls the correct Mouse event of the model.
+        /// </summary>
+        /// <param name="mouseAction">The action which is sent by the View.</param>
+        /// <param name="e">The Mouse event arguments.</param>
         public void MouseEvent(MouseAction mouseAction, MouseEventArgs e)
         {
             switch (mouseAction)
@@ -196,11 +222,19 @@ namespace SketchAssistant
             programView.DisplayInRightPictureBox(img);
         }
 
+        /// <summary>
+        /// Pass-trough function to display an info message in the view.
+        /// </summary>
+        /// <param name="msg">The message.</param>
         public void PassMessageToView(String msg)
         {
             programView.ShowInfoMessage(msg);
         }
 
+        /// <summary>
+        /// Pass-trough function to update the display of the last action taken.
+        /// </summary>
+        /// <param name="msg">The new last action taken.</param>
         public void PassLastActionTaken(String msg)
         {
             programView.SetLastActionTakenText(msg);