Beispiel #1
0
        /// <summary>
        /// Mouse move - resize new polygon
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e)
        {
            drawArea.Cursor = Cursor;

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            if (newPolygon == null)
            {
                return;                 // precaution
            }
            Point point    = new Point(e.X, e.Y);
            int   distance = (e.X - lastX) * (e.X - lastX) + (e.Y - lastY) * (e.Y - lastY);

            if (distance < minDistance)
            {
                // Distance between last two points is less than minimum -
                // move last point
                newPolygon.MoveHandleTo(point, newPolygon.HandleCount);
            }
            else
            {
                // Add new point
                newPolygon.AddPoint(point);
                lastX = e.X;
                lastY = e.Y;
            }

            drawArea.Refresh();
        }
Beispiel #2
0
        private bool _drawingInProcess = false; // Set to true when drawing

        /// <summary>
        /// Left nouse 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;
                newPolyLine.DrawFinish();
                newPolyLine = null;
            }
            else
            {
                Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y));
                if (drawArea.PenType ==
                    DrawingPens.PenType.Generic)
                {
                    if (_drawingInProcess == false)
                    {
                        newPolyLine          = new DrawPolygon(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.LineColor, drawArea.LineWidth);
                        newPolyLine.EndPoint = new Point(p.X + 1, p.Y + 1);
                        AddNewObject(drawArea, newPolyLine);
                        _drawingInProcess = true;
                    }
                    else
                    {
                        // Drawing is in process, so simply add a new point
                        newPolyLine.AddPoint(p);
                        newPolyLine.EndPoint = p;
                    }
                }
                else
                {
                    if (_drawingInProcess == false)
                    {
                        newPolyLine          = new DrawPolygon(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.PenType);
                        newPolyLine.EndPoint = new Point(p.X + 1, p.Y + 1);
                        AddNewObject(drawArea, newPolyLine);
                        _drawingInProcess = true;
                    }
                    else
                    {
                        // Drawing is in process, so simply add a new point
                        newPolyLine.AddPoint(p);
                        newPolyLine.EndPoint = p;
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Mouse move - resize new polygon
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e)
        {
            drawArea.Cursor = Cursor;

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            if (_newPolygon == null)
            {
                return;                 // precaution
            }
            var point    = new Point(e.X, e.Y);
            int distance = (e.X - _lastX) * (e.X - _lastX) + (e.Y - _lastY) * (e.Y - _lastY);

            try
            {
                if (distance < MinDistance)
                {
                    // Distance between last two points is less than minimum -
                    // move last point
                    _newPolygon.MoveHandleTo(point, _newPolygon.HandleCount);
                }
                else
                {
                    // Add new point
                    _newPolygon.AddPoint(point);
                    _lastX = e.X;
                    _lastY = e.Y;
                }
                drawArea.Refresh();
            }
            catch (Exception ex)
            {
                ErrH.Log("ToolPolygon", "OnMouse", ex.ToString(), ErrH._LogPriority.Info);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Mouse move - resize new polygon
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseMove(ImageDrawBox drawArea, MouseEventArgs e)
        {
            Point p = GetEventPointInArea(drawArea, e);

            drawArea.Cursor = Cursor;

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            if (newPolygon == null)
            {
                return;                 // precaution
            }
            Point point    = new Point(p.X, p.Y);
            int   distance = (p.X - lastX) * (p.X - lastX) + (p.Y - lastY) * (p.Y - lastY);

            if (distance < minDistance)
            {
                // Distance between last two points is less than minimum -
                // move last pointscroll
                newPolygon.MoveHandleTo(point, newPolygon.HandleCount);
                drawArea.GraphicsList.Dirty = true;
            }
            else
            {
                // Add new pointscroll
                newPolygon.AddPoint(point);
                lastX = p.X;
                lastY = p.Y;
                drawArea.GraphicsList.Dirty = true;
            }

            drawArea.Refresh();
        }