Example #1
0
        public static void Main(string[] args)
        {
            Point  p1       = new Point(2.0, 1.0);
            Point  p2       = new Point(6.0, 4.0);
            Line   line1    = new Line(p1, p2);
            double length   = line1.Distance();
            Canvas myCanvas = new Canvas(3);

            myCanvas.AddLine(line1);
            int numberOfLines = myCanvas.numLines;

            myCanvas.Undo();
            numberOfLines = myCanvas.numLines;
            myCanvas.Undo();
            numberOfLines = myCanvas.numLines;
            myCanvas.AddLine(line1);
            Point p3    = new Point(0.0, 0.0);
            Point p4    = new Point(1.0, 1.0);
            Line  line2 = new Line(p3, p4);

            myCanvas.AddLine(line2);
            myCanvas.AddLine(line1);
            numberOfLines = myCanvas.numLines;
            myCanvas.AddLine(line2);
            numberOfLines = myCanvas.numLines;
        }
Example #2
0
        public override void MouseUp(MouseEventArgs e)
        {
            if (IsDrawing)
            {
                IsDrawing = false;

                // Mouse up means that we want to draw our final result, so we longer need creation shapes.
                CreationDrawable = null;

                // The final drawn result.
                DrawableLine line = GetDrawableLine(true);

                // Add final result to the Canvas.
                if (line.StartPoint != line.EndPoint)
                {
                    Canvas.AddLine(line);
                }

                RepaintCanvas();
            }
        }