Пример #1
0
        private static void PrintModifierSimple(SymbolSetType symbolSet, int modifierNumber, int modifierCode, string modifierName)
        {
            string symbolSetString = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2);

            string sModifierCode = modifierCode.ToString();

            // this one has to be 2 chars:
            if (sModifierCode.Length < 2)
            {
                sModifierCode = sModifierCode.PadLeft(2, '0');
            }

            string fullModifierName = symbolSet.ToString() + TypeUtilities.NameSeparator +
                                      "Modifier " + modifierNumber.ToString() + TypeUtilities.NameSeparator +
                                      modifierName;

            string modifierIconName = MilitarySymbolToGraphicLayersMaker.GetModfierIconName(
                symbolSet, modifierNumber, modifierCode);

            string modifierIconNameWithFolder = MilitarySymbolToGraphicLayersMaker.GetModfierIconNameWithFolder(
                symbolSet, modifierNumber, modifierCode);

            string nameAsTags = fullModifierName.Replace(TypeUtilities.NameSeparator, ";");

            string tags = nameAsTags + ";" + modifierIconNameWithFolder + ";" +
                          fullModifierName + ";" + modifierIconName;

            Console.WriteLine(modifierCode + "," + symbolSet + "," + symbolSetString
                              + "," + modifierNumber.ToString() + "," + sModifierCode
                              + "," + modifierIconNameWithFolder
                              + "," + fullModifierName
                              + "," + modifierIconName
                              + "," + tags);
        }
        private void updatePictureBox()
        {
            if (!currentSymbol.Id.IsValid)
            {
                return;
            }

            MilitarySymbolToGraphicLayersMaker.SetMilitarySymbolGraphicLayers(ref currentSymbol);

            // Debug in case drawing layers crazed:
            // System.Diagnostics.Trace.WriteLine("MilitarySymbol State After SetMilitarySymbolGraphicLayers : ");
            // System.Diagnostics.Trace.WriteLine(this.currentSymbol);

            if (currentSymbol.GraphicLayers.Count == 0)
            {
                System.Diagnostics.Trace.WriteLine("WARNING: No Graphic Layers to Draw");
                return;
            }

            SvgSymbol.ImageSize = new Size(pbPreview.Width, pbPreview.Height);
            pbPreview.Image     = SvgSymbol.GetBitmap(currentSymbol.GraphicLayers);

            // Set the Combo Box with the layers
            cbLayers.Items.Clear();
            int layerNumber = 0;

            foreach (string graphicLayer in currentSymbol.GraphicLayers)
            {
                layerNumber++;
                string simpleLayer = layerNumber.ToString() + ":" +
                                     graphicLayer.Replace(MilitarySymbolToGraphicLayersMaker.ImageFilesHome,
                                                          " ");

                if (!System.IO.File.Exists(graphicLayer))
                {
                    simpleLayer = "[MISSING]:" + simpleLayer;
                }

                cbLayers.Items.Add(simpleLayer);
            }
            cbLayers.SelectedIndex = 0;
        }
Пример #3
0
        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);
        }
Пример #4
0
        private static void ListSymbolSetSimple(SymbolLookup symbolLookup, SymbolSetType symbolSet)
        {
            string symbolSetString = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2);

            Console.WriteLine(Environment.NewLine + "SymbolSet: " + symbolSet + " : " + symbolSetString);

            Console.WriteLine("Entities:");

            List <MilitarySymbol> matchingSymbols = symbolLookup.GetMilitarySymbols(symbolSet);

            int matchCount = 0;

            foreach (MilitarySymbol matchSymbol in matchingSymbols)
            {
                matchCount++;

                // Copying so making ref below useless, but had to do this because of use of iterator/ref
                MilitarySymbol currentMilSymbol = matchSymbol;
                string         svgTag           = MilitarySymbolToGraphicLayersMaker.GetMainIconNameWithFolder(ref currentMilSymbol);
                string         idTag            = MilitarySymbolToGraphicLayersMaker.GetMainIconName(ref currentMilSymbol);

                string nameAsTags = matchSymbol.Id.Name.Replace(TypeUtilities.NameSeparator, ";");

                Console.WriteLine(matchCount + "," + symbolSet + "," + symbolSetString
                                  + "," + matchSymbol.Id.Name + ","
//                    + matchSymbol.Id.CodeFirstTen + "," + matchSymbol.Id.CodeSecondTen + ","
                                  + nameAsTags + ";"
                                  + matchSymbol.TagsAsString + svgTag + ";"
                                  + matchSymbol.Id.Name + ";"
                                  + idTag

                                  + "," + svgTag);
            }

            List <string> matchingModifiers = symbolLookup.GetDistinctModifierNames(symbolSet, 1);

            if (matchingModifiers.Count > 0)
            {
                Console.WriteLine(Environment.NewLine + "Modifier 1:");

                matchCount = 0;
                foreach (string match in matchingModifiers)
                {
                    PrintModifierSimple(symbolSet, 1, matchCount, match);
                    matchCount++;
                }
            }

            matchingModifiers = symbolLookup.GetDistinctModifierNames(symbolSet, 2);
            if (matchingModifiers.Count > 0)
            {
                Console.WriteLine(Environment.NewLine + "Modifier 2:");

                matchCount = 0;
                foreach (string match in matchingModifiers)
                {
                    PrintModifierSimple(symbolSet, 2, matchCount, match);

                    matchCount++;
                }
            }
        }
