示例#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);
        }