void SetFigureStyle(IniFile.Section section, IFigure figure) { figure.Visible = !section.ReadBool("Hide", false) && section.ReadBool("Visible", true); var fillColor = section.ReadColor("FillColor"); var foreColor = section.ReadColor("ForeColor"); var drawWidth = section.TryReadDouble("DrawWidth") ?? 1.0; if (drawWidth < 0.1) { drawWidth = 0.1; } var drawStyle = section.TryReadInt("DrawStyle"); var fillStyle = section.TryReadInt("FillStyle"); var drawMode = section.TryReadInt("DrawMode"); if (fillStyle == null || fillStyle == 6) { fillColor = Colors.Transparent; } DoubleCollection strokeDashArray = null; if (drawStyle != null && drawStyle != 0) { strokeDashArray = new DoubleCollection(); switch (drawStyle) { case 1: strokeDashArray.Add(15 / drawWidth, 6 / drawWidth); break; case 2: strokeDashArray.Add(3 / drawWidth, 3 / drawWidth); break; case 3: strokeDashArray.Add(10 / drawWidth, 4 / drawWidth, 2 / drawWidth, 4 / drawWidth); break; case 4: strokeDashArray.Add(10 / drawWidth, 4 / drawWidth, 2 / drawWidth, 4 / drawWidth, 2 / drawWidth, 4 / drawWidth); break; default: break; } } IFigureStyle style; if (figure is IShapeWithInterior) { if (fillColor != Colors.Transparent && drawMode != 13) { fillColor.A = 128; } style = new ShapeStyle() { Fill = new SolidColorBrush(fillColor), Color = foreColor, StrokeWidth = drawWidth, StrokeDashArray = strokeDashArray }; } else { if (foreColor == Colors.Transparent) { System.Diagnostics.Debugger.Break(); } style = new LineStyle() { Color = foreColor, StrokeWidth = drawWidth, StrokeDashArray = strokeDashArray }; } figure.Style = drawing.StyleManager.FindExistingOrAddNew(style); }