C#中绘制文字两套代码

来源:互联网 发布:知乎 金庸哪个最好 编辑:程序博客网 时间:2024/05/18 22:13
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace picture5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Graphics formGraphics = this.CreateGraphics();
           // string drawString = "Sample TexT";
            //string drawString = "您好!";
            //System.Drawing.*/Font drawFont = new Font("Arial",120);
           //System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System .Drawing .Color .Black );
            //formGraphics.DrawString(drawString ,drawFont ,drawBrush ,x ,y );
            //drawFont.Dispose(); drawBrush.Dispose (); formGraphics.Dispose();
            float x = 50.0f, y = 50.0f;           
            Font myFont = new Font("Times New Roman",120);
            SolidBrush myBrush = new SolidBrush(Color .Red  );
            formGraphics.DrawString("您好!",myFont,myBrush ,x ,y );
        }
    }
}
0 0
原创粉丝点击