Beispiel #1
0
 public static bool Fill(Graphics gr, Rectangle rc, Color startColor, Color middleColor1, Color middleColor2, Color endColor, FillDirection fillDirection)
 {
     bool flag = (middleColor1 != Color.Transparent) | (middleColor2 != Color.Transparent);
     int num = 2;
     if (flag)
     {
         num += 2;
     }
     Win32Helper.TRIVERTEX[] pVertex = new Win32Helper.TRIVERTEX[num];
     pVertex[0] = new Win32Helper.TRIVERTEX(rc.X, rc.Y, startColor);
     if (flag)
     {
         if (middleColor1 == Color.Transparent)
         {
             middleColor1 = middleColor2;
         }
         if (middleColor2 == Color.Transparent)
         {
             middleColor2 = middleColor1;
         }
         if (fillDirection == FillDirection.Horizontal)
         {
             pVertex[1] = new Win32Helper.TRIVERTEX(rc.X + (rc.Width / 2), rc.Bottom, middleColor1);
             pVertex[2] = new Win32Helper.TRIVERTEX(rc.X + (rc.Width / 2), rc.Y, middleColor2);
         }
         else
         {
             pVertex[1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Y + (rc.Height / 2), middleColor1);
             pVertex[2] = new Win32Helper.TRIVERTEX(rc.X, rc.Y + (rc.Height / 2), middleColor2);
         }
     }
     pVertex[num - 1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Bottom, endColor);
     Win32Helper.GRADIENT_RECT[] pMesh = null;
     if (flag)
     {
         pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1), new Win32Helper.GRADIENT_RECT(2, 3) };
     }
     else
     {
         pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1) };
     }
     IntPtr hdc = gr.GetHdc();
     bool flag2 = false;
     try
     {
         flag2 = Win32Helper.GradientFill(hdc, pVertex, (uint) pVertex.Length, pMesh, (uint) pMesh.Length, (uint) fillDirection);
         gr.ReleaseHdc(hdc);
     }
     catch (Exception)
     {
         gr.ReleaseHdc(hdc);
         if (Environment.OSVersion.Platform == PlatformID.WinCE)
         {
             gr.FillRectangle(GetBrush(startColor), rc);
             return true;
         }
         try
         {
             try
             {
                 Assembly.Load("Resco.AdvancedComboBox.Design, Version=" + GetAssemblyVersion() + ", Culture=neutral, PublicKeyToken=7444f602060105f9").GetType("Resco.Controls.AdvancedComboBox.Design.AdvancedComboBoxDesigner").GetMethod("DesignerGradientFill", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(Graphics), typeof(Rectangle), typeof(Color), typeof(Color), typeof(Color), typeof(Color), typeof(FillDirection) }, null).Invoke(null, new object[] { gr, rc, startColor, middleColor1, middleColor2, endColor, fillDirection });
             }
             catch (Exception)
             {
                 gr.FillRectangle(GetBrush(startColor), rc);
             }
             return flag2;
         }
         finally
         {
             flag2 = true;
         }
     }
     return flag2;
 }
Beispiel #2
0
        public static bool Fill(Graphics gr, Rectangle rc, Color startColor, Color middleColor1, Color middleColor2, Color endColor, FillDirection fillDirection)
        {
            bool flag = (middleColor1 != Color.Transparent) | (middleColor2 != Color.Transparent);
            int  num  = 2;

            if (flag)
            {
                num += 2;
            }
            Win32Helper.TRIVERTEX[] pVertex = new Win32Helper.TRIVERTEX[num];
            pVertex[0] = new Win32Helper.TRIVERTEX(rc.X, rc.Y, startColor);
            if (flag)
            {
                if (middleColor1 == Color.Transparent)
                {
                    middleColor1 = middleColor2;
                }
                if (middleColor2 == Color.Transparent)
                {
                    middleColor2 = middleColor1;
                }
                if (fillDirection == FillDirection.Horizontal)
                {
                    pVertex[1] = new Win32Helper.TRIVERTEX(rc.X + (rc.Width / 2), rc.Bottom, middleColor1);
                    pVertex[2] = new Win32Helper.TRIVERTEX(rc.X + (rc.Width / 2), rc.Y, middleColor2);
                }
                else
                {
                    pVertex[1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Y + (rc.Height / 2), middleColor1);
                    pVertex[2] = new Win32Helper.TRIVERTEX(rc.X, rc.Y + (rc.Height / 2), middleColor2);
                }
            }
            pVertex[num - 1] = new Win32Helper.TRIVERTEX(rc.Right, rc.Bottom, endColor);
            Win32Helper.GRADIENT_RECT[] pMesh = null;
            if (flag)
            {
                pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1), new Win32Helper.GRADIENT_RECT(2, 3) };
            }
            else
            {
                pMesh = new Win32Helper.GRADIENT_RECT[] { new Win32Helper.GRADIENT_RECT(0, 1) };
            }
            IntPtr hdc   = gr.GetHdc();
            bool   flag2 = false;

            try
            {
                flag2 = Win32Helper.GradientFill(hdc, pVertex, (uint)pVertex.Length, pMesh, (uint)pMesh.Length, (uint)fillDirection);
                gr.ReleaseHdc(hdc);
            }
            catch (Exception)
            {
                gr.ReleaseHdc(hdc);
                if (Environment.OSVersion.Platform == PlatformID.WinCE)
                {
                    gr.FillRectangle(GetBrush(startColor), rc);
                    return(true);
                }
                try
                {
                    try
                    {
                        Assembly.Load("Resco.AdvancedComboBox.Design, Version=" + GetAssemblyVersion() + ", Culture=neutral, PublicKeyToken=7444f602060105f9").GetType("Resco.Controls.AdvancedComboBox.Design.AdvancedComboBoxDesigner").GetMethod("DesignerGradientFill", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(Graphics), typeof(Rectangle), typeof(Color), typeof(Color), typeof(Color), typeof(Color), typeof(FillDirection) }, null).Invoke(null, new object[] { gr, rc, startColor, middleColor1, middleColor2, endColor, fillDirection });
                    }
                    catch (Exception)
                    {
                        gr.FillRectangle(GetBrush(startColor), rc);
                    }
                    return(flag2);
                }
                finally
                {
                    flag2 = true;
                }
            }
            return(flag2);
        }