コード例 #1
0
        private void TipCapture()
        {
            IntPtr handle = Handle;

            if (handle == IntPtr.Zero)
            {
                return;
            }

            RECT rect = new RECT();

            NativeMethods.GetWindowRect(handle, ref rect);

            Size size = new Size(
                rect.Right - rect.Left,
                rect.Bottom - rect.Top);

            _backDc = new ImageDc(size.Width, size.Height);
            IntPtr pD = NativeMethods.GetDesktopWindow();
            IntPtr pH = NativeMethods.GetDC(pD);

            NativeMethods.BitBlt(
                _backDc.Hdc,
                0, 0, size.Width, size.Height,
                pH, rect.Left, rect.Top, 0xCC0020);
            NativeMethods.ReleaseDC(pD, pH);
        }
コード例 #2
0
ファイル: ToolTipEx.cs プロジェクト: scjjcs/DirectUI
        /// <summary> 获取ToolTip区域的截图
        /// </summary>
        private void ToolTipCapture()
        {
            backImageDc = new ImageDc(this.Size.Width, this.Size.Height);
            IntPtr pD = NativeMethods.GetDesktopWindow();
            IntPtr pH = NativeMethods.GetDC(pD);

            NativeMethods.BitBlt(backImageDc.Hdc, 0, 0, this.Width, this.Height, pH, this.X, this.Y, 0xCC0020);
            NativeMethods.ReleaseDC(pD, pH);
        }
コード例 #3
0
ファイル: ToolTipEx.cs プロジェクト: scjjcs/DirectUI
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         if (backImageDc != null)
         {
             backImageDc.Dispose();
             backImageDc = null;
         }
     }
 }
コード例 #4
0
 //public int X { get { return Control.MousePosition.X + 10; } }
 //public int Y { get { return Control.MousePosition.Y + 10; } }
 //public Point Location { get { return new Point(X, Y); } }
 public void SetToolTip()
 {
     this.Location    = Control.MousePosition;
     this.backImageDc = new ImageDc(200, 200);
     this.backImageDc.ScreenCapture(Location);
     this.Show(Location);
     //new Thread(() =>
     //{
     //    Thread.Sleep(500);
     //    synchronizationContext.Send((obj) =>
     //    {
     //        this.Show(Location);
     //    }, null);
     //}) { IsBackground = true }.Start();
     ////this.backImageDc.ScreenCapture(this.Location);
     ////this.control = control;
 }
コード例 #5
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                if (_backDc != null)
                {
                    _backDc.Dispose();
                    _backDc = null;
                }

                if (!_titleFont.IsSystemFont)
                {
                    _titleFont.Dispose();
                }
                _titleFont = null;

                _image      = null;
                _colorTable = null;
            }
        }
コード例 #6
0
ファイル: SBManger.cs プロジェクト: jollitycn/JGNet
        private void DrawScrollBar(
            IntPtr maskHWnd,
            Rectangle bounds,
            Rectangle trackRect,
            Rectangle topLeftArrowRect,
            Rectangle bottomRightArrowRect,
            Rectangle thumbRect,
            ControlState topLeftArrowState,
            ControlState bottomRightArrowState,
            ControlState thumbState,
            Orientation direction)
        {
            bool            bHorizontal = direction == Orientation.Horizontal;
            ArrowDirection  arrowDirection;
            bool            bEnabled = _owner.Enabled;
            IScrollBarPaint paint    = _owner as IScrollBarPaint;

            if (paint == null)
            {
                return;
            }

            ImageDc tempDc = new ImageDc(bounds.Width, bounds.Height);
            IntPtr  hdc    = NativeMethods.GetDC(maskHWnd);

            try
            {
                using (Graphics g = Graphics.FromHdc(tempDc.Hdc))
                {
                    using (PaintScrollBarTrackEventArgs te =
                               new PaintScrollBarTrackEventArgs(
                                   g,
                                   trackRect,
                                   direction,
                                   bEnabled))
                    {
                        Graphics  ge   = te.Graphics;
                        Rectangle rect = te.TrackRectangle;

                        Color baseColor = GetGray(Color.Blue);

                        ControlPaintEx.DrawScrollBarTrack(
                            ge, rect, baseColor, Color.White, te.Orientation);
                        //paint.OnPaintScrollBarTrack(te);
                    }

                    arrowDirection = bHorizontal ?
                                     ArrowDirection.Left : ArrowDirection.Up;

                    using (PaintScrollBarArrowEventArgs te =
                               new PaintScrollBarArrowEventArgs(
                                   g,
                                   topLeftArrowRect,
                                   topLeftArrowState,
                                   arrowDirection,
                                   direction,
                                   bEnabled))
                    {
                        paint.OnPaintScrollBarArrow(te);
                    }

                    arrowDirection = bHorizontal ?
                                     ArrowDirection.Right : ArrowDirection.Down;

                    using (PaintScrollBarArrowEventArgs te =
                               new PaintScrollBarArrowEventArgs(
                                   g,
                                   bottomRightArrowRect,
                                   bottomRightArrowState,
                                   arrowDirection,
                                   direction,
                                   bEnabled))
                    {
                        paint.OnPaintScrollBarArrow(te);
                    }

                    using (PaintScrollBarThumbEventArgs te =
                               new PaintScrollBarThumbEventArgs(
                                   g,
                                   thumbRect,
                                   thumbState,
                                   direction,
                                   bEnabled))
                    {
                        paint.OnPaintScrollBarThumb(te);
                    }
                }

                NativeMethods.BitBlt(
                    hdc,
                    0,
                    0,
                    bounds.Width,
                    bounds.Height,
                    tempDc.Hdc,
                    0,
                    0,
                    TernaryRasterOperations.SRCCOPY);
            }
            finally
            {
                NativeMethods.ReleaseDC(maskHWnd, hdc);
                tempDc.Dispose();
            }
        }
