private void cbFontSize_SelectedValueChanged(object sender, EventArgs e) { //TODO: est font size SinglePointRenderer spr = SinglePointRenderer.getInstance(); //spr. }
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); } }
private void Form1_MouseClick(object sender, MouseEventArgs e) { try { if (symbolID != null) { SinglePointRenderer spr = SinglePointRenderer.getInstance(); Dictionary <int, String> attribs = new Dictionary <int, string>(); Dictionary <int, String> modifiers = new Dictionary <int, string>(); attribs.Add(MilStdAttributes.PixelSize, cbSize.Text); // attribs.Add(MilStdAttributes.SymbolOutlineSize, "0"); //attribs.Add(MilStdAttributes.SymbolOutlineColor, "FF0000"); //attribs.Add(MilStdAttributes.SymbolOutlineSize, "2"); if (cbDrawModifiers.Checked == true) { if (symbolID[0] != 'G') { populateModifiersForUnits(modifiers); } else { populateModifiersForTGs(modifiers); } } ImageInfo ii = spr.RenderSymbol(symbolID, modifiers, attribs); Graphics g = this.CreateGraphics(); Point offset = ii.getCenterPoint(); g.DrawImageUnscaled(ii.getBitmap(), e.X - offset.X, e.Y - offset.Y); //bmp.getBitmap().Save("C:\\iconC.png", ImageFormat.Png); symbolID = null; //TEXT test render, TextRenderer much faster /* * Font font = new Font("arial", 24); * String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; * * Color[] colors = {Color.Black,Color.Magenta}; * Brush[] brushes = {Brushes.Black,Brushes.Magenta}; * * Stopwatch stopwatch = Stopwatch.StartNew(); * for (int i = 0; i < 10000; i++ ) * g.DrawString(alpha, font, brushes[i%2], 200, 300); * stopwatch.Stop(); * * Stopwatch stopwatch2 = Stopwatch.StartNew(); * for (int j = 0; j < 10000; j++) * TextRenderer.DrawText(g, alpha, font, new Point(200, 340), colors[j % 2]); * stopwatch2.Stop(); * * * Console.WriteLine(stopwatch.ElapsedMilliseconds); * Console.WriteLine(stopwatch2.ElapsedMilliseconds);//*/ //text orientation test /*Font font = new Font("arial", 24); * TextFormatFlags tff = TextFormatFlags.Top; * TextRenderer.DrawText(g, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", font, new Point(200, 340), Color.Black,tff); * Size fb = TextRenderer.MeasureText(g, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",font,new Size(),tff); * g.DrawRectangle(Pens.Red, 200, 340, fb.Width, fb.Height);//*/ } } catch (Exception exc) { ErrorLogger.LogException("SinglePointRenderer", "DrawTest", exc); } }
private void btnSpeedTest_Click(object sender, EventArgs e) { Dictionary <int, String> modifiersTG = new Dictionary <int, string>(); Dictionary <int, String> modifiersU = new Dictionary <int, string>(); Dictionary <int, String> attributes = new Dictionary <int, string>(); String feCode = getCodeFromFEList(); String tgCode = getCodeFromTGList(); int numberToMake = Convert.ToInt32(tbSpeedTestCount.Text); int x = 0; int y = 0; int height = this.Height; int width = this.Width; List <ImageInfo> BMPs = new List <ImageInfo>(); SinglePointRenderer spr = SinglePointRenderer.getInstance(); Stopwatch sw = Stopwatch.StartNew(); attributes.Add(MilStdAttributes.PixelSize, this.cbSize.Text); if (cbDrawModifiers.Checked == true) { populateModifiersForUnits(modifiersU); populateModifiersForTGs(modifiersTG); } for (int i = 0; i < numberToMake; i++) { if (cbSpeedTestType.SelectedItem.ToString() == ("Mixed")) { if ((i % 2) == 0) { BMPs.Add(spr.RenderSymbol(feCode, modifiersU, attributes)); } else { BMPs.Add(spr.RenderSymbol(tgCode, modifiersTG, attributes)); } } else if (cbSpeedTestType.SelectedItem.ToString() == ("Units")) { BMPs.Add(spr.RenderSymbol(feCode, modifiersU, attributes)); } else//"Tactical" { BMPs.Add(spr.RenderSymbol(tgCode, modifiersTG, attributes)); } } String generateTime = "Seconds to Generate: " + Convert.ToString(sw.ElapsedMilliseconds / 1000.0); Console.WriteLine(generateTime); Graphics g = Graphics.FromHwnd(this.Handle); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; if (cbDoubleBuffer.CheckState != CheckState.Checked) { sw.Restart(); for (int j = 0; j < numberToMake; j++) { g.DrawImageUnscaled(BMPs[j].getBitmap(), x, y); x += 50; if (x > width) { x = 0; y += 50; } if (y > height) { y = 0; } } sw.Stop(); } else { Bitmap buffer = new Bitmap(width, height); Graphics bg = Graphics.FromImage(buffer); bg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; sw.Restart(); for (int j = 0; j < numberToMake; j++) { bg.DrawImageUnscaled(BMPs[j].getBitmap(), x, y); x += 50; if (x > width) { x = 0; y += 50; } if (y > height) { y = 0; } } g.DrawImageUnscaled(buffer, 0, 0); sw.Stop(); bg.Dispose(); bg = null; } String renderTime = "Seconds to Render: " + Convert.ToString(sw.ElapsedMilliseconds / 1000.0); Console.WriteLine(renderTime); g.Dispose(); g = null; textBox1.Text = generateTime; }