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


C# RectangleF.Inflate方法代码示例

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


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

示例1: DrawNode

 static public void DrawNode(ICanvas canvas, UnitPoint nodepoint)
 {
     RectangleF r = new RectangleF(canvas.ToScreen(nodepoint), new SizeF(0, 0));
     r.Inflate(3, 3);
     if (r.Right < 0 || r.Left > canvas.ClientRectangle.Width)
         return;
     if (r.Top < 0 || r.Bottom > canvas.ClientRectangle.Height)
         return;
     canvas.Graphics.FillRectangle(Brushes.White, r);
     r.Inflate(1, 1);
     canvas.Graphics.DrawRectangle(Pens.Black, ScreenUtils.ConvertRect(r));
 }
开发者ID:sduxiaowu,项目名称:NineLineScore,代码行数:12,代码来源:DrawToolsUtils.cs

示例2: Hit

        public override bool Hit(Point p)
        {
            Point p1,p2, s;
            RectangleF r1, r2;
            float o,u;
            p1 = From.Point; p2 = To.Point;

            // p1 must be the leftmost point.
            if (p1.X > p2.X) { s = p2; p2 = p1; p1 = s; }

            r1 = new RectangleF(p1.X, p1.Y, 0, 0);
            r2 = new RectangleF(p2.X, p2.Y, 0, 0);
            r1.Inflate(3, 3);
            r2.Inflate(3, 3);
            //this is like a topological neighborhood
            //the connection is shifted left and right
            //and the point under consideration has to be in between.
            if (RectangleF.Union(r1, r2).Contains(p))
            {
                if (p1.Y < p2.Y) //SWNE
                {
                    o = r1.Left + (((r2.Left - r1.Left) * (p.Y - r1.Bottom)) / (r2.Bottom - r1.Bottom));
                    u = r1.Right + (((r2.Right - r1.Right) * (p.Y - r1.Top)) / (r2.Top - r1.Top));
                    return ((p.X > o) && (p.X < u));
                }
                else //NWSE
                {
                    o = r1.Left + (((r2.Left - r1.Left) * (p.Y - r1.Top)) / (r2.Top - r1.Top));
                    u = r1.Right + (((r2.Right - r1.Right) * (p.Y - r1.Bottom)) / (r2.Bottom - r1.Bottom));
                    return ((p.X > o) && (p.X < u));
                }
            }
            return false;
        }
开发者ID:Tom-Hoinacki,项目名称:OO-CASE-Tool,代码行数:34,代码来源:Connection.cs

示例3: OnPaintBackground

        protected override void OnPaintBackground(PaintEventArgs pevent)
        {
            base.OnPaintBackground(pevent);
            pevent.Graphics.Clear(Color.FromArgb(0));

            foreach (TabPage tab in this.TabPages)
            {
                Rectangle tabRect = GetTabRect(this.TabPages.IndexOf(tab));

                using (StringFormat sf = new StringFormat(StringFormatFlags.NoWrap))
                {
                    sf.Alignment = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    SizeF textSize = pevent.Graphics.MeasureString(tab.Text, this.Font);
                    RectangleF rc = new RectangleF(tabRect.Left + ((tabRect.Width / 2) - (textSize.Width / 2)), tabRect.Top + tabRect.Height / 2 - textSize.Height / 2, textSize.Width, textSize.Height);
                    rc.Inflate(4, 5);

                    GraphicsPath path = new GraphicsPath();
                    path.AddRectangle(rc);

                    using (PathGradientBrush brush = new PathGradientBrush(path))
                    {
                        brush.CenterColor = Color.FromArgb(192, tab == this.SelectedTab ? Color.Red : Color.Black);
                        brush.SurroundColors = new Color[] { Color.Black };
                        pevent.Graphics.FillRectangle(brush,rc);
                    }

                    var tc = new SolidBrush(Color.FromArgb(tab.ForeColor.A, tab.ForeColor.R, tab.ForeColor.G, tab.ForeColor.B));

                    pevent.Graphics.DrawString(tab.Text, this.Font, tc, rc, sf);

                }
            }
        }
