Esempio n. 1
0
 public static extern bool GradientFill(
     IntPtr          hdc,
     TRIVERTEX[]     pVertex,
     uint            dwNumVertex,
     GRADIENT_RECT[] pMesh,
     uint            dwNumMesh,
     uint            dwMode
     );
Esempio n. 2
0
        public static void GradientFill(Graphics g, Rectangle rect, Color startColor, Color endColor, FillDirection fillDir)
        {
            TRIVERTEX[] vertex = new TRIVERTEX[]
            {
                new TRIVERTEX(rect.X, rect.Y, startColor),
                new TRIVERTEX(rect.Right, rect.Bottom, endColor)
            };
            GRADIENT_RECT[] grect = new GRADIENT_RECT[] {
                new GRADIENT_RECT(0, 1)
            };

            IntPtr hdc = g.GetHdc();

            GradientFill(hdc, vertex, (uint)vertex.Length, grect, (uint)grect.Length, (uint)fillDir);
            g.ReleaseHdc(hdc);
        }
Esempio n. 3
0
        public static void DrawGradientFill(int dwColour1, int dwColour2, Form myFrm)
        {
            TRIVERTEX[]   vert = new TRIVERTEX[2];
            GRADIENT_RECT grRc = new GRADIENT_RECT();

            //Colour at upper-left corner
            TRIVERTEX with_1 = vert[0];

            with_1.x     = 0;
            with_1.Y     = 0;
            with_1.Red   = LongToSignedShort(((short)(dwColour1 & 0xFF)) * 256);
            with_1.Green = LongToSignedShort(System.Convert.ToInt32(((dwColour1 & 0xFF00) / 0x100) * 256));
            with_1.Blue  = LongToSignedShort(System.Convert.ToInt32(((dwColour1 & 0xFF0000) / 0x10000) * 256));
            with_1.Alpha = (short)0;


            //Colour at bottom-right corner
            TRIVERTEX with_2 = vert[1];

            ///with_2.x = System.Convert.ToInt32(Microsoft.VisualBasic.Compatibility.VB6.Support.PixelsToTwipsX(myFrm.ClientRectangle.Width) / Microsoft.VisualBasic.Compatibility.VB6.Support.TwipsPerPixelX());
            ///with_2.Y = System.Convert.ToInt32(Microsoft.VisualBasic.Compatibility.VB6.Support.PixelsToTwipsY(myFrm.ClientRectangle.Height) / Microsoft.VisualBasic.Compatibility.VB6.Support.TwipsPerPixelY());
            with_2.Red   = LongToSignedShort(((short)(dwColour2 & 0xFF)) * 256);
            with_2.Green = LongToSignedShort(System.Convert.ToInt32(((dwColour2 & 0xFF00) / 0x100) * 256));
            with_2.Blue  = LongToSignedShort(System.Convert.ToInt32(((dwColour2 & 0xFF0000) / 0x10000) * 256));
            with_2.Alpha = (short)0;

            grRc.LowerRight = 0;
            grRc.UpperLeft  = 1;

            myFrm = new Form();
            myFrm.Show();

            //parameters:
            //hdc - display context handle of the target window
            //vert(0) - first member of interest in the vert() array
            //2 - number of vert() array members (not ubound(vert))
            //grRc - GRADIENT_RECT info
            //1 - number of grRc structures passed
            //GRADIENT_FILL_RECT_DIRECTION - fill operation -
            //will toggle between 0 and 1, the values of
            //GRADIENT_FILL_RECT_H and GRADIENT_FILL_RECT_V.
            ///	GradientFill(myFrm.CreateGraphics().GetHdc().ToInt32(), ref vert[0], 2, ref grRc, 1, System.Math.Abs(GRADIENT_FILL_RECT_DIRECTION));
        }
Esempio n. 4
0
        public void FillRect(Rect rect, Color color1, Color color2, bool horizontalGradient)
        {
            TRIVERTEX[] points = new TRIVERTEX[] { new TRIVERTEX(), new TRIVERTEX() };

            points[0].x     = rect.left;
            points[0].y     = rect.top;
            points[0].Red   = Convert.ToInt16(color1.Red << 8);
            points[0].Green = Convert.ToInt16(color1.Green << 8);
            points[0].Blue  = Convert.ToInt16(color1.Blue << 8);

            points[1].x     = rect.right;
            points[1].y     = rect.bottom;
            points[1].Red   = Convert.ToInt16(color2.Red << 8);
            points[1].Green = Convert.ToInt16(color2.Green << 8);
            points[1].Blue  = Convert.ToInt16(color2.Blue << 8);

            GRADIENT_RECT gradientRect = new GRADIENT_RECT(0, 1);

            NativeMethods.GradientFill(Handle, points, 2, ref gradientRect, 1, horizontalGradient ? 0 : 1);
        }
Esempio n. 5
0
 public static extern bool GradientFill(IntPtr hdc, IntPtr pVertex, uint dwNumVertex, [In] ref GRADIENT_RECT pMesh, uint dwNumMesh, uint dwMode);
 internal static extern bool GdiGradientFill(IntPtr hdc, TRIVERTEX[] pVertex, int nVertex, ref GRADIENT_RECT pMesh, int nCount, InTheHand.Drawing.Drawing2D.LinearGradientMode ulMode);
Esempio n. 7
0
 public static extern bool GradientFill(IntPtr hdc, TRIVERTEX[] pVertex, uint nVertex, GRADIENT_RECT[] pMesh, uint nCount, uint ulMode);
Esempio n. 8
0
 private static extern Int32 GradientFill(
     IntPtr hdc, TRIVERTEX[] pVertex,
     uint dwNumVertex,
     GRADIENT_RECT[] pMesh,
     uint dwNumMesh,
     uint dwMode);
Esempio n. 9
0
        public static void GradientFill(Graphics g, Rectangle rect, Color startColor, Color endColor, FillDirection fillDir)
        {
            TRIVERTEX[] vertex = new TRIVERTEX[]
            {
                new TRIVERTEX(rect.X,rect.Y,startColor),
                new TRIVERTEX(rect.Right,rect.Bottom,endColor)
            };
            GRADIENT_RECT[] grect = new GRADIENT_RECT[] {
                new GRADIENT_RECT(0,1)
            };

            IntPtr hdc = g.GetHdc();
            GradientFill(hdc, vertex, (uint)vertex.Length, grect, (uint)grect.Length, (uint)fillDir);
            g.ReleaseHdc(hdc);
        }