protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            // If we are dragging an element....
            if (this.m_Multiselecting)
            {
                this.m_MultiselectPreviousEndX = this.m_MultiselectEndX;
                this.m_MultiselectPreviousEndY = this.m_MultiselectEndY;
                this.m_MultiselectEndX = e.X;
                this.m_MultiselectEndY = e.Y;
                var r = new Rectangle(
                    this.m_MultiselectStartX,
                    this.m_MultiselectStartY,
                    this.m_MultiselectPreviousEndX - this.m_MultiselectStartX,
                    this.m_MultiselectPreviousEndY - this.m_MultiselectStartY);
                r.Inflate(r.Width > 0 ? 10 : -10, r.Height > 0 ? 10 : -10);
                this.Invalidate(r.Fix());
            }
            else if (this.m_SelectedElementStillHeldDown && (this.m_SelectedElement != null || this.m_SelectedElements.Count > 1))
            {
                var toMove = this.m_SelectedElements;

                if (this.m_SelectedElements.Count <= 1 && this.m_SelectedElement != null)
                {
                    toMove = new ListOfFlowElements { this.m_SelectedElement };
                }

                foreach (var el in toMove)
                {
                    this.Invalidate(el.InvalidatingRegion.Apply(this.Zoom).Fix());
                    foreach (Rectangle r in el.GetConnectorRegionsToInvalidate())
                    {
                        this.Invalidate(r.Apply(this.Zoom).Fix());
                    }

                    el.X = (int)(e.X / this.Zoom) - this.m_SelectedElementsDrag[el].X;
                    el.Y = (int)(e.Y / this.Zoom) - this.m_SelectedElementsDrag[el].Y;
                    this.Invalidate(el.InvalidatingRegion.Apply(this.Zoom));

                    foreach (Rectangle r in el.GetConnectorRegionsToInvalidate())
                    {
                        this.Invalidate(r.Apply(this.Zoom).Fix());
                    }
                }
            }
            else if (this.m_PanningStillHeldDown)
            {
                this.Invalidate();
                this.m_AllElementPanX = e.X;
                this.m_AllElementPanY = e.Y;
                foreach (FlowElement el in this.m_Elements)
                {
                    el.X += (int)((this.m_AllElementPanX - this.m_AllElementPanOldX) / this.Zoom);
                    el.Y += (int)((this.m_AllElementPanY - this.m_AllElementPanOldY) / this.Zoom);
                }
                this.m_AllElementPanOldX = this.m_AllElementPanX;
                this.m_AllElementPanOldY = this.m_AllElementPanY;
            }
            else if (this.m_ActiveConnection != null)
            {
                var r = new Rectangle(
                    this.m_ActiveConnection.Center.X,
                    this.m_ActiveConnection.Center.Y,
                    this.m_MouseActiveConnectionLocation.X - this.m_ActiveConnection.Center.X,
                    this.m_MouseActiveConnectionLocation.Y - this.m_ActiveConnection.Center.Y);
                r.Inflate(r.Width > 0 ? 10 : -10, r.Height > 0 ? 10 : -10);
                this.Invalidate(r.Fix());
                r = new Rectangle(
                    this.m_ActiveConnection.Center.X,
                    this.m_ActiveConnection.Center.Y,
                    e.X - this.m_ActiveConnection.Center.X,
                    e.Y - this.m_ActiveConnection.Center.Y);
                r.Inflate(r.Width > 0 ? 10 : -10, r.Height > 0 ? 10 : -10);
                this.Invalidate(r.Fix());
            }
            this.m_MouseActiveConnectionLocation = new Point(
                e.X,
                e.Y
            );
        }
Ejemplo n.º 2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            // If we are dragging an element....
            if (this.m_Multiselecting)
            {
                this.m_MultiselectPreviousEndX = this.m_MultiselectEndX;
                this.m_MultiselectPreviousEndY = this.m_MultiselectEndY;
                this.m_MultiselectEndX         = e.X;
                this.m_MultiselectEndY         = e.Y;
                var r = new Rectangle(
                    this.m_MultiselectStartX,
                    this.m_MultiselectStartY,
                    this.m_MultiselectPreviousEndX - this.m_MultiselectStartX,
                    this.m_MultiselectPreviousEndY - this.m_MultiselectStartY);
                r.Inflate(r.Width > 0 ? 10 : -10, r.Height > 0 ? 10 : -10);
                this.Invalidate(r.Fix());
            }
            else if (this.m_SelectedElementStillHeldDown && (this.m_SelectedElement != null || this.m_SelectedElements.Count > 1))
            {
                var toMove = this.m_SelectedElements;

                if (this.m_SelectedElements.Count <= 1 && this.m_SelectedElement != null)
                {
                    toMove = new ListOfFlowElements {
                        this.m_SelectedElement
                    };
                }

                foreach (var el in toMove)
                {
                    this.Invalidate(el.InvalidatingRegion.Apply(this.Zoom).Fix());
                    foreach (Rectangle r in el.GetConnectorRegionsToInvalidate())
                    {
                        this.Invalidate(r.Apply(this.Zoom).Fix());
                    }

                    el.X = (int)(e.X / this.Zoom) - this.m_SelectedElementsDrag[el].X;
                    el.Y = (int)(e.Y / this.Zoom) - this.m_SelectedElementsDrag[el].Y;
                    this.Invalidate(el.InvalidatingRegion.Apply(this.Zoom));

                    foreach (Rectangle r in el.GetConnectorRegionsToInvalidate())
                    {
                        this.Invalidate(r.Apply(this.Zoom).Fix());
                    }
                }
            }
            else if (this.m_PanningStillHeldDown)
            {
                this.Invalidate();
                this.m_AllElementPanX = e.X;
                this.m_AllElementPanY = e.Y;
                foreach (FlowElement el in this.m_Elements)
                {
                    el.X += (int)((this.m_AllElementPanX - this.m_AllElementPanOldX) / this.Zoom);
                    el.Y += (int)((this.m_AllElementPanY - this.m_AllElementPanOldY) / this.Zoom);
                }
                this.m_AllElementPanOldX = this.m_AllElementPanX;
                this.m_AllElementPanOldY = this.m_AllElementPanY;
            }
            else if (this.m_ActiveConnection != null)
            {
                var r = new Rectangle(
                    this.m_ActiveConnection.Center.X,
                    this.m_ActiveConnection.Center.Y,
                    this.m_MouseActiveConnectionLocation.X - this.m_ActiveConnection.Center.X,
                    this.m_MouseActiveConnectionLocation.Y - this.m_ActiveConnection.Center.Y);
                r.Inflate(r.Width > 0 ? 10 : -10, r.Height > 0 ? 10 : -10);
                this.Invalidate(r.Fix());
                r = new Rectangle(
                    this.m_ActiveConnection.Center.X,
                    this.m_ActiveConnection.Center.Y,
                    e.X - this.m_ActiveConnection.Center.X,
                    e.Y - this.m_ActiveConnection.Center.Y);
                r.Inflate(r.Width > 0 ? 10 : -10, r.Height > 0 ? 10 : -10);
                this.Invalidate(r.Fix());
            }
            this.m_MouseActiveConnectionLocation = new Point(
                e.X,
                e.Y
                );
        }