Esempio n. 1
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            try
            {
                //Graphics gg = this.CreateGraphics();
                //gg.GetHdc();
                //gg.DrawLine(new Pen(Color.Red), 0, 0, 900, 900);
                //gg.DrawArc(new Pen(Color.Red), 500, 500, 50, 50, 0, 90);
                //gg.ReleaseHdc();
                Graphics g = this.CreateGraphics();
                SVGRenderer.getInstance().renderSVGPathToGraphics(g);

                String symbolID     = "SFZP------*****";
                String spaceStation = "SFPPT-----*****";
                String ambush       = "GFGPSLA---*****";
                String checkPoint   = "GFGPGPPK--****X";

                UnitDef ud = UnitDefTable.getInstance().getUnitDef(SymbolUtilities.getBasicSymbolID(symbolID));
                Console.WriteLine(ud.getDescription());
                SymbolDef sd = SymbolDefTable.getInstance().getSymbolDef(SymbolUtilities.getBasicSymbolID(ambush), 1);
                Console.WriteLine(sd.getDescription());

                int mapping = SinglePointLookup.getInstance().getCharCodeFromSymbol(checkPoint);
                Console.WriteLine(mapping.ToString());

                UnitFontLookupInfo ufli = UnitFontLookup.getInstance().getLookupInfo(spaceStation);
                Console.WriteLine(ufli.getMapping1(spaceStation).ToString());

                SinglePointRenderer spr = SinglePointRenderer.getInstance();
                //Bitmap tempBMP = spr.DrawTest();
                //tempBMP.Save("C:\\test.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                //MilStdBMP msb = spr.RenderSymbol(spaceStation, null, null);
                //msb.getBitmap().Save("C:\\test.png", System.Drawing.Imaging.ImageFormat.Png);


                //Graphics g = Graphics.FromHwnd(this.Handle);
                //Graphics g = this.CreateGraphics();
                float x = this.Width / 2.0f;
                float y = this.Height / 2.0f;
                //g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;
                //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                //g.DrawImageUnscaled(tempBMP, (int)x, (int)y);
                //g.Flush();
                //g.Dispose();
                // g.DrawImage(spr.DrawTest(), x, y);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                Console.WriteLine(exc.StackTrace);
            }
        }
Esempio n. 2
0
        private void btnDrawTG_Click(object sender, EventArgs e)
        {
            symbolID = getCodeFromTGList();
            SymbolDef sd = SymbolDefTable.getInstance().getSymbolDef(SymbolUtilities.getBasicSymbolID(symbolID), 1);

            if (sd != null && sd.getMinPoints() == 1 && sd.getMaxPoints() == 1 && sd.HasWidth() == false)
            {
                //code is good
            }
            else //symbol is a multipoint and renderer isn't ready for that yet.
            {
                //symbolID = null;
            }
        }
Esempio n. 3
0
        private void Init()
        {
            try
            {
                Debug.Write("MilStdIconRenderer.Init()");
                Stopwatch sw = new Stopwatch();
                sw.Start();
                SymbolDefTable.getInstance();
                Debug.Write("SymbolDefTable Loaded");
                SinglePointLookup.getInstance();
                Debug.Write("SinglePointLookup Loaded");
                SymbolSVGTable.getInstance();
                Debug.Write("SymbolSVGTable Loaded");


                UnitDefTable.getInstance();
                Debug.Write("UnitDefTable Loaded");
                UnitFontLookup.getInstance();
                Debug.Write("UnitFontLookup Loaded");
                UnitSVGTable.getInstance();
                Debug.Write("UnitSVGTable Loaded");

                TacticalGraphicLookup.getInstance();
                Debug.Write("TacticalGraphicLookup Loaded");
                TGSVGTable.getInstance();
                Debug.Write("TGSVGTable Loaded");//*/
                sw.Stop();
                string ExecutionTimeTaken = string.Format("Minutes :{0} Seconds :{1} Mili seconds :{2}", sw.Elapsed.Minutes, sw.Elapsed.Seconds, sw.Elapsed.Milliseconds);
                Debug.WriteLine("Init Time: " + ExecutionTimeTaken);
            }
            catch (InvalidOperationException ioe)
            {
                Debug.Write(ioe.Message);
                Debug.Write(ioe.StackTrace);
            }
            catch (Exception exc)
            {
                Debug.Write(exc.Message);
                Debug.Write(exc.StackTrace);
            }
        }
        public ImageInfo RenderSymbol(String symbolID, Dictionary <int, String> modifiers, Dictionary <int, String> attributes)
        {
            ImageInfo returnVal = null;
            int       symStd    = 0;

            if (SymbolUtilities.isTacticalGraphic(symbolID))
            {
                SymbolDef sd = SymbolDefTable.getInstance().getSymbolDef(SymbolUtilities.getBasicSymbolID(symbolID), symStd);
                if (sd.getMaxPoints() == 1 && sd.HasWidth() == false)
                {
                    returnVal = RenderSPTG(symbolID, modifiers, attributes);
                }
                else
                {
                    returnVal = RenderMPTG(symbolID, modifiers, attributes);
                }
            }
            else
            {
                returnVal = RenderUnit(symbolID, modifiers, attributes);
            }
            return(returnVal);
        }
        public ImageInfo RenderSymbol(String symbolID, Dictionary <int, String> modifiers, Dictionary <int, String> attributes)
        {
            ImageInfo returnVal = null;
            int       symStd    = 1;


            if (SymbolUtilities.isTacticalGraphic(symbolID))
            {
                if (modifiers != null && modifiers[MilStdAttributes.SymbologyStandard] != null)
                {
                    symStd = Convert.ToInt32(modifiers[MilStdAttributes.SymbologyStandard]);
                }
                else
                {
                    if (modifiers == null)
                    {
                        modifiers = new Dictionary <int, String>();
                    }
                    modifiers[MilStdAttributes.SymbologyStandard] = Convert.ToString(RendererSettings.getInstance().getSymbologyStandard());
                }
                SymbolDef sd = SymbolDefTable.getInstance().getSymbolDef(SymbolUtilities.getBasicSymbolIDStrict(symbolID), symStd);
                if (sd.getMaxPoints() == 1 && sd.HasWidth() == false)
                {
                    returnVal = RenderSPTG(symbolID, modifiers, attributes);
                }
                else
                {
                    returnVal = RenderMPTG(symbolID, modifiers, attributes);
                }
            }
            else
            {
                returnVal = RenderUnit(symbolID, modifiers, attributes, null);
            }
            return(returnVal);
        }
