| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 796 人关注过本帖
标题:!~~~!C#画图程序出现问题!~~~!
只看楼主 加入收藏
68948436
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-11-25
收藏
 问题点数:0 回复次数:1 
!~~~!C#画图程序出现问题!~~~!
//画笔参数
        Pen pen = new Pen(Color.Black, 1);
        Color color = Color.Black;
        float width;
        //直线参数
        Point startpoint;
        Point currentpoint;
        bool mousedown = false;
        //画图
        GraphicsPath gPath = new GraphicsPath();
        Graphics gs;
        Bitmap bitmap;
        private void Form1_Load(object sender, EventArgs e)
        {
            bitmap = new Bitmap(SystemInformation.PrimaryMonitorMaximizedWindowSize.Width,SystemInformation.PrimaryMonitorMaximizedWindowSize.Height);
            gs = Graphics.FromImage(bitmap);
            gs.Clear(Color.White);
            gs.Dispose();
        }  
        private void trackBar1_ValueChanged(object sender, EventArgs e)
        {
            width = trackBar1.Value;
        }
        private void colorPickerButton1_SelectedColorChanged(object sender, EventArgs e)
        {
            color = colorPickerButton1.SelectedColor;
        }
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                mousedown = true;
                pen = new Pen(color, width);
                startpoint = new Point(e.X, e.Y);
            }
        }
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (mousedown && e.Button == MouseButtons.Left)
            {
                currentpoint = new Point(e.X, e.Y);
                Graphics gs = panel1.CreateGraphics();
                gs.DrawImage(bitmap, 0, 0);
                gs.DrawLine(pen, startpoint, currentpoint);
                gs.Dispose();
            }
        }
        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            if (mousedown)
            {
                gPath.AddLine(startpoint, currentpoint);
                Graphics gs = Graphics.FromImage(bitmap);
                gs.DrawPath(pen, gPath);
            }
        }
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawImage(bitmap, 0, 0);
        }

画到第三条先,自动连接第一条和第二条直线的;画第四条直线自动连接第二条和第一条直线的!~
希望大侠帮帮忙,看看出了什么问题!

[[italic] 本帖最后由 68948436 于 2007-12-3 18:40 编辑 [/italic]]
搜索更多相关主题的帖子: 画图 
2007-12-03 18:37
x50756011
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-4-11
收藏
得分:0 
你该不会是这个星期要交把。。我就是。。

2007-12-04 23:00
快速回复:!~~~!C#画图程序出现问题!~~~!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017914 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved