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


C# GraphicsPath.AddRectangle方法代码示例

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


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

示例1: OnPaint

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        G = e.Graphics;
        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

        G.Clear(BackColor);

        Rectangle R = default(Rectangle);

        int Offset = 0;
        G.DrawRectangle(P1, 0, 0, (12 * 32) + 1, (5 * 32) + 1);

        for (int I = 0; I <= Buttons.Length - 1; I++)
        {
            R = Buttons[I];

            Offset = 0;
            if (I == Pressed)
            {
                Offset = 1;

                GP1 = new GraphicsPath();
                GP1.AddRectangle(R);

                PB1 = new PathGradientBrush(GP1);
                PB1.CenterColor = Color.FromArgb(60, 60, 60);
                PB1.SurroundColors = new Color[] { Color.FromArgb(55, 55, 55) };
                PB1.FocusScales = new PointF(0.8f, 0.5f);

                G.FillPath(PB1, GP1);
            }
            else {
                GB1 = new LinearGradientBrush(R, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f);
                G.FillRectangle(GB1, R);
            }

            switch (I)
            {
                case 48:
                case 49:
                case 50:
                    SZ1 = G.MeasureString(Other[I - 48], Font);
                    G.DrawString(Other[I - 48], Font, Brushes.Black, R.X + (R.Width / 2 - SZ1.Width / 2) + Offset + 1, R.Y + (R.Height / 2 - SZ1.Height / 2) + Offset + 1);
                    G.DrawString(Other[I - 48], Font, Brushes.White, R.X + (R.Width / 2 - SZ1.Width / 2) + Offset, R.Y + (R.Height / 2 - SZ1.Height / 2) + Offset);
                    break;
                case 47:
                    DrawArrow(Color.Black, R.X + Offset + 1, R.Y + Offset + 1);
                    DrawArrow(Color.White, R.X + Offset, R.Y + Offset);
                    break;
                default:
                    if (Shift)
                    {
                        G.DrawString(Upper[I].ToString(), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1);
                        G.DrawString(Upper[I].ToString(), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset);

                        if (!char.IsLetter(Lower[I]))
                        {
                            PT1 = LowerCache[I];
                            G.DrawString(Lower[I].ToString(), Font, B1, PT1.X + Offset, PT1.Y + Offset);
                        }
                    }
                    else {
                        G.DrawString(Lower[I].ToString(), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1);
                        G.DrawString(Lower[I].ToString(), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset);

                        if (!char.IsLetter(Upper[I]))
                        {
                            PT1 = UpperCache[I];
                            G.DrawString(Upper[I].ToString(), Font, B1, PT1.X + Offset, PT1.Y + Offset);
                        }
                    }
                    break;
            }

            G.DrawRectangle(P2, R.X + 1 + Offset, R.Y + 1 + Offset, R.Width - 2, R.Height - 2);
            G.DrawRectangle(P3, R.X + Offset, R.Y + Offset, R.Width, R.Height);

            if (I == Pressed)
            {
                G.DrawLine(P1, R.X, R.Y, R.Right, R.Y);
                G.DrawLine(P1, R.X, R.Y, R.X, R.Bottom);
            }
        }
    }
开发者ID:massimoca,项目名称:Wedit,代码行数:84,代码来源:Theme.cs

