Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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#.Net 4.0面板鼠标移动事件闪烁矩形_C#_.net_Mousemove_Flicker_Rectangles - Fatal编程技术网

C#.Net 4.0面板鼠标移动事件闪烁矩形

C#.Net 4.0面板鼠标移动事件闪烁矩形,c#,.net,mousemove,flicker,rectangles,C#,.net,Mousemove,Flicker,Rectangles,我的问题是,即使我想在panel_MouseMove()上移动已绘制的矩形,所有这些矩形都会闪烁。 我不知道为什么。 下面是我的panel_MouseMove方法代码: private void panel_MouseMove(object sender, MouseEventArgs e) { bool flag = false; if (_guiParserMgr != null) { if (e.Button

我的问题是,即使我想在panel_MouseMove()上移动已绘制的矩形,所有这些矩形都会闪烁。 我不知道为什么。 下面是我的panel_MouseMove方法代码:

private void panel_MouseMove(object sender, MouseEventArgs e)
    {
        bool flag = false;
        if (_guiParserMgr != null)
        {
            if (e.Button == MouseButtons.Left)
            {
                foreach (GuiModulModel gmm in _guiParserMgr.Moduls)
                {
                    log.Debug("Modul: XPos:" + gmm.getXPos() + " YPos:" + gmm.getYPos() + " WidthPos:" + ((int)gmm.getXPos() + (int)gmm.getWidth()) + " HeightPos:" + ((int)gmm.getYPos() + (int)gmm.getHeight()));

                    if (flag == false)
                    {
                        foreach (GuiEntityModel gem in gmm.Entitys)
                        {
                            log.Debug("Entity: XPos:" + gem.getXPos() + " YPos:" + gem.getYPos() + " WidthPos:" + ((int)gem.getXPos() + (int)gem.getWidth()) + " HeightPos:" + ((int)gem.getYPos() + (int)gem.getHeight()));
                            if (gem.getXPos() < e.X && gem.getXPos() + gem.getWidth() > e.X && gem.getYPos() < e.X && gem.getYPos() + gem.getHeight() > e.Y)
                            {

                                // Increment rectangle-location by mouse-location delta.
                                gem.setXPos(e.X /*+ _firstPoint.X*/);
                                gem.setYPos(e.Y /*+ _firstPoint.Y*/);

                                // Re-calibrate on each move operation.
                                _firstPoint = new MovePoint { X = e.X, Y = e.Y };

                                //panel.Invalidate();

                                foreach (GuiFieldModel gfm in gem.Fields)
                                {
                                    // Increment rectangle-location by mouse-location delta.
                                    gfm.setXPos(e.X/*+ _firstPoint.X*/);
                                    gfm.setYPos(e.Y + 15/*+ _firstPoint.Y*/);

                                    // Re-calibrate on each move operation.
                                    _firstPoint = new MovePoint { X = e.X, Y = e.Y };

                                    //panel.Invalidate();                                    
                                }
                                flag = true;
                            }
                        }
                    }
                    if (flag == false)
                    {
                        foreach (GuiEnumTypeModel getm in gmm.EnumTypes)
                        {
                            log.Debug("EnumType: XPos:" + getm.getXPos() + " YPos:" + getm.getYPos() + " WidthPos:" + ((int)getm.getXPos() + (int)getm.getWidth()) + " HeightPos:" + ((int)getm.getYPos() + (int)getm.getHeight()));
                            if (getm.getXPos() < e.X && getm.getXPos() + getm.getWidth() > e.X && getm.getYPos() < e.X && getm.getYPos() + getm.getHeight() > e.Y)
                            {
                                // Increment rectangle-location by mouse-location delta.
                                getm.setXPos(e.X /*+ _firstPoint.X*/);
                                getm.setYPos(e.Y /*+ _firstPoint.Y*/);
                                // Re-calibrate on each move operation.
                                _firstPoint = new MovePoint { X = e.X, Y = e.Y };

                                //panel.Invalidate();
                                flag = true;
                            }

                        }
                    }
                    if (flag == false)
                    {

                        foreach (GuiServiceModel gsm in gmm.Services)
                        {
                            log.Debug("Service: XPos:" + gsm.getXPos() + " YPos:" + gsm.getYPos() + " WidthPos:" + ((int)gsm.getXPos() + (int)gsm.getWidth()) + " HeightPos:" + ((int)gsm.getYPos() + (int)gsm.getHeight()));
                            if (gsm.getXPos() < e.X && gsm.getXPos() + gsm.getWidth() > e.X && gsm.getYPos() < e.X && gsm.getYPos() + gsm.getHeight() > e.Y)
                            {

                                // Increment rectangle-location by mouse-location delta.
                                gsm.setXPos(e.X /*+ _firstPoint.X*/);
                                gsm.setYPos(e.Y /*+ _firstPoint.Y*/);

                                // Re-calibrate on each move operation.
                                _firstPoint = new MovePoint { X = e.X, Y = e.Y };

                                //panel.Invalidate();
                                flag = true;
                            }

                        }
                    }
                    if (flag == false)
                    {
                        foreach (GuiWebMvcModel gwm in gmm.WebMvcs)
                        {
                            log.Debug("WebMVC: XPos:" + gwm.getXPos() + " YPos:" + gwm.getYPos() + " WidthPos:" + ((int)gwm.getXPos() + (int)gwm.getWidth()) + " HeightPos:" + ((int)gwm.getYPos() + (int)gwm.getHeight()));

                            if (gwm.getXPos() < e.X && gwm.getXPos() + gwm.getWidth() > e.X && gwm.getYPos() < e.X && gwm.getYPos() + gwm.getHeight() > e.Y)
                            {
                                // Increment rectangle-location by mouse-location delta.
                                gwm.setXPos(e.X /*+ _firstPoint.X*/);
                                gwm.setYPos(e.Y /*+ _firstPoint.Y*/);

                                // Re-calibrate on each move operation.
                                _firstPoint = new MovePoint { X = e.X, Y = e.Y };

                                //panel.Invalidate();
                                flag = true;
                            }

                        }
                    }
                    if (flag == false)
                    {
                        if (gmm.getXPos() < e.X && gmm.getXPos() + gmm.getWidth() > e.X && gmm.getYPos() < e.X && gmm.getYPos() + gmm.getHeight() > e.Y)
                        {
                            // Increment rectangle-location by mouse-location delta.
                            gmm.setXPos(e.X /*+ _firstPoint.X*/);
                            gmm.setYPos(e.Y /*+ _firstPoint.Y*/);

                            // Re-calibrate on each move operation.
                            _firstPoint = new MovePoint { X = e.X, Y = e.Y };

                            //panel.Invalidate();
                            flag = true;

                        }
                    }
                    panel.Invalidate();




                }
            }
        }
    }
