Example #1
0
        /// <summary>
        /// Initialize a new instance of the PaletteContent class.
        /// </summary>
        /// <param name="inherit">Source for inheriting defaulted values.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public PaletteContent(IPaletteContent inherit,
                              NeedPaintHandler needPaint)
        {
            Debug.Assert(inherit != null);

            // Remember inheritance
            _inherit = inherit;

            // Store the provided paint notification delegate
            NeedPaint = needPaint;

            // Create the content storage for sub objects
            _image     = new PaletteContentImage(needPaint);
            _shortText = new PaletteContentText(needPaint);
            _longText  = new PaletteContentText(needPaint);
        }
Example #2
0
        /// <summary>
        /// Initialize a new instance of the KryptonButton class.
        /// </summary>
        public KryptonCommandLinkButton()
        {
            // 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
            base.AutoSize = false;
            DialogResult  = DialogResult.None;
            _orientation  = VisualOrientation.Top;
            _useMnemonic  = true;

            // Create content storage
            CommandLinkImageValue = new ImageValue(NeedPaintDelegate);
            CommandLinkTextValues = new CommandLinkTextValues(NeedPaintDelegate);

            // Create the palette storage
            StateCommon = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonCommand, PaletteBorderStyle.ButtonCommand, PaletteContentStyle.ButtonCommand, NeedPaintDelegate);
            PaletteContentText contentShortText = StateCommon.Content.ShortText;

            contentShortText.Font              = new Font(@"Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 0);
            contentShortText.TextH             = PaletteRelativeAlign.Near;
            contentShortText.TextV             = PaletteRelativeAlign.Center;
            StateCommon.Content.LongText.TextH = PaletteRelativeAlign.Near;
            StateCommon.Content.LongText.TextV = PaletteRelativeAlign.Far;

            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.ButtonCommand, PaletteBorderStyle.ButtonCommand, PaletteContentStyle.ButtonCommand, NeedPaintDelegate);
            OverrideFocus                     = new PaletteTripleRedirect(Redirector, PaletteBackStyle.ButtonCommand, PaletteBorderStyle.ButtonCommand, PaletteContentStyle.ButtonCommand, NeedPaintDelegate);
            OverrideFocus.Border.Draw         = InheritBool.True;
            OverrideFocus.Border.DrawBorders  = PaletteDrawBorders.All;
            OverrideFocus.Border.GraphicsHint = PaletteGraphicsHint.AntiAlias;
            // Force style update
            ButtonStyle = ButtonStyle.Command;

            // 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 ViewDrawCommandLinkButton(StateDisabled,
                                                       _overrideNormal,
                                                       _overrideTracking,
                                                       _overridePressed,
                                                       new PaletteMetricRedirect(Redirector),
                                                       CommandLinkImageValue, CommandLinkTextValues,
                                                       Orientation,
                                                       UseMnemonic)
            {
                // Only draw a focus rectangle when focus cues are needed in the top level form
                TestForFocusCues = true
            };

            // Create a button controller to handle button style behaviour
            _buttonController = new ButtonController(drawButton, NeedPaintDelegate);

            // 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);
        }