示例2: ColorWheel

    public ColorWheel(Rectangle colorRectangle, Rectangle brightnessRectangle, Rectangle selectedColorRectangle)
    {
        // Caller must provide locations for color wheel
        // (colorRectangle), brightness "strip" (brightnessRectangle)
        // and location to display selected color (selectedColorRectangle).

        using (GraphicsPath path = new GraphicsPath())
        {
            // Store away locations for later use.
            this.colorRectangle = colorRectangle;
            this.brightnessRectangle = brightnessRectangle;
            this.selectedColorRectangle = selectedColorRectangle;
            //this.selectedColor = Color.FromArgb(RGB.Alpha, RGB.Red, RGB.Green, RGB.Blue);

            // Calculate the center of the circle.
            // Start with the location, then offset
            // the point by the radius.
            // Use the smaller of the width and height of
            // the colorRectangle value.
            this.radius = (int)Math.Min(colorRectangle.Width, colorRectangle.Height) / 2;
            this.centerPoint = colorRectangle.Location;
            this.centerPoint.Offset(radius, radius);

            // Start the pointer in the center.
            this.colorPoint = this.centerPoint;

            // Create a region corresponding to the color circle.
            // Code uses this later to determine if a specified
            // point is within the region, using the IsVisible
            // method.
            path.AddEllipse(colorRectangle);
            colorRegion = new Region(path);

            // set { the range for the brightness selector.
            this.brightnessMin = this.brightnessRectangle.Top;
            this.brightnessMax = this.brightnessRectangle.Bottom;

            // Create a region corresponding to the
            // brightness rectangle, with a little extra
            // "breathing room".

            path.AddRectangle(new Rectangle(brightnessRectangle.Left, brightnessRectangle.Top - 10, brightnessRectangle.Width + 10, brightnessRectangle.Height + 20));
            // Create region corresponding to brightness
            // rectangle. Later code uses this to
            // determine if a specified point is within
            // the region, using the IsVisible method.
            brightnessRegion = new Region(path);

            // Set the location for the brightness indicator "marker".
            // Also calculate the scaling factor, scaling the height
            // to be between 0 and 255.
            brightnessX = brightnessRectangle.Left + brightnessRectangle.Width;
            brightnessScaling = (double)255 / (brightnessMax - brightnessMin);

            // Calculate the location of the brightness
            // pointer. Assume it's at the highest position.
            brightnessPoint = new Point(brightnessX, brightnessMax);

            // Create the bitmap that contains the circular gradient.
            CreateGradient();
        }
    }
开发者ID:vebin,项目名称:PhotoBrushProject,代码行数:62,代码来源:ColorWheel.cs

示例3: RefreshPath

    // Create the corresponding GraphicsPath for the shape, and apply
    // it to the control by setting the Region property.
    private void RefreshPath()
    {
        path = new GraphicsPath();
        patje = new GraphicsPath();

        //switch (shape)
        //{
        //    case ShapeType.PosRectangle:
        path.AddRectangle(this.ClientRectangle);
        patje.AddString("POS1", new FontFamily("Arial"), (int)FontStyle.Regular, 10, new Point(4, 7), StringFormat.GenericDefault);
        //        break;
        //    case ShapeType.Ellipse:
        //        path.AddEllipse(this.ClientRectangle);
        //        break;
        //    case ShapeType.Triangle:
        //        Point pt1 = new Point(this.Width / 2, 0);
        //        Point pt2 = new Point(0, this.Height);
        //        Point pt3 = new Point(this.Width, this.Height);
        //        path.AddPolygon(new Point[] { pt1, pt2, pt3 });
        //        break;
        //}
        this.Region = new Region(path);
    }
开发者ID:Subwolf666,项目名称:KHR-1HV-Client,代码行数:25,代码来源:KHR-1HV_Main.cs

