/// <summary> /// Initialize a new instance of the PaletteTabTripleRedirect class. /// </summary> /// <param name="redirect">inheritance redirection instance.</param> /// <param name="backStyle">Initial background style.</param> /// <param name="borderStyle">Initial border style.</param> /// <param name="contentStyle">Initial content style.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public PaletteTabTripleRedirect(PaletteRedirect redirect, PaletteBackStyle backStyle, PaletteBorderStyle borderStyle, PaletteContentStyle contentStyle, NeedPaintHandler needPaint) { Debug.Assert(redirect != null); // Store the provided paint notification delegate NeedPaint = needPaint; // Store the inherit instances _backInherit = new PaletteBackInheritRedirect(redirect, backStyle); _borderInherit = new PaletteBorderInheritRedirect(redirect, borderStyle); _contentInherit = new PaletteContentInheritRedirect(redirect, contentStyle); // Create storage that maps onto the inherit instances Back = new PaletteBack(_backInherit, needPaint); Border = new PaletteTabBorder(_borderInherit, needPaint); Content = new PaletteContent(_contentInherit, needPaint); }
public void LoadContent(PaletteContent content) { Unload(); probe = content.Probe; brushButtons = new List <BrushButton>(); foreach (var image in content.Images) { var picture = new BrushButton() { ActiveColor = SystemColors.ActiveCaption, Brush = image.Brush, IdleColor = SystemColors.Control, Image = image.Image, Size = image.Image.Size + BrushesMargin, SizeMode = PictureBoxSizeMode.CenterImage }; picture.Click += (s, e) => ChangeBrush(s as BrushButton); brushButtons.Add(picture); flowLayoutPanel.Controls.Add(picture); } }
/// <summary> /// Initialize a new instance of the KryptonLabel class. /// </summary> public KryptonLabel() { SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // The label cannot take the focus SetStyle(ControlStyles.Selectable, false); // Set default properties _style = LabelStyle.NormalPanel; _useMnemonic = true; _orientation = VisualOrientation.Top; _target = null; EnabledTarget = true; // Create content storage Values = new LabelValues(NeedPaintDelegate); Values.TextChanged += OnLabelTextChanged; // Create palette redirector _paletteCommonRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalPanel); // Create the palette provider StateCommon = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate); StateDisabled = new PaletteContent(StateCommon, NeedPaintDelegate); StateNormal = new PaletteContent(StateCommon, NeedPaintDelegate); // Our view contains background and border with content inside _drawContent = new ViewDrawContent(StateNormal, this, VisualOrientation.Top) { UseMnemonic = _useMnemonic }; // Create the view manager instance ViewManager = new ViewManager(this, _drawContent); // 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 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); }
/// <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)); } }
/// <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.NormalPanel; _orientation = VisualOrientation.Top; _checkPosition = VisualOrientation.Left; _checked = false; _useMnemonic = true; _autoCheck = true; // Create content storage Values = new LabelValues(NeedPaintDelegate); Values.TextChanged += OnRadioButtonTextChanged; Images = new RadioButtonImages(NeedPaintDelegate); // Create palette redirector _paletteCommonRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalPanel); _paletteRadioButtonImages = new PaletteRedirectRadioButton(Redirector, Images); // Create the palette provider StateCommon = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate); StateDisabled = new PaletteContent(StateCommon, NeedPaintDelegate); StateNormal = new PaletteContent(StateCommon, NeedPaintDelegate); OverrideFocus = new PaletteContent(_paletteCommonRedirect, NeedPaintDelegate); // Override the normal values with the focus, when the control has focus _overrideNormal = new PaletteContentInheritOverride(OverrideFocus, StateNormal, PaletteState.FocusOverride, false); // Our view contains background and border with content inside _drawContent = new ViewDrawContent(_overrideNormal, Values, VisualOrientation.Top) { UseMnemonic = _useMnemonic, // Only draw a focus rectangle when focus cues are needed in the top level form TestForFocusCues = true }; // Create the check box image drawer and place inside element so it is always centered _drawRadioButton = new ViewDrawRadioButton(_paletteRadioButtonImages) { CheckState = _checked }; _layoutCenter = new ViewLayoutCenter { _drawRadioButton }; // Place check box on the left and the label in the remainder _layoutDocker = new ViewLayoutDocker { { _layoutCenter, ViewDockStyle.Left }, { _drawContent, ViewDockStyle.Fill } }; // Need a controller for handling mouse input _controller = new RadioButtonController(_drawRadioButton, _layoutDocker, NeedPaintDelegate); _controller.Click += 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> /// Gets the first back color for the long text. /// </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 GetContentLongTextColor1(PaletteContentStyle style, PaletteState state) => // Do we need to override the text color OverrideTextColor(state) && (PaletteContent != null) ? PaletteContent.GetContentShortTextColor1(state) : base.GetContentLongTextColor1(style, state);