コード例 #7
0
        private void DrawScrollBar(
            IntPtr maskHWnd,
            Rectangle bounds,
            Rectangle trackRect,
            Rectangle topLeftArrowRect,
            Rectangle bottomRightArrowRect,
            Rectangle thumbRect,
            ControlState topLeftArrowState,
            ControlState bottomRightArrowState,
            ControlState thumbState,
            Orientation direction)
        {
            bool bHorizontal = direction == Orientation.Horizontal;
            ArrowDirection arrowDirection;
            bool bEnabled = _owner.Enabled;
            IScrollBarPaint paint = _owner as IScrollBarPaint;

            if (paint == null)
            {
                return;
            }

            ImageDc tempDc = new ImageDc(bounds.Width, bounds.Height);
            IntPtr hdc = NativeMethods.GetDC(maskHWnd);
            try
            {
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromHdc(tempDc.Hdc))
                {
                    using (PaintScrollBarTrackEventArgs te =
                        new PaintScrollBarTrackEventArgs(
                        g,
                        trackRect,
                        direction,
                        bEnabled))
                    {
                        paint.OnPaintScrollBarTrack(te);
                    }

                    arrowDirection = bHorizontal ?
                        ArrowDirection.Left : ArrowDirection.Up;

                    using (PaintScrollBarArrowEventArgs te =
                        new PaintScrollBarArrowEventArgs(
                        g,
                        topLeftArrowRect,
                        topLeftArrowState,
                        arrowDirection,
                        direction,
                        bEnabled))
                    {
                        paint.OnPaintScrollBarArrow(te);
                    }

                    arrowDirection = bHorizontal ?
                        ArrowDirection.Right : ArrowDirection.Down;

                    using (PaintScrollBarArrowEventArgs te =
                        new PaintScrollBarArrowEventArgs(
                        g,
                        bottomRightArrowRect,
                        bottomRightArrowState,
                        arrowDirection,
                        direction,
                        bEnabled))
                    {
                        paint.OnPaintScrollBarArrow(te);
                    }

                    using (PaintScrollBarThumbEventArgs te =
                        new PaintScrollBarThumbEventArgs(
                        g,
                        thumbRect,
                        thumbState,
                        direction,
                        bEnabled))
                    {
                        paint.OnPaintScrollBarThumb(te);
                    }
                }

                NativeMethods.BitBlt(
                    hdc,
                    0,
                    0,
                    bounds.Width,
                    bounds.Height,
                    tempDc.Hdc,
                    0,
                    0,
                    TernaryRasterOperations.SRCCOPY);
            }
            finally
            {
                NativeMethods.ReleaseDC(maskHWnd, hdc);
                tempDc.Dispose();
            }
        }
コード例 #8
0
ファイル: TrackBarEx.cs プロジェクト: songques/CSSIM_Solution
        private void DrawTrackBar(IntPtr hWnd)
        {
            ControlState state = ControlState.Normal;
            bool horizontal = base.Orientation == Orientation.Horizontal;
            ImageDc tempDc = new ImageDc(base.Width, base.Height);
            RECT trackRect = new RECT();
            RECT thumbRect = new RECT();

            System.Drawing.Graphics g = System.Drawing.Graphics.FromHdc(tempDc.Hdc);

            NativeMethods.SendMessage(
                hWnd, TBM.TBM_GETCHANNELRECT, 0, ref trackRect);
            NativeMethods.SendMessage(
                hWnd, TBM.TBM_GETTHUMBRECT, 0, ref thumbRect);

            Rectangle trackRectangle = horizontal ?
                trackRect.Rect :
                Rectangle.FromLTRB(
                trackRect.Top, trackRect.Left,
                trackRect.Bottom, trackRect.Right);

            if (ThumbHovering(thumbRect))
            {
                if (Helper.LeftKeyPressed())
                {
                    state = ControlState.Pressed;
                }
                else
                {
                    state = ControlState.Hover;
                }
            }

            using (PaintEventArgs pe = new PaintEventArgs(
                g, ClientRectangle))
            {
                OnRenderBackground(pe);
            }

            int ticks = NativeMethods.SendMessage(
                hWnd, TBM.TBM_GETNUMTICS, 0, 0);

            if (ticks > 0)
            {
                List<float> tickPosList = new List<float>(ticks);

                int thumbOffset = horizontal ?
                    thumbRect.Rect.Width : thumbRect.Rect.Height;
                int trackWidth = trackRect.Right - trackRect.Left;
                float tickSpace = (trackWidth - thumbOffset) / (float)(ticks - 1);
                float offset = trackRect.Left + thumbOffset / 2f;

                for(int pos = 0; pos < ticks; pos ++)
                {
                    tickPosList.Add(offset + tickSpace * pos);
                }

                using (PaintTickEventArgs pte = new PaintTickEventArgs(
                    g, trackRectangle, tickPosList))
                {
                    OnRenderTick(pte);
                }
            }

            using (PaintEventArgs pe = new PaintEventArgs(
                g, trackRectangle))
            {
                OnRenderTrack(pe);
            }

            using (PaintThumbEventArgs pe = new PaintThumbEventArgs(
                g, thumbRect.Rect, state))
            {
                OnRenderThumb(pe);
            }

            g.Dispose();
            IntPtr hDC = NativeMethods.GetDC(hWnd);
            NativeMethods.BitBlt(
                hDC, 0, 0, base.Width, base.Height,
                tempDc.Hdc, 0, 0, 0xCC0020);
            NativeMethods.ReleaseDC(hWnd, hDC);
            tempDc.Dispose();
        }