Example #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.MouseMove"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (DesignView.Context != null)
            {
                Size dragBoxSize = SystemInformation.DragSize;
                CurrentMousePoint = new Point(e.X, e.Y);
                int dx = CurrentMousePoint.X - FirstMousePoint.X;
                int dy = CurrentMousePoint.Y - FirstMousePoint.Y;
                if (!m_dragOverThreshold)
                {
                    if (Math.Abs(dx) > dragBoxSize.Width || Math.Abs(dy) > dragBoxSize.Height)
                    {
                        m_dragOverThreshold = true;
                        if (m_mouseDownAction == MouseDownAction.Manipulating)
                        {
                            DesignView.Manipulator.OnBeginDrag();
                        }
                    }
                }

                if (m_mouseDownAction == MouseDownAction.Picking)
                {
                    Invalidate();
                }
                else if (m_mouseDownAction == MouseDownAction.ControllingCamera)
                {
                    CameraController.MouseMove(this, e);
                }
                else if (m_mouseDownAction == MouseDownAction.Manipulating)
                {
                    if (m_dragOverThreshold)
                    {
                        DesignView.Manipulator.OnDragging(this, e.Location);
                        DesignView.Tick();
                        if (m_propEditor == null)
                        {
                            m_propEditor = Globals.MEFContainer.GetExportedValue <PropertyEditor>();
                        }
                        m_propEditor.PropertyGrid.RefreshProperties();
                    }
                }
                else if (DesignView.Manipulator != null)
                {
                    bool picked = DesignView.Manipulator.Pick(this, e.Location);
                    this.Cursor = picked ? Cursors.SizeAll : Cursors.Default;
                    DesignView.InvalidateViews();
                }
                else if (this.Cursor != Cursors.Default)
                {
                    this.Cursor = Cursors.Default;
                }
            }

            if (m_dragOverThreshold)
            {
                m_hitIndex = -1;
            }

            base.OnMouseMove(e);
        }
Example #2
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.MouseDown"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // reject additional mouse clicks until current is done.
            if (m_mouseDownAction != MouseDownAction.None)
            {
                return;
            }

            Focus();

            FirstMousePoint     = CurrentMousePoint = new Point(e.X, e.Y);
            m_dragOverThreshold = false;

            if (DesignView.Context != null)
            {
                bool handled = CameraController.MouseDown(this, e);
                if (handled)
                {
                    m_mouseDownAction = MouseDownAction.ControllingCamera;
                }
                else if (e.Button == MouseButtons.Left)
                {// either regular pick or manipulator pick.
                    if (DesignView.Manipulator != null && DesignView.Manipulator.Pick(this, e.Location))
                    {
                        m_mouseDownAction = MouseDownAction.Manipulating;
                    }
                    else
                    {
                        m_mouseDownAction = MouseDownAction.Picking;
                    }
                }
            }
            DesignView.InvalidateViews();
            base.OnMouseDown(e);
        }
Example #3
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (m_mouseDownAction == MouseDownAction.Picking)
            {
                HandlePick(e);
            }
            else if (m_mouseDownAction == MouseDownAction.ControllingCamera)
            {
                CameraController.MouseUp(this, e);
            }
            else if (m_mouseDownAction == MouseDownAction.Manipulating)
            {
                DesignView.Manipulator.OnEndDrag(this, e.Location);
            }
            else if (e.Button == MouseButtons.Right)
            {
                IEnumerable <IContextMenuCommandProvider>
                contextMenuCommandProviders = Globals.MEFContainer.GetExportedValues <IContextMenuCommandProvider>();

                Point clientPoint = new Point(e.X, e.Y);
                Point screenPoint = PointToScreen(clientPoint);

                object         target   = this;
                IList <object> pickList = Pick(e);
                if (pickList.Count > 0)
                {
                    Path <object> pickedObj = (Path <object>)pickList[0];
                    target = pickedObj.Last;
                }


                IEnumerable <object> commands =
                    contextMenuCommandProviders.GetCommands(DesignView.Context, target);

                ICommandService commandService = Globals.MEFContainer.GetExportedValue <ICommandService>();
                commandService.RunContextMenu(commands, screenPoint);
            }

            m_mouseDownAction = MouseDownAction.None;

            DesignView.InvalidateViews();
            base.OnMouseUp(e);
        }