示例4: OnPaint

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        int intRate = 0;
        e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        Color UseFillColor = new Color();
        Color UseBorderColor = new Color();
        GraphicsPath ShapePath = new GraphicsPath();
        float ptx;
        float pty;
        StringFormat sf = new StringFormat();
        sf.Alignment = StringAlignment.Center;
        sf.LineAlignment = StringAlignment.Center;

        pty = (this.Height - (RadiusOuter * 2)) / 2;
        intRate = 0;
        while (!(intRate == MaxRating))
        {
          ptx = intRate * (RadiusOuter * 2 + ShapeGap) + Padding.Left + (ShapeGap / 2);
          if (PaintRating > intRate)
          {
        if (!IsPainting & HighlightRateFill & (PaintRating != intRate + 1))
        {
          UseFillColor = ShapeColorHover;
          UseBorderColor = ShapeBorderHoverColor;
        }
        else if (IsPainting & HighlightRateHover & (PaintRating == intRate + 1))
        {
          UseFillColor = ShapeColorFill;
          UseBorderColor = ShapeBorderFilledColor;
        }
        else
        {
          UseFillColor = PaintColor;
          UseBorderColor = PaintBorderColor;
        }
          }
          else
          {
        UseFillColor = ShapeColorEmpty;
        UseBorderColor = ShapeBorderEmptyColor;
          }

          ShapePath.Reset();
          Point[] pts;
          switch (Shape)
          {
        case eShape.Star:
          ShapePath = DrawStar(ptx, pty);
          break;
        case eShape.Heart:
          ShapePath = DrawHeart(ptx, pty);
          break;
        case eShape.Square:
          ShapePath.AddRectangle(new Rectangle((int)ptx, (int)pty, (int)(RadiusOuter * 2), (int)(RadiusOuter * 2)));
          break;
        case eShape.Circle:
          ShapePath.AddEllipse(ptx, pty, RadiusOuter * 2, RadiusOuter * 2);
          break;
        case eShape.Diamond:
          pts = new Point[] { new Point((int)(ptx + RadiusOuter), (int)pty), new Point((int)(ptx + RadiusOuter * 2), (int)(pty + RadiusOuter)), new Point((int)(ptx + RadiusOuter), (int)(pty + RadiusOuter * 2)), new Point((int)ptx, (int)(pty + RadiusOuter)) };
          ShapePath.AddPolygon(pts);
          break;
        case eShape.Triangle:
          pts = new Point[] { new Point((int)(ptx + RadiusOuter), (int)pty), new Point((int)(ptx + RadiusOuter * 2), (int)(pty + RadiusOuter * 2)), new Point((int)ptx, (int)(pty + RadiusOuter * 2)) };
          ShapePath.AddPolygon(pts);
          break;

          }

          e.Graphics.FillPath(new SolidBrush(UseFillColor), ShapePath);
          e.Graphics.DrawPath(new Pen(UseBorderColor, ShapeBorderWidth), ShapePath);

          if (ShapeNumberShow != eShapeNumberShow.None)
          {
        if (ShapeNumberShow == eShapeNumberShow.All | (ShapeNumberShow == eShapeNumberShow.RateOnly & PaintRating == intRate + 1))
        {
          e.Graphics.DrawString((intRate + 1).ToString(), ShapeNumberFont, new SolidBrush(ShapeNumberColor), new RectangleF(ShapeNumberIndent.X + ptx, ShapeNumberIndent.Y + pty, RadiusOuter * 2, RadiusOuter * 2), sf);
        }
          }

          intRate += 1;
        }

        if (LabelShow)
        {
          int R_x = (int)(((RadiusOuter * 2) * (MaxRating)) + LabelIndent + ((ShapeGap) * MaxRating) + Padding.Left);
          if (IsPainting)
          {
        RateLabel.Text = GetLabelText(LabelTypeHover);
          }
          else
          {
        RateLabel.Text = GetLabelText(LabelTypeText);
          }
          RateLabel.Width = (this.Width - R_x);
          RateLabel.Height = (this.Height);
          RateLabel.Location = new Point(R_x, 0);
        }
    }
开发者ID:jcbarton,项目名称:MUMS,代码行数:99,代码来源:ShapeRater.cs

