Example #1
0
        internal static bool IsDarker(Color c1, Color c2)
        {
            var hc1 = new HLSColor(c1);
            var hc2 = new HLSColor(c2);

            return(hc1.Luminosity < hc2.Luminosity);
        }
        /// <summary>
        /// 颜色c1,相对c2是否为暗色
        /// </summary>
        /// <param name="c1">颜色c1</param>
        /// <param name="c2">颜色c2</param>
        /// <returns>是否为暗</returns>
        private static bool IsDarker(Color c1, Color c2)
        {
            HLSColor color  = new HLSColor(c1);
            HLSColor color2 = new HLSColor(c2);

            return(color.Luminosity < color2.Luminosity);
        }
        internal void AddPlayerColor(String player, Color color)
        {
            ColorHls hlsValue = HLSColor.RgbToHls(color);

            this.PlayerBrushes[player] = new List <Brush>();
            this.PlayerBrushes[player].Add(new SolidColorBrush(HLSColor.HlsToRgb(hlsValue.H, Math.Min(1d, hlsValue.L * 1.1), hlsValue.S, hlsValue.A)));
            this.PlayerBrushes[player].Add(new SolidColorBrush(HLSColor.HlsToRgb(hlsValue.H, Math.Min(1d, hlsValue.L * 1.125), hlsValue.S * 0.95, hlsValue.A)));
            this.PlayerBrushes[player].Add(new SolidColorBrush(HLSColor.HlsToRgb(hlsValue.H, hlsValue.L * 0.25, hlsValue.S, hlsValue.A)));
            this.PlayerBrushes[player].ForEach((b) => b.Freeze());
        }
        public ucPlayerSettings()
        {
            InitializeComponent();

            scpTint.Clear();
            for (int h = 0; h < 15; h++)
            {
                scpTint.AddColor(HLSColor.HlsToRgb(24 * h, 0.85, 1, 1));
            }
            scpTint.AddColor(Colors.Transparent);
        }
            public override bool Equals(object o)
            {
                if (!(o is HLSColor))
                {
                    return(false);
                }

                HLSColor c = (HLSColor)o;

                return(_hue == c._hue &&
                       _saturation == c._saturation &&
                       Luminosity == c.Luminosity &&
                       _isSystemColors_Control == c._isSystemColors_Control);
            }
            public override bool Equals(object?o)
            {
                if (o is not HLSColor hlsColor)
                {
                    return(false);
                }

                HLSColor c = hlsColor;

                return(_hue == c._hue &&
                       _saturation == c._saturation &&
                       Luminosity == c.Luminosity &&
                       _isSystemColors_Control == c._isSystemColors_Control);
            }
Example #7
0
            /// <summary>
            /// 是否相等
            /// </summary>
            /// <param name="o">要比较的对象</param>
            /// <returns>相等返回true,否则返回false</returns>
            public override bool Equals(object o)
            {
                if (!(o is HLSColor))
                {
                    return(false);
                }

                HLSColor c = (HLSColor)o;

                return(hue == c.hue &&
                       saturation == c.saturation &&
                       luminosity == c.luminosity &&
                       isSystemColors_Control == c.isSystemColors_Control);
            }
            public override bool Equals(object o)
            {
                bool result;

                if (!(o is HLSColor))
                {
                    result = false;
                }
                else
                {
                    HLSColor color = (HLSColor)o;
                    result = (this.hue == color.hue && this.saturation == color.saturation && this.luminosity == color.luminosity);
                }
                return(result);
            }
Example #9
0
        public static Windows.UI.Color UpdateTint(Windows.UI.Color baseColor, float tint)
        {
            if (tint == 0.0)
            {
                return(baseColor);
            }
            HLSColor color = new HLSColor(baseColor);

            if (tint > 0f)
            {
                int   num  = 240 - color.Luminosity;
                float num2 = num * tint;
                return(ColorFromHLS(color.Hue, color.Luminosity + ((int)num2), color.Saturation));
            }
            float num3 = color.Luminosity * -tint;

            return(ColorFromHLS(color.Hue, color.Luminosity - ((int)num3), color.Saturation));
        }
