Inherit properties from primary source in preference to the backup source.
Inheritance: PaletteContentInherit
        /// <summary>
        /// Initialize a new instance of the KryptonContextMenuCheckBox class.
        /// </summary>
        /// <param name="initialText">Initial text for display.</param>
        public KryptonContextMenuCheckBox(string initialText)
        {
            // Default fields
            _enabled               = true;
            _autoClose             = false;
            _text                  = initialText;
            _extraText             = string.Empty;
            _image                 = null;
            _imageTransparentColor = Color.Empty;
            _checkState            = CheckState.Unchecked;
            _checked               = false;
            _threeState            = false;
            _autoCheck             = true;
            _style                 = LabelStyle.NormalControl;
            _images                = new CheckBoxImages();

            // Create the redirectors
            _stateCommonRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalControl);
            _stateCheckBoxImages = new PaletteRedirectCheckBox(_images);

            // Create the states
            _stateCommon   = new PaletteContent(_stateCommonRedirect);
            _stateDisabled = new PaletteContent(_stateCommon);
            _stateNormal   = new PaletteContent(_stateCommon);
            _stateFocus    = new PaletteContent(_stateCommonRedirect);

            // Override the normal/disabled values with the focus, when the control has focus
            _overrideNormal   = new PaletteContentInheritOverride(_stateFocus, _stateNormal, PaletteState.FocusOverride, false);
            _overrideDisabled = new PaletteContentInheritOverride(_stateFocus, _stateDisabled, PaletteState.FocusOverride, false);
        }
        /// <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);
            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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize a new instance of the PaletteTripleOverride class.
        /// </summary>
        /// <param name="normalTriple">Normal palette to use.</param>
        /// <param name="overrideTriple">Override palette to use.</param>
        /// <param name="overrideState">State used by the override.</param>
        public PaletteTripleOverride(IPaletteTriple normalTriple,
                                     IPaletteTriple overrideTriple,
                                     PaletteState overrideState)
        {
            Debug.Assert(normalTriple != null);
            Debug.Assert(overrideTriple != null);

            // Validate incoming references
            if (normalTriple == null)
            {
                throw new ArgumentNullException(nameof(normalTriple));
            }

            if (overrideTriple == null)
            {
                throw new ArgumentNullException(nameof(overrideTriple));
            }

            // Create the triple override instances
            _overrideBack    = new PaletteBackInheritOverride(normalTriple.PaletteBack, overrideTriple.PaletteBack);
            _overrideBorder  = new PaletteBorderInheritOverride(normalTriple.PaletteBorder, overrideTriple.PaletteBorder);
            _overrideContent = new PaletteContentInheritOverride(normalTriple.PaletteContent, overrideTriple.PaletteContent);

            // Do not apply an override by default
            Apply = false;

            // Always override the state
            Override      = true;
            OverrideState = overrideState;
        }
