public void MilAppendixTest() { string str = MilAppendix.Description("qqqqqqqqqqqqqqq"); Assert.AreEqual(str, string.Empty); str = MilAppendix.Description(null); Assert.AreEqual(str, string.Empty); str = MilAppendix.Description("I*G*SC------***"); Assert.AreEqual(str, "Signals Intelligence\r\n Ground Track\r\n Signal Intercept\r\n Communications\r\n"); }
/// <summary> /// Process the given appendix. /// </summary> /// <param name="append"> /// The name of the appendix. /// </param> /// <param name="framed"> /// Whether or not the symbols are framed. /// </param> private void ProcessSymbolCollection(string append, bool framed) { const double Scale = 1.0; // Since some appendices cross reference symbols, // in other appendices, we'll check to make sure // we haven't already drawn a particular symbol code. IList <string> symList = new List <string>(); var affiliations = new[] { "U", "F", "N", "H" }; var keys = MilAppendix.Keys(append); foreach (var ap in keys) { MilSymbol ms; var sc = ap; if (symList.Contains(sc)) { continue; } symList.Add(sc); // There is no affiliation for weather var schemeKey = CodingScheme.GetCode(sc); if (schemeKey == CodingScheme.Weather) { ms = new MilSymbol(sc, Scale, "X=67.8"); this.ProcessSymbol(ms, sc); continue; } if (schemeKey == CodingScheme.TacticalGraphics) { sc = sc.Substring(0, 1) + "H" + sc.Substring(2, 1) + "A" + sc.Substring(4); ms = new MilSymbol(sc, Scale, "H=HH;H1=H1;W=W;W1=W1;T=TT;N=N;X=XX;V=VV;C=CC;Y=YY;Q=-60.0"); this.ProcessSymbol(ms, sc); continue; } if (!framed) { sc = sc.Substring(0, 2) + "X" + sc.Substring(3); } foreach (var c in affiliations) { sc = sc[0] + c + sc[2] + "P" + sc.Substring(4, 10) + "E"; ms = new MilSymbol(sc, Scale, null, null); this.ProcessSymbol(ms, sc); } } }
/// <summary> /// Generates a static tooltip for a given symbol code. /// </summary> /// <param name="symbolCode">The symbol code which needs the tooltip.</param> /// <returns>A string representing a tooltip.</returns> private static string GenerateTooltip(string symbolCode) { var desc = new StringBuilder(MilAppendix.Description(symbolCode)); desc.AppendLine("Affiliation: " + StandardIdentity.GetName(symbolCode)); desc.AppendLine("Condition: " + StatusOperationalCapacity.GetName(symbolCode)); desc.AppendLine("Order of battle: " + OrderOfBattle.GetName(symbolCode)); desc.AppendLine("Country: " + Countries.GetName(symbolCode)); desc.Append("Modifier: " + CombinedModifierCode.GetName(symbolCode)); return(desc.ToString(0, desc.Length)); }
/// <summary> /// Writes out the CXML file. /// </summary> /// <param name="ms"> /// The symbol for which to generate the CXML. /// </param> /// <param name="rootName"> /// The name to use for the symbol. /// </param> private void WriteCxml(MilSymbol ms, string rootName) { var symbolCode = (CodingScheme.GetCode(ms.SymbolCode) != CodingScheme.Weather) ? rootName + "*****" : ms.SymbolCode; var description = MilAppendix.Description(symbolCode); var lines = description.Split(new[] { '\n' }); var lineCount = lines.Length - 1; // the last line is empty var sb = new StringBuilder(); sb.AppendFormat(@"<Item Id=""{0}"" Name=""{1}"" Img=""Symbols\{1}.png"" Href="""">", this.index++, rootName); sb.AppendLine(); if (lineCount > 0) { sb.AppendFormat(@" <Description>""{0}""</Description>", lines[lineCount - 1].Trim(new[] { ' ', '\n', '\r' })); sb.AppendLine(); } else { sb.AppendFormat(@" <Description>""""</Description>"); sb.AppendLine(); } sb.AppendLine(@" <Facets>"); sb.AppendLine(@" <Facet Name=""Affiliation"">"); sb.AppendFormat(@" <String Value=""{0}"" />", StandardIdentity.GetName(symbolCode)); sb.AppendLine(); sb.AppendLine(@" </Facet>"); sb.AppendLine(@" <Facet Name=""Battle Dimension"">"); sb.AppendFormat(@" <String Value=""{0}"" />", CategoryBattleDimension.GetName(symbolCode)); sb.AppendLine(); sb.AppendLine(@" </Facet>"); if (lineCount > 2) { sb.AppendLine(@" <Facet Name=""Type"">"); sb.AppendFormat(@" <String Value=""{0}"" />", lines[2].Trim(new[] { ' ', '\n', '\r' })); sb.AppendLine(); sb.AppendLine(@" </Facet>"); } sb.AppendLine(@" <Facet Name=""Coding Scheme"">"); sb.AppendFormat(@" <String Value=""{0}"" />", CodingScheme.GetName(symbolCode)); sb.AppendLine(); sb.AppendLine(@" </Facet>"); if (lineCount - 1 > 3) { sb.AppendLine(@" <Facet Name=""Key Phrases"">"); for (var i = 3; i < lineCount - 1; i++) { sb.AppendFormat(@" <String Value=""{0}"" />", lines[i].Trim(new[] { ' ', '\n', '\r' })); sb.AppendLine(); } sb.AppendLine(@" </Facet>"); } sb.AppendLine(@" </Facets>"); sb.AppendLine(@"</Item>"); #if DO_WRITES this.cxmlStream.Write(sb.ToString()); #endif }
/// <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); } }
/// <summary> /// Plots all of the core symbols that are in Appendix D. /// Since not all symbol codes are non-blank, there are some blanks in the output. /// Refer to MIL-STD 2525C for comparison. /// </summary> /// <param name="append"> /// The appendix from which to get the symbols. /// </param> /// <param name="framed"> /// Whether or not the symbols are framed. /// </param> private static void PlotAllSymbols(string append, bool framed) { Canvas cv = GetCanvas(); if (cv == null) { return; } // Since some appendices cross reference symbols, // in other appendices, we'll check to make sure // we haven't already drawn a particular symbol code. IList <string> symList = new List <string>(); double x = Edge; double y = Edge; var affiliations = new[] { "U", "F", "N", "H" }; bool first = true; var keys = MilAppendix.Keys(append); foreach (string ap in keys) { string sc = ap; if (symList.Contains(sc)) { continue; } symList.Add(sc); // There is no affiliation for weather int schemeKey = CodingScheme.GetCode(sc); if (schemeKey == CodingScheme.Weather) { // Check centering // var ls1 = new Line { X1 = x + 5, Y1 = y + 5, X2 = x - 5, Y2 = y - 5, Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 1 }; // var ls2 = new Line { X1 = x - 5, Y1 = y + 5, X2 = x + 5, Y2 = y - 5, Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 1 }; // cv.Children.Add(ls1); // cv.Children.Add(ls2); var ms = new MilSymbol(sc, Scale, "X=67.8"); DrawSymbol(cv, ms, x, y); if ((x += Tight) > 12 * Tight) { x = Edge; y += Tight; } continue; } if (schemeKey == CodingScheme.TacticalGraphics) { // Check centering // var ls1 = new Line { X1 = x + 5, Y1 = y + 5, X2 = x - 5, Y2 = y - 5, Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 1 }; // var ls2 = new Line { X1 = x - 5, Y1 = y + 5, X2 = x + 5, Y2 = y - 5, Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 1 }; // cv.Children.Add(ls1); // cv.Children.Add(ls2); sc = sc.Substring(0, 1) + "H" + sc.Substring(2, 1) + "A" + sc.Substring(4); var ms = new MilSymbol(sc, Scale, "H=HH;H1=H1;W=W;W1=W1;T=TT;N=N;X=XX;V=VV;C=CC;Y=YY;Q=-60.0"); DrawSymbol(cv, ms, x, y); if ((x += Tight) > 12 * Tight) { x = Edge; y += Tight + 25; } continue; } if (!framed) { sc = sc.Substring(0, 2) + "X" + sc.Substring(3); } foreach (string c in affiliations) { sc = sc[0] + c + sc[2] + "C" + sc.Substring(4, 10) + "E"; var ms = new MilSymbol(sc, Scale, null, null); if (first && ms.Empty) { continue; } first = false; DrawSymbol(cv, ms, x, y); if ((x += Tight) > 12 * Tight) { x = Edge; y += Tight; } } } }