Esempio n. 1
0
        /// <summary>Gets the control brush.</summary>
        /// <param name="graphics">Graphics controller.</param>
        /// <param name="enabled">Enabled state.</param>
        /// <param name="mouseState">Mouse state.</param>
        /// <param name="controlStates">The gradient color states.</param>
        /// <param name="rectangle">The rectangle</param>
        /// <returns>Control brush state.</returns>
        internal static LinearGradientBrush GetControlBrush(Graphics graphics, bool enabled, MouseStates mouseState, Gradient[] controlStates, Rectangle rectangle)
        {
            Gradient tempGradient;

            if (enabled)
            {
                switch (mouseState)
                {
                case MouseStates.Normal:
                {
                    tempGradient = controlStates[0];
                    break;
                }

                case MouseStates.Hover:
                {
                    tempGradient = controlStates[1];
                    break;
                }

                case MouseStates.Down:
                {
                    tempGradient = controlStates[2];
                    break;
                }

                default:
                {
                    tempGradient = controlStates[0];
                    break;
                }
                }
            }
            else
            {
                tempGradient = controlStates[3];
            }

            return(Gradient.CreateBrush(tempGradient.Angle, tempGradient.Colors, tempGradient.Locations, rectangle));
        }