Exemplo n.º 1
0
 /*******************************************************
  * New File Menu
  *
  * Arguments: Object Sender and EventArgs e
  * Return Type: void
  * Use Case:
  ******************************************************/
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     lines.Clear();
     strokes.Clear();
     PaintCanvas.Image = null;
     PaintCanvas.Refresh();
 }
Exemplo n.º 2
0
        /*******************************************************
         * Mouse Up Click
         *
         * Arguments: Object Sender and EventArgs e
         * Return Type: void
         * Use Case:
         ******************************************************/
        private void PaintCanvas_MouseUp(object sender, MouseEventArgs e)
        {
            if (isLineSelected && !point1.IsEmpty && !point2.IsEmpty)
            {
                Line newLine = new Line(selectedPen, point1, point2);
                lines.Add(newLine);
                UndoStack.Push("Line");

                PaintCanvas.Refresh();

                point1 = Point.Empty;
                point2 = Point.Empty;
            }

            if (isPencilSelected || isEraserSelected || isPaintSelected || isCustom)
            {
                strokes.Add(currentStroke);
                UndoStack.Push("Stroke");

                PaintCanvas.Refresh();

                currentStroke = new Stroke(selectedPen, new List <Point>());
            }

            Cursor = Cursors.Default;
        }
Exemplo n.º 3
0
        /*******************************************************
         * Undo button Click
         *
         * Arguments: Object Sender and EventArgs e
         * Return Type: void
         * Use Case:
         ******************************************************/
        private void UndoButton_Click(object sender, EventArgs e)
        {
            textBox1.Text = "Undo";
            if (UndoStack.Count > 0)
            {
                string      action = UndoStack.Pop();
                PaintAction newAction;

                switch (action)
                {
                case "Line":
                    newAction = lines[lines.Count - 1];
                    RedoStack.Push(newAction);

                    lines.RemoveAt(lines.Count - 1);
                    lines.TrimExcess();
                    break;

                case "Stroke":
                    newAction = strokes[strokes.Count - 1];
                    RedoStack.Push(newAction);

                    strokes.RemoveAt(strokes.Count - 1);
                    strokes.TrimExcess();
                    break;

                default:
                    Console.WriteLine("Undo Button Error!");
                    break;
                }
            }

            PaintCanvas.Refresh();
        }
Exemplo n.º 4
0
        /*******************************************************
         * Mouse Move Event
         *
         * Arguments: Object Sender and EventArgs e
         * Return Type: void
         * Use Case:
         ******************************************************/
        private void PaintCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && (isPencilSelected || isEraserSelected || isPaintSelected))

            {
                currentStroke.Points.Add(new Point(e.Location.X - 10, e.Location.Y + 10));

                PaintCanvas.Refresh();
            }
        }
Exemplo n.º 5
0
        /*******************************************************
         * Redo button Click
         *
         * Arguments: Object Sender and EventArgs e
         * Return Type: void
         * Use Case:
         ******************************************************/
        private void RedoButton_Click(object sender, EventArgs e)
        {
            textBox1.Text = "Redo";

            if (RedoStack.Count > 0)
            {
                var action = RedoStack.Pop();

                if (action is Line)
                {
                    lines.Add((Line)action);
                    UndoStack.Push("Line");
                    PaintCanvas.Refresh();
                }

                if (action is Stroke)
                {
                    strokes.Add((Stroke)action);
                    UndoStack.Push("Stroke");
                    PaintCanvas.Refresh();
                }
            }
        }