Base class for buttons.
Inheritance: ViewBase, IButtonView
 private bool EnabledConditionMet(ButtonView button)
 {
     if (EnabledCondition == EnabledCondition.Either) return true;
     if (EnabledCondition == EnabledCondition.EnabledOnly && !button.IsEnabled) return false;
     if (EnabledCondition == EnabledCondition.DisabledOnly && button.IsEnabled) return false;
     return true;
 }
 private bool FocusConditionMet(ButtonView button)
 {
     if (FocusCondition == FocusCondition.Either) return true;
     if (FocusCondition == FocusCondition.FocusedOnly && !button.Focus.IsFocused) return false;
     if (FocusCondition == FocusCondition.UnfocusedOnly && button.Focus.IsFocused) return false;
     return true;
 }
        public bool IsCurrent(ButtonView button)
        {
            // Check that the button-state matches.
            if (!States.Contains(button.State)) return false;

            // Check that the disabled and focused conditions are met.
            if (!FocusConditionMet(button)) return false;
            if (!EnabledConditionMet(button)) return false;

            // Finish up.
            return true;
        }
        /// <summary>Constructor.</summary>
        /// <param name="control">The clickable button element.</param>
        public ButtonEventController(ButtonView control)
        {
            // Setup initial conditions.
            this.control = control;
            jQueryObject divMask = control.Container;

            // Wire up events.
            Model.IsPressedChanged += OnModelIsPressedChanged;

            // -- Mouse events.
            divMask.MouseOver(OnMouseOver);
            divMask.MouseOut(OnMouseOut);
            divMask.MouseDown(OnMouseDown);
            divMask.MouseUp(OnMouseUp);
        }
        /// <summary>Adds a silver background to the given button.</summary>
        /// <param name="layer">The layer to assign the content to (typically '0').</param>
        /// <param name="button">The button to effect.</param>
        /// <param name="showForNormal">Flag indicating if the background should be visible for the default (normal) state.</param>
        public static void SilverBackground(int layer, ButtonView button, bool showForNormal)
        {
            // Setup initial conditions.
            ButtonState[] upStates = showForNormal
                                         ? new ButtonState[] { ButtonState.Normal, ButtonState.MouseOver }
                                         : new ButtonState[] { ButtonState.MouseOver };
            ButtonState[] downStates = new ButtonState[] { ButtonState.MouseDown, ButtonState.Pressed };

            // Insert the DIV element that will show the CSS styles.
            button.TemplateForStates(layer, ButtonView.AllStates, ButtonTemplates.CommonBg, EnabledCondition.Either, FocusCondition.Either);

            // Apply CSS.
            button.CssForStates(layer, upStates, string.Format("{0} {1}", ButtonCss.ClassSilver, ButtonCss.ClassUp));
            button.CssForStates(layer, downStates, string.Format("{0} {1}", ButtonCss.ClassSilver, ButtonCss.ClassDown));
            button.CssForStates(layer, new ButtonState[] { ButtonState.MouseOver, ButtonState.MouseDown }, ButtonCss.ClassHighlight);
        }
 /// <summary>Adds a style for rounded corners.</summary>
 /// <param name="layer">The layer to assign the content to (typically '0').</param>
 /// <param name="button">The button to effect.</param>
 public static void Rounded(int layer, ButtonView button)
 {
     button.CssForStates(layer, ButtonView.AllStates, ButtonCss.ClassRounded);
 }
 public ButtonContentController(ButtonView button, jQueryObject divContent)
 {
     Button = button;
     DivContent = divContent;
 }