Пример #5
0
        private static void ListSymbolSetAsStyleCsv(SymbolLookup symbolLookup, SymbolSetType symbolSet)
        {
            MilitarySymbolToGraphicLayersMaker.ImageFilesHome = IMAGES_HOME;

            string symbolSetString = TypeUtilities.EnumHelper.getEnumValAsString(symbolSet, 2);
            string symbolSetName   = symbolSet.ToString().Replace('_', ' ');

            //Console.WriteLine(Environment.NewLine + "SymbolSet : " + symbolSetName + " : " + symbolSetString);
            //Console.WriteLine(symbolSetName + " : Entities :");

            // filePath, pointSize, styleItemName, styleItemCategory, styleItemTags
            Console.WriteLine("filePath,pointSize,styleItemName,styleItemCategory,styleItemTags,notes");

            List <MilitarySymbol> matchingSymbols = symbolLookup.GetMilitarySymbols(symbolSet);

            StringBuilder sbNotes = new StringBuilder();

            int matchCount = 0;

            foreach (MilitarySymbol matchSymbol in matchingSymbols)
            {
                matchCount++;

                // Copying so making ref below useless, but had to do this because of use of iterator/ref
                MilitarySymbol currentMilSymbol = matchSymbol;

                // IMPORTANT: SKIPPING ALL NON-POINTS CURRENTLY
                if (currentMilSymbol.Shape != ShapeType.Point)
                {
                    System.Diagnostics.Trace.WriteLine("Skipping export of non-point: Name=" + matchSymbol.Id.Name);
                    continue;
                }

                sbNotes.Clear();

                string imageFile = MilitarySymbolToGraphicLayersMaker.GetMainIconNameWithFullPath(ref currentMilSymbol);
                if (IMAGE_FORMAT_IS_EMF)
                {
                    imageFile = imageFile.Replace(".svg", ".emf");
                }

                string svgTag     = MilitarySymbolToGraphicLayersMaker.GetMainIconNameWithFolder(ref currentMilSymbol);
                string idTag      = MilitarySymbolToGraphicLayersMaker.GetMainIconName(ref currentMilSymbol);
                string nameAsTags = matchSymbol.Id.Name.Replace(TypeUtilities.NameSeparator, ";");

                // WORKAROUND: check that files exists & it is not one of the _0,_1,_2,_3,xxxx ones
                if (!System.IO.File.Exists(imageFile))
                {
                    string subIconName = imageFile;
                    subIconName = subIconName.Replace(@".svg", @"_0.svg");
                    if (System.IO.File.Exists(subIconName)) // if the other file exists, use that one
                    {
                        imageFile = subIconName;
                    }
                    else
                    {
                        sbNotes.Append("ImageFile not found: " + svgTag);
                    }
                }

                string styleItemCategory = symbolSetName + TypeUtilities.NameSeparator + "Main Icon";

                string styleItemName = matchSymbol.Id.Name;

                string styleItemTags = nameAsTags + ";" + matchSymbol.TagsAsString + svgTag + ";"
                                       + matchSymbol.Id.Name + ";" + idTag;

                if (styleItemName.Length > MAX_STYLE_LENGTH)
                {
                    sbNotes.Append(" Name > " + MAX_STYLE_LENGTH);
                }
                if (styleItemTags.Length > MAX_STYLE_LENGTH)
                {
                    sbNotes.Append(" Tags > " + MAX_STYLE_LENGTH);
                }

                if (!INCLUDE_NOTES)
                {
                    sbNotes.Clear();
                }

                // filePath, pointSize, styleItemName, styleItemCategory, styleItemTags
                // matchCount + "," +
                Console.WriteLine(imageFile + "," + POINT_SIZE_STRING + "," +
                                  styleItemName + "," + styleItemCategory + "," + styleItemTags + "," + sbNotes.ToString());
            }

            List <string> matchingModifiers = symbolLookup.GetDistinctModifierNames(symbolSet, 1);

            if (matchingModifiers.Count > 0)
            {
                matchCount = 0;
                foreach (string match in matchingModifiers)
                {
                    PrintModifierAsStyleCsv(symbolLookup, symbolSet, 1, matchCount, match);
                    matchCount++;
                }
            }

            matchingModifiers = symbolLookup.GetDistinctModifierNames(symbolSet, 2);
            if (matchingModifiers.Count > 0)
            {
                matchCount = 0;
                foreach (string match in matchingModifiers)
                {
                    PrintModifierAsStyleCsv(symbolLookup, symbolSet, 2, matchCount, match);

                    matchCount++;
                }
            }
        }
