c#窗口构造 和绘图

来源:互联网 发布:dz论坛发帖软件 编辑:程序博客网 时间:2024/05/06 15:23

//设置窗口属性(可在设计器属性中设置)< xmlnamespace prefix ="o" ns ="urn:schemas-microsoft-com:office:office" />

        //窗口构造函数

        public TricolorForm()

        {

            InitializeComponent();

//设置窗口属性代码

        }

窗体重绘OnPaint事件

protected override void OnPaint(PaintEventArgs e)

        {

            //调用基类的OnPaint方法

            base.OnPaint(e);

            //获取Graphics对象

Graphics g = e.Graphics;

(在窗体中绘制,若要在现成的图像中绘制,则用:

//创建图像

            Image image = Image.FromFile(fileName);

            //创建Graphics对象

Graphics g = Graphics.FromImage(image);

)

//其他绘图代码

        }

原创粉丝点击