예제 #1
0
파일: HWndCtrl.cs 프로젝트: MarkDDi/Frame
        /*******************************************************************/
        private void mouseMoved(object sender, HalconDotNet.HMouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                mousePressed = true;
                int activeROIidx = -1;
                //double scale;
                startX = e.X;
                startY = e.Y;
                if (roiManager != null)
                {
                    activeROIidx = roiManager.mouseDownAction(e.X, e.Y);
                }

                MouseMove me = new MouseMove();
                try
                {
                    if (HObjList.Count > 0)
                    {
                        HTuple       gray  = 0;
                        HObjectEntry entry = (HObjectEntry)HObjList[0];
                        if ((e.Y >= 0) && (e.X >= 0))
                        {
                            HOperatorSet.GetGrayval(entry.HObj, e.Y, e.X, out gray);
                            me.Gray = (uint)gray.I;
                        }
                    }
                }
                catch { me.Gray = 0; }
                me.X = (int)e.X + 1;   //图像从0开始,显示数据从1开始
                me.Y = (int)e.Y + 1;
                MouseMoveEventOutput(me);
            }
            else
            {
                double motionX, motionY;

                if (!mousePressed)
                {
                    return;
                }

                if (roiManager != null && (roiManager.activeROIidx != -1))
                {
                    roiManager.mouseMoveAction(e.X, e.Y);
                }
                else
                {
                    if (!isCancelImageMove)
                    {
                        motionX = ((e.X - startX));
                        motionY = ((e.Y - startY));

                        if (((int)motionX != 0) || ((int)motionY != 0))
                        {
                            moveImage(motionX, motionY);
                            startX = e.X - motionX;
                            startY = e.Y - motionY;
                        }
                    }
                }
            }
        }