Inherit properties from primary source in preference to the backup source.
Наследование: PaletteRibbonDoubleInherit
Пример #1
0
        private void CheckPaletteState(ViewContext context)
        {
            // Should control be enabled or disabled
            bool enabled = IsFixed || context.Control.Enabled;

            // Ensure we and child and in correct enabled state
            Enabled = enabled;

            // Better check we have a child!
            if (Count > 0)
                this[0].Enabled = enabled;

            // If disabled...
            if (!enabled)
            {
                //...must always be using the normal overrides
                _paletteContextCurrent.SetInherit(_overrideStateNormal);
            }
            else
            {
                // Default to using this element calculated state
                PaletteState buttonState = State;

                // Update the checked state
                Checked = (_ribbon.SelectedTab == RibbonTab);

                // Is this tab a context tab?
                bool contextTab = !string.IsNullOrEmpty(RibbonTab.ContextName);

                // Apply the checked state if not fixed
                if (!IsFixed)
                {
                    if (Checked)
                    {
                        switch (buttonState)
                        {
                            case PaletteState.Normal:
                            case PaletteState.CheckedNormal:
                            case PaletteState.ContextCheckedNormal:
                                if (contextTab)
                                    buttonState = PaletteState.ContextCheckedNormal;
                                else
                                    buttonState = PaletteState.CheckedNormal;
                                break;
                            case PaletteState.Tracking:
                            case PaletteState.CheckedTracking:
                            case PaletteState.ContextCheckedTracking:
                                if (contextTab)
                                    buttonState = PaletteState.ContextCheckedTracking;
                                else
                                    buttonState = PaletteState.CheckedTracking;
                                break;
                        }
                    }
                    else
                    {
                        switch (buttonState)
                        {
                            case PaletteState.CheckedNormal:
                            case PaletteState.ContextCheckedNormal:
                                buttonState = PaletteState.Normal;
                                break;
                            case PaletteState.Tracking:
                            case PaletteState.CheckedTracking:
                            case PaletteState.ContextCheckedTracking:
                                if (contextTab)
                                    buttonState = PaletteState.ContextTracking;
                                else
                                    buttonState = PaletteState.Tracking;
                                break;
                        }
                    }
                }

                // Set the correct palette based on state
                switch (buttonState)
                {
                    case PaletteState.Disabled:
                    case PaletteState.Normal:
                        _overrideCurrent = _overrideStateNormal;
                        break;
                    case PaletteState.Tracking:
                        _overrideCurrent = _overrideStateTracking;
                        break;
                    case PaletteState.CheckedNormal:
                        _overrideCurrent = _overrideStateCheckedNormal;
                        break;
                    case PaletteState.CheckedTracking:
                        _overrideCurrent = _overrideStateCheckedTracking;
                        break;
                    case PaletteState.ContextTracking:
                        _overrideCurrent = _overrideStateContextTracking;
                        break;
                    case PaletteState.ContextCheckedNormal:
                        _overrideCurrent = _overrideStateContextCheckedNormal;
                        break;
                    case PaletteState.ContextCheckedTracking:
                        _overrideCurrent = _overrideStateContextCheckedTracking;
                        break;
                    default:
                        // Should never happen!
                        Debug.Assert(false);
                        break;
                }

                // Switch the child elements over to correct state
                ElementState = buttonState;

                // Better check we have a child!
                if (Count > 0)
                    this[0].ElementState = buttonState;

                // Update the actual source palette
                _paletteContextCurrent.SetInherit(_overrideCurrent);
            }
        }
