Beispiel #1
0
        /// <summary>
        /// 左键点击绘制区时调用
        /// 激活指定绘图对象
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="o"></param>
        protected void ChangeObject(RegionForm regionForm, DrawRectangle o)
        {
            regionForm.DrawRectangle = o;

            regionForm.Capture = true;
            regionForm.Refresh();
        }
Beispiel #2
0
        /// <summary>
        /// ������������ʱ����
        /// ����ָ����ͼ����
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="o"></param>
        protected void ChangeObject(RegionForm regionForm, DrawRectangle o)
        {
            regionForm.DrawRectangle = o;

            regionForm.Capture = true;
            regionForm.Refresh();
        }
Beispiel #3
0
        /// <summary>
        /// 释放鼠标左键
        /// 改变绘制对象的大小
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(RegionForm regionForm, MouseEventArgs e)
        {
            regionForm.DrawRectangle.Normalize();
            // 切换成拖动模式
            regionForm.ActiveTool = RegionForm.RegionToolType.Pointer;

            regionForm.Capture = false;
            regionForm.Refresh();
        }
Beispiel #4
0
        /// <summary>
        /// �ͷ�������
        /// �ı���ƶ���Ĵ�С
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(RegionForm regionForm, MouseEventArgs e)
        {
            regionForm.DrawRectangle.Normalize();
            // �л����϶�ģʽ
            regionForm.ActiveTool = RegionForm.RegionToolType.Pointer;

            regionForm.Capture = false;
            regionForm.Refresh();
        }
Beispiel #5
0
        public override void OnMouseMove(RegionForm regionForm, MouseEventArgs e)
        {
            regionForm.Cursor = Cursor;

            if (e.Button == MouseButtons.Left)
            {
                Point point = new Point(e.X, e.Y);
                regionForm.DrawRectangle.MoveHandleTo(point, 5);
                regionForm.Refresh();
            }
        }
Beispiel #6
0
        public override void OnMouseMove(RegionForm regionForm, MouseEventArgs e)
        {
            regionForm.Cursor = Cursor;

            if ( e.Button == MouseButtons.Left )
            {
                Point point = new Point(e.X, e.Y);
                regionForm.DrawRectangle.MoveHandleTo(point, 5);
                regionForm.Refresh();
            }
        }
Beispiel #7
0
        /// <summary>
        /// 释放鼠标右键
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(RegionForm regionForm, MouseEventArgs e)
        {
            if (resizedObject != null)
            {
                // after resizing
                resizedObject.Normalize();
                resizedObject = null;
            }

            regionForm.Capture = false;
            regionForm.Refresh();
        }
Beispiel #8
0
        /// <summary>
        /// 按下鼠标左键
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseDown(RegionForm regionForm, MouseEventArgs e)
        {
            wasMove = false;

            selectMode = SelectionMode.None;
            Point point = new Point(e.X, e.Y);

            int handleNumber = regionForm.DrawRectangle.HitTest(point);

            if (handleNumber > 0)
            {
                selectMode = SelectionMode.Size;


                resizedObject       = regionForm.DrawRectangle;
                resizedObjectHandle = handleNumber;
            }

            if (selectMode == SelectionMode.None)
            {
                DrawRectangle o = null;

                if (regionForm.DrawRectangle.HitTest(point) == 0)
                {
                    o = regionForm.DrawRectangle;
                }

                if (o != null)
                {
                    selectMode = SelectionMode.Move;

                    regionForm.Cursor = Cursors.SizeAll;
                }
            }

            lastPoint.X  = e.X;
            lastPoint.Y  = e.Y;
            startPoint.X = e.X;
            startPoint.Y = e.Y;

            regionForm.Capture = true;

            regionForm.Refresh();
        }
