當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。