Пример #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (m_selection != null)
            {
                Graphics dc = Graphics.FromHwnd(Handle);
                m_selection.SetMousePoint(dc, new PointF(e.X, e.Y));
                dc.Dispose();
                return;
            }
            if (moving) //如果有选中的区域正在移动
            {
                Invalidate();
                mr.moving(e.X - lastX, e.Y - lastY);
                lastX = e.X;
                lastY = e.Y;
            }
            if (ispaste) //如果有选中的区域正在移动
            {
                Invalidate();
                pr.moving(e.X - lastX, e.Y - lastY);
                lastX = e.X;
                lastY = e.Y;
            }
            UnitPoint mousepoint;

            if (m_commandType == eCommandType.draw || m_commandType == eCommandType.move || m_nodeMoveHelper.IsEmpty == false)
            {
                Rectangle  invalidaterect = Rectangle.Empty;
                ISnapPoint newsnap        = null;
                mousepoint = GetMousePoint();
                if (RunningSnapsEnabled)
                {
                    newsnap = m_model.SnapPoint(m_canvaswrapper, mousepoint, m_runningSnapTypes, null);
                }
                if (newsnap == null)
                {
                    newsnap = m_model.GridLayer.SnapPoint(m_canvaswrapper, mousepoint, null);
                }
                if ((m_snappoint != null) && ((newsnap == null) || (newsnap.SnapPoint != m_snappoint.SnapPoint) || m_snappoint.GetType() != newsnap.GetType()))
                {
                    invalidaterect = ScreenUtils.ConvertRect(ScreenUtils.ToScreenNormalized(m_canvaswrapper, m_snappoint.BoundingRect));
                    invalidaterect.Inflate(2, 2);
                    RepaintStatic(invalidaterect); // remove old snappoint
                    m_snappoint = newsnap;
                }
                //if (m_commandType == eCommandType.move)
                //    Invalidate(invalidaterect);

                if (m_snappoint == null)
                {
                    m_snappoint = newsnap;
                }
            }
            //////////////////////////////////////////////////////////////////////////

            //UnitPoint mousepoint;
            if (m_snappoint != null)
            {
                mousepoint = m_snappoint.SnapPoint;
            }
            else
            {
                mousepoint = GetMousePoint();
            }

            if (m_newObject != null)
            {
                Rectangle invalidaterect = ScreenUtils.ConvertRect(ScreenUtils.ToScreenNormalized(m_canvaswrapper, m_newObject.GetBoundingRect(m_canvaswrapper)));
                invalidaterect.Inflate(2, 2);
                RepaintStatic(invalidaterect);

                m_newObject.OnMouseMove(m_canvaswrapper, mousepoint);
                RepaintObject(m_newObject);
            }
            if (m_snappoint != null)
            {
                RepaintSnappoint(m_snappoint);
            }

            /*
             * if (m_moveHelper.HandleMouseMoveForMove(mousepoint))
             *  Refresh(); //Invalidate();
             *
             * RectangleF rNoderect = m_nodeMoveHelper.HandleMouseMoveForNode(mousepoint);
             *
             * if (rNoderect != RectangleF.Empty)
             * {
             *
             *  Rectangle invalidaterect = ScreenUtils.ConvertRect(ScreenUtils.ToScreenNormalized(m_canvaswrapper, rNoderect));
             *  RepaintStatic(invalidaterect);
             *
             *  CanvasWrapper dc = new CanvasWrapper(this, Graphics.FromHwnd(Handle), ClientRectangle);
             *  dc.Graphics.Clip = new Region(ClientRectangle);
             *  //m_nodeMoveHelper.DrawOriginalObjects(dc, rNoderect);
             *  m_nodeMoveHelper.DrawObjects(dc, rNoderect);
             *  if (m_snappoint != null)
             *      RepaintSnappoint(m_snappoint);
             *
             *  dc.Graphics.Dispose();
             *  dc.Dispose();
             * }
             */
        }