Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 绘制和删除旧图形_C#_.net_Drawing - Fatal编程技术网

C# 绘制和删除旧图形

C# 绘制和删除旧图形,c#,.net,drawing,C#,.net,Drawing,我是这个论坛的新手,我的英语不是很好,所以我想原谅我的问题写得不好 我正在用C做一个绘画程序,除了一个问题,一切都很完美。 当我画直线、矩形或椭圆时,当mouseMove事件被调用时,也会绘制旧的形状 如何使用mouseMove事件绘制形状以及未绘制的旧形状 这是我的代码的一部分,需要进一步澄清 //---Variables declared by the Prgrammer---// //'parent' is variable that take the MdiParent //'mouse

我是这个论坛的新手,我的英语不是很好,所以我想原谅我的问题写得不好

我正在用C做一个绘画程序,除了一个问题,一切都很完美。 当我画直线、矩形或椭圆时,当mouseMove事件被调用时,也会绘制旧的形状

如何使用mouseMove事件绘制形状以及未绘制的旧形状

这是我的代码的一部分,需要进一步澄清

//---Variables declared by the Prgrammer---//
//'parent' is variable that take the MdiParent
//'mouseIsDown' is boolean variable
//'startPoint' and 'endPoint' are Point Varables
//'pen' is Pen variable that is configured eralier
//'graphic' is pictureBox in the same form.

private void pbx_MouseDown(object sender, MouseEventArgs e)
    {
        if (parent.btnLine.Checked)
        {
            mouseIsDown = true;
            startPoint = new Point(e.X, e.Y);
        }
    }

    private void pbx_MouseMove(object sender, MouseEventArgs e)
    {
        if (mouseIsDown == true && parent.btnLine.Checked)
        {
            pen = new Pen(parent.btnPreview.BackColor, 12);
            endPoint = new Point(e.X, e.Y);
            graphic.DrawLine(pen, startPoint, endPoint);
        }
    }

    private void pbx_MouseUp(object sender, MouseEventArgs e)
    {
        mouseIsDown = false;
    }
请帮帮我。这对我来说是个大问题。 谢谢

请帮帮我,我等了两天。 当我为图形对象绘制新图形时,旧图形将被删除

我尝试了图形保存方法,但没有给出正确的结果


当我制作另一个图形时,如何使图形稳定?

当您使用picturebox时,可以使用方法。

无效功能不会给我想要的结果,因为在鼠标移动时图形不可见。但使用刷新方法,图形是可见的。问题是现在当我开始画一幅新画的时候。旧的将被删除。。谢谢你的帮助。