コード例 #1
0
        public override void EndScene(bool waitVSync)
        {
            Graphics gr = mParent.CreateGraphics();

            gr.DrawImageUnscaled(mBackBuffer.Bitmap, new Point(0, 0));
            gr.Dispose();

            mFrames++;
        }
コード例 #2
0
        public static Color GetColorOfControl(System.Windows.Forms.Control control, Point point)
        {
            System.Drawing.Graphics g = control.CreateGraphics();
            IntPtr dc  = g.GetHdc();
            Color  res = ColorTranslator.FromWin32(NativeMethods.GetPixel(dc, point.X, point.Y));

            NativeMethods.ReleaseDC(dc);
            return(res);
        }
コード例 #3
0
 public void draw(System.Windows.Forms.Control control, Point k)
 {
     System.Drawing.Pen myPen;
     myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
     System.Drawing.Graphics formGraphics = control.CreateGraphics();
     formGraphics.DrawLine(myPen, k.x * a.x, k.y * a.y, k.x * b.x, k.y * b.y);
     myPen.Dispose();
     formGraphics.Dispose();
 }
コード例 #4
0
ファイル: GanttControlCS.cs プロジェクト: brien/js-go
        public static void SetBarStartLeft(string rowText, Font rowTextFont, int barStartLeft, System.Windows.Forms.Control ths)
        {
            Graphics gfx    = ths.CreateGraphics();
            int      length = (int)gfx.MeasureString(rowText, rowTextFont, 500).Width;

            if (length > barStartLeft)
            {
                barStartLeft = length;
            }
        }
コード例 #5
0
ファイル: Common.cs プロジェクト: Vocaoson/qlgx
        public static int MeasureString(string s, System.Windows.Forms.Control ctl)
        {
            System.Drawing.Graphics g = ctl.CreateGraphics();
            int w = 0;

            for (int i = 0; i < s.Length; i++)
            {
                w += (int)g.MeasureString(s.Substring(i, 1), ctl.Font).Width;
            }
            return(w);
        }
コード例 #6
0
 public static int MeasureTextWidth(System.Windows.Forms.Control c, string text)
 {
     if (c == null)
     {
         return(-1);
     }
     using (System.Drawing.Graphics g = c.CreateGraphics())
     {
         return((int)Math.Ceiling(g.MeasureString(text, c.Font).Width));
     }
 }
コード例 #7
0
        public static Size GetThumbnailSize(System.Windows.Forms.Control control)
        {
            int scaledWidth;

            using (Graphics g = control.CreateGraphics())
            {
                scaledWidth = (int)(192 * g.DpiX / 96);
            }

            return(new Size(scaledWidth, scaledWidth * 9 / 16));
        }
コード例 #8
0
        /// <summary>
        /// 绘制的方法
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="nCompress"></param>
        public virtual void doDrawing(ref PointF pos, int status, float width)
        {
            Graphics grap = myControl.CreateGraphics();

            grap.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            grap.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            Color pointc = Color.Black;
            float penW   = width;

            if (status == 33)
            {
                pointc = Color.Red;
            }
            else if (status == 49)
            {
                pointc = Color.White;
                penW   = 10;
            }
            grap.DrawLine(new Pen(pointc, penW), m_lastPoint, pos);
            m_lastPoint = pos;
            grap.Dispose();
        }
コード例 #9
0
 public static System.Drawing.Graphics CreateGraphicsMSS(
     System.Windows.Forms.Control target)
 {
     object result;
     if (TestSpecificStubsUtil.RunTestSpecificStub(System.Reflection.MethodBase.GetCurrentMethod(), new object[] { target }, out result))
     {
         return (System.Drawing.Graphics)result;
     }
     else
     {
         return target.CreateGraphics();
     }
 }
