Пример #1
0
        protected override void OnBackColorChanged(EventArgs e)
        {
            base.OnBackColorChanged(e);

            Color BackgroundColor;

            if (BackColor.Equals(Color.Transparent))
            {
                if (Parent != null)
                {
                    BackgroundColor = Parent.BackColor;
                }
                else
                {
                    BackgroundColor = Color.White;
                }
            }
            else
            {
                BackgroundColor = BackColor;
            }

            // Get the hue of the background color
            float hue        = BackgroundColor.GetHue();
            float saturation = BackgroundColor.GetSaturation();
            float bright     = BackgroundColor.GetBrightness();
            float alpha      = BackgroundColor.A;

            // Get a value which is darker or lighter
            CircleEdge   = DoubleBufferedControl.ColorFromAhsb(220, hue, saturation, bright * 0.2f);
            CircleBack   = DoubleBufferedControl.ColorFromAhsb(190, hue, saturation, bright * 0.4f);
            CircleCenter = DoubleBufferedControl.ColorFromAhsb(210, hue, saturation, bright * 0.7f);
            CircleBright = DoubleBufferedControl.ColorFromAhsb(250, hue, saturation, bright * 1.0f);

            #region Draw the faded edge of the circle to give spherical depth

            GlassShadowColorBlend.Colors    = new Color[] { CircleEdge, CircleBack, CircleCenter, CircleCenter };
            GlassShadowColorBlend.Positions = new float[] { 0.00F, 0.25f, 0.7f, 1.0f };

            #endregion

            #region Set the colors of the reflection

            // If the background color is black, make the class reflection white
            if (BackgroundColor.Equals(Color.Black))
            {
                float WhiteHue        = Color.White.GetHue();
                float WhiteSaturation = Color.White.GetSaturation();
                float WhiteBright     = Color.White.GetBrightness();
                CircleCenter = DoubleBufferedControl.ColorFromAhsb(210, WhiteHue, WhiteSaturation, WhiteBright * 0.7f);
                CircleBright = DoubleBufferedControl.ColorFromAhsb(250, WhiteHue, WhiteSaturation, WhiteBright * 1.0f);
                GlassReflectionColorBlend.Colors = new Color[] { CircleBright, Color.FromArgb(200, CircleCenter), Color.FromArgb(10, CircleCenter), Color.Transparent };
            }
            else
            {
                Color NearWhite = DoubleBufferedControl.ColorFromAhsb(255, hue, saturation, 1.0f);

                GlassReflectionColorBlend.Colors = new Color[] { NearWhite, Color.FromArgb(200, CircleCenter), Color.FromArgb(10, CircleCenter), Color.Transparent };
            }

            GlassReflectionColorBlend.Positions = new float[] { 0F, 0.15f, 0.35F, 1.0f };

            MakeBrushes();

            #endregion
        }