Example #10
0
        private static void DrawBorderComplex(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style)
        {
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }

            borderPen1.DashStyle = DashStyle.Solid;

            if (style == ButtonBorderStyle.Inset)
            { // button being pushed
                var hls = new HLSColor(color);

                // top + left
                borderPen1.Color = hls.Darker(1.0f);
                graphics.DrawLine(borderPen1, bounds.X, bounds.Y, bounds.X + bounds.Width - 1, bounds.Y);
                graphics.DrawLine(borderPen1, bounds.X, bounds.Y, bounds.X, bounds.Y + bounds.Height - 1);

                // bottom + right
                borderPen1.Color = hls.Lighter(1.0f);
                graphics.DrawLine(borderPen1, bounds.X, bounds.Y + bounds.Height - 1, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
                graphics.DrawLine(borderPen1, bounds.X + bounds.Width - 1, bounds.Y, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);

                // Top + left inset
                borderPen1.Color = hls.Lighter(0.5f);
                graphics.DrawLine(borderPen1, bounds.X + 1, bounds.Y + 1, bounds.X + bounds.Width - 2, bounds.Y + 1);
                graphics.DrawLine(borderPen1, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Y + bounds.Height - 2);

                // bottom + right inset
                if (color == SystemColors.Control)
                {
                    borderPen1.Color = SystemColors.ControlLight;
                    graphics.DrawLine(borderPen1, bounds.X + 1, bounds.Y + bounds.Height - 2, bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                    graphics.DrawLine(borderPen1, bounds.X + bounds.Width - 2, bounds.Y + 1, bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                }
            }
            else
            {
                // Standard button
                bool stockColor = color == SystemColors.Control;
                var  hls        = new HLSColor(color);

                // top + left
                borderPen1.Color = stockColor ? SystemColors.ControlLightLight : hls.Lighter(1.0f);
                graphics.DrawLine(borderPen1, bounds.X, bounds.Y, bounds.X + bounds.Width - 1, bounds.Y);
                graphics.DrawLine(borderPen1, bounds.X, bounds.Y, bounds.X, bounds.Y + bounds.Height - 1);

                // bottom + right
                borderPen1.Color = stockColor ? SystemColors.ControlDarkDark : hls.Darker(1.0f);
                graphics.DrawLine(borderPen1, bounds.X, bounds.Y + bounds.Height - 1, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
                graphics.DrawLine(borderPen1, bounds.X + bounds.Width - 1, bounds.Y, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);

                // top + left inset
                if (stockColor)
                {
                    borderPen1.Color = SystemInformation.HighContrast ? SystemColors.ControlLight : SystemColors.Control;
                }
                else
                {
                    borderPen1.Color = color;
                }

                graphics.DrawLine(borderPen1, bounds.X + 1, bounds.Y + 1, bounds.X + bounds.Width - 2, bounds.Y + 1);
                graphics.DrawLine(borderPen1, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Y + bounds.Height - 2);

                // Bottom + right inset
                borderPen1.Color = stockColor ? SystemColors.ControlDark : hls.Darker(0.5f);
                graphics.DrawLine(borderPen1, bounds.X + 1, bounds.Y + bounds.Height - 2, bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                graphics.DrawLine(borderPen1, bounds.X + bounds.Width - 2, bounds.Y + 1, bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
            }
        }
Example #11
0
        //public struct RGBColor
        //{
        //    public int Red;
        //    public int Green;
        //    public int Blue;
        //}
        public static HLSColor RGBToHSL(int Red, int Green, int Blue)
        {
            double Max, Min, delta;
            double rR, rG, rB;
            HLSColor ret = new HLSColor();

            rR = (double)Red / 255;
            rG = (double)Green / 255;
            rB = (double)Blue / 255;

            // Given: rgb each in [0,1].
            // Desired: h in [0,360] and s in [0,1], except if s=0, then h=UNDEFINED.}
            Max = Maximum(rR, rG, rB);
            Min = Minimum(rR, rG, rB);
            delta = Max - Min;
            ret.Lightness = (Max + Min) / 2;    // {This is the lightness}
            // {Next calculate saturation}

            if (Max == Min)
            {
                // begin {Acrhomatic case}
                ret.Saturation = 0;
                ret.Hue = 0;
                // end {Acrhomatic case}	
            }
            else
            {
                // begin {Chromatic case}
                // {First calculate the saturation.}
                if (ret.Lightness <= 0.5)
                    ret.Saturation = (Max - Min) / (Max + Min);
                else
                    ret.Saturation = (Max - Min) / (2 - Max - Min);
                // {Next calculate the hue.}
                
                double delr = (((Max - rR) / 6) + (delta / 2)) / delta;
                double delg = (((Max - rG) / 6) + (delta / 2)) / delta;
                double delb = (((Max - rB) / 6) + (delta / 2)) / delta;

                if (rR == Max)
                    ret.Hue = delb - delg;		//{Resulting color is between yellow and magenta}
                else if (rG == Max)
                    ret.Hue = (1d / 3d) + delr - delb;	// {Resulting color is between cyan and yellow}
                else if (rB == Max)
                    ret.Hue = (2d / 3d) + delg - delr;;	// {Resulting color is between magenta and cyan}

                if (ret.Hue < 0) ret.Hue += 1;
                if (ret.Hue > 1) ret.Hue -= 1;
            }
            return ret;
        }
        public static Color Dark(this Color baseColor)
        {
            HLSColor color = new HLSColor(baseColor);

            return(color.Darker(0.5f));
        }
 public static Color Light(Color baseColor, float percOfLightLight)
 {
     HLSColor color = new HLSColor(baseColor);
     return color.Lighter(percOfLightLight);
 }
 public static Color Dark(Color baseColor, float percOfDarkDark)
 {
     HLSColor color = new HLSColor(baseColor);
     return color.Darker(percOfDarkDark);
 }
Example #15
0
 internal static Windows.UI.Color UpdateColor(Color color, SpreadDrawingColorSettings drawingColorSettings, bool updateTint)
 {
     if (drawingColorSettings != null)
     {
         double?alpha = drawingColorSettings.alpha;
         if (alpha.HasValue)
         {
             color = Windows.UI.Color.FromArgb((byte)((alpha.Value / 100000.0) * 255.0), color.R, color.G, color.B);
         }
         double?shade = drawingColorSettings.shade;
         if (shade.HasValue)
         {
             float num = ((float)shade.Value) / 100000f;
             byte  r   = (byte)(num * color.R);
             byte  g   = (byte)(num * color.G);
             byte  b   = (byte)(num * color.B);
             color = Windows.UI.Color.FromArgb(color.A, r, g, b);
         }
         if (updateTint)
         {
             double?tint = drawingColorSettings.tint;
             if (tint.HasValue)
             {
                 float num5 = ((float)tint.Value) / 100000f;
                 byte  num6 = (byte)((num5 * color.R) + ((1f - num5) * 255f));
                 byte  num7 = (byte)((num5 * color.G) + ((1f - num5) * 255f));
                 byte  num8 = (byte)((num5 * color.B) + ((1f - num5) * 255f));
                 color = Windows.UI.Color.FromArgb(color.A, num6, num7, num8);
             }
         }
         double?hue    = drawingColorSettings.hue;
         double?hueOff = drawingColorSettings.hueOff;
         double?hueMod = drawingColorSettings.hueMod;
         double?sat    = drawingColorSettings.sat;
         double?satOff = drawingColorSettings.satOff;
         double?satMod = drawingColorSettings.satMod;
         double?lum    = drawingColorSettings.lum;
         double?lumOff = drawingColorSettings.lumOff;
         double?lumMod = drawingColorSettings.lumMod;
         if (((!hue.HasValue && !hueOff.HasValue) && (!hueMod.HasValue && !sat.HasValue)) && ((!satOff.HasValue && !satMod.HasValue) && ((!lum.HasValue && !lumOff.HasValue) && !lumMod.HasValue)))
         {
             return(color);
         }
         HLSColor color2     = new HLSColor(color);
         int      num9       = color2.Hue;
         int      saturation = color2.Saturation;
         int      luminosity = color2.Luminosity;
         int      num12      = 0xff;
         if (hue.HasValue)
         {
             num9 = (int)((hue.Value * num12) / 36000000.0);
         }
         if (hueMod.HasValue)
         {
             num9 = (int)((num9 * hueMod.Value) / 100000.0);
             if (num9 > num12)
             {
                 num9 = num12;
             }
         }
         if (hueOff.HasValue)
         {
             num9 += (int)((hueOff.Value * num12) / 21600000.0);
             if (num9 > num12)
             {
                 num9 = num12;
             }
             else if (num9 < 0)
             {
                 num9 = 0;
             }
         }
         if (sat.HasValue)
         {
             saturation = (int)((sat.Value * num12) / 1000000.0);
         }
         if (satMod.HasValue)
         {
             saturation = (int)((saturation * satMod.Value) / 100000.0);
             if (saturation > num12)
             {
                 saturation = num12;
             }
         }
         if (satOff.HasValue)
         {
             saturation += (int)((satOff.Value * num12) / 100000.0);
             if (saturation > num12)
             {
                 saturation = num12;
             }
             else if (saturation < 0)
             {
                 saturation = 0;
             }
         }
         if (lum.HasValue)
         {
             luminosity = (int)((lum.Value * num12) / 1000000.0);
         }
         if (lumMod.HasValue)
         {
             luminosity = (int)((luminosity * lumMod.Value) / 100000.0);
             if (luminosity > num12)
             {
                 luminosity = num12;
             }
         }
         if (lumOff.HasValue)
         {
             luminosity += (int)((lumOff.Value * num12) / 100000.0);
             if (luminosity > num12)
             {
                 luminosity = num12;
             }
             else if (luminosity < 0)
             {
                 luminosity = 0;
             }
         }
         color = ColorFromHLS(num9, luminosity, saturation);
     }
     return(color);
 }
Example #16
0
        public static Windows.UI.Color Light(Windows.UI.Color baseColor, float percOfLightLight)
        {
            HLSColor color = new HLSColor(baseColor);

            return(color.Lighter(percOfLightLight));
        }
Example #17
0
        public static Windows.UI.Color Dark(Windows.UI.Color baseColor, float percOfDarkDark)
        {
            HLSColor color = new HLSColor(baseColor);

            return(color.Darker(percOfDarkDark));
        }
Example #18
0
 public static Windows.UI.Color ColorFromHLS(int hue, int luminosity, int saturation)
 {
     return(HLSColor.ColorFromHLS(hue, luminosity, saturation));
 }
        /// <devdoc>
        ///     Helper function that draws a more complex border.  This is used by DrawBorder for less common
        ///     rendering cases.  We split DrawBorder into DrawBorderSimple and DrawBorderComplex so we maximize
        ///     the % of the function call.  It is less performant to have large functions that do many things.
        /// </devdoc>
        private static void DrawBorderComplex(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style) {
            if (graphics == null) {
                throw new ArgumentNullException("graphics");
            }
            if (style == ButtonBorderStyle.Inset) { // button being pushed
                HLSColor hls = new HLSColor(color);

                // top + left
                Pen pen = new Pen(hls.Darker(1.0f));
                graphics.DrawLine(pen, bounds.X, bounds.Y, 
                                  bounds.X + bounds.Width - 1, bounds.Y);
                graphics.DrawLine(pen, bounds.X, bounds.Y, 
                                  bounds.X, bounds.Y + bounds.Height - 1);

                // bottom + right
                pen.Color = hls.Lighter(1.0f);
                graphics.DrawLine(pen, bounds.X, bounds.Y + bounds.Height - 1, 
                                  bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
                graphics.DrawLine(pen, bounds.X + bounds.Width - 1, bounds.Y, 
                                  bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);

                // Top + left inset
                pen.Color = hls.Lighter(0.5f);
                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + 1,
                                      bounds.X + bounds.Width - 2, bounds.Y + 1);
                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + 1,
                                  bounds.X + 1, bounds.Y + bounds.Height - 2);

                // bottom + right inset
                if (color.ToKnownColor() == SystemColors.Control.ToKnownColor()) {
                    pen.Color = SystemColors.ControlLight;
                    graphics.DrawLine(pen, bounds.X + 1, bounds.Y + bounds.Height - 2,
                                              bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                    graphics.DrawLine(pen, bounds.X + bounds.Width - 2, bounds.Y + 1,
                                      bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                }

                pen.Dispose();
            }
            else { // Standard button
                Debug.Assert(style == ButtonBorderStyle.Outset, "Caller should have known how to use us.");
                
                bool stockColor = color.ToKnownColor() == SystemColors.Control.ToKnownColor();
                HLSColor hls = new HLSColor(color);

                // top + left
                Pen pen = stockColor ? SystemPens.ControlLightLight : new Pen(hls.Lighter(1.0f));
                graphics.DrawLine(pen, bounds.X, bounds.Y,
                                            bounds.X + bounds.Width - 1, bounds.Y);
                graphics.DrawLine(pen, bounds.X, bounds.Y, 
                                  bounds.X, bounds.Y + bounds.Height - 1);
                // bottom + right
                if (stockColor) {
                    pen = SystemPens.ControlDarkDark;
                }
                else {
                    pen.Color = hls.Darker(1.0f);
                }
                graphics.DrawLine(pen, bounds.X, bounds.Y + bounds.Height - 1, 
                                  bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
                graphics.DrawLine(pen, bounds.X + bounds.Width - 1, bounds.Y, 
                                  bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
                // top + left inset
                if (stockColor) {
                    if (SystemInformation.HighContrast) {
                        pen = SystemPens.ControlLight;
                    }
                    else {
                        pen = SystemPens.Control;
                    }
                }
                else {
                    pen.Color = color;
                }
                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + 1,
                                  bounds.X + bounds.Width - 2, bounds.Y + 1);
                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + 1,
                                  bounds.X + 1, bounds.Y + bounds.Height - 2);

                // Bottom + right inset                        
                if (stockColor) {
                    pen = SystemPens.ControlDark;
                }
                else {
                    pen.Color = hls.Darker(0.5f);
                }

                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + bounds.Height - 2,
                                  bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                graphics.DrawLine(pen, bounds.X + bounds.Width - 2, bounds.Y + 1,
                                  bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                                  
                if (!stockColor) {
                    pen.Dispose();
                }
            }
        }
        public static void DrawBorder(Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth, ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle, Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor, int bottomWidth, ButtonBorderStyle bottomStyle)
        {
            Pen pen;
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }
            int[] numArray = new int[topWidth];
            int[] numArray2 = new int[topWidth];
            int[] numArray3 = new int[leftWidth];
            int[] numArray4 = new int[leftWidth];
            int[] numArray5 = new int[bottomWidth];
            int[] numArray6 = new int[bottomWidth];
            int[] numArray7 = new int[rightWidth];
            int[] numArray8 = new int[rightWidth];
            float num = 0f;
            float num2 = 0f;
            if (leftWidth > 0)
            {
                num = ((float) topWidth) / ((float) leftWidth);
                num2 = ((float) bottomWidth) / ((float) leftWidth);
            }
            float num3 = 0f;
            float num4 = 0f;
            if (rightWidth > 0)
            {
                num3 = ((float) topWidth) / ((float) rightWidth);
                num4 = ((float) bottomWidth) / ((float) rightWidth);
            }
            HLSColor color = new HLSColor(topColor);
            HLSColor color2 = new HLSColor(leftColor);
            HLSColor color3 = new HLSColor(bottomColor);
            HLSColor color4 = new HLSColor(rightColor);
            if (topWidth > 0)
            {
                int index = 0;
                while (index < topWidth)
                {
                    int num6 = 0;
                    if (num > 0f)
                    {
                        num6 = (int) (((float) index) / num);
                    }
                    int num7 = 0;
                    if (num3 > 0f)
                    {
                        num7 = (int) (((float) index) / num3);
                    }
                    numArray[index] = bounds.X + num6;
                    numArray2[index] = ((bounds.X + bounds.Width) - num7) - 1;
                    if (leftWidth > 0)
                    {
                        numArray3[num6] = (bounds.Y + index) + 1;
                    }
                    if (rightWidth > 0)
                    {
                        numArray7[num7] = bounds.Y + index;
                    }
                    index++;
                }
                for (int i = index; i < leftWidth; i++)
                {
                    numArray3[i] = (bounds.Y + index) + 1;
                }
                for (int j = index; j < rightWidth; j++)
                {
                    numArray7[j] = bounds.Y + index;
                }
            }
            else
            {
                for (int k = 0; k < leftWidth; k++)
                {
                    numArray3[k] = bounds.Y;
                }
                for (int m = 0; m < rightWidth; m++)
                {
                    numArray7[m] = bounds.Y;
                }
            }
            if (bottomWidth > 0)
            {
                int num12 = 0;
                while (num12 < bottomWidth)
                {
                    int num13 = 0;
                    if (num2 > 0f)
                    {
                        num13 = (int) (((float) num12) / num2);
                    }
                    int num14 = 0;
                    if (num4 > 0f)
                    {
                        num14 = (int) (((float) num12) / num4);
                    }
                    numArray5[num12] = bounds.X + num13;
                    numArray6[num12] = ((bounds.X + bounds.Width) - num14) - 1;
                    if (leftWidth > 0)
                    {
                        numArray4[num13] = ((bounds.Y + bounds.Height) - num12) - 1;
                    }
                    if (rightWidth > 0)
                    {
                        numArray8[num14] = ((bounds.Y + bounds.Height) - num12) - 1;
                    }
                    num12++;
                }
                for (int n = num12; n < leftWidth; n++)
                {
                    numArray4[n] = ((bounds.Y + bounds.Height) - num12) - 1;
                }
                for (int num16 = num12; num16 < rightWidth; num16++)
                {
                    numArray8[num16] = ((bounds.Y + bounds.Height) - num12) - 1;
                }
            }
            else
            {
                for (int num17 = 0; num17 < leftWidth; num17++)
                {
                    numArray4[num17] = (bounds.Y + bounds.Height) - 1;
                }
                for (int num18 = 0; num18 < rightWidth; num18++)
                {
                    numArray8[num18] = (bounds.Y + bounds.Height) - 1;
                }
            }
            switch (topStyle)
            {
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(topColor) {
                        DashStyle = DashStyle.Dot
                    };
                    for (int num19 = 0; num19 < topWidth; num19++)
                    {
                        graphics.DrawLine(pen, numArray[num19], bounds.Y + num19, numArray2[num19], bounds.Y + num19);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Dashed:
                    pen = new Pen(topColor) {
                        DashStyle = DashStyle.Dash
                    };
                    for (int num20 = 0; num20 < topWidth; num20++)
                    {
                        graphics.DrawLine(pen, numArray[num20], bounds.Y + num20, numArray2[num20], bounds.Y + num20);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Solid:
                    pen = new Pen(topColor) {
                        DashStyle = DashStyle.Solid
                    };
                    for (int num21 = 0; num21 < topWidth; num21++)
                    {
                        graphics.DrawLine(pen, numArray[num21], bounds.Y + num21, numArray2[num21], bounds.Y + num21);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Inset:
                {
                    float num22 = InfinityToOne(1f / ((float) (topWidth - 1)));
                    for (int num23 = 0; num23 < topWidth; num23++)
                    {
                        pen = new Pen(color.Darker(1f - (num23 * num22))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, numArray[num23], bounds.Y + num23, numArray2[num23], bounds.Y + num23);
                        pen.Dispose();
                    }
                    break;
                }
                case ButtonBorderStyle.Outset:
                {
                    float num24 = InfinityToOne(1f / ((float) (topWidth - 1)));
                    for (int num25 = 0; num25 < topWidth; num25++)
                    {
                        pen = new Pen(color.Lighter(1f - (num25 * num24))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, numArray[num25], bounds.Y + num25, numArray2[num25], bounds.Y + num25);
                        pen.Dispose();
                    }
                    break;
                }
            }
            pen = null;
            switch (leftStyle)
            {
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(leftColor) {
                        DashStyle = DashStyle.Dot
                    };
                    for (int num26 = 0; num26 < leftWidth; num26++)
                    {
                        graphics.DrawLine(pen, bounds.X + num26, numArray3[num26], bounds.X + num26, numArray4[num26]);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Dashed:
                    pen = new Pen(leftColor) {
                        DashStyle = DashStyle.Dash
                    };
                    for (int num27 = 0; num27 < leftWidth; num27++)
                    {
                        graphics.DrawLine(pen, bounds.X + num27, numArray3[num27], bounds.X + num27, numArray4[num27]);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Solid:
                    pen = new Pen(leftColor) {
                        DashStyle = DashStyle.Solid
                    };
                    for (int num28 = 0; num28 < leftWidth; num28++)
                    {
                        graphics.DrawLine(pen, bounds.X + num28, numArray3[num28], bounds.X + num28, numArray4[num28]);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Inset:
                {
                    float num29 = InfinityToOne(1f / ((float) (leftWidth - 1)));
                    for (int num30 = 0; num30 < leftWidth; num30++)
                    {
                        pen = new Pen(color2.Darker(1f - (num30 * num29))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, bounds.X + num30, numArray3[num30], bounds.X + num30, numArray4[num30]);
                        pen.Dispose();
                    }
                    break;
                }
                case ButtonBorderStyle.Outset:
                {
                    float num31 = InfinityToOne(1f / ((float) (leftWidth - 1)));
                    for (int num32 = 0; num32 < leftWidth; num32++)
                    {
                        pen = new Pen(color2.Lighter(1f - (num32 * num31))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, bounds.X + num32, numArray3[num32], bounds.X + num32, numArray4[num32]);
                        pen.Dispose();
                    }
                    break;
                }
            }
            pen = null;
            switch (bottomStyle)
            {
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(bottomColor) {
                        DashStyle = DashStyle.Dot
                    };
                    for (int num33 = 0; num33 < bottomWidth; num33++)
                    {
                        graphics.DrawLine(pen, numArray5[num33], ((bounds.Y + bounds.Height) - 1) - num33, numArray6[num33], ((bounds.Y + bounds.Height) - 1) - num33);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Dashed:
                    pen = new Pen(bottomColor) {
                        DashStyle = DashStyle.Dash
                    };
                    for (int num34 = 0; num34 < bottomWidth; num34++)
                    {
                        graphics.DrawLine(pen, numArray5[num34], ((bounds.Y + bounds.Height) - 1) - num34, numArray6[num34], ((bounds.Y + bounds.Height) - 1) - num34);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Solid:
                    pen = new Pen(bottomColor) {
                        DashStyle = DashStyle.Solid
                    };
                    for (int num35 = 0; num35 < bottomWidth; num35++)
                    {
                        graphics.DrawLine(pen, numArray5[num35], ((bounds.Y + bounds.Height) - 1) - num35, numArray6[num35], ((bounds.Y + bounds.Height) - 1) - num35);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Inset:
                {
                    float num36 = InfinityToOne(1f / ((float) (bottomWidth - 1)));
                    for (int num37 = 0; num37 < bottomWidth; num37++)
                    {
                        pen = new Pen(color3.Lighter(1f - (num37 * num36))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, numArray5[num37], ((bounds.Y + bounds.Height) - 1) - num37, numArray6[num37], ((bounds.Y + bounds.Height) - 1) - num37);
                        pen.Dispose();
                    }
                    break;
                }
                case ButtonBorderStyle.Outset:
                {
                    float num38 = InfinityToOne(1f / ((float) (bottomWidth - 1)));
                    for (int num39 = 0; num39 < bottomWidth; num39++)
                    {
                        pen = new Pen(color3.Darker(1f - (num39 * num38))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, numArray5[num39], ((bounds.Y + bounds.Height) - 1) - num39, numArray6[num39], ((bounds.Y + bounds.Height) - 1) - num39);
                        pen.Dispose();
                    }
                    break;
                }
            }
            pen = null;
            switch (rightStyle)
            {
                case ButtonBorderStyle.None:
                    break;

                case ButtonBorderStyle.Dotted:
                    pen = new Pen(rightColor) {
                        DashStyle = DashStyle.Dot
                    };
                    for (int num40 = 0; num40 < rightWidth; num40++)
                    {
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num40, numArray7[num40], ((bounds.X + bounds.Width) - 1) - num40, numArray8[num40]);
                    }
                    pen.Dispose();
                    return;

                case ButtonBorderStyle.Dashed:
                    pen = new Pen(rightColor) {
                        DashStyle = DashStyle.Dash
                    };
                    for (int num41 = 0; num41 < rightWidth; num41++)
                    {
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num41, numArray7[num41], ((bounds.X + bounds.Width) - 1) - num41, numArray8[num41]);
                    }
                    pen.Dispose();
                    return;

                case ButtonBorderStyle.Solid:
                    pen = new Pen(rightColor) {
                        DashStyle = DashStyle.Solid
                    };
                    for (int num42 = 0; num42 < rightWidth; num42++)
                    {
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num42, numArray7[num42], ((bounds.X + bounds.Width) - 1) - num42, numArray8[num42]);
                    }
                    pen.Dispose();
                    return;

                case ButtonBorderStyle.Inset:
                {
                    float num43 = InfinityToOne(1f / ((float) (rightWidth - 1)));
                    for (int num44 = 0; num44 < rightWidth; num44++)
                    {
                        pen = new Pen(color4.Lighter(1f - (num44 * num43))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num44, numArray7[num44], ((bounds.X + bounds.Width) - 1) - num44, numArray8[num44]);
                        pen.Dispose();
                    }
                    return;
                }
                case ButtonBorderStyle.Outset:
                {
                    float num45 = InfinityToOne(1f / ((float) (rightWidth - 1)));
                    for (int num46 = 0; num46 < rightWidth; num46++)
                    {
                        pen = new Pen(color4.Darker(1f - (num46 * num45))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num46, numArray7[num46], ((bounds.X + bounds.Width) - 1) - num46, numArray8[num46]);
                        pen.Dispose();
                    }
                    break;
                }
                default:
                    return;
            }
        }
 internal static bool IsDarker(Color c1, Color c2)
 {
     HLSColor color = new HLSColor(c1);
     HLSColor color2 = new HLSColor(c2);
     return (color.Luminosity < color2.Luminosity);
 }
        /// <include file='doc\ControlPaint.uex' path='docs/doc[@for="ControlPaint.DrawBorder1"]/*' />
        /// <devdoc>
        ///      Draws a border of the specified style and color to the given graphics.
        /// </devdoc>
        public static void DrawBorder(Graphics graphics, Rectangle bounds,
                                      Color leftColor, int leftWidth, ButtonBorderStyle leftStyle,
                                      Color topColor, int topWidth, ButtonBorderStyle topStyle,
                                      Color rightColor, int rightWidth, ButtonBorderStyle rightStyle,
                                      Color bottomColor, int bottomWidth, ButtonBorderStyle bottomStyle) {
            // Very general, and very slow
            if (graphics == null) {
                throw new ArgumentNullException("graphics");
            }

            int[] topLineLefts = new int[topWidth];
            int[] topLineRights = new int[topWidth];
            int[] leftLineTops = new int[leftWidth];
            int[] leftLineBottoms = new int[leftWidth];
            int[] bottomLineLefts = new int[bottomWidth];
            int[] bottomLineRights = new int[bottomWidth];
            int[] rightLineTops = new int[rightWidth];
            int[] rightLineBottoms = new int[rightWidth];

            float topToLeft = 0.0f;
            float bottomToLeft = 0.0f;
            if (leftWidth > 0) {
                topToLeft = ((float)topWidth)/((float)leftWidth);
                bottomToLeft = ((float)bottomWidth)/((float)leftWidth);
            }
            float topToRight = 0.0f;
            float bottomToRight = 0.0f;
            if (rightWidth > 0) {
                topToRight = ((float)topWidth)/((float)rightWidth);
                bottomToRight = ((float)bottomWidth)/((float)rightWidth);
            }

            HLSColor topHLSColor = new HLSColor(topColor);
            HLSColor leftHLSColor = new HLSColor(leftColor);
            HLSColor bottomHLSColor = new HLSColor(bottomColor);
            HLSColor rightHLSColor = new HLSColor(rightColor);

            if (topWidth > 0) {
                int i=0;
                for (; i<topWidth; i++) {
                    int leftOffset = 0;
                    if (topToLeft > 0) {
                        leftOffset = (int)(((float)i) / topToLeft);
                    }
                    int rightOffset = 0;
                    if (topToRight > 0) {
                        rightOffset = (int)(((float)i) / topToRight);
                    }
                    topLineLefts[i] = bounds.X + leftOffset;
                    topLineRights[i] = bounds.X + bounds.Width - rightOffset - 1;
                    if (leftWidth > 0) {
                        leftLineTops[leftOffset] = bounds.Y + i + 1;
                    }
                    if (rightWidth > 0) {
                        rightLineTops[rightOffset] = bounds.Y + i;
                    }
                }
                for (int j=i; j<leftWidth; j++) {
                    leftLineTops[j] = bounds.Y + i + 1;
                }
                for (int j=i; j<rightWidth; j++) {
                    rightLineTops[j] = bounds.Y + i;
                }
            }
            else {
                for (int i=0; i<leftWidth; i++) {
                    leftLineTops[i] = bounds.Y;
                }
                for (int i=0; i<rightWidth; i++) {
                    rightLineTops[i] = bounds.Y;
                }
            }

            if (bottomWidth > 0) {
                int i=0;
                for (; i<bottomWidth; i++) {
                    int leftOffset = 0;
                    if (bottomToLeft > 0) {
                        leftOffset = (int)(((float)i) / bottomToLeft);
                    }
                    int rightOffset = 0;
                    if (bottomToRight > 0) {
                        rightOffset = (int)(((float)i) / bottomToRight);
                    }
                    bottomLineLefts[i] = bounds.X + leftOffset;
                    bottomLineRights[i] = bounds.X + bounds.Width - rightOffset - 1;
                    if (leftWidth > 0) {
                        leftLineBottoms[leftOffset] = bounds.Y + bounds.Height - i - 1;
                    }
                    if (rightWidth > 0) {
                        rightLineBottoms[rightOffset] = bounds.Y + bounds.Height - i - 1;
                    }
                }
                for (int j=i; j<leftWidth; j++) {
                    leftLineBottoms[j] = bounds.Y + bounds.Height - i - 1;
                }
                for (int j=i; j<rightWidth; j++) {
                    rightLineBottoms[j] = bounds.Y + bounds.Height - i - 1;
                }
            }
            else {
                for (int i=0; i<leftWidth; i++) {
                    leftLineBottoms[i] = bounds.Y + bounds.Height - 1;
                }
                for (int i=0; i<rightWidth; i++) {
                    rightLineBottoms[i] = bounds.Y + bounds.Height - 1;
                }
            }

            Pen pen;

            // draw top line
            switch (topStyle) {
                case ButtonBorderStyle.None:
                    // nothing
                    break;
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(topColor);
                    pen.DashStyle = DashStyle.Dot;
                    for (int i=0; i<topWidth; i++) {
                        graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Dashed:
                    pen = new Pen(topColor);
                    pen.DashStyle = DashStyle.Dash;
                    for (int i=0; i<topWidth; i++) {
                        graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Solid:
                    pen = new Pen(topColor);
                    pen.DashStyle = DashStyle.Solid;
                    for (int i=0; i<topWidth; i++) {
                        graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Inset: {
                        float inc = InfinityToOne(1.0f/(float)(topWidth-1));
                        for (int i=0; i<topWidth; i++) {
                            pen = new Pen(topHLSColor.Darker(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                            pen.Dispose();
                        }
                        break;
                    }
                case ButtonBorderStyle.Outset: {
                        float inc = InfinityToOne(1.0f/(float)(topWidth-1));

                        for (int i=0; i<topWidth; i++) {
                            pen = new Pen(topHLSColor.Lighter(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                            pen.Dispose();
                        }
                        break;
                    }
            }

            // Assertion: pen has been disposed
            pen = null;

            // draw left line
            switch (leftStyle) {
                case ButtonBorderStyle.None:
                    // nothing
                    break;
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(leftColor);
                    pen.DashStyle = DashStyle.Dot;
                    for (int i=0; i<leftWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Dashed:
                    pen = new Pen(leftColor);
                    pen.DashStyle = DashStyle.Dash;
                    for (int i=0; i<leftWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Solid:
                    pen = new Pen(leftColor);
                    pen.DashStyle = DashStyle.Solid;
                    for (int i=0; i<leftWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Inset: {
                        float inc = InfinityToOne(1.0f/(float)(leftWidth-1));
                        for (int i=0; i<leftWidth; i++) {
                            pen = new Pen(leftHLSColor.Darker(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                            pen.Dispose();
                        }
                        break;
                    }
                case ButtonBorderStyle.Outset: {
                        float inc = InfinityToOne(1.0f/(float)(leftWidth-1));
                        for (int i=0; i<leftWidth; i++) {
                            pen = new Pen(leftHLSColor.Lighter(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                            pen.Dispose();
                        }
                        break;
                    }
            }

            // Assertion: pen has been disposed
            pen = null;

            // draw bottom line
            switch (bottomStyle) {
                case ButtonBorderStyle.None:
                    // nothing
                    break;
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(bottomColor);
                    pen.DashStyle = DashStyle.Dot;
                    for (int i=0; i<bottomWidth; i++) {
                        graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Dashed:
                    pen = new Pen(bottomColor);
                    pen.DashStyle = DashStyle.Dash;
                    for (int i=0; i<bottomWidth; i++) {
                        graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Solid:
                    pen = new Pen(bottomColor);
                    pen.DashStyle = DashStyle.Solid;
                    for (int i=0; i<bottomWidth; i++) {
                        graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Inset: {
                        float inc = InfinityToOne(1.0f/(float)(bottomWidth-1));
                        for (int i=0; i<bottomWidth; i++) {
                            pen = new Pen(bottomHLSColor.Lighter(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                            pen.Dispose();
                        }
                        break;
                    }
                case ButtonBorderStyle.Outset: {
                        float inc = InfinityToOne(1.0f/(float)(bottomWidth-1));

                        for (int i=0; i<bottomWidth; i++) {
                            pen = new Pen(bottomHLSColor.Darker(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                            pen.Dispose();
                        }
                        break;
                    }
            }

            // Assertion: pen has been disposed
            pen = null;

            // draw right line
            switch (rightStyle) {
                case ButtonBorderStyle.None:
                    // nothing
                    break;
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(rightColor);
                    pen.DashStyle = DashStyle.Dot;
                    for (int i=0; i<rightWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Dashed:
                    pen = new Pen(rightColor);
                    pen.DashStyle = DashStyle.Dash;
                    for (int i=0; i<rightWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Solid:
                    pen = new Pen(rightColor);
                    pen.DashStyle = DashStyle.Solid;
                    for (int i=0; i<rightWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Inset: {
                        float inc = InfinityToOne(1.0f/(float)(rightWidth-1));
                        for (int i=0; i<rightWidth; i++) {
                            pen = new Pen(rightHLSColor.Lighter(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                            pen.Dispose();
                        }
                        break;
                    }
                case ButtonBorderStyle.Outset: {
                        float inc = InfinityToOne(1.0f/(float)(rightWidth-1));

                        for (int i=0; i<rightWidth; i++) {
                            pen = new Pen(rightHLSColor.Darker(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                            pen.Dispose();
                        }

                        break;
                    }
            }
        }
 public static Color LightLight(Color baseColor)
 {
     HLSColor color = new HLSColor(baseColor);
     return color.Lighter(1f);
 }
Example #24
0
 public static Color HLSToRGB(HLSColor clr)
 {
     return HLSToRGB(clr.Hue, clr.Lightness, clr.Saturation);
 }
 public static Color DarkDark(Color baseColor)
 {
     HLSColor color = new HLSColor(baseColor);
     return color.Darker(1f);
 }
        public static Color Light(this Color baseColor)
        {
            HLSColor color = new HLSColor(baseColor);

            return(color.Lighter(0.5f));
        }
 private static void DrawBorderComplex(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style)
 {
     if (graphics == null)
     {
         throw new ArgumentNullException("graphics");
     }
     if (style == ButtonBorderStyle.Inset)
     {
         HLSColor color2 = new HLSColor(color);
         Pen pen = new Pen(color2.Darker(1f));
         graphics.DrawLine(pen, bounds.X, bounds.Y, (bounds.X + bounds.Width) - 1, bounds.Y);
         graphics.DrawLine(pen, bounds.X, bounds.Y, bounds.X, (bounds.Y + bounds.Height) - 1);
         pen.Color = color2.Lighter(1f);
         graphics.DrawLine(pen, bounds.X, (bounds.Y + bounds.Height) - 1, (bounds.X + bounds.Width) - 1, (bounds.Y + bounds.Height) - 1);
         graphics.DrawLine(pen, (bounds.X + bounds.Width) - 1, bounds.Y, (bounds.X + bounds.Width) - 1, (bounds.Y + bounds.Height) - 1);
         pen.Color = color2.Lighter(0.5f);
         graphics.DrawLine(pen, (int) (bounds.X + 1), (int) (bounds.Y + 1), (int) ((bounds.X + bounds.Width) - 2), (int) (bounds.Y + 1));
         graphics.DrawLine(pen, (int) (bounds.X + 1), (int) (bounds.Y + 1), (int) (bounds.X + 1), (int) ((bounds.Y + bounds.Height) - 2));
         if (color.ToKnownColor() == SystemColors.Control.ToKnownColor())
         {
             pen.Color = SystemColors.ControlLight;
             graphics.DrawLine(pen, (int) (bounds.X + 1), (int) ((bounds.Y + bounds.Height) - 2), (int) ((bounds.X + bounds.Width) - 2), (int) ((bounds.Y + bounds.Height) - 2));
             graphics.DrawLine(pen, (int) ((bounds.X + bounds.Width) - 2), (int) (bounds.Y + 1), (int) ((bounds.X + bounds.Width) - 2), (int) ((bounds.Y + bounds.Height) - 2));
         }
         pen.Dispose();
     }
     else
     {
         bool flag = color.ToKnownColor() == SystemColors.Control.ToKnownColor();
         HLSColor color3 = new HLSColor(color);
         Pen controlDarkDark = flag ? SystemPens.ControlLightLight : new Pen(color3.Lighter(1f));
         graphics.DrawLine(controlDarkDark, bounds.X, bounds.Y, (bounds.X + bounds.Width) - 1, bounds.Y);
         graphics.DrawLine(controlDarkDark, bounds.X, bounds.Y, bounds.X, (bounds.Y + bounds.Height) - 1);
         if (flag)
         {
             controlDarkDark = SystemPens.ControlDarkDark;
         }
         else
         {
             controlDarkDark.Color = color3.Darker(1f);
         }
         graphics.DrawLine(controlDarkDark, bounds.X, (bounds.Y + bounds.Height) - 1, (bounds.X + bounds.Width) - 1, (bounds.Y + bounds.Height) - 1);
         graphics.DrawLine(controlDarkDark, (bounds.X + bounds.Width) - 1, bounds.Y, (bounds.X + bounds.Width) - 1, (bounds.Y + bounds.Height) - 1);
         if (flag)
         {
             if (SystemInformation.HighContrast)
             {
                 controlDarkDark = SystemPens.ControlLight;
             }
             else
             {
                 controlDarkDark = SystemPens.Control;
             }
         }
         else
         {
             controlDarkDark.Color = color;
         }
         graphics.DrawLine(controlDarkDark, (int) (bounds.X + 1), (int) (bounds.Y + 1), (int) ((bounds.X + bounds.Width) - 2), (int) (bounds.Y + 1));
         graphics.DrawLine(controlDarkDark, (int) (bounds.X + 1), (int) (bounds.Y + 1), (int) (bounds.X + 1), (int) ((bounds.Y + bounds.Height) - 2));
         if (flag)
         {
             controlDarkDark = SystemPens.ControlDark;
         }
         else
         {
             controlDarkDark.Color = color3.Darker(0.5f);
         }
         graphics.DrawLine(controlDarkDark, (int) (bounds.X + 1), (int) ((bounds.Y + bounds.Height) - 2), (int) ((bounds.X + bounds.Width) - 2), (int) ((bounds.Y + bounds.Height) - 2));
         graphics.DrawLine(controlDarkDark, (int) ((bounds.X + bounds.Width) - 2), (int) (bounds.Y + 1), (int) ((bounds.X + bounds.Width) - 2), (int) ((bounds.Y + bounds.Height) - 2));
         if (!flag)
         {
             controlDarkDark.Dispose();
         }
     }
 }
 //returns true if the luminosity of c1 is less than c2.
 internal static bool IsDarker(Color c1, Color c2) {
     HLSColor hc1 = new HLSColor(c1);
     HLSColor hc2 = new HLSColor(c2);
     return (hc1.Luminosity < hc2.Luminosity);
 }