/// <summary> /// Construction /// </summary> public NodeBackgroundStyle() { m_BackColor = Color.FromArgb(255, 192, 128); m_FadeColor = Color.FromArgb(255, 216, 197); m_FillStyle = FillStyle.Flat; m_Visible = false; }
public Arc(GraphicsDevice graphics, float radius, int tellselation, float thickness, FillStyle style, float startAngle, float sweepAngle, Color baseColor, float outerEdgeThickness, Color outerEdgeColor, float innerEdgeThickness, Color innerEdgeColor, Effect customEffect) { primitive = new ColoredArcPrimitive(graphics, radius, tellselation, thickness, style, startAngle, sweepAngle, baseColor, outerEdgeThickness, outerEdgeColor, innerEdgeThickness, innerEdgeColor); primitive.CustomEffect = customEffect; Radius = radius; Color = baseColor; }
/// <summary> /// /// </summary> /// <param name="graphics"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="fillStyle"></param> /// <param name="backColor"></param> /// <param name="fadeColor"></param> /// <param name="borderStyle"></param> /// <param name="borderColor"></param> public static void PaintRectangle(Graphics graphics, int x, int y, int width, int height, FillStyle fillStyle, Color backColor, Color fadeColor, BorderStyle borderStyle, Color borderColor) { OnPaintBackgroundClassic(x, y, width, height, fillStyle, backColor, fadeColor, borderStyle, borderColor, graphics); }
private PathBuilder GetByFillStyle(FillStyle style, SubShape subShape) { if (style == null) return null; if (subShape.Fills.ContainsKey(style)) return subShape.Fills[style]; var b = new PathBuilder(true, false); b.Tag = style; subShape.Fills.Add(style, b); return b; }
public FillStyleArray(SwfStream swf, bool hasAlpha) { int count = swf.ReadByte(); if (count == 0xFF) count = swf.ReadUShort(); Styles = new FillStyle[count]; for (int i = 0; i < count; i++) Styles[i] = new FillStyle(swf, hasAlpha, i + 1); }
public LineStyle(SwfStream swf, bool hasAlpha, bool isExtended, int index) { Index = index; if (isExtended) { Width = swf.ReadUShort(); StartCapStyle = ReadCap(swf); JoinStyle = ReadJoin(swf); HasFill = swf.ReadBit(); NoHScale = swf.ReadBit(); NoVScale = swf.ReadBit(); PixelHinting = swf.ReadBit(); swf.ReadBitUInt(5); // Reserved NoClose = swf.ReadBit(); EndCapStyle = ReadCap(swf); if (JoinStyle == VGLineJoin.Miter) MiterLimit = swf.ReadFixedHalf(); if (HasFill) Fill = new FillStyle(swf, hasAlpha, -1); else Color = swf.ReadRGBA(); } else { Width = swf.ReadUShort(); Color = hasAlpha ? swf.ReadRGBA() : swf.ReadRGB(); StartCapStyle = VGLineCap.Round; EndCapStyle = VGLineCap.Round; JoinStyle = VGLineJoin.Round; HasFill = false; NoHScale = false; NoVScale = false; PixelHinting = false; NoClose = false; MiterLimit = 1m; Fill = null; } if (Width < 1) Width = 1; }
private void FillStyleToolStripButton_Click(object sender, EventArgs e) { if (diagram1.View.SelectionList != null && diagram1.View.SelectionList.Count > 0) { FillStyleDialog fsd = new FillStyleDialog(); FillStyle fs = null; if (DialogResult.OK == fsd.ShowDialog()) { diagram1.BeginUpdate(); foreach (Node node in this.diagram1.View.SelectionList) { if (node is FilledPath) { fs = (FillStyle)TypeDescriptor.GetProperties(node, false)["FillStyle"].GetValue(node); if (fs != null) { fs.Color = fsd.FillStyle.Color; fs.ForeColor = fsd.FillStyle.ForeColor; fs.ColorAlphaFactor = fsd.FillStyle.ColorAlphaFactor; fs.ForeColorAlphaFactor = fsd.FillStyle.ForeColorAlphaFactor; fs.Type = fsd.FillStyle.Type; fs.GradientAngle = fsd.FillStyle.GradientAngle; fs.GradientCenter = fsd.FillStyle.GradientCenter; fs.PathBrushStyle = fsd.FillStyle.PathBrushStyle; fs.HatchBrushStyle = fsd.FillStyle.HatchBrushStyle; fs.Texture = fsd.FillStyle.Texture; fs.TextureWrapMode = fsd.FillStyle.TextureWrapMode; } } else if (node is ConnectorBase) { ((ConnectorBase)node).LineStyle.LineColor = fsd.FillStyle.Color; ((ConnectorBase)node).HeadDecorator.FillStyle.Color = fsd.FillStyle.Color; ((ConnectorBase)node).HeadDecorator.LineStyle.LineColor = fsd.FillStyle.Color; } } diagram1.EndUpdate(); } } }
public void DrawInterfaceShape(string s, int x, int y, Dictionary <String, CaptionedShapeBase> dShape) { CircleBase shape = (CircleBase)_NShapeProject.ShapeTypes["Circle"].CreateInstance(); shape.Diameter = 100; shape.X = x; shape.Y = y; ColorStyle myColorStyle = new ColorStyle("test", System.Drawing.Color.Green); ColorStyle mySecondColorStyle = new ColorStyle("test", System.Drawing.Color.White); FillStyle myFillStyle = new FillStyle("test", myColorStyle, mySecondColorStyle); shape.FillStyle = myFillStyle; shape.SetCaptionText(0, s); _NShapeDiagram.Shapes.Add(shape); if (!dShape.ContainsKey(s)) { dShape.Add(s, shape); } }
public void DrawPolygon(Polygon polygon, FillStyle fillStyle, LineStyle lineStyle, PointStyle vertexStyle, bool fast) { Polygon viewPolygon = (Polygon)Viewport.GetViewGeometry(polygon); AM.PathGeometry geometry = new AM.PathGeometry(); AM.StreamGeometryContext geometryContext = geometry.Open(); DrawPolygonRing(viewPolygon.Shell, false, geometryContext); foreach (LinearRing hole in viewPolygon.Holes) { DrawPolygonRing(hole, true, geometryContext); } m_Context.DrawGeometry(new SolidColorBrush(fillStyle.Color.Argb), new Pen(new SolidColorBrush(lineStyle.Color.Argb)), geometry); DrawCoordinates(viewPolygon.Shell.Coordinates, vertexStyle, fast, true); foreach (LinearRing hole in viewPolygon.Holes) { DrawCoordinates(hole.Coordinates, vertexStyle, fast, true); } }
public void CanChangeGroupSizeShapesSizeInsideGroupChagedToo() { var slide = new Slide(500, 500); var fStyle = new FillStyle(Color.Red, true); var oStyle = new OutlineStyle(Color.Black, true, 2); var f = new Rect <float> { Top = 0, Left = 0, Width = 10, Height = 10 }; var rect = new Rectangle(f, oStyle, fStyle); var group = new Group(rect); Assert.AreEqual(group.GetShapesCount(), 1); Assert.AreEqual(new Rect <float>(0, 0, 10, 10), group.GetFrame()); Assert.AreEqual(2, group.OutlineStyle.GetLineThickness()); group.SetFrame(new Rect <float>(1, 1, 11, 11)); Assert.AreEqual(new Rect <float>(1, 1, 11, 11), rect.GetFrame()); Assert.AreEqual(new Rect <float>(1, 1, 11, 11), group.GetFrame()); }
public void CanChangeSimpleShapeFrame() { var slide = new Slide(500, 500); var fStyle = new FillStyle(Color.Red, true); var oStyle = new OutlineStyle(Color.Black, true); var newF = new Rect <float> { Top = 3, Left = 2, Width = 4, Height = 4 }; var f = new Rect <float> { Top = 1, Left = 1, Width = 10, Height = 10 }; var rect = new Rectangle(f, oStyle, fStyle); Assert.AreEqual(rect.OutlineStyle, oStyle); Assert.AreEqual(rect.FillStyle, fStyle); Assert.AreEqual(rect.GetFrame(), f); rect.SetFrame(newF); Assert.AreEqual(rect.GetFrame(), newF); }
public void ReturnSumGroupSizeIfGroupMoreThan1Shape() { var slide = new Slide(500, 500); var fStyle = new FillStyle(Color.Red, true); var oStyle = new OutlineStyle(Color.Black, true, 2); var f = new Rect <float> { Top = 0, Left = 0, Width = 10, Height = 10 }; var rect = new Rectangle(f, oStyle, fStyle); var f2 = new Rect <float> { Top = 2, Left = 2, Width = 10, Height = 10 }; var rect2 = new Rectangle(f2, oStyle, fStyle); var group = new Group(rect); group.InsertShape(rect2, 0); Assert.AreEqual(group.GetShapesCount(), 2); Assert.AreEqual(new Rect <float>(0, 0, 12, 12), group.GetFrame()); Assert.AreEqual(2, group.OutlineStyle.GetLineThickness()); }
public void CanAddGroupInGroup() { var slide = new Slide(500, 500); var fStyle = new FillStyle(Color.Red, true); var oStyle = new OutlineStyle(Color.Black, true, 2); var otherFS = new FillStyle(Color.White, false); var otherOS = new OutlineStyle(Color.White, false, 3); var f = new Rect <float> { Top = 0, Left = 0, Width = 10, Height = 10 }; var rect = new Rectangle(f, oStyle, fStyle); var rect2 = new Rectangle(f, otherOS, otherFS); var group1 = new Group(rect); var group2 = new Group(rect2); group1.InsertShape(group2, 1); Assert.AreEqual(group1.GetShapesCount(), 2); Assert.AreEqual(group2.GetShapesCount(), 1); }
public override void Draw(Graphics g) { IsDraw = true; if (Selected) { g.FillPolygon(Brushes.Yellow, pointList); } else { StartPoint = pointList[0]; if (FillStyle.ToString() == "None") { Pen pen = new Pen(PenColor, PenWidth); g.DrawPolygon(pen, pointList); } else { SolidBrush br = new SolidBrush(FillColor); g.FillPolygon(br, pointList); } } }
// ----------------------------- // FillStyle // ----------------------------- static FillStyle ReadFillStyle(SwfStreamReader reader, bool with_alpha) { var fill_style = new FillStyle(); fill_style.Type = SwfFillStyleType.Read(reader); if (fill_style.Type.IsSolidType) { SwfColor.Read(reader, with_alpha); } if (fill_style.Type.IsGradientType) { SwfMatrix.Read(reader, true); // GradientMatrix switch (fill_style.Type.Value) { case SwfFillStyleType.Type.LinearGradient: case SwfFillStyleType.Type.RadialGradient: SkipGradient(reader, with_alpha); // Gradient break; case SwfFillStyleType.Type.FocalGradient: SkipFocalGradient(reader, with_alpha); // FocalGradient break; } } if (fill_style.Type.IsBitmapType) { fill_style.BitmapId = reader.ReadUInt16(); fill_style.BitmapMatrix = SwfMatrix.Read(reader, true); } else { throw new System.Exception( "Imported .swf file contains vector graphics. " + "You should use Tools/FlashExport.jsfl script for prepare .fla file"); } return(fill_style); }
public void ThrowsExceptionIfTryToGetComponentInGroupByIndexWithIndexLessOrMoreThanGroupSize() { var slide = new Slide(500, 500); var fStyle = new FillStyle(Color.Red, true); var oStyle = new OutlineStyle(Color.Black, true, 2); var otherFS = new FillStyle(Color.White, false); var otherOS = new OutlineStyle(Color.White, false, 3); var f = new Rect <float> { Top = 0, Left = 0, Width = 10, Height = 10 }; var rect = new Rectangle(f, oStyle, fStyle); var rect2 = new Rectangle(f, otherOS, otherFS); var group1 = new Group(rect); Assert.ThrowsException <IndexOutOfRangeException>(() => group1.GetComponentByIndex(-1)); Assert.ThrowsException <IndexOutOfRangeException>(() => group1.GetComponentByIndex(1)); group1.InsertShape(rect2, 1); Assert.ThrowsException <IndexOutOfRangeException>(() => group1.GetComponentByIndex(2)); group1.RemoveShapeAtIndex(0); group1.RemoveShapeAtIndex(0); Assert.ThrowsException <IndexOutOfRangeException>(() => group1.GetComponentByIndex(0)); }
public Arc(GraphicsDevice graphics, float radius, int tellselation, float thickness, FillStyle style, float startAngle, float sweepAngle, Color baseColor, Effect customEffect) : this(graphics, radius, tellselation, thickness, style, startAngle, sweepAngle, baseColor, 0f, Color.Transparent, 0f, Color.Transparent, customEffect) { }
public void DrawNestedClassShape(string s, int x, int y, Dictionary<String, CaptionedShapeBase> dShape) { CircleBase shape = (CircleBase)_NShapeProject.ShapeTypes["Circle"].CreateInstance(); shape.Diameter = 100; shape.X = x; shape.Y = y; ColorStyle myColorStyle = new ColorStyle("test", System.Drawing.Color.Red); ColorStyle mySecondColorStyle = new ColorStyle("test", System.Drawing.Color.White); FillStyle myFillStyle = new FillStyle("test", myColorStyle, mySecondColorStyle); shape.FillStyle = myFillStyle; shape.SetCaptionText(0, s); _NShapeDiagram.Shapes.Add(shape); if (!dShape.ContainsKey(s)) dShape.Add(s, shape); }
protected Drawable() { OutlineStyle = new OutlineStyle(Color.Black, 0, System.Drawing.Drawing2D.DashStyle.Solid); FillStyle = new FillStyle(); }
private void FillPaths(FillStyle fill, List <GraphicsPath> paths) { Brush b = null; foreach (GraphicsPath path in paths) { path.Transform(translateMatrix); switch (fill.FillType) { case FillType.Solid: SolidFill sf = (SolidFill)fill; b = new SolidBrush(GetColor(sf.Color)); break; case FillType.Linear: GradientFill lf = (GradientFill)fill; RectangleF rect = Vex.GradientFill.GradientVexRect.SysRectangleF(); LinearGradientBrush lgb = new LinearGradientBrush( rect, Ms.Color.White, Ms.Color.White, 1.0F ); lgb.InterpolationColors = GetColorBlend(lf); lgb.Transform = GetMatrix(lf.Transform); lgb.WrapMode = WrapMode.TileFlipX; ExtendGradientBrush(lgb, path); b = lgb; break; case FillType.Radial: GradientFill rf = (GradientFill)fill; ColorBlend cb = GetColorBlend(rf); SolidBrush bkgCol = new SolidBrush(cb.Colors[0]); g.FillPath(bkgCol, path); bkgCol.Dispose(); // radial fill part GraphicsPath gp = new GraphicsPath(); gp.AddEllipse(Vex.GradientFill.GradientVexRect.SysRectangleF()); PathGradientBrush pgb = new PathGradientBrush(gp); pgb.InterpolationColors = GetColorBlend(rf); pgb.Transform = GetMatrix(rf.Transform); b = pgb; break; case FillType.Image: ImageFill imgFill = (ImageFill)fill; Bitmap bmp = new Bitmap(imgFill.ImagePath); b = new TextureBrush(bmp); break; default: b = new SolidBrush(Ms.Color.Red); break; } g.FillPath(b, path); } if (b != null) { b.Dispose(); } }
public ColoredArcPrimitive( GraphicsDevice graphicsDevice, float radius, int tessellation, float thickness, FillStyle style, float startAngle, float sweepAngle, Color baseColor, float outerEdgeThickness, Color outerEdgeColor, float innerEdgeThickness, Color innerEdgeColor) { if (tessellation < 3) throw new ArgumentOutOfRangeException("tessellation"); if (sweepAngle > (float)(Math.PI * 2)) sweepAngle = (float)(Math.PI * 2); BaseColor = baseColor; float delta = sweepAngle / tessellation; float alpha = startAngle; float swept = 0f; int current = 0; int inc = 2; if (outerEdgeThickness > 0f) inc++; if (innerEdgeThickness > 0f) inc++; while (Math.Abs(swept) < Math.Abs(sweepAngle)) { switch (style) { case FillStyle.Center: if (innerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - (thickness / 2f) - innerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius - (thickness / 2f) - innerEdgeThickness))), Vector3.Up, innerEdgeColor); } AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - thickness / 2f)), 0, (float)(Math.Sin(alpha) * (radius - thickness / 2f))), Vector3.Up, BaseColor); AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + thickness / 2f)), 0, (float)(Math.Sin(alpha) * (radius + thickness / 2f))), Vector3.Up, BaseColor); if (outerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + (thickness / 2f) + outerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius + (thickness / 2f) + outerEdgeThickness))), Vector3.Up, outerEdgeColor); } break; case FillStyle.Inside: if (innerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - thickness - innerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius - thickness - innerEdgeThickness))), Vector3.Up, innerEdgeColor); } AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - thickness)), 0, (float)(Math.Sin(alpha) * (radius - thickness))), Vector3.Up, BaseColor); AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius)), 0, (float)(Math.Sin(alpha) * (radius))), Vector3.Up, BaseColor); if (outerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + outerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius + outerEdgeThickness))), Vector3.Up, outerEdgeColor); } break; case FillStyle.Outside: if (innerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - innerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius - innerEdgeThickness))), Vector3.Up, innerEdgeColor); } AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius)), 0, (float)(Math.Sin(alpha) * (radius))), Vector3.Up, BaseColor); AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + thickness)), 0, (float)(Math.Sin(alpha) * (radius + thickness))), Vector3.Up, BaseColor); if (outerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + thickness + outerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius + thickness + outerEdgeThickness))), Vector3.Up, outerEdgeColor); } break; } alpha += delta; current += inc; swept += delta; if (current > inc) { if (outerEdgeThickness > 0 && innerEdgeThickness > 0f) { AddIndex(current - 8); // inner AddIndex(current - 7); AddIndex(current - 4); AddIndex(current - 3); AddIndex(current - 4); AddIndex(current - 7); AddIndex(current - 7); // center AddIndex(current - 6); AddIndex(current - 3); AddIndex(current - 2); AddIndex(current - 3); AddIndex(current - 6); AddIndex(current - 6); // outer AddIndex(current - 5); AddIndex(current - 2); AddIndex(current - 1); AddIndex(current - 2); AddIndex(current - 5); } else if (outerEdgeThickness > 0 || innerEdgeThickness > 0f) { AddIndex(current - 6); AddIndex(current - 5); AddIndex(current - 3); AddIndex(current - 2); AddIndex(current - 3); AddIndex(current - 5); AddIndex(current - 5); AddIndex(current - 4); AddIndex(current - 2); AddIndex(current - 1); AddIndex(current - 2); AddIndex(current - 4); } else { AddIndex(current - 4); AddIndex(current - 3); AddIndex(current - 2); AddIndex(current - 1); AddIndex(current - 2); AddIndex(current - 3); } } } InitializePrimitive(graphicsDevice); }
private VGPaint MakeFill(FillStyle f, IVGDevice device, FlashDocument document) { VGPaint paint = null; switch (f.FillType) { case FillStyle.FillStyleType.Solid: paint = device.CreateColorPaint(f.Color); break; case FillStyle.FillStyleType.Linear: paint = device.CreateLinearPaint(f.Gradient.AsEnumerable(), f.Gradient.InterpolationMode == GradientInfo.Interpolation.Linear); break; case FillStyle.FillStyleType.Radial: case FillStyle.FillStyleType.Focal: paint = device.CreateRadialPaint(f.Gradient.AsEnumerable(), f.Gradient.InterpolationMode == GradientInfo.Interpolation.Linear); break; case FillStyle.FillStyleType.RepeatingBitmap: case FillStyle.FillStyleType.RepeatingNonsmoothedBitmap: case FillStyle.FillStyleType.ClippedBitmap: case FillStyle.FillStyleType.ClippedNonsmoothedBitmap: paint = device.CreatePatternPaint((document[f.BitmapID] as Bitmap).Image); break; } if (paint is VGColorPaint) return paint; if (paint is VGGradientPaint) { if (f.Gradient is FocalGradientInfo) (paint as VGRadialPaint).FocalPoint = (float)(f.Gradient as FocalGradientInfo).FocalPoint; var p = paint as VGGradientPaint; p.GradientFilter = TextureFilter.Linear; switch (f.Gradient.PadMode) { case GradientInfo.Padding.Pad: p.AddressMode = TextureAddressMode.Clamp; break; case GradientInfo.Padding.Reflect: p.AddressMode = TextureAddressMode.Mirror; break; case GradientInfo.Padding.Repeat: p.AddressMode = TextureAddressMode.Wrap; break; } } if (paint is VGPatternPaint) { var i = (paint as VGPatternPaint).Pattern; switch (f.FillType) { case FillStyle.FillStyleType.RepeatingBitmap: i.ImageFilter = TextureFilter.Linear; i.AddressMode = TextureAddressMode.Wrap; break; case FillStyle.FillStyleType.RepeatingNonsmoothedBitmap: i.ImageFilter = TextureFilter.Point; i.AddressMode = TextureAddressMode.Wrap; break; case FillStyle.FillStyleType.ClippedBitmap: i.ImageFilter = TextureFilter.Linear; i.AddressMode = TextureAddressMode.Clamp; break; case FillStyle.FillStyleType.ClippedNonsmoothedBitmap: i.ImageFilter = TextureFilter.Point; i.AddressMode = TextureAddressMode.Clamp; break; } } return paint; }
public FillStyleArray() { Styles = new FillStyle[] { new FillStyle() }; }
[DllImport("wx-c"), System.Security.SuppressUnmanagedCodeSecurity] static extern void wxBrush_SetStyle(IntPtr self, FillStyle style);
/* * The method takes a string and splits it according to what attributes have to be decoded. */ public static List<Shape> ConvertToShape(string image) { ColorConverter colorConverter = new ColorConverter(); List<String> color = null; Style lineStyle = Style.Solid; FillStyle fillStyle = new FillStyle(); List<Shape> listOfShapes = new List<Shape>(); var originalLine = String.Empty; using (StringReader reader = new StringReader(image)) { var isPolygon = false; var isPolyline = false; Polygon currentPolygon = null; Polyline currentPolyline = null; while ((originalLine = reader.ReadLine()) != null) { var line = originalLine.ToUpper().Trim(); if (String.IsNullOrWhiteSpace(line) || line.StartsWith("*") || line.StartsWith("$") || line.StartsWith("/") || line.StartsWith("HEADER")) { continue; } if (line.StartsWith("ATB")) { var lineParts = line.Split(' '); foreach (var linePart in lineParts) { if (linePart.StartsWith("COL")) { color = new List<String>(); var linePartParts = linePart.Split('='); try { var colorParted = linePartParts[1].Split(','); var R = Convert.ToInt32(colorParted[0]); var G = Convert.ToInt32(colorParted[1]); var B = Convert.ToInt32(colorParted[2]); var colorObject = Color.FromArgb(255, R, G, B); var hexColor = HexConverter(colorObject); if (hexColor != null) { color.Add(hexColor); } } catch (Exception) { color.Add("#ffffff"); } } else if (linePart.StartsWith("FILLSTYLE")) { var linePartParts = linePart.Split('='); if (linePartParts[1] != null) { if (linePartParts[1].Equals("VERTICAL")) { fillStyle = FillStyle.Vertical; } else if (linePartParts[1].Equals("HORIZONTAL")) { fillStyle = FillStyle.Horizontal; } else if (linePartParts[1].Equals("FDIAGONAL")) { fillStyle = FillStyle.Fdiagonal; } else if (linePartParts[1].Equals("BDIAGONAL")) { fillStyle = FillStyle.Bdiagonal; } else if (linePartParts[1].Equals("DIAGCROSS")) { fillStyle = FillStyle.Diagcross; } } else { fillStyle = FillStyle.Transparent; } } else if (linePart.StartsWith("STYLE")) { var linePartParts = linePart.Split('='); if (linePartParts[1] != null) { if (linePartParts[1].Equals("DASHDOTDOT")) { lineStyle = Style.Dashdotdot; }else if (linePartParts[1].Equals("DOT")) { lineStyle = Style.Dot; } } } } } else if (line.StartsWith("C (#") && line.Contains("POLYGON")) // Start of polygon { isPolygon = true; var lineParts = line.Split(' '); var polygon = new Polygon(); polygon.Color = color; polygon.FillStyle = fillStyle; polygon.Style = lineStyle; Coordinates points = new Coordinates(); var lat = lineParts[1].Split('#'); points.Latitude = Convert.ToDouble(lat[1]); points.Longitude = Convert.ToDouble(lineParts[2]); polygon.coordinates.Add(points); currentPolygon = polygon; } else if (line.StartsWith("C (N") && line.Contains("POLYGON")) { isPolygon = true; var polygon = new Polygon(); polygon.Color = color; polygon.FillStyle = fillStyle; polygon.Style = lineStyle; var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var coord = lineParts[1].Split('N'); var latParts = coord[1].Split(','); var divider = createDivider(latParts[0].Length - 3); var latDecimals = ((Convert.ToDouble(latParts[0])) / divider).ToString().Split('.'); if (latDecimals.Length >1) { var latDecimalsParts = ((Convert.ToDouble(latDecimals[1])) / 100).ToString().Split('.'); points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), Convert.ToDouble(latDecimalsParts[0]), Convert.ToDouble(latDecimalsParts[1])); } else { points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), 0, 0); } var longParts = latParts[1].Split('E'); var longDecimals = ((Convert.ToDouble(longParts[1])) / createDivider(longParts[1].Length - 3)).ToString().Split('.'); if (longDecimals.Length > 1) { var longDecimalsParts = ((Convert.ToDouble(longDecimals[1])) / 100).ToString().Split('.'); points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), Convert.ToDouble(longDecimalsParts[0]), Convert.ToDouble(longDecimalsParts[1])); } else { points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), 0, 0); } polygon.coordinates.Add(points); currentPolygon = polygon; } else if (line.StartsWith("C (#") && !(line.Contains("POLYGON"))) // Start of polyline { isPolyline = true; var lineParts = line.Split(' '); var polyline = new Polyline(); polyline.Color = color; polyline.Style = lineStyle; Coordinates points = new Coordinates(); var linePartsPart = lineParts[1].Split('#'); points.Latitude = Convert.ToDouble(linePartsPart[1]); points.Longitude = Convert.ToDouble(lineParts[2]); polyline.type = "Polyline"; polyline.coordinates.Add(points); currentPolyline = polyline; } else if (line.StartsWith("C (N") && !(line.Contains("POLYGON"))) { isPolyline = true; var polyline = new Polyline(); polyline.Color = color; polyline.Style = lineStyle; var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var coord = lineParts[1].Split('N'); var latParts = coord[1].Split(','); var divider = createDivider(latParts[0].Length - 3); var latDecimals = ((Convert.ToDouble(latParts[0])) / divider).ToString().Split('.'); if (latDecimals.Length > 1) { var latDecimalsParts = ((Convert.ToDouble(latDecimals[1])) / 100).ToString().Split('.'); points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), Convert.ToDouble(latDecimalsParts[0]), Convert.ToDouble(latDecimalsParts[1])); } else { points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), 0, 0); } var longParts = latParts[1].Split('E'); var longDecimals = ((Convert.ToDouble(longParts[1])) / createDivider(longParts[1].Length - 3)).ToString().Split('.'); if (longDecimals.Length > 1) { var longDecimalsParts = ((Convert.ToDouble(longDecimals[1])) / 100).ToString().Split('.'); points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), Convert.ToDouble(longDecimalsParts[0]), Convert.ToDouble(longDecimalsParts[1])); } else { points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), 0, 0); } polyline.coordinates.Add(points); currentPolyline = polyline; } else if (line.StartsWith("C +#") && isPolygon) { var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var lat = lineParts[1].Split('#'); points.Latitude = Convert.ToDouble(lat[1]); points.Longitude = Convert.ToDouble(lineParts[2]); currentPolygon.coordinates.Add(points); } else if (line.StartsWith("C +N") && isPolygon) { var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var coord = lineParts[1].Split('N'); var latParts = coord[1].Split(','); var divider = createDivider(latParts[0].Length - 3); var latDecimals = ((Convert.ToDouble(latParts[0])) / divider).ToString().Split('.'); if (latDecimals.Length > 1) { var latDecimalsParts = ((Convert.ToDouble(latDecimals[1])) / 100).ToString().Split('.'); points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), Convert.ToDouble(latDecimalsParts[0]), Convert.ToDouble(latDecimalsParts[1])); } else { points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), 0, 0); } var longParts = latParts[1].Split('E'); var longDecimals = ((Convert.ToDouble(longParts[1])) / createDivider(longParts[1].Length - 3)).ToString().Split('.'); if (longDecimals.Length > 1) { var longDecimalsParts = ((Convert.ToDouble(longDecimals[1])) / 100).ToString().Split('.'); points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), Convert.ToDouble(longDecimalsParts[0]), Convert.ToDouble(longDecimalsParts[1])); } else { points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), 0, 0); } currentPolygon.coordinates.Add(points); } else if (line.StartsWith("C +#") && isPolyline) { var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var linePartsPart = lineParts[1].Split('#'); points.Latitude = Convert.ToDouble(linePartsPart[1]); points.Longitude = Convert.ToDouble(lineParts[2]); currentPolyline.coordinates.Add(points); ; } else if (line.StartsWith("C +N") && isPolyline) { var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var coord = lineParts[1].Split('N'); var latParts = coord[1].Split(','); var divider = createDivider(latParts[0].Length - 3); var latDecimals = ((Convert.ToDouble(latParts[0])) / divider).ToString().Split('.'); if (latDecimals.Length > 1) { var latDecimalsParts = ((Convert.ToDouble(latDecimals[1])) / 100).ToString().Split('.'); points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), Convert.ToDouble(latDecimalsParts[0]), Convert.ToDouble(latDecimalsParts[1])); } else { points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), 0, 0); } var longParts = latParts[1].Split('E'); var longDecimals = ((Convert.ToDouble(longParts[1])) / createDivider(longParts[1].Length - 3)).ToString().Split('.'); if (longDecimals.Length > 1) { var longDecimalsParts = ((Convert.ToDouble(longDecimals[1])) / 100).ToString().Split('.'); points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), Convert.ToDouble(longDecimalsParts[0]), Convert.ToDouble(longDecimalsParts[1])); } else { points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), 0, 0); } currentPolyline.coordinates.Add(points); } else if (line.StartsWith("C )#") && isPolygon) { var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var lat = lineParts[1].Split('#'); points.Latitude = Convert.ToDouble(lat[1]); points.Longitude = Convert.ToDouble(lineParts[2]); currentPolygon.coordinates.Add(points); currentPolygon.type = "Polygon"; listOfShapes.Add(currentPolygon); currentPolygon = null; isPolygon = false; } else if (line.StartsWith("C )N") && isPolygon) { var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var coord = lineParts[1].Split('N'); var latParts = coord[1].Split(','); var divider = createDivider(latParts[0].Length - 3); var latDecimals = ((Convert.ToDouble(latParts[0])) / divider).ToString().Split('.'); if (latDecimals.Length > 1) { var latDecimalsParts = ((Convert.ToDouble(latDecimals[1])) / 100).ToString().Split('.'); points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), Convert.ToDouble(latDecimalsParts[0]), Convert.ToDouble(latDecimalsParts[1])); } else { points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), 0, 0); } var longParts = latParts[1].Split('E'); var longDecimals = ((Convert.ToDouble(longParts[1])) / createDivider(longParts[1].Length - 3)).ToString().Split('.'); if (longDecimals.Length > 1) { var longDecimalsParts = ((Convert.ToDouble(longDecimals[1])) / 100).ToString().Split('.'); points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), Convert.ToDouble(longDecimalsParts[0]), Convert.ToDouble(longDecimalsParts[1])); } else { points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), 0, 0); } currentPolygon.coordinates.Add(points); isPolygon = false; } else if (line.StartsWith("C )#") && isPolyline) { var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var linePartsPart = lineParts[1].Split('#'); points.Latitude = Convert.ToDouble(linePartsPart[1]); points.Longitude = Convert.ToDouble(lineParts[2]); currentPolyline.coordinates.Add(points); currentPolyline.type = "Polyline"; listOfShapes.Add(currentPolyline); currentPolyline = null; isPolyline = false; } else if (line.StartsWith("C )N") && isPolyline) { var lineParts = line.Split(' '); Coordinates points = new Coordinates(); var coord = lineParts[1].Split('N'); var latParts = coord[1].Split(','); var divider = createDivider(latParts[0].Length - 3); var latDecimals = ((Convert.ToDouble(latParts[0])) / divider).ToString().Split('.'); if (latDecimals.Length > 1) { var latDecimalsParts = ((Convert.ToDouble(latDecimals[1])) / 100).ToString().Split('.'); points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), Convert.ToDouble(latDecimalsParts[0]), Convert.ToDouble(latDecimalsParts[1])); } else { points.Latitude = ConvertDegreeAngleToDouble(Convert.ToDouble(latDecimals[0]), 0, 0); } var longParts = latParts[1].Split('E'); var longDecimals = ((Convert.ToDouble(longParts[1])) / createDivider(longParts[1].Length - 3)).ToString().Split('.'); if (longDecimals.Length > 1) { var longDecimalsParts = ((Convert.ToDouble(longDecimals[1])) / 100).ToString().Split('.'); points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), Convert.ToDouble(longDecimalsParts[0]), Convert.ToDouble(longDecimalsParts[1])); } else { points.Longitude = ConvertDegreeAngleToDouble(Convert.ToDouble(longDecimals[0]), 0, 0); } currentPolyline.coordinates.Add(points); isPolyline = false; } else if (line.StartsWith("CIR")) { var circle = new Circle(); circle.Color = color; circle.FillStyle = fillStyle; circle.Style = lineStyle; var lineParts = line.Split(' '); foreach (var linePart in lineParts) { if (linePart.StartsWith("C") && !linePart.StartsWith("CIR")) { var linePartParts = linePart.Split('#'); circle.centerCoordinates.Latitude = Convert.ToDouble(linePartParts[1]); circle.centerCoordinates.Longitude = Convert.ToDouble(lineParts[2]); } else if (linePart.StartsWith("R")) { var linePartParts = linePart.Split('='); var radius = default(double); try { radius = Double.Parse(linePartParts[1], CultureInfo.InvariantCulture); } catch (Exception) { } circle.Radius = convertToMeters(radius); } } circle.type = "Circle"; listOfShapes.Add(circle); } else if (line.StartsWith("TEXT")) { var text = new Text(); text.Color = color; var lineParts = line.Split(' '); foreach (var linePart in lineParts) { if (linePart.StartsWith("POS")) { var linePartParts = linePart.Split('#'); Coordinates points = new Coordinates(); points.Latitude = Convert.ToDouble(linePartParts[1]); points.Longitude = Convert.ToDouble(lineParts[2]); text.coordinates.Add(points); } if (linePart.StartsWith("[")) { var linePartParts = linePart.Split('['); var txt = linePartParts[1].Split(']'); text.textString = txt[0]; } } text.type = "Text"; listOfShapes.Add(text); } } } return listOfShapes; }
public virtual void DrawMark(double x, double y, MarkType type, int size) { double sz = (double)size; FillStyle oldfill = FillStyle; if ((type & MarkType.LargeCross) != 0) { double sd = sz * 1.414213562; //ie. sqrt(2) DrawLine(x, y - sd, x, y + sd); DrawLine(x - sd, y, x + sd, y); } else if ((type & MarkType.Cross) != 0) { DrawLine(x, y - sz, x, y + sz); DrawLine(x - sz, y, x + sz, y); } else if ((type & MarkType.Slit) != 0) { DrawLine(x, y, x, y + sz); } else if ((type & MarkType.Pixel) != 0) { SetPixel(GFXUtil.FloatToInt(x), GFXUtil.FloatToInt(y), Color); } if ((type & MarkType.DiagonalCross) != 0) { DrawLine(x - sz, y - sz, x + sz, y + sz); DrawLine(x - sz, y + sz, x + sz, y - sz); } if ((type & MarkType.Triangle) != 0) { DrawLine(x - sz, y - sz, x + sz, y - sz); DrawLine(x + sz, y - sz, x, y + sz); DrawLine(x, y + sz, x - sz, y - sz); } if ((type & MarkType.Roof) != 0) { DrawLine(x - sz, y + sz, x + sz, y + sz); } if ((type & MarkType.Floor) != 0) { DrawLine(x - sz, y - sz, x + sz, y - sz); } if ((type & MarkType.Circle) != 0) { DrawCircle(x, y, sz); } if ((type & MarkType.Diamond) != 0) { DrawPolyLine(true, x + sz, y, x, y - sz, x - sz, y, x, y + sz); } if ((type & MarkType.FilledRectangle) != 0) { FillStyle = FillStyle.Solid; FillRectangle(x - sz, y - sz, x + sz, y + sz); } else if ((type & MarkType.Rectangle) != 0) { DrawRectangle(x - sz, y - sz, x + sz, y + sz); } if (type.HasFlag(MarkType.Perpendicular)) { DrawLine(x - sz, y + sz, x - sz, y - sz); DrawLine(x - sz, y - sz, x + sz, y - sz); DrawLine(x - sz, y, x, y); DrawLine(x, y, x, y - sz); } if (type.HasFlag(MarkType.Ellipsis)) { MarkEllipsisDot(x - sz, y - sz); MarkEllipsisDot(x, y - sz); MarkEllipsisDot(x + sz, y - sz); } FillStyle = oldfill; }
public Pen(Colour col, int width, FillStyle style) : base(wxPen_ctor(Object.SafePtr(col), width, style)) { }
public Pen(string name, int width, FillStyle style) : base(wxPen_ctorByName(name, width, style)) { }
public Arc(GraphicsDevice graphics, float radius, int tellselation, float thickness, FillStyle style, float startAngle, float sweepAngle, Color baseColor, float outerEdgeThickness, Color outerEdgeColor, float innerEdgeThickness, Color innerEdgeColor) : this(graphics, radius, tellselation, thickness, style, startAngle, sweepAngle, baseColor, outerEdgeThickness, outerEdgeColor, outerEdgeThickness, outerEdgeColor, null) { }
public abstract void changeFillStyle(FillStyle fs);
protected override void RenderPath(FillStyle fs, StrokeStyle ss, List <IShapeData> sh, bool silverlight) { // <Path Fill="#FFFF0000" // StrokeThickness="0.00491913" StrokeLineJoin="Round" Stroke="#FF014393" // Data="M 196.667,4L 388.667,100L 388.667,292L 196.667,388L 4.66669,292L 4.66669,100L 196.667,4 Z "/> if (sh.Count == 0) { return; } xw.WriteStartElement("Path"); bool isGradient = false; bool isTiledBitmap = false; if (fs != null) { if (fs.FillType == FillType.Solid) { Color c = ((SolidFill)fs).Color; xw.WriteStartAttribute("Fill"); xw.WriteColor(c); xw.WriteEndAttribute(); // try to clean up faint edges if (ss == null && c != new Color(0xFF, 0xFF, 0xFF) && c.A != 0) { ss = new SolidStroke(0.3F, c); } } else if ( fs.FillType == FillType.Linear || fs.FillType == FillType.Radial || fs.FillType == FillType.Focal) { isGradient = true; } else if (fs.FillType == FillType.Image) { // Fill="{StaticResource vb_1}" ImageFill img = (ImageFill)fs; if (img.IsTiled || silverlight) { isTiledBitmap = true;// this causes bitmap to be written inline } else { string brushName = imageBrushes[img.ImagePath]; xw.WriteStartAttribute("Fill"); xw.WriteValue("{StaticResource " + brushName + "}"); xw.WriteEndAttribute(); } } } if (ss != null) { if (ss is SolidStroke) { // StrokeThickness="3" StrokeLineJoin="Round" Stroke="#FF014393" // StrokeStartLineCap="Round" // StrokeEndLineCap="Round" SolidStroke st = (SolidStroke)ss; xw.WriteStartAttribute("StrokeThickness"); xw.WriteFloat(st.LineWidth); xw.WriteEndAttribute(); xw.WriteStartAttribute("StrokeLineJoin"); xw.WriteString("Round"); xw.WriteEndAttribute(); xw.WriteStartAttribute("StrokeStartLineCap"); xw.WriteString("Round"); xw.WriteEndAttribute(); xw.WriteStartAttribute("StrokeEndLineCap"); xw.WriteString("Round"); xw.WriteEndAttribute(); xw.WriteStartAttribute("Stroke"); xw.WriteColor(st.Color); xw.WriteEndAttribute(); } } float minX = float.PositiveInfinity; float minY = float.PositiveInfinity; float maxX = float.NegativeInfinity; float maxY = float.NegativeInfinity; xw.WriteStartAttribute("Data"); xw.WriteMoveTo(sh[0].StartPoint); Point lastPoint = sh[0].StartPoint; for (int i = 0; i < sh.Count; i++) { IShapeData sd = sh[i]; if (lastPoint != sd.StartPoint) { xw.WriteMoveTo(sd.StartPoint); } switch (sd.SegmentType) { case SegmentType.Line: xw.WriteLineTo(sd.EndPoint); lastPoint = sd.EndPoint; break; case SegmentType.CubicBezier: CubicBezier cb = (CubicBezier)sd; xw.WriteCubicCurveTo(cb.Control0, cb.Control1, cb.Anchor1); lastPoint = cb.EndPoint; minX = Math.Min(minX, cb.Control0.X); maxX = Math.Max(maxX, cb.Control0.X); minY = Math.Min(minY, cb.Control0.Y); maxY = Math.Max(maxY, cb.Control0.Y); minX = Math.Min(minX, cb.Control1.X); maxX = Math.Max(maxX, cb.Control1.X); minY = Math.Min(minY, cb.Control1.Y); maxY = Math.Max(maxY, cb.Control1.Y); break; case SegmentType.QuadraticBezier: QuadBezier qb = (QuadBezier)sd; xw.WriteQuadraticCurveTo(qb.Control, qb.Anchor1); lastPoint = qb.EndPoint; minX = Math.Min(minX, qb.Control.X); maxX = Math.Max(maxX, qb.Control.X); minY = Math.Min(minY, qb.Control.Y); maxY = Math.Max(maxY, qb.Control.Y); break; } // need bounds for gradient :( if (isGradient) { minX = Math.Min(minX, sd.StartPoint.X); maxX = Math.Max(maxX, sd.StartPoint.X); minY = Math.Min(minY, sd.StartPoint.Y); maxY = Math.Max(maxY, sd.StartPoint.Y); minX = Math.Min(minX, sd.EndPoint.X); maxX = Math.Max(maxX, sd.EndPoint.X); minY = Math.Min(minY, sd.EndPoint.Y); maxY = Math.Max(maxY, sd.EndPoint.Y); } } xw.WriteEndAttribute(); if (isGradient) { GradientFill gf = (GradientFill)fs; // need a gradient def here if (fs.FillType == FillType.Linear) { //<Path.Fill> // <LinearGradientBrush StartPoint="0.14706,0.532137" EndPoint="1.14962,0.55353"> // <LinearGradientBrush.GradientStops> // <GradientStop Color="#FF4A4A4A" Offset="0"/> // <GradientStop Color="#FFB0B0B0" Offset="0.412067"/> // <GradientStop Color="#FFBBBBBB" Offset="0.638141"/> // <GradientStop Color="#FF545454" Offset="1"/> // </LinearGradientBrush.GradientStops> // </LinearGradientBrush> //</Path.Fill> xw.WriteStartElement("Path.Fill"); xw.WriteStartElement("LinearGradientBrush"); Matrix m = gf.Transform; Rectangle r = GradientFill.GradientVexRect; sysDraw2D.Matrix m2 = new sysDraw2D.Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, m.TranslateX, m.TranslateY); float midY = r.Point.Y + (r.Size.Height / 2); sysDraw.PointF pt0 = new sysDraw.PointF(r.Point.X, midY); sysDraw.PointF pt1 = new sysDraw.PointF(r.Point.X + r.Size.Width, midY); sysDraw.PointF[] pts = new sysDraw.PointF[] { pt0, pt1 }; m2.TransformPoints(pts); float ratX = 1 / (maxX - minX); float ratY = 1 / (maxY - minY); float d0x = (pts[0].X - minX) * ratX; float d0y = (pts[0].Y - minY) * ratY; float d1x = (pts[1].X - minX) * ratX; float d1y = (pts[1].Y - minY) * ratY; xw.WriteStartAttribute("StartPoint"); xw.WritePoint(new Point(d0x, d0y)); xw.WriteEndAttribute(); xw.WriteStartAttribute("EndPoint"); xw.WritePoint(new Point(d1x, d1y)); xw.WriteEndAttribute(); xw.WriteStartAttribute("SpreadMethod"); xw.WriteValue("Pad"); xw.WriteEndAttribute(); xw.WriteStartElement("LinearGradientBrush.GradientStops"); for (int i = 0; i < gf.Stops.Count; i++) { xw.WriteStartElement("GradientStop"); xw.WriteStartAttribute("Color"); xw.WriteColor(gf.Fills[i]); xw.WriteEndAttribute(); xw.WriteStartAttribute("Offset"); xw.WriteFloat(gf.Stops[i]); xw.WriteEndAttribute(); xw.WriteEndElement(); // GradientStop } xw.WriteEndElement(); // LinearGradientBrush.GradientStops xw.WriteEndElement(); // LinearGradientBrush xw.WriteEndElement(); // Path.Fill } else if (fs.FillType == FillType.Radial) { //<Ellipse.Fill> // <RadialGradientBrush RadiusX="0.622359" RadiusY="0.604589" Center="0.5,0.5" GradientOrigin="0.5,0.5"> // <RadialGradientBrush.RelativeTransform> // <TransformGroup/> // </RadialGradientBrush.RelativeTransform> // <GradientStop Color="#95000000" Offset="0.347222"/> // <GradientStop Color="#007877A7" Offset="0.773148"/> // </RadialGradientBrush> //</Ellipse.Fill> xw.WriteStartElement("Path.Fill"); xw.WriteStartElement("RadialGradientBrush"); Matrix m = gf.Transform; Rectangle r = GradientFill.GradientVexRect; sysDraw2D.Matrix m2 = new sysDraw2D.Matrix(m.ScaleX, m.Rotate0, m.Rotate1, m.ScaleY, m.TranslateX, m.TranslateY); float midX = r.Point.X + (r.Size.Width / 2); float midY = r.Point.Y + (r.Size.Height / 2); sysDraw.PointF pt0 = new sysDraw.PointF(midX, midY); // center sysDraw.PointF pt1 = new sysDraw.PointF(r.Point.X + r.Size.Width, midY); // radius vector sysDraw.PointF[] pts = new sysDraw.PointF[] { pt0, pt1 }; m2.TransformPoints(pts); float ratX = 1 / (maxX - minX); float ratY = 1 / (maxY - minY); float d0x = (pts[0].X - minX) * ratX; float d0y = (pts[0].Y - minY) * ratY; float d1x = (pts[1].X - pts[0].X); //float d1y = (pts[1].Y - pts[0].Y) * ratY; float rad = (float)Math.Sqrt(d1x * d1x); xw.WriteStartAttribute("RadiusX"); xw.WriteFloat(rad * ratX); xw.WriteEndAttribute(); xw.WriteStartAttribute("RadiusY"); xw.WriteFloat(rad * ratY); xw.WriteEndAttribute(); xw.WriteStartAttribute("Center"); xw.WritePoint(new Point(d0x, d0y)); xw.WriteEndAttribute(); xw.WriteStartAttribute("GradientOrigin"); xw.WritePoint(new Point(d0x, d0y)); xw.WriteEndAttribute(); xw.WriteStartAttribute("SpreadMethod"); xw.WriteValue("Pad"); xw.WriteEndAttribute(); //xw.WriteStartElement("RadialGradientBrush.GradientStops"); for (int i = 0; i < gf.Stops.Count; i++) { xw.WriteStartElement("GradientStop"); xw.WriteStartAttribute("Color"); xw.WriteColor(gf.Fills[i]); xw.WriteEndAttribute(); xw.WriteStartAttribute("Offset"); xw.WriteFloat(1 - gf.Stops[i]); // xaml fill is reversed from gdi xw.WriteEndAttribute(); xw.WriteEndElement(); // GradientStop } //xw.WriteEndElement(); // LinearGradientBrush.GradientStops xw.WriteEndElement(); // LinearGradientBrush xw.WriteEndElement(); // Path.Fill } } else if (isTiledBitmap) { //<Path.Fill> // <ImageBrush ImageSource="Resources\bmp_1.jpg" TileMode="Tile" RelativeTransform=".2,0,0,.2,0,0"/> //</Path.Fill> ImageFill img = (ImageFill)fs; xw.WriteStartElement("Path.Fill"); xw.WriteStartElement("ImageBrush"); xw.WriteStartAttribute("ImageSource"); xw.WriteValue(img.ImagePath); xw.WriteEndAttribute(); if (!silverlight) { xw.WriteStartAttribute("TileMode"); xw.WriteValue("Tile"); xw.WriteEndAttribute(); } //xw.WriteStartAttribute("ViewportUnits"); //xw.WriteValue("Absolute"); //xw.WriteEndAttribute(); Matrix pMatrix = ApplyMatrixToShape(sh, img.Matrix, images[img.ImagePath].StrokeBounds); //Matrix pMatrix = ApplyMatrixToImage(img.Matrix, images[img.ImagePath].Bounds); xw.WriteStartAttribute("RelativeTransform"); xw.WriteMatrix(pMatrix); //xw.WriteMatrix(img.Matrix); xw.WriteEndAttribute(); xw.WriteEndElement(); // Path.Fill xw.WriteEndElement(); // ImageBrush } xw.WriteEndElement(); // Path }
public Brush(Colour colour, FillStyle style) : this() { Colour = colour; Style = style; }
private void ConfigFiltersAndPatching_Load(object sender, EventArgs e) { diagramDisplay.Diagram = diagramSetController.CreateDiagram("filterDiagram"); diagramDisplay.Diagram.Size = new Size(0, 0); diagramDisplay.BackColor = Color.FromArgb(250, 250, 250); diagramDisplay.Diagram.Layers.Add(_visibleLayer); diagramDisplay.Diagram.Layers.Add(_hiddenLayer); diagramDisplay.SetLayerVisibility(_visibleLayer.Id, true); diagramDisplay.SetLayerVisibility(_hiddenLayer.Id, false); diagramDisplay.ShowDefaultContextMenu = false; diagramDisplay.ClicksOnlyAffectTopShape = true; checkBoxHighQualityRendering.Checked = _applicationData.FilterSetupFormHighQualityRendering; diagramDisplay.HighQualityRendering = _applicationData.FilterSetupFormHighQualityRendering; // A: fixed shapes with no connection points: nothing (parent nested shapes: node groups, controllers) ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS, StandardRole.Operator, Permission.Insert); // B: fixed shapes with connection points: connect only (element nodes (leaf), output shapes) ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_FIXED_SHAPE_WITH_CONNECTIONS, StandardRole.Operator, Permission.Connect | Permission.Insert); // C: movable shapes: connect, layout (movable), and deleteable (filters, patch lines) ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_MOVABLE_SHAPE_WITH_CONNECTIONS, StandardRole.Operator, Permission.Connect | Permission.Insert | Permission.Layout | Permission.Delete); // D: fixed shapes with no connection points, but deletable: only for established patch lines (so the user can't move them again, but an still delete them) ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS_DELETABLE, StandardRole.Operator, Permission.Insert | Permission.Delete); ((RoleBasedSecurityManager) diagramDisplay.Project.SecurityManager).SetPermissions(StandardRole.Operator, Permission.All); ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).CurrentRole = StandardRole.Operator; FillStyle styleElementGroup = new FillStyle("ElementGroup", new ColorStyle("", Color.FromArgb(120, 160, 240)), new ColorStyle("", Color.FromArgb(90, 120, 180))); styleElementGroup.FillMode = FillMode.Gradient; FillStyle styleElementLeaf = new FillStyle("ElementLeaf", new ColorStyle("", Color.FromArgb(200, 220, 255)), new ColorStyle("", Color.FromArgb(140, 160, 200))); styleElementLeaf.FillMode = FillMode.Gradient; FillStyle styleFilter = new FillStyle("Filter", new ColorStyle("", Color.FromArgb(255, 220, 150)), new ColorStyle("", Color.FromArgb(230, 200, 100))); styleFilter.FillMode = FillMode.Gradient; FillStyle styleController = new FillStyle("Controller", new ColorStyle("", Color.FromArgb(100, 200, 100)), new ColorStyle("", Color.FromArgb(50, 200, 50))); styleController.FillMode = FillMode.Gradient; FillStyle styleOutput = new FillStyle("Output", new ColorStyle("", Color.FromArgb(180, 230, 180)), new ColorStyle("", Color.FromArgb(120, 210, 120))); styleOutput.FillMode = FillMode.Gradient; project.Design.FillStyles.Add(styleElementGroup, styleElementGroup); project.Design.FillStyles.Add(styleElementLeaf, styleElementLeaf); project.Design.FillStyles.Add(styleFilter, styleFilter); project.Design.FillStyles.Add(styleController, styleController); project.Design.FillStyles.Add(styleOutput, styleOutput); diagramDisplay.DoSuspendUpdate(); // DateTime start = DateTime.Now; // VixenSystem.Logging.Debug("ConfigFiltersAndPatching: LOADING: start time: " + start); _InitializeShapesFromElements(); // VixenSystem.Logging.Debug("ConfigFiltersAndPatching: post _InitializeShapesFromElements: " + (DateTime.Now - start)); _InitializeShapesFromFilters(); // VixenSystem.Logging.Debug("ConfigFiltersAndPatching: post _InitializeShapesFromFilters: " + (DateTime.Now - start)); _InitializeShapesFromControllers(); // VixenSystem.Logging.Debug("ConfigFiltersAndPatching: post _InitializeShapesFromControllers: " + (DateTime.Now - start)); _RelayoutAllShapes(); // VixenSystem.Logging.Debug("ConfigFiltersAndPatching: post _RelayoutAllShapes: " + (DateTime.Now - start)); _CreateConnectionsFromExistingLinks(); // VixenSystem.Logging.Debug("ConfigFiltersAndPatching: post _CreateConnectionsFromExistingLinks: " + (DateTime.Now - start)); diagramDisplay.DoResumeUpdate(); diagramDisplay.CurrentTool = new ConnectionTool(); _populateComboBox(); diagramDisplay.SelectedShapes.Clear(); }
public override void CalculateValues() { foreach (string name in Properties.Keys) { string value = Properties[name]; switch (name) { case "background-color": _backgroundColor = ParseColor(value); break; case "shape": _shape = (ShapeStyle)Enum.Parse(typeof(ShapeStyle), value); break; case "color": _foregroundColor = ParseColor(value); break; case "border-style": _borderStyle = (BorderStyle)Enum.Parse(typeof(BorderStyle), value); break; case "border-width": _borderWidth = float.Parse(value, CultureInfo.InvariantCulture); break; case "border-color": _borderColor = ParseColor(value); break; case "fill-style": _fillStyle = (FillStyle)Enum.Parse(typeof(FillStyle), value); break; case "hatch-style": _hatchStyle = (HatchStyle)Enum.Parse(typeof(HatchStyle), value); break; case "width": _width = float.Parse(value, CultureInfo.InvariantCulture); break; case "height": _height = float.Parse(value, CultureInfo.InvariantCulture); break; case "alpha": _alpha = int.Parse(value, CultureInfo.InvariantCulture); break; } } }
public override void changeFillStyle(FillStyle fs) { fillStyle = fs; }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="fillStyle"></param> /// <param name="backColor"></param> /// <param name="fadeColor"></param> /// <param name="borderStyle"></param> /// <param name="borderColor"></param> /// <param name="graphics"></param> private static void OnPaintBackgroundClassic(int x, int y, int width, int height, FillStyle fillStyle, Color backColor, Color fadeColor, BorderStyle borderStyle, Color borderColor, Graphics graphics) { if (height == 0) { height = 4; } if (width == 0) { width = 4; } if (fillStyle == FillStyle.VistaFading) { Brush brush1 = null, brush2 = null, brush3 = null; brush1 = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, (int)((float)height / 2.0f) + 4), fadeColor, backColor, LinearGradientMode.Vertical); brush2 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 4), backColor, fadeColor, LinearGradientMode.Vertical); brush3 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 2), Color.FromArgb(50, ColorManager.ModifyBrightness(backColor, 0.15)), Color.FromArgb(10, ColorManager.ModifyBrightness(backColor, 1.4)), LinearGradientMode.Vertical); Blend bl = new Blend(); bl.Factors = new float[] { 0f, 0.0f, 0.05f, 1.0f }; bl.Positions = new float[] { 0, 0.5f, 0.55f, 1.0f }; ((LinearGradientBrush)brush3).Blend = bl; graphics.FillRectangle(brush1, x, y, width, (int)((float)height / 2.0f) + 1); graphics.FillRectangle(brush2, x, y + (int)((float)height / 2.0f) - 1, width, (int)((float)height / 2.0f) + 2); SmoothingMode mode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.FillRectangle(brush3, x + 1, y + (int)((float)height / 2.0f) - 1, width - 3, (int)((float)height / 2.0f) + 1); graphics.SmoothingMode = mode; brush1.Dispose(); brush2.Dispose(); brush3.Dispose(); } else if (fillStyle == FillStyle.VerticalCentreFading) { Brush brush1 = null, brush2 = null; brush1 = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, (int)((float)height / 2.0f) + 4), fadeColor, backColor, LinearGradientMode.Vertical); brush2 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 4), backColor, fadeColor, LinearGradientMode.Vertical); SmoothingMode mode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.FillRectangle(brush1, x, y, width, (int)((float)height / 2.0f)); graphics.FillRectangle(brush2, x, y + (int)((float)height / 2.0f) - 1, width, (int)((float)height / 2.0f) + 1); graphics.SmoothingMode = mode; brush1.Dispose(); brush2.Dispose(); } else { Brush brush = null; if (fillStyle == FillStyle.DiagonalBackward) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.BackwardDiagonal); } else if (fillStyle == FillStyle.DiagonalForward) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.ForwardDiagonal); } else if (fillStyle == FillStyle.Flat) { brush = new SolidBrush(backColor); } else if (fillStyle == FillStyle.HorizontalFading) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.Horizontal); } else if (fillStyle == FillStyle.VerticalFading) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), fadeColor, backColor, LinearGradientMode.Vertical); //brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), // backColor, fadeColor, LinearGradientMode.Vertical); } graphics.FillRectangle(brush, x, y, width, height); brush.Dispose(); } // now render the other part a bit if (borderStyle == BorderStyle.Dot) { Pen pen = new Pen(borderColor); pen.DashStyle = DashStyle.Dot; graphics.DrawRectangle(pen, x, y, width - 1, height - 1); pen.Dispose(); } else if (borderStyle == BorderStyle.Solid) { Pen pen = new Pen(borderColor); graphics.DrawRectangle(pen, x, y, width - 1, height - 1); pen.Dispose(); } }
private void SetupPatchingGraphical_Load(object sender, EventArgs e) { diagramDisplay.Diagram = diagramSetController.CreateDiagram("filterDiagram"); diagramDisplay.Diagram.Size = new Size(0, 0); diagramDisplay.BackColor = Color.FromArgb(250, 250, 250); diagramDisplay.Diagram.Layers.Add(_visibleLayer); diagramDisplay.Diagram.Layers.Add(_hiddenLayer); diagramDisplay.SetLayerVisibility(_visibleLayer.Id, true); diagramDisplay.SetLayerVisibility(_hiddenLayer.Id, false); diagramDisplay.ShowDefaultContextMenu = false; diagramDisplay.ClicksOnlyAffectTopShape = true; diagramDisplay.HighQualityRendering = true; // A: fixed shapes with no connection points: nothing (parent nested shapes: node groups, controllers) ((RoleBasedSecurityManager) diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS, StandardRole.Operator, Permission.Insert); // B: fixed shapes with connection points: connect only (element nodes (leaf), output shapes) ((RoleBasedSecurityManager) diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_FIXED_SHAPE_WITH_CONNECTIONS, StandardRole.Operator, Permission.Connect | Permission.Insert); // C: movable shapes: connect, layout (movable), and deleteable (filters, patch lines) ((RoleBasedSecurityManager) diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_MOVABLE_SHAPE_WITH_CONNECTIONS, StandardRole.Operator, Permission.Connect | Permission.Insert | Permission.Layout | Permission.Delete); // D: fixed shapes with no connection points, but deletable: only for established patch lines (so the user can't move them again, but an still delete them) ((RoleBasedSecurityManager) diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS_DELETABLE, StandardRole.Operator, Permission.Insert | Permission.Delete); // E: all permissions ((RoleBasedSecurityManager) diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_ALL_PERMISSIONS, StandardRole.Operator, Permission.All); ((RoleBasedSecurityManager) diagramDisplay.Project.SecurityManager).SetPermissions(StandardRole.Operator, Permission.All); ((RoleBasedSecurityManager) diagramDisplay.Project.SecurityManager).CurrentRole = StandardRole.Operator; FillStyle styleElementGroup = new FillStyle("ElementGroup", new ColorStyle(string.Empty, Color.FromArgb(120, 160, 240)), new ColorStyle(string.Empty, Color.FromArgb(90, 120, 180))); styleElementGroup.FillMode = FillMode.Gradient; FillStyle styleElementLeaf = new FillStyle("ElementLeaf", new ColorStyle(string.Empty, Color.FromArgb(200, 220, 255)), new ColorStyle(string.Empty, Color.FromArgb(140, 160, 200))); styleElementLeaf.FillMode = FillMode.Gradient; FillStyle styleFilter = new FillStyle("Filter", new ColorStyle(string.Empty, Color.FromArgb(255, 220, 150)), new ColorStyle(string.Empty, Color.FromArgb(230, 200, 100))); styleFilter.FillMode = FillMode.Gradient; FillStyle styleController = new FillStyle("Controller", new ColorStyle(string.Empty, Color.FromArgb(100, 200, 100)), new ColorStyle(string.Empty, Color.FromArgb(50, 200, 50))); styleController.FillMode = FillMode.Gradient; FillStyle styleOutput = new FillStyle("Output", new ColorStyle(string.Empty, Color.FromArgb(180, 230, 180)), new ColorStyle(string.Empty, Color.FromArgb(120, 210, 120))); styleOutput.FillMode = FillMode.Gradient; project.Design.FillStyles.Add(styleElementGroup, styleElementGroup); project.Design.FillStyles.Add(styleElementLeaf, styleElementLeaf); project.Design.FillStyles.Add(styleFilter, styleFilter); project.Design.FillStyles.Add(styleController, styleController); project.Design.FillStyles.Add(styleOutput, styleOutput); ConnectionTool tool = new ConnectionTool(); tool.DataFlowModificationMade += tool_DataFlowModificationMade; diagramDisplay.CurrentTool = tool; }
public void FillText(string text, double x, double y) { if (!TextToPaths) { if (!UsedFontFamilies.ContainsKey(Font.FontFamily.FileName)) { UsedFontFamilies.Add(Font.FontFamily.FileName, Font.FontFamily); UsedChars.Add(Font.FontFamily.FileName, new HashSet <char>()); } UsedChars[Font.FontFamily.FileName].UnionWith(text); Font.DetailedFontMetrics metrics = Font.MeasureTextAdvanced(text); double[,] currTransform = null; switch (TextBaseline) { case TextBaselines.Baseline: currTransform = MatrixUtils.Translate(_transform, x - metrics.LeftSideBearing, y); break; case TextBaselines.Top: currTransform = MatrixUtils.Translate(_transform, x - metrics.LeftSideBearing, y + metrics.Top); break; case TextBaselines.Bottom: currTransform = MatrixUtils.Translate(_transform, x - metrics.LeftSideBearing, y + metrics.Bottom); break; case TextBaselines.Middle: currTransform = MatrixUtils.Translate(_transform, x - metrics.LeftSideBearing, y + (metrics.Top + metrics.Bottom) * 0.5); break; default: currTransform = MatrixUtils.Translate(_transform, x - metrics.LeftSideBearing, y); break; } XmlElement currElement = currentElement; if (!string.IsNullOrEmpty(_currClipPath)) { currentElement = Document.CreateElement("g", SVGNamespace); currentElement.SetAttribute("clip-path", _currClipPath); currElement.AppendChild(currentElement); } XmlElement textElement = Document.CreateElement("text", SVGNamespace); textElement.SetAttribute("stroke", "none"); textElement.SetAttribute("fill", FillStyle.ToCSSString(false)); textElement.SetAttribute("fill-opacity", FillStyle.A.ToString(System.Globalization.CultureInfo.InvariantCulture)); textElement.SetAttribute("transform", "matrix(" + currTransform[0, 0].ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + currTransform[1, 0].ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + currTransform[0, 1].ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + currTransform[1, 1].ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + currTransform[0, 2].ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + currTransform[1, 2].ToString(System.Globalization.CultureInfo.InvariantCulture) + ")"); textElement.SetAttribute("x", "0"); textElement.SetAttribute("y", "0"); textElement.SetAttribute("font-size", Font.FontSize.ToString(System.Globalization.CultureInfo.InvariantCulture)); textElement.SetAttribute("font-family", Font.FontFamily.FileName); if (Font.FontFamily.IsBold) { textElement.SetAttribute("font-weight", "bold"); } else { textElement.SetAttribute("font-weight", "regular"); } if (Font.FontFamily.IsItalic) { textElement.SetAttribute("font-style", "italic"); } else { textElement.SetAttribute("font-style", "normal"); } if (Font.FontFamily.IsOblique) { textElement.SetAttribute("font-style", "oblique"); } textElement.InnerText = text; if (!string.IsNullOrEmpty(Tag)) { textElement.SetAttribute("id", Tag); } if (!string.IsNullOrEmpty(this.Tag) && this.linkDestinations.TryGetValue(this.Tag, out string destination) && !string.IsNullOrEmpty(destination)) { XmlElement aElement = Document.CreateElement("a", SVGNamespace); aElement.SetAttribute("href", destination); currentElement.AppendChild(aElement); currentElement = aElement; } currentElement.AppendChild(textElement); currentElement = currElement; } else { PathText(text, x, y); Fill(); } }
public static extern Status XSetFillStyle(IntPtr display, IntPtr gc, FillStyle fill_style);
/// <summary> /// Parametrized contruction /// </summary> /// <param name="backColor"></param> /// <param name="foreColor"></param> /// <param name="borderColor"></param> /// <param name="fadeColor"></param> /// <param name="selectionColor"></param> /// <param name="borderStyle"></param> /// <param name="fillStyle"></param> public TreeViewPathSelectorStyle(Color backColor, Color foreColor, Color borderColor, Color fadeColor, Color selectionColor, BorderStyle borderStyle, FillStyle fillStyle, FillStyle fillStyleSelection) { m_BackColor = backColor; m_ForeColor = foreColor; m_BorderColor = borderColor; m_FadeColor = fadeColor; m_SelectionColor = selectionColor; m_BorderStyle = borderStyle; m_FillStyle = fillStyle; m_FillStyleSelection = fillStyleSelection; }
public void DrawRelationNested(string class1Name, string class2Name, Dictionary<string, CaptionedShapeBase> shapeDictionary) { if (!shapeDictionary.ContainsKey(class1Name)) { MainForm.LogOnDebug("DrawRelation: Departing class missing from dictionary: " + class1Name); return; } if (!shapeDictionary.ContainsKey(class2Name)) { MainForm.LogOnDebug("DrawRelation: Arrival class missing from dictionary: " + class2Name); return; } LineShapeBase line = (LineShapeBase)_NShapeProject.ShapeTypes["Polyline"].CreateInstance(); ThickArrow arrow = (ThickArrow)_NShapeProject.ShapeTypes["ThickArrow"].CreateInstance(); line.Connect(ControlPointId.FirstVertex, shapeDictionary[class1Name], ControlPointId.Reference); line.Connect(ControlPointId.LastVertex, shapeDictionary[class2Name], ControlPointId.Reference); ColorStyle myColorStyle = new ColorStyle("test", System.Drawing.Color.Red); ColorStyle mySecondColorStyle = new ColorStyle("test", System.Drawing.Color.White); FillStyle myFillStyle = new FillStyle("test", myColorStyle, mySecondColorStyle); arrow.FillStyle = myFillStyle; arrow.MoveControlPointTo(1, line.GetControlPointPosition(ControlPointId.FirstVertex).X, line.GetControlPointPosition(ControlPointId.FirstVertex).Y, 0); arrow.MoveControlPointTo(6, line.GetControlPointPosition(ControlPointId.LastVertex).X, line.GetControlPointPosition(ControlPointId.LastVertex).Y, 0); _NShapeDiagram.Shapes.Add(arrow); }
public override VerbResult Start(EditableView.ClickPosition position) { FillStyle.SetDefaults(); return(base.Start(position)); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="fillStyle"></param> /// <param name="backColor"></param> /// <param name="fadeColor"></param> /// <param name="borderStyle"></param> /// <param name="borderColor"></param> /// <param name="graphics"></param> private static void OnPaintBackgroundClassic(int x, int y, int width, int height, FillStyle fillStyle, Color backColor, Color fadeColor, BorderStyle borderStyle, Color borderColor, Graphics graphics) { if (height == 0) height = 4; if (width == 0) width = 4; if (fillStyle == FillStyle.VistaFading) { Brush brush1 = null, brush2 = null, brush3 = null; brush1 = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, (int)((float)height / 2.0f) + 4), fadeColor, backColor, LinearGradientMode.Vertical); brush2 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 4), backColor, fadeColor, LinearGradientMode.Vertical); brush3 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 2), Color.FromArgb(50, ColorManager.ModifyBrightness(backColor, 0.15)), Color.FromArgb(10, ColorManager.ModifyBrightness(backColor, 1.4)), LinearGradientMode.Vertical); Blend bl = new Blend(); bl.Factors=new float[]{0f,0.0f,0.05f,1.0f}; bl.Positions=new float[]{0,0.5f,0.55f,1.0f}; ((LinearGradientBrush)brush3).Blend=bl; graphics.FillRectangle(brush1, x, y, width, (int)((float)height / 2.0f) + 1); graphics.FillRectangle(brush2, x, y + (int)((float)height / 2.0f) - 1, width, (int)((float)height / 2.0f) + 2); SmoothingMode mode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.FillRectangle(brush3, x + 1, y + (int)((float)height / 2.0f) - 1, width - 3, (int)((float)height / 2.0f) + 1); graphics.SmoothingMode = mode; brush1.Dispose(); brush2.Dispose(); brush3.Dispose(); } else if (fillStyle == FillStyle.VerticalCentreFading) { Brush brush1 = null, brush2 = null; brush1 = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, (int)((float)height / 2.0f) + 4), fadeColor, backColor, LinearGradientMode.Vertical); brush2 = new LinearGradientBrush(new Rectangle(x, y + (int)((float)height / 2.0f) - 2, width + 2, (int)((float)height / 2.0f) + 4), backColor, fadeColor, LinearGradientMode.Vertical); SmoothingMode mode = graphics.SmoothingMode; graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.FillRectangle(brush1, x, y, width, (int)((float)height / 2.0f)); graphics.FillRectangle(brush2, x, y + (int)((float)height / 2.0f) - 1, width, (int)((float)height / 2.0f) + 1); graphics.SmoothingMode = mode; brush1.Dispose(); brush2.Dispose(); } else { Brush brush = null; if (fillStyle == FillStyle.DiagonalBackward) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.BackwardDiagonal); } else if (fillStyle == FillStyle.DiagonalForward) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.ForwardDiagonal); } else if (fillStyle == FillStyle.Flat) { brush = new SolidBrush(backColor); } else if (fillStyle == FillStyle.HorizontalFading) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.Horizontal); } else if (fillStyle == FillStyle.VerticalFading) { brush = new LinearGradientBrush(new Rectangle(x - 1, y - 1, width + 2, height + 2), backColor, fadeColor, LinearGradientMode.Vertical); } graphics.FillRectangle(brush, x, y, width, height); brush.Dispose(); } // now render the other part a bit if (borderStyle == BorderStyle.Dot) { Pen pen = new Pen(borderColor); pen.DashStyle = DashStyle.Dot; graphics.DrawRectangle(pen, x, y, width - 1, height - 1); pen.Dispose(); } else if (borderStyle == BorderStyle.Solid) { Pen pen = new Pen(borderColor); graphics.DrawRectangle(pen, x, y, width - 1, height - 1); pen.Dispose(); } }
// Registers entity types for styles, designs, projectData, templates and diagramControllers // with the cache. private void RegisterBaseLibraryTypes(bool create) { int version; // When creating a repository without a valid version, we use the last supported save version. if (create && repository.Version <= 0) { repository.Version = LastSupportedSaveVersion; } version = repository.Version; // repository.AddEntityType(new EntityType(CapStyle.EntityTypeName, EntityCategory.Style, version, () => new CapStyle(), CapStyle.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(CharacterStyle.EntityTypeName, EntityCategory.Style, version, () => new CharacterStyle(), CharacterStyle.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(ColorStyle.EntityTypeName, EntityCategory.Style, version, () => new ColorStyle(), ColorStyle.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(FillStyle.EntityTypeName, EntityCategory.Style, version, () => new FillStyle(), FillStyle.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(LineStyle.EntityTypeName, EntityCategory.Style, version, () => new LineStyle(), LineStyle.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(ParagraphStyle.EntityTypeName, EntityCategory.Style, version, () => new ParagraphStyle(), ParagraphStyle.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(Design.EntityTypeName, EntityCategory.Design, version, () => new Design(), Design.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(ProjectSettings.EntityTypeName, EntityCategory.ProjectSettings, version, () => new ProjectSettings(), ProjectSettings.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(Template.EntityTypeName, EntityCategory.Template, version, () => new Template(), Template.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(Diagram.EntityTypeName, EntityCategory.Diagram, version, () => new Diagram(""), Diagram.GetPropertyDefinitions(version))); // Register ModelMapping types // Create mandatory Model type repository.AddEntityType(new EntityType(Model.EntityTypeName, EntityCategory.Model, version, () => new Model(), Model.GetPropertyDefinitions(version))); // Register mandatory ModelMapping types repository.AddEntityType(new EntityType(NumericModelMapping.EntityTypeName, EntityCategory.ModelMapping, version, () => new NumericModelMapping(), NumericModelMapping.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(FormatModelMapping.EntityTypeName, EntityCategory.ModelMapping, version, () => new FormatModelMapping(), FormatModelMapping.GetPropertyDefinitions(version))); repository.AddEntityType(new EntityType(StyleModelMapping.EntityTypeName, EntityCategory.ModelMapping, version, () => new StyleModelMapping(), StyleModelMapping.GetPropertyDefinitions(version))); // // Create the mandatory shape types initializingLibrary = new Library(GetType().Assembly); ((IRegistrar)this).RegisterLibrary("Core", LastSupportedSaveVersion); ShapeType groupShapeType = new ShapeType( "ShapeGroup", "Core", "Core", ShapeGroup.CreateInstance, ShapeGroup.GetPropertyDefinitions, false); ((IRegistrar)this).RegisterShapeType(groupShapeType); // Create mandatory model object types ModelObjectType genericModelObjectType = new GenericModelObjectType( "GenericModelObject", "Core", "Core", GenericModelObject.CreateInstance, GenericModelObject.GetPropertyDefinitions, 4); ((IRegistrar)this).RegisterModelObjectType(genericModelObjectType); initializingLibrary = null; // // Register static model entity types foreach (ModelObjectType mot in modelObjectTypes) { RegisterModelObjectEntityType(mot, create); } // Register static shape entity types foreach (ShapeType st in shapeTypes) { RegisterShapeEntityType(st, create); } }
[DllImport("wx-c"), System.Security.SuppressUnmanagedCodeSecurity] static extern IntPtr wxPen_ctorByName(string name, int width, FillStyle style);
public Brush(string name, FillStyle style) : this() { Colour = new Colour(name); Style = style; }
public FillPath(FillStyle fillStyle, IShapeData segment) { this.FillStyle = fillStyle; this.Segment = segment; }
private void ConfigFiltersAndPatching_Load(object sender, EventArgs e) { diagramDisplay.Diagram = diagramSetController.CreateDiagram("filterDiagram"); diagramDisplay.Diagram.Size = new Size(0, 0); diagramDisplay.BackColor = Color.FromArgb(250, 250, 250); diagramDisplay.Diagram.Layers.Add(_visibleLayer); diagramDisplay.Diagram.Layers.Add(_hiddenLayer); diagramDisplay.SetLayerVisibility(_visibleLayer.Id, true); diagramDisplay.SetLayerVisibility(_hiddenLayer.Id, false); diagramDisplay.ShowDefaultContextMenu = false; diagramDisplay.ClicksOnlyAffectTopShape = true; checkBoxHighQualityRendering.Checked = _applicationData.FilterSetupFormHighQualityRendering; diagramDisplay.HighQualityRendering = _applicationData.FilterSetupFormHighQualityRendering; // A: fixed shapes with no connection points: nothing (parent nested shapes: node groups, controllers) ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS, StandardRole.Operator, Permission.Insert); // B: fixed shapes with connection points: connect only (element nodes (leaf), output shapes) ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_FIXED_SHAPE_WITH_CONNECTIONS, StandardRole.Operator, Permission.Connect | Permission.Insert); // C: movable shapes: connect, layout (movable), and deleteable (filters, patch lines) ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_MOVABLE_SHAPE_WITH_CONNECTIONS, StandardRole.Operator, Permission.Connect | Permission.Insert | Permission.Layout | Permission.Delete); // D: fixed shapes with no connection points, but deletable: only for established patch lines (so the user can't move them again, but an still delete them) ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).SetPermissions( SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS_DELETABLE, StandardRole.Operator, Permission.Insert | Permission.Delete); ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).SetPermissions(StandardRole.Operator, Permission.All); ((RoleBasedSecurityManager)diagramDisplay.Project.SecurityManager).CurrentRole = StandardRole.Operator; FillStyle styleElementGroup = new FillStyle("ElementGroup", new ColorStyle(string.Empty, Color.FromArgb(120, 160, 240)), new ColorStyle(string.Empty, Color.FromArgb(90, 120, 180))); styleElementGroup.FillMode = FillMode.Gradient; FillStyle styleElementLeaf = new FillStyle("ElementLeaf", new ColorStyle(string.Empty, Color.FromArgb(200, 220, 255)), new ColorStyle(string.Empty, Color.FromArgb(140, 160, 200))); styleElementLeaf.FillMode = FillMode.Gradient; FillStyle styleFilter = new FillStyle("Filter", new ColorStyle(string.Empty, Color.FromArgb(255, 220, 150)), new ColorStyle(string.Empty, Color.FromArgb(230, 200, 100))); styleFilter.FillMode = FillMode.Gradient; FillStyle styleController = new FillStyle("Controller", new ColorStyle(string.Empty, Color.FromArgb(100, 200, 100)), new ColorStyle(string.Empty, Color.FromArgb(50, 200, 50))); styleController.FillMode = FillMode.Gradient; FillStyle styleOutput = new FillStyle("Output", new ColorStyle(string.Empty, Color.FromArgb(180, 230, 180)), new ColorStyle(string.Empty, Color.FromArgb(120, 210, 120))); styleOutput.FillMode = FillMode.Gradient; project.Design.FillStyles.Add(styleElementGroup, styleElementGroup); project.Design.FillStyles.Add(styleElementLeaf, styleElementLeaf); project.Design.FillStyles.Add(styleFilter, styleFilter); project.Design.FillStyles.Add(styleController, styleController); project.Design.FillStyles.Add(styleOutput, styleOutput); diagramDisplay.DoSuspendUpdate(); // DateTime start = DateTime.Now; // Logging.Debug("ConfigFiltersAndPatching: LOADING: start time: " + start); _InitializeShapesFromElements(); // Logging.Debug("ConfigFiltersAndPatching: post _InitializeShapesFromElements: " + (DateTime.Now - start)); _InitializeShapesFromFilters(); // Logging.Debug("ConfigFiltersAndPatching: post _InitializeShapesFromFilters: " + (DateTime.Now - start)); _InitializeShapesFromControllers(); // Logging.Debug("ConfigFiltersAndPatching: post _InitializeShapesFromControllers: " + (DateTime.Now - start)); _RelayoutAllShapes(); // Logging.Debug("ConfigFiltersAndPatching: post _RelayoutAllShapes: " + (DateTime.Now - start)); _CreateConnectionsFromExistingLinks(); // Logging.Debug("ConfigFiltersAndPatching: post _CreateConnectionsFromExistingLinks: " + (DateTime.Now - start)); diagramDisplay.DoResumeUpdate(); diagramDisplay.CurrentTool = new ConnectionTool(); _populateComboBox(); diagramDisplay.SelectedShapes.Clear(); }
public ColoredArcPrimitive( GraphicsDevice graphicsDevice, float radius, int tessellation, float thickness, FillStyle style, float startAngle, float sweepAngle, Color baseColor, float outerEdgeThickness, Color outerEdgeColor, float innerEdgeThickness, Color innerEdgeColor) { if (tessellation < 3) { throw new ArgumentOutOfRangeException("tessellation"); } if (sweepAngle > (float)(Math.PI * 2)) { sweepAngle = (float)(Math.PI * 2); } BaseColor = baseColor; float delta = sweepAngle / tessellation; float alpha = startAngle; float swept = 0f; int current = 0; int inc = 2; if (outerEdgeThickness > 0f) { inc++; } if (innerEdgeThickness > 0f) { inc++; } while (Math.Abs(swept) < Math.Abs(sweepAngle)) { switch (style) { case FillStyle.Center: if (innerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - (thickness / 2f) - innerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius - (thickness / 2f) - innerEdgeThickness))), Vector3.Up, innerEdgeColor); } AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - thickness / 2f)), 0, (float)(Math.Sin(alpha) * (radius - thickness / 2f))), Vector3.Up, BaseColor); AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + thickness / 2f)), 0, (float)(Math.Sin(alpha) * (radius + thickness / 2f))), Vector3.Up, BaseColor); if (outerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + (thickness / 2f) + outerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius + (thickness / 2f) + outerEdgeThickness))), Vector3.Up, outerEdgeColor); } break; case FillStyle.Inside: if (innerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - thickness - innerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius - thickness - innerEdgeThickness))), Vector3.Up, innerEdgeColor); } AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - thickness)), 0, (float)(Math.Sin(alpha) * (radius - thickness))), Vector3.Up, BaseColor); AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius)), 0, (float)(Math.Sin(alpha) * (radius))), Vector3.Up, BaseColor); if (outerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + outerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius + outerEdgeThickness))), Vector3.Up, outerEdgeColor); } break; case FillStyle.Outside: if (innerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius - innerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius - innerEdgeThickness))), Vector3.Up, innerEdgeColor); } AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius)), 0, (float)(Math.Sin(alpha) * (radius))), Vector3.Up, BaseColor); AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + thickness)), 0, (float)(Math.Sin(alpha) * (radius + thickness))), Vector3.Up, BaseColor); if (outerEdgeThickness > 0f) { AddVertex(new Vector3((float)(Math.Cos(alpha) * (radius + thickness + outerEdgeThickness)), 0, (float)(Math.Sin(alpha) * (radius + thickness + outerEdgeThickness))), Vector3.Up, outerEdgeColor); } break; } alpha += delta; current += inc; swept += delta; if (current > inc) { if (outerEdgeThickness > 0 && innerEdgeThickness > 0f) { AddIndex(current - 8); // inner AddIndex(current - 7); AddIndex(current - 4); AddIndex(current - 3); AddIndex(current - 4); AddIndex(current - 7); AddIndex(current - 7); // center AddIndex(current - 6); AddIndex(current - 3); AddIndex(current - 2); AddIndex(current - 3); AddIndex(current - 6); AddIndex(current - 6); // outer AddIndex(current - 5); AddIndex(current - 2); AddIndex(current - 1); AddIndex(current - 2); AddIndex(current - 5); } else if (outerEdgeThickness > 0 || innerEdgeThickness > 0f) { AddIndex(current - 6); AddIndex(current - 5); AddIndex(current - 3); AddIndex(current - 2); AddIndex(current - 3); AddIndex(current - 5); AddIndex(current - 5); AddIndex(current - 4); AddIndex(current - 2); AddIndex(current - 1); AddIndex(current - 2); AddIndex(current - 4); } else { AddIndex(current - 4); AddIndex(current - 3); AddIndex(current - 2); AddIndex(current - 1); AddIndex(current - 2); AddIndex(current - 3); } } } InitializePrimitive(graphicsDevice); }