private void FormPicker_Load(object sender, EventArgs e) { symbolLookup.Initialize(); if (!symbolLookup.Initialized) { MessageBox.Show(@"Symbol Search will not work: Could not initialize the Symbol Lookup (Do Data\*.csv files exist? Are they locked/open anywhere else?)"); } CheckSettings(); buttonList.Add(this.button11); buttonList.Add(this.button12); buttonList.Add(this.button13); buttonList.Add(this.button14); buttonList.Add(this.button15); buttonList.Add(this.button21); buttonList.Add(this.button22); buttonList.Add(this.button23); buttonList.Add(this.button24); buttonList.Add(this.button25); buttonList.Add(this.button31); buttonList.Add(this.button32); buttonList.Add(this.button33); buttonList.Add(this.button34); buttonList.Add(this.button35); currentSymbol.Id.Affiliation = StandardIdentityAffiliationType.NotSet; currentSymbol.Id.SymbolSet = SymbolSetType.NotSet; SetPaneState(); }
private void FormPicker_Load(object sender, EventArgs e) { symbolLookup.Initialize(); if (!symbolLookup.Initialized) { MessageBox.Show(@"Symbol Search will not work: Could not initialize the Symbol Lookup (Do Data\*.csv files exist? Are they locked/open anywhere else?)"); } if (!System.IO.Directory.Exists(MilitarySymbolToGraphicLayersMaker.ImageFilesHome)) { MessageBox.Show("Images will not work: could not find folder: " + MilitarySymbolToGraphicLayersMaker.ImageFilesHome); } buttonList.Add(this.button11); buttonList.Add(this.button12); buttonList.Add(this.button13); buttonList.Add(this.button14); buttonList.Add(this.button15); buttonList.Add(this.button21); buttonList.Add(this.button22); buttonList.Add(this.button23); buttonList.Add(this.button24); buttonList.Add(this.button25); buttonList.Add(this.button31); buttonList.Add(this.button32); buttonList.Add(this.button33); buttonList.Add(this.button34); buttonList.Add(this.button35); currentSymbol.Id.Affiliation = StandardIdentityAffiliationType.NotSet; currentSymbol.Id.SymbolSet = SymbolSetType.NotSet; SetPaneState(); }
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); }
/// <summary> /// This command line app, just returns types and values that it knows about /// first using reflection (if it is a type) & then by doing a look-up of the SymbolSet /// if its not a type /// </summary> static void Main(string[] args) { string typeToExportUpper = "LIST"; int argLength = args.Length; if (argLength == 0) { // TODO: if you just want to wire in a quick test uncomment: // MyAdHocTest(); // return; // Help: Console.WriteLine("Usage: TestTableExporter [Type -or- \"List\" -or- \"ALL\"]"); Console.WriteLine(" TestTableExporter [SymbolSet (Name or Code)]"); } else { typeToExportUpper = args[0].ToUpper(); if (!FORMAT_IS_STYLE_CSV) { Console.WriteLine("Looking for Type: " + typeToExportUpper); } } bool found = false; if (!FORMAT_IS_STYLE_CSV) // don't do for Style Export { Assembly myAssembly = Assembly.GetAssembly(typeof(SymbolIdCode)); foreach (Type type in myAssembly.GetTypes()) { if (!type.IsEnum) { continue; } string typeName = type.Name; string typeNameUpper = typeName.ToUpper(); if (typeToExportUpper == "LIST") { Console.WriteLine("Type: " + typeName); found = true; } if (typeToExportUpper.Equals("ALL") || typeNameUpper.Contains(typeToExportUpper)) { Console.WriteLine(Environment.NewLine + "Found Type: " + typeNameUpper); found = true; List <Enum> enums = TypeUtilities.EnumHelper.getEnumValues(type); foreach (Enum en in enums) { string enumString = en.ToString(); int hashCode = en.GetHashCode(); Console.WriteLine(enumString + "," + hashCode); } } // end if } // end foreach // if found, we are done, if not check for a symbol set query if (found && (!typeToExportUpper.Equals("ALL"))) { return; } } string symbolSetUpper = typeToExportUpper; if (!FORMAT_IS_STYLE_CSV) { Console.WriteLine("Type not found, looking for SymbolSet: " + symbolSetUpper); } SymbolLookup symbolLookup = new SymbolLookup(); symbolLookup.Initialize(); if (!symbolLookup.Initialized) // should not happen, but you never know { System.Diagnostics.Trace.WriteLine("Failed to initialize symbol list, exiting..."); return; } SymbolSetType symbolSet = SymbolSetType.NotSet; // find the symbol set selected List <Enum> symbolSetEnums = TypeUtilities.EnumHelper.getEnumValues(typeof(SymbolSetType)); foreach (Enum en in symbolSetEnums) { string enumStringUpper = en.ToString().ToUpper(); int hashCode = en.GetHashCode(); string hashCodeString = Convert.ToString(hashCode); if (hashCodeString.Length < 2) { hashCodeString = hashCodeString.PadLeft(2, '0'); } // Mildly confusing but allow either the name or the Number if (symbolSetUpper.Equals("ALL") || enumStringUpper.Contains(symbolSetUpper) || hashCodeString.Equals(symbolSetUpper)) { symbolSet = (SymbolSetType)en; if (FORMAT_IS_STYLE_CSV) { ListSymbolSetAsStyleCsv(symbolLookup, symbolSet); } else { ListSymbolSetSimple(symbolLookup, symbolSet); } } } if (symbolSet == SymbolSetType.NotSet) { Console.WriteLine("Warning: SymbolSet not found: " + symbolSetUpper); } }