static void ExportSymbolId(SymbolIdCode id, string optionalLegacyCode = "") { int width = 256, height = 256; Size exportSize = new Size(width, height); System.Drawing.Bitmap exportBitmap; bool success = Utilities.ExportSymbol(id, out exportBitmap, exportSize); if (!success || (exportBitmap == null)) { Console.WriteLine("Export failed for ID:" + id.HumanReadableCode()); return; } string imageFileName = id.HumanReadableCode(); if (!string.IsNullOrWhiteSpace(optionalLegacyCode)) { imageFileName += "-" + optionalLegacyCode; } string filepath = getFullFileName(imageFileName); Console.WriteLine("Exporting File: " + filepath); exportBitmap.Save(filepath); }
private void butExtras_Click(object sender, EventArgs e) { FormExtras extras = new FormExtras(); DialogResult dr = extras.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { if (extras.cbManuallyEnterCode.Checked) { string id2Try = extras.tbManuallyEnterCode.Text.Trim(); SymbolIdCode tryCode = new SymbolIdCode(id2Try); if (tryCode.IsValid) { this.currentSymbol.Id = tryCode; this.currentPane = PaneSequenceType.StartOver; setSymbolState(); } else { MessageBox.Show("Could not create symbol from ID:" + id2Try + ", Length:" + id2Try.Length, "Create Symbol Failed"); } } } }
static void ExportSymbolSetEntityCode(string symbolSetEntityCode) { if (symbolSetEntityCode.Length < 8) { Usage(); return; } SymbolIdCode sidc = new SymbolIdCode(); string symbolSetString = symbolSetEntityCode.Substring(0, 2); sidc.SymbolSet = (SymbolSetType) TypeUtilities.EnumHelper.getEnumFromHashCodeString(typeof(SymbolSetType), symbolSetString); sidc.EntityCode = symbolSetEntityCode.Substring(2, 6); sidc.Affiliation = StandardIdentityAffiliationType.Friend; ExportSymbolId(sidc); // Export all 4 affiliations if only SymbolSet & EntityCode supplied (& has frame) if (TypeUtilities.HasFrame(sidc.SymbolSet)) { sidc.Affiliation = StandardIdentityAffiliationType.Hostile; ExportSymbolId(sidc); sidc.Affiliation = StandardIdentityAffiliationType.Neutral; ExportSymbolId(sidc); sidc.Affiliation = StandardIdentityAffiliationType.Unknown; ExportSymbolId(sidc); } }
static void ConvertCharlieToDelta(string code2525Charlie) { SymbolIdCode sidc = new SymbolIdCode(); bool success = Utilities.ConvertCodeCharlieToDelta(code2525Charlie, out sidc); string simpleCode = sidc.HumanReadableCode(); printConversionLine(code2525Charlie, sidc, success); }
static void ExportFullSymbolId(string sidcString) { if (sidcString.Length < 20) { Usage(); return; } SymbolIdCode sidc = new SymbolIdCode(); sidc.Code = sidcString; ExportSymbolId(sidc); }
static void ExportCharlieSymbol(string code2525Charlie) { SymbolIdCode sidc = new SymbolIdCode(); bool success = Utilities.ConvertCodeCharlieToDelta(code2525Charlie, out sidc); if (!success) { Console.WriteLine("Could not convert to Delta SIDC: " + code2525Charlie); return; } Console.Write("2525C: " + code2525Charlie + ", "); ExportFullSymbolId(sidc.Code); }
static void printConversionLine(string code2525Charlie, SymbolIdCode sidc, bool success = true, bool newline = true) { if ((success) || (code2525Charlie == "NOT FOUND")) { string simpleCode = sidc.HumanReadableCode(false); Console.Write(code2525Charlie + "," + simpleCode + "," + sidc.Name + "," + sidc.CodeFirstTen + ":" + sidc.CodeSecondTen + ",\"" + sidc.ToString() + "\""); } else { Console.Write(code2525Charlie + ",NOT FOUND,NOT FOUND,NOT FOUND,NOT FOUND"); } if (newline) { Console.WriteLine(); } }
static void PrintCodeLine(SymbolIdCode sidc, string optionalTag = "") { string simpleCode = sidc.HumanReadableCode(false); if (!string.IsNullOrWhiteSpace(baseString)) { Console.Write(baseString + delimiter); } Console.Write(sidc.Code + delimiter + simpleCode + delimiter + sidc.Name + delimiter); if (!string.IsNullOrWhiteSpace(optionalTag)) { Console.WriteLine(optionalTag); } else { Console.WriteLine(); } }
static void ConvertDeltaToCharlie(string sidcString, bool newline = true) { SymbolIdCode sidc = new SymbolIdCode(); if (sidcString.Length == 20) { sidc.Code = sidcString; } else if (sidcString.Length == 8) { string symbolSetString = sidcString.Substring(0, 2); sidc.SymbolSet = (SymbolSetType) TypeUtilities.EnumHelper.getEnumFromHashCodeString(typeof(SymbolSetType), symbolSetString); sidc.EntityCode = sidcString.Substring(2, 6); } string code2525Charlie; bool success = Utilities.ConvertCodeDeltaToCharlie(sidc, out code2525Charlie); string simpleCode = sidc.HumanReadableCode(); printConversionLine(code2525Charlie, sidc, success, newline); }
private static void MyAdHocTest() { ///////////////////////////////////////////////////// // TODO: move this test code to a Unit Test Project ///////////////////////////////////////////////////// SymbolIdCode sidcSpecialLandUnit = new SymbolIdCode("10121195"); string wfnSpecialLandUnit = Utilities.GetWellFormedName(sidcSpecialLandUnit); SymbolIdCode sidc = new SymbolIdCode(); System.Diagnostics.Trace.WriteLine("SIDC=" + sidc); sidc.Affiliation = StandardIdentityAffiliationType.Hostile; SymbolIdCode sidc2 = new SymbolIdCode(); sidc2.Affiliation = StandardIdentityAffiliationType.Hostile; if (sidc == sidc2) { System.Diagnostics.Trace.WriteLine("pass"); } sidc.Affiliation = StandardIdentityAffiliationType.Friend; sidc2.SymbolSet = SymbolSetType.Control_Measures; sidc2.EntityCode = "110100"; if (sidc != sidc2) { System.Diagnostics.Trace.WriteLine("pass"); } string wfn = Utilities.GetWellFormedName(sidc2); sidc.SymbolSet = SymbolSetType.Air; sidc.EntityCode = "110131"; sidc.ModifierOne = "01"; sidc.ModifierTwo = "02"; string wfn2 = Utilities.GetWellFormedName(sidc); MilitarySymbol ms1 = new MilitarySymbol(); ms1.Id = SymbolIdCode.DefaultSymbolIdCode; MilitarySymbol ms2 = new MilitarySymbol(); ms2.Id = new SymbolIdCode(); if (ms1 == ms2) { System.Diagnostics.Trace.WriteLine("pass"); } ms2.Id.HeadquartersTaskForceDummy = HeadquartersTaskForceDummyType.Feint_Dummy; if (ms1 != ms2) { System.Diagnostics.Trace.WriteLine("pass"); } SymbolLookup symbolLookup = new SymbolLookup(); symbolLookup.Initialize(); if (!symbolLookup.Initialized) { System.Diagnostics.Trace.WriteLine("Fail"); } MilitarySymbol ms = symbolLookup.CreateSymbolByEntityName("Fighter/Bomber"); MilitarySymbolToGraphicLayersMaker.SetMilitarySymbolGraphicLayers(ref ms); System.Diagnostics.Trace.WriteLine("MilitarySymbol: " + ms); List <MilitarySymbol> matchingSymbols = symbolLookup.GetMilitarySymbols(SymbolSetType.Space); int matchCount = 0; foreach (MilitarySymbol matchSymbol in matchingSymbols) { matchCount++; System.Diagnostics.Trace.WriteLine("Match: " + matchCount + ", MilitarySymbol: " + matchSymbol);; } List <MilitarySymbol> matchingSymbols2 = symbolLookup.GetMilitarySymbols(SymbolSetType.Space, StandardIdentityAffiliationType.Friend, "Military"); matchCount = 0; foreach (MilitarySymbol matchSymbol in matchingSymbols2) { matchCount++; System.Diagnostics.Trace.WriteLine("Match: " + matchCount + ", MilitarySymbol: " + matchSymbol);; } List <string> matchingStrings = symbolLookup.GetDistinctEntries(SymbolSetType.Space); matchCount = 0; foreach (string distinctMatch in matchingStrings) { matchCount++; System.Diagnostics.Trace.WriteLine("Distinct Match: " + distinctMatch); } matchingStrings = symbolLookup.GetDistinctEntries(SymbolSetType.Air, "Military", "Fixed-Wing"); matchCount = 0; foreach (string distinctMatch in matchingStrings) { matchCount++; System.Diagnostics.Trace.WriteLine("Distinct Match: " + distinctMatch); } matchingStrings = symbolLookup.GetDistinctModifierNames(SymbolSetType.Air, 1); matchCount = 0; foreach (string distinctMatch in matchingStrings) { matchCount++; System.Diagnostics.Trace.WriteLine("Modifiers: Distinct Match: " + distinctMatch); } string modifierName = "Government"; string modifierCode = symbolLookup.GetModifierCodeFromName(SymbolSetType.Air, 1, modifierName); }
static void ProcessSidc(string sidcString) { // base code SymbolIdCode sidc = new SymbolIdCode(sidcString); if (!sidc.IsValid) { Console.WriteLine("Could not create symbol from SIDC: " + sidcString); return; } if (TypeUtilities.IsWeather(sidc.SymbolSet)) { // create a one version & then return, the rest don't apply PrintCommentLine("Weather Symbol Set: " + sidc.SymbolSet); PrintCodeLine(sidc, "Weather - only one version of symbol"); return; } bool hasFrame = TypeUtilities.HasFrame(sidc.SymbolSet); PrintCommentLine("Affiliation/Planning Combinations"); List <Enum> enums = TypeUtilities.EnumHelper.getEnumValues(typeof(StandardIdentityAffiliationType)); foreach (Enum en in enums) { sidc.Affiliation = (StandardIdentityAffiliationType)en; string tag = TypeUtilities.EnumHelper.getStringFromEnum(en); if ((tag != "NotSet") && (tag != "Dont Display Frame")) { PrintCodeLine(sidc, tag); // create a planning version sidc.Status = StatusType.Planned_Anticipated_Suspect; PrintCodeLine(sidc, "Planning"); sidc.Status = StatusType.Present; // Reset // if it has a frame also do the Real/Exercise/Sim combos if ((hasFrame) && ((sidc.Affiliation == StandardIdentityAffiliationType.Friend) || (sidc.Affiliation == StandardIdentityAffiliationType.Hostile) || (sidc.Affiliation == StandardIdentityAffiliationType.Suspect_Joker) || (sidc.Affiliation == StandardIdentityAffiliationType.Neutral) || (sidc.Affiliation == StandardIdentityAffiliationType.Unknown))) { PrintCommentLine("StandardIdentity Combinations for affiliation: " + en); List <Enum> enums2 = TypeUtilities.EnumHelper.getEnumValues(typeof(StandardIdentityRealExerciseSimType)); foreach (Enum en2 in enums2) { sidc.StandardIdentity = (StandardIdentityRealExerciseSimType)en2; string tag2 = TypeUtilities.EnumHelper.getStringFromEnum(en2); if (tag2 != "NotSet") { PrintCodeLine(sidc, tag2); } } // Reset sidc.StandardIdentity = StandardIdentityRealExerciseSimType.Reality; } } } // Reset sidc.Affiliation = StandardIdentityAffiliationType.Friend; // Does it have a frame? If not don't need to do the rest if (!hasFrame) { PrintCommentLine("Non-framed Symbol Set: " + sidc.SymbolSet + " - done"); return; } if (TypeUtilities.HasFrameModifiers(sidc.SymbolSet)) { PrintCommentLine("Headquarters/Task Force/Feint/Dummy Combinations"); enums = TypeUtilities.EnumHelper.getEnumValues(typeof(HeadquartersTaskForceDummyType)); foreach (Enum en in enums) { sidc.HeadquartersTaskForceDummy = (HeadquartersTaskForceDummyType)en; string tag = TypeUtilities.EnumHelper.getStringFromEnum(en); PrintCodeLine(sidc, tag); } // Reset sidc.HeadquartersTaskForceDummy = HeadquartersTaskForceDummyType.NoHQTFDummyModifier; PrintCommentLine("Echelon/Mobility Combinations"); enums = TypeUtilities.EnumHelper.getEnumValues(typeof(EchelonMobilityType)); foreach (Enum en in enums) { sidc.EchelonMobility = (EchelonMobilityType)en; string tag = TypeUtilities.EnumHelper.getStringFromEnum(en); PrintCodeLine(sidc, tag); } // Reset sidc.EchelonMobility = EchelonMobilityType.NoEchelonMobility; } SymbolLookup sl = Utilities.GetSymbolLookup(); CentralIconType iconType = sl.GetEntityIconTypeFromCode(sidc.SymbolSet, sidc.EntityCode); if (iconType == CentralIconType.FULL_OCTAGON) { // Then we are done, no need for modifiers return; } if (iconType != CentralIconType.MAIN_1) // can't have modifier 1 { PrintCommentLine("Modifier 1 Code Combinations"); // Add all the modifiers List <string> modifierCode1s = sl.GetModifierCodesForSymbolSet(sidc.SymbolSet, 1); foreach (string mod1 in modifierCode1s) { sidc.ModifierOne = mod1; string tag = sl.GetModifierNameFromCode(sidc.SymbolSet, 1, mod1); PrintCodeLine(sidc, tag); } } // Reset sidc.ModifierOne = "00"; if (iconType != CentralIconType.MAIN_2) // can't have modifier 1 { PrintCommentLine("Modifier 2 Code Combinations"); List <string> modifierCode2s = sl.GetModifierCodesForSymbolSet(sidc.SymbolSet, 2); foreach (string mod2 in modifierCode2s) { sidc.ModifierTwo = mod2; string tag = sl.GetModifierNameFromCode(sidc.SymbolSet, 2, mod2); PrintCodeLine(sidc, tag); } } // Reset sidc.ModifierTwo = "00"; // Add those "Special Land Unit Entity Subtype combos in Land Unit if (sidc.SymbolSet == SymbolSetType.Land_Unit) { List <string> specialSubTypes = new List <string>() { "95", "96", "97", "98" }; foreach (string subType in specialSubTypes) { sidc.EntitySubTypeField = subType; PrintCodeLine(sidc, subType); } } }