/// <summary> /// Initialize a new instance of the KryptonContextMenuCheckButton class. /// </summary> /// <param name="initialText">Initial text for display.</param> public KryptonContextMenuCheckButton(string initialText) { // Default fields _enabled = true; _autoClose = false; _text = initialText; _extraText = string.Empty; _image = null; _imageTransparentColor = Color.Empty; _checked = false; _autoCheck = false; _style = ButtonStyle.Standalone; // Create the redirectors StateCommon = new PaletteTripleRedirect(PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone); OverrideFocus = new PaletteTripleRedirect(PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone); // Create the palette storage StateDisabled = new PaletteTriple(StateCommon); StateNormal = new PaletteTriple(StateCommon); StateTracking = new PaletteTriple(StateCommon); StatePressed = new PaletteTriple(StateCommon); StateCheckedNormal = new PaletteTriple(StateCommon); StateCheckedTracking = new PaletteTriple(StateCommon); StateCheckedPressed = new PaletteTriple(StateCommon); // Create the override handling classes OverrideDisabled = new PaletteTripleOverride(OverrideFocus, StateDisabled, PaletteState.FocusOverride); OverrideNormal = new PaletteTripleOverride(OverrideFocus, StateNormal, PaletteState.FocusOverride); OverrideTracking = new PaletteTripleOverride(OverrideFocus, StateTracking, PaletteState.FocusOverride); OverridePressed = new PaletteTripleOverride(OverrideFocus, StatePressed, PaletteState.FocusOverride); OverrideCheckedNormal = new PaletteTripleOverride(OverrideFocus, StateCheckedNormal, PaletteState.FocusOverride); OverrideCheckedTracking = new PaletteTripleOverride(OverrideFocus, StateCheckedTracking, PaletteState.FocusOverride); OverrideCheckedPressed = new PaletteTripleOverride(OverrideFocus, StateCheckedPressed, PaletteState.FocusOverride); }
/// <summary> /// Initialize a new instance of the KryptonCheckButton class. /// </summary> public KryptonCheckButton() { // Create the extra state needed for the checked additions the the base button StateCheckedNormal = new PaletteTriple(StateCommon, NeedPaintDelegate); StateCheckedTracking = new PaletteTriple(StateCommon, NeedPaintDelegate); StateCheckedPressed = new PaletteTriple(StateCommon, NeedPaintDelegate); // Create the override handling classes _overrideCheckedFocus = new PaletteTripleOverride(OverrideFocus, StateCheckedNormal, PaletteState.FocusOverride); _overrideCheckedNormal = new PaletteTripleOverride(OverrideDefault, _overrideCheckedFocus, PaletteState.NormalDefaultOverride); _overrideCheckedTracking = new PaletteTripleOverride(OverrideFocus, StateCheckedTracking, PaletteState.FocusOverride); _overrideCheckedPressed = new PaletteTripleOverride(OverrideFocus, StateCheckedPressed, PaletteState.FocusOverride); // Add the checked specific palettes to the existing view button ViewDrawButton.SetCheckedPalettes(_overrideCheckedNormal, _overrideCheckedTracking, _overrideCheckedPressed); }
/// <summary> /// Initialize a new instance of the KryptonDropButton class. /// </summary> public KryptonDropButton() { // We generate click events manually, suppress default // production of them by the base Control class SetStyle(ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, false); // Set default button properties _style = ButtonStyle.Standalone; DialogResult = DialogResult.None; _useMnemonic = true; // Create content storage Values = CreateButtonValues(NeedPaintDelegate); Values.TextChanged += OnButtonTextChanged; Images = new DropDownButtonImages(NeedPaintDelegate); // Image need an extra redirector to check the local images first _paletteDropDownButtonImages = new PaletteRedirectDropDownButton(Redirector, Images); // Create the palette storage StateCommon = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate); StateDisabled = new PaletteTriple(StateCommon, NeedPaintDelegate); StateNormal = new PaletteTriple(StateCommon, NeedPaintDelegate); StateTracking = new PaletteTriple(StateCommon, NeedPaintDelegate); StatePressed = new PaletteTriple(StateCommon, NeedPaintDelegate); OverrideDefault = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate); OverrideFocus = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonStandalone, PaletteBorderStyle.ButtonStandalone, PaletteContentStyle.ButtonStandalone, NeedPaintDelegate); // Create the override handling classes _overrideFocus = new PaletteTripleOverride(OverrideFocus, StateNormal, PaletteState.FocusOverride); _overrideNormal = new PaletteTripleOverride(OverrideDefault, _overrideFocus, PaletteState.NormalDefaultOverride); _overrideTracking = new PaletteTripleOverride(OverrideFocus, StateTracking, PaletteState.FocusOverride); _overridePressed = new PaletteTripleOverride(OverrideFocus, StatePressed, PaletteState.FocusOverride); // Create the view button instance _drawButton = new ViewDrawButton(StateDisabled, _overrideNormal, _overrideTracking, _overridePressed, new PaletteMetricRedirect(Redirector), this, VisualOrientation.Top, UseMnemonic) { // Set default button state DropDown = true, Splitter = true, TestForFocusCues = true, DropDownPalette = _paletteDropDownButtonImages }; // Create a button controller to handle button style behaviour _buttonController = new ButtonController(_drawButton, NeedPaintDelegate) { BecomesFixed = true }; // Assign the controller to the view element to treat as a button _drawButton.MouseController = _buttonController; _drawButton.KeyController = _buttonController; _drawButton.SourceController = _buttonController; // Need to know when user clicks the button view or mouse selects it _buttonController.Click += OnButtonClick; _buttonController.MouseSelect += OnButtonSelect; // Create the view manager instance ViewManager = new ViewManager(this, _drawButton); }