public Context( Graphics g, RibbonControl ribbonControl, Renderer renderer, History history, Updates updates , Dictionary<Section, Rectangle> mapSectionToRectangle, Dictionary<Item, Rectangle> mapItemToRectangle) { _graphics = g; _renderer = renderer; _history = history; _updates = updates; _ribbonControl = ribbonControl; _mapSectionToRectangle = mapSectionToRectangle; _mapItemToRectangle = mapItemToRectangle; }
protected virtual void PaintBackground( Context context, Rectangle clip, Rectangle logicalBounds, Renderer.BackgroundStyle backgroundStyle ) { context.Renderer.PaintItemBackground( context, clip, logicalBounds, this, backgroundStyle ); }
protected override void PaintBackground( Context context, Rectangle clip, Rectangle logicalBounds, Renderer.BackgroundStyle backgroundStyle ) { ButtonSizeKind buttonSizeKind = IdentifyButton( logicalBounds.Size ); if( buttonSizeKind != ButtonSizeKind.Single ) { Rectangle majorBounds = GetMajorBounds( logicalBounds ); Rectangle minorBounds = GetMinorBounds( logicalBounds ); context.Renderer.PaintItemBackground( context, clip, minorBounds, this, backgroundStyle ); Renderer.BackgroundStyle majorBackgroundStyle = backgroundStyle; if( minorBounds.Contains( context.RibbonControl.PointToClient( Control.MousePosition ) ) ) { if( majorBackgroundStyle == Renderer.BackgroundStyle.Pressed ) { majorBackgroundStyle = Renderer.BackgroundStyle.Normal; } } context.Renderer.PaintItemBackground( context, clip, majorBounds, this, majorBackgroundStyle ); if( backgroundStyle != Renderer.BackgroundStyle.Disabled ) { Rectangle arrowRect; Drawing.ColorTable colorTable = context.RibbonControl.ColorTable; switch( buttonSizeKind ) { case ButtonSizeKind.Single: case ButtonSizeKind.Wide: arrowRect = new Rectangle( logicalBounds.Right - TriangleSize - 1, logicalBounds.Y + (logicalBounds.Height - TriangleSize) / 2 + 3, TriangleSize, TriangleSize / 2 ); break; case ButtonSizeKind.Big: arrowRect = new Rectangle( logicalBounds.Right - TriangleSize - 1, logicalBounds.Top + logicalBounds.Height / 2, TriangleSize, TriangleSize / 2 ); break; default: throw new InvalidOperationException(); } using( Brush brush = new SolidBrush( colorTable.TextColor ) ) { context.Graphics.FillPolygon( brush, new Point[] { new Point( arrowRect.Right, arrowRect.Top ), new Point( arrowRect.Left, arrowRect.Top ), new Point( arrowRect.Left + arrowRect.Width / 2, arrowRect.Bottom ) } ); } } } else { base.PaintBackground( context, clip, logicalBounds, backgroundStyle ); } }