예제 #1
0
        /// <summary>
        ///   Right mouse button is released
        /// </summary>
        /// <param name="drawArea"> </param>
        /// <param name="e"> </param>
        public override void OnMouseUp(TransparentCanvas drawArea, MouseEventArgs e)
        {
            if (_selectMode == SelectionMode.NetSelection)
            {
                // Remove old selection rectangle
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)),
                    Color.Black,
                    FrameStyle.Dashed);

                // Make group selection
                drawArea.GraphicsList.SelectInRectangle(
                    DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint));

                _selectMode = SelectionMode.None;
            }

            if (_resizedObject != null)
            {
                // after resizing
                _resizedObject.Normalize();
                _resizedObject = null;
            }

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

            if (_commandChangeState != null && _wasMove)
            {
                // Keep state after moving/resizing and add command to history
                _commandChangeState.NewState(drawArea.GraphicsList);
                drawArea.AddCommandToHistory(_commandChangeState);
                _commandChangeState = null;
            }
        }
예제 #2
0
        /// <summary>
        ///   Show Properties dialog. Return true if list is changed
        /// </summary>
        /// <param name="parent"> </param>
        /// <returns> </returns>
        public bool ShowPropertiesDialog(TransparentCanvas parent)
        {
            if (SelectionCount < 1)
            {
                return(false);
            }

            GraphicsProperties properties = GetProperties();
//            var dlg = new PropertiesDialog();
//            dlg.Properties = properties;
//
            var c = new CommandChangeState(this);

//
//            if (dlg.ShowDialog(parent) != DialogResult.OK)
//            {
//                return false;
//            }

            if (ApplyProperties(properties))
            {
                c.NewState(this);
                parent.AddCommandToHistory(c);
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        ///   Left mouse button is pressed
        /// </summary>
        /// <param name="drawArea"> </param>
        /// <param name="e"> </param>
        public override void OnMouseDown(TransparentCanvas drawArea, MouseEventArgs e)
        {
            _commandChangeState = null;
            _wasMove = false;

            _selectMode = SelectionMode.None;
            Point point = new Point(e.X, e.Y);

            // Test for resizing (only if control is selected, cursor is on the handle)
            foreach (DrawObject o in drawArea.GraphicsList.Selection)
            {
                int handleNumber = o.HitTest(point);

                if (handleNumber > 0)
                {
                    _selectMode = SelectionMode.Size;

                    // keep resized object in class member
                    _resizedObject = o;
                    _resizedObjectHandle = handleNumber;

                    // Since we want to resize only one object, unselect all other objects
                    drawArea.GraphicsList.UnselectAll();
                    o.Selected = true;

                    _commandChangeState = new CommandChangeState(drawArea.GraphicsList);

                    break;
                }
            }

            // Test for move (cursor is on the object)
            if (_selectMode == SelectionMode.None)
            {
                int n1 = drawArea.GraphicsList.Count;
                DrawObject o = null;

                for (int i = 0; i < n1; i++)
                {
                    if (drawArea.GraphicsList[i].HitTest(point) == 0)
                    {
                        o = drawArea.GraphicsList[i];
                        break;
                    }
                }

                if (o != null)
                {
                    _selectMode = SelectionMode.Move;

                    // Unselect all if Ctrl is not pressed and clicked object is not selected yet
                    if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected)
                    {
                        drawArea.GraphicsList.UnselectAll();
                    }

                    // Select clicked object
                    o.Selected = true;

                    _commandChangeState = new CommandChangeState(drawArea.GraphicsList);

                    drawArea.Cursor = Cursors.SizeAll;
                }
            }

            // Net selection
            if (_selectMode == SelectionMode.None)
            {
                // click on background
                if ((Control.ModifierKeys & Keys.Control) == 0)
                {
                    drawArea.GraphicsList.UnselectAll();
                }

                _selectMode = SelectionMode.NetSelection;
            }

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

            drawArea.Capture = true;

            drawArea.Refresh();

            if (_selectMode == SelectionMode.NetSelection)
            {
                // Draw selection rectangle in initial position
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)),
                    Color.Black,
                    FrameStyle.Dashed);
            }
        }
