/// <summary>
        /// Initialize a new instance of the KryptonLinkLabel class.
        /// </summary>
        public KryptonLinkLabel()
        {
            // The link label cannot take the focus
            SetStyle(ControlStyles.Selectable, true);

            // Turn off the target functionality present in the base class
            EnabledTarget = false;

            // Create the override states that redirect without inheriting
            _stateVisitedRedirect    = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _stateNotVisitedRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _statePressedRedirect    = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _stateFocusRedirect      = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _stateVisited            = new PaletteContent(_stateVisitedRedirect, NeedPaintDelegate);
            _stateNotVisited         = new PaletteContent(_stateNotVisitedRedirect, NeedPaintDelegate);
            _stateFocus   = new PaletteContent(_stateFocusRedirect, NeedPaintDelegate);
            _statePressed = new PaletteContent(_statePressedRedirect, NeedPaintDelegate);

            // Override the normal state to implement the underling logic
            _inheritBehavior = new LinkLabelBehaviorInherit(StateNormal, KryptonLinkBehavior.AlwaysUnderline);

            // Create the override handling classes
            _overrideVisited         = new PaletteContentInheritOverride(_stateVisited, _inheritBehavior, PaletteState.LinkVisitedOverride, false);
            _overrideNotVisited      = new PaletteContentInheritOverride(_stateNotVisited, _overrideVisited, PaletteState.LinkNotVisitedOverride, true);
            _overrideFocusNotVisited = new PaletteContentInheritOverride(_stateFocus, _overrideNotVisited, PaletteState.FocusOverride, false);
            _overridePressed         = new PaletteContentInheritOverride(_statePressed, _inheritBehavior, PaletteState.LinkPressedOverride, false);
            _overridePressedFocus    = new PaletteContentInheritOverride(_stateFocus, _overridePressed, PaletteState.FocusOverride, false);

            // Create controller for updating the view state/click events
            _controller        = new LinkLabelController(ViewDrawContent, StateDisabled, _overrideFocusNotVisited, _overrideFocusNotVisited, _overridePressedFocus, _overridePressed, NeedPaintDelegate);
            _controller.Click += new MouseEventHandler(OnControllerClick);
            ViewDrawContent.MouseController  = _controller;
            ViewDrawContent.KeyController    = _controller;
            ViewDrawContent.SourceController = _controller;

            // Set initial palette for drawing the content
            ViewDrawContent.SetPalette(_overrideFocusNotVisited);
        }
        /// <summary>
        /// Gets the color to use in place of the image map color.
        /// </summary>
        /// <param name="style">Content style.</param>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <returns>Color value.</returns>
        public override Color GetContentImageColorTo(PaletteContentStyle style, PaletteState state)
        {
            // If allowed to override then get the map color
            Color mapColor = OverrideImageColor(state);

            // If mapping occuring then return the target remap color
            if ((mapColor != Color.Empty) && (PaletteContent != null))
            {
                PaletteState getState = PaletteState;

                // Honor the button disabled state
                if (state == PaletteState.Disabled)
                {
                    getState = PaletteState.Disabled;
                }

                return(PaletteContent.GetContentShortTextColor1(getState));
            }
            else
            {
                return(base.GetContentImageColorTo(style, state));
            }
        }
Exemple #3
0
        /// <summary>
        /// Initialize a new instance of the RadioButton class.
        /// </summary>
        public KryptonRadioButton()
        {
            // Turn off standard click and double click events, we do that manually
            SetStyle(ControlStyles.StandardClick |
                     ControlStyles.StandardDoubleClick, false);

            // Set default properties
            _style         = LabelStyle.NormalControl;
            _orientation   = VisualOrientation.Top;
            _checkPosition = VisualOrientation.Left;
            _checked       = false;
            _useMnemonic   = true;
            _autoCheck     = true;

            // Create content storage
            _labelValues              = new LabelValues(NeedPaintDelegate);
            _labelValues.TextChanged += new EventHandler(OnRadioButtonTextChanged);
            _images = new RadioButtonImages(NeedPaintDelegate);

            // Create palette redirector
            _paletteCommonRedirect    = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _paletteRadioButtonImages = new PaletteRedirectRadioButton(Redirector, _images);

            // Create the palette provider
            _stateCommon   = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate);
            _stateDisabled = new PaletteContent(_stateCommon, NeedPaintDelegate);
            _stateNormal   = new PaletteContent(_stateCommon, NeedPaintDelegate);
            _stateFocus    = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate);

            // Override the normal values with the focus, when the control has focus
            _overrideNormal = new PaletteContentInheritOverride(_stateFocus, _stateNormal, PaletteState.FocusOverride, false);

            // Our view contains background and border with content inside
            _drawContent             = new ViewDrawContent(_overrideNormal, _labelValues, VisualOrientation.Top);
            _drawContent.UseMnemonic = _useMnemonic;

            // Only draw a focus rectangle when focus cues are needed in the top level form
            _drawContent.TestForFocusCues = true;

            // Create the check box image drawer and place inside element so it is always centered
            _drawRadioButton            = new ViewDrawRadioButton(_paletteRadioButtonImages);
            _drawRadioButton.CheckState = _checked;
            _layoutCenter = new ViewLayoutCenter();
            _layoutCenter.Add(_drawRadioButton);

            // Place check box on the left and the label in the remainder
            _layoutDocker = new ViewLayoutDocker();
            _layoutDocker.Add(_layoutCenter, ViewDockStyle.Left);
            _layoutDocker.Add(_drawContent, ViewDockStyle.Fill);

            // Need a controller for handling mouse input
            _controller                   = new RadioButtonController(_drawRadioButton, _layoutDocker, NeedPaintDelegate);
            _controller.Click            += new EventHandler(OnControllerClick);
            _controller.Enabled           = true;
            _layoutDocker.MouseController = _controller;
            _layoutDocker.KeyController   = _controller;

            // Change the layout to match the inital right to left setting and orientation
            UpdateForOrientation();

            // Create the view manager instance
            ViewManager = new ViewManager(this, _layoutDocker);

            // We want to be auto sized by default, but not the property default!
            AutoSize     = true;
            AutoSizeMode = AutoSizeMode.GrowAndShrink;
        }
 /// <summary>
 /// Initialize a new instance of the PaletteGroupBox class.
 /// </summary>
 /// <param name="inherit">Source for inheriting palette defaulted values.</param>
 /// <param name="needPaint">Delegate for notifying paint requests.</param>
 public PaletteGroupBox(PaletteGroupBoxRedirect inherit,
                        NeedPaintHandler needPaint)
     : base(inherit, needPaint)
 {
     _content = new PaletteContent(inherit.PaletteContent, needPaint);
 }