コード例 #10
0
ファイル: hwndutils.cs プロジェクト: nishkt/barcode-scanning
        // this is the new wndproc, just show a messagebox on left button down:
        private IntPtr MyWndProc(IntPtr hWnd, int msg, int wParam, int lParam)
        {
            //is this a message for us?
            if (((msg == (int)WM_LBUTTONDOWN) || (msg == (int)WM_LBUTTONUP)) && (this._mIsStartButtonDisabled || this._mIsCloseButtonDisabled))
            {
                int x = ((int)lParam) & 0xFFFF;
                int y = ((int)lParam) >> 16;

                bool isVGA;
                bool isQVGA;
                using (System.Windows.Forms.Control detector = new System.Windows.Forms.Control())
                {
                    using (System.Drawing.Graphics gr = detector.CreateGraphics())
                    {
                        isVGA  = gr.DpiY == 192;
                        isQVGA = gr.DpiY == 96;
                    }
                }

                RECT rect;
                GetWindowRect(hWnd, out rect); //get the rectangle of the menu_bar

                int width  = Math.Max(rect.Left, rect.Right) - Math.Min(rect.Left, rect.Right);
                int height = Math.Max(rect.Bottom, rect.Top) - Math.Min(rect.Bottom, rect.Top);

                //width values are assumed
                int buttonWidth  = (isQVGA | isVGA) ? 92 : 46;
                int buttonHeight = height; //(isQVGA | isVGA) ? 72 : 36;

                System.Drawing.Rectangle rectStartButton = new System.Drawing.Rectangle(0, 0, buttonWidth, buttonHeight);
                System.Drawing.Rectangle rectCloseButton = new System.Drawing.Rectangle(width - buttonWidth, 0, buttonWidth, buttonHeight);

                //check if enabled and click is inside the start or close button rectangle
                if (this._mIsStartButtonDisabled && rectStartButton.Contains(x, y))
                {
                    return(IntPtr.Zero);
                }
                if (this._mIsCloseButtonDisabled && rectCloseButton.Contains(x, y))
                {
                    return(IntPtr.Zero);
                }

                //if both are false, we have to provide the click to windows
                return(CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam));
            }
            else
            {
                return(CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam));
            }
        }
コード例 #11
0
 public void Repaint(bool isAct)
 {
     if (control != null)
     {
         Color     color  = isAct ? Color.Red : Color.Gray;
         int       width  = control.Width;
         int       height = control.Height;
         Point     point  = control.Location;
         int       radius = width >= height ? height : width;
         Rectangle rec    = new Rectangle(point.X + width / 2 - radius / 2 - 1, point.Y + height / 2 - radius / 2 - 1, radius - 2, radius - 2);
         g = control.CreateGraphics();
         Pen p = new Pen(color, 1);
         g.DrawEllipse(p, rec);
         g.FillEllipse(new SolidBrush(color), rec);
     }
 }
コード例 #12
0
                /// <summary>
                /// Gets the graphics object from the given control
                /// </summary>
                /// <param name="control">Control to obtain the graphics from</param>
                /// <returns>A graphics object with the control's characteristics</returns>
                public Graphics GetGraphics(System.Windows.Forms.Control control)
                {
                    Graphics graphic;

                    if (control.Visible)
                    {
                        graphic = control.CreateGraphics();
                        SetColor(graphic, control.ForeColor);
                        SetFont(graphic, control.Font);
                    }
                    else
                    {
                        graphic = null;
                    }
                    return(graphic);
                }
コード例 #13
0
ファイル: AdvanceMeasure.cs プロジェクト: yifeidong/gvms
        public void MearseMouseDown(System.Drawing.Point mousePosition, System.Windows.Forms.Control mapControl)
        {
            if (this._graphics == null)
            {
                this._mapControl  = mapControl;
                this._graphics    = mapControl.CreateGraphics();
                this._measureLine = new GraphicsPath();
            }

            this._graphics.FillRectangle(new SolidBrush(Color.Blue), new Rectangle(mousePosition.X - 3, mousePosition.Y - 3, 6, 6));

            if (this._measureLine.PointCount == 0 && this._startDraw == false)
            {
                this._curPoint  = this._prePoint = mousePosition;
                this._startDraw = true;
            }
            else
            {
                this._prePoint = this._curPoint;
                this._curPoint = mousePosition;
                this._measureLine.AddLine(this._prePoint, this._curPoint);
                this._graphics.DrawPath(new System.Drawing.Pen(Color.Blue, 4), this._measureLine);
            }
        }
コード例 #14
0
ファイル: MeasureHelper.cs プロジェクト: gehy1/sourcegrid
 /// <summary>
 /// Create a graphic object from the current control
 /// </summary>
 /// <param name="control"></param>
 public MeasureHelper(System.Windows.Forms.Control control)
 {
     mGraphics   = control.CreateGraphics();
     mDisposeObj = true;
 }
