예제 #1
0
        public Pen(Color color, int width, PenEndCapStyle capStyle = PenEndCapStyle.Round, PenJoinCapStyle joinStyle = PenJoinCapStyle.Round)
        {
            int styleValue = 0;

            switch (capStyle)
            {
            case PenEndCapStyle.Round: styleValue |= GDIConstants.PS_ENDCAP_ROUND; break;

            case PenEndCapStyle.Flat: styleValue |= GDIConstants.PS_ENDCAP_FLAT; break;

            case PenEndCapStyle.Square: styleValue |= GDIConstants.PS_ENDCAP_SQUARE; break;
            }
            switch (joinStyle)
            {
            case PenJoinCapStyle.Round: styleValue |= GDIConstants.PS_JOIN_ROUND; break;

            case PenJoinCapStyle.Bevel: styleValue |= GDIConstants.PS_JOIN_BEVEL; break;

            case PenJoinCapStyle.Miter: styleValue |= GDIConstants.PS_JOIN_MITER; break;
            }

            LOGBRUSH brush = new LOGBRUSH();

            brush.lbColor = Color.ToWin32Color(color);
            Handle        = NativeMethods.ExtCreatePen(styleValue, width, ref brush, 0, Array.Empty <int>());
        }
예제 #2
0
        private static IntPtr GetHalfToneBrush()
        {
            if (m_halfToneBrush == IntPtr.Zero)
            {
                Bitmap bitmap = new Bitmap(8, 8, PixelFormat.Format32bppArgb);

                Color white = Color.FromArgb(255, 255, 255, 255);
                Color black = Color.FromArgb(255, 0, 0, 0);

                bool flag = true;

                // Alternate black and white pixels across all lines
                for (int x = 0; x < 8; x++, flag = !flag)
                {
                    for (int y = 0; y < 8; y++, flag = !flag)
                    {
                        bitmap.SetPixel(x, y, (flag ? white : black));
                    }
                }

                IntPtr hBitmap = bitmap.GetHbitmap();

                LOGBRUSH brush = new LOGBRUSH();

                brush.lbStyle = (uint)Win32.BrushStyles.BS_PATTERN;
                brush.lbHatch = (uint)hBitmap;

                m_halfToneBrush = Gdi32.CreateBrushIndirect(ref brush);
                Gdi32.DeleteObject(hBitmap);
            }

            return(m_halfToneBrush);
        }
예제 #3
0
 public static extern int ExtCreatePen(
     int dwPenStyle,
     int dwWidth,
     ref LOGBRUSH lplb,
     int dwStyleCount,
     ref int lpStyle
     );
        IntPtr CreateLineBrush()
        {
            short[] grayPattern = new short[8];
            for (int i = 0; i < 2; i++)
            {
                grayPattern[i] = 0xff;
            }
            IntPtr   hBitmap = CreateBitmap(2, 2, 1, 1, grayPattern);
            LOGBRUSH lb      = new LOGBRUSH(BS_PATTERN, 0, hBitmap);
            IntPtr   brush   = CreateBrushIndirect(lb);

            DeleteObject(hBitmap);
            return(brush);
        }
        IntPtr CreateSplitBrush()
        {
            short[] grayPattern = new short[8];
            for (int i = 0; i < 8; i++)
            {
                grayPattern[i] = (short)(0x5555 << (i & 1));
            }
            IntPtr   hBitmap = CreateBitmap(8, 8, 1, 1, grayPattern);
            LOGBRUSH lb      = new LOGBRUSH(BS_PATTERN, 0, hBitmap);
            IntPtr   brush   = CreateBrushIndirect(lb);

            DeleteObject(hBitmap);
            return(brush);
        }
예제 #6
0
        public static PenHandle CreatePen(PenStyleExtended style, uint width, COLORREF color, PenEndCap endCap = PenEndCap.Round, PenJoin join = PenJoin.Round)
        {
            LOGBRUSH brush = new LOGBRUSH
            {
                lbColor = color,
                lpStyle = BrushStyle.Solid
            };

            return(Imports.ExtCreatePen(
                       (uint)style | (uint)PenType.Geometric | (uint)endCap | (uint)join,
                       width,
                       ref brush,
                       0,
                       null));
        }
