示例#1
0
        private void CreatePen()
        {
            if (width > 1)    // Geometric pen.
            {
                // From MSDN: if width > 1, the style must be PS_NULL, PS_SOLID, or PS_INSIDEFRAME.
                style |= WindowsPenStyle.Geometric | WindowsPenStyle.Solid;
            }

            if (wndBrush == null)
            {
                nativeHandle = SafeNativeMethods.CreatePen((int)style, width, ColorTranslator.ToWin32(color));
            }
            else
            {
                NativeMethods.LOGBRUSH lb = new NativeMethods.LOGBRUSH
                {
                    lbColor = ColorTranslator.ToWin32(wndBrush.Color),
                    lbStyle = IntNativeMethods.BS_SOLID,
                    lbHatch = IntPtr.Zero
                };

                // Note: We currently don't support custom styles, that's why 0 and null for last two params.
                nativeHandle = SafeNativeMethods.ExtCreatePen((int)style, width, ref lb, 0, null);
            }
        }
示例#2
0
        public static IntPtr CreateHalftoneBrush()
        {
            short[] numArray1 = new short[8];
            for (int num1 = 0; num1 < 8; num1++)
            {
                numArray1[num1] = (short)(0x5555 << ((num1 & 1) & 0x1f));
            }
            IntPtr ptr1 = NativeMethods.CreateBitmap(8, 8, 1, 1, numArray1);

            NativeMethods.LOGBRUSH logbrush1 = new NativeMethods.LOGBRUSH();
            logbrush1.lbColor = ColorTranslator.ToWin32(Color.Black);
            logbrush1.lbStyle = 3;
            logbrush1.lbHatch = ptr1;
            IntPtr ptr2 = NativeMethods.CreateBrushIndirect(logbrush1);

            NativeMethods.DeleteObject(new HandleRef(null, ptr1));
            return(ptr2);
        }
        internal IntPtr CreateHalftoneHBRUSH()
        {
            short[] array = new short[8];
            for (int i = 0; i < 8; i++)
            {
                array[i] = (short)(21845 << (i & 1));
            }
            IntPtr intPtr = SafeNativeMethods.CreateBitmap(8, 8, 1, 1, array);

            NativeMethods.LOGBRUSH lOGBRUSH = new NativeMethods.LOGBRUSH();
            lOGBRUSH.lbColor = ColorTranslator.ToWin32(Color.Black);
            lOGBRUSH.lbStyle = 3;
            lOGBRUSH.lbHatch = intPtr;
            IntPtr result = SafeNativeMethods.CreateBrushIndirect(lOGBRUSH);

            SafeNativeMethods.DeleteObject(new HandleRef(null, intPtr));
            return(result);
        }
示例#4
0
 public static IntPtr CreateBrushIndirect(NativeMethods.LOGBRUSH lb)
 {
     return(System.Internal.HandleCollector.Add(IntCreateBrushIndirect(lb), NativeMethods.CommonHandles.GDI));
 }
示例#5
0
 private static extern IntPtr IntCreateBrushIndirect(NativeMethods.LOGBRUSH lb);
示例#6
0
 public static extern IntPtr ExtCreatePen(int fnStyle, int dwWidth, ref NativeMethods.LOGBRUSH lplb, int dwStyleCount, int[] lpStyle);
示例#7
0
 public static extern IntPtr CreateBrushIndirect(ref NativeMethods.LOGBRUSH lb);