Пример #1
0
        public static ImageInfo getIcon(String symbolID, int size, Color color, int outlineSize)
        {
            ImageInfo returnVal = null;

            if (_tgl == null)
            {
                _tgl = TacticalGraphicLookup.getInstance();
            }

            int mapping = _tgl.getCharCodeFromSymbol(symbolID);

            CanvasRenderTarget coreBMP = null;

            SVGPath svgTG = null;

            //SVGPath svgFrame = null;

            if (mapping > 0)
            {
                svgTG = TGSVGTable.getInstance().getSVGPath(mapping);
            }

            //float scale = 1;
            Matrix3x2 mScale, mTranslate;
            Matrix3x2 mIdentity = Matrix3x2.Identity;
            Rect      rectF     = new Rect();
            Matrix3x2 m         = svgTG.CreateMatrix(size, size, out rectF, out mScale, out mTranslate);
            //svgTG.TransformToFitDimensions(size, size);
            Rect rr = svgTG.computeBounds(m);

            CanvasDevice device = CanvasDevice.GetSharedDevice();

            //CanvasRenderTarget offscreen = new CanvasRenderTarget(device, width, height, 96);
            coreBMP = new CanvasRenderTarget(device, (int)(rr.Width + 0.5), (int)(rr.Height + 0.5), 96);

            using (CanvasDrawingSession cds = coreBMP.CreateDrawingSession())
            {
                svgTG.Draw(cds, Colors.Transparent, 0, color, m);
                cds.DrawRectangle(coreBMP.GetBounds(device), Colors.Red);
            }
            returnVal = new ImageInfo(coreBMP, new Point(coreBMP.Size.Width / 2f, coreBMP.Size.Height / 2.0f), new Rect(0, 0, coreBMP.Size.Width, coreBMP.Size.Height), coreBMP.GetBounds(device));

            return(returnVal);
        }
Пример #2
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);
            }
        }
Пример #3
0
        public static ImageInfo getIcon(String symbolID, int size, Color color, int outlineSize)
        {
            ImageInfo returnVal = null;

            if (_tgl == null)
            {
                _tgl = TacticalGraphicLookup.getInstance();
            }

            int mapping = _tgl.getCharCodeFromSymbol(symbolID);

            Bitmap coreBMP = null;

            SVGPath svgTG = null;

            //SVGPath svgFrame = null;

            if (mapping > 0)
            {
                svgTG = TGSVGTable.getInstance().getSVGPath(mapping);
            }

            //float scale = 1;

            svgTG.TransformToFitDimensions(size, size);
            RectangleF rr = svgTG.getBounds();

            coreBMP = new Bitmap((int)(rr.Width + 0.5), (int)(rr.Height + 0.5));

            Graphics g = Graphics.FromImage(coreBMP);

            g.SmoothingMode     = SmoothingMode.AntiAlias;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            svgTG.Draw(g, Color.Empty, 0, color, null);

            returnVal = new ImageInfo(coreBMP, new PointF(coreBMP.Width / 2f, coreBMP.Height / 2.0f), new RectangleF(0, 0, coreBMP.Width, coreBMP.Height));

            return(returnVal);
        }