Esempio n. 6
0
        public ImageInfo Render(String symbolID, Dictionary <int, String> modifiers, Dictionary <int, String> attributes, CanvasDevice device)
        {
            SinglePointRenderer spr = SinglePointRenderer.getInstance();

            int symStd = 1;

            if (modifiers != null && modifiers[MilStdAttributes.SymbologyStandard] != null)
            {
                symStd = Convert.ToInt32(modifiers[MilStdAttributes.SymbologyStandard]);
            }
            else
            {
                if (modifiers == null)
                {
                    modifiers = new Dictionary <int, String>();
                }
                modifiers[MilStdAttributes.SymbologyStandard] = Convert.ToString(RendererSettings.getInstance().getSymbologyStandard());
            }

            var basicID = SymbolUtilities.getBasicSymbolIDStrict(symbolID);

            if (SymbolUtilities.isTacticalGraphic(symbolID))
            {
                SymbolDef sd = SymbolDefTable.getInstance().getSymbolDef(basicID, symStd);
                if (sd == null)
                {
                    sd = SymbolDefTable.getInstance().getSymbolDef(basicID, symStd);
                }

                if (sd != null && sd.getDrawCategory() == SymbolDef.DRAW_CATEGORY_POINT)
                {
                    return(spr.RenderSPTG(symbolID, modifiers, attributes));
                }
                else
                {
                    Color color = RenderUtilities.DrawingColorToUIColor(SymbolUtilities.getLineColorOfAffiliation(symbolID));
                    int   size  = 35;
                    if (attributes.ContainsKey(MilStdAttributes.PixelSize))
                    {
                        size = int.Parse(attributes[MilStdAttributes.PixelSize]);
                    }

                    if (modifiers.ContainsKey(MilStdAttributes.LineColor))
                    {
                        color = RenderUtilities.getColorFromHexString(modifiers[MilStdAttributes.LineColor]);
                    }
                    if (modifiers.ContainsKey(MilStdAttributes.PixelSize))
                    {
                        size = int.Parse(modifiers[MilStdAttributes.PixelSize]);
                    }
                    return(TacticalGraphicIconRenderer.getIcon(symbolID, size, color, 0));
                }
            }
            else if (UnitFontLookup.getInstance().getLookupInfo(basicID) != null)
            {
                return(spr.RenderUnit(symbolID, modifiers, attributes, device));
            }
            else
            {
                //symbolID = SymbolUtilities.reconcileSymbolID(symbolID, false);
                return(spr.RenderUnit(symbolID, modifiers, attributes, null));
            }
        }
