示例#1
0
        /// <summary>
        /// Clone this instance
        /// </summary>
        public override DrawObject Clone()
        {
            DrawConnector drawPolyLine = new DrawConnector();

            drawPolyLine.startPoint = startPoint;
            drawPolyLine.endPoint   = endPoint;
            drawPolyLine.pointArray = pointArray;

            FillDrawObjectFields(drawPolyLine);
            return(drawPolyLine);
        }
示例#2
0
        private bool _drawingInProcess = false;         // Set to true when drawing

        /// <summary>
        /// Left mouse button is pressed
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                _drawingInProcess = false;
                newConnector      = null;
            }
            else
            {
                Point p        = drawArea.BackTrackMouse(new Point(e.X, e.Y));
                int   objectID = -1;
                p = TestForConnection(drawArea, p, out objectID);
                if (drawArea.PenType == DrawingPens.PenType.Generic)
                {
                    if (_drawingInProcess == false)
                    {
                        newConnector          = new DrawConnector(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.LineColor, drawArea.LineWidth);
                        newConnector.EndPoint = new Point(p.X + 1, p.Y + 1);
                        if (objectID > -1)
                        {
                            newConnector.StartIsAnchored = true;
                            newConnector.StartObjectId   = objectID;
                        }
                        AddNewObject(drawArea, newConnector);
                        _drawingInProcess = true;
                    }
                    else
                    {
                        // Drawing is in process, so simply add a new point
                        newConnector.AddPoint(p);
                        newConnector.EndPoint = p;
                        if (objectID > -1)
                        {
                            newConnector.EndIsAnchored = true;
                            newConnector.EndObjectId   = objectID;
                            _drawingInProcess          = false;
                        }
                    }
                }
                else
                {
                    if (_drawingInProcess == false)
                    {
                        newConnector          = new DrawConnector(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.PenType);
                        newConnector.EndPoint = new Point(p.X + 1, p.Y + 1);
                        if (objectID > -1)
                        {
                            newConnector.StartIsAnchored = true;
                            newConnector.StartObjectId   = objectID;
                        }
                        AddNewObject(drawArea, newConnector);
                        _drawingInProcess = true;
                    }
                    else
                    {
                        // Drawing is in process, so simply add a new point
                        newConnector.AddPoint(p);
                        newConnector.EndPoint = p;
                        if (objectID > -1)
                        {
                            newConnector.EndIsAnchored = true;
                            newConnector.EndObjectId   = objectID;
                            _drawingInProcess          = false;
                        }
                    }
                }
            }
        }