예제 #7
0
        public static IntPtr CreateExtPen(HCPen aPen)
        {
            LOGBRUSH vPenParams = new LOGBRUSH();

            switch (aPen.Style)
            {
            case HCPenStyle.psSolid:
            case HCPenStyle.psInsideFrame:
                vPenParams.lbStyle = GDI.PS_SOLID;
                break;

            case HCPenStyle.psDash:
                vPenParams.lbStyle = GDI.PS_DASH;
                break;

            case HCPenStyle.psDot:
                vPenParams.lbStyle = GDI.PS_DOT;
                break;

            case HCPenStyle.psDashDot:
                vPenParams.lbStyle = GDI.PS_DASHDOT;
                break;

            case HCPenStyle.psDashDotDot:
                vPenParams.lbStyle = GDI.PS_DASHDOTDOT;
                break;

            case HCPenStyle.psClear:
                vPenParams.lbStyle = GDI.PS_NULL;
                break;

            default:
                vPenParams.lbStyle = GDI.PS_SOLID;
                break;
            }

            vPenParams.lbColor = aPen.Color.ToRGB_UInt();
            vPenParams.lbHatch = 0;

            if (aPen.Width != 1)
            {
                return((IntPtr)(GDI.ExtCreatePen(GDI.PS_GEOMETRIC | GDI.PS_ENDCAP_SQUARE, aPen.Width, ref vPenParams, 0, IntPtr.Zero)));
            }
            else
            {
                return((IntPtr)(GDI.ExtCreatePen(GDI.PS_COSMETIC | GDI.PS_ENDCAP_SQUARE, aPen.Width, ref vPenParams, 0, IntPtr.Zero)));
            }
        }
예제 #8
0
파일: GDI.cs 프로젝트: dotnetchris/nfx
 public static extern IntPtr CreateBrushIndirect([In] ref LOGBRUSH lplb);
예제 #9
0
 public static extern IntPtr CreateBrushIndirect(ref LOGBRUSH brush);
예제 #10
0
 public static extern IntPtr ExtCreatePen(uint iPenStyle, uint cWidth, [In] ref LOGBRUSH plbrush, uint cStyle, [In] IntPtr pstyle);
예제 #11
0
 public static extern IntPtr CreateBrushIndirect(ref LOGBRUSH brush);
예제 #12
0
 public static extern IntPtr ExtCreatePen(int style, int nWidth, LOGBRUSH logbrush, int styleArrayLength, int[] styleArray);
예제 #13
0
 public HCBrush()
 {
     FLogBrush = new LOGBRUSH();
     ReCreateHandle();
 }
예제 #14
0
 static extern IntPtr CreateBrushIndirect(LOGBRUSH lb);
예제 #15
0
 public static extern Win32ObjectSafeHandle ExtCreatePen(uint dwPenStyle, uint dwWidth, ref LOGBRUSH lplb, uint dwStyleCount, [In][Out] uint[] lpStyle);
예제 #16
0
파일: GDI.cs 프로젝트: itadapter/nfx
 static extern IntPtr ExtCreatePen(UInt32 dwPenStyle, UInt32 dwWidth, ref LOGBRUSH lplb, UInt32 dwStyleCount, UInt32[] lpStyle);
예제 #17
0
파일: GDI.cs 프로젝트: dotnetchris/nfx
 static extern IntPtr ExtCreatePen(UInt32 dwPenStyle, UInt32 dwWidth, ref LOGBRUSH lplb, UInt32 dwStyleCount, UInt32[] lpStyle);
예제 #18
0
파일: GDI.cs 프로젝트: ventor3000/guppy2
 internal static extern IntPtr ExtCreatePen(PenStyle dwPenStyle, uint dwWidth,
                                            [In] ref LOGBRUSH lplb, uint dwStyleCount, uint[] lpStyle);
예제 #19
0
 public static extern PenHandle ExtCreatePen(
     uint dwPenStyle,
     uint dwWidth,
     [In] ref LOGBRUSH lplb,
     uint dwStyleCount,
     uint[] lpStyle);
예제 #20
0
 public static extern IntPtr ExtCreatePen(int style, int nWidth, LOGBRUSH logbrush, int styleArrayLength, int[] styleArray);
예제 #21
0
 public static IntPtr CreateBrushIndirect(LOGBRUSH lpLogBrush)
 {
     NotImplemented(MethodBase.GetCurrentMethod());
     return(IntPtr.Zero);
 }
예제 #22
0
 public unsafe static extern HPEN ExtCreatePen(PS fnStyle, int dwWidth, ref LOGBRUSH lplb, uint dwStyleCount, uint *lpStyle);
 public static extern HBRUSH CreateBrushIndirect(ref LOGBRUSH lb);