/// <summary> /// Sets the standard line brush. /// </summary> /// <param name="lineBrush"> /// The line brush to be used as the standard. /// </param> private void SetLines(Brush lineBrush) { // Standard calls for black lines and black text this.line = MilBrush.GetLinePresent(MilBrush.Black); if (lineBrush != null) { this.line = new Style(typeof(Shape)) { BasedOn = this.line }; this.line.Setters.Add(new Setter(Shape.StrokeProperty, lineBrush)); } }
/// <summary> /// Sets the brush for unframed lines and fills /// </summary> /// <param name="fillBrush"> /// The fill brush to use for unframed lines and fills. /// </param> private void SetUnframedLineFills(Brush fillBrush) { if (fillBrush == null) { return; } // Use brush to find fill styles this.fill = MilBrush.GetFill(fillBrush); this.unframedLineFill = MilBrush.GetLineFillPresent(fillBrush); this.unframedLineFill = new Style(typeof(Shape)) { BasedOn = this.unframedLineFill }; this.unframedLineFill.Setters.Add(new Setter(Shape.StrokeProperty, fillBrush)); }
/// <summary> /// Sets the standard line and fill brush. /// </summary> /// <param name="lineBrush"> /// The line brush to be used for lines. /// </param> /// <param name="fillBrush"> /// The fill brush to be used for fills. /// </param> private void SetLineFills(Brush lineBrush, Brush fillBrush) { if (fillBrush == null) { return; } // Use brush to find fill styles this.fill = MilBrush.GetFill(fillBrush); this.lineFill = MilBrush.GetLineFillPresent(fillBrush); if (lineBrush != null) { this.lineFill = new Style(typeof(Shape)) { BasedOn = this.lineFill }; this.lineFill.Setters.Add(new Setter(Shape.StrokeProperty, lineBrush)); } this.brush = fillBrush; // may need this brush for unframed symbols }
/// <summary> /// Initializes a new instance of the <see cref="MilSymbolBase"/> class. /// </summary> /// <param name="symbolCode"> /// The symbol code for this symbol. /// </param> /// <param name="lineBrush"> /// An optional line brush for outlining the symbol. /// </param> /// <param name="fillBrush"> /// An optional fill brush for filling the symbol's background. /// </param> public MilSymbolBase(string symbolCode, Brush lineBrush, Brush fillBrush) { if (symbolCode == null) { this.empty = true; return; } string stencil = CodeToStencil(symbolCode); if (MilAppendix.NoTemplate(stencil)) { this.empty = true; return; } this.DataContext = this; // Will need to treat weather and tactical graphics carefully int schemeKey = CodingScheme.GetCode(symbolCode); if (schemeKey == CodingScheme.Weather) { // These symbols can change color - so we bind to Line and Fill if (symbolCode.StartsWith("WAS-WSTS")) { if (lineBrush == null) { lineBrush = MilBrush.Rust; } if (fillBrush == null) { fillBrush = MilBrush.Rust; } this.SetLines(lineBrush); this.SetLineFills(lineBrush, fillBrush); } this.Template = SymbolData.GetControlTemplate(stencil); // gets the template - the main thing this.empty = this.Template == null; if (!this.empty) { this.SetLimits(symbolCode); } return; } // If the standard identity (StandardIdentity) is some type of pending, we'll need the // anticipated (dashhed) outline for the frame. this.needDashed = SymbolData.IsDashed(symbolCode); // There are occasions when we need a line style that matches affiliation and present int dimensionKey = CategoryBattleDimension.GetCode(symbolCode); bool needUnframed = schemeKey == CodingScheme.TacticalGraphics || dimensionKey == CategoryBattleDimension.BdOther || (schemeKey == CodingScheme.Warfighting && dimensionKey == CategoryBattleDimension.BdSubsurface); if (needUnframed) { this.unframedLine = MilBrush.GetLinePresent(MilBrush.FindColorScheme(symbolCode)); this.SetUnframedLines(lineBrush); } this.SetLines(lineBrush); // Get a brush style if user didn't specify if (fillBrush == null) { fillBrush = MilBrush.FindColorScheme(symbolCode); } if (needUnframed) { this.SetUnframedLineFills(fillBrush); } this.SetLineFills(lineBrush, fillBrush); this.Template = SymbolData.GetControlTemplate(stencil); // gets the template - the main thing this.empty = this.Template == null; if (!this.empty) { this.SetLimits(symbolCode); } }