public void RenderDynamicShadows(GaugeGraphics g) { using (GraphicsPath graphicsPath = new GraphicsPath()) { foreach (Knob knob in this.Knobs) { GraphicsPath shadowPath = knob.GetShadowPath(g); if (shadowPath != null) { graphicsPath.AddPath(shadowPath, false); } } foreach (CircularPointer pointer in this.Pointers) { GraphicsPath shadowPath2 = pointer.GetShadowPath(g); if (shadowPath2 != null) { graphicsPath.AddPath(shadowPath2, false); } } graphicsPath.FillMode = FillMode.Winding; using (Brush brush = g.GetShadowBrush()) { g.FillPath(brush, graphicsPath); } } }
/// <summary> /// Adds the X and Y coordinates to the current graphics path. /// </summary> /// <param name="path"> The current Graphics path</param> /// <param name="x">The x coordinate to be added</param> /// <param name="y">The y coordinate to be added</param> private static void AddPointToGraphicsPath(GraphicsPath path, int x, int y) { PointF[] tempPointArray = new PointF[path.PointCount + 1]; byte[] tempPointTypeArray = new byte[path.PointCount + 1]; if (path.PointCount == 0) { tempPointArray[0] = new PointF(x, y); GraphicsPath tempGraphicsPath = new GraphicsPath(tempPointArray, new byte[] { (byte)PathPointType.Start }); path.AddPath(tempGraphicsPath, false); } else { path.PathPoints.CopyTo(tempPointArray, 0); tempPointArray[path.PointCount] = new Point(x, y); path.PathTypes.CopyTo(tempPointTypeArray, 0); tempPointTypeArray[path.PointCount] = (byte)PathPointType.Line; GraphicsPath tempGraphics = new GraphicsPath(tempPointArray, tempPointTypeArray); path.Reset(); path.AddPath(tempGraphics, false); //path.CloseFigure(); } }
public override GraphicsPath CreatePath() { List <Point> firstQuarterPointLists = GeneratePointLists(); List <Point> pointLists = new List <Point>(); List <Point> symmetricPointLists = new List <Point>(); foreach (Point p in firstQuarterPointLists) { pointLists.Add(p); pointLists.Insert(0, new Point(p.X, pointStart.Y - (p.Y - pointStart.Y))); symmetricPointLists.Add(new Point(pointStart.X - (p.X - pointStart.X), p.Y)); symmetricPointLists.Insert(0, new Point(pointStart.X - (p.X - pointStart.X), pointStart.Y - (p.Y - pointStart.Y))); } GraphicsPath path1 = new GraphicsPath(); path1.AddLines(pointLists.ToArray()); GraphicsPath path2 = new GraphicsPath(); path2.AddLines(symmetricPointLists.ToArray()); GraphicsPath path = new GraphicsPath(); try { path.AddPath(path1, false); path.AddPath(path2, false); } catch { } return(path); }
private void Form1_MouseMove(object sender, MouseEventArgs e) { if (checkIntractPath1(e) && isMouseDown) { xPath1 = e.Location.X - dx; yPath1 = e.Location.Y - dy; isMerged = checkSnap(); this.Invalidate(); if (isMerged) { xPath1 = xPath2; yPath1 = yPath2 - 100; fullSquare = new GraphicsPath(); fullSquare.AddPath(CloseShapePath, true); fullSquare.AddPath(OpenSHapepath, true); this.Invalidate(); } } else if (checkIntractPath2(e) && isMouseDown) { xPath2 = e.Location.X - dx; yPath2 = e.Location.Y - dy; isMerged = checkSnap(); if (isMerged) { xPath1 = xPath2; yPath1 = yPath2 - 100; } this.Invalidate(); } }
private void FillLastSeriesGradient(ChartGraphics graph) { if (areaPath != null) { areaPath.AddLine(areaPath.GetLastPoint().X, areaPath.GetLastPoint().Y, areaPath.GetLastPoint().X, areaBottomPath.GetLastPoint().Y); } if (gradientFill && areaPath != null) { graph.SetClip(area.PlotAreaPosition.ToRectangleF()); GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddPath(areaPath, connect: true); areaBottomPath.Reverse(); graphicsPath.AddPath(areaBottomPath, connect: true); Brush gradientBrush = graph.GetGradientBrush(graphicsPath.GetBounds(), series.Color, series.BackGradientEndColor, series.BackGradientType); graph.FillPath(gradientBrush, graphicsPath); gradientFill = false; graph.ResetClip(); } if (areaPath != null) { areaPath.Dispose(); areaPath = null; } areaBottomPath.Reset(); }
internal void RenderStaticShadows(GaugeGraphics g) { using (GraphicsPath graphicsPath = new GraphicsPath()) { foreach (CircularRange range in Ranges) { GraphicsPath path = range.GetPath(g, getShadowPath: true); if (path != null) { graphicsPath.AddPath(path, connect: false); } } foreach (CircularScale scale in Scales) { GraphicsPath shadowPath = scale.GetShadowPath(g); if (shadowPath != null) { graphicsPath.AddPath(shadowPath, connect: false); } } graphicsPath.FillMode = FillMode.Winding; using (Brush brush = g.GetShadowBrush()) { g.FillPath(brush, graphicsPath); } } }
/// <summary> /// Adds the X and Y coordinates to the current graphics path. /// </summary> /// <param name="path"> The current Graphics path</param> /// <param name="x">The x coordinate to be added</param> /// <param name="y">The y coordinate to be added</param> private static void AddPointToGraphicsPath(GraphicsPath path, int x, int y) { // increment by one. var points = new PointF[path.PointCount + 1]; var pointTypes = new byte[path.PointCount + 1]; if (path.PointCount == 0) { points[0] = new PointF(x, y); var newPath = new GraphicsPath(points, new[] { (byte)PathPointType.Start }); path.AddPath(newPath, false); } else { path.PathPoints.CopyTo(points, 0); points[path.PointCount] = new Point(x, y); path.PathTypes.CopyTo(pointTypes, 0); pointTypes[path.PointCount] = (byte)PathPointType.Line; var tempGraphics = new GraphicsPath(points, pointTypes); path.Reset(); path.AddPath(tempGraphics, false); } }
public void RenderStaticShadows(GaugeGraphics g) { using (GraphicsPath graphicsPath = new GraphicsPath()) { foreach (LinearRange range in this.Ranges) { GraphicsPath path = range.GetPath(g, true); if (path != null) { graphicsPath.AddPath(path, false); } } foreach (LinearScale scale in this.Scales) { GraphicsPath shadowPath = scale.GetShadowPath(); if (shadowPath != null) { graphicsPath.AddPath(shadowPath, false); } } graphicsPath.FillMode = FillMode.Winding; using (Brush brush = g.GetShadowBrush()) { g.FillPath(brush, graphicsPath); } } }
public override void Paint(Graphics g, IPaintContext paintContext) { if (null == _cachedLayerSegment) // _privLayer should be set before in FixupInternalDataStructures { PaintErrorInvalidLayerType(g, paintContext); return; } if (_background == null) { _axisStyle.Paint(g, paintContext, _cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation); } else { // if we have a background, we paint in a dummy bitmap in order to measure all items // the real painting is done later on after painting the background. using (var bmp = new Bitmap(4, 4)) { using (var gg = Graphics.FromImage(bmp)) { _axisStyle.Paint(gg, paintContext, _cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation); } } } _cachedPath = _axisStyle.AxisLineStyle.GetObjectPath(_cachedLayerSegment, true); // calculate size information RectangleD2D bounds1 = _cachedPath.GetBounds(); if (_axisStyle.AreMinorLabelsEnabled) { var path = _axisStyle.MinorLabelStyle.GetSelectionPath(); if (path.PointCount > 0) { _cachedPath.AddPath(path, false); RectangleD2D bounds2 = path.GetBounds(); bounds1.ExpandToInclude(bounds2); } } if (_axisStyle.AreMajorLabelsEnabled) { var path = _axisStyle.MajorLabelStyle.GetSelectionPath(); if (path.PointCount > 0) { _cachedPath.AddPath(path, false); RectangleD2D bounds2 = path.GetBounds(); bounds1.ExpandToInclude(bounds2); } } ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(bounds1.Size, false); // size here is important only for selection, thus we set size silently if (_background != null) { bounds1.Expand(_backgroundPadding); _background.Draw(g, bounds1); _axisStyle.Paint(g, paintContext, _cachedLayerSegment, _cachedLayerSegment.GetAxisStyleInformation); } }
static private GraphicsPath Complex() { GraphicsPath path = new GraphicsPath(); path.AddPath(Pie(), false); path.AddPath(Rectangle(), true); path.AddPath(Polygon(), false); return(path); }
public void Method102() { GraphicsPath graphicsPath1 = new GraphicsPath(); GraphicsPath graphicsPath2 = new GraphicsPath(); // <snippet102> myGraphicsPath.AddPath(graphicsPath1, false); myGraphicsPath.AddPath(graphicsPath2, false); // </snippet102> }
void IData.Draw(Graphics g, RectangleF plotRectangle) { if (points.Length > 1) { if (BarStyle != BarStyle.None) { if (BarFillColor.A > 0) { g.FillRectangles(new SolidBrush(BarFillColor), bars); } if (BarLineColor.A > 0) { g.DrawRectangles(new Pen(BarLineColor), bars); } } if (FillStyle != FillStyle.None) { GraphicsPath fillPath = new GraphicsPath(); if (FillStyle == FillStyle.ToNInfitity) { fillPath.AddPath(GraphicsPath, true); fillPath.AddLine(points[0].X, points[0].Y, points[0].X, plotRectangle.Bottom); fillPath.AddLine(points[0].X, plotRectangle.Bottom, points[points.Length - 1].X, plotRectangle.Bottom); fillPath.AddLine(points[points.Length - 1].X, plotRectangle.Bottom, points[points.Length - 1].X, points[points.Length - 1].Y); } else if (FillStyle == FillStyle.ToPInfinity) { fillPath.AddPath(GraphicsPath, true); fillPath.AddLine(points[0].X, points[0].Y, points[0].X, plotRectangle.Top); fillPath.AddLine(points[0].X, plotRectangle.Top, points[points.Length - 1].X, plotRectangle.Top); fillPath.AddLine(points[points.Length - 1].X, plotRectangle.Top, points[points.Length - 1].X, points[points.Length - 1].Y); } else if (FillStyle == FillStyle.ToValue) { float fillValue = (float)VerticalAxis.Transform(FillValue); fillPath.AddPath(GraphicsPath, true); fillPath.AddLine(points[0].X, points[0].Y, points[0].X, fillValue); fillPath.AddLine(points[0].X, fillValue, points[points.Length - 1].X, fillValue); fillPath.AddLine(points[points.Length - 1].X, fillValue, points[points.Length - 1].X, points[points.Length - 1].Y); } else if (FillStyle == FillStyle.ToPlot && FillPlot != null) { fillPath.AddPath(GraphicsPath, true); fillPath.Reverse(); fillPath.AddPath(FillPlot.GraphicsPath, true); } g.FillPath(new SolidBrush(FillColor), fillPath); fillPath.Flatten(); flattenFill = fillPath.PathPoints; } Line.DrawPath(g, LineColor, LineStyle, LineWidth, GraphicsPath); Marker.Draw(g, MarkColor, MarkStyle, MarkSize, points); } }
public override GraphicsPath GetPath() { GraphicsPath gpLocal = (GraphicsPath)r_model.Clone(); Matrix mat = new Matrix(); mat.Translate(base.Pos.X, base.Pos.Y); mat.Rotate(_fRot); gpLocal.Transform(mat); if (Pos.X > (base.clientSize.Width - size)) { GraphicsPath gpWrap = (GraphicsPath)r_model.Clone(); Matrix mat2 = new Matrix(); mat2.Translate((Pos.X - base.clientSize.Width), Pos.Y); mat2.Rotate(_fRot, MatrixOrder.Prepend); gpWrap.Transform(mat2); gpLocal.AddPath(gpWrap, true); } else if (Pos.X < size) { GraphicsPath gpWrap = (GraphicsPath)r_model.Clone(); Matrix mat2 = new Matrix(); mat2.Translate(Pos.X + base.clientSize.Width, Pos.Y); mat2.Rotate(_fRot, MatrixOrder.Prepend); gpWrap.Transform(mat2); gpLocal.AddPath(gpWrap, true); } if (Pos.Y > (base.clientSize.Height - size)) { GraphicsPath gpWrap = (GraphicsPath)r_model.Clone(); Matrix mat2 = new Matrix(); mat2.Translate(Pos.X, Pos.Y - base.clientSize.Height); mat2.Rotate(_fRot, MatrixOrder.Prepend); gpWrap.Transform(mat2); gpLocal.AddPath(gpWrap, true); } else if (Pos.Y < size) { GraphicsPath gpWrap = (GraphicsPath)r_model.Clone(); //Do translation or movement Matrix mat2 = new Matrix(); mat2.Translate(Pos.X, Pos.Y + base.clientSize.Height); mat2.Rotate(_fRot, MatrixOrder.Prepend); gpWrap.Transform(mat2); gpLocal.AddPath(gpWrap, true); } return(gpLocal); }
public GraphicsPath getModelPathB(List <BaseShape> listBaseShape) { GraphicsPath gp = new GraphicsPath(); Pen pen = new Pen(Color.White, 0); for (int i = 0; i < listBaseShape.Count; i++) { if ("Line".Equals(listBaseShape[i].ShapeClass)) { GraphicsPath gpLine = new GraphicsPath(); Line line = (Line)listBaseShape[i]; gpLine.AddLine(line.StartPoint, line.EndPoint); gp.AddPath(gpLine, true); } else if ("Circle".Equals(listBaseShape[i].ShapeClass)) { GraphicsPath gpCircle = new GraphicsPath(); Circle circle = (Circle)listBaseShape[i]; gpCircle.AddEllipse(circle.CenterPoint.X - circle.Radius, circle.CenterPoint.Y - circle.Radius, 2 * circle.Radius, 2 * circle.Radius); gp.AddPath(gpCircle, true); } else if ("Arc".Equals(listBaseShape[i].ShapeClass)) { GraphicsPath gpArc = new GraphicsPath(); Arc arc = (Arc)listBaseShape[i]; gpArc.AddArc(arc.CenterPoint.X - arc.Radius, arc.CenterPoint.Y - arc.Radius, 2 * arc.Radius, 2 * arc.Radius, arc.StartAngle, arc.EndAngle > arc.StartAngle ? arc.EndAngle - arc.StartAngle : 360 - arc.StartAngle + arc.EndAngle); //gpArc.Widen(pen); gp.AddPath(gpArc, true); } else if ("Ellipse".Equals(listBaseShape[i].ShapeClass)) { GraphicsPath gpEllipse = new GraphicsPath(); Ellipse ellipse = (Ellipse)listBaseShape[i]; if (ellipse.Complete) { gpEllipse.AddEllipse(0, 0, 2 * ellipse.LongRadius, 2 * ellipse.ShortRadius); } else { gpEllipse.AddArc(0, 0, 2 * ellipse.LongRadius, 2 * ellipse.ShortRadius, ellipse.StartAngle, ellipse.EndAngle > ellipse.StartAngle ? ellipse.EndAngle - ellipse.StartAngle : 360 - ellipse.StartAngle + ellipse.EndAngle); } Matrix matrix = new Matrix(); matrix.Translate(ellipse.CenterPoint.X - ellipse.LongRadius, ellipse.CenterPoint.Y - ellipse.ShortRadius, MatrixOrder.Append); matrix.RotateAt(ellipse.Angle, ellipse.CenterPoint, MatrixOrder.Append); gpEllipse.Transform(matrix); //gpEllipse.Widen(pen); gp.AddPath(gpEllipse, true); } } return(gp); }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="isPattern"></param> /// <param name="totalPathLength"></param> /// <param name="interval"></param> /// <returns></returns> internal static GraphicsPath PreparePathToWarp(GraphicsPath path, bool isPattern, Double totalPathLength, Double interval) { var rect = path.GetBounds(); double maxX = rect.Right; double minX = rect.Left; /* * PointF[] pathPoints = path.PathPoints; * for (int i = 0; i < path.PointCount; i++) * { * minX = Math.Min(minX, pathPoints[i].X); * maxX = Math.Max(maxX, pathPoints[i].X); * } */ //if path has x-ordinates less than 0, we need to shift the path to values greater than 0. if (minX < 0d) { Matrix m = new Matrix(1f, 0f, 0f, 1f, (float)minX, 0f); path.Transform(m); maxX -= minX; } //Complete pattern if (isPattern) // && maxX < totalPathLength) { GraphicsPath patternPath = new GraphicsPath(); double pathLength = maxX; interval = interval - pathLength; if (interval < pathLength) { interval = pathLength; } Matrix m = new Matrix(1f, 0f, 0f, 1f, (float)interval, 0f); while (maxX < totalPathLength) { patternPath.StartFigure(); patternPath.AddPath(path, true); maxX += interval; path.Transform(m); } GraphicsPath clippedPattern = ClipPath(path, (float)totalPathLength); if (clippedPattern.PointCount > 0) { patternPath.AddPath(clippedPattern, false); } return(patternPath); } return(path); }
protected override void OnPaint(PaintEventArgs pevent) { Graphics g = pevent.Graphics; ButtonRenderer.DrawParentBackground(g, ClientRectangle, this); // Paint the outer rounded rectangle g.SmoothingMode = SmoothingMode.AntiAlias; using (GraphicsPath outerPath = RoundedRectangle(buttonRect, rectCornerRadius, 0)) { using (LinearGradientBrush outerBrush = new LinearGradientBrush(buttonRect, paintGradientTop, paintGradientBottom, LinearGradientMode.Vertical)) { g.FillPath(outerBrush, outerPath); } using (Pen outlinePen = new Pen(paintGradientTop, rectOutlineWidth)) { outlinePen.Alignment = PenAlignment.Inset; g.DrawPath(outlinePen, outerPath); } } // If this is the default button, paint an additional highlight if (IsDefault) { using (GraphicsPath defaultPath = new GraphicsPath()) { defaultPath.AddPath(RoundedRectangle(buttonRect, rectCornerRadius, 0), false); defaultPath.AddPath(RoundedRectangle(buttonRect, rectCornerRadius, defaultHighlightOffset), false); using (PathGradientBrush defaultBrush = new PathGradientBrush(defaultPath)) { defaultBrush.CenterColor = Color.FromArgb(50, Color.White); defaultBrush.SurroundColors = new Color[] { Color.FromArgb(100, Color.White) }; g.FillPath(defaultBrush, defaultPath); } } } // Paint the gel highlight using (GraphicsPath innerPath = RoundedRectangle(highlightRect, rectCornerRadius, highlightRectOffset)) { using (LinearGradientBrush innerBrush = new LinearGradientBrush(highlightRect, Color.FromArgb(highlightAlphaTop, Color.White), Color.FromArgb(highlightAlphaBottom, Color.White), LinearGradientMode.Vertical)) { g.FillPath(innerBrush, innerPath); } } // Paint the text TextRenderer.DrawText(g, Text, Font, buttonRect, paintForeColor, Color.Transparent, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); }
/// <summary> /// Overridden. Set the bounds of this path. /// </summary> /// <param name="x">The new x-coordinate of the bounds/</param> /// <param name="y">The new y-coordinate of the bounds.</param> /// <param name="width">The new width of the bounds.</param> /// <param name="height">The new height of the bounds.</param> /// <returns>True if the bounds have changed; otherwise, false.</returns> /// <remarks> /// This works by scaling the path to fit into the specified bounds. This normally /// works well, but if the specified base bounds get too small then it is impossible /// to expand the path shape again since all its numbers have tended to zero, so /// application code may need to take this into consideration. /// </remarks> protected override void InternalUpdateBounds(float x, float y, float width, float height) { if (updatingBoundsFromPath || path == null) { return; } if (resizePath != null) { path.Reset(); path.AddPath(resizePath, false); } RectangleF pathBounds = path.GetBounds(); if (pen != null && path.PointCount > 0) { try { TEMP_PATH.Reset(); TEMP_PATH.AddPath(path, false); TEMP_PATH.Widen(pen); RectangleF penPathBounds = TEMP_PATH.GetBounds(); float strokeOutset = Math.Max(penPathBounds.Width - pathBounds.Width, penPathBounds.Height - pathBounds.Height); x += strokeOutset / 2; y += strokeOutset / 2; width -= strokeOutset; height -= strokeOutset; } catch (OutOfMemoryException) { // Catch the case where the path is a single point } } float scaleX = (width == 0 || pathBounds.Width == 0) ? 1 : width / pathBounds.Width; float scaleY = (height == 0 || pathBounds.Height == 0) ? 1 : height / pathBounds.Height; TEMP_MATRIX.Reset(); TEMP_MATRIX.TranslateBy(x, y); TEMP_MATRIX.ScaleBy(scaleX, scaleY); TEMP_MATRIX.TranslateBy(-pathBounds.X, -pathBounds.Y); path.Transform(TEMP_MATRIX.MatrixReference); }
private GraphicsPath GetTitlePath(int nPage) { GraphicsPath path = new GraphicsPath(); path.Reset(); if (nPage == currentPage) { path.AddPath(tabPathSelected, true); } else { path.AddPath(tabPathNormal, true); } Matrix m = new Matrix(); int d = tabWidth;; if (tabView == TabControlView.OneNote) { d += tabHeight / 2; } switch (tabAlignment) { case TabAlignment.Top: m.Translate(d * nPage - offsetX, 0); break; case TabAlignment.Right: m.Rotate(90); m.Translate(d * nPage - offsetX, -Width + 1); break; case TabAlignment.Left: m.Translate(0, nPage * d - offsetX); break; case TabAlignment.Bottom: m.Rotate(-90); m.Translate(-Height + 1, nPage * d - offsetX); break; } path.Transform(m); return(path); }
//Adds a vector path to this element. public virtual void AddPath(GraphicsPath path, bool connect) { mPath.AddPath(path, connect); Geometry.MovePathToOrigin(mPath); SetRectangle(GetBoundingRectangle().Size); OnElementInvalid(); }
public WordGlyph(Word word) { Word = word; var path = new GraphicsPath(); Figure = new SolidFigure(path); if (Word.Polygons != null && Word.Polygons.Count > 0) { foreach (Polygon polygon in Word.Polygons) { path.AddPath(Functions.GeneratePathFromPoints(polygon.ConvertToDrawingPoints()), false); } } Figures = new List <Figure>(); if (Word.Polygons != null && Word.Polygons.Count > 0) { foreach (Polygon polygon in Word.Polygons) { Figures.Add(new SolidFigure(Functions.GeneratePathFromPoints(polygon.ConvertToDrawingPoints()))); } } Figure.Path.CloseAllFigures();; Childs = new List <Glyph>(); }
public GraphicsPath GetShadowPath(GaugeGraphics g) { if (base.Visible && base.ShadowOffset != 0.0 && this.Width > 0.0) { this.SetDrawRegion(g); GraphicsPath graphicsPath = new GraphicsPath(); using (GraphicsPath addingPath = this.GetBarPath((float)(this.Width / 2.0), (float)(this.Width / 2.0), 0f)) { graphicsPath.AddPath(addingPath, false); } using (Matrix matrix = new Matrix()) { matrix.Translate(base.ShadowOffset, base.ShadowOffset); graphicsPath.Transform(matrix); } PointF pointF = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY); g.RestoreDrawRegion(); PointF pointF2 = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY); using (Matrix matrix2 = new Matrix()) { matrix2.Translate(pointF.X - pointF2.X, pointF.Y - pointF2.Y); graphicsPath.Transform(matrix2); return(graphicsPath); } } return(null); }
public static GraphicsPath GetPathFromGraph(IGraph graph) { GraphicsPath path1 = new GraphicsPath(); if (graph is ItopVector.Core.Figure.Group) { SvgElementCollection.ISvgElementEnumerator enumerator1 = ((ItopVector.Core.Figure.Group)graph).GraphList.GetEnumerator(); while (enumerator1.MoveNext()) { SvgElement element1 = (SvgElement)enumerator1.Current; if (element1 is IGraph) { GraphicsPath path2 = PathFunc.GetPathFromGraph((IGraph)element1); if (path2.PointCount > 0) { path1.StartFigure(); path1.AddPath(path2, false); } } } return(path1); } path1 = (GraphicsPath)graph.GPath.Clone(); path1.Transform(graph.Transform.Matrix); return(path1); }
internal GraphicsPath GetShadowPath(GaugeGraphics g) { if (base.Visible && base.ShadowOffset != 0f && Width > 0f) { SetDrawRegion(g); GraphicsPath graphicsPath = new GraphicsPath(); using (GraphicsPath addingPath = GetBarPath(Width / 2f, Width / 2f, 0f)) { graphicsPath.AddPath(addingPath, connect: false); } using (Matrix matrix = new Matrix()) { matrix.Translate(base.ShadowOffset, base.ShadowOffset); graphicsPath.Transform(matrix); } PointF pointF = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY); g.RestoreDrawRegion(); PointF pointF2 = new PointF(g.Graphics.Transform.OffsetX, g.Graphics.Transform.OffsetY); using (Matrix matrix2 = new Matrix()) { matrix2.Translate(pointF.X - pointF2.X, pointF.Y - pointF2.Y); graphicsPath.Transform(matrix2); return(graphicsPath); } } return(null); }
public static GraphicsPath Shrink(this GraphicsPath originalPath, float width) { originalPath.CloseAllFigures(); originalPath.Flatten(); var parts = originalPath.SplitFigures(); var shrunkPaths = new List <GraphicsPath>(); foreach (var part in parts) { using (var widePath = new GraphicsPath(part.PathPoints, part.PathTypes)) { // widen the figure widePath.Widen(new Pen(Color.Black, width * 2)); // pick the inner edge var innerEdge = widePath.SplitFigures()[1]; var fixedPath = CleanPath(innerEdge, part, width); if (fixedPath.PointCount > 0) { shrunkPaths.Add(fixedPath); } } } // build the result originalPath.Reset(); foreach (var p in shrunkPaths) { originalPath.AddPath(p, false); } return(originalPath); }
internal GraphicsPath GetPath(MapGraphics g, bool outlineOnly) { if (Shapes.Count == 0) { return(null); } if (outlineOnly) { ArrayList arrayList = new ArrayList(); foreach (Shape shape in Shapes) { GraphicsPath[] paths = shape.GetPaths(g); arrayList.Add(paths[shape.largestPathIndex]); } if (arrayList.Count > 0 && !GetMapCore().IsDesignMode()) { return(new GraphicsPathOutliner(g.Graphics).GetOutlinePath((GraphicsPath[])arrayList.ToArray(typeof(GraphicsPath)))); } return(null); } GraphicsPath graphicsPath = new GraphicsPath(); foreach (Shape shape2 in Shapes) { GraphicsPath[] paths2 = shape2.GetPaths(g); foreach (GraphicsPath addingPath in paths2) { graphicsPath.AddPath(addingPath, connect: false); } } return(graphicsPath); }
// </snippet8> // Snippet for: M:System.Drawing.Drawing2D.GraphicsPath.AddPath(System.Drawing.Drawing2D.GraphicsPath,System.Boolean) // <snippet9> private void AddPathExample(PaintEventArgs e) { // Create the first pathright side up triangle. Point[] myArray = { new Point(30, 30), new Point(60, 60), new Point(0, 60), new Point(30, 30) }; GraphicsPath myPath = new GraphicsPath(); myPath.AddLines(myArray); // Create the second pathinverted triangle. Point[] myArray2 = { new Point(30, 30), new Point(0, 0), new Point(60, 0), new Point(30, 30) }; GraphicsPath myPath2 = new GraphicsPath(); myPath2.AddLines(myArray2); // Add the second path to the first path. myPath.AddPath(myPath2, true); // Draw the combined path to the screen. Pen myPen = new Pen(Color.Black, 2); e.Graphics.DrawPath(myPen, myPath); }
public override IEnumerable <int> Draw(Graphics g, Pen pen, GraphicsPath path) { var tpath = new GraphicsPath(); var font = new System.Drawing.Font("@宋体", (float)Height, FontStyle.Italic); var format = new StringFormat { Alignment = StringAlignment.Center }; var size = g.MeasureString(Content, font); var rec = new RectangleF( new PointF(-size.Width / 2, -size.Height / 2), size); tpath.AddString( Content, font.FontFamily, (int)font.Style, (float)Height, rec, format); //文字宽度比例0.7,水平翻转 Matrix m = new Matrix(1, 0, 0, -1, 0, 0); m.Scale(0.7f, 1, MatrixOrder.Append); m.Translate((float)Position.X, (float)Position.Y, MatrixOrder.Append); tpath.Transform(m); path.AddPath(tpath, false); path.StartFigure(); yield return(0); yield break; }
public GraphicsPath GetPath(MapGraphics g, bool outlineOnly) { if (this.Shapes.Count == 0) { return(null); } if (outlineOnly) { ArrayList arrayList = new ArrayList(); foreach (Shape shape3 in this.Shapes) { GraphicsPath[] paths = shape3.GetPaths(g); arrayList.Add(paths[shape3.largestPathIndex]); } if (arrayList.Count > 0 && !this.GetMapCore().IsDesignMode()) { GraphicsPathOutliner graphicsPathOutliner = new GraphicsPathOutliner(g.Graphics); return(graphicsPathOutliner.GetOutlinePath((GraphicsPath[])arrayList.ToArray(typeof(GraphicsPath)))); } return(null); } GraphicsPath graphicsPath = new GraphicsPath(); foreach (Shape shape4 in this.Shapes) { GraphicsPath[] paths2 = shape4.GetPaths(g); GraphicsPath[] array = paths2; foreach (GraphicsPath addingPath in array) { graphicsPath.AddPath(addingPath, false); } } return(graphicsPath); }
/// <summary> /// 当鼠标移上去的时候的炫光 /// </summary> /// <param name="g">The graphics object used in the paint event.</param> private void DrawGlow(Graphics g) { if (this.mButtonState == State.Pressed) { return; } using (GraphicsPath glow = new GraphicsPath()) { Rectangle r = this.ClientRectangle; //r.Width -= 3; r.Height -= 3; glow.AddPath(RoundRect(new Rectangle(r.Left + 1, r.Top + 1, r.Width - 3, r.Height - 3), CornerRadius, CornerRadius, CornerRadius, CornerRadius), true); using (GraphicsPath gp = RoundRect(new Rectangle(r.Left + 1, r.Top + 1, r.Width - 3, r.Height / 2 - 2), CornerRadius, CornerRadius, CornerRadius, CornerRadius)) { Color c = Color.FromArgb(mGlowAlpha, this.GlowColor); Color c1 = Color.FromArgb(mGlowAlpha / 2 + 50, Color.White); using (SolidBrush sb = new SolidBrush(c)) { using (SolidBrush sb1 = new SolidBrush(c1)) { g.FillPath(sb, glow); g.FillPath(sb1, gp); } } } } g.ResetClip(); }
private void GetImages(string fileName) { var locX = 100; var locY = 100; var endX = 130; var graphicsPath = new GraphicsPath(); graphicsPath.AddLine(0 + locX, 0 + locY, 40 + locX, 0 + locY); graphicsPath.AddBezier(40 + locX, 0 + locY, 44 + locX, 2 + locY, 44 + locX, 4 + locY, 44 + locX, 6 + locY); graphicsPath.AddBezier(44 + locX, 6 + locY, 15 + locX, 45 + locY, 115 + locX, 45 + locY, 86 + locX, 6 + locY); graphicsPath.AddBezier(86 + locX, 6 + locY, 86 + locX, 4 + locY, 86 + locX, 2 + locY, 90 + locX, 0 + locY); graphicsPath.AddLine(90 + locX, 0 + locY, endX + locX, 0 + locY); graphicsPath.AddPath(getGraphicsPath(graphicsPath, new PointF(65 + locX, 65 + locY), Math.PI), true); //graphicsPath.AddLine(endX, 0, endX, 40); //graphicsPath.AddBezier(endX, 40, endX + 2, 44, endX + 4, 44, endX + 6, 44); //graphicsPath.AddBezier(endX + 6, 44, endX + 45, 15, endX + 45, 115, endX + 6, 86); //graphicsPath.AddBezier(endX + 6, 86, endX + 4, 86, endX + 2, 86, endX, 90); //graphicsPath.AddLine(endX, 90, endX, endX); graphicsPath.AddLine(endX + locX, endX + locY, 0 + locX, endX + locY); graphicsPath.AddLine(0 + locX, endX + locY, 0 + locX, 0 + locY); graphicsPath.AddLine(0 + locX, 0 + locY, 50 + locX, 0 + locY); _pb.Region = new Region(graphicsPath); var bmp = new Bitmap(fileName); _pb.Image = (Image) new Bitmap(bmp, 600, 400); /*Image.FromFile(fileName);*/ _pb.Location = new Point(10, 30); _pb.Size = new Size(600, 500); _pb.BorderStyle = BorderStyle.None; this.Controls.Add(_pb); }
public GraphicsPath RandomWarp(GraphicsPath path) { // Add line // int PsCount = 10; PointF[] curvePs = new PointF[PsCount * 2]; for (int u = 0; u < PsCount; u++) { curvePs[u].X = u * (Width / PsCount); curvePs[u].Y = Height / 2; } for (int u = PsCount; u < (PsCount * 2); u++) { curvePs[u].X = (u - PsCount) * (Width / PsCount); curvePs[u].Y = Height / 2 + 2; } double eps = Height * 0.05; double amp = rnd.NextDouble() * (double)(Height / 3); double size = rnd.NextDouble() * (double)(Width / 4) + Width / 8; double offset = (double)(Height / 3); PointF[] pn = new PointF[path.PointCount]; byte[] pt = new byte[path.PointCount]; GraphicsPath np2 = new GraphicsPath(); GraphicsPathIterator iter = new GraphicsPathIterator(path); for (int i = 0; i < iter.SubpathCount; i++) { GraphicsPath sp = new GraphicsPath(); bool closed; iter.NextSubpath(sp, out closed); Matrix m = new Matrix(); m.RotateAt(Convert.ToSingle(rnd.NextDouble() * 30 - 15), sp.PathPoints[0]); m.Translate(-1 * i, 0);//uncomment sp.Transform(m); np2.AddPath(sp, true); } for (int i = 0; i < np2.PointCount; i++) { //pn[i] = Noise( path.PathPoints[i] , eps); pn[i] = Wave(np2.PathPoints[i], amp, size); pt[i] = np2.PathTypes[i]; } GraphicsPath newpath = new GraphicsPath(pn, pt); return newpath; }