Inheritance: PaletteContentInherit
        /// <summary>
        /// Initialize a new instance of the KryptonContextMenuLinkLabel class.
        /// </summary>
        /// <param name="initialText">Initial text for display.</param>
        public KryptonContextMenuLinkLabel(string initialText)
        {
            // Default fields
            _text = initialText;
            _extraText = string.Empty;
            _image = null;
            _imageTransparentColor = Color.Empty;
            _style = LabelStyle.NormalControl;
            _autoClose = true;

            // Create the redirectors
            _stateNormalRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalControl);
            _stateVisitedRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalControl);
            _stateNotVisitedRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalControl);
            _statePressedRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalControl);
            _stateFocusRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalControl);

            // Create the states
            _stateNormal = new PaletteContent(_stateNormalRedirect);
            _stateVisited = new PaletteContent(_stateVisitedRedirect);
            _stateNotVisited = new PaletteContent(_stateNotVisitedRedirect);
            _stateFocus = new PaletteContent(_stateFocusRedirect);
            _statePressed = new PaletteContent(_statePressedRedirect);

            // 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, true);
            _overridePressedFocus = new PaletteContentInheritOverride(_stateFocus, _overridePressed, PaletteState.FocusOverride, false);
        }
Exemplo n.º 2
0
        /// <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);
        }