Exemplo n.º 4
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);
            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);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initialize a new instance of the PaletteTripleOverride class.
        /// </summary>
        /// <param name="normalTriple">Normal palette to use.</param>
        /// <param name="overrideTriple">Override palette to use.</param>
        /// <param name="overrideState">State used by the override.</param>
        public PaletteTripleOverride(IPaletteTriple normalTriple,
                                     IPaletteTriple overrideTriple,
                                     PaletteState overrideState)
        {
            Debug.Assert(normalTriple != null);
            Debug.Assert(overrideTriple != null);

            // Validate incoming references
            if (normalTriple == null) throw new ArgumentNullException("normalTriple");
            if (overrideTriple == null) throw new ArgumentNullException("overrideTriple");

            // Create the triple override instances
            _overrideBack = new PaletteBackInheritOverride(normalTriple.PaletteBack, overrideTriple.PaletteBack);
            _overrideBorder = new PaletteBorderInheritOverride(normalTriple.PaletteBorder, overrideTriple.PaletteBorder);
            _overrideContent = new PaletteContentInheritOverride(normalTriple.PaletteContent, overrideTriple.PaletteContent);

            // Do not apply an override by default
            Apply = false;

            // Always override the state
            Override = true;
            OverrideState = overrideState;
        }
        /// <summary>
        /// Initialize a new instance of the LinkLabelController class.
        /// </summary>
        /// <param name="target">Target for state changes.</param>
        /// <param name="paletteDisabled">Palette to use in the disabled state.</param>
        /// <param name="paletteNormal">Palette to use in the normal state.</param>
        /// <param name="paletteTracking">Palette to use in the tracking state.</param>
        /// <param name="palettePressed">Palette to use in the pressed state.</param>
        /// <param name="pressed">Override to update with the pressed state.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public LinkLabelController(ViewDrawContent target,
                                   IPaletteContent paletteDisabled,
                                   IPaletteContent paletteNormal,
                                   IPaletteContent paletteTracking,
                                   IPaletteContent palettePressed,
                                   PaletteContentInheritOverride pressed,
                                   NeedPaintHandler needPaint)
        {
            Debug.Assert(target != null);

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

            // Remember target for state changes
            _target          = target;
            _paletteDisabled = paletteDisabled;
            _paletteNormal   = paletteNormal;
            _paletteTracking = paletteTracking;
            _palettePressed  = palettePressed;
            _pressed         = pressed;

            // Default other properties
            _clickTime = new DateTime();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initialize a new instance of the LinkLabelController class.
        /// </summary>
        /// <param name="target">Target for state changes.</param>
        /// <param name="paletteDisabled">Palette to use in the disabled state.</param>
        /// <param name="paletteNormal">Palette to use in the normal state.</param>
        /// <param name="paletteTracking">Palette to use in the tracking state.</param>
        /// <param name="palettePressed">Palette to use in the pressed state.</param>
        /// <param name="pressed">Override to update with the pressed state.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public LinkLabelController(ViewDrawContent target,
                                   IPaletteContent paletteDisabled,
                                   IPaletteContent paletteNormal,
                                   IPaletteContent paletteTracking,
                                   IPaletteContent palettePressed,
                                   PaletteContentInheritOverride pressed,
                                   NeedPaintHandler needPaint)
        {
            Debug.Assert(target != null);

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

            // Remember target for state changes
            _target = target;
            _paletteDisabled = paletteDisabled;
            _paletteNormal = paletteNormal;
            _paletteTracking = paletteTracking;
            _palettePressed = palettePressed;
            _pressed = pressed;

            // Default other properties
            _clickTime = new DateTime();
        }
        /// <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
            Values              = new LabelValues(NeedPaintDelegate);
            Values.TextChanged += 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);
            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>
        /// Initialize a new instance of the KryptonContextMenuRadioButton class.
        /// </summary>
        /// <param name="initialText">Initial text for display.</param>
        public KryptonContextMenuRadioButton(string initialText)
        {
            // Default fields
            _enabled = true;
            _autoClose = false;
            _text = initialText;
            _extraText = string.Empty;
            _image = null;
            _imageTransparentColor = Color.Empty;
            _checked = false;
            _autoCheck = true;
            _style = LabelStyle.NormalControl;
            _images = new RadioButtonImages();

            // Create the redirectors
            _stateCommonRedirect = new PaletteContentInheritRedirect(PaletteContentStyle.LabelNormalControl);
            _stateRadioButtonImages = new PaletteRedirectRadioButton(_images);

            // Create the states
            _stateCommon = new PaletteContent(_stateCommonRedirect);
            _stateDisabled = new PaletteContent(_stateCommon);
            _stateNormal = new PaletteContent(_stateCommon);
            _stateFocus = new PaletteContent(_stateCommonRedirect);

            // Override the normal/disabled values with the focus, when the control has focus
            _overrideNormal = new PaletteContentInheritOverride(_stateFocus, _stateNormal, PaletteState.FocusOverride, false);
            _overrideDisabled = new PaletteContentInheritOverride(_stateFocus, _stateDisabled, PaletteState.FocusOverride, false);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initialize a new instance of the KryptonCheckBox class.
        /// </summary>
        public KryptonCheckBox()
        {
            // 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;
            _threeState = false;
            _checkState = CheckState.Unchecked;
            _useMnemonic = true;
            _autoCheck = true;

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

            // Create palette redirector
            _paletteCommonRedirect = new PaletteContentInheritRedirect(Redirector, PaletteContentStyle.LabelNormalControl);
            _paletteCheckBoxImages = new PaletteRedirectCheckBox(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, this, 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
            _drawCheckBox = new ViewDrawCheckBox(_paletteCheckBoxImages);
            _drawCheckBox.CheckState = _checkState;
            _layoutCenter = new ViewLayoutCenter();
            _layoutCenter.Add(_drawCheckBox);

            // 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 CheckBoxController(_drawCheckBox, _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 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.º 12
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);
        }