예제 #1
0
        public void GetWindowDeviceContext_NullWindow()
        {
            // Null here should be the entire screen
            DeviceContext context = GdiMethods.GetWindowDeviceContext(WindowHandle.Null);

            context.IsInvalid.Should().BeFalse();
            int pixelWidth  = GdiMethods.GetDeviceCapability(context, DeviceCapability.HORZRES);
            int pixelHeight = GdiMethods.GetDeviceCapability(context, DeviceCapability.VERTRES);
        }
예제 #2
0
        public void GetSystemColorBrush()
        {
            // System color brushes are special- they'll always give the same value
            BrushHandle brush  = GdiMethods.GetSystemColorBrush(SystemColor.MenuBar);
            long        handle = (long)brush.DangerousGetHandle();

            handle = handle & 0xFFFF00;

            // This changed in RS4 from C5 to BF for the last byte. Checking the first
            // bytes to make sure we're in the right ballpark.
            handle.Should().Be(0x100000);
        }
예제 #3
0
        static void DrawHands(DeviceContext dc, SYSTEMTIME pst, bool fChange)
        {
            int[] iAngle =
            {
                (pst.wHour * 30) % 360 + pst.wMinute / 2,
                pst.wMinute * 6,
                pst.wSecond * 6
            };

            POINT[][] pt =
            {
                new POINT[] { new POINT(0, -150), new POINT(100, 0), new POINT(0, 600), new POINT(-100, 0), new POINT(0, -150) },
                new POINT[] { new POINT(0, -200), new POINT(50, 0), new POINT(0, 800), new POINT(-50, 0), new POINT(0, -200), },
                new POINT[] { new POINT(0, 0), new POINT(0, 0), new POINT(0, 0), new POINT(0, 0), new POINT(0, 800) }
            };

            COLORREF color = GdiMethods.GetPenColor(dc.GetCurrentPen());
            bool erase = (color != new COLORREF());

#if GDIPLUS
            using (var graphics = GdiPlusMethods.CreateGraphics(dc))
            {
                if (erase)
                {
                    using (var brush = GdiPlusMethods.CreateSolidBrush(color))
                    {
                        GdiPlusMethods.FillEllipse(graphics, brush, -830, -830, 1660, 1660);
                    }
                    return;
                }

                using (var pen = GdiPlusMethods.CreatePen(color))
                {
                    GdiPlusMethods.SetSmoothingMode(graphics, SmoothingMode.HighQuality);

#endif

                    for (int i = fChange ? 0 : 2; i < 3; i++)
                    {
                        RotatePoint(pt[i], 5, iAngle[i]);

#if GDIPLUS
                        GdiPlusMethods.DrawLines(graphics, pen, pt[i]);
#else
                        dc.Polyline(pt[i]);
#endif
                    }
#if GDIPLUS
                }
            }
#endif
        }
예제 #4
0
 public static FontHandle CreateFont(
     int height,
     int width,
     int escapement,
     int orientation,
     FontWeight weight,
     bool italic,
     bool underline,
     bool strikeout,
     CharacterSet characterSet,
     OutputPrecision outputPrecision,
     ClippingPrecision clippingPrecision,
     Quality quality,
     FontPitch pitch,
     FontFamily family,
     string typeface) => GdiMethods.CreateFont(
     height, width, escapement, orientation, weight, italic, underline, strikeout, characterSet, outputPrecision, clippingPrecision, quality, pitch, family, typeface);
예제 #5
0
 public static PenHandle CreatePen(PenStyle style, int width, COLORREF color) => GdiMethods.CreatePen(style, width, color);
 public static bool DeviceToLogical(this DeviceContext deviceContext, params POINT[] points) => GdiMethods.DeviceToLogical(deviceContext, points);
예제 #7
0
 public static bool ClientToScreen(this WindowHandle window, ref POINT point) => GdiMethods.ClientToScreen(window, ref point);
예제 #8
0
 public static bool ValidateRectangle(this WindowHandle window, ref RECT rect) => GdiMethods.ValidateRectangle(window, ref rect);
예제 #9
0
 public static bool InvalidateRectangle(this WindowHandle window, RECT rect, bool erase = true) => GdiMethods.InvalidateRectangle(window, rect, erase);
예제 #10
0
 public static DeviceContext BeginPaint(this WindowHandle window, out PAINTSTRUCT paintStruct) => GdiMethods.BeginPaint(window, out paintStruct);
예제 #11
0
 public static DeviceContext GetWindowDeviceContext(this WindowHandle window) => GdiMethods.GetWindowDeviceContext(window);
 public static RegionType SelectClippingRegion(this DeviceContext deviceContext, RegionHandle region) => GdiMethods.SelectClippingRegion(deviceContext, region);
 public static MapMode SetMapMode(this DeviceContext deviceContext, MapMode mapMode) => GdiMethods.SetMapMode(deviceContext, mapMode);
 public static bool SetViewportExtents(this DeviceContext deviceContext, int x, int y) => GdiMethods.SetViewportExtents(deviceContext, x, y);
 public static bool OffsetViewportOrigin(this DeviceContext deviceContext, int x, int y) => GdiMethods.OffsetViewportOrigin(deviceContext, x, y);
 public static bool SetWindowOrigin(this DeviceContext deviceContext, int x, int y) => GdiMethods.SetWindowOrigin(deviceContext, x, y);
 public static bool LogicalToDevice(this DeviceContext deviceContext, params POINT[] points) => GdiMethods.LogicalToDevice(deviceContext, points);
예제 #18
0
 public static PenHandle CreatePen(PenStyleExtended style, uint width, COLORREF color, PenEndCap endCap = PenEndCap.Round, PenJoin join = PenJoin.Round)
 => GdiMethods.CreatePen(style, width, color, endCap, join);
 public static RegionType CombineRegion(this RegionHandle destination, RegionHandle sourceOne, RegionHandle sourceTwo, CombineRegionMode mode) =>
 GdiMethods.CombineRegion(destination, sourceOne, sourceTwo, mode);
예제 #20
0
 public static DeviceContext CreateInformationContext(string driver, string device) => GdiMethods.CreateInformationContext(driver, device);
예제 #21
0
 public static DeviceContext BeginPaint(this WindowHandle window) => GdiMethods.BeginPaint(window);
예제 #22
0
 public static RegionHandle CreateRectangleRegion(int left, int top, int right, int bottom) => GdiMethods.CreateRectangleRegion(left, top, right, bottom);
예제 #23
0
 public static bool Invalidate(this WindowHandle window, bool erase = true) => GdiMethods.Invalidate(window, erase);
예제 #24
0
 public static BrushHandle GetSystemColorBrush(SystemColor systemColor) => GdiMethods.GetSystemColorBrush(systemColor);
예제 #25
0
 public static bool UpdateWindow(this WindowHandle window) => GdiMethods.UpdateWindow(window);
 public static bool SetPixel(this DeviceContext deviceContext, POINT point, COLORREF color) => GdiMethods.SetPixel(deviceContext, point.x, point.y, color);
예제 #27
0
 public static bool ScreenToClient(this WindowHandle window, ref POINT point) => GdiMethods.ScreenToClient(window, ref point);
예제 #28
0
 public static BrushHandle CreateSolidBrush(COLORREF color) => GdiMethods.CreateSolidBrush(color.R, color.G, color.B);
예제 #29
0
 public static BrushHandle CreateSolidBrush(byte red, byte green, byte blue) => GdiMethods.CreateSolidBrush(red, green, blue);
 public static bool SetPixel(this DeviceContext deviceContext, int x, int y, COLORREF color) => GdiMethods.SetPixel(deviceContext, x, y, color);