Пример #1
0
        public void ToolMouseUp(object sender, MouseEventArgs e)
        {
            if (this.lineSegment != null)
            {
                if (e.Button == MouseButtons.Left)
                {
                    Point P = new Point();
                    lineSegment.Endpoint = new Point(e.X, e.Y);
                    lineSegment.iniSelect();

                    if (canvas.GetObjectAt(e.X, e.Y) is Vertex)
                    {
                        endingObject = (Vertex)canvas.GetObjectAt(e.X, e.Y);
                    }

                    if (startingObject != null)
                    {
                        P = startingObject.GetIntersectionPoint(lineSegment.Startpoint, lineSegment.Endpoint);
                        startingObject.Subscribe(lineSegment);
                        lineSegment.AddVertex(startingObject);
                        lineSegment.Startpoint = new Point(P.X, P.Y);
                    }
                    if (endingObject != null)
                    {
                        P = endingObject.GetIntersectionPoint(lineSegment.Startpoint, lineSegment.Endpoint);
                        endingObject.Subscribe(lineSegment);
                        lineSegment.AddVertex(endingObject);
                        lineSegment.Endpoint = new Point(P.X, P.Y);
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    canvas.RemoveDrawingObject(this.lineSegment);
                }
            }
        }