ComponentFactory.Krypton.Toolkit.ViewDrawSplitCanvas.SetPalettes C# (CSharp) Method

SetPalettes() public method

Update the source palettes for drawing.
public SetPalettes ( IPaletteBack paletteBack, IPaletteBorder paletteBorder ) : void
paletteBack IPaletteBack Palette source for the background.
paletteBorder IPaletteBorder Palette source for the border.
return void
        public virtual void SetPalettes(IPaletteBack paletteBack,
                                        IPaletteBorder paletteBorder)
        {
            SetPalettes(paletteBack, paletteBorder, _paletteMetric);
        }

Same methods

ViewDrawSplitCanvas::SetPalettes ( IPaletteBack paletteBack, IPaletteBorder paletteBorder, IPaletteMetric paletteMetric ) : void

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Check that the palette and state are correct.
        /// </summary>
        /// <param name="context">Reference to the view context.</param>
        protected virtual void CheckPaletteState(ViewContext context)
        {
            // Default to using this element calculated state
            PaletteState buttonState = State;

            // If the actual control is not enabled, force to disabled state
            if (!IsFixed && !context.Control.Enabled)
            {
                buttonState = PaletteState.Disabled;
            }

            // Apply the checked state if not fixed
            if (!IsFixed && Checked)
            {
                // Is the checked button allowed to become unchecked
                if (AllowUncheck)
                {
                    // Show feedback on tracking and presssed
                    switch (buttonState)
                    {
                    case PaletteState.Normal:
                        buttonState = PaletteState.CheckedNormal;
                        break;

                    case PaletteState.Tracking:
                        buttonState = PaletteState.CheckedTracking;
                        break;

                    case PaletteState.Pressed:
                        buttonState = PaletteState.CheckedPressed;
                        break;
                    }
                }
                else
                {
                    // Always use the normal state as user cannot uncheck the button
                    buttonState = PaletteState.CheckedNormal;
                }
            }

            // If the child elements are not in correct state
            if (_forcePaletteUpdate || (_drawCanvas.ElementState != buttonState))
            {
                // No longer need to force the palettes to be updated
                _forcePaletteUpdate = false;

                // Switch the child elements over to correct state
                _drawCanvas.ElementState         = buttonState;
                _drawContent.ElementState        = buttonState;
                _drawSplitBorder.ElementState    = buttonState;
                _drawDropDownButton.ElementState = buttonState;

                // Push the correct palettes into them
                switch (buttonState)
                {
                case PaletteState.Disabled:
                    _paletteCurrent = _paletteDisabled;
                    break;

                case PaletteState.Normal:
                    _paletteCurrent = _paletteNormal;
                    break;

                case PaletteState.CheckedNormal:
                    _paletteCurrent = _paletteCheckedNormal;
                    break;

                case PaletteState.Pressed:
                    _paletteCurrent = _palettePressed;
                    break;

                case PaletteState.CheckedPressed:
                    _paletteCurrent = _paletteCheckedPressed;
                    break;

                case PaletteState.Tracking:
                    _paletteCurrent = _paletteTracking;
                    break;

                case PaletteState.CheckedTracking:
                    _paletteCurrent = _paletteCheckedTracking;
                    break;

                default:
                    // Should never happen!
                    Debug.Assert(false);
                    break;
                }

                // Update with the correct palettes
                _drawCanvas.SetPalettes(_paletteCurrent.PaletteBack, _paletteCurrent.PaletteBorder);
                _drawContent.SetPalette(_paletteCurrent.PaletteContent);
                _edgeRedirect.SetPalette(_paletteCurrent.PaletteBorder);
            }
        }