Beispiel #9
0
        /// <summary>
        /// 移动鼠标
        /// 未按下任何键或者按下左键
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseMove(RegionForm regionForm, MouseEventArgs e)
        {
            Point point    = new Point(e.X, e.Y);
            Point oldPoint = lastPoint;

            wasMove = true;

            if (e.Button == MouseButtons.None)
            {
                Cursor cursor = null;

                int n = regionForm.DrawRectangle.HitTest(point);

                if (n > 0)
                {
                    cursor = regionForm.DrawRectangle.GetHandleCursor(n);
                }

                if (cursor == null)
                {
                    cursor = Cursors.Default;
                }

                regionForm.Cursor = cursor;

                return;
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            // 按下左键


            // 找出上一位置和当前位置的差异
            int dx = e.X - lastPoint.X;
            int dy = e.Y - lastPoint.Y;

            lastPoint.X = e.X;
            lastPoint.Y = e.Y;

            // 拖动
            if (selectMode == SelectionMode.Size)
            {
                if (resizedObject != null)
                {
                    resizedObject.MoveHandleTo(point, resizedObjectHandle);
                    regionForm.Refresh();
                }
            }

            // 移动
            if (selectMode == SelectionMode.Move)
            {
                regionForm.DrawRectangle.Move(dx, dy);

                regionForm.Cursor = Cursors.SizeAll;
                regionForm.Refresh();
            }
        }
Beispiel #10
0
        /// <summary>
        /// ����������
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseDown(RegionForm regionForm, MouseEventArgs e)
        {
            wasMove = false;

            selectMode = SelectionMode.None;
            Point point = new Point(e.X, e.Y);

            int handleNumber = regionForm.DrawRectangle.HitTest(point);

            if (handleNumber > 0)
            {
                selectMode = SelectionMode.Size;

                resizedObject = regionForm.DrawRectangle;
                resizedObjectHandle = handleNumber;
            }

            if (selectMode == SelectionMode.None)
            {
                DrawRectangle o = null;

                if (regionForm.DrawRectangle.HitTest(point) == 0)
                {
                    o = regionForm.DrawRectangle;
                }

                if (o != null)
                {
                    selectMode = SelectionMode.Move;

                    regionForm.Cursor = Cursors.SizeAll;
                }
            }

            lastPoint.X = e.X;
            lastPoint.Y = e.Y;
            startPoint.X = e.X;
            startPoint.Y = e.Y;

            regionForm.Capture = true;

            regionForm.Refresh();
        }
Beispiel #11
0
        /// <summary>
        /// �ͷ�����Ҽ�
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(RegionForm regionForm, MouseEventArgs e)
        {
            if (resizedObject != null)
            {
                // after resizing
                resizedObject.Normalize();
                resizedObject = null;
            }

            regionForm.Capture = false;
            regionForm.Refresh();
        }
Beispiel #12
0
        /// <summary>
        /// �ƶ����
        /// δ�����κμ����߰������
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseMove(RegionForm regionForm, MouseEventArgs e)
        {
            Point point = new Point(e.X, e.Y);
            Point oldPoint = lastPoint;

            wasMove = true;

            if (e.Button == MouseButtons.None)
            {
                Cursor cursor = null;

                int n = regionForm.DrawRectangle.HitTest(point);

                if (n > 0)
                {
                    cursor = regionForm.DrawRectangle.GetHandleCursor(n);
                }

                if (cursor == null)
                {
                    cursor = Cursors.Default;
                }

                regionForm.Cursor = cursor;

                return;
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            // �������

            // �ҳ���һλ�ú͵�ǰλ�õIJ���
            int dx = e.X - lastPoint.X;
            int dy = e.Y - lastPoint.Y;

            lastPoint.X = e.X;
            lastPoint.Y = e.Y;

            // �϶�
            if (selectMode == SelectionMode.Size)
            {
                if (resizedObject != null)
                {
                    resizedObject.MoveHandleTo(point, resizedObjectHandle);
                    regionForm.Refresh();
                }
            }

            // �ƶ�
            if (selectMode == SelectionMode.Move)
            {
                regionForm.DrawRectangle.Move(dx, dy);

                regionForm.Cursor = Cursors.SizeAll;
                regionForm.Refresh();
            }
        }