Inheritance: IPaletteContent
        /// <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;
        }
Esempio n. 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, new NeedPaintHandler(OnNeedPaint));
            _buttonController.ClickOnDown = true;
            _buttonController.Click += new MouseEventHandler(OnClick);
            _buttonController.RightClick += new MouseEventHandler(OnRightClick);

            // Allow the page to be dragged and hook into drag events
            _buttonController.AllowDragging = true;
            _buttonController.DragStart += new EventHandler<DragStartEventCancelArgs>(OnDragStart);
            _buttonController.DragMove += new EventHandler<PointEventArgs>(OnDragMove);
            _buttonController.DragEnd += new EventHandler<PointEventArgs>(OnDragEnd);
            _buttonController.DragQuit += new EventHandler(OnDragQuit);
            _buttonController.ButtonDragRectangle += new EventHandler<ButtonDragRectangleEventArgs>(OnButtonDragRectangle);
            _buttonController.ButtonDragOffset += new EventHandler<ButtonDragOffsetEventArgs>(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();
            _layoutDocker.Add(_viewContent, ViewDockStyle.Fill);
            Add(_layoutDocker);

            // Create button specification collection manager
            _buttonManager = 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 },
                                                               new GetToolStripRenderer(Navigator.CreateToolStripRenderer),
                                                               new NeedPaintHandler(OnNeedPaint));

            // Hook up the tooltip manager so that tooltips can be generated
            _buttonManager.ToolTipManager = Navigator.ToolTipManager;
            _buttonManager.RemapTarget = ButtonSpecNavRemap.ButtonSpecRemapTarget.ButtonStandalone;

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

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

            // Cache the last shape encountered
            _lastRibbonShape = PaletteRibbonShape.Office2010;
        }