Пример #2
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawRibbonTab class.
        /// </summary>
        /// <param name="ribbon">Reference to owning ribbon control.</param>
        /// <param name="layoutTabs">Reference to view used for layout out tabs.</param>
        /// <param name="needPaint">Delegate for notifying paint requests.</param>
        public ViewDrawRibbonTab(KryptonRibbon ribbon,
                                 ViewLayoutRibbonTabs layoutTabs,
                                 NeedPaintHandler needPaint)
        {
            Debug.Assert(ribbon != null);
            Debug.Assert(layoutTabs != null);
            Debug.Assert(needPaint != null);

            // Cache incoming values
            _ribbon = ribbon;
            _layoutTabs = layoutTabs;
            _needPaint = needPaint;

            // Create overrides for handling a focus state
            _paletteGeneral = ribbon.StateCommon.RibbonGeneral;
            _overrideStateNormal = new PaletteRibbonDoubleInheritOverride(_ribbon.OverrideFocus.RibbonTab, _ribbon.OverrideFocus.RibbonTab, _ribbon.StateNormal.RibbonTab, _ribbon.StateNormal.RibbonTab, PaletteState.FocusOverride);
            _overrideStateTracking = new PaletteRibbonDoubleInheritOverride(_ribbon.OverrideFocus.RibbonTab, _ribbon.OverrideFocus.RibbonTab, _ribbon.StateTracking.RibbonTab, _ribbon.StateTracking.RibbonTab, PaletteState.FocusOverride);
            _overrideStateCheckedNormal = new PaletteRibbonDoubleInheritOverride(_ribbon.OverrideFocus.RibbonTab, _ribbon.OverrideFocus.RibbonTab, _ribbon.StateCheckedNormal.RibbonTab, _ribbon.StateCheckedNormal.RibbonTab, PaletteState.FocusOverride);
            _overrideStateCheckedTracking = new PaletteRibbonDoubleInheritOverride(_ribbon.OverrideFocus.RibbonTab, _ribbon.OverrideFocus.RibbonTab, _ribbon.StateCheckedTracking.RibbonTab, _ribbon.StateCheckedTracking.RibbonTab, PaletteState.FocusOverride);
            _overrideStateContextTracking = new PaletteRibbonDoubleInheritOverride(_ribbon.OverrideFocus.RibbonTab, _ribbon.OverrideFocus.RibbonTab, _ribbon.StateContextTracking.RibbonTab, _ribbon.StateContextTracking.RibbonTab, PaletteState.FocusOverride);
            _overrideStateContextCheckedNormal = new PaletteRibbonDoubleInheritOverride(_ribbon.OverrideFocus.RibbonTab, _ribbon.OverrideFocus.RibbonTab, _ribbon.StateContextCheckedNormal.RibbonTab, _ribbon.StateContextCheckedNormal.RibbonTab, PaletteState.FocusOverride);
            _overrideStateContextCheckedTracking = new PaletteRibbonDoubleInheritOverride(_ribbon.OverrideFocus.RibbonTab, _ribbon.OverrideFocus.RibbonTab, _ribbon.StateContextCheckedTracking.RibbonTab, _ribbon.StateContextCheckedTracking.RibbonTab, PaletteState.FocusOverride);
            _overrideCurrent = _overrideStateNormal;

            // Create and default the setup of the context colors provider
            _paletteContextCurrent = new PaletteRibbonContextDouble(_ribbon);
            _paletteContextCurrent.SetInherit(_overrideCurrent);

            // Use a class to convert from ribbon tab to content interface
            _contentProvider = new RibbonTabToContent(_paletteGeneral, _paletteContextCurrent);

            // Use a controller to change state because of mouse movement
            RibbonTabController controller = new RibbonTabController(_ribbon, this, _needPaint);
            controller.Click += new MouseEventHandler(OnTabClicked);
            controller.ContextClick += new MouseEventHandler(OnTabContextClicked);
            MouseController = controller;
            SourceController = controller;
            KeyController = controller;

            // Associate this view with the source component (required for design time selection)
            Component = _ribbonTab;

            // Create and add the draw content for display inside the tab
            Add(new ViewDrawContent(_contentProvider, this, VisualOrientation.Top, true, false));

            // Create the state specific memento array
            _mementos = new IDisposable[Enum.GetValues(typeof(PaletteState)).Length];
        }
 /// <summary>
 /// Sets the inheritence parent.
 /// </summary>
 public void SetInherit(PaletteRibbonDoubleInheritOverride inherit)
 {
     _inherit = inherit;
 }