示例5: RoundRect

    public static GraphicsPath RoundRect(Rectangle Rect, int Rounding, RoundingStyle Style = RoundingStyle.All)
    {
        GraphicsPath GP = new GraphicsPath();
        int AW = Rounding * 2;

        GP.StartFigure();

        if (Rounding == 0)
        {
            GP.AddRectangle(Rect);
            GP.CloseAllFigures();
            return GP;
        }

        switch (Style)
        {
            case RoundingStyle.All:
                GP.AddArc(new Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90);
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
                GP.AddArc(new Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90);
                break;
            case RoundingStyle.Top:
                GP.AddArc(new Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90);
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
                GP.AddLine(new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
                break;
            case RoundingStyle.Bottom:
                GP.AddLine(new Point(Rect.X, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y));
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
                GP.AddArc(new Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90);
                break;
            case RoundingStyle.Left:
                GP.AddArc(new Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90);
                GP.AddLine(new Point(Rect.X + Rect.Width, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height));
                GP.AddArc(new Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90);
                break;
            case RoundingStyle.Right:
                GP.AddLine(new Point(Rect.X, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y));
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
                break;
            case RoundingStyle.TopRight:
                GP.AddLine(new Point(Rect.X, Rect.Y + 1), new Point(Rect.X, Rect.Y));
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
                GP.AddLine(new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height - 1), new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height));
                GP.AddLine(new Point(Rect.X + 1, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
                break;
            case RoundingStyle.BottomRight:
                GP.AddLine(new Point(Rect.X, Rect.Y + 1), new Point(Rect.X, Rect.Y));
                GP.AddLine(new Point(Rect.X + Rect.Width - 1, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y));
                GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
                GP.AddLine(new Point(Rect.X + 1, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
                break;
        }

        GP.CloseAllFigures();

        return GP;
    }
开发者ID:RedNax67,项目名称:GoBot,代码行数:60,代码来源:DarkTheme.cs

示例6: GetPath

	protected GraphicsPath GetPath()
	{
		GraphicsPath graphPath = new GraphicsPath();

		if (_BorderStyle == BorderStyle.Fixed3D)
		{
			graphPath.AddRectangle(ClientRectangle);
		}
		else
		{
			try
			{
				int curve = 0;

				Rectangle rect = ClientRectangle;
				int offset = 0;

				switch (_BorderStyle)
				{
				case BorderStyle.FixedSingle:
					offset = (int) Math.Ceiling(BorderWidth / 2.0d);
					curve = adjustedCurve;

					break;
				case BorderStyle.Fixed3D:

					break;
				case BorderStyle.None:
					curve = adjustedCurve;

					break;
				}

				if (curve == 0)
				{
					graphPath.AddRectangle(Rectangle.Inflate(rect, -offset, -offset));
				}
				else
				{
					int rectWidth = rect.Width - 1 - offset;
					int rectHeight = rect.Height - 1 - offset;
					int curveWidth;

					if ((_CurveMode & CornerCurveMode.TopRight) != 0)
					{
						curveWidth = (curve * 2);
					}
					else
					{
						curveWidth = 1;
					}
					graphPath.AddArc(rectWidth - curveWidth, offset, curveWidth, curveWidth, 270, 90);

					if ((_CurveMode & CornerCurveMode.BottomRight) != 0)
					{
						curveWidth = (curve * 2);
					}
					else
					{
						curveWidth = 1;
					}
					graphPath.AddArc(rectWidth - curveWidth, rectHeight - curveWidth, curveWidth, curveWidth, 0, 90);

					if ((_CurveMode & CornerCurveMode.BottomLeft) != 0)
					{
						curveWidth = (curve * 2);
					}
					else
					{
						curveWidth = 1;
					}
					graphPath.AddArc(offset, rectHeight - curveWidth, curveWidth, curveWidth, 90, 90);

					if ((_CurveMode & CornerCurveMode.TopLeft) != 0)
					{
						curveWidth = (curve * 2);
					}
					else
					{
						curveWidth = 1;
					}
					graphPath.AddArc(offset, offset, curveWidth, curveWidth, 180, 90);

					graphPath.CloseFigure();
				}
			}
			catch (Exception)
			{
				graphPath.AddRectangle(ClientRectangle);
			}
		}

		return graphPath;
	}
开发者ID:killbug2004,项目名称:WSProf,代码行数:94,代码来源:CustomPanel.cs


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