/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { if (Draw) { RectangleF rectF = new RectangleF(ClientLocation.X, ClientLocation.Y - 0.5f, ClientWidth, ClientHeight + 1); using (LinearGradientBrush sepBrush = new LinearGradientBrush(rectF, Color.Transparent, _palette.GetRibbonTabSeparatorColor(PaletteState.Normal), 90f)) { sepBrush.Blend = _fadeBlend; switch (_palette.GetRibbonShape()) { default: case PaletteRibbonShape.Office2007: case PaletteRibbonShape.Office2013: context.Graphics.FillRectangle(sepBrush, ClientLocation.X + 2, ClientLocation.Y, 1, ClientHeight - 1); break; case PaletteRibbonShape.Office2010: context.Graphics.FillRectangle(sepBrush, ClientLocation.X + 1, ClientLocation.Y, 1, ClientHeight - 1); using (LinearGradientBrush sepLightBrush = new LinearGradientBrush(rectF, Color.Transparent, _lighten1, 90f)) context.Graphics.FillRectangle(sepLightBrush, ClientLocation.X + 2, ClientLocation.Y, 1, ClientHeight - 1); break; } } } }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { // Draw the application menu outer background _memento = context.Renderer.RenderRibbon.DrawRibbonBack(_ribbon.RibbonShape, context, ClientRectangle, State, _ribbon.StateCommon.RibbonAppMenuDocs, VisualOrientation.Top, false, _memento); }
/// <summary> /// Draw a drop down grid appropriate for a input control. /// </summary> /// <param name="context">Render context.</param> /// <param name="cellRect">Available drawing rectangle space.</param> /// <param name="paletteContent">Content palette for getting colors.</param> /// <param name="state">State associated with rendering.</param> public override void DrawInputControlDropDownGlyph(RenderContext context, Rectangle cellRect, IPaletteContent paletteContent, PaletteState state) { Debug.Assert(context != null); Debug.Assert(paletteContent != null); // Validate parameter references if (context == null) throw new ArgumentNullException("context"); if (paletteContent == null) throw new ArgumentNullException("paletteContent"); Color c1 = paletteContent.GetContentShortTextColor1(state); // Find the top left starting position for drawing lines int xStart = cellRect.Left + (cellRect.Right - cellRect.Left - 4) / 2; int yStart = cellRect.Top + (cellRect.Bottom - cellRect.Top - 3) / 2; using (Pen darkPen = new Pen(c1)) { context.Graphics.DrawLine(darkPen, xStart, yStart, xStart + 4, yStart); context.Graphics.DrawLine(darkPen, xStart + 1, yStart + 1, xStart + 3, yStart + 1); context.Graphics.DrawLine(darkPen, xStart + 2, yStart + 2, xStart + 2, yStart + 1); } }
/// <summary> /// Perform drawing of a separator glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteBack">Background palette details.</param> /// <param name="paletteBorder">Border palette details.</param> /// <param name="orientation">Visual orientation of the content.</param> /// <param name="state">State associated with rendering.</param> /// <param name="canMove">Can the separator be moved.</param> public override void DrawSeparator(RenderContext context, Rectangle displayRect, IPaletteBack paletteBack, IPaletteBorder paletteBorder, Orientation orientation, PaletteState state, bool canMove) { // Let base class perform standard processing base.DrawSeparator(context, displayRect, paletteBack, paletteBorder, orientation, state, canMove); // If we are drawing the background then draw grab handles on top if (paletteBack.GetBackDraw(state) == InheritBool.True) { // Only draw grab handle if the user can move the separator if (canMove) DrawGrabHandleGlyph(context, displayRect, orientation, state); } }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { IPaletteElementColor elementColors = null; switch (State) { default: case PaletteState.Normal: elementColors = _drawTrackBar.StateNormal.Position; break; case PaletteState.Disabled: elementColors = _drawTrackBar.StateDisabled.Position; break; case PaletteState.Tracking: elementColors = _drawTrackBar.StateTracking.Position; break; case PaletteState.Pressed: elementColors = _drawTrackBar.StatePressed.Position; break; } context.Renderer.RenderGlyph.DrawTrackPositionGlyph(context, State, elementColors, ClientRectangle, _drawTrackBar.Orientation, _drawTrackBar.TickStyle); }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { // Use renderer to draw the drop arrow in the provided space context.Renderer.RenderGlyph.DrawRibbonDropArrow(_ribbon.RibbonShape, context, ClientRectangle, _ribbon.StateCommon.RibbonGeneral, State); }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { using (Pen darkPen = new Pen(_palette.GetRibbonMinimizeBarDark(PaletteState.Normal)), lightPen = new Pen(_palette.GetRibbonMinimizeBarLight(PaletteState.Normal))) { context.Graphics.DrawLine(darkPen, ClientRectangle.Left, ClientRectangle.Bottom - 2, ClientRectangle.Right - 1, ClientRectangle.Bottom - 2); context.Graphics.DrawLine(lightPen, ClientRectangle.Left, ClientRectangle.Bottom - 1, ClientRectangle.Right - 1, ClientRectangle.Bottom - 1); } }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { IPaletteElementColor elementColors; if (Enabled) elementColors = _drawTrackBar.StateNormal.Track; else elementColors = _drawTrackBar.StateDisabled.Track; context.Renderer.RenderGlyph.DrawTrackGlyph(context, State, elementColors, ClientRectangle, _drawTrackBar.Orientation, _drawTrackBar.VolumeControl); }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) throw new ArgumentNullException("context"); using(SolidBrush brush = new SolidBrush(Color.FromArgb(197, 197, 197))) context.Graphics.FillRectangle(brush, ClientRectangle); }
/// <summary> /// Perform a render of the elements. /// </summary> /// <param name="context">Rendering context.</param> public override void Render(RenderContext context) { Debug.Assert(context != null); // Perform rendering before any children RenderBefore(context); // Perform rendering after that of children RenderAfter(context); }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { // Ask each child to render in turn foreach (ViewBase child in this) { // Only render visible children that are inside the clipping rectangle if (child.Visible && child.ClientRectangle.IntersectsWith(context.ClipRect)) child.RenderBefore(context); } }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) throw new ArgumentNullException("context"); // Ignore renderer, we just draw using solid color for debugging purposes using (SolidBrush brush = new SolidBrush(_color)) context.Graphics.FillRectangle(brush, ClientRectangle); }
/// <summary> /// Perform rendering after child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderAfter(RenderContext context) { // Ask for another draw of the child but this time only drawing the selected tab _layoutTabs.DrawChecked = true; // Only render visible children that are inside the clipping rectangle if (_layoutOverlap.Visible && _layoutOverlap.ClientRectangle.IntersectsWith(context.ClipRect)) _layoutOverlap.Render(context); _layoutTabs.DrawChecked = false; }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { // Let base class perform standard drawing first base.RenderBefore(context); Rectangle drawRect = new Rectangle(ClientLocation.X, ClientLocation.Y + ClientWidth, ClientWidth, ClientHeight - (ClientWidth * 2)); context.Renderer.RenderRibbon.DrawRibbonClusterEdge(_ribbon.RibbonShape, context, drawRect, _palette, State); }
/// <summary> /// Draw a background for an expert style button that is checked. /// </summary> /// <param name="context">Rendering context.</param> /// <param name="rect">Rectangle to draw.</param> /// <param name="backColor1">First color.</param> /// <param name="backColor2">Second color.</param> /// <param name="orientation">Drawing orientation.</param> /// <param name="path">Clipping path.</param> /// <param name="memento">Cache used for drawing.</param> public static IDisposable DrawBackExpertChecked(RenderContext context, Rectangle rect, Color backColor1, Color backColor2, VisualOrientation orientation, GraphicsPath path, IDisposable memento) { using (Clipping clip = new Clipping(context.Graphics, path)) { // Draw the expert background which is gradient with highlight at bottom return DrawBackExpert(rect, backColor1, backColor2, orientation, context.Graphics, memento, true, false); } }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { Rectangle drawRect = ClientRectangle; if (_start) drawRect.X -= 4; drawRect.Width += 4; context.Renderer.RenderGlyph.DrawRibbonGroupSeparator(_ribbon.RibbonShape, context, drawRect, _ribbon.StateCommon.RibbonGeneral, State); }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { IPaletteElementColor elementColors; if (Enabled) elementColors =_drawTrackBar.StateNormal.Tick; else elementColors = _drawTrackBar.StateDisabled.Tick; context.Renderer.RenderGlyph.DrawTrackTicksGlyph(context, State, elementColors, ClientRectangle, _drawTrackBar.Orientation, _topRight, _drawTrackBar.PositionSize, _drawTrackBar.Minimum, _drawTrackBar.Maximum, _drawTrackBar.TickFrequency); }
/// <summary> /// Draw a design area with a flap on the left hand edge. /// </summary> /// <param name="ribbon">Reference to owning ribbon control.</param> /// <param name="context">Rendering context.</param> /// <param name="clientRect">Client rectangle of the source view.</param> /// <param name="state">State of element.</param> public static void DrawArea(KryptonRibbon ribbon, RenderContext context, Rectangle clientRect, PaletteState state) { Color c; if (state == PaletteState.Normal) c = ribbon.StateCommon.RibbonGeneral.GetRibbonGroupSeparatorDark(PaletteState.Normal); else c = ribbon.StateCommon.RibbonGroupButton.Back.GetBackColor1(PaletteState.Tracking); // Draw entire area in color using (SolidBrush darkBrush = new SolidBrush(c)) context.Graphics.FillRectangle(darkBrush, clientRect); }
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) throw new ArgumentNullException("context"); // Only draw the shortcut text if there is some defined string shortcut = Values.GetShortText(); if (!string.IsNullOrEmpty(shortcut)) { // Only draw shortcut if the shortcut is not equal to the fixed string 'A' if (!shortcut.Equals("A")) base.RenderBefore(context); } }
/// <summary> /// Perform rendering after child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderAfter(RenderContext context) { // Do we have a status strip to try and merge? if (_statusStrip != null) { // Is the status strip using the global renderer? if (_statusStrip.RenderMode == ToolStripRenderMode.ManagerRenderMode) { // Cast to correct type KryptonForm form = context.Control as KryptonForm; if (form != null) { // Find the size of the borders around the form Padding borders = form.RealWindowBorders; // Grab the global renderer to use for painting ToolStripRenderer renderer = ToolStripManager.Renderer; // Size the render strip to the apparent size when merged into borders _renderStrip.Width = form.Width; _renderStrip.Height = _statusStrip.Height + borders.Bottom; // Find vertical start of the status strip int y = _statusStrip.Top + borders.Top; try { // We need to transform downwards from drawing at 0,0 to actual required position context.Graphics.TranslateTransform(0, y); // Use the tool strip renderer to draw the correct status strip border/background renderer.DrawToolStripBorder(new ToolStripRenderEventArgs(context.Graphics, _renderStrip)); renderer.DrawToolStripBackground(new ToolStripRenderEventArgs(context.Graphics, _renderStrip)); } finally { // Make sure that even a crash in the renderer does not prevent the transform reversal context.Graphics.TranslateTransform(0, -y); } } } } // Finally we let the border be drawn base.RenderAfter(context); }
/// <summary> /// Draw a background with glass effect where the fade is from the bottom. /// </summary> /// <param name="context">Rendering context.</param> /// <param name="rect">Rectangle to draw.</param> /// <param name="backColor1">First color.</param> /// <param name="backColor2">Second color.</param> /// <param name="orientation">Drawing orientation.</param> /// <param name="path">Clipping path.</param> /// <param name="memento">Cache used for drawing.</param> public static IDisposable DrawBackGlassBottom(RenderContext context, Rectangle rect, Color backColor1, Color backColor2, VisualOrientation orientation, GraphicsPath path, IDisposable memento) { using (Clipping clip = new Clipping(context.Graphics, path)) { MementoDouble cache; if ((memento == null) || !(memento is MementoDouble)) { if (memento != null) memento.Dispose(); cache = new MementoDouble(); memento = cache; } else cache = (MementoDouble)memento; // Draw the one pixel border around the area cache.first = DrawBackLinear(rect, false, ControlPaint.Light(backColor1), ControlPaint.LightLight(backColor1), orientation, context.Graphics, cache.first); // Reduce size on all but the upper edge ModifyRectByEdges(ref rect, 1, 0, 1, 1, orientation); // Draw the inside areas as a glass effect cache.second = DrawBackGlassRadial(rect, backColor1, backColor2, _glassColorTopD, _glassColorBottomD, 3f, 1.1f, orientation, context.Graphics, _fullGlassLength, cache.second); } return memento; }
/// <summary> /// Perform drawing of a ribbon cluster edge. /// </summary> /// <param name="shape">Ribbon shape.</param> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteBack">Palette used for recovering drawing details.</param> /// <param name="state">State associated with rendering.</param> public override void DrawRibbonClusterEdge(PaletteRibbonShape shape, RenderContext context, Rectangle displayRect, IPaletteBack paletteBack, PaletteState state) { Debug.Assert(context != null); Debug.Assert(paletteBack != null); // Get the first border color Color borderColor = paletteBack.GetBackColor1(state); // We want to lighten it by merging with white Color lightColor = CommonHelper.MergeColors(borderColor, BORDER_PERCENT, Color.White, WHITE_PERCENT); // Draw inside of the border edge in a lighter version of the border using (SolidBrush drawBrush = new SolidBrush(lightColor)) context.Graphics.FillRectangle(drawBrush, displayRect); }
/// <summary> /// Perform rendering after child elements are rendered. /// </summary> /// <param name="renderContext">Rendering context.</param> public override void RenderAfter(RenderContext renderContext) { base.RenderAfter(renderContext); // Convert our rectangle to the screen Rectangle screenRect = renderContext.TopControl.RectangleToScreen(renderContext.TopControl.ClientRectangle); // If the fixed rectangle is in our showing area and at the top if ((screenRect.Contains(_fixedScreenRect)) && (screenRect.Y == _fixedScreenRect.Y)) { // Position the element appropriately using (ViewLayoutContext layoutContext = new ViewLayoutContext(renderContext.Control, renderContext.Renderer)) { layoutContext.DisplayRectangle = renderContext.TopControl.RectangleToClient(_fixedScreenRect); _fixedElement.Layout(layoutContext); } // Now draw _fixedElement.Render(renderContext); } }
/// <summary> /// Draw border on the inside edge of the specified rectangle. /// </summary> /// <param name="context">Rendering context.</param> /// <param name="rect">Target rectangle.</param> /// <param name="palette">Palette used for drawing.</param> /// <param name="orientation">Visual orientation of the border.</param> /// <param name="state">State associated with rendering.</param> /// <param name="tabBorderStyle">Style of tab border.</param> public abstract void DrawTabBorder(RenderContext context, Rectangle rect, IPaletteBorder palette, VisualOrientation orientation, PaletteState state, TabBorderStyle tabBorderStyle);
/// <summary> /// Perform drawing of a separator glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="paletteBack">Background palette details.</param> /// <param name="paletteBorder">Border palette details.</param> /// <param name="orientation">Visual orientation of the content.</param> /// <param name="state">State associated with rendering.</param> /// <param name="canMove">Can the separator be moved.</param> public abstract void DrawSeparator(RenderContext context, Rectangle displayRect, IPaletteBack paletteBack, IPaletteBorder paletteBorder, Orientation orientation, PaletteState state, bool canMove);
/// <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) { using (SolidBrush fillBrush = new SolidBrush(_fillColor)) context.Graphics.FillRectangle(fillBrush, ClientRectangle); }
/// <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 is MementoRibbonTabContextOffice)) { 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) { Blend = _ribbonGroup5Blend }; cache.borderPen = new Pen(borderBrush); LinearGradientBrush underlineBrush = new LinearGradientBrush(borderRect, Color.Transparent, Color.FromArgb(200, c2), 0f) { Blend = _ribbonGroup7Blend }; cache.underlinePen = new Pen(underlineBrush); cache.fillBrush = new LinearGradientBrush(borderRect, Color.FromArgb(106, c2), Color.Transparent, 270f) { 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> /// Perform a render of the elements. /// </summary> /// <param name="context">Rendering context.</param> public override void Render(RenderContext context) { _child.Render(context); }
/// <summary> /// Internal rendering method. /// </summary> protected virtual void DrawGrabHandleGlyph(RenderContext context, Rectangle displayRect, Orientation orientation, PaletteState state) { // Is there enough room to draw the at least one grab handle? if ((displayRect.Height >= GRAB_SQUARE_MIN_SPACE) && (displayRect.Width >= GRAB_SQUARE_MIN_SPACE)) { // Reduce rectangle to remove the border around the display area edges displayRect.Inflate(-GRAB_SQUARE_GAP, -GRAB_SQUARE_GAP); // Find how much space is available for drawing grab handles in the orientation int orientationSpace = (orientation == Orientation.Horizontal ? displayRect.Width : displayRect.Height); // Try to display the maximum allowed number of handles, but show less if not possible for (int i = GRAB_SQUARE_COUNT; i > 0; i--) { // Calculate how much space this number of grab handles takes up int requiredSpace = (i * GRAB_SQUARE_TOTAL) + (i > 1 ? (i - 1) * GRAB_SQUARE_GAP : 0); // Is there enough space all the grab handles? if (requiredSpace <= orientationSpace) { // Find offset before showing the first handle int offset = (orientationSpace - requiredSpace) / 2; // Find location of first handle Point draw = orientation == Orientation.Horizontal ? new Point(displayRect.X + offset, displayRect.Y + ((displayRect.Height - GRAB_SQUARE_TOTAL) / 2)) : new Point(displayRect.X + ((displayRect.Width - GRAB_SQUARE_TOTAL) / 2), displayRect.Y + offset); using (Brush lightBrush = new SolidBrush(_grabHandleLight), darkBrush = new SolidBrush(_grabHandleDark)) { // Draw each grab handle in turn for (int j = 0; j < i; j++) { // Draw the light colored square context.Graphics.FillRectangle(lightBrush, draw.X + GRAB_SQUARE_OFFSET, draw.Y + GRAB_SQUARE_OFFSET, GRAB_SQUARE_LENGTH, GRAB_SQUARE_LENGTH); // Draw the dark colored square overlapping the dark context.Graphics.FillRectangle(darkBrush, draw.X, draw.Y, GRAB_SQUARE_LENGTH, GRAB_SQUARE_LENGTH); // Move to the next handle position if (orientation == Orientation.Horizontal) { draw.X += GRAB_SQUARE_TOTAL + GRAB_SQUARE_GAP; } else { draw.Y += GRAB_SQUARE_TOTAL + GRAB_SQUARE_GAP; } } } // Finished break; } } } }
/// <summary> /// Draw the track bar track glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="state">Element state.</param> /// <param name="elementPalette">Source of palette colors.</param> /// <param name="drawRect">Drawing rectangle that should contain the track.</param> /// <param name="orientation">Drawing orientation.</param> /// <param name="volumeControl">Drawing as a volume control or standard slider.</param> public abstract void DrawTrackGlyph(RenderContext context, PaletteState state, IPaletteElementColor elementPalette, Rectangle drawRect, Orientation orientation, bool volumeControl);
/// <summary> /// Perform rendering before child elements are rendered. /// </summary> /// <param name="context">Rendering context.</param> public override void RenderBefore(RenderContext context) { Debug.Assert(context != null); // Validate incoming reference if (context == null) { throw new ArgumentNullException("context"); } // Do we need to draw the background? if (_drawCanvas && (_paletteBack.GetBackDraw(State) == InheritBool.True)) { GraphicsPath borderPath; Padding borderPadding; // Ask the border renderer for a path that encloses the border if (DrawTabBorder) { borderPath = context.Renderer.RenderTabBorder.GetTabBackPath(context, ClientRectangle, _paletteBorder, Orientation, State, TabBorderStyle); borderPadding = Padding.Empty; } else { borderPath = context.Renderer.RenderStandardBorder.GetBackPath(context, ClientRectangle, _paletteBorder, Orientation, State); borderPadding = context.Renderer.RenderStandardBorder.GetBorderRawPadding(_paletteBorder, State, Orientation); } // Apply the padding depending on the orientation Rectangle enclosingRect = CommonHelper.ApplyPadding(_orientation, ClientRectangle, borderPadding); // Render the background inside the border path _mementoBack = context.Renderer.RenderStandardBack.DrawBack(context, enclosingRect, borderPath, _paletteBack, _orientation, State, _mementoBack); borderPath.Dispose(); } if (_drawCanvas && (_paletteBorder != null)) { // Do we draw the border before the children? if (!DrawBorderLast) { RenderBorder(context); } else { // Drawing border afterwards, and so clip children to prevent drawing // over the corners if they are rounded. We only clip children if the // border is drawn afterwards. // Remember the current clipping region _clipRegion = context.Graphics.Clip.Clone(); GraphicsPath borderPath; // Restrict the clipping to the area inside the canvas border if (DrawTabBorder) { borderPath = context.Renderer.RenderTabBorder.GetTabBorderPath(context, ClientRectangle, _paletteBorder, Orientation, State, TabBorderStyle); } else { borderPath = context.Renderer.RenderStandardBorder.GetBorderPath(context, ClientRectangle, _paletteBorder, Orientation, State); } // Create a new region the same as the existing clipping region Region combineRegion = new Region(borderPath); // Reduce clipping region down by our border path combineRegion.Intersect(_clipRegion); context.Graphics.Clip = combineRegion; borderPath.Dispose(); } } }
/// <summary> /// Draw the track bar position glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="state">Element state.</param> /// <param name="elementPalette">Source of palette colors.</param> /// <param name="drawRect">Drawing rectangle that should contain the track.</param> /// <param name="orientation">Drawing orientation.</param> /// <param name="tickStyle">Tick marks that surround the position.</param> public abstract void DrawTrackPositionGlyph(RenderContext context, PaletteState state, IPaletteElementColor elementPalette, Rectangle drawRect, Orientation orientation, TickStyle tickStyle);
/// <summary> /// Draw the track bar ticks glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="state">Element state.</param> /// <param name="elementPalette">Source of palette colors.</param> /// <param name="drawRect">Drawing rectangle that should contain ticks.</param> /// <param name="orientation">Orientation of the drawing area.</param> /// <param name="topRight">Drawing on the topRight or the bottomLeft.</param> /// <param name="positionSize">Size of the position indicator.</param> /// <param name="minimum">First value.</param> /// <param name="maximum">Last value.</param> /// <param name="frequency">How often ticks are drawn.</param> public abstract void DrawTrackTicksGlyph(RenderContext context, PaletteState state, IPaletteElementColor elementPalette, Rectangle drawRect, Orientation orientation, bool topRight, Size positionSize, int minimum, int maximum, int frequency);
/// <summary> /// Generate a graphics path that encloses the border itself. /// </summary> /// <param name="context">Rendering context.</param> /// <param name="rect">Target rectangle.</param> /// <param name="palette">Palette used for drawing.</param> /// <param name="orientation">Visual orientation of the border.</param> /// <param name="state">State associated with rendering.</param> /// <param name="tabBorderStyle">Style of tab border.</param> /// <returns>GraphicsPath instance.</returns> public abstract GraphicsPath GetTabBorderPath(RenderContext context, Rectangle rect, IPaletteBorder palette, VisualOrientation orientation, PaletteState state, TabBorderStyle tabBorderStyle);
/// <summary> /// Internal rendering method. /// </summary> protected virtual void DrawGrabHandleGlyph(RenderContext context, Rectangle displayRect, Orientation orientation, PaletteState state) { // Is there enough room to draw the at least one grab handle? if ((displayRect.Height >= _grabSquareMinSpace) && (displayRect.Width >= _grabSquareMinSpace)) { // Reduce rectangle to remove the border around the display area edges displayRect.Inflate(-_grabSquareGap, -_grabSquareGap); // Find how much space is available for drawing grab handles in the orientation int orientationSpace = (orientation == Orientation.Horizontal ? displayRect.Width : displayRect.Height); // Try to display the maximum allowed number of handles, but show less if not possible for (int i = _grabSquareCount; i > 0; i--) { // Calculate how much space this number of grab handles takes up int requiredSpace = (i * _grabSquareTotal) + (i > 1 ? (i - 1) * _grabSquareGap : 0); // Is there enough space all the grab handles? if (requiredSpace <= orientationSpace) { // Find offset before showing the first handle int offset = (orientationSpace - requiredSpace) / 2; Point draw; // Find location of first handle if (orientation == Orientation.Horizontal) { draw = new Point(displayRect.X + offset, displayRect.Y + (displayRect.Height - _grabSquareTotal) / 2); } else { draw = new Point(displayRect.X + (displayRect.Width - _grabSquareTotal) / 2, displayRect.Y + offset); } using (Brush lightBrush = new SolidBrush(_grabHandleLight), darkBrush = new SolidBrush(_grabHandleDark)) { // Draw each grab handle in turn for (int j = 0; j < i; j++) { // Draw the light colored square context.Graphics.FillRectangle(lightBrush, draw.X + _grabSquareOffset, draw.Y + _grabSquareOffset, _grabSquareLength, _grabSquareLength); // Draw the dark colored square overlapping the dark context.Graphics.FillRectangle(darkBrush, draw.X, draw.Y, _grabSquareLength, _grabSquareLength); // Move to the next handle position if (orientation == Orientation.Horizontal) { draw.X += _grabSquareTotal + _grabSquareGap; } else { draw.Y += _grabSquareTotal + _grabSquareGap; } } } // Finished break; } } } }