/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing) { if (_mementos != null) { // Dispose of all the mementos in the array foreach (IDisposable memento in _mementos) { if (memento != null) { memento.Dispose(); } } _mementos = null; } if (_buttonManager != null) { _buttonManager.Destruct(); _buttonManager = null; } } base.Dispose(disposing); }
/// <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; }
/// <summary> /// Release unmanaged and optionally managed resources. /// </summary> /// <param name="disposing">Called from Dispose method.</param> protected override void Dispose(bool disposing) { if (_buttonManager != null) { _buttonManager.Destruct(); _buttonManager = null; } // Must call base class to finish disposing base.Dispose(disposing); }
/// <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; }
/// <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 _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), null); // Hook up the tooltip manager so that tooltips can be generated _buttonManager.ToolTipManager = Navigator.ToolTipManager; // Allow derived classes to update the remapping with different values UpdateButtonSpecMapping(); } }