/// <summary>
        /// 从计算机屏幕上创建对象
        /// </summary>
        /// <returns>创建的对象</returns>
        public static ReversibleDrawer FromScreen()
        {
            ReversibleDrawer rd = new ReversibleDrawer();

            rd.InitFromHWnd(new IntPtr(0));
            return(rd);
        }
        /// <summary>
        /// 从一个设备上下文句柄创建对象
        /// </summary>
        /// <param name="hdc">设备上下文句柄</param>
        /// <returns>创建的对象</returns>
        public static ReversibleDrawer FromHDC(IntPtr hdc)
        {
            ReversibleDrawer rd = new ReversibleDrawer();

            rd.InitFromHDC(hdc);
            return(rd);
        }
        /// <summary>
        /// 从一个窗体句柄创建一个对象
        /// </summary>
        /// <param name="hwnd">窗体句柄</param>
        /// <returns>创建的对象</returns>
        public static ReversibleDrawer FromHwnd(IntPtr hwnd)
        {
            ReversibleDrawer rd = new ReversibleDrawer();

            rd.InitFromHWnd(hwnd);
            return(rd);
        }
Beispiel #4
0
        protected virtual void OnDraw(bool ResumeView)
        {
            if (this.ReversibleShape == ReversibleShapeStyle.Custom)
            {
                if (Draw != null)
                {
                    CaptureMouseMoveEventArgs args = this.CreateArgs();
                    args.ResumeView = ResumeView;
                    Draw(this, args);
                }
            }
            else
            {
                ReversibleDrawer drawer = null;
                if (myBindControl == null)
                {
                    drawer = ReversibleDrawer.FromScreen();
                }
                else
                {
                    drawer = ReversibleDrawer.FromHwnd(myBindControl.Handle);
                }

                drawer.PenStyle  = PenStyle.PS_SOLID;
                drawer.PenColor  = Color.White;
                drawer.LineWidth = 1;

                Rectangle rect = GetRectangle(this.StartPosition, this.CurrentPosition);
                switch (this.ReversibleShape)
                {
                case ReversibleShapeStyle.Rectangle:
                    drawer.DrawRectangle(rect);
                    break;

                case ReversibleShapeStyle.Ellipse:
                    drawer.DrawEllipse(rect);
                    break;

                case ReversibleShapeStyle.Line:
                    drawer.DrawLine(this.StartPosition, this.CurrentPosition);
                    break;

                case ReversibleShapeStyle.FillRectangle:
                    drawer.FillRectangle(rect);
                    break;
                }
                drawer.Dispose();
            }
        }
Beispiel #5
0
        /// <summary>
        /// 绘制可逆矩形
        /// </summary>
        protected override void OnDraw(bool ResumeView)
        {
            base.OnDraw(ResumeView);
            if (bolCustomAction)
            {
                return;
            }
            ReversibleDrawer drawer = null;

            if (myBindControl != null)
            {
                drawer = ReversibleDrawer.FromHwnd(myBindControl.Handle);
            }
            else
            {
                drawer = ReversibleDrawer.FromScreen();
            }
            drawer.DrawRectangle(myDescRectangle);
            drawer.Dispose();
        }