public static bool ExportSymbol(SymbolIdCode code, out System.Drawing.Bitmap exportBitmap,
                                        System.Drawing.Size size)
        {
            if (!code.IsValid)
            {
                exportBitmap = null;
                return(false);
            }

            SvgSymbol svgSymbol = new SvgSymbol();

            SvgSymbol.ImageSize = size;

            MilitarySymbol milSymbol = new MilitarySymbol();

            milSymbol.Id = code;

            MilitarySymbolToGraphicLayersMaker.SetMilitarySymbolGraphicLayers(ref milSymbol);

            exportBitmap = SvgSymbol.GetBitmap(milSymbol.GraphicLayers);

            return(exportBitmap != null);
        }
        public static bool ConvertCodeCharlieToDelta(string code2525Charlie,
                                                     out SymbolIdCode code2525Delta)
        {
            code2525Delta = SymbolIdCode.DefaultSymbolIdCode;

            if (code2525Charlie.Length < 10)
            {
                return(false);
            }

            string code2525CharlieUpper = code2525Charlie.ToUpper();

            SymbolLookup codeLookup = GetSymbolLookup();

            string symbolSetString, entityString, mod1String, mod2String;

            bool success = codeLookup.GetDeltaCodeFromCharlie(code2525CharlieUpper, out symbolSetString,
                                                              out entityString, out mod1String, out mod2String);

            if (!success || string.IsNullOrEmpty(symbolSetString) || string.IsNullOrEmpty(entityString) ||
                entityString.Length != 6)
            {
                return(false);
            }

            // TRICKY/WORKAROUND: to ones with "TABLE D-V. Land unit icons–special entity subtypes"
            if (entityString.EndsWith("95") || entityString.EndsWith("96") ||
                entityString.EndsWith("97") || entityString.EndsWith("98"))
            {
                entityString = entityString.Substring(0, 4) + "00";

                // TODO: test/implement this in MilitarySymbol + drawing to see if we can get it to show up
            }

            code2525Delta.SymbolSet = (SymbolSetType)
                                      TypeUtilities.EnumHelper.getEnumFromHashCodeString(typeof(SymbolSetType), symbolSetString);
            code2525Delta.EntityCode = entityString;
            if (!string.IsNullOrEmpty(mod1String))
            {
                code2525Delta.ModifierOne = mod1String;
            }
            if (!string.IsNullOrEmpty(mod2String))
            {
                code2525Delta.ModifierTwo = mod2String;
            }

            char affilChar = code2525CharlieUpper[1];

            foreach (KeyValuePair <StandardIdentityAffiliationType, char> kvp in TypeUtilities.AffiliationToCharlieChar)
            {
                if (kvp.Value == affilChar)
                {
                    code2525Delta.Affiliation = kvp.Key;
                    break;
                }
            }

            char planningChar = code2525CharlieUpper[3];

            if (!TypeUtilities.IsWeather(code2525Delta.SymbolSet))
            {
                foreach (KeyValuePair <StatusType, char> kvp in TypeUtilities.StatusToCharlieChar)
                {
                    if (kvp.Value == planningChar)
                    {
                        code2525Delta.Status = kvp.Key;
                        break;
                    }
                }
            } // ! IsWeather

            if (code2525Charlie.Length < 12) // allow codes to be 10 or 15, but don't go past here if not > 12
            {
                return(true);
            }

            if (TypeUtilities.HasFrame(code2525Delta.SymbolSet))
            {
                char hqFdTfChar = code2525CharlieUpper[10];
                foreach (KeyValuePair <HeadquartersTaskForceDummyType, char> kvp in TypeUtilities.HqTfFdToCharlieChar)
                {
                    if (kvp.Value == hqFdTfChar)
                    {
                        code2525Delta.HeadquartersTaskForceDummy = kvp.Key;
                        break;
                    }
                }

                char echelonChar = code2525CharlieUpper[11];
                foreach (KeyValuePair <EchelonMobilityType, char> kvp in TypeUtilities.EchelonMobilityToCharlieChar)
                {
                    if (kvp.Value == echelonChar)
                    {
                        code2525Delta.EchelonMobility = kvp.Key;
                        break;
                    }
                }
            } // HasFrame

            return(true);
        }
        /// <summary>
        /// Creates an consistent name from a Symbol ID Code
        /// (not in SymbolIdCode because it needs SymbolLookup)
        /// </summary>
        public static string GetWellFormedName(SymbolIdCode id)
        {
            // Just monitoring how often this is being called for now:
            // System.Diagnostics.Trace.WriteLine("GetWellFormedName");

            SymbolLookup milSymbolLookup = GetSymbolLookup();

            StringBuilder sb            = new StringBuilder();
            string        symbolSetName = TypeUtilities.EnumHelper.getStringFromEnum(id.SymbolSet);

            sb.Append(symbolSetName);

            string entityName        = string.Empty;
            string entityTypeName    = string.Empty;
            string entitySubTypeName = string.Empty;

            bool found = milSymbolLookup.GetEntityNamesFromCode(id.SymbolSet, id.EntityCode,
                                                                out entityName, out entityTypeName, out entitySubTypeName);

            if (!found)
            {
                return(sb.ToString());
            }

            sb.Append(TypeUtilities.NameSeparator);
            sb.Append(entityName);

            if (!string.IsNullOrWhiteSpace(entityTypeName))
            {
                sb.Append(TypeUtilities.NameSeparator);
                sb.Append(entityTypeName);
            }

            if (!string.IsNullOrWhiteSpace(entitySubTypeName))
            {
                sb.Append(TypeUtilities.NameSeparator);
                sb.Append(entitySubTypeName);
            }

            if (id.IsLandUnitSpecialEntity)
            {
                sb.Append(TypeUtilities.NameSeparator);
                sb.Append(TypeUtilities.EntitySubtypeCodeToLandUnitSpecialEntityName[id.EntitySubTypeField]);
            }

            string modifier1Name =
                milSymbolLookup.GetModifierNameFromCode(id.SymbolSet, 1, id.ModifierOne);
            string modifier2Name =
                milSymbolLookup.GetModifierNameFromCode(id.SymbolSet, 2, id.ModifierTwo);

            if (!string.IsNullOrWhiteSpace(modifier1Name))
            {
                sb.Append(TypeUtilities.NameSeparator);
                sb.Append("M1-");
                sb.Append(modifier1Name);
            }

            if (!string.IsNullOrWhiteSpace(modifier2Name))
            {
                sb.Append(TypeUtilities.NameSeparator);
                sb.Append("M2-");
                sb.Append(modifier2Name);
            }

            return(sb.ToString());
        }
        public static bool ConvertCodeDeltaToCharlie(SymbolIdCode code2525Delta,
                                                     out string code2525Charlie)
        {
            // Just monitoring how often this is being called for now:
            System.Diagnostics.Trace.WriteLine("ConvertCodeDeltaToCharlie");

            code2525Charlie = "NOT FOUND";

            SymbolLookup codeLookup = GetSymbolLookup();

            string symbolSetString = TypeUtilities.EnumHelper.getEnumValAsString(
                code2525Delta.SymbolSet, 2);
            string entityString = code2525Delta.EntityCode;
            string mod1String   = code2525Delta.ModifierOne;
            string mod2String   = code2525Delta.ModifierTwo;

            string code2525CharlieFromLookup;

            bool success = codeLookup.GetCharlieCodeFromDelta(symbolSetString,
                                                              entityString, mod1String, mod2String, out code2525CharlieFromLookup);

            if (!success || string.IsNullOrEmpty(code2525CharlieFromLookup) ||
                code2525CharlieFromLookup.Length < 15)
            {
                return(false);
            }

            char charlieAffilationChar = TypeUtilities.AffiliationToCharlieChar[code2525Delta.Affiliation];

            bool isWeather = (code2525CharlieFromLookup[0] == 'W');

            char replaceChar1 = charlieAffilationChar;

            if (isWeather) // Don't replace weather with affiliation
            {
                replaceChar1 = code2525CharlieFromLookup[1];
            }

            StringBuilder sbCharlieCode = new StringBuilder();

            sbCharlieCode.Append(code2525CharlieFromLookup[0]);
            sbCharlieCode.Append(replaceChar1);
            sbCharlieCode.Append(code2525CharlieFromLookup[2]);

            if (isWeather)
            {
                sbCharlieCode.Append(code2525CharlieFromLookup[3]);
            }
            else
            {
                sbCharlieCode.Append(TypeUtilities.StatusToCharlieChar[code2525Delta.Status]);
            }

            sbCharlieCode.Append(code2525CharlieFromLookup.Substring(4, 6));
            sbCharlieCode.Append(TypeUtilities.HqTfFdToCharlieChar[code2525Delta.HeadquartersTaskForceDummy]);
            sbCharlieCode.Append(TypeUtilities.EchelonMobilityToCharlieChar[code2525Delta.EchelonMobility]);
            sbCharlieCode.Append("---");

            code2525Charlie = sbCharlieCode.ToString();

            return(true);
        }