private void ResimOlustur(int genislik, int yukseklik) { Bitmap bitmap = new Bitmap(genislik, yukseklik, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(bitmap); g.SmoothingMode = SmoothingMode.AntiAlias; Rectangle rect = new Rectangle(0, 0, genislik, yukseklik); HatchBrush hatchBrush = new HatchBrush(HatchStyle.SmallConfetti, Color.LightGray, Color.White); g.FillRectangle(hatchBrush, rect); SizeF size; float fontSize = rect.Height + 1; Font font; do { fontSize--; font = new Font(System.Drawing.FontFamily.GenericSerif.Name, fontSize, FontStyle.Bold); size = g.MeasureString(this.text, font); } while (size.Width > rect.Width); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; GraphicsPath path = new GraphicsPath(); path.AddString(this.text, font.FontFamily, (int)font.Style, font.Size, rect, format); float v = 4F; PointF[] points = { new PointF(this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v), new PointF(rect.Width - this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v), new PointF(this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v), new PointF(rect.Width - this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v) }; Matrix matrix = new Matrix(); matrix.Translate(0F, 0F); path.Warp(points, rect, matrix, WarpMode.Perspective, 0F); hatchBrush = new HatchBrush(HatchStyle.LargeConfetti, Color.LightGray, Color.DarkGray); g.FillPath(hatchBrush, path); int m = Math.Max(rect.Width, rect.Height); for (int i = 0; i < (int)(rect.Width * rect.Height / 30F); i++) { int x = this.random.Next(rect.Width); int y = this.random.Next(rect.Height); int w = this.random.Next(m / 50); int h = this.random.Next(m / 50); g.FillEllipse(hatchBrush, x, y, w, h); } font.Dispose(); hatchBrush.Dispose(); g.Dispose(); this.Image = bitmap; }
void MainForm_Paint (object sender, PaintEventArgs e) { Graphics g = e.Graphics; GraphicsPath path = new GraphicsPath (); Rectangle borderect = new Rectangle (49, 49, 252, 252); g.FillRectangle (new SolidBrush (Color.White), borderect); int Diameter = 16; Rectangle baserect = new Rectangle (50, 50, 249, 249); Rectangle arcrect = new Rectangle (baserect.Location, new Size (Diameter, Diameter)); // handle top left corner path.AddArc (arcrect, 180, 90); // handle top right corner arcrect.X = baserect.Right - Diameter; path.AddArc (arcrect, 270, 90); // handle baserect right corner arcrect.Y = baserect.Bottom - Diameter; path.AddArc (arcrect, 0, 90); // handle bottom left corner arcrect.X = baserect.Left; path.AddArc (arcrect, 90, 90); path.CloseFigure (); g.DrawPath (Pens.SteelBlue, path); }
protected override void OnPaint(PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.CompositingQuality = CompositingQuality.HighQuality; e.Graphics.CompositingMode = CompositingMode.SourceOver; GraphicsPath stroke = new GraphicsPath(); stroke.AddString(this.Text, this.Font.FontFamily, (int)FontStyle.Regular, this.Font.Size * 1.2f, new Point(0, 0), StringFormat.GenericDefault); string tmp = this.Text; while (stroke.GetBounds().Width > this.Width - 8) { tmp = tmp.Substring(0, tmp.Length - 1); stroke = new GraphicsPath(); stroke.AddString(tmp + "...", this.Font.FontFamily, (int)FontStyle.Regular, this.Font.Size * 1.2f, new Point(0, 0), StringFormat.GenericDefault); } RectangleF bounds = stroke.GetBounds(); Matrix translationMatrix = new Matrix(); if (this.TextAlign == ContentAlignment.TopRight || this.TextAlign == ContentAlignment.MiddleRight || this.TextAlign == ContentAlignment.BottomRight) { translationMatrix.Translate(this.Width - bounds.Width - 8, 0); } else if (this.TextAlign == ContentAlignment.TopCenter || this.TextAlign == ContentAlignment.MiddleCenter || this.TextAlign == ContentAlignment.BottomCenter) { translationMatrix.Translate((this.Width - bounds.Width - 8) / 2, 0); } if (this.TextAlign == ContentAlignment.MiddleLeft || this.TextAlign == ContentAlignment.MiddleRight || this.TextAlign == ContentAlignment.MiddleCenter) { translationMatrix.Translate(0, (this.Height - bounds.Height - 5) / 2); } else if (this.TextAlign == ContentAlignment.BottomLeft || this.TextAlign == ContentAlignment.BottomCenter || this.TextAlign == ContentAlignment.BottomRight) { translationMatrix.Translate(0, (this.Height - bounds.Height - 5)); } stroke.Transform(translationMatrix); e.Graphics.DrawPath(new Pen(Brushes.Black, 3.0f), stroke); /* Stroke */ e.Graphics.FillPath(Brushes.White, stroke); /* Text */ }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { GraphicsPath grPath = new GraphicsPath(); grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height); this.Region = new System.Drawing.Region(grPath); base.OnPaint(e); }
public override void DrawPath(GraphicsPath gfxPath) { throw new NotSupportedException(); //gx.DrawPath(internalPen, gfxPath.InnerPath as System.Drawing.Drawing2D.GraphicsPath); }
public override void DrawPath(GraphicsPath gfxPath) { //convert graphics path to skia path using (SKPath p = ResolveGraphicsPath(gfxPath)) { skCanvas.DrawPath(p, stroke); } }
protected override void OnResize(EventArgs e) { using (var path = new GraphicsPath()) { path.AddEllipse(new Rectangle(2, 2, this.Width - 4, this.Height - 4)); this.Region = new Region(path); } base.OnResize(e); }
protected override void OnResize(EventArgs e) { base.OnResize(e); using (var gp = new GraphicsPath()) { gp.AddEllipse(new Rectangle(0, 0, this.Width - 1, this.Height - 1)); this.Region = new Region(gp); } }
void MainForm_Load (object sender, EventArgs e) { GraphicsPath gp = new GraphicsPath (); gp.AddArc (_changeShapeButton.ClientRectangle, 0.0f, 360.0f); _changeShapeButton.Region = new Region (gp); InstructionsForm instructionsForm = new InstructionsForm (); instructionsForm.Show (); }
public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset) { this.fillPath = fillPath; this.strokePath = strokePath; this.baseCap = baseCap; this.baseInset = baseInset; }
/// <summary> /// Initilizes <c>Quadrilateral</c> object with given corner points. /// </summary> /// <param name="point1"> /// First <c>PointF</c>. /// </param> /// <param name="point2"> /// Second <c>PointF</c>. /// </param> /// <param name="point3"> /// Third <c>PointF</c>. /// </param> /// <param name="point4"> /// Fourth <c>PointF</c>. /// </param> /// <param name="toClose"> /// Indicator should the quadrilateral be closed by the line. /// </param> public Quadrilateral(PointF point1, PointF point2, PointF point3, PointF point4, bool toClose) { byte[] pointTypes = (byte[])s_quadrilateralPointTypes.Clone(); if (toClose) pointTypes[3] |= (byte)PathPointType.PathPointTypeCloseSubpath;//CloseSubpath; m_path = new GraphicsPath();//new GraphicsPath(new PointF[] { point1, point2, point3, point4 }, pointTypes); //m_path. }
static internal GraphicsPath CreateRound(Rectangle r, int slope) { CreateRoundPath = new GraphicsPath(FillMode.Winding); CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180f, 90f); CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270f, 90f); CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0f, 90f); CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90f, 90f); CreateRoundPath.CloseFigure(); return CreateRoundPath; }
public static GraphicsPath RoundRect(Rectangle rect, int Curve) { GraphicsPath P = new GraphicsPath(); int ArcRectWidth = Curve * 2; P.AddArc(new Rectangle(rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -180, 90); P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Y, ArcRectWidth, ArcRectWidth), -90, 90); P.AddArc(new Rectangle(rect.Width - ArcRectWidth + rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 0, 90); P.AddArc(new Rectangle(rect.X, rect.Height - ArcRectWidth + rect.Y, ArcRectWidth, ArcRectWidth), 90, 90); P.AddLine(new Point(rect.X, rect.Height - ArcRectWidth + rect.Y), new Point(rect.X, Curve + rect.Y)); return P; }
public static GraphicsPath GetArrowLinePath(float x1, float y1, float x2, float y2, bool include_arrow, float extra_thickness = 0) { var newPoints = GetArrowLinePoints(x1, y1, x2, y2, extra_thickness); var path = new GraphicsPath(FillMode.Winding); path.AddLines(newPoints.ToArray()); //if (include_arrow) // path.AddLines(GetArrowPoints(x2, y2, extra_thickness).ToArray()); //path.CloseFigure(); return path; }
public CustomLineCap(GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset) { IntPtr fill = IntPtr.Zero; IntPtr stroke = IntPtr.Zero; if (fillPath != null) fill = fillPath.nativePath; if (strokePath != null) stroke = strokePath.nativePath; Status status = GDIPlus.GdipCreateCustomLineCap (fill, stroke, baseCap, baseInset, out nativeObject); GDIPlus.CheckStatus (status); }
public ThemeContainer154() { SetStyle((ControlStyles)139270, true); _ImageSize = Size.Empty; Font = new Font("Verdana", 8); MeasureBitmap = new Bitmap(1, 1); MeasureGraphics = Graphics.FromImage(MeasureBitmap); DrawRadialPath = new GraphicsPath(); InvalidateCustimization(); }
protected override void OnResize(EventArgs e) { Height = 19; Width = 47; RoundedRectangle = new GraphicsPath(); int radius = 10; RoundedRectangle.AddArc(11, 4, radius - 1, radius, 180, 90); RoundedRectangle.AddArc(Width - 21, 4, radius - 1, radius, -90, 90); RoundedRectangle.AddArc(Width - 21, Height - 15, radius - 1, radius, 0, 90); RoundedRectangle.AddArc(11, Height - 15, radius - 1, radius, 90, 90); RoundedRectangle.CloseAllFigures(); Invalidate(); }
public static GraphicsPath CreateRoundRect(float x, float y, float width, float height, float radius) { GraphicsPath gp = new GraphicsPath(); gp.AddLine(x + radius, y, x + width - (radius * 2), y); gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2)); gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height); gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); gp.AddLine(x, y + height - (radius * 2), x, y + radius); gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); gp.CloseFigure(); return gp; }
private void IrregularForm_Load(object sender, EventArgs e) { GraphicsPath path = new GraphicsPath(); Point[] pointsA = new Point[] { new Point(0, 0), new Point(40, 60), new Point(this.Width - 100, 10) }; path.AddCurve(pointsA); Point[] pointsB = new Point[]{ new Point(this.Width - 40, this.Height - 60), new Point(this.Width, this.Height), new Point(10, this.Height) }; path.AddCurve(pointsB); path.CloseAllFigures(); this.Region = new Region(path); }
public static GraphicsPath CreateRoundedRectangle(SizeF size, PointF location) { int cornerSize = (int)GraphConstants.CornerSize * 2; var height = size.Height; var width = size.Width; var left = location.X; var top = location.Y; var right = location.X + width; var bottom = location.Y + height; var path = new GraphicsPath(FillMode.Winding); path.AddArc(left, top, cornerSize, cornerSize, 180, 90); path.AddArc(right - cornerSize, top, cornerSize, cornerSize, 270, 90); path.AddArc(right - cornerSize, bottom - cornerSize, cornerSize, cornerSize, 0, 90); path.AddArc(left, bottom - cornerSize, cornerSize, cornerSize, 90, 90); path.CloseFigure(); return path; }
public static void Run() { // ExStart:DrawingUsingGraphicsPath // The path to the documents directory. string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages(); // Create an instance of BmpOptions and set its various properties BmpOptions ImageOptions = new BmpOptions(); ImageOptions.BitsPerPixel = 24; // Create an instance of FileCreateSource and assign it to Source property ImageOptions.Source = new FileCreateSource(dataDir + "sample_1.bmp", false); // Create an instance of Image and initialize an instance of Graphics using (Image image = Image.Create(ImageOptions, 500, 500)) { Graphics graphics = new Graphics(image); graphics.Clear(Color.White); // Create an instance of GraphicsPath and Instance of Figure, add EllipseShape, RectangleShape and TextShape to the figure GraphicsPath graphicspath = new GraphicsPath(); Figure figure = new Figure(); figure.AddShape(new EllipseShape(new RectangleF(0, 0, 499, 499))); figure.AddShape(new RectangleShape(new RectangleF(0, 0, 499, 499))); figure.AddShape(new TextShape("Aspose.Imaging", new RectangleF(170, 225, 170, 100), new Font("Arial", 20), StringFormat.GenericTypographic)); graphicspath.AddFigures(new[] { figure }); graphics.DrawPath(new Pen(Color.Blue), graphicspath); // Create an instance of HatchBrush and set its properties also Fill path by supplying the brush and GraphicsPath objects HatchBrush hatchbrush = new HatchBrush(); hatchbrush.BackgroundColor = Color.Brown; hatchbrush.ForegroundColor = Color.Blue; hatchbrush.HatchStyle = HatchStyle.Vertical; graphics.FillPath(hatchbrush, graphicspath); image.Save(); Console.WriteLine("Processing completed successfully."); } // ExEnd:DrawingUsingGraphicsPath }
private void DrawBar(Graphics objGraphics, int Value, int BarNumber, string Label) { int intLeft = (BarNumber*75)+60; int intBottom = 275; int intHeight = (25*Value); //绘制柱面 objGraphics.FillRectangle(Brushes.Red,intLeft, intBottom-intHeight,35,intHeight); //使用GraphicsPath方法绘制柱面顶层 GraphicsPath pthTop = new GraphicsPath(); pthTop.AddLine(intLeft-1, intBottom-intHeight, intLeft+20, intBottom-intHeight-10); pthTop.AddLine(intLeft+55,intBottom- intHeight-10,intLeft+35, intBottom-intHeight); objGraphics.FillPath(Brushes.LightSalmon, pthTop); // 绘制柱面左侧 GraphicsPath pthRight = new GraphicsPath(); pthRight.AddLine(intLeft+35,intBottom- intHeight,intLeft+55,intBottom- intHeight-10); pthRight.AddLine(intLeft+55, intBottom-15,intLeft+35,intBottom); objGraphics.FillPath(Brushes.Firebrick, pthRight); //绘制标签 objGraphics.TranslateTransform(intLeft+15, intBottom-intHeight - 30); objGraphics.RotateTransform(300); objGraphics.DrawString(Label,new Font("Arial",10,FontStyle.Bold), Brushes.Black,0,0); objGraphics.ResetTransform(); }
private void ConstructGraphicsPath(Graphics g) { //GraphicsPath gp = null; if (regionGP != null) { regionGP.Dispose(); } regionGP = new GraphicsPath(); if (this.relStreamPoint.Orientation == PointOrientation.E && this.relUnitOpPoint.Orientation == PointOrientation.W) { this.ConstructGraphicsPathEtoW(g); } else if (this.relStreamPoint.Orientation == PointOrientation.S && this.relUnitOpPoint.Orientation == PointOrientation.W) { this.ConstructGraphicsPathStoW(g); } else if (this.relStreamPoint.Orientation == PointOrientation.W && this.relUnitOpPoint.Orientation == PointOrientation.W) { this.ConstructGraphicsPathWtoW(g); } else if (this.relStreamPoint.Orientation == PointOrientation.N && this.relUnitOpPoint.Orientation == PointOrientation.W) { this.ConstructGraphicsPathNtoW(g); } else if (this.relStreamPoint.Orientation == PointOrientation.E && this.relUnitOpPoint.Orientation == PointOrientation.N) { this.ConstructGraphicsPathEtoN(g); } else if (this.relStreamPoint.Orientation == PointOrientation.S && this.relUnitOpPoint.Orientation == PointOrientation.N) { this.ConstructGraphicsPathStoN(g); } else if (this.relStreamPoint.Orientation == PointOrientation.W && this.relUnitOpPoint.Orientation == PointOrientation.N) { this.ConstructGraphicsPathWtoN(g); } else if (this.relStreamPoint.Orientation == PointOrientation.N && this.relUnitOpPoint.Orientation == PointOrientation.N) { this.ConstructGraphicsPathNtoN(g); } else if (this.relStreamPoint.Orientation == PointOrientation.E && this.relUnitOpPoint.Orientation == PointOrientation.E) { this.ConstructGraphicsPathEtoE(g); } else if (this.relStreamPoint.Orientation == PointOrientation.S && this.relUnitOpPoint.Orientation == PointOrientation.E) { this.ConstructGraphicsPathStoE(g); } else if (this.relStreamPoint.Orientation == PointOrientation.W && this.relUnitOpPoint.Orientation == PointOrientation.E) { this.ConstructGraphicsPathWtoE(g); } else if (this.relStreamPoint.Orientation == PointOrientation.N && this.relUnitOpPoint.Orientation == PointOrientation.E) { this.ConstructGraphicsPathNtoE(g); } else if (this.relStreamPoint.Orientation == PointOrientation.E && this.relUnitOpPoint.Orientation == PointOrientation.S) { this.ConstructGraphicsPathEtoS(g); } else if (this.relStreamPoint.Orientation == PointOrientation.S && this.relUnitOpPoint.Orientation == PointOrientation.S) { this.ConstructGraphicsPathStoS(g); } else if (this.relStreamPoint.Orientation == PointOrientation.W && this.relUnitOpPoint.Orientation == PointOrientation.S) { this.ConstructGraphicsPathWtoS(g); } else if (this.relStreamPoint.Orientation == PointOrientation.N && this.relUnitOpPoint.Orientation == PointOrientation.S) { this.ConstructGraphicsPathNtoS(g); } //return gp; }
internal override void Render(MapGraphics g) { base.Render(g); if (IsEmpty) { return; } RectangleF absoluteRectangle = g.GetAbsoluteRectangle(new RectangleF(0f, 0f, 100f, 100f)); bool flag = false; try { if (Colors.Count == 0 && Common != null && Common.MapCore.IsDesignMode()) { PopulateDummyData(); flag = true; } int num = (LabelAlignment != LabelAlignment.Alternate) ? 1 : 2; SwatchLabelType swatchLabelType = GetLabelType(); SizeF colorBoxSize = default(SizeF); SizeF labelBoxSize = default(SizeF); SizeF firstCaptionSize = default(SizeF); SizeF lastCaptionSize = default(SizeF); CalculateFontDependentData(g, absoluteRectangle.Size); absoluteRectangle.Inflate(-PanelPadding, -PanelPadding); if (absoluteRectangle.Width < 1f || absoluteRectangle.Height < 1f) { return; } int[] colorsRef = GetColorsRef(swatchLabelType); float num2 = 0f; if (LabelInterval > 0 && ShowEndLabels) { firstCaptionSize = g.MeasureString(GetLabelCaption(0, getFromValue: true, swatchLabelType), Font, absoluteRectangle.Size, StringFormat.GenericTypographic); firstCaptionSize.Width += TrimmingProtector; lastCaptionSize = g.MeasureString(GetLabelCaption(Colors.Count - 1, getFromValue: false, swatchLabelType), Font, absoluteRectangle.Size, StringFormat.GenericTypographic); lastCaptionSize.Width += TrimmingProtector; num2 = Math.Max(firstCaptionSize.Width, lastCaptionSize.Width); } bool flag2 = !string.IsNullOrEmpty(Title); RectangleF layoutRectangle = absoluteRectangle; if (flag2) { float num4 = layoutRectangle.Height = Math.Min(absoluteRectangle.Height, g.MeasureString(Title, TitleFont, layoutRectangle.Size, StringFormat.GenericTypographic).Height + (float)TitleSeparatorSize); absoluteRectangle.Y += num4; absoluteRectangle.Height -= num4; titlePosition = layoutRectangle; } RectangleF colorBarBounds = CalculateMaxColorBarBounds(g, absoluteRectangle, num2, colorsRef.Length, swatchLabelType); float num5 = 0f; float num6 = 0f; if (LabelInterval > 0) { num5 = GetLabelMaxSize(g, absoluteRectangle.Size, swatchLabelType).Height; num6 = TickMarkLength + TickMarkLabelGapSize; } float val = Math.Max(3f, (absoluteRectangle.Height - num6) / 5f); colorBoxSize.Height = Math.Max(val, absoluteRectangle.Height - (float)num * (num6 + num5)); colorBoxSize.Width = colorBarBounds.Width / (float)colorsRef.Length; colorBarBounds.Height = colorBoxSize.Height; labelBoxSize.Height = Math.Max(0f, absoluteRectangle.Height - colorBoxSize.Height) / (float)num - num6; labelBoxSize.Width = colorBoxSize.Width * (float)LabelInterval * (float)num; if (LabelAlignment == LabelAlignment.Top || LabelAlignment == LabelAlignment.Alternate) { colorBarBounds.Y += labelBoxSize.Height + num6; } AntiAliasing antiAliasing = g.AntiAliasing; try { g.AntiAliasing = AntiAliasing.None; CreateColorBarPath(absoluteRectangle, colorBarBounds, colorsRef, swatchLabelType, out GraphicsPath outlinePath, out GraphicsPath fillPath); GraphicsPathIterator graphicsPathIterator = new GraphicsPathIterator(fillPath); GraphicsPath graphicsPath = new GraphicsPath(); Pen pen = new Pen(OutlineColor); try { int[] array = colorsRef; foreach (int colorIndex in array) { graphicsPath.Reset(); graphicsPathIterator.NextSubpath(graphicsPath, out bool isClosed); if (isClosed) { using (Brush brush = CreateColorBoxBrush(g, graphicsPath.GetBounds(), colorIndex)) { g.FillPath(brush, graphicsPath); } } } g.DrawPath(pen, outlinePath); } finally { outlinePath.Dispose(); fillPath.Dispose(); graphicsPathIterator.Dispose(); graphicsPath.Dispose(); pen.Dispose(); } } finally { g.AntiAliasing = antiAliasing; } if (flag2) { using (Brush brush2 = new SolidBrush(TitleColor)) { using (StringFormat stringFormat = (StringFormat)StringFormat.GenericTypographic.Clone()) { stringFormat.Alignment = TitleAlignment; stringFormat.LineAlignment = StringAlignment.Near; stringFormat.Trimming = StringTrimming.EllipsisCharacter; stringFormat.FormatFlags = StringFormatFlags.NoWrap; g.DrawString(Title, TitleFont, brush2, layoutRectangle, stringFormat); } } } if (Colors.Count == 0 || LabelInterval == 0) { return; } using (StringFormat stringFormat2 = (StringFormat)StringFormat.GenericTypographic.Clone()) { stringFormat2.Alignment = StringAlignment.Center; stringFormat2.LineAlignment = StringAlignment.Near; stringFormat2.Trimming = StringTrimming.EllipsisCharacter; stringFormat2.FormatFlags = StringFormatFlags.NoWrap; using (Brush brush3 = new SolidBrush(LabelColor)) { bool flag3 = LabelAlignment != LabelAlignment.Top; if (swatchLabelType == SwatchLabelType.ShowMiddleValue) { for (int j = 0; j < colorsRef.Length; j++) { if (!MustPrintLabel(colorsRef, j, isFromValue: true, swatchLabelType)) { continue; } StringAlignment horizontalAlignemnt; RectangleF labelBounds = GetLabelBounds(j, colorsRef, absoluteRectangle, colorBarBounds, labelBoxSize, colorBoxSize, num2, getFromValue: true, swatchLabelType, flag3, firstCaptionSize, lastCaptionSize, out horizontalAlignemnt); string labelCaption = GetLabelCaption(j, getFromValue: true, swatchLabelType); if (labelBounds.Width > 1f && labelBounds.Height > 1f) { if (flag3) { labelBounds.Offset(0f, 1f); } stringFormat2.Alignment = horizontalAlignemnt; g.DrawString(labelCaption, Font, brush3, labelBounds, stringFormat2); } flag3 = ((LabelAlignment == LabelAlignment.Alternate) ? (!flag3) : flag3); } return; } for (int k = 0; k < colorsRef.Length; k++) { RectangleF labelBounds2; string labelCaption2; if (MustPrintLabel(colorsRef, k, isFromValue: true, swatchLabelType)) { labelBounds2 = GetLabelBounds(colorsRef[k], colorsRef, absoluteRectangle, colorBarBounds, labelBoxSize, colorBoxSize, num2, getFromValue: true, swatchLabelType, flag3, firstCaptionSize, lastCaptionSize, out StringAlignment horizontalAlignemnt2); labelCaption2 = GetLabelCaption(colorsRef[k], getFromValue: true, swatchLabelType); if (labelBounds2.Width > 1f && labelBounds2.Height > 1f) { if (flag3) { labelBounds2.Offset(0f, 1f); } stringFormat2.Alignment = horizontalAlignemnt2; g.DrawString(labelCaption2, Font, brush3, labelBounds2, stringFormat2); } flag3 = ((LabelAlignment == LabelAlignment.Alternate) ? (!flag3) : flag3); } if (!MustPrintLabel(colorsRef, k, isFromValue: false, swatchLabelType)) { continue; } labelBounds2 = GetLabelBounds(colorsRef[k], colorsRef, absoluteRectangle, colorBarBounds, labelBoxSize, colorBoxSize, num2, getFromValue: false, swatchLabelType, flag3, firstCaptionSize, lastCaptionSize, out StringAlignment horizontalAlignemnt3); labelCaption2 = GetLabelCaption(colorsRef[k], getFromValue: false, swatchLabelType); if (labelBounds2.Width > 1f && labelBounds2.Height > 1f) { if (flag3) { labelBounds2.Offset(0f, 1f); } stringFormat2.Alignment = horizontalAlignemnt3; g.DrawString(labelCaption2, Font, brush3, labelBounds2, stringFormat2); } flag3 = ((LabelAlignment == LabelAlignment.Alternate) ? (!flag3) : flag3); } } } } finally { if (flag) { Colors.Clear(); } } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { G = e.Graphics; G.Clear(BackColor); GP1 = DrawArrow(6, 4, false); GP2 = DrawArrow(7, 5, false); G.FillPath(B1, GP2); G.FillPath(B2, GP1); GP3 = DrawArrow(Width - 11, 4, true); GP4 = DrawArrow(Width - 10, 5, true); G.FillPath(B1, GP4); G.FillPath(B2, GP3); if (ShowThumb) { G.FillRectangle(B1, Thumb); G.DrawRectangle(P1, Thumb); G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2); int X = 0; int LX = Thumb.X + (Thumb.Width / 2) - 3; for (int I = 0; I <= 2; I++) { X = LX + (I * 3); G.DrawLine(P1, X, Thumb.Y + 5, X, Thumb.Bottom - 5); G.DrawLine(P2, X + 1, Thumb.Y + 5, X + 1, Thumb.Bottom - 5); } } G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1); G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3); }
/// <summary> /// Resets the path. /// </summary> private void ResetPath() { Point[] ps = null; switch (direction) { case ArrowDirection.Left: ps = new Point[] { new Point(0, this.Height / 2), new Point(40, 0), new Point(40, this.Height / 4), new Point(this.Width - 1, this.Height / 4), new Point(this.Width - 1, this.Height - this.Height / 4), new Point(40, this.Height - this.Height / 4), new Point(40, this.Height), new Point(0, this.Height / 2) }; break; case ArrowDirection.Right: ps = new Point[] { new Point(0, this.Height / 4), new Point(this.Width - 40, this.Height / 4), new Point(this.Width - 40, 0), new Point(this.Width - 1, this.Height / 2), new Point(this.Width - 40, this.Height), new Point(this.Width - 40, this.Height - this.Height / 4), new Point(0, this.Height - this.Height / 4), new Point(0, this.Height / 4) }; break; case ArrowDirection.Top: ps = new Point[] { new Point(this.Width / 2, 0), new Point(this.Width, 40), new Point(this.Width - this.Width / 4, 40), new Point(this.Width - this.Width / 4, this.Height - 1), new Point(this.Width / 4, this.Height - 1), new Point(this.Width / 4, 40), new Point(0, 40), new Point(this.Width / 2, 0), }; break; case ArrowDirection.Bottom: ps = new Point[] { new Point(this.Width - this.Width / 4, 0), new Point(this.Width - this.Width / 4, this.Height - 40), new Point(this.Width, this.Height - 40), new Point(this.Width / 2, this.Height - 1), new Point(0, this.Height - 40), new Point(this.Width / 4, this.Height - 40), new Point(this.Width / 4, 0), new Point(this.Width - this.Width / 4, 0), }; break; case ArrowDirection.Left_Right: ps = new Point[] { new Point(0, this.Height / 2), new Point(40, 0), new Point(40, this.Height / 4), new Point(this.Width - 40, this.Height / 4), new Point(this.Width - 40, 0), new Point(this.Width - 1, this.Height / 2), new Point(this.Width - 40, this.Height), new Point(this.Width - 40, this.Height - this.Height / 4), new Point(40, this.Height - this.Height / 4), new Point(40, this.Height), new Point(0, this.Height / 2), }; break; case ArrowDirection.Top_Bottom: ps = new Point[] { new Point(this.Width / 2, 0), new Point(this.Width, 40), new Point(this.Width - this.Width / 4, 40), new Point(this.Width - this.Width / 4, this.Height - 40), new Point(this.Width, this.Height - 40), new Point(this.Width / 2, this.Height - 1), new Point(0, this.Height - 40), new Point(this.Width / 4, this.Height - 40), new Point(this.Width / 4, 40), new Point(0, 40), new Point(this.Width / 2, 0), }; break; } m_path = new GraphicsPath(); m_path.AddLines(ps); m_path.CloseAllFigures(); }
protected override void OnMouseLeave(EventArgs e) { Graphics g = CreateGraphics(); g.SmoothingMode = SmoothingMode.AntiAlias; RectangleF tabTextArea = RectangleF.Empty; for (int nIndex = 0; nIndex < this.TabCount; nIndex++) { if (nIndex != this.SelectedIndex) { tabTextArea = (RectangleF)this.GetTabRect(nIndex); GraphicsPath _Path = new GraphicsPath(); _Path.AddRectangle(tabTextArea); using (LinearGradientBrush _Brush = new LinearGradientBrush(tabTextArea, SystemColors.Control, SystemColors.ControlLight, LinearGradientMode.Vertical)) { ColorBlend _ColorBlend = new ColorBlend(3); _ColorBlend.Colors = new Color[] { SystemColors.ActiveBorder, SystemColors.ActiveBorder, SystemColors.ActiveBorder, SystemColors.ActiveBorder }; _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; _Brush.InterpolationColors = _ColorBlend; g.FillRectangle(_Brush, tabTextArea.X + tabTextArea.Width - 22, 4, tabTextArea.Height - 2, tabTextArea.Height - 5); g.DrawRectangle(Pens.White, tabTextArea.X + tabTextArea.Width - 20, 6, tabTextArea.Height - 8, tabTextArea.Height - 9); using (Pen pen = new Pen(Color.White, 2)) { g.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 16, 9, tabTextArea.X + tabTextArea.Width - 7, 17); g.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 16, 17, tabTextArea.X + tabTextArea.Width - 7, 9); } if (CanDrawMenuButton(nIndex)) { _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; // assign the color blend to the pathgradientbrush _Brush.InterpolationColors = _ColorBlend; g.FillRectangle(_Brush, tabTextArea.X + tabTextArea.Width - 43, 4, tabTextArea.Height - 3, tabTextArea.Height - 5); // e.Graphics.DrawRectangle(SystemPens.GradientInactiveCaption, tabTextArea.X + tabTextArea.Width - 37, 7, 13, 13); g.DrawRectangle(new Pen(Color.White), tabTextArea.X + tabTextArea.Width - 41, 6, tabTextArea.Height - 7, tabTextArea.Height - 9); using (Pen pen = new Pen(Color.White, 2)) { g.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 36, 11, tabTextArea.X + tabTextArea.Width - 33, 16); g.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 33, 16, tabTextArea.X + tabTextArea.Width - 30, 11); } } } _Path.Dispose(); } else { tabTextArea = (RectangleF)this.GetTabRect(nIndex); GraphicsPath _Path = new GraphicsPath(); _Path.AddRectangle(tabTextArea); using (LinearGradientBrush _Brush = new LinearGradientBrush(tabTextArea, SystemColors.Control, SystemColors.ControlLight, LinearGradientMode.Vertical)) { ColorBlend _ColorBlend = new ColorBlend(3); _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; _ColorBlend.Colors = new Color[] { Color.FromArgb(255, 231, 164, 152), Color.FromArgb(255, 231, 164, 152), Color.FromArgb(255, 197, 98, 79), Color.FromArgb(255, 197, 98, 79) }; _Brush.InterpolationColors = _ColorBlend; g.FillRectangle(_Brush, tabTextArea.X + tabTextArea.Width - 22, 4, tabTextArea.Height - 3, tabTextArea.Height - 5); g.DrawRectangle(Pens.White, tabTextArea.X + tabTextArea.Width - 20, 6, tabTextArea.Height - 8, tabTextArea.Height - 9); using (Pen pen = new Pen(Color.White, 2)) { g.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 16, 9, tabTextArea.X + tabTextArea.Width - 7, 17); g.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 16, 17, tabTextArea.X + tabTextArea.Width - 7, 9); } if (CanDrawMenuButton(nIndex)) { //Drawing menu button _ColorBlend.Colors = new Color[] { SystemColors.ControlLightLight, Color.FromArgb(255, SystemColors.ControlLight), SystemColors.ControlDark, SystemColors.ControlLightLight }; _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; _Brush.InterpolationColors = _ColorBlend; _ColorBlend.Colors = new Color[] { Color.FromArgb(255, 170, 213, 243), Color.FromArgb(255, 170, 213, 243), Color.FromArgb(255, 44, 137, 191), Color.FromArgb(255, 44, 137, 191) }; _Brush.InterpolationColors = _ColorBlend; g.FillRectangle(_Brush, tabTextArea.X + tabTextArea.Width - 43, 4, tabTextArea.Height - 3, tabTextArea.Height - 5); g.DrawRectangle(Pens.White, tabTextArea.X + tabTextArea.Width - 41, 6, tabTextArea.Height - 7, tabTextArea.Height - 9); using (Pen pen = new Pen(Color.White, 2)) { g.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 36, 11, tabTextArea.X + tabTextArea.Width - 33, 16); g.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 33, 16, tabTextArea.X + tabTextArea.Width - 30, 11); } } } _Path.Dispose(); } } g.Dispose(); }
/// <summary> /// Перерисовует объект. /// </summary> public override void PreRender() { GrPath = new GraphicsPath(FillMode.Winding); GrPath.AddEllipse(Center.X, Center.Y, Radius, Radius); }
//Scale, Rotate, Translate //Draw the asteroid and does each change on the shape one at a time in this order so that the shape doesn't get convoluted public override GraphicsPath GetPath(Rectangle r) { GraphicsPath copy = (GraphicsPath)_modelGraphicsPath.Clone(); Matrix mat = new Matrix(); //Only lets the asteroids rotate when the game isn't paused if (!IsPaused) { mat.Rotate(_dRotation++); copy.Transform(mat); } else { mat.Rotate(_dRotation); copy.Transform(mat); } //Moves the asteroid to the proper position in the client rectangle mat.Reset(); mat.Translate(_position.X, _position.Y); copy.Transform(mat); //If the original asteroid is starting to disappear into a wall then draw copies of that asteriod on all the different directions and add it to the path if (_position.X < _cfRadius || _position.Y < _cfRadius || (r.Width - _position.X) < _cfRadius || (r.Height - _position.Y) < _cfRadius) //Checks if the asteroid has hit a wall { GraphicsPath mirror1 = (GraphicsPath)copy.Clone(); mat.Reset(); mat.Translate(-r.Width, r.Height); mirror1.Transform(mat); GraphicsPath mirror2 = (GraphicsPath)copy.Clone(); mat.Reset(); mat.Translate(0, r.Height); mirror2.Transform(mat); GraphicsPath mirror3 = (GraphicsPath)copy.Clone(); mat.Reset(); mat.Translate(r.Width, r.Height); mirror3.Transform(mat); GraphicsPath mirror4 = (GraphicsPath)copy.Clone(); mat.Reset(); mat.Translate(-r.Width, 0); mirror4.Transform(mat); GraphicsPath mirror5 = (GraphicsPath)copy.Clone(); mat.Reset(); mat.Translate(r.Width, 0); mirror5.Transform(mat); GraphicsPath mirror6 = (GraphicsPath)copy.Clone(); mat.Reset(); mat.Translate(-r.Width, -r.Height); mirror6.Transform(mat); GraphicsPath mirror7 = (GraphicsPath)copy.Clone(); mat.Reset(); mat.Translate(0, -r.Height); mirror7.Transform(mat); GraphicsPath mirror8 = (GraphicsPath)copy.Clone(); mat.Reset(); mat.Translate(r.Width, -r.Height); mirror8.Transform(mat); copy.AddPath(mirror1, false); copy.AddPath(mirror2, false); copy.AddPath(mirror3, false); copy.AddPath(mirror4, false); copy.AddPath(mirror5, false); copy.AddPath(mirror6, false); copy.AddPath(mirror7, false); copy.AddPath(mirror8, false); } return(copy); }
public override void AddGp(GraphicsPath gp, int dx, int dy, float zoom) { gp.AddRectangle(new RectangleF((Location0.X + dx) * zoom, (Location0.Y + dy) * zoom, (Location1.X - Location0.X) * zoom, (Location1.Y - Location0.Y) * zoom)); }
/// <summary> /// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。 /// </summary> /// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param> protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var g = e.Graphics; g.SetGDIHigh(); //玻璃管管 GraphicsPath path = new GraphicsPath(); path.AddLine(m_rectWorking.Left, m_rectWorking.Bottom, m_rectWorking.Left, m_rectWorking.Top + m_rectWorking.Width / 2); path.AddArc(new Rectangle(m_rectWorking.Left, m_rectWorking.Top, m_rectWorking.Width, m_rectWorking.Width), 180, 180); path.AddLine(m_rectWorking.Right, m_rectWorking.Top + m_rectWorking.Width / 2, m_rectWorking.Right, m_rectWorking.Bottom); path.CloseAllFigures(); g.FillPath(new SolidBrush(glassTubeColor), path); //底部 var rectDi = new Rectangle(this.Width / 2 - m_rectWorking.Width, m_rectWorking.Bottom - m_rectWorking.Width - 2, m_rectWorking.Width * 2, m_rectWorking.Width * 2); g.FillEllipse(new SolidBrush(glassTubeColor), rectDi); g.FillEllipse(new SolidBrush(mercuryColor), new Rectangle(rectDi.Left + 4, rectDi.Top + 4, rectDi.Width - 8, rectDi.Height - 8)); //刻度 decimal decSplit = (maxValue - minValue) / splitCount; decimal decSplitHeight = m_rectLeft.Height / splitCount; for (int i = 0; i <= splitCount; i++) { g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Left + 2, (float)(m_rectLeft.Bottom - decSplitHeight * i)), new PointF(m_rectLeft.Right, (float)(m_rectLeft.Bottom - decSplitHeight * i))); var valueLeft = (minValue + decSplit * i).ToString("0.##"); var sizeLeft = g.MeasureString(valueLeft, Font); g.DrawString(valueLeft, Font, new SolidBrush(ForeColor), new PointF(m_rectLeft.Left, m_rectLeft.Bottom - (float)decSplitHeight * i - sizeLeft.Height - 1)); if (rightTemperatureUnit != TemperatureUnit.None) { g.DrawLine(new Pen(new SolidBrush(Color.Black), 1), new PointF(m_rectRight.Left + 2, (float)(m_rectRight.Bottom - decSplitHeight * i)), new PointF(m_rectRight.Right, (float)(m_rectRight.Bottom - decSplitHeight * i))); var valueRight = GetRightValue(minValue + decSplit * i).ToString("0.##"); var sizeRight = g.MeasureString(valueRight, Font); g.DrawString(valueRight, Font, new SolidBrush(ForeColor), new PointF(m_rectRight.Right - sizeRight.Width - 1, m_rectRight.Bottom - (float)decSplitHeight * i - sizeRight.Height - 1)); } if (i != splitCount) { if (decSplitHeight > 40) { var decSp1 = decSplitHeight / 10; for (int j = 1; j < 10; j++) { if (j == 5) { g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Right - 10, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectLeft.Right, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j)))); if (rightTemperatureUnit != TemperatureUnit.None) { g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectRight.Left + 10, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectRight.Left, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j)))); } } else { g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Right - 5, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectLeft.Right, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j)))); if (rightTemperatureUnit != TemperatureUnit.None) { g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectRight.Left + 5, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectRight.Left, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j)))); } } } } else if (decSplitHeight > 10) { g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Right - 5, (m_rectLeft.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)), new PointF(m_rectLeft.Right, (m_rectLeft.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2))); if (rightTemperatureUnit != TemperatureUnit.None) { g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectRight.Left + 5, (m_rectRight.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)), new PointF(m_rectRight.Left, (m_rectRight.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2))); } } } } //单位 string strLeftUnit = GetUnitChar(leftTemperatureUnit); g.DrawString(strLeftUnit, Font, new SolidBrush(ForeColor), new PointF(m_rectLeft.Left + 2, 2)); if (rightTemperatureUnit != TemperatureUnit.None) { string strRightUnit = GetUnitChar(rightTemperatureUnit); var rightSize = g.MeasureString(strRightUnit, Font); g.DrawString(strRightUnit, Font, new SolidBrush(ForeColor), new PointF(m_rectRight.Right - 2 - rightSize.Width, 2)); } //值 float fltHeightValue = (float)(Value / (maxValue - minValue) * m_rectLeft.Height); RectangleF rectValue = new RectangleF(m_rectWorking.Left + 4, m_rectLeft.Top + (m_rectLeft.Height - fltHeightValue), m_rectWorking.Width - 8, fltHeightValue + (m_rectWorking.Height - m_rectWorking.Width / 2 - m_rectLeft.Height)); g.FillRectangle(new SolidBrush(mercuryColor), rectValue); var sizeValue = g.MeasureString(m_value.ToString("0.##"), Font); g.DrawString(m_value.ToString("0.##"), Font, new SolidBrush(Color.White), new PointF(rectDi.Left + (rectDi.Width - sizeValue.Width) / 2, rectDi.Top + (rectDi.Height - sizeValue.Height) / 2 + 1)); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { G = e.Graphics; G.Clear(BackColor); G.SmoothingMode = SmoothingMode.AntiAlias; GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7); GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7); R1 = new Rectangle(0, 2, Width - 1, Height - 1); GB1 = new LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90f); G.SetClip(GP1); G.FillRectangle(GB1, R1); I1 = Convert.ToInt32((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3)); if (I1 > 1) { GP3 = ThemeModule.CreateRound(1, 1, I1, Height - 3, 7); R2 = new Rectangle(1, 1, I1, Height - 3); GB2 = new LinearGradientBrush(R2, Color.FromArgb(205, 150, 0), Color.FromArgb(150, 110, 0), 90f); G.FillPath(GB2, GP3); G.DrawPath(P1, GP3); G.SetClip(GP3); G.SmoothingMode = SmoothingMode.None; G.FillRectangle(B1, R2.X, R2.Y + 1, R2.Width, R2.Height / 2); G.SmoothingMode = SmoothingMode.AntiAlias; G.ResetClip(); } G.DrawPath(P2, GP1); G.DrawPath(P1, GP2); }
public override void AddToPath(GraphicsPath graphicsPath) { graphicsPath.StartFigure(); }
protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); if (!_bShow) { return; } Font stateFont = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point); StringFormat strFormat = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; Pen borderPen = new Pen(Color.ForestGreen, 1); Pen redPen = new Pen(Color.Red, 2); Pen connectorPen = new Pen(Color.FromArgb(0x33, 0x00, 0x33), 1); Brush arrowBrush = new SolidBrush(Color.FromArgb(0x33, 0x00, 0x33)); foreach (Selectable _selectable in _selectables) { CurvedStateConnector curvedConnector = null; if (_selectable is StateConnector) { var connector = _selectable as StateConnector; if (connector.Label.IsSelected) { Pen labelBorderPen = new Pen(Color.DarkRed, 1.5f) { DashStyle = DashStyle.Dash }; var labelRect = connector.Label.GetRect(_automatGraphics); _automatGraphics.DrawRectangle(labelBorderPen, labelRect.Left, labelRect.Top, labelRect.Width, labelRect.Height); labelBorderPen.Dispose(); } Pen pen = connector.IsSelected ? redPen : connectorPen; if (_selectable is CurvedStateConnector) { curvedConnector = _selectable as CurvedStateConnector; } if (curvedConnector != null && curvedConnector.ControlPoints[0] != _InvalidPoint && curvedConnector.ControlPoints[1] != _InvalidPoint) { _automatGraphics.DrawBezier(pen, curvedConnector.SourceState.Position, curvedConnector.ControlPoints[0], curvedConnector.ControlPoints[1], curvedConnector.DestinationState.Position); _automatGraphics.DrawString(curvedConnector.Label.Text, ConnectorLabel.LabelFont, Brushes.Brown, connector.Label.Position); } else { _automatGraphics.DrawLine(pen, connector.SourceState.Position, connector.DestinationState.Position); _automatGraphics.DrawString(connector.Label.Text, ConnectorLabel.LabelFont, Brushes.Brown, connector.Label.Position); } if (connector.ArrowPoints != null) { _automatGraphics.DrawLine(pen, connector.ArrowPoints[0], connector.ArrowPoints[1]); _automatGraphics.DrawLine(pen, connector.ArrowPoints[0], connector.ArrowPoints[2]); } } else if (_selectable is State) { var state = _selectable as State; GraphicsPath gp = new GraphicsPath(); gp.AddEllipse(state.BoundingRect); var boundColor = (_selectable == _hilightState && _t1 >= 0 && _t1 <= 255) ? _paramColor : Color.FromArgb(0xCC, 0x66, 0xFF); Color[] colors = { boundColor, // dark green Color.FromArgb(0xCC, 0xCC, 0xFF), // aqua Color.FromArgb(0xCC, 0xFF, 0xFF) }; // blue float[] relativePositions = { 0f, // Dark green is at the boundary of the triangle. 0.58f, // Aqua is 40 percent of the way from the boundary // to the center point. 1.0f }; // Blue is at the center point. ColorBlend colorBlend = new ColorBlend(); colorBlend.Colors = colors; colorBlend.Positions = relativePositions; PathGradientBrush grd = new PathGradientBrush(gp); //{ // SurroundColors = new Color[] { Color.FromArgb(0xCC, 0x33, 0xCC) }, // CenterColor = Color.FloralWhite //}; grd.InterpolationColors = colorBlend; _automatGraphics.FillEllipse(grd, state.BoundingRect); _automatGraphics.DrawString(state.Label, stateFont, Brushes.DarkSlateBlue, state.BoundingRect, strFormat); Pen stateBorderPen = state.IsSelected ? redPen : borderPen; _automatGraphics.DrawEllipse(stateBorderPen, state.BoundingRect); if (IsFinalState(state)) { Pen markPen = new Pen(Color.Maroon, 2); var newRect = state.BoundingRect; newRect.Inflate(3, 3); _automatGraphics.DrawEllipse(markPen, newRect); markPen.Dispose(); } grd.Dispose(); gp.Dispose(); } } if (_bCurve) { if (_curveControlPoints[0] != InvalidPoint) { OnPaintHandle(_curveControlPoints[0]); } if (_curveControlPoints[1] != InvalidPoint) { OnPaintHandle(_curveControlPoints[1]); } } OnAnimatePaint(_automatGraphics); pe.Graphics.DrawImage(_automatBitmap, DisplayRectangle, DisplayRectangle, GraphicsUnit.Pixel); stateFont.Dispose(); strFormat.Dispose(); borderPen.Dispose(); redPen.Dispose(); connectorPen.Dispose(); arrowBrush.Dispose(); }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Bounds != RectangleF.Empty) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; RectangleF tabTextArea = RectangleF.Empty; for (int nIndex = 0; nIndex < this.TabCount; nIndex++) { if (nIndex != this.SelectedIndex) { tabTextArea = (RectangleF)this.GetTabRect(nIndex); GraphicsPath _Path = new GraphicsPath(); _Path.AddRectangle(tabTextArea); using (LinearGradientBrush _Brush = new LinearGradientBrush(tabTextArea, SystemColors.Control, SystemColors.ControlLight, LinearGradientMode.Vertical)) { ColorBlend _ColorBlend = new ColorBlend(3); _ColorBlend.Colors = new Color[] { SystemColors.ControlLightLight, Color.FromArgb(255, SystemColors.ControlLight), SystemColors.ControlDark, SystemColors.ControlLightLight }; _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; _Brush.InterpolationColors = _ColorBlend; e.Graphics.FillPath(_Brush, _Path); using (Pen pen = new Pen(SystemColors.ActiveBorder)) { e.Graphics.DrawPath(pen, _Path); } _ColorBlend.Colors = new Color[] { SystemColors.ActiveBorder, SystemColors.ActiveBorder, SystemColors.ActiveBorder, SystemColors.ActiveBorder }; _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; _Brush.InterpolationColors = _ColorBlend; e.Graphics.FillRectangle(_Brush, tabTextArea.X + tabTextArea.Width - 22, 4, tabTextArea.Height - 3, tabTextArea.Height - 5); e.Graphics.DrawRectangle(Pens.White, tabTextArea.X + tabTextArea.Width - 20, 6, tabTextArea.Height - 8, tabTextArea.Height - 9); using (Pen pen = new Pen(Color.White, 2)) { e.Graphics.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 16, 9, tabTextArea.X + tabTextArea.Width - 7, 17); e.Graphics.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 16, 17, tabTextArea.X + tabTextArea.Width - 7, 9); } if (CanDrawMenuButton(nIndex)) { _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; _Brush.InterpolationColors = _ColorBlend; _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; // assign the color blend to the pathgradientbrush _Brush.InterpolationColors = _ColorBlend; e.Graphics.FillRectangle(_Brush, tabTextArea.X + tabTextArea.Width - 43, 4, tabTextArea.Height - 3, tabTextArea.Height - 5); // e.Graphics.DrawRectangle(SystemPens.GradientInactiveCaption, tabTextArea.X + tabTextArea.Width - 37, 7, 13, 13); e.Graphics.DrawRectangle(new Pen(Color.White), tabTextArea.X + tabTextArea.Width - 41, 6, tabTextArea.Height - 7, tabTextArea.Height - 9); using (Pen pen = new Pen(Color.White, 2)) { e.Graphics.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 36, 11, tabTextArea.X + tabTextArea.Width - 33, 16); e.Graphics.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 33, 16, tabTextArea.X + tabTextArea.Width - 30, 11); } } } _Path.Dispose(); } else { tabTextArea = (RectangleF)this.GetTabRect(nIndex); GraphicsPath _Path = new GraphicsPath(); _Path.AddRectangle(tabTextArea); using (LinearGradientBrush _Brush = new LinearGradientBrush(tabTextArea, SystemColors.Control, SystemColors.ControlLight, LinearGradientMode.Vertical)) { ColorBlend _ColorBlend = new ColorBlend(3); _ColorBlend.Colors = new Color[] { SystemColors.ControlLightLight, Color.FromArgb(255, SystemColors.Control), SystemColors.ControlLight, SystemColors.Control }; _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; _Brush.InterpolationColors = _ColorBlend; e.Graphics.FillPath(_Brush, _Path); using (Pen pen = new Pen(SystemColors.ActiveBorder)) { e.Graphics.DrawPath(pen, _Path); } //Drawing Close Button _ColorBlend.Colors = new Color[] { Color.FromArgb(255, 231, 164, 152), Color.FromArgb(255, 231, 164, 152), Color.FromArgb(255, 197, 98, 79), Color.FromArgb(255, 197, 98, 79) }; _Brush.InterpolationColors = _ColorBlend; e.Graphics.FillRectangle(_Brush, tabTextArea.X + tabTextArea.Width - 22, 4, tabTextArea.Height - 3, tabTextArea.Height - 5); e.Graphics.DrawRectangle(Pens.White, tabTextArea.X + tabTextArea.Width - 20, 6, tabTextArea.Height - 8, tabTextArea.Height - 9); using (Pen pen = new Pen(Color.White, 2)) { e.Graphics.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 16, 9, tabTextArea.X + tabTextArea.Width - 7, 17); e.Graphics.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 16, 17, tabTextArea.X + tabTextArea.Width - 7, 9); } if (CanDrawMenuButton(nIndex)) { //Drawing menu button _ColorBlend.Colors = new Color[] { SystemColors.ControlLightLight, Color.FromArgb(255, SystemColors.ControlLight), SystemColors.ControlDark, SystemColors.ControlLightLight }; _ColorBlend.Positions = new float[] { 0f, .4f, 0.5f, 1f }; _Brush.InterpolationColors = _ColorBlend; _ColorBlend.Colors = new Color[] { Color.FromArgb(255, 170, 213, 243), Color.FromArgb(255, 170, 213, 243), Color.FromArgb(255, 44, 137, 191), Color.FromArgb(255, 44, 137, 191) }; _Brush.InterpolationColors = _ColorBlend; e.Graphics.FillRectangle(_Brush, tabTextArea.X + tabTextArea.Width - 43, 4, tabTextArea.Height - 3, tabTextArea.Height - 5); e.Graphics.DrawRectangle(Pens.White, tabTextArea.X + tabTextArea.Width - 41, 6, tabTextArea.Height - 7, tabTextArea.Height - 9); using (Pen pen = new Pen(Color.White, 2)) { e.Graphics.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 36, 11, tabTextArea.X + tabTextArea.Width - 33, 16); e.Graphics.DrawLine(pen, tabTextArea.X + tabTextArea.Width - 33, 16, tabTextArea.X + tabTextArea.Width - 30, 11); } } } _Path.Dispose(); } string str = this.TabPages[nIndex].Text; StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; e.Graphics.DrawString(str, this.Font, new SolidBrush(this.TabPages[nIndex].ForeColor), tabTextArea, stringFormat); } } }
private static void RunVisualTest() { var image = new Bitmap(560, 400, PixelFormat.Format32bppArgb); int xOffset = image.Width / 2 + 5; int yOffset = 5; using (var g = Graphics.FromImage(image)) { g.FillRectangle(Brushes.White, 0, 0, image.Width / 2, image.Height); IntPtr dib; var memoryHdc = CreateMemoryHdc(IntPtr.Zero, image.Width, 40, out dib); try { // create memory buffer graphics to use for HTML rendering using (var memoryGraphics = Graphics.FromHdc(memoryHdc)) { memoryGraphics.FillRectangle(Brushes.White, 0, 0, image.Width / 2, image.Height); // execute GDI text rendering var hdc = memoryGraphics.GetHdc(); SelectObject(hdc, _font1.ToHfont()); SetTextColor(hdc, (Color.Red.B & 0xFF) << 16 | (Color.Red.G & 0xFF) << 8 | Color.Red.R); const string tStr = String + " (Native)"; TextOut(hdc, 5, yOffset, tStr, tStr.Length); TextOut(hdc, xOffset, yOffset, tStr, tStr.Length); memoryGraphics.ReleaseHdc(hdc); } // copy from memory buffer to image using (var imageGraphics = Graphics.FromImage(image)) { var imgHdc = imageGraphics.GetHdc(); BitBlt(imgHdc, 0, 0, image.Width, 40, memoryHdc, 0, 0, 0x00CC0020); imageGraphics.ReleaseHdc(imgHdc); } } finally { // release memory buffer DeleteObject(dib); DeleteDC(memoryHdc); } yOffset += 50; // TextRenderer.DrawText(g, String + " (TextRenderer)", _font1, new Point(5, yOffset), Color.Red, Color.White); // TextRenderer.DrawText(g, String + " (TextRenderer)", _font1, new Point(xOffset, yOffset), Color.Red); // yOffset += 50; g.TextRenderingHint = TextRendering; g.DrawString(String + " (DrawString)", _font1, Brushes.Red, new Point(5, yOffset)); g.DrawString(String + " (DrawString)", _font1, Brushes.Red, new Point(xOffset, yOffset)); g.TextRenderingHint = TextRenderingHint.SystemDefault; yOffset += 50; g.SmoothingMode = Smoothing; float emSize = g.DpiY * _font1.Size / 72f; using (var path = new GraphicsPath()) { path.AddString(String + " (GraphicsPath)", _font1.FontFamily, (int)_font1.Style, emSize, new Point(5, yOffset), StringFormat.GenericDefault); g.FillPath(Brushes.Red, path); } using (var path = new GraphicsPath()) { path.AddString(String + " (GraphicsPath)", _font1.FontFamily, (int)_font1.Style, emSize, new Point(xOffset, yOffset), StringFormat.GenericDefault); g.FillPath(Brushes.Red, path); } g.SmoothingMode = SmoothingMode.Default; } image.Save("TestVisal.png", ImageFormat.Png); }
public ShotChartWindow(Dictionary <int, PlayerPBPStats> pbpsList, bool showOffense = true) : this() { _pbpsList = pbpsList; grdButtons.Visibility = Visibility.Hidden; var list = new List <Image> { Properties.Resources.Default_001 }; for (var i = 2; i <= 20; i++) { if ((showOffense && pbpsList[i].FGp >= 0.5) || (!showOffense && pbpsList[i].DefFGp >= 0.5)) { list.Add((Image)Properties.Resources.ResourceManager.GetObject("Red_0" + String.Format("{0:00}", i))); } else if ((showOffense && pbpsList[i].FGp >= 0.4) || (!showOffense && pbpsList[i].DefFGp >= 0.4)) { list.Add((Image)Properties.Resources.ResourceManager.GetObject("Gray_0" + String.Format("{0:00}", i))); } else if ((showOffense && pbpsList[i].FGA > 0) || (!showOffense && pbpsList[i].DefFGA > 0)) { list.Add((Image)Properties.Resources.ResourceManager.GetObject("Blue_0" + String.Format("{0:00}", i))); } else { list.Add((Image)Properties.Resources.ResourceManager.GetObject("Default_0" + String.Format("{0:00}", i))); } } Image canvas = new Bitmap(586, 551); var frame = new Rectangle(0, 0, 586, 551); var g = Graphics.FromImage(canvas); list.ForEach(o => g.DrawImage(o, frame, frame, GraphicsUnit.Pixel)); g.TextRenderingHint = TextRenderingHint.AntiAlias; g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; var strFormat = new StringFormat(); strFormat.Alignment = StringAlignment.Center; strFormat.LineAlignment = StringAlignment.Center; var totalFGM = 0U; var totalFGA = 0U; foreach (var pair in XyDict) { var s = _pbpsList[pair.Key]; var fgpString = ""; if (!Double.IsNaN(s.FGp)) { if ((showOffense && s.FGM == s.FGA) || (!showOffense && s.DefFGM == s.DefFGA)) { fgpString = "1."; } else { fgpString = String.Format("{0:F3}", showOffense ? s.FGp : s.DefFGp).Substring(1); } } var gp = new GraphicsPath(); gp.AddString( String.Format("{0}-{1}\n{2}", showOffense ? s.FGM : s.DefFGM, showOffense ? s.FGA : s.DefFGA, fgpString), new FontFamily("Tahoma"), (int)System.Drawing.FontStyle.Bold, 16, new Point(pair.Value.Key, pair.Value.Value), strFormat); var pen = new Pen(Color.FromArgb(255, 255, 255), 3); g.DrawPath(pen, gp); var brush = new SolidBrush(Color.FromArgb(0, 0, 0)); g.FillPath(brush, gp); brush.Dispose(); pen.Dispose(); gp.Dispose(); totalFGM += s.FGM; totalFGA += s.FGA; } var totalFGp = (double)totalFGM / totalFGA; Title += String.Format(" - {0}-{1} ({2:F3})", totalFGM, totalFGA, totalFGp); var ms = new MemoryStream(); canvas.Save(ms, ImageFormat.Png); var bmi = new BitmapImage(); bmi.BeginInit(); bmi.CacheOption = BitmapCacheOption.OnLoad; bmi.StreamSource = ms; bmi.EndInit(); imgShotChart.Source = bmi; g.Dispose(); canvas.Dispose(); }
private GraphicsPath _enclosingPath = new GraphicsPath(); // with Winding also overlapping rectangles are selected public override void Paint(Graphics g, XYPlotLayer layer, CSAxisInformation styleInfo, AxisLineStyle axisstyle, bool useMinorTicks) { _cachedStyleID = styleInfo.Identifier; CSLineID styleID = styleInfo.Identifier; Scale raxis = styleID.ParallelAxisNumber == 0 ? layer.XAxis : layer.YAxis; _enclosingPath.Reset(); _enclosingPath.FillMode = FillMode.Winding; // with Winding also overlapping rectangles are selected GraphicsPath helperPath = new GraphicsPath(); Matrix math = new Matrix(); Logical3D r0 = _cachedStyleID.Begin; Logical3D r1 = _cachedStyleID.End; SizeF layerSize = layer.Size; PointF outVector; Logical3D outer; float outerDistance = null == axisstyle? 0 : axisstyle.GetOuterDistance(styleInfo.PreferedLabelSide); float dist_x = outerDistance; // Distance from axis tick point to label float dist_y = outerDistance; // y distance from axis tick point to label // dist_x += this._font.SizeInPoints/3; // add some space to the horizontal direction in order to separate the chars a little from the ticks // next statement is necessary to have a consistent string length both // on 0 degree rotated text and rotated text // without this statement, the text is fitted to the pixel grid, which // leads to "steps" during scaling g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; double[] relpositions; AltaxoVariant[] ticks; if (useMinorTicks) { relpositions = raxis.GetMinorTicksNormal(); ticks = raxis.GetMinorTicksAsVariant(); } else { relpositions = raxis.GetMajorTicksNormal(); ticks = raxis.GetMajorTicksAsVariant(); } IMeasuredLabelItem[] labels = _labelFormatting.GetMeasuredItems(g, _font, _stringFormat, ticks); float emSize = _font.SizeInPoints; for (int i = 0; i < ticks.Length; i++) { double r = relpositions[i]; outer = layer.CoordinateSystem.GetLogicalDirection(styleID.ParallelAxisNumber, styleInfo.PreferedLabelSide); PointF tickorg = layer.CoordinateSystem.GetNormalizedDirection(r0, r1, r, outer, out outVector); PointF tickend = tickorg; tickend.X += outVector.X * outerDistance; tickend.Y += outVector.Y * outerDistance; SizeF msize = labels[i].Size; PointF morg = tickend; if (_automaticRotationShift) { double alpha = _rotation * Math.PI / 180 - Math.Atan2(outVector.Y, outVector.X); double shift = msize.Height * 0.5 * Math.Abs(Math.Sin(alpha)) + (msize.Width + _font.SizeInPoints / 2) * 0.5 * Math.Abs(Math.Cos(alpha)); morg.X += (float)(outVector.X * shift); morg.Y += (float)(outVector.Y * shift); } else { morg.X += (float)(outVector.X * _font.SizeInPoints / 3); } RectangleF mrect = new RectangleF(morg, msize); if (_automaticRotationShift) { AdjustRectangle(ref mrect, StringAlignment.Center, StringAlignment.Center); } else { AdjustRectangle(ref mrect, _horizontalAlignment, _verticalAlignment); } math.Reset(); math.Translate((float)morg.X, (float)morg.Y); if (this._rotation != 0) { math.Rotate((float)-this._rotation); } math.Translate((float)(mrect.X - morg.X + emSize * _xOffset), (float)(mrect.Y - morg.Y + emSize * _yOffset)); System.Drawing.Drawing2D.GraphicsState gs = g.Save(); g.MultiplyTransform(math); if (this._backgroundStyle != null) { _backgroundStyle.Draw(g, new RectangleF(PointF.Empty, msize)); } _brush.Rectangle = new RectangleF(PointF.Empty, msize); labels[i].Draw(g, _brush, new PointF(0, 0)); g.Restore(gs); // Restore the graphics state helperPath.Reset(); helperPath.AddRectangle(new RectangleF(PointF.Empty, msize)); helperPath.Transform(math); _enclosingPath.AddPath(helperPath, true); } }
/// <summary>Converts the GraphicsPath to a border path.</summary> /// <param name="borderPath">The border path.</param> /// <param name="border">The border.</param> /// <returns>The <see cref="GraphicsPath" />.</returns> public static GraphicsPath ToBorderPath(this GraphicsPath borderPath, Border border) { return(VisualBorderRenderer.CreateBorderTypePath(borderPath.GetBounds().ToRectangle(), border)); }
/// <summary> /// 建立带有圆角样式的路径。 /// </summary> /// <param name="rect">用来建立路径的矩形。</param> /// <param name="_radius">圆角的大小。</param> /// <param name="style">圆角的样式。</param> /// <param name="correction">是否把矩形长宽减 1,以便画出边框。</param> /// <returns>建立的路径。</returns> public static GraphicsPath CreatePath( Rectangle rect, int radius, RoundStyle style, bool correction) { GraphicsPath path = new GraphicsPath(); int radiusCorrection = correction ? 1 : 0; switch (style) { case RoundStyle.None: path.AddRectangle(rect); break; case RoundStyle.All: path.AddArc(rect.X, rect.Y, radius, radius, 180, 90); path.AddArc( rect.Right - radius - radiusCorrection, rect.Y, radius, radius, 270, 90); path.AddArc( rect.Right - radius - radiusCorrection, rect.Bottom - radius - radiusCorrection, radius, radius, 0, 90); path.AddArc( rect.X, rect.Bottom - radius - radiusCorrection, radius, radius, 90, 90); break; case RoundStyle.Left: path.AddArc(rect.X, rect.Y, radius, radius, 180, 90); path.AddLine( rect.Right - radiusCorrection, rect.Y, rect.Right - radiusCorrection, rect.Bottom - radiusCorrection); path.AddArc( rect.X, rect.Bottom - radius - radiusCorrection, radius, radius, 90, 90); break; case RoundStyle.Right: path.AddArc( rect.Right - radius - radiusCorrection, rect.Y, radius, radius, 270, 90); path.AddArc( rect.Right - radius - radiusCorrection, rect.Bottom - radius - radiusCorrection, radius, radius, 0, 90); path.AddLine(rect.X, rect.Bottom - radiusCorrection, rect.X, rect.Y); break; case RoundStyle.Top: path.AddArc(rect.X, rect.Y, radius, radius, 180, 90); path.AddArc( rect.Right - radius - radiusCorrection, rect.Y, radius, radius, 270, 90); path.AddLine( rect.Right - radiusCorrection, rect.Bottom - radiusCorrection, rect.X, rect.Bottom - radiusCorrection); break; case RoundStyle.Bottom: path.AddArc( rect.Right - radius - radiusCorrection, rect.Bottom - radius - radiusCorrection, radius, radius, 0, 90); path.AddArc( rect.X, rect.Bottom - radius - radiusCorrection, radius, radius, 90, 90); path.AddLine(rect.X, rect.Y, rect.Right - radiusCorrection, rect.Y); break; } path.CloseFigure(); return(path); }
private GraphicsPath DrawArrow(int x, int y, bool flip) { GraphicsPath GP = new GraphicsPath(); int W = 5; int H = 9; if (flip) { GP.AddLine(x, y + 1, x, y + H + 1); GP.AddLine(x, y + H, x + W - 1, y + W); } else { GP.AddLine(x + W, y, x + W, y + H); GP.AddLine(x + W, y + H, x + 1, y + W); } GP.CloseFigure(); return GP; }
private void CreateColorBarPath(RectangleF panelBounds, RectangleF colorBarBounds, int[] colorsRef, SwatchLabelType currentLabelType, out GraphicsPath outlinePath, out GraphicsPath fillPath) { colorBarBounds = Rectangle.Round(colorBarBounds); float width = colorBarBounds.Width / (float)colorsRef.Length; RectangleF rect = new RectangleF(colorBarBounds.X, colorBarBounds.Y, width, colorBarBounds.Height); outlinePath = new GraphicsPath(); fillPath = new GraphicsPath(); PointF pointF = new PointF(colorBarBounds.Left, colorBarBounds.Bottom); PointF pointF2 = new PointF(colorBarBounds.Left, colorBarBounds.Top); float num = Math.Min(TickMarkLength + 1, panelBounds.Bottom - pointF.Y); float num2 = Math.Min(TickMarkLength, pointF.Y - panelBounds.Top); pointF2.Y -= num2; if (colorBarBounds.Width <= 0f || colorBarBounds.Width <= 0f) { return; } outlinePath.AddRectangle(colorBarBounds); for (int i = 0; i < colorsRef.Length; i++) { fillPath.StartFigure(); fillPath.AddRectangle(rect); outlinePath.StartFigure(); outlinePath.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom); rect.Offset(rect.Width, 0f); } bool flag = LabelAlignment != LabelAlignment.Top; if (LabelInterval <= 0 || TickMarkLength <= 0) { return; } switch (currentLabelType) { case SwatchLabelType.ShowMiddleValue: { pointF.X += rect.Width / 2f; pointF2.X += rect.Width / 2f; for (int k = 0; k < colorsRef.Length; k += LabelInterval) { if (MustPrintLabel(colorsRef, k, isFromValue: true, currentLabelType)) { PointF empty2 = PointF.Empty; float num5 = 0f; if (flag) { empty2 = pointF; num5 = num; } else { empty2 = pointF2; num5 = num2; } outlinePath.StartFigure(); outlinePath.AddLine(empty2.X + (float)k * rect.Width, empty2.Y, empty2.X + (float)k * rect.Width, empty2.Y + num5); flag = ((LabelAlignment == LabelAlignment.Alternate) ? (!flag) : flag); } } break; } case SwatchLabelType.ShowBorderValue: { PointF empty = PointF.Empty; float num3 = 0f; for (int j = 0; j < colorsRef.Length * 2; j++) { if (flag) { empty = pointF; num3 = num; } else { empty = pointF2; num3 = num2; } if (MustPrintLabel(colorsRef, j / 2, j % 2 == 0, currentLabelType)) { float num4 = 0f; if (Colors[colorsRef[j / 2]].NoData) { num4 = rect.Width / 2f; } outlinePath.StartFigure(); outlinePath.AddLine(empty.X + num4 + (float)(j / 2 + j % 2) * rect.Width, empty.Y, empty.X + num4 + (float)(j / 2 + j % 2) * rect.Width, empty.Y + num3); flag = ((LabelAlignment == LabelAlignment.Alternate) ? (!flag) : flag); } } break; } } }
protected override void OnPaint(PaintEventArgs e) { G = e.Graphics; G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; G.Clear(BackColor); G.SmoothingMode = SmoothingMode.AntiAlias; GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7); GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7); GB1 = new LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f); G.SetClip(GP1); G.FillRectangle(GB1, ClientRectangle); G.ResetClip(); G.DrawPath(P1, GP1); G.DrawPath(P4, GP2); SZ1 = G.MeasureString(Text, Font); PT1 = new PointF(5, Height / 2 - SZ1.Height / 2); G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1); G.DrawString(Text, Font, Brushes.White, PT1); G.DrawLine(P3, Width - 15, 10, Width - 11, 13); G.DrawLine(P3, Width - 7, 10, Width - 11, 13); G.DrawLine(Pens.Black, Width - 11, 13, Width - 11, 14); G.DrawLine(P2, Width - 16, 9, Width - 12, 12); G.DrawLine(P2, Width - 8, 9, Width - 12, 12); G.DrawLine(Pens.White, Width - 12, 12, Width - 12, 13); G.DrawLine(P1, Width - 22, 0, Width - 22, Height); G.DrawLine(P4, Width - 23, 1, Width - 23, Height - 2); G.DrawLine(P4, Width - 21, 1, Width - 21, Height - 2); }
private void PaintInternal(PaintEventArgs pe) { using (var img = new Bitmap(Width, Height)) using (Graphics e = Graphics.FromImage(img)) using (var gp = new GraphicsPath()) { e.SmoothingMode = SmoothingMode.AntiAlias; if (_glowColor.HasValue) { using (Brush bru = new SolidBrush(Color.FromArgb(50, _glowColor.Value))) using (var pn = new Pen(bru, 6f)) { pn.LineJoin = LineJoin.Round; var rectangle = new Rectangle(3, 3, Width - 10, Height - 10); gp.AddRectangle(rectangle); e.DrawPath(pn, gp); gp.Reset(); rectangle = new Rectangle(5, 5, Width - 14, Height - 14); gp.AddRectangle(rectangle); e.DrawPath(pn, gp); gp.Reset(); rectangle = new Rectangle(7, 7, Width - 18, Height - 18); gp.AddRectangle(rectangle); e.DrawPath(pn, gp); gp.Reset(); rectangle = new Rectangle(9, 9, Width - 22, Height - 22); gp.AddRectangle(rectangle); e.DrawPath(pn, gp); gp.Reset(); } } using (var backBrush = new SolidBrush(_backgroundColor)) using (var blackPn = new Pen(backBrush, 5f) { LineJoin = LineJoin.Round }) { var rectangle = new Rectangle(8, 8, Width - 20, Height - 20); gp.AddRectangle(rectangle); e.DrawPath(blackPn, gp); rectangle = new Rectangle(9, 9, Width - 21, Height - 21); e.FillRectangle(backBrush, rectangle); var cma = new ColorMatrix { Matrix33 = AlphaValue }; var imga = new ImageAttributes(); imga.SetColorMatrix(cma); var sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center, Trimming = StringTrimming.EllipsisCharacter }; using (var foregroundBrush = new SolidBrush(_foregroundColor)) { rectangle = new Rectangle(9, 9, Width - 21, Height - 21); e.DrawString(_message, Font, foregroundBrush, rectangle, sf); rectangle = new Rectangle(0, 0, Width, Height); pe.Graphics.DrawImage(img, rectangle, 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imga); } } } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { G = e.Graphics; G.Clear(BackColor); G.SmoothingMode = SmoothingMode.AntiAlias; GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7); GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7); PB1 = new PathGradientBrush(GP1); PB1.CenterColor = Color.FromArgb(50, 50, 50); PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) }; PB1.FocusScales = new PointF(0.9f, 0.5f); G.FillPath(PB1, GP1); G.DrawPath(P2, GP1); G.DrawPath(P1, GP2); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { G = e.Graphics; G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; G.Clear(BackColor); G.SmoothingMode = SmoothingMode.AntiAlias; GP1 = ThemeModule.CreateRound(0, 2, Height - 5, Height - 5, 5); GP2 = ThemeModule.CreateRound(1, 3, Height - 7, Height - 7, 5); PB1 = new PathGradientBrush(GP1); PB1.CenterColor = Color.FromArgb(50, 50, 50); PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) }; PB1.FocusScales = new PointF(0.3f, 0.3f); G.FillPath(PB1, GP1); G.DrawPath(P11, GP1); G.DrawPath(P22, GP2); if (_Checked) { G.DrawLine(P3, 5, Height - 9, 8, Height - 7); G.DrawLine(P3, 7, Height - 7, Height - 8, 7); G.DrawLine(P4, 4, Height - 10, 7, Height - 8); G.DrawLine(P4, 6, Height - 8, Height - 9, 6); } SZ1 = G.MeasureString(Text, Font); PT1 = new PointF(Height - 3, Height / 2 - SZ1.Height / 2); G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1); G.DrawString(Text, Font, Brushes.White, PT1); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { G = e.Graphics; G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; G.Clear(BackColor); G.SmoothingMode = SmoothingMode.AntiAlias; GP1 = ThemeModule.CreateRound(0, 0, Width - 1, Height - 1, 7); GP2 = ThemeModule.CreateRound(1, 1, Width - 3, Height - 3, 7); if (IsMouseDown) { 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(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90f); G.FillPath(GB1, GP1); } G.DrawPath(P1, GP1); G.DrawPath(P2, GP2); SZ1 = G.MeasureString(Text, Font); PT1 = new PointF(5, Height / 2 - SZ1.Height / 2); if (IsMouseDown) { PT1.X += 1f; PT1.Y += 1f; } G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1); G.DrawString(Text, Font, Brushes.White, PT1); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { G = e.Graphics; G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; G.Clear(BackColor); G.SmoothingMode = SmoothingMode.AntiAlias; GP1 = new GraphicsPath(); GP1.AddEllipse(0, 2, Height - 5, Height - 5); PB1 = new PathGradientBrush(GP1); PB1.CenterColor = Color.FromArgb(50, 50, 50); PB1.SurroundColors = new Color[] { Color.FromArgb(45, 45, 45) }; PB1.FocusScales = new PointF(0.3f, 0.3f); G.FillPath(PB1, GP1); G.DrawEllipse(P1, 0, 2, Height - 5, Height - 5); G.DrawEllipse(P2, 1, 3, Height - 7, Height - 7); if (_Checked) { G.FillEllipse(Brushes.Black, 6, 8, Height - 15, Height - 15); G.FillEllipse(Brushes.White, 5, 7, Height - 15, Height - 15); } SZ1 = G.MeasureString(Text, Font); PT1 = new PointF(Height - 3, Height / 2 - SZ1.Height / 2); G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1); G.DrawString(Text, Font, Brushes.White, PT1); }