Example #1
0
        /// <summary>
        /// Create a manager for handling the button specifications.
        /// </summary>
        protected override void CreateButtonSpecManager()
        {
            // Let base class create the button spec manager
            base.CreateButtonSpecManager();

            // Modify the way that button specs are remapped
            ButtonSpecNavManagerLayoutBar barManager = (ButtonSpecNavManagerLayoutBar)_buttonManager;

            // Remap the normal color onto the button text
            barManager.RemapTarget = ButtonSpecNavRemap.ButtonSpecRemapTarget.ButtonStandalone;
        }
Example #2
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawNavRibbonTab class.
        /// </summary>
        /// <param name="navigator">Owning navigator instance.</param>
        /// <param name="page">Page this ribbon tab represents.</param>
        public ViewDrawNavRibbonTab(KryptonNavigator navigator,
                                    KryptonPage page)
        {
            Debug.Assert(navigator != null);
            Debug.Assert(page != null);

            Navigator  = navigator;
            Page       = page;
            _lastClick = DateTime.Now.AddDays(-1);

            // Associate the page component with this view element
            Component = page;

            // Create a controller for managing button behavior
            _buttonController = new PageButtonController(this, OnNeedPaint)
            {
                ClickOnDown = true
            };
            _buttonController.Click      += OnClick;
            _buttonController.RightClick += OnRightClick;

            // Allow the page to be dragged and hook into drag events
            _buttonController.AllowDragging        = true;
            _buttonController.DragStart           += OnDragStart;
            _buttonController.DragMove            += OnDragMove;
            _buttonController.DragEnd             += OnDragEnd;
            _buttonController.DragQuit            += OnDragQuit;
            _buttonController.ButtonDragRectangle += OnButtonDragRectangle;
            _buttonController.ButtonDragOffset    += OnButtonDragOffset;

            // A tab is selected on being pressed and not on the mouse up
            _buttonController.ClickOnDown = true;

            // We need to be notified of got/lost focus and keyboard events
            SourceController = _buttonController;
            KeyController    = _buttonController;

            // Create a decorator to interface with the tooltip manager
            ToolTipController toolTipController = new ToolTipController(Navigator.ToolTipManager, this, _buttonController);
            ToolTipController hoverController   = new ToolTipController(Navigator.HoverManager, this, toolTipController);

            // Assign controller for handing mouse input
            MouseController = hoverController;

            // Create overrides for handling a focus state
            _paletteGeneral        = Navigator.StateCommon.RibbonGeneral;
            _overrideStateNormal   = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StateNormal.RibbonTab.TabDraw, Page.StateNormal.RibbonTab.TabDraw, Page.StateNormal.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateTracking = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StateTracking.RibbonTab.TabDraw, Page.StateTracking.RibbonTab.TabDraw, Page.StateTracking.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStatePressed  = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StatePressed.RibbonTab.TabDraw, Page.StatePressed.RibbonTab.TabDraw, Page.StatePressed.RibbonTab.Content, PaletteState.FocusOverride);
            _overrideStateSelected = new PaletteRibbonTabContentInheritOverride(Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.TabDraw, Page.OverrideFocus.RibbonTab.Content, Page.StateSelected.RibbonTab.TabDraw, Page.StateSelected.RibbonTab.TabDraw, Page.StateSelected.RibbonTab.Content, PaletteState.FocusOverride);

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

            // Create the content view element and use the content provider as a way to
            // convert from the ribbon palette entries to the content palette entries
            _viewContent = new ViewDrawContent(_contentProvider, this, VisualOrientation.Top);

            // Add content to the view
            _layoutDocker = new ViewLayoutDocker
            {
                { _viewContent, ViewDockStyle.Fill }
            };
            Add(_layoutDocker);

            // Create button specification collection manager
            ButtonSpecManager = new ButtonSpecNavManagerLayoutBar(Navigator, Navigator.InternalRedirector, Page.ButtonSpecs, null,
                                                                  new ViewLayoutDocker[] { _layoutDocker },
                                                                  new IPaletteMetric[] { Navigator.StateCommon },
                                                                  new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                  new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                  new PaletteMetricPadding[] { PaletteMetricPadding.PageButtonPadding },
                                                                  Navigator.CreateToolStripRenderer,
                                                                  OnNeedPaint)
            {
                // Hook up the tooltip manager so that tooltips can be generated
                ToolTipManager = Navigator.ToolTipManager,
                RemapTarget    = ButtonSpecNavRemap.ButtonSpecRemapTarget.ButtonStandalone
            };

            // Ensure current button specs are created
            ButtonSpecManager.RecreateButtons();

            // Create the state specific memento array
            _mementos = new IDisposable[Enum.GetValues(typeof(PaletteState)).Length];

            // Cache the last shape encountered
            _lastRibbonShape = PaletteRibbonShape.Office2010;
        }
