Easy implementation of rotation display text

xiaoxiao2021-03-06  107

/ / This program shows how to rotate the text, the code is simple, but the individual feels that it is good to use it! // Author: i.Posei (ipqn) // Welcome to www.kunwsoft.com

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Drawing2D; using System.Drawing.Text;

Namespace eddy {public class form1: system.windows.Forms.form {// The required designer variable. Private system.componentmodel.Container Components = NULL;

Public form1 () {initializationComponent ();

Protected Override Void Dispose (bool disposing) {if (disponents! = null) {components.dispose ();}} Base.Dispose (Disposing);

Private void initializecomponent () {this.autoscalebasesize = new system.drawing.size (6, 14); this.clientsize = new system.drawing.size (520, 520); this.name = "form1"; this.text = "Rotary Display Text"; this.Paint = New System.windows.Forms.PainteventHandler (this.form1_paint);

[STAThread] static void Main () {Application.Run (new Form1 ());} private void Form1_Paint (object sender, System.Windows.Forms.PaintEventArgs e) {// declare and initialize the Graphics object Graphics g = e.Graphics G.smoothingmode = smoothingmode.antialias;

String str = "C # learning note kunwsoft.com"; for (int i = 0; i <360; i = i 10) {G.TranslateTransform (260, 260); // Apply the specified rotation to the G based on the conversion matrix G. RotateTransform (i);

Brush mybrush = brushes.red; font drawfont = new font ("Song", 12); g.drawstring (Str, DrawFont, Mybrush, 60, 0);

g.RsetTransform ();}}}}}

Below is a screenshot of the program runtime:

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

New Post(0)