有关ControlPaint.DrawReversibleFrame的问题 [英] A question about ControlPaint.DrawReversibleFrame

查看:310
本文介绍了有关ControlPaint.DrawReversibleFrame的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我是学生,现在被ControlPaint.DrawReversibleFrame方法阻止

Hello to all
i am student now blocked by ControlPaint.DrawReversibleFrame method

private void Form1_MouseMove(object sender,
    System.Windows.Forms.MouseEventArgs e)
{

    // If the mouse is being dragged,
    // undraw and redraw the rectangle as the mouse moves.
    if (isDrag)

        // Hide the previous rectangle by calling the
        // DrawReversibleFrame method with the same parameters.
    {
        ControlPaint.DrawReversibleFrame(theRectangle,
            this.BackColor, FrameStyle.Dashed);

        // Calculate the endpoint and dimensions for the new
        // rectangle, again using the PointToScreen method.
        Point endPoint = ((Control) sender).PointToScreen(new Point(e.X, e.Y));

        int width = endPoint.X-startPoint.X;
        int height = endPoint.Y-startPoint.Y;
        theRectangle = new Rectangle(startPoint.X,
            startPoint.Y, width, height);

        // Draw the new rectangle by calling DrawReversibleFrame
        // again.
        ControlPaint.DrawReversibleFrame(theRectangle,
            this.BackColor, FrameStyle.Dashed);
    }
}



我不明白为什么以前的DrawReversibleFrame用于隐藏前一个矩形,以及为什么后者的DrawReversibleFrame可以绘制新的矩形.
轮流隐藏或绘制矩形吗?



i don''t understand why the former DrawReversibleFrame is used to hide the previous rectangle.and why the latter DrawReversibleFrame can Draw the new rectangle.
does it take turns to hide or draw a rectangle?

thanks in advance!

推荐答案

因为它是可逆框架:绘制一次后,它出现,再次绘制时,它消失.如果您不再次绘制它,它将保留在那里直到控件失效.

如果您考虑异或(XOR)运算:

Because it is a Reversible Frame: When you draw it once, it appears, when you draw it again, it disappears. If you didn''t draw it again, it would remain there until the control is invalidated.

If you think about Exclusive OR (XOR) operation:

0x23 XOR 0x17 = 0x34

0x34 XOR 0x17 = 0x23

0x34 XOR 0x23 = 0x17



可逆框架会在更大范围内做类似的事情.



A Reversible Frame does a similar thing on a bigger scale.


这篇关于有关ControlPaint.DrawReversibleFrame的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