Esempio n. 7
0
        /**
         *
         * */
        private void Init()
        {
            try
            {
                SymbolDefTable sdTable = SymbolDefTable.getInstance();

                Dictionary <String, SymbolDef> symbolDefs = sdTable.getAllSymbolDefs();

                ICollection <SymbolDef> vc = symbolDefs.Values;

                IEnumerator <SymbolDef> enumerator = vc.GetEnumerator();
                SymbolDef sdTemp = null;
                UnitDef   udTemp = null;
                String    item   = null;
                while (enumerator.MoveNext())
                {
                    sdTemp = enumerator.Current;
                    item   = sdTemp.getDescription() + ":" + sdTemp.getBasicSymbolId();

                    if (sdTemp.getDrawCategory() != 0)//0 means category, not drawable
                    {
                        lbTGs.Items.Add(item);
                    }
                }
                lbTGs.Sorted = true;

                ////////////////////////////////////////////////////////////////////////

                UnitDefTable udTable = UnitDefTable.getInstance();

                Dictionary <String, UnitDef> unitDefs = udTable.GetAllUnitDefs();

                ICollection <UnitDef> c = unitDefs.Values;

                IEnumerator <UnitDef> ude = c.GetEnumerator();
                //SymbolDef temp = null;
                //String item = null;
                while (ude.MoveNext())
                {
                    udTemp = ude.Current;
                    item   = udTemp.getDescription() + ":" + udTemp.getBasicSymbolId();
                    lbFEs.Items.Add(item);
                }
                lbFEs.Sorted = true;

                /////////////////////////////////////////////////////////////////////////
                cbAffiliation.SelectedIndex   = 0;
                cbStatus.SelectedIndex        = 1;
                cbModifiers.SelectedIndex     = 0;
                cbSize.SelectedIndex          = 0;
                cbOutlineType.SelectedIndex   = 0;
                cbSpeedTestType.SelectedIndex = 1;
                cbDoubleBuffer.CheckState     = CheckState.Checked;

                //RENDERER SETTINGS//////////////////////////////////////////////////////
                RendererSettings RS = RendererSettings.getInstance();
                RS.setTextBackgroundMethod(RendererSettings.TextBackgroundMethod_OUTLINE_QUICK);
                //RS.setTextBackgroundMethod(RendererSettings.TextBackgroundMethod_OUTLINE);
                //RS.setTextBackgroundMethod(RendererSettings.TextBackgroundMethod_NONE);
                //RS.setTextBackgroundMethod(RendererSettings.TextBackgroundMethod_COLORFILL);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                Console.WriteLine(exc.StackTrace);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Setup test page controls
        /// </summary>
        private void init()
        {
            try
            {
                //First get instance call initialized the renderer and its required classes.
                MilStdIconRenderer.getInstance();
                //initialize controls

                //Populate TG list
                System.Collections.Generic.List <SymbolDef> symbolDefs = SymbolDefTable.getInstance().getAllSymbolDefs().Values.ToList();
                symbolDefs.Sort();
                foreach (SymbolDef sd in symbolDefs)
                {
                    String itemTG = sd.getDescription() + "|" + sd.getBasicSymbolId();
                    if (sd.getDrawCategory() != 0 && sd.getBasicSymbolId().Contains("BS_") == false)
                    {
                        lbTGList.Items.Add(itemTG);
                    }
                }

                //Populate Unit List
                System.Collections.Generic.List <UnitDef> unitDefs = UnitDefTable.getInstance().GetAllUnitDefs().Values.ToList();
                unitDefs.Sort();
                foreach (UnitDef ud in unitDefs)
                {
                    String itemUnit = ud.getDescription() + "|" + ud.getBasicSymbolId();
                    if (ud.getDrawCategory() != 0)
                    {
                        lbUnitList.Items.Add(itemUnit);
                    }
                }

                //setup affiliations
                cbAffiliation.Items.Add("P");
                cbAffiliation.Items.Add("U"); //Unknown
                cbAffiliation.Items.Add("F"); //Friend
                cbAffiliation.Items.Add("N"); //NEutral
                cbAffiliation.Items.Add("H"); //Hostile
                cbAffiliation.Items.Add("A");
                cbAffiliation.Items.Add("S");
                cbAffiliation.Items.Add("G");
                cbAffiliation.Items.Add("W");
                cbAffiliation.Items.Add("D");
                cbAffiliation.Items.Add("L");
                cbAffiliation.Items.Add("M");
                cbAffiliation.Items.Add("J"); //Joker
                cbAffiliation.Items.Add("K"); //Faker
                cbAffiliation.SelectedIndex = 2;

                //setup status
                cbStatus.Items.Add("A"); //anticipated/planned
                cbStatus.Items.Add("P"); //present
                cbStatus.Items.Add("C"); //present/fully capable
                cbStatus.Items.Add("D"); //present/damaged
                cbStatus.Items.Add("X"); //present/destroyed
                cbStatus.Items.Add("F"); //present/full to capacity
                cbStatus.SelectedIndex = 1;

                chkbKeepUnitRatio.IsChecked = true;
                chkbLabels.IsChecked        = false;
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
                Debug.WriteLine(exc.StackTrace);
                Debug.WriteLine(exc.Source);
            }
        }