Esempio n. 1
0
        /// <summary>
        ///   Add new object to draw area. Function is called when user left-clicks draw area, and one of ToolObject-derived tools is active.
        /// </summary>
        /// <param name="drawArea"> </param>
        /// <param name="o"> </param>
        protected void AddNewObject(TransparentCanvas drawArea, DrawObject o)
        {
            drawArea.GraphicsList.UnselectAll();

            o.Selected = true;
            drawArea.GraphicsList.Add(o);

            drawArea.Capture = true;
            drawArea.Refresh();

            drawArea.SetDirty();
        }
Esempio n. 2
0
        /// <summary>
        ///   Add new object to draw area. Function is called when user left-clicks draw area, and one of ToolObject-derived tools is active.
        /// </summary>
        /// <param name="drawArea"> </param>
        /// <param name="o"> </param>
        protected void AddNewObject(TransparentCanvas drawArea, DrawObject o)
        {
            drawArea.GraphicsList.UnselectAll();

            o.Selected = true;
            drawArea.GraphicsList.Add(o);

            drawArea.Capture = true;
            drawArea.Refresh();

            drawArea.SetDirty();
        }
Esempio n. 3
0
        /// <summary>
        ///   Mouse is moved. None button is pressed, or left button is pressed.
        /// </summary>
        /// <param name="drawArea"> </param>
        /// <param name="e"> </param>
        public override void OnMouseMove(TransparentCanvas drawArea, MouseEventArgs e)
        {
            Point point = new Point(e.X, e.Y);
            Point oldPoint = _lastPoint;

            _wasMove = true;

            // set cursor when mouse button is not pressed
            if (e.Button == MouseButtons.None)
            {
                Cursor cursor = null;

                for (int i = 0; i < drawArea.GraphicsList.Count; i++)
                {
                    int n = drawArea.GraphicsList[i].HitTest(point);

                    if (n > 0)
                    {
                        cursor = drawArea.GraphicsList[i].GetHandleCursor(n);
                        break;
                    }
                }

                if (cursor == null)
                {
                    cursor = Cursors.Default;
                }

                drawArea.Cursor = cursor;

                return;
            }

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

            // Find difference between previous and current position
            int dx = e.X - _lastPoint.X;
            int dy = e.Y - _lastPoint.Y;

            _lastPoint.X = e.X;
            _lastPoint.Y = e.Y;

            // resize
            if (_selectMode == SelectionMode.Size)
            {
                if (_resizedObject != null)
                {
                    _resizedObject.MoveHandleTo(point, _resizedObjectHandle);
                    drawArea.SetDirty();
                    drawArea.Refresh();
                }
            }

            // move
            if (_selectMode == SelectionMode.Move)
            {
                foreach (DrawObject o in drawArea.GraphicsList.Selection)
                {
                    o.Move(dx, dy);
                }

                drawArea.Cursor = Cursors.SizeAll;
                drawArea.SetDirty();
                drawArea.Refresh();
            }

            if (_selectMode == SelectionMode.NetSelection)
            {
                // Remove old selection rectangle
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, oldPoint)),
                    Color.Black,
                    FrameStyle.Dashed);

                // Draw new selection rectangle
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, point)),
                    Color.Black,
                    FrameStyle.Dashed);
            }
        }
Esempio n. 4
0
        /// <summary>
        ///   Mouse is moved. None button is pressed, or left button is pressed.
        /// </summary>
        /// <param name="drawArea"> </param>
        /// <param name="e"> </param>
        public override void OnMouseMove(TransparentCanvas drawArea, MouseEventArgs e)
        {
            Point point    = new Point(e.X, e.Y);
            Point oldPoint = _lastPoint;

            _wasMove = true;

            // set cursor when mouse button is not pressed
            if (e.Button == MouseButtons.None)
            {
                Cursor cursor = null;

                for (int i = 0; i < drawArea.GraphicsList.Count; i++)
                {
                    int n = drawArea.GraphicsList[i].HitTest(point);

                    if (n > 0)
                    {
                        cursor = drawArea.GraphicsList[i].GetHandleCursor(n);
                        break;
                    }
                }

                if (cursor == null)
                {
                    cursor = Cursors.Default;
                }

                drawArea.Cursor = cursor;

                return;
            }

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

            // Find difference between previous and current position
            int dx = e.X - _lastPoint.X;
            int dy = e.Y - _lastPoint.Y;

            _lastPoint.X = e.X;
            _lastPoint.Y = e.Y;

            // resize
            if (_selectMode == SelectionMode.Size)
            {
                if (_resizedObject != null)
                {
                    _resizedObject.MoveHandleTo(point, _resizedObjectHandle);
                    drawArea.SetDirty();
                    drawArea.Refresh();
                }
            }

            // move
            if (_selectMode == SelectionMode.Move)
            {
                foreach (DrawObject o in drawArea.GraphicsList.Selection)
                {
                    o.Move(dx, dy);
                }

                drawArea.Cursor = Cursors.SizeAll;
                drawArea.SetDirty();
                drawArea.Refresh();
            }

            if (_selectMode == SelectionMode.NetSelection)
            {
                // Remove old selection rectangle
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, oldPoint)),
                    Color.Black,
                    FrameStyle.Dashed);

                // Draw new selection rectangle
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, point)),
                    Color.Black,
                    FrameStyle.Dashed);
            }
        }