コード例 #15
0
        // this is the new wndproc, just show a messagebox on left button down:
        private IntPtr MyWndProc(IntPtr hWnd, int msg, int wParam, int lParam)
        {
            //is this a message for us?
            if ((msg == (int)WM_LBUTTONDOWN) || (msg == (int)WM_LBUTTONUP))
            {
                int x = ((int)lParam) & 0xFFFF;
                int y = ((int)lParam) >> 16;
                System.Diagnostics.Debug.WriteLine("MyWndProc got lClick at " + x.ToString() + "/" + y.ToString());

                if (this._mIsStartButtonDisabled || this._mIsCloseButtonDisabled || this._mIsMenuButtonDisabled)
                {
                    bool isVGA;
                    bool isQVGA;
                    using (System.Windows.Forms.Control detector = new System.Windows.Forms.Control())
                    {
                        using (System.Drawing.Graphics gr = detector.CreateGraphics())
                        {
                            isVGA  = gr.DpiY == 192;
                            isQVGA = gr.DpiY == 96;
                        }
                    }
                    //menu button on wvga at 280,0  400,65

                    RECT rect;
                    GetWindowRect(hWnd, out rect); //get the rectangle of the menu_bar

                    int width  = Math.Max(rect.Left, rect.Right) - Math.Min(rect.Left, rect.Right);
                    int height = Math.Max(rect.Bottom, rect.Top) - Math.Min(rect.Bottom, rect.Top);

                    //width values are assumed
                    int buttonWidth  = (isQVGA | isVGA) ? 92 : 46;
                    int buttonHeight = height; //(isQVGA | isVGA) ? 72 : 36;

                    System.Drawing.Rectangle rectStartButton = new System.Drawing.Rectangle(0, 0, 0, 0);
                    if (StartAndCloseButton.isStartVisible())
                    {
                        rectStartButton = new System.Drawing.Rectangle(0, 0, buttonWidth, buttonHeight);
                    }
                    else
                    {
                        _mIsStartButtonDisabled = false; //no Start button = No need to capture clicks
                    }
                    System.Drawing.Rectangle rectCloseButton = new System.Drawing.Rectangle(0, 0, 0, 0);
                    if (StartAndCloseButton.isDoneVisible())
                    {
                        rectCloseButton = new System.Drawing.Rectangle(width - buttonWidth, 0, buttonWidth, buttonHeight);
                    }
                    else
                    {
                        _mIsCloseButtonDisabled = false; //no Done/Close button = No need to capture clicks
                    }
                    System.Drawing.Rectangle rectMenuButton;
                    if (StartAndCloseButton.isDoneVisible())
                    {
                        rectMenuButton = new System.Drawing.Rectangle(width - buttonWidth * 3, 0, buttonWidth * 2, buttonHeight);//asuming Menu button is two times the close button
                    }
                    else
                    {
                        rectMenuButton = new System.Drawing.Rectangle(width - buttonWidth * 2, 0, buttonWidth * 2, buttonHeight);//asuming Menu button is two times the close button
                    }
                    //check if enabled and click is inside the start or close button rectangle
                    if (this._mIsStartButtonDisabled && rectStartButton.Contains(x, y))
                    {
                        System.Diagnostics.Debug.WriteLine("click in Start button area defered");
                        return(IntPtr.Zero);
                    }
                    if (this._mIsCloseButtonDisabled && rectCloseButton.Contains(x, y))
                    {
                        System.Diagnostics.Debug.WriteLine("click in Close button area defered");
                        return(IntPtr.Zero);
                    }
                    if (this._mIsMenuButtonDisabled && rectMenuButton.Contains(x, y))
                    {
                        System.Diagnostics.Debug.WriteLine("click in Menu button area defered");
                        return(IntPtr.Zero);
                    }

                    //if both are false, we have to provide the click to windows
                    return(CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam));
                }
                else
                {
                    return(CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam));
                }
            }
            else
            {
                return(CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam));
            }
        }
コード例 #16
0
 internal LanePainter(System.Windows.Forms.Control canvas)
 {
     this.Canvas    = canvas;
     this._graphic  = canvas.CreateGraphics();
     this.IsRunning = true;
 }
コード例 #17
0
ファイル: Document.cs プロジェクト: akinomyoga/afh
 public Document(System.Windows.Forms.Control ctrl)
 {
     this.Drawer = ctrl.CreateGraphics();
 }
コード例 #18
0
 internal XNodePainter(System.Windows.Forms.Control canvas)
 {
     this.Canvas   = canvas;
     this._graphic = canvas.CreateGraphics();
 }