コード例 #1
0
        public CentralIconType GetEntityIconTypeFromCode(SymbolSetType symbolSet, string entityCode)
        {
            Initialize();

            if ((EntityTable == null) || (symbolSet == SymbolSetType.NotSet) ||
                (entityCode == "000000") || entityCode.Length != 6)
            {
                return(CentralIconType.NotSet);
            }

            string entityCodeToSearch = entityCode;

            if (symbolSet == SymbolSetType.Land_Unit)
            {
                // See SymbolIdCode.IsLandUnitSpecialEntity for explanation of this exceptional case
                string entitySubType = entityCode.Substring(4, 2);
                if (TypeUtilities.EntitySubtypeCodeToLandUnitSpecialEntityName.Keys.Contains(entitySubType))
                {
                    entityCodeToSearch = entityCode.Substring(0, 4) + "00";
                }
            }

            string symbolSetToSearch = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2);

            var results = from row in EntityTable.AsEnumerable()
                          where ((row.Field <string>("SymbolSet") == symbolSetToSearch)
                                 & (row.Field <string>("Code") == entityCodeToSearch))
                          select row;

            int resultCount = results.Count();

            if (resultCount < 1)
            {
                System.Diagnostics.Trace.WriteLine("Entity Code not found: " + entityCode);
                return(CentralIconType.NotSet);
            }

            CentralIconType iconFormat = CentralIconType.NotSet;

            foreach (DataRow row in results)
            {
                string centralIconTypeString = row["IconType"] as string;
                iconFormat = (CentralIconType)TypeUtilities.EnumHelper.getEnumFromString(typeof(CentralIconType), centralIconTypeString);
                break;
            }

            return(iconFormat);
        }
コード例 #2
0
        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);
                }
            }
        }