private void panel\u MouseMove(对象发送器,MouseEventArgs e)
{
布尔标志=假;
if(_guiParserMgr!=null)
{
if(e.Button==MouseButtons.Left)
{
foreach(guiParserMgr.modules中的guimodulemodel gmm)
{
log.Debug(“Modul:XPos:+gmm.getXPos()+”YPos:+gmm.getYPos()+”WidthPos:”+((int)gmm.getXPos()+(int)gmm.getWidth())+“HeightPos:”+((int)gmm.getYPos()+(int)gmm.getHeight());
如果(标志==false)
{
foreach(gmm.Entitys中的GuiEntityModel gem)
{
log.Debug(“实体:XPos:+gem.getXPos()+”YPos:+gem.getYPos()+”WidthPos:”+((int)gem.getXPos()+(int)gem.getWidth())+“HeightPos:”+((int)gem.getYPos()+(int)gem.getHeight());
如果(gem.getXPos()e.X&&gem.getYPos()e.Y)
{
//通过鼠标位置增量增加矩形位置增量。
gem.setXPos(e.X/*+_firstPoint.X*/);
gem.setYPos(e.Y/*+_firstPoint.Y*/);
//每次移动操作时重新校准。
_第一个点=新的移动点{X=e.X,Y=e.Y};
//panel.Invalidate();
foreach(gem.Fields中的GuiFieldModel gfm)
{
//通过鼠标位置增量增加矩形位置增量。
gfm.setXPos(e.X/*+_firstPoint.X*/);
gfm.setYPos(e.Y+15/*+_firstPoint.Y*/);
//每次移动操作时重新校准。
_第一个点=新的移动点{X=e.X,Y=e.Y};
//panel.Invalidate();
}
flag=true;
}
}
}
如果(标志==false)
{
foreach(gmm.EnumTypes中的GuiEnumTypeModel getm)
{
log.Debug(“EnumType:XPos:+getm.getXPos()+”YPos:+getm.getYPos()+”WidthPos:”+((int)getm.getXPos()+(int)getm.getWidth())+“HeightPos:”+((int)getm.getYPos()+(int)getm.getHeight());
如果(getm.getXPos()e.X&&getm.getYPos()e.Y)
{
//通过鼠标位置增量增加矩形位置增量。
getm.setXPos(e.X/*+_firstPoint.X*/);
getm.setYPos(e.Y/*+_firstPoint.Y*/);
//每次移动操作时重新校准。
_第一个点=新的移动点{X=e.X,Y=e.Y};
//panel.Invalidate();
flag=true;
}
}
}
如果(标志==false)
{
foreach(GuiServiceModel gsm在gmm.Services中)
{
log.Debug(“服务:XPos:+gsm.getXPos()+”YPos:+gsm.getYPos()+”WidthPos:”+((int)gsm.getXPos()+(int)gsm.getWidth())+“HeightPos:”+((int)gsm.getYPos()+(int)gsm.getHeight());
如果(gsm.getXPos()e.X&&gsm.getYPos()e.Y)
{
//通过鼠标位置增量增加矩形位置增量。
gsm.setXPos(e.X/*+_firstPoint.X*/);
gsm.setYPos(e.Y/*+_firstPoint.Y*/);
//每次移动操作时重新校准。
_第一个点=新的移动点{X=e.X,Y=e.Y};
//panel.Invalidate();
flag=true;
}
}
}
如果(标志==false)
{
foreach(gmm.WebMvcs中的guiwebmvc模型gwm)
{
log.Debug(“WebMVC:XPos:+gwm.getXPos()+”YPos:+gwm.getYPos()+”WidthPos:”+((int)gwm.getXPos()+(int)gwm.getWidth())+“HeightPos:”+((int)gwm.getYPos()+(int)gwm.getHeight());
如果(gwm.getXPos()e.X&&gwm.getYPos()e.Y)
{
//通过鼠标位置增量增加矩形位置增量。
gwm.setXPos(e.X/*+_firstPoint.X*/);
gwm.setYPos(e.Y/*+_firstPoint.Y*/);
//每次移动操作时重新校准。
_第一个点=新的移动点{X=e.X,Y=e.Y};
//panel.Invalidate();
flag=true;
}
}
}
如果(标志==false)
{
如果(gmm.g
using System;
using System.Drawing;
using System.Windows.Forms;

namespace BigBrother
{
    public class SizeablePictureBox : PictureBox
    {

        private const int grab = 16;
        public Point PBstartLocation;
        public Point PBcornerStart;

        public SizeablePictureBox()
        {
            this.ResizeRedraw = true;
        }


        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            var rc = new Rectangle(this.ClientSize.Width - grab, this.ClientSize.Height - grab, grab, grab);
            ControlPaint.DrawSizeGrip(e.Graphics, this.BackColor, rc);
        }

        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
            if (m.Msg == 0x84)
            {

                var pos = this.PointToClient(new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16));
                if (pos.X >= this.ClientSize.Width - grab && pos.Y >= this.ClientSize.Height - grab)
                    m.Result = new IntPtr(17);
            }
        }


        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                PBstartLocation = e.Location;
                PBcornerStart = this.Location;
                this.BringToFront();
            }

        }


        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                this.Left = e.X + this.Left - PBstartLocation.X;
                this.Top = e.Y + this.Top - PBstartLocation.Y;
            }
        }
    }