Пример #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();
        }
Пример #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();
        }
Пример #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();
        }
Пример #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();
        }
Пример #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();
            }
        }
Пример #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();
            }
        }
Пример #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();
        }
Пример #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();
        }
Пример #9
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();
        }
Пример #10
0
        /// <summary>
        /// ˫��������
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseDoubleClick(RegionForm regionForm, MouseEventArgs e)
        {
            // ��ȡ��������
            Rectangle rect = ((DrawRectangle)regionForm.DrawRectangle).Rectangle;
            // �½�λͼ�����������
            Image = new Bitmap(rect.Width, rect.Height);
            Graphics g = Graphics.FromImage(_image);

            // ��������ձ�����λͼ��
            g.DrawImage(regionForm.BackgroundImage, 0, 0, rect, GraphicsUnit.Pixel);

            g.Dispose();

            // �ݴ浽������
            /*
             * Clipboard.SetImage(FullScrn.Image);
             */
            // ����ͼƬ
            Image.Save(Application.StartupPath + "\\RegionScrn.png");
        }
Пример #11
0
        /// <summary>
        /// 双击鼠标左键
        /// </summary>
        /// <param name="regionForm"></param>
        /// <param name="e"></param>
        public override void OnMouseDoubleClick(RegionForm regionForm, MouseEventArgs e)
        {
            // 获取矩形区域
            Rectangle rect = ((DrawRectangle)regionForm.DrawRectangle).Rectangle;

            // 新建位图保存区域快照
            Image = new Bitmap(rect.Width, rect.Height);
            Graphics g = Graphics.FromImage(_image);

            // 把区域快照保存在位图中
            g.DrawImage(regionForm.BackgroundImage, 0, 0, rect, GraphicsUnit.Pixel);

            g.Dispose();

            // 暂存到剪贴板

            /*
             * Clipboard.SetImage(FullScrn.Image);
             */
            // 保存图片
            Image.Save(Application.StartupPath + "\\RegionScrn.png");
        }
Пример #12
0
        /// <summary>
        /// ·����ͼ
        /// </summary>
        private void CommandPathScrn()
        {
            // ��ȡ��Ļ��С
            Size size = Screen.PrimaryScreen.Bounds.Size;
            // ������Ļ����
            Image image = new Bitmap(size.Width, size.Height);
            Graphics g = Graphics.FromImage(image);
            g.CopyFromScreen(0, 0, 0, 0, size);

            g.Dispose();

            // ��ʾ�����ͼ����
            RegionForm frm = new RegionForm();
            frm.Size = size;
            frm.Initialize();

            // ����Ĭ�Ϲ���
            frm.ActiveTool = RegionForm.RegionToolType.Path;
            frm.DrawRectangle = new DrawPath();
            frm.BackgroundImage = image;
            frm.Show();
        }
Пример #13
0
        /// <summary>
        /// 路径截图
        /// </summary>
        private void CommandPathScrn()
        {
            // 获取屏幕大小
            Size size = Screen.PrimaryScreen.Bounds.Size;
            // 保存屏幕快照
            Image    image = new Bitmap(size.Width, size.Height);
            Graphics g     = Graphics.FromImage(image);

            g.CopyFromScreen(0, 0, 0, 0, size);

            g.Dispose();

            // 显示区域截图窗体
            RegionForm frm = new RegionForm();

            frm.Size = size;
            frm.Initialize();

            // 设置默认工具
            frm.ActiveTool      = RegionForm.RegionToolType.Path;
            frm.DrawRectangle   = new DrawPath();
            frm.BackgroundImage = image;
            frm.Show();
        }
Пример #14
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();
            }
        }
Пример #15
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();
            }
        }
Пример #16
0
 public override void OnMouseDown(RegionForm regionForm, MouseEventArgs e)
 {
     ChangeObject(regionForm, new DrawRectangle(e.X, e.Y, 1, 1));
 }
Пример #17
0
 /// <summary>
 /// 双击鼠标左键
 /// </summary>
 /// <param name="regionForm"></param>
 /// <param name="e"></param>
 public virtual void OnMouseDoubleClick(RegionForm regionForm, MouseEventArgs e)
 {
 }
Пример #18
0
 /// <summary>
 /// 释放鼠标左键
 /// </summary>
 /// <param name="regionForm"></param>
 /// <param name="e"></param>
 public virtual void OnMouseUp(RegionForm regionForm, MouseEventArgs e)
 {
 }
Пример #19
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();
        }
Пример #20
0
 /// <summary>
 /// ˫��������
 /// </summary>
 /// <param name="regionForm"></param>
 /// <param name="e"></param>
 public virtual void OnMouseDoubleClick(RegionForm regionForm, MouseEventArgs e)
 {
 }
Пример #21
0
 /// <summary>
 /// �ͷ�������
 /// </summary>
 /// <param name="regionForm"></param>
 /// <param name="e"></param>
 public virtual void OnMouseUp(RegionForm regionForm, MouseEventArgs e)
 {
 }
Пример #22
0
 public override void OnMouseDown(RegionForm regionForm, MouseEventArgs e)
 {
     ChangeObject(regionForm, new DrawRectangle(e.X, e.Y, 1, 1));
 }