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


C# RectangleF.RoundCorners方法代码示例

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


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

示例1: Draw

        /// <summary>
        /// Draws the scale division label on a GDI+ surface against the provided x and y axes.
        /// </summary>
        /// <param name="g">The GDI+ surface on which to draw.</param>
        /// <param name="xAxis">The X-Axis to draw against.</param>
        /// <param name="yAxis">The Y-Axis to draw against.</param>
        /// 
        public void Draw(System.Drawing.Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis)
        {
            ArrayList yLargePositions = null;
            ArrayList ySmallPositions = null;

            yAxis.Axis.WorldTickPositions_FirstPass( yAxis.PhysicalMin, yAxis.PhysicalMax, out yLargePositions, out ySmallPositions );

            // test if we have enough y ticks
            if (yLargePositions.Count <= this.YPosition) {
                if (yLargePositions.Count > 1)
                    this.YPosition = yLargePositions.Count - 1;
                else return;
            }

            double minX = xAxis.PhysicalToWorld(xAxis.PhysicalMin,false);
            double maxX = xAxis.PhysicalToWorld(xAxis.PhysicalMax,false);

            double xOffset = this.XPosition;
            double xRef = xAxis.PhysicalMin.X;
            if (xOffset < 0)
                xRef = xAxis.PhysicalMax.X;

            if (xOffset < 1 && xOffset > 0)
                xOffset = (xAxis.PhysicalMax.X - xAxis.PhysicalMin.X) * this.XPosition;

            //*P8 	P3*==*P2==*P4
            //		 	||
            //		 	||
            //		 	|| *P7
            //       	||
            //       	||
            //  	P5*==*P1==*P6

            //Points for the main-line
            PointF p1 = new PointF(Convert.ToSingle(xRef + xOffset), 0.0f);
            PointF p2 = p1;

            PointF yTick1 = yAxis.WorldToPhysical((double)yLargePositions[yLargePositions.Count-this.YPosition],false);
            PointF yTick0 = yAxis.WorldToPhysical((double)yLargePositions[yLargePositions.Count-(this.YPosition+1)],false);

            p1.Y = yTick0.Y;
            p2.Y = yTick1.Y;

            //Points for the upper line
            PointF p3 = yTick1;
            PointF p4 = p3;
            p3.X = Convert.ToSingle(xRef + xOffset - 3);
            p4.X = Convert.ToSingle(xRef + xOffset + 3);

            //Points for the lower line
            PointF p5 = p3;
            PointF p6 = p4;
            p5.Y = yTick0.Y;
            p6.Y = yTick0.Y;

            //Label-point
            PointF p7 = p6;
            p7.Y = p7.Y + (p2.Y - p1.Y)/2;

            //Background-point
            PointF p8 = p3;
            p8.X = Convert.ToSingle((xRef + xOffset) - 14);

            double labelValue = (double)yLargePositions[yLargePositions.Count-this.YPosition] -
                (double)yLargePositions[yLargePositions.Count-(this.YPosition+1)];

            StringBuilder label = new StringBuilder();
            label.AppendFormat(this.NumberFormat, labelValue);
            float labelLength = g.MeasureString (label.ToString(), this.LabelFont).Width;

            float width = Convert.ToSingle((xRef + xOffset) + 14) - p8.X;
            float widthMin = (p7.X - p8.X) + labelLength + 2;
            if (widthMin > width)
                width = widthMin;

            float height = p1.Y-p2.Y;

            RectangleF bgRect = new RectangleF (p8.X, p8.Y, width, height);
            g.FillPath(this.BackgroundBrush, bgRect.RoundCorners(this.BackgroundCornerRadius));
            g.DrawString(label.ToString(), this.LabelFont, this.ValueBrush, p7);
            g.DrawLine( this.LinePen, (int)p1.X, (int)p1.Y, (int)p2.X, (int)p2.Y );
            g.DrawLine( this.LinePen, (int)p3.X, (int)p3.Y, (int)p4.X, (int)p4.Y );
            g.DrawLine( this.LinePen, (int)p5.X, (int)p5.Y, (int)p6.X, (int)p6.Y );
        }
开发者ID:sevoku,项目名称:nplot-gtk,代码行数:91,代码来源:GridScaleDivision.cs


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