예제 #4
0
        /// <summary>
        ///   Right mouse button is released
        /// </summary>
        /// <param name="drawArea"> </param>
        /// <param name="e"> </param>
        public override void OnMouseUp(TransparentCanvas drawArea, MouseEventArgs e)
        {
            if (_selectMode == SelectionMode.NetSelection)
            {
                // Remove old selection rectangle
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)),
                    Color.Black,
                    FrameStyle.Dashed);

                // Make group selection
                drawArea.GraphicsList.SelectInRectangle(
                    DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint));

                _selectMode = SelectionMode.None;
            }

            if (_resizedObject != null)
            {
                // after resizing
                _resizedObject.Normalize();
                _resizedObject = null;
            }

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

            if (_commandChangeState != null && _wasMove)
            {
                // Keep state after moving/resizing and add command to history
                _commandChangeState.NewState(drawArea.GraphicsList);
                drawArea.AddCommandToHistory(_commandChangeState);
                _commandChangeState = null;
            }
        }
예제 #5
0
        /// <summary>
        ///   Left mouse button is pressed
        /// </summary>
        /// <param name="drawArea"> </param>
        /// <param name="e"> </param>
        public override void OnMouseDown(TransparentCanvas drawArea, MouseEventArgs e)
        {
            _commandChangeState = null;
            _wasMove            = false;

            _selectMode = SelectionMode.None;
            Point point = new Point(e.X, e.Y);

            // Test for resizing (only if control is selected, cursor is on the handle)
            foreach (DrawObject o in drawArea.GraphicsList.Selection)
            {
                int handleNumber = o.HitTest(point);

                if (handleNumber > 0)
                {
                    _selectMode = SelectionMode.Size;

                    // keep resized object in class member
                    _resizedObject       = o;
                    _resizedObjectHandle = handleNumber;

                    // Since we want to resize only one object, unselect all other objects
                    drawArea.GraphicsList.UnselectAll();
                    o.Selected = true;

                    _commandChangeState = new CommandChangeState(drawArea.GraphicsList);

                    break;
                }
            }

            // Test for move (cursor is on the object)
            if (_selectMode == SelectionMode.None)
            {
                int        n1 = drawArea.GraphicsList.Count;
                DrawObject o  = null;

                for (int i = 0; i < n1; i++)
                {
                    if (drawArea.GraphicsList[i].HitTest(point) == 0)
                    {
                        o = drawArea.GraphicsList[i];
                        break;
                    }
                }

                if (o != null)
                {
                    _selectMode = SelectionMode.Move;

                    // Unselect all if Ctrl is not pressed and clicked object is not selected yet
                    if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected)
                    {
                        drawArea.GraphicsList.UnselectAll();
                    }

                    // Select clicked object
                    o.Selected = true;

                    _commandChangeState = new CommandChangeState(drawArea.GraphicsList);

                    drawArea.Cursor = Cursors.SizeAll;
                }
            }

            // Net selection
            if (_selectMode == SelectionMode.None)
            {
                // click on background
                if ((Control.ModifierKeys & Keys.Control) == 0)
                {
                    drawArea.GraphicsList.UnselectAll();
                }

                _selectMode = SelectionMode.NetSelection;
            }

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

            drawArea.Capture = true;

            drawArea.Refresh();

            if (_selectMode == SelectionMode.NetSelection)
            {
                // Draw selection rectangle in initial position
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)),
                    Color.Black,
                    FrameStyle.Dashed);
            }
        }
예제 #6
0
        /// <summary>
        ///   Show Properties dialog. Return true if list is changed
        /// </summary>
        /// <param name="parent"> </param>
        /// <returns> </returns>
        public bool ShowPropertiesDialog(TransparentCanvas parent)
        {
            if (SelectionCount < 1)
            {
                return false;
            }

            GraphicsProperties properties = GetProperties();
//            var dlg = new PropertiesDialog();
//            dlg.Properties = properties;
//
            var c = new CommandChangeState(this);
//
//            if (dlg.ShowDialog(parent) != DialogResult.OK)
//            {
//                return false;
//            }

            if (ApplyProperties(properties))
            {
                c.NewState(this);
                parent.AddCommandToHistory(c);
            }

            return true;
        }