Example #1
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);
            }
        }
Example #2
0
        void CanvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            /*args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3);
             *
             * var format = new CanvasTextFormat();
             *
             * format.FontFamily = "Arial";
             * format.FontSize = 32.0f;
             * format.FontStyle = Windows.UI.Text.FontStyle.Normal;//normal / italic
             * format.FontWeight = Windows.UI.Text.FontWeights.Normal;//normal / bold
             * format.VerticalAlignment = CanvasVerticalAlignment.Top;
             * args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow,format);//*/

            MilStdIconRenderer r   = MilStdIconRenderer.getInstance();
            ImageInfo          foo = null;

            try
            {
                char[] separator = { '|' };
                String symbolID  = null; //"SUPPT----------";
                //String status = "P";
                //String affiliation = "F";
                String size = "100";
                Dictionary <int, String> attributes = new Dictionary <int, String>();
                string keepUnitRatio = "false";
                if (chkbKeepUnitRatio.IsChecked == true)
                {
                    keepUnitRatio = "true";
                }
                if (SymbolUtilities.isNumber(tbSize.Text))
                {
                    size = tbSize.Text;
                }
                if (lbUnitList.SelectedItem != null && drawUnit == true)
                {
                    symbolID = ((String)lbUnitList.SelectedItem).Split(separator)[1];
                    symbolID = SymbolUtilities.setAffiliation(symbolID, (String)cbAffiliation.SelectedItem);
                    symbolID = SymbolUtilities.setStatus(symbolID, (String)cbStatus.SelectedItem);
                    symbolID = symbolID.Substring(0, 10) + Convert.ToString(tbModifier.Text);
                    attributes.Add(MilStdAttributes.PixelSize, size);
                    attributes.Add(MilStdAttributes.KeepUnitRatio, keepUnitRatio);
                    foo = r.Render(symbolID, null, attributes, null);
                }
                if (lbTGList.SelectedItem != null && drawTG == true)
                {
                    symbolID = ((String)lbTGList.SelectedItem).Split(separator)[1];
                    if (SymbolUtilities.isWeather(symbolID) == false)
                    {
                        symbolID = SymbolUtilities.setAffiliation(symbolID, (String)cbAffiliation.SelectedItem);
                        symbolID = SymbolUtilities.setStatus(symbolID, (String)cbStatus.SelectedItem);
                    }
                    attributes.Add(MilStdAttributes.PixelSize, size);
                    attributes.Add(MilStdAttributes.KeepUnitRatio, keepUnitRatio);
                    foo = r.Render(symbolID, null, attributes, null);
                }
                if (foo != null && _pp != null)
                {
                    args.DrawingSession.DrawImage(foo.getCanvasRenderTarget(), (float)(_pp.Position.X - foo.getAnchorPoint().X), (float)(_pp.Position.Y - foo.getAnchorPoint().Y));
                }

                //////SPEEDTEST///////////////////////////////////////////////
                bool speedTest = false;
                if (speedTest && lbUnitList.SelectedItem != null)
                {
                    CanvasDevice cd = CanvasDevice.GetSharedDevice();
                    Stopwatch    sw = new Stopwatch();
                    try
                    {
                        sw.Start();
                        //MilStdBMP fooo = null;
                        for (int i = 0; i < 10000; i++)
                        {
                            r.Render(symbolID, null, attributes, cd);

                            /*fooo = r.Render(symbolID, null, attributes,cd);
                             * fooo.getCanvasRenderTarget().Dispose();
                             * fooo = null;//*/
                        }
                        sw.Stop();
                    }
                    catch (Exception exc)
                    {
                        Debug.WriteLine(exc.Message);
                        Debug.WriteLine(exc.StackTrace);
                    }
                    cd = null;
                    MessageDialog md = new MessageDialog(sw.Elapsed.Seconds.ToString() + "." + sw.Elapsed.Milliseconds);
                    Debug.WriteLine(sw.Elapsed.Seconds.ToString() + "." + sw.Elapsed.Milliseconds);
                }
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
                Debug.WriteLine(exc.StackTrace);
            }
        }