Example #3
0
        /// <summary>
        /// Initialize a new instance of the ViewDrawNavCheckButtonBase class.
        /// </summary>
        /// <param name="navigator">Owning navigator instance.</param>
        /// <param name="page">Page this check button represents.</param>
        /// <param name="orientation">Orientation for the check button.</param>
        /// <param name="stateDisabled">Source for disabled state values.</param>
        /// <param name="stateNormal">Source for normal state values.</param>
        /// <param name="stateTracking">Source for tracking state values.</param>
        /// <param name="statePressed">Source for pressed state values.</param>
        /// <param name="stateSelected">Source for selected state values.</param>
        /// <param name="stateFocused">Source for focused state values.</param>
        public ViewDrawNavCheckButtonBase(KryptonNavigator navigator,
                                          KryptonPage page,
                                          VisualOrientation orientation,
                                          IPaletteTriple stateDisabled,
                                          IPaletteTriple stateNormal,
                                          IPaletteTriple stateTracking,
                                          IPaletteTriple statePressed,
                                          IPaletteTriple stateSelected,
                                          IPaletteTriple stateFocused)
            : base(stateDisabled, stateNormal, stateTracking,
                   statePressed, null, null, orientation, true)
        {
            Debug.Assert(navigator != null);

            Navigator  = navigator;
            _page      = page;
            _lastClick = DateTime.Now.AddDays(-1);

            // Associate the page component with this view element
            Component = page;

            // Prevent user from unchecking the selected check button
            AllowUncheck = false;

            // Set the source for values to ourself
            ButtonValues = this;

            // Create a controller for managing button behavior
            IMouseController controller = CreateMouseController();

            MouseController = controller;

            // Create overrides for getting the focus values
            _overrideDisabled = new PaletteTripleOverride(stateFocused, stateDisabled, PaletteState.FocusOverride);
            _overrideNormal   = new PaletteTripleOverride(stateFocused, stateNormal, PaletteState.FocusOverride);
            _overrideTracking = new PaletteTripleOverride(stateFocused, stateTracking, PaletteState.FocusOverride);
            _overridePressed  = new PaletteTripleOverride(stateFocused, statePressed, PaletteState.FocusOverride);
            _overrideSelected = new PaletteTripleOverride(stateFocused, stateSelected, PaletteState.FocusOverride);

            // Push values into the base class
            SetPalettes(_overrideDisabled, _overrideNormal, _overrideTracking, _overridePressed);
            SetCheckedPalettes(_overrideSelected, _overrideSelected, _overrideSelected);

            // Are we allowed to add button specs to the button?
            if (AllowButtonSpecs)
            {
                // Create button specification collection manager
                ButtonSpecManager = new ButtonSpecNavManagerLayoutBar(Navigator, Navigator.InternalRedirector, Page.ButtonSpecs, null,
                                                                      new ViewLayoutDocker[] { LayoutDocker },
                                                                      new IPaletteMetric[] { Navigator.StateCommon },
                                                                      new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                      new PaletteMetricInt[] { PaletteMetricInt.PageButtonInset },
                                                                      new PaletteMetricPadding[] { PaletteMetricPadding.PageButtonPadding },
                                                                      Navigator.CreateToolStripRenderer,
                                                                      null)
                {
                    // Hook up the tooltip manager so that tooltips can be generated
                    ToolTipManager = Navigator.ToolTipManager
                };

                // Allow derived classes to update the remapping with different values
                UpdateButtonSpecMapping();
            }
        }