Use C # to draw a mileage table

xiaoxiao2021-03-06  74

Private void form3_paint (object sender, system.windows.Forms.Painteventargs e) {graphics g = this.creategraphics (); Rectangle Rect = this.clientRectactangle;

// Set height and wide int width = Rect.width / 2; int Height = Rect.Height / 2;

g.smoothingmode = smoothingmode.antialias; fontfamily f = new fontfamily ("Song"); Font Font = New Font (f, 14, fontstyle.bold, graphicsunit.pixel);

G.TranslateTransform (Width / 2, Height / 2); // The original point is located in the window center

G.FLLLLLIPSE (New Solidbrush (Color.Black), Height / -2, Height / -2, Height, Height;

g.drawstring ("km / h), new solid.green, new pointf (-26, height / -4-font.getHeight (0.0F) 20);

G.RotateTransform (225); for (int x = 0; x <55; x ) {g.fillRectangle (New SolidRush (Color.green), - 2, (Height / 2-2) * - 1,3,15 ); G.RotateTransform (5);}

g.TranslateTransform (Width / 2, Height / 2); G.RotateTransform (225); int sp = 0; string tmp; for (int x = 0; x <7; x ) {TMP = Sp.Tostring (); g.fillRectangle (New Solidbrush (Color.red), - 3, (Height / 2-2) * - 1, 6, 25); G.drawString (TMP, Font, New Solidbrush (Color). Green, New Pointf (Tmp.Length * -6, (HEIGHT / -2) 25)); G.RotateTransform (45); SP = 20; //g.drawstring (}

g.RsetTransform (); G.TranslateTransform (Width / 2, Height / 2);

Float angle; angle = (float) (30.0 * 2.25) 225; g.RotateTransform (Angle);

Pen P = New Pen (Color.Blue, 14); p.Endcap = linecap.Arrowanchor; p.startcap = linecap.RoundAnchor;

g.drawline (p, new pointf (0), new pointf (0, -1 * (height / 2.75f)));

g.RsetTransform (); G.TranslateTransform (Width / 2, Height / 2);

G.FLLLLLIPSE (New Solidbrush (Color.Black), - 6, -9, 14, 14); G.FLLLLIPSE (New Solidbrush (Color.red), - 7, -7, 14, 14); p.Width = 4.0f; p.color = color.black; p.Endcap = linecap.round; p.startcap = linecap.flat; g.drawline (p, new pointf (height / 15.75f, height / 3.95f), New Pointf HEIGHT / 10.75F, Height / 5.2F));

P.Color = color.red; g.drawline (p, new pointf (height / 15.75f, height / 3.95f), new pointf (height / 15.75f, height / 4.6f)); g.dispose ();}

转载请注明原文地址:https://www.9cbs.com/read-93425.html

New Post(0)