当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.Fix方法代码示例

本文整理汇总了C#中System.Drawing.Rectangle.Fix方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Fix方法的具体用法?C# Rectangle.Fix怎么用?C# Rectangle.Fix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Rectangle的用法示例。


在下文中一共展示了Rectangle.Fix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnMouseMove

        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
            );
        }
开发者ID:hach-que,项目名称:Redpoint.FlowGraph,代码行数:81,代码来源:FlowInterfaceControl.cs

示例2: EndMultiselect

        private void EndMultiselect()
        {
            this.m_Multiselecting = false;
            this.m_WillMultiselect = false;

            this.m_SelectedElements.Clear();

            var r = new Rectangle(
                this.m_MultiselectStartX,
                this.m_MultiselectStartY,
                this.m_MultiselectEndX - this.m_MultiselectStartX,
                this.m_MultiselectEndY - this.m_MultiselectStartY);
            r.Fix();
            r = r.Apply(1 / this.Zoom);

            foreach (FlowElement el in this.m_Elements.Reverse<FlowElement>())
            {
                if (r.IntersectsWith(el.Region))
                {
                    this.m_SelectedElements.Add(el);
                }
            }

            this.Invalidate();
        }
开发者ID:hach-que,项目名称:Redpoint.FlowGraph,代码行数:25,代码来源:FlowInterfaceControl.cs

示例3: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            e.Graphics.FillRectangle(SystemBrushes.ControlDark, e.ClipRectangle);

            // Render each flow element.
            var re = new RenderAttributes
            {
                Graphics = e.Graphics,
                Zoom = this.Zoom,
                Font = new Font(SystemFonts.DefaultFont.FontFamily, SystemFonts.DefaultFont.Size * this.Zoom)
            };
            foreach (FlowElement el in this.m_Elements)
                FlowElement.RenderTo(el, re, this.m_SelectedElement == el || this.m_SelectedElements.Contains(el));

            // Render the active connection line.
            if (this.m_ActiveConnection != null)
            {
                e.Graphics.DrawLine(new Pen(Color.Red, 3),
                    this.m_ActiveConnection.Center,
                    this.m_MouseActiveConnectionLocation
                );
            }

            if (this.m_Multiselecting)
            {
                var r = new Rectangle(
                    this.m_MultiselectStartX,
                    this.m_MultiselectStartY,
                    this.m_MultiselectEndX - this.m_MultiselectStartX,
                    this.m_MultiselectEndY - this.m_MultiselectStartY);
                r.Fix();

                e.Graphics.DrawRectangle(
                    new Pen(Color.Red, 3),
                    r
                );
            }
        }
开发者ID:hach-que,项目名称:Redpoint.FlowGraph,代码行数:40,代码来源:FlowInterfaceControl.cs


注:本文中的System.Drawing.Rectangle.Fix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。