标题:绘图有错请高手教教谢谢
只看楼主
xp白马飞马
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2011-8-7
 问题点数:0 回复次数:1 
绘图有错请高手教教谢谢
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MouseToDraw
{
    public partial class Frm_Main : Form
    {
        public Frm_Main()
        {
            InitializeComponent();
            pen = new Pen(Color.FromName("black"));//始末画笔
            graphics = CreateGraphics();//初始画板
        }

        public bool G_OnMouseDown = false;//标识,用来控制画图
        public Point lastPoint = Point.Empty;//定义绘图开始点
        public Pen pen;//声明画笔
        public Graphics graphics;//声明绘图对象


        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (lastPoint.Equals(Point.Empty))//判断绘图开始点是否为空
            {
                lastPoint = new Point(e.X, e.Y);//记录鼠标当前位置
            }
            if (G_OnMouseDown)//开始绘图
            {
                Point cruuPoint = new Point(e.X, e.Y);//获取鼠标当前位置
                graphics.DrawLine(pen, cruuPoint, lastPoint);//绘图
            }
            lastPoint = new Point(e.X, e.Y);//记录鼠标当前位置
        }
        //当鼠标离开时把布尔变量设为false;
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            G_OnMouseDown = false;//开始绘图标识设置为false
        }

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            G_OnMouseDown = true;//开始绘图标识设置为true
        }
    }
}
搜索更多相关主题的帖子: 标识 public false black class 
2011-08-09 01:00
guang
Rank: 4
来 自:广东深圳
等 级:贵宾
威 望:13
帖 子:1414
专家分:285
注 册:2006-4-3
得分:0 
又没说什么错,叫别人怎么帮你

不相信未作牺牲竟先可拥有,只相信靠双手找到我的欲求!!
我的博客:http://liao5930.blog.
2011-08-09 11:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-347110-1-1.html




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

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