开发者ID:liuxingghost,项目名称:MTK-FirmwareAdapter-Tool,代码行数:34,代码来源:GlassTabControl.cs

示例4: Inflate

		/// <summary>
		///	Inflate Shared Method
		/// </summary>
		///
		/// <remarks>
		///	Produces a new RectangleF by inflating an existing 
		///	RectangleF by the specified coordinate values.
		/// </remarks>
		
		public static RectangleF Inflate (RectangleF rect, 
						  float x, float y)
		{
			RectangleF ir = new RectangleF (rect.X, rect.Y, rect.Width, rect.Height);
			ir.Inflate (x, y);
			return ir;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:RectangleF.cs

示例5: PaintValue

        /// <summary>
        /// Draw a preview of the <see cref="ColorPair"/>
        /// </summary>
        /// <param name="e">The paint event args providing the <see cref="Graphics"/> and bounding
        /// rectangle</param>
        public override void PaintValue(PaintValueEventArgs e)
        {
            ColorPair colorPair = (ColorPair)e.Value ;

            using ( SolidBrush b = new SolidBrush(colorPair.Background)) {
                e.Graphics.FillRectangle(b, e.Bounds);
            }

            // Draw the text "ab" using the Foreground/Background values from the ColorPair
            using(SolidBrush b = new SolidBrush(colorPair.Foreground)) {
                using(Font f = new Font("Arial",6)) {
                    RectangleF temp = new RectangleF(e.Bounds.Left,e.Bounds.Top,e.Bounds.Height,e.Bounds.Width) ;
                    temp.Inflate(-2,-2) ;

                    // Set up how we want the text drawn
                    StringFormat format = new StringFormat(StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap) ;
                    format.Trimming = StringTrimming.EllipsisCharacter ;
                    format.Alignment = StringAlignment.Center ;
                    format.LineAlignment = StringAlignment.Center ;

                    // save the Smoothing mode of the Graphics object so we can restore it
                    SmoothingMode saveMode = e.Graphics.SmoothingMode ;
                    e.Graphics.SmoothingMode = SmoothingMode.AntiAlias ;
                    e.Graphics.DrawString("ab",f,b,temp,format) ;
                    e.Graphics.SmoothingMode = saveMode ;
                }
            }
        }
开发者ID:svn2github,项目名称:fiddler-plus,代码行数:33,代码来源:ColorEditors.cs

示例6: PointF

    GetRectangleTransformation
    (
        RectangleF rectangle1,
        RectangleF rectangle2
    )
    {
        Debug.Assert(rectangle1.Width >= 0);
        Debug.Assert(rectangle1.Height >= 0);
        Debug.Assert(rectangle2.Width >= 0);
        Debug.Assert(rectangle2.Height >= 0);

        // Handle collapsed rectangles, which can result, for example, when a
        // graph contains only one vertex.

        if (rectangle1.Width == 0)
        {
            rectangle1.Inflate(1, 0);
        }

        if (rectangle1.Height == 0)
        {
            rectangle1.Inflate(0, 1);
        }

        if (rectangle2.Width == 0)
        {
            rectangle2.Inflate(1, 0);
        }

        if (rectangle2.Height == 0)
        {
            rectangle2.Inflate(0, 1);
        }

        Matrix oMatrix = new Matrix(

            rectangle1,

            new PointF [] {
                rectangle2.Location,
                new PointF(rectangle2.Right, rectangle2.Top),
                new PointF(rectangle2.Left, rectangle2.Bottom)
                }
            );

        return (oMatrix);
    }
开发者ID:2014-sed-team3,项目名称:term-project,代码行数:47,代码来源:LayoutUtil.cs

示例7: Hit

        public override bool Hit(System.Drawing.PointF p)
        {
            bool join = false;
            //			points = new PointF[2+insertionPoints.Count];
            //			points[0] = p1;
            //			points[2+insertionPoints.Count-1] = p2;
            //			for(int m=0; m<insertionPoints.Count; m++)
            //			{
            //				points[1+m] = (PointF)  insertionPoints[m];
            //			}
            PointF[] points = mPoints;

            PointF p1 = this.mConnection.From.AdjacentPoint;
            PointF p2 = this.mConnection.To.AdjacentPoint;

            PointF s;
                float o, u;
            RectangleF r1=RectangleF.Empty, r2=RectangleF.Empty, r3=RectangleF.Empty;

            //Tomas Kuchar wrote
            if (points == null)
                return join;

            for(int v = 0; v<points.Length-1; v++)
            {

                //this is the usual segment test
                //you can do this because the PointF object is a value type!
                p1 = points[v]; p2 = points[v+1];

                // p1 must be the leftmost point.
                if (p1.X > p2.X) { s = p2; p2 = p1; p1 = s; }

                r1 = new RectangleF(p1.X, p1.Y, 0, 0);
                r2 = new RectangleF(p2.X, p2.Y, 0, 0);
                r1.Inflate(3, 3);
                r2.Inflate(3, 3);
                //this is like a topological neighborhood
                //the connection is shifted left and right
                //and the point under consideration has to be in between.
                if (RectangleF.Union(r1, r2).Contains(p))
                {
                    if (p1.Y < p2.Y) //SWNE
                    {
                        o = r1.Left + (((r2.Left - r1.Left) * (p.Y - r1.Bottom)) / (r2.Bottom - r1.Bottom));
                        u = r1.Right + (((r2.Right - r1.Right) * (p.Y - r1.Top)) / (r2.Top - r1.Top));
                        join |= ((p.X > o) && (p.X < u));
                    }
                    else //NWSE
                    {
                        o = r1.Left + (((r2.Left - r1.Left) * (p.Y - r1.Top)) / (r2.Top - r1.Top));
                        u = r1.Right + (((r2.Right - r1.Right) * (p.Y - r1.Bottom)) / (r2.Bottom - r1.Bottom));
                        join |= ((p.X > o) && (p.X < u));
                    }
                }

            }
            return join;
        }
开发者ID:BackupTheBerlios,项目名称:ferdadataminer-svn,代码行数:59,代码来源:DefaultPainter.cs

示例8: GetOurRectangle

 private RectangleF GetOurRectangle()
 {
     RectangleF rectF = new RectangleF(this.Location, new SizeF(0, 0));
     float ratio = 1.0f / (float)OwnerList.ScaleFactor.Ratio;
     float ourSize = UI.ScaleWidth(size);
     rectF.Inflate(ratio * ourSize, ratio * ourSize);
     return rectF;
 }
开发者ID:herbqiao,项目名称:paint.net,代码行数:8,代码来源:RotateNubRenderer.cs

示例9: Render

            protected override void Render(RectangleF sourceBounds, Matrix transform, Graphics g)
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;

                g.Transform = transform;
                sourceBounds.Inflate(1, 1); // allow for pen widths
                g.SetClip(sourceBounds);

                foreach (IPrintingAdapter printingAdapter in m_viewingContext.Control.AsAll<IPrintingAdapter>())
                    printingAdapter.Print(this, g);
            }
开发者ID:Joxx0r,项目名称:ATF,代码行数:12,代码来源:PrintableDocument.cs

示例10: ToAspectRatioB

        /// <summary>
        /// Shortens the height or narrows the width of a rectangle to match the specified aspect ratio.
        /// </summary>
        /// <param name="rectangle"></param>
        /// <param name="aspectRatio"></param>
        /// <returns></returns>
        public static RectangleF ToAspectRatioB(RectangleF rectangle, float aspectRatio)
        {
            float projectedAspect = ((float)rectangle.Width / (float)rectangle.Height);

            if (aspectRatio > projectedAspect)
            {
#if !PocketPC
                rectangle.Inflate(0, (rectangle.Width / aspectRatio - rectangle.Height) * .5f);
#else
                return RectangleFHelper.Inflate(rectangle, 0, (rectangle.Width / aspectRatio - rectangle.Height) * .5f);
#endif
            }
            else if (aspectRatio < projectedAspect)
            {
#if !PocketPC
                rectangle.Inflate((aspectRatio * rectangle.Height - rectangle.Width) * .5f, 0);
#else
                return RectangleFHelper.Inflate(rectangle, (aspectRatio * rectangle.Height - rectangle.Width) * .5f, 0);
#endif
            }
            return rectangle;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:28,代码来源:RectangleFHelper.cs

示例11: DrawGlyph

 public override void DrawGlyph(PaintEventArgs e, Rectangle bounds)
 {
     GraphicsPath path;
     int num = Math.Max(0, (bounds.Width - bounds.Height) / 2);
     int num2 = Math.Max(0, (bounds.Height - bounds.Width) / 2);
     bounds.Inflate(-num, -num2);
     if ((bounds.Width % 2) == 1)
     {
         bounds.Width--;
     }
     if ((bounds.Height % 2) == 1)
     {
         bounds.Height--;
     }
     if (bounds.Width > bounds.Height)
     {
         bounds.Width = bounds.Height;
     }
     if (bounds.Height > bounds.Width)
     {
         bounds.Height = bounds.Width;
     }
     bounds.Inflate(-2, -2);
     int width = bounds.Width;
     int num4 = width / 3;
     int num5 = width / 4;
     int num6 = bounds.X + (bounds.Width / 2);
     float x = bounds.X + (0.5f * (bounds.Width + 3));
     float num8 = x - 3f;
     SmoothingMode smoothingMode = e.Graphics.SmoothingMode;
     e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
     using (path = new GraphicsPath())
     {
         Point[] points = new Point[] { new Point(bounds.Left + num4, bounds.Bottom), new Point(bounds.Right - num4, bounds.Bottom), new Point(bounds.Right, bounds.Bottom - num4), new Point(bounds.Right, bounds.Top + num4), new Point(bounds.Right - num4, bounds.Top), new Point(bounds.Left + num4, bounds.Top), new Point(bounds.Left, bounds.Top + num4), new Point(bounds.Left, bounds.Bottom - num4) };
         path.AddLines(points);
         path.CloseAllFigures();
         e.Graphics.FillPath(Brushes.Red, path);
         e.Graphics.DrawPath(Pens.DarkGray, path);
     }
     using (path = new GraphicsPath())
     {
         PointF[] tfArray = new PointF[] { new PointF(num8, (float) ((bounds.Top + num5) - 1)), new PointF(x, (float) ((bounds.Top + num5) - 1)), new PointF(num6 + 1.2f, (-0.5f + bounds.Top) + ((bounds.Height * 2f) / 3f)), new PointF(num6 - 1.2f, (-0.5f + bounds.Top) + ((bounds.Height * 2f) / 3f)) };
         path.AddLines(tfArray);
         path.CloseAllFigures();
         e.Graphics.FillPath(Brushes.White, path);
     }
     RectangleF rect = new RectangleF((float) num6, (float) (bounds.Bottom - num5), 0f, 0f);
     rect.Inflate(1.5f, 1.5f);
     e.Graphics.FillEllipse(Brushes.White, rect);
     e.Graphics.SmoothingMode = smoothingMode;
 }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:51,代码来源:ExceptionLineIndicator.cs

示例12: Draw

        public override void Draw(ICanvas canvas, RectangleF unitrect)
        {
            Color color = Color;
            Pen pen = canvas.CreatePen(color, Width);
            if (Highlighted || Selected)
            {
                pen = Canvas.DrawTools.DrawUtils.SelectedPen;
                //if (m_p1.IsEmpty == false) Canvas.DrawTools.DrawUtils.DrawNode(canvas, m_p1);
            }
            pen = new Pen(pen.Color, (float)6);

            unitrect.Inflate(3, 3);
            canvas.DrawArc(canvas,pen,m_p1,(float)0.05,0,360);
        }
开发者ID:jjacksons,项目名称:GLUE,代码行数:14,代码来源:Node.cs

示例13: Maze

 public Maze(Size size)
 {
     MapSize = new Size(MazeSettings.CurrentRowSize, MazeSettings.CurrentColSize);
     MapRowData = new byte[MapSize.Width, MapSize.Height - 1]; // 横向门 --
     MapColData = new byte[MapSize.Width - 1, MapSize.Height]; // 纵向门 ||
     MapRect = new Rectangle(Point.Empty, MapSize);
     MzSize = size;
     MzBitmap = new Bitmap(size.Width, size.Height);
     MzGraphics = Graphics.FromImage(MzBitmap);
     MapRectF = new RectangleF(Point.Empty, MzSize);
     MapRectF.Inflate(-MazeSettings.CurrentBorderSize, -MazeSettings.CurrentBorderSize);
     PtStart = Point.Empty;
     PtEnd = new Point(MapSize.Width - 1, MapSize.Height - 1);
     GenerateGridLines();
     GenerateMaze();
 }
开发者ID:smithLiLi,项目名称:dev,代码行数:16,代码来源:Maze.cs

示例14: ChartCanvas

        public ChartCanvas(RectangleF rect)
            : base(rect)
        {
            ContentMode = UIViewContentMode.Redraw;
            this.AutoresizingMask = UIViewAutoresizing.All;
            this.BackColor = Color.Wheat;

            var panelRect = new RectangleF(rect.X,rect.Y,rect.Width,rect.Height-20 / UIScreen.MainScreen.Scale);
            panelRect.Inflate(-20 / UIScreen.MainScreen.Scale,-20 / UIScreen.MainScreen.Scale);
            panel1 = new PlotPanel(panelRect);
            panel1.BackColor = Color.AliceBlue;

            this.AddSubview(panel1);

            // Subscribing to a paint eventhandler to drawingPanel:
            panel1.Paint +=
                new PaintEventHandler(PlotPanelPaint);
        }
开发者ID:ronaldli,项目名称:sysdrawing-coregraphics,代码行数:18,代码来源:ChartCanvas.cs

示例15: PaintValue

		public override void PaintValue(PaintValueEventArgs e)
		{
			MindFusion.FlowChartX.ShapeTemplate shape = 
				e.Value as MindFusion.FlowChartX.ShapeTemplate;

			if (shape == null)
				return;

			// Draw the shape
			RectangleF rect = new RectangleF(
				(float)e.Bounds.Left, (float)e.Bounds.Top,
				(float)e.Bounds.Width - 1, (float)e.Bounds.Height - 1);
			rect.Inflate(-2, -2);
			MindFusion.FlowChartX.ShapeTemplate.PathData data =
				shape.initData(rect, 0);
			System.Drawing.Brush brush =
				new System.Drawing.SolidBrush(Color.LightSteelBlue);
			System.Drawing.Pen pen =
				new System.Drawing.Pen(Color.Black);

			System.Drawing.Drawing2D.SmoothingMode mode =
				e.Graphics.SmoothingMode;
			e.Graphics.SmoothingMode = 
				System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

			System.Drawing.Drawing2D.GraphicsPath path =
				shape.getPath(data, 0);
			e.Graphics.FillPath(brush, path);
			e.Graphics.DrawPath(pen, path);
			path.Dispose();

			path = shape.getDecorationPath(data, 0);
			if (path != null)
			{
				e.Graphics.DrawPath(pen, path);
				path.Dispose();
			}
			
			e.Graphics.SmoothingMode = mode;

            pen.Dispose();
			brush.Dispose();
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:43,代码来源:ShapeEditor.cs


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