/// <summary> /// Initialize a new instance of the PaletteRibbonGeneral class. /// </summary> /// <param name="inherit">Source for inheriting general values.</param> /// <param name="needPaint">Delegate for notifying paint requests.</param> public PaletteRibbonGeneral(IPaletteRibbonGeneral inherit, NeedPaintHandler needPaint) { Debug.Assert(inherit != null); // Remember inheritance _inherit = inherit; // Store the provided paint notification delegate NeedPaint = needPaint; // Set default values _contextTextAlign = PaletteRelativeAlign.Inherit; _contextTextColor = Color.Empty; _contextTextFont = null; _disabledDarkColor = Color.Empty; _disabledLightColor = Color.Empty; _dialogDarkColor = Color.Empty; _dialogLightColor = Color.Empty; _dropArrowLightColor = Color.Empty; _dropArrowDarkColor = Color.Empty; _groupSeparatorDark = Color.Empty; _groupSeparatorLight = Color.Empty; _minimizeBarDarkColor = Color.Empty; _minimizeBarLightColor = Color.Empty; _ribbonShape = PaletteRibbonShape.Inherit; _tabSeparatorColor = Color.Empty; _tabSeparatorContextColor = Color.Empty; _textFont = null; _textHint = PaletteTextHint.Inherit; _qatButtonDarkColor = Color.Empty; _qatButtonLightColor = Color.Empty; }
/// <summary> /// Initialize a new instance of the RibbonTabToContent class. /// </summary> /// <param name="ribbonGeneral">Source for general ribbon settings.</param> /// <param name="ribbonTabText">Source for ribbon tab settings.</param> /// <param name="content">Source for content settings.</param> public RibbonTabToContent(IPaletteRibbonGeneral ribbonGeneral, IPaletteRibbonText ribbonTabText, IPaletteContent content) { Debug.Assert(ribbonGeneral != null); Debug.Assert(ribbonTabText != null); Debug.Assert(content != null); _ribbonGeneral = ribbonGeneral; _ribbonTabText = ribbonTabText; _content = content; }
/// <summary> /// Perform drawing of a ribbon drop arrow glyph. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteGeneral">General ribbon palette details.</param> /// <param name="state">State associated with rendering.</param> public override void DrawRibbonDropArrow(PaletteRibbonShape shape, RenderContext context, Rectangle displayRect, IPaletteRibbonGeneral paletteGeneral, PaletteState state) { Debug.Assert(context != null); Debug.Assert(paletteGeneral != null); // Validate parameter references if (context == null) throw new ArgumentNullException("context"); if (paletteGeneral == null) throw new ArgumentNullException("paletteGeneral"); Color darkColor = (state == PaletteState.Disabled ? paletteGeneral.GetRibbonDisabledDark(state) : paletteGeneral.GetRibbonGroupDialogDark(state)); Color lightColor = (state == PaletteState.Disabled ? paletteGeneral.GetRibbonDisabledLight(state) : paletteGeneral.GetRibbonGroupDialogLight(state)); using (Pen darkPen = new Pen(darkColor), lightPen = new Pen(lightColor)) { context.Graphics.DrawLine(lightPen, displayRect.Left, displayRect.Top + 1, displayRect.Left + 2, displayRect.Top + 3); context.Graphics.DrawLine(lightPen, displayRect.Left + 2, displayRect.Top + 3, displayRect.Left + 4, displayRect.Top + 1); context.Graphics.DrawLine(lightPen, displayRect.Left + 4, displayRect.Top + 1, displayRect.Left + 1, displayRect.Top + 1); context.Graphics.DrawLine(lightPen, displayRect.Left + 1, displayRect.Top + 1, displayRect.Left + 2, displayRect.Top + 2); context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top + 2, displayRect.Left + 2, displayRect.Top + 4); context.Graphics.DrawLine(darkPen, displayRect.Left + 2, displayRect.Top + 4, displayRect.Left + 4, displayRect.Top + 2); } }
/// <summary> /// Perform drawing of a ribbon overflow image. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteGeneral">General ribbon palette details.</param> /// <param name="state">State associated with rendering.</param> public abstract void DrawRibbonOverflow(PaletteRibbonShape shape, RenderContext context, Rectangle displayRect, IPaletteRibbonGeneral paletteGeneral, PaletteState state);
/// <summary> /// Internal rendering method. /// </summary> protected override IDisposable DrawRibbonTabContext(RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal); Color c2 = paletteBack.GetRibbonBackColor5(PaletteState.ContextCheckedNormal); bool generate = true; MementoRibbonTabContextOffice2010 cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabContextOffice2010)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonTabContextOffice2010(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonTabContextOffice2010)memento; generate = !cache.UseCachedValues(rect, c1, c2); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); cache.borderOuterPen = new Pen(c1); cache.borderInnerPen = new Pen(CommonHelper.MergeColors(Color.Black, 0.1f, c2, 0.9f)); cache.topBrush = new SolidBrush(c2); Color lightC2 = ControlPaint.Light(c2); cache.bottomBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y, rect.Width + 2, rect.Height + 1), Color.FromArgb(128, lightC2), Color.FromArgb(64, lightC2), 90f); } // Draw the left and right borders context.Graphics.DrawLine(cache.borderOuterPen, rect.X, rect.Y, rect.X, rect.Bottom); context.Graphics.DrawLine(cache.borderInnerPen, rect.X + 1, rect.Y, rect.X + 1, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderOuterPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderInnerPen, rect.Right - 2, rect.Y, rect.Right - 2, rect.Bottom - 1); // Draw the solid block of colour at the top context.Graphics.FillRectangle(cache.topBrush, rect.X + 2, rect.Y, rect.Width - 4, 4); // Draw the gradient to the bottom context.Graphics.FillRectangle(cache.bottomBrush, rect.X + 2, rect.Y + 4, rect.Width - 4, rect.Height - 4); } return memento; }
/// <summary> /// Draw a context ribbon tab title. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Rendering context.</param> /// <param name="rect">Target rectangle.</param> /// <param name="paletteGeneral">Palette used for general ribbon settings.</param> /// <param name="paletteBack">Palette used for background ribbon settings.</param> /// <param name="memento">Cached storage for drawing objects.</param> public override IDisposable DrawRibbonTabContextTitle(PaletteRibbonShape shape, RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento) { return DrawRibbonTabContext(context, rect, paletteGeneral, paletteBack, memento); }
/// <summary> /// Perform drawing of a ribbon group separator. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteGeneral">General ribbon palette details.</param> /// <param name="state">State associated with rendering.</param> public override void DrawRibbonGroupSeparator(PaletteRibbonShape shape, RenderContext context, Rectangle displayRect, IPaletteRibbonGeneral paletteGeneral, PaletteState state) { Debug.Assert(context != null); Debug.Assert(paletteGeneral != null); // Validate parameter references if (context == null) throw new ArgumentNullException("context"); if (paletteGeneral == null) throw new ArgumentNullException("paletteGeneral"); int x = displayRect.X + (displayRect.Width - 2) / 2; Color darkColor = paletteGeneral.GetRibbonGroupSeparatorDark(state); Color lightColor = paletteGeneral.GetRibbonGroupSeparatorLight(state); switch (shape) { default: case PaletteRibbonShape.Office2007: using (Pen darkPen = new Pen(darkColor), lightPen = new Pen(lightColor)) { context.Graphics.DrawLine(lightPen, x, displayRect.Top + 2, x, displayRect.Bottom - 3); context.Graphics.DrawLine(darkPen, x + 1, displayRect.Top + 2, x + 1, displayRect.Bottom - 3); } break; case PaletteRibbonShape.Office2010: using (LinearGradientBrush darkBrush = new LinearGradientBrush(new RectangleF(displayRect.X, displayRect.Y - 1, displayRect.Width, displayRect.Height + 2), Color.FromArgb(72, darkColor), darkColor, 90f), lightBrush = new LinearGradientBrush(new RectangleF(displayRect.X - 1, displayRect.Y - 1, displayRect.Width + 2, displayRect.Height + 2), Color.FromArgb(128, lightColor), lightColor, 90f)) { darkBrush.SetSigmaBellShape(0.5f); lightBrush.SetSigmaBellShape(0.5f); using (Pen darkPen = new Pen(darkBrush)) { context.Graphics.FillRectangle(lightBrush, x, displayRect.Top, 3, displayRect.Height); context.Graphics.DrawLine(darkPen, x + 1, displayRect.Top, x + 1, displayRect.Bottom - 1); } } break; } }
/// <summary> /// Perform drawing of a ribbon dialog box launcher glyph. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteGeneral">General ribbon palette details.</param> /// <param name="state">State associated with rendering.</param> public override void DrawRibbonDialogBoxLauncher(PaletteRibbonShape shape, RenderContext context, Rectangle displayRect, IPaletteRibbonGeneral paletteGeneral, PaletteState state) { Debug.Assert(context != null); Debug.Assert(paletteGeneral != null); // Validate parameter references if (context == null) throw new ArgumentNullException("context"); if (paletteGeneral == null) throw new ArgumentNullException("paletteGeneral"); switch (shape) { default: case PaletteRibbonShape.Office2007: using (Pen darkPen = new Pen(paletteGeneral.GetRibbonGroupDialogDark(state)), lightPen = new Pen(paletteGeneral.GetRibbonGroupDialogLight(state))) { context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top + 5, displayRect.Left, displayRect.Top); context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top, displayRect.Left + 5, displayRect.Top); context.Graphics.DrawLine(lightPen, displayRect.Left + 1, displayRect.Top + 5, displayRect.Left + 1, displayRect.Top + 1); context.Graphics.DrawLine(lightPen, displayRect.Left + 1, displayRect.Top + 1, displayRect.Left + 5, displayRect.Top + 1); context.Graphics.DrawLine(lightPen, displayRect.Right - 1, displayRect.Bottom - 5, displayRect.Right - 1, displayRect.Bottom - 1); context.Graphics.DrawLine(lightPen, displayRect.Right - 1, displayRect.Bottom - 1, displayRect.Right - 4, displayRect.Bottom - 1); context.Graphics.DrawLine(lightPen, displayRect.Right - 1, displayRect.Bottom - 1, displayRect.Right - 4, displayRect.Bottom - 5); context.Graphics.DrawLine(darkPen, displayRect.Right - 5, displayRect.Bottom - 2, displayRect.Right - 2, displayRect.Bottom - 2); context.Graphics.DrawLine(darkPen, displayRect.Right - 4, displayRect.Bottom - 3, displayRect.Right - 3, displayRect.Bottom - 3); context.Graphics.DrawLine(darkPen, displayRect.Right - 2, displayRect.Bottom - 2, displayRect.Right - 2, displayRect.Bottom - 5); context.Graphics.DrawLine(darkPen, displayRect.Right - 3, displayRect.Bottom - 3, displayRect.Right - 3, displayRect.Bottom - 4); context.Graphics.DrawLine(darkPen, displayRect.Right - 5, displayRect.Bottom - 5, displayRect.Right - 3, displayRect.Bottom - 3); } break; case PaletteRibbonShape.Office2010: LinearGradientBrush dialogBrush = new LinearGradientBrush(new RectangleF(displayRect.X - 1, displayRect.Y - 1, displayRect.Width + 2, displayRect.Height + 2), paletteGeneral.GetRibbonGroupDialogLight(state), paletteGeneral.GetRibbonGroupDialogDark(state), 45f); using (Pen dialogPen = new Pen(dialogBrush)) { context.Graphics.DrawLine(dialogPen, displayRect.Left, displayRect.Top + 5, displayRect.Left, displayRect.Top); context.Graphics.DrawLine(dialogPen, displayRect.Left, displayRect.Top, displayRect.Left + 5, displayRect.Top); context.Graphics.DrawLine(dialogPen, displayRect.Right - 5, displayRect.Bottom - 2, displayRect.Right - 2, displayRect.Bottom - 2); context.Graphics.DrawLine(dialogPen, displayRect.Right - 4, displayRect.Bottom - 3, displayRect.Right - 3, displayRect.Bottom - 3); context.Graphics.DrawLine(dialogPen, displayRect.Right - 2, displayRect.Bottom - 2, displayRect.Right - 2, displayRect.Bottom - 5); context.Graphics.DrawLine(dialogPen, displayRect.Right - 3, displayRect.Bottom - 3, displayRect.Right - 3, displayRect.Bottom - 4); context.Graphics.DrawLine(dialogPen, displayRect.Right - 5, displayRect.Bottom - 5, displayRect.Right - 3, displayRect.Bottom - 3); } break; } }
/// <summary> /// Internal rendering method. /// </summary> protected override IDisposable DrawRibbonTabContext(RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal); Color c2 = paletteBack.GetRibbonBackColor5(PaletteState.ContextCheckedNormal); bool generate = true; MementoRibbonTabContextOffice cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabContextOffice)) { if (memento != null) { memento.Dispose(); } cache = new MementoRibbonTabContextOffice(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonTabContextOffice)memento; generate = !cache.UseCachedValues(rect, c1, c2); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); Rectangle borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); cache.fillRect = new Rectangle(rect.X + 1, rect.Y, rect.Width - 2, rect.Height - 1); LinearGradientBrush borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f); borderBrush.Blend = _ribbonGroup5Blend; cache.borderPen = new Pen(borderBrush); LinearGradientBrush underlineBrush = new LinearGradientBrush(borderRect, Color.Transparent, Color.FromArgb(200, c2), 0f); underlineBrush.Blend = _ribbonGroup7Blend; cache.underlinePen = new Pen(underlineBrush); cache.fillBrush = new LinearGradientBrush(borderRect, Color.FromArgb(106, c2), Color.Transparent, 270f); cache.fillBrush.Blend = _ribbonGroup6Blend; } // Draw the left and right border lines context.Graphics.DrawLine(cache.borderPen, rect.X, rect.Y, rect.X, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); // Fill the inner area with a gradient context specific color context.Graphics.FillRectangle(cache.fillBrush, cache.fillRect); // Overdraw the brighter line at bottom context.Graphics.DrawLine(cache.underlinePen, rect.X + 1, rect.Bottom - 2, rect.Right - 2, rect.Bottom - 2); } return(memento); }
/// <summary> /// Sets the inheritance parent. /// </summary> public void SetInherit(IPaletteRibbonGeneral inherit) => _inherit = inherit;
/// <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 ViewDrawRibbonTabSep class. /// </summary> /// <param name="palette">Source for palette values.</param> public ViewDrawRibbonTabSep(IPaletteRibbonGeneral palette) : base(SEP_WIDTH, true) { Debug.Assert(palette != null); _palette = palette; }
/// <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> /// Internal rendering method. /// </summary> protected override IDisposable DrawRibbonTabContext(RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal); Color c2 = paletteBack.GetRibbonBackColor5(PaletteState.ContextCheckedNormal); bool generate = true; MementoRibbonTabContextOffice2010 cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabContextOffice2010)) { if (memento != null) { memento.Dispose(); } cache = new MementoRibbonTabContextOffice2010(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonTabContextOffice2010)memento; generate = !cache.UseCachedValues(rect, c1, c2); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); cache.borderOuterPen = new Pen(c1); cache.borderInnerPen = new Pen(CommonHelper.MergeColors(Color.Black, 0.1f, c2, 0.9f)); cache.topBrush = new SolidBrush(c2); Color lightC2 = ControlPaint.Light(c2); cache.bottomBrush = new LinearGradientBrush(new RectangleF(rect.X - 1, rect.Y, rect.Width + 2, rect.Height + 1), Color.FromArgb(128, lightC2), Color.FromArgb(64, lightC2), 90f); } // Draw the left and right borders context.Graphics.DrawLine(cache.borderOuterPen, rect.X, rect.Y, rect.X, rect.Bottom); context.Graphics.DrawLine(cache.borderInnerPen, rect.X + 1, rect.Y, rect.X + 1, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderOuterPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderInnerPen, rect.Right - 2, rect.Y, rect.Right - 2, rect.Bottom - 1); // Draw the solid block of colour at the top context.Graphics.FillRectangle(cache.topBrush, rect.X + 2, rect.Y, rect.Width - 4, 4); // Draw the gradient to the bottom context.Graphics.FillRectangle(cache.bottomBrush, rect.X + 2, rect.Y + 4, rect.Width - 4, rect.Height - 4); } return(memento); }
/// <summary> /// Sets the inheritence parent. /// </summary> public void SetInherit(IPaletteRibbonGeneral inherit) { _inherit = inherit; }
/// <summary> /// Gets the color for the dialog launcher dark. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonGroupDialogDark(PaletteState state) { IPaletteRibbonGeneral inherit = GetInherit(state); return(inherit?.GetRibbonGroupDialogDark(state) ?? Target.GetRibbonGroupDialogDark(state)); }
/// <summary> /// Perform drawing of a ribbon drop arrow glyph. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteGeneral">General ribbon palette details.</param> /// <param name="state">State associated with rendering.</param> public override void DrawRibbonDropArrow(PaletteRibbonShape shape, RenderContext context, Rectangle displayRect, IPaletteRibbonGeneral paletteGeneral, PaletteState state) { Debug.Assert(context != null); Debug.Assert(paletteGeneral != null); // Validate parameter references if (context == null) throw new ArgumentNullException("context"); if (paletteGeneral == null) throw new ArgumentNullException("paletteGeneral"); Color darkColor = (state == PaletteState.Disabled ? paletteGeneral.GetRibbonDisabledDark(state) : paletteGeneral.GetRibbonDropArrowDark(state)); Color lightColor = (state == PaletteState.Disabled ? paletteGeneral.GetRibbonDisabledLight(state) : paletteGeneral.GetRibbonDropArrowLight(state)); switch (shape) { default: case PaletteRibbonShape.Office2007: using (Pen darkPen = new Pen(darkColor), lightPen = new Pen(lightColor)) { context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top, displayRect.Left + 4, displayRect.Top); context.Graphics.DrawLine(darkPen, displayRect.Left + 1, displayRect.Top + 1, displayRect.Left + 3, displayRect.Top + 1); context.Graphics.DrawLine(darkPen, displayRect.Left + 2, displayRect.Top + 1, displayRect.Left + 2, displayRect.Top + 2); context.Graphics.DrawLine(lightPen, displayRect.Left, displayRect.Top + 1, displayRect.Left + 2, displayRect.Top + 3); context.Graphics.DrawLine(lightPen, displayRect.Left + 2, displayRect.Top + 3, displayRect.Left + 4, displayRect.Top + 1); } break; case PaletteRibbonShape.Office2010: using (LinearGradientBrush fillBrush = new LinearGradientBrush(new RectangleF(displayRect.X - 1, displayRect.Y - 1, displayRect.Width + 2, displayRect.Height + 2), lightColor, darkColor, 45f)) { context.Graphics.FillPolygon(fillBrush, new Point[]{ new Point(displayRect.Left - 1, displayRect.Top - 1), new Point(displayRect.Left + 2, displayRect.Top + 3), new Point(displayRect.Left + 5, displayRect.Top) }); } break; } }
/// <summary> /// Gets the color for the group separator light. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonGroupSeparatorLight(PaletteState state) { IPaletteRibbonGeneral inherit = GetInherit(state); return(inherit?.GetRibbonGroupSeparatorLight(state) ?? Target.GetRibbonGroupSeparatorLight(state)); }
/// <summary> /// Perform drawing of a ribbon overflow image. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteGeneral">General ribbon palette details.</param> /// <param name="state">State associated with rendering.</param> public override void DrawRibbonOverflow(PaletteRibbonShape shape, RenderContext context, Rectangle displayRect, IPaletteRibbonGeneral paletteGeneral, PaletteState state) { Debug.Assert(context != null); Debug.Assert(paletteGeneral != null); // Validate parameter references if (context == null) throw new ArgumentNullException("context"); if (paletteGeneral == null) throw new ArgumentNullException("paletteGeneral"); Color c1 = paletteGeneral.GetRibbonQATButtonDark(state); Color c2 = paletteGeneral.GetRibbonQATButtonLight(state); // Office 2010 uses the same color for both parts if (shape == PaletteRibbonShape.Office2010) c2 = c1; // If disabled then convert to black and white if (state == PaletteState.Disabled) { c1 = CommonHelper.ColorToBlackAndWhite(c1); c2 = CommonHelper.ColorToBlackAndWhite(c2); } using (Pen darkPen = new Pen(c1), lightPen = new Pen(c2)) { context.Graphics.DrawLine(darkPen, displayRect.Left, displayRect.Top + 1, displayRect.Left, displayRect.Top + 3); context.Graphics.DrawLine(darkPen, displayRect.Left + 1, displayRect.Top + 2, displayRect.Left, displayRect.Top + 3); context.Graphics.DrawLine(lightPen, displayRect.Left, displayRect.Top, displayRect.Left + 2, displayRect.Top + 2); context.Graphics.DrawLine(lightPen, displayRect.Left + 1, displayRect.Top + 3, displayRect.Left, displayRect.Top + 4); context.Graphics.DrawLine(darkPen, displayRect.Left + 4, displayRect.Top + 1, displayRect.Left + 4, displayRect.Top + 3); context.Graphics.DrawLine(darkPen, displayRect.Left + 5, displayRect.Top + 2, displayRect.Left + 4, displayRect.Top + 3); context.Graphics.DrawLine(lightPen, displayRect.Left + 4, displayRect.Top, displayRect.Left + 6, displayRect.Top + 2); context.Graphics.DrawLine(lightPen, displayRect.Left + 5, displayRect.Top + 3, displayRect.Left + 4, displayRect.Top + 4); } }
/// <summary> /// Gets the color for the minimize bar light. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonMinimizeBarLight(PaletteState state) { IPaletteRibbonGeneral inherit = GetInherit(state); return(inherit?.GetRibbonMinimizeBarLight(state) ?? Target.GetRibbonMinimizeBarLight(state)); }
/// <summary> /// Internal rendering method. /// </summary> protected virtual IDisposable DrawRibbonTabContext(RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento) { if ((rect.Width > 0) && (rect.Height > 0)) { Color c1 = paletteGeneral.GetRibbonTabSeparatorContextColor(PaletteState.Normal); Color c2 = paletteBack.GetRibbonBackColor5(PaletteState.ContextCheckedNormal); bool generate = true; MementoRibbonTabContext cache; // Access a cache instance and decide if cache resources need generating if ((memento == null) || !(memento is MementoRibbonTabContext)) { if (memento != null) memento.Dispose(); cache = new MementoRibbonTabContext(rect, c1, c2); memento = cache; } else { cache = (MementoRibbonTabContext)memento; generate = !cache.UseCachedValues(rect, c1, c2); } // Do we need to generate the contents of the cache? if (generate) { // Dispose of existing values cache.Dispose(); Rectangle borderRect = new Rectangle(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2); cache.fillRect = new Rectangle(rect.X + 1, rect.Y, rect.Width - 2, rect.Height - 1); LinearGradientBrush borderBrush = new LinearGradientBrush(borderRect, c1, Color.Transparent, 270f); borderBrush.Blend = _ribbonGroup5Blend; cache.borderPen = new Pen(borderBrush); LinearGradientBrush underlineBrush = new LinearGradientBrush(borderRect, Color.Transparent, Color.FromArgb(200, c2), 0f); underlineBrush.Blend = _ribbonGroup7Blend; cache.underlinePen = new Pen(underlineBrush); cache.fillBrush = new LinearGradientBrush(borderRect, Color.FromArgb(196, c2), Color.Transparent, 270f); cache.fillBrush.Blend = _ribbonGroup6Blend; } // Draw the left and right border lines context.Graphics.DrawLine(cache.borderPen, rect.X, rect.Y, rect.X, rect.Bottom - 1); context.Graphics.DrawLine(cache.borderPen, rect.Right - 1, rect.Y, rect.Right - 1, rect.Bottom - 1); // Fill the inner area with a gradient context specific color context.Graphics.FillRectangle(cache.fillBrush, cache.fillRect); // Overdraw the brighter line at bottom context.Graphics.DrawLine(cache.underlinePen, rect.X + 1, rect.Bottom - 1, rect.Right - 2, rect.Bottom - 1); } return memento; }
/// <summary> /// Gets the color for the tab context separators. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetRibbonTabSeparatorContextColor(PaletteState state) { IPaletteRibbonGeneral inherit = GetInherit(state); return(inherit?.GetRibbonTabSeparatorContextColor(state) ?? Target.GetRibbonTabSeparatorContextColor(state)); }
/// <summary> /// Perform drawing of a ribbon dialog box launcher glyph. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteGeneral">General ribbon palette details.</param> /// <param name="state">State associated with rendering.</param> public abstract void DrawRibbonDialogBoxLauncher(PaletteRibbonShape shape, RenderContext context, Rectangle displayRect, IPaletteRibbonGeneral paletteGeneral, PaletteState state);
/// <summary> /// Gets the font for the ribbon text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Font value.</returns> public override Font GetRibbonTextFont(PaletteState state) { IPaletteRibbonGeneral inherit = GetInherit(state); return(inherit?.GetRibbonTextFont(state) ?? Target.GetRibbonTextFont(state)); }
/// <summary> /// Draw a context ribbon tab title. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Rendering context.</param> /// <param name="rect">Target rectangle.</param> /// <param name="paletteGeneral">Palette used for general ribbon settings.</param> /// <param name="paletteBack">Palette used for background ribbon settings.</param> /// <param name="memento">Cached values to use when drawing.</param> public abstract IDisposable DrawRibbonTabContextTitle(PaletteRibbonShape shape, RenderContext context, Rectangle rect, IPaletteRibbonGeneral paletteGeneral, IPaletteRibbonBack paletteBack, IDisposable memento);
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { // Update the enabled state of the button Enabled = _ribbon.Enabled; IPaletteBack paletteBack = _ribbon.StateCommon.RibbonGroupDialogButton.PaletteBack; IPaletteBorder paletteBorder = _ribbon.StateCommon.RibbonGroupDialogButton.PaletteBorder; IPaletteRibbonGeneral paletteGeneral = _ribbon.StateCommon.RibbonGeneral; if (_ribbon.RibbonShape == PaletteRibbonShape.NeoAxis) { paletteBack = _ribbon.StateCommon.RibbonQATButton.PaletteBack; paletteBorder = _ribbon.StateCommon.RibbonQATButton.PaletteBorder; paletteGeneral = _ribbon.StateCommon.RibbonGeneral; } // Do we need to draw the background? if (paletteBack.GetBackDraw(State) == InheritBool.True) { // Get the border path which the background is clipped to drawing within using (GraphicsPath borderPath = context.Renderer.RenderStandardBorder.GetBackPath(context, ClientRectangle, paletteBorder, VisualOrientation.Top, State)) { Padding borderPadding = context.Renderer.RenderStandardBorder.GetBorderRawPadding(paletteBorder, State, VisualOrientation.Top); // Apply the padding depending on the orientation Rectangle enclosingRect = CommonHelper.ApplyPadding(VisualOrientation.Top, ClientRectangle, borderPadding); // Render the background inside the border path _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, enclosingRect, borderPath, paletteBack, VisualOrientation.Top, State, _mementoBack); } } // Do we need to draw the border? if (paletteBorder.GetBorderDraw(State) == InheritBool.True) { context.Renderer.RenderStandardBorder.DrawBorder(context, ClientRectangle, paletteBorder, VisualOrientation.Top, State); } // Find the content area inside the button rectangle Rectangle contentRect = ClientRectangle; var contentSize = new Size(-(ClientRectangle.Width - _imageSize.Width) / 2, -(ClientRectangle.Height - _imageSize.Height) / 2); contentRect.Inflate(contentSize); bool isMinibar = _ribbon.QATLocation == QATLocation.Above; // Decide if we are drawing an overflow or context arrow image if (Overflow) { context.Renderer.RenderGlyph.DrawRibbonOverflow(_ribbon.RibbonShape, context, contentRect, paletteGeneral, State); } else { context.Renderer.RenderGlyph.DrawRibbonContextArrow(_ribbon.RibbonShape, context, contentRect, paletteGeneral, State, isMinibar); } }