Пример #6
0
        private static void PrintModifierAsStyleCsv(SymbolLookup symbolLookup, SymbolSetType symbolSet,
                                                    int modifierNumber, int modifierCode, string modifierName)
        {
            string symbolSetName = symbolSet.ToString().Replace('_', ' ');

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

            string modifierCategory = symbolLookup.GetModifierCategoryFromName(symbolSet,
                                                                               modifierName, modifierNumber);

            string sModifierCode = modifierCode.ToString();

            // this one has to be 2 chars:
            if (sModifierCode.Length < 2)
            {
                sModifierCode = sModifierCode.PadLeft(2, '0');
            }

            string modifierIconName = MilitarySymbolToGraphicLayersMaker.GetModfierIconName(
                symbolSet, modifierNumber, modifierCode);

            string modifierIconNameWithFolder = MilitarySymbolToGraphicLayersMaker.GetModfierIconNameWithFolder(
                symbolSet, modifierNumber, modifierCode);

            StringBuilder sbNotes = new StringBuilder();

            string imageFile = MilitarySymbolToGraphicLayersMaker.GetModfierIconNameWithFullPath(
                symbolSet, modifierNumber, modifierCode);

            if (IMAGE_FORMAT_IS_EMF)
            {
                imageFile = imageFile.Replace(".svg", ".emf");
            }

            // WORKAROUND: check that files exists & it is not one of the _0,_1,_2,_3,xxxx ones
            if (!System.IO.File.Exists(imageFile))
            {
                sbNotes.Append("ImageFile not found: " + modifierIconNameWithFolder);
            }

            string styleItemName = symbolSetName + TypeUtilities.NameSeparator +
                                   "Modifier " + modifierNumber.ToString() + TypeUtilities.NameSeparator +
                                   modifierCategory + TypeUtilities.NameSeparator +
                                   modifierName;

            string nameAsTags = styleItemName.Replace(TypeUtilities.NameSeparator, ";");

            string styleItemTags = nameAsTags + ";" + modifierIconNameWithFolder + ";" +
                                   styleItemName + ";" + modifierIconName;

            string styleItemCategory = symbolSetName + TypeUtilities.NameSeparator + "Modifier " + modifierNumber.ToString();

            if (styleItemName.Length > MAX_STYLE_LENGTH)
            {
                sbNotes.Append(" Name > " + MAX_STYLE_LENGTH);
            }
            if (styleItemTags.Length > MAX_STYLE_LENGTH)
            {
                sbNotes.Append(" Tags > " + MAX_STYLE_LENGTH);
            }

            if (!INCLUDE_NOTES)
            {
                sbNotes.Clear();
            }

            // filePath, pointSize, styleItemName, styleItemCategory, styleItemTags
            // modifierCode + "," +
            Console.WriteLine(imageFile + "," + POINT_SIZE_STRING + "," +
                              styleItemName + "," + styleItemCategory + "," + styleItemTags + "," + sbNotes.ToString());
        }