/// <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.NormalPanel; _autoClose = true; // Create the redirectors _stateNormalRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalPanel); _stateVisitedRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalPanel); _stateNotVisitedRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalPanel); _statePressedRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalPanel); _stateFocusRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalPanel); // Create the states StateNormal = new PaletteContent(_stateNormalRedirect); OverrideVisited = new PaletteContent(_stateVisitedRedirect); OverrideNotVisited = new PaletteContent(_stateNotVisitedRedirect); OverrideFocus = new PaletteContent(_stateFocusRedirect); OverridePressed = new PaletteContent(_statePressedRedirect); // Override the normal state to implement the underling logic LinkBehaviorNormal = new LinkLabelBehaviorInherit(StateNormal, KryptonLinkBehavior.AlwaysUnderline); // Create the override handling classes _overrideVisited = new PaletteContentInheritOverride(OverrideVisited, LinkBehaviorNormal, PaletteState.LinkVisitedOverride, false); _overrideNotVisited = new PaletteContentInheritOverride(OverrideNotVisited, _overrideVisited, PaletteState.LinkNotVisitedOverride, true); OverrideFocusNotVisited = new PaletteContentInheritOverride(OverrideFocus, _overrideNotVisited, PaletteState.FocusOverride, false); _overridePressed = new PaletteContentInheritOverride(OverridePressed, LinkBehaviorNormal, PaletteState.LinkPressedOverride, true); OverridePressedFocus = new PaletteContentInheritOverride(OverrideFocus, _overridePressed, PaletteState.FocusOverride, false); }
/// <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.LabelNormalPanel); _stateNotVisitedRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalPanel); _statePressedRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalPanel); _stateFocusRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalPanel); OverrideVisited = new PaletteContent(_stateVisitedRedirect, NeedPaintDelegate); OverrideNotVisited = new PaletteContent(_stateNotVisitedRedirect, NeedPaintDelegate); OverrideFocus = new PaletteContent(_stateFocusRedirect, NeedPaintDelegate); OverridePressed = 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(OverrideVisited, _inheritBehavior, PaletteState.LinkVisitedOverride, false); _overrideNotVisited = new PaletteContentInheritOverride(OverrideNotVisited, _overrideVisited, PaletteState.LinkNotVisitedOverride, true); _overrideFocusNotVisited = new PaletteContentInheritOverride(OverrideFocus, _overrideNotVisited, PaletteState.FocusOverride, false); _overridePressed = new PaletteContentInheritOverride(OverridePressed, _inheritBehavior, PaletteState.LinkPressedOverride, false); _overridePressedFocus = new PaletteContentInheritOverride(OverrideFocus, _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 += OnControllerClick; ViewDrawContent.MouseController = _controller; ViewDrawContent.KeyController = _controller; ViewDrawContent.SourceController = _controller; // Set initial palette for drawing the content ViewDrawContent.SetPalette(_overrideFocusNotVisited); }