Example #1
0
            public static bool Fill(
                Graphics gr, Rectangle rc,
                Color startColor, Color endColor,
                FillDirection fillDir)
            {
                if (System.Environment.OSVersion.Platform != PlatformID.WinCE)
                {
                    using (SolidBrush br = new SolidBrush(startColor))
                    {
                        gr.FillRectangle(br, rc);
                    }
                    return true;
                }

                // 頂点の座標と色を指定
                Win32Helper.TRIVERTEX[] tva = new Win32Helper.TRIVERTEX[2];
                tva[0] = new Win32Helper.TRIVERTEX(rc.X, rc.Y, startColor);
                tva[1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Bottom, endColor);

                // どのTRIVERTEXの値を使用するかインデックスを指定
                Win32Helper.GRADIENT_RECT[] gra
                    = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1) };

                // GradientFill関数の呼び出し
                IntPtr hdc = gr.GetHdc();
                bool b = Win32Helper.GradientFill(
                    hdc, tva, (uint)tva.Length,
                    gra, (uint)gra.Length, (uint)fillDir);
                gr.ReleaseHdc(hdc);
                return b;
            }
Example #2
0
            public static bool Fill(
                Graphics gr, Rectangle rc,
                Color startColor, Color endColor,
                FillDirection fillDir)
            {
                // 頂点の座標と色を指定
                Win32Helper.TRIVERTEX[] tva = new Win32Helper.TRIVERTEX[2];
                tva[0] = new Win32Helper.TRIVERTEX(rc.X, rc.Y, startColor);
                tva[1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Bottom, endColor);

                // どのTRIVERTEXの値を使用するかインデックスを指定
                Win32Helper.GRADIENT_RECT[] gra
                    = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1) };

                // GradientFill関数の呼び出し
                IntPtr hdc = gr.GetHdc();
                bool b = Win32Helper.GradientFill(
                    hdc, tva, (uint)tva.Length,
                    gra, (uint)gra.Length, (uint)fillDir);
                gr.ReleaseHdc(hdc);
                return b;
            }