/// <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)); }
public void StandardIdentityTest() { int gc = StandardIdentity.GetCode(string.Empty); Assert.AreEqual(gc, (char)0); gc = StandardIdentity.GetCode(null); Assert.AreEqual(gc, (char)0); gc = StandardIdentity.GetCode("qqqqqqqqqqqqqqq"); Assert.AreEqual(gc, (char)0); string str = StandardIdentity.GetName(string.Empty); Assert.AreEqual(str, string.Empty); str = StandardIdentity.GetName(null); Assert.AreEqual(str, string.Empty); str = StandardIdentity.GetName("qqqqqqqqqqqqqqq"); Assert.AreEqual(str, string.Empty); str = StandardIdentity.GetName("qApqqqqqqqqqqqn"); Assert.AreEqual(str, "Assumed Friend"); }
/// <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 }