/// <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> /// Draw a numeric down button image 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> /// <exception cref="ArgumentNullException"></exception> public override void DrawInputControlNumericDownGlyph(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(nameof(context)); } if (paletteContent == null) { throw new ArgumentNullException(nameof(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> /// Gets the first back color for the short text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public virtual Color GetContentShortTextColor1(PaletteState state) { if (Apply) { Color ret = _primaryContent.GetContentShortTextColor1(Override ? OverrideState : state); if (ret == Color.Empty) { ret = _backupContent.GetContentShortTextColor1(state); } return(ret); } else { return(_backupContent.GetContentShortTextColor1(state)); } }
/// <summary> /// Gets the first back color for the short text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentShortTextColor1(PaletteState state) { if (_apply) { Color ret = _primary.GetContentShortTextColor1(_override ? _state : state); if (ret == Color.Empty) { ret = _backup.GetContentShortTextColor1(state); } return(ret); } else { return(_backup.GetContentShortTextColor1(state)); } }
/// <summary> /// Gets the first back color for the short text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentShortTextColor1(PaletteState state) { if ((TreeNode != null) && (TreeNode.ForeColor != Color.Empty)) { return(TreeNode.ForeColor); } else { return(_inherit.GetContentShortTextColor1(state)); } }
/// <summary> /// Gets the first color for the short text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public Color GetContentShortTextColor1(PaletteState state) { if (_color1 != Color.Empty) { return(_color1); } else { return(_inherit.GetContentShortTextColor1(state)); } }
/// <summary> /// Gets the first back color for the short text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentShortTextColor1(PaletteState state) { switch (state) { case PaletteState.Normal: return(_cellStyle.ForeColor); case PaletteState.CheckedNormal: return(_cellStyle.SelectionForeColor); } return(_inherit.GetContentShortTextColor1(state)); }
/// <summary> /// Gets the first back color for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentShortTextColor1(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); if (inherit != null) { return(inherit.GetContentShortTextColor1(state)); } else { return(Target.GetContentShortTextColor1(style, state)); } }
/// <summary> /// Gets the first back color for the short text. /// </summary> /// <param name="style">Content style.</param> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentShortTextColor1(PaletteContentStyle style, PaletteState state) { IPaletteContent inherit = GetInherit(state); return(inherit?.GetContentShortTextColor1(state) ?? Target.GetContentShortTextColor1(style, state)); }
/// <summary> /// Gets the first back color for the short text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentShortTextColor1(PaletteState state) { return(_inherit.GetContentShortTextColor1(state)); }
/// <summary> /// Perform draw of content using provided memento. /// </summary> /// <param name="context">Render context.</param> /// <param name="displayRect">Display area available for drawing.</param> /// <param name="palette">Content palette details.</param> /// <param name="memento">Cached values from layout call.</param> /// <param name="orientation">Visual orientation of the content.</param> /// <param name="state">State associated with rendering.</param> /// <param name="composition">Drawing onto a composition element.</param> /// <param name="glowing">If composition should glowing be drawn.</param> /// <param name="allowFocusRect">Allow drawing of focus rectangle.</param> public override void DrawContent(RenderContext context, Rectangle displayRect, IPaletteContent palette, IDisposable memento, VisualOrientation orientation, PaletteState state, bool composition, bool glowing, bool allowFocusRect) { Debug.Assert(context != null); Debug.Assert(memento != null); Debug.Assert(memento is StandardContentMemento); // Validate parameter references if (context == null) throw new ArgumentNullException("context"); if (palette == null) throw new ArgumentNullException("palette"); Debug.Assert(context.Control != null); Debug.Assert(!context.Control.IsDisposed); // Cast the incoming memento to the correct type StandardContentMemento standard = (StandardContentMemento)memento; if (standard.DrawImage) { DrawImageHelper(context, standard.Image, standard.ImageTransparentColor, standard.ImageRect, orientation, palette.GetContentImageEffect(state), palette.GetContentImageColorMap(state), palette.GetContentImageColorTo(state)); } if (standard.DrawShortText) { using (GraphicsTextHint hint = new GraphicsTextHint(context.Graphics, standard.ShortTextHint)) { // Get the rectangle to use when dealing with gradients Rectangle gradientRect = context.GetAlignedRectangle(palette.GetContentShortTextColorAlign(state), standard.ShortTextRect); // Use standard helper routine to create appropriate color brush Color color1 = palette.GetContentShortTextColor1(state); PaletteColorStyle colorStyle = palette.GetContentShortTextColorStyle(state); using (Brush colorBrush = CreateColorBrush(gradientRect, color1, palette.GetContentShortTextColor2(state), colorStyle, palette.GetContentShortTextColorAngle(state), orientation)) { if (!AccurateText.DrawString(context.Graphics, colorBrush, standard.ShortTextRect, context.Control.RightToLeft, standard.Orientation, composition, glowing, state, standard.ShortTextMemento)) { // Failed to draw means the font is likely to be invalid, get a fresh font standard.ShortTextMemento.Font = palette.GetContentShortTextNewFont(state); // Try again using the new font AccurateText.DrawString(context.Graphics, colorBrush, standard.ShortTextRect, context.Control.RightToLeft, standard.Orientation, composition, glowing, state, standard.ShortTextMemento); } } Image shortImage = palette.GetContentShortTextImage(state); PaletteImageStyle shortImageStyle = palette.GetContentShortTextImageStyle(state); // Do we need to draw the image? if (ShouldDrawImage(shortImage)) { // Get the rectangle to use when dealing with gradients Rectangle imageRect = context.GetAlignedRectangle(palette.GetContentShortTextImageAlign(state), standard.ShortTextRect); // Use standard helper routine to create appropriate image brush using (Brush imageBrush = CreateImageBrush(imageRect, shortImage, shortImageStyle)) { if (!AccurateText.DrawString(context.Graphics, imageBrush, standard.ShortTextRect, context.Control.RightToLeft, standard.Orientation, composition, glowing, state, standard.ShortTextMemento)) { // Failed to draw means the font is likely to be invalid, get a fresh font standard.ShortTextMemento.Font = palette.GetContentShortTextNewFont(state); AccurateText.DrawString(context.Graphics, imageBrush, standard.ShortTextRect, context.Control.RightToLeft, standard.Orientation, composition, glowing, state, standard.ShortTextMemento); } } } } } if (standard.DrawLongText) { using (GraphicsTextHint hint = new GraphicsTextHint(context.Graphics, standard.LongTextHint)) { // Get the rectangle to use when dealing with gradients Rectangle gradientRect = context.GetAlignedRectangle(palette.GetContentLongTextColorAlign(state), standard.LongTextRect); // Use standard helper routine to create appropriate color brush Color color1 = palette.GetContentLongTextColor1(state); PaletteColorStyle colorStyle = palette.GetContentLongTextColorStyle(state); using (Brush colorBrush = CreateColorBrush(gradientRect, color1, palette.GetContentLongTextColor2(state), colorStyle, palette.GetContentLongTextColorAngle(state), orientation)) { if (!AccurateText.DrawString(context.Graphics, colorBrush, standard.LongTextRect, context.Control.RightToLeft, standard.Orientation, composition, glowing, state, standard.LongTextMemento)) { // Failed to draw means the font is likely to be invalid, get a fresh font standard.LongTextMemento.Font = palette.GetContentLongTextNewFont(state); AccurateText.DrawString(context.Graphics, colorBrush, standard.LongTextRect, context.Control.RightToLeft, standard.Orientation, composition, glowing, state, standard.LongTextMemento); } } Image longImage = palette.GetContentLongTextImage(state); PaletteImageStyle longImageStyle = palette.GetContentLongTextImageStyle(state); // Do we need to draw the image? if (ShouldDrawImage(longImage)) { // Get the rectangle to use when dealing with gradients Rectangle imageRect = context.GetAlignedRectangle(palette.GetContentLongTextImageAlign(state), standard.LongTextRect); // Use standard helper routine to create appropriate image brush using (Brush imageBrush = CreateImageBrush(imageRect, longImage, longImageStyle)) { if (!AccurateText.DrawString(context.Graphics, imageBrush, standard.LongTextRect, context.Control.RightToLeft, standard.Orientation, composition, glowing, state, standard.LongTextMemento)) { // Failed to draw means the font is likely to be invalid, get a fresh font standard.LongTextMemento.Font = palette.GetContentLongTextNewFont(state); AccurateText.DrawString(context.Graphics, imageBrush, standard.LongTextRect, context.Control.RightToLeft, standard.Orientation, composition, glowing, state, standard.LongTextMemento); } } } } } // Do we need to show this content has the focus? if (allowFocusRect && (palette.GetContentDrawFocus(state) == InheritBool.True)) { // Place the rectangle 1 pixel inside the content display area displayRect.Inflate(-1, -1); // Use window forms provided helper class for drawing ControlPaint.DrawFocusRectangle(context.Graphics, displayRect); } }
/// <summary> /// Draw a grid sorting direction glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="sortOrder">Sorting order of the glyph.</param> /// <param name="cellRect">Available drawing rectangle space.</param> /// <param name="paletteContent">Palette to use for sourcing values.</param> /// <param name="state">State associated with rendering.</param> /// <param name="rtl">Should be drawn from right to left.</param> /// <returns>Remainder space left over for other drawing.</returns> public override Rectangle DrawGridSortGlyph(RenderContext context, SortOrder sortOrder, Rectangle cellRect, IPaletteContent paletteContent, PaletteState state, bool rtl) { Debug.Assert(context != null); Debug.Assert(paletteContent != null); // Get the appropriate each to draw Image sortImage = _gridSortOrder.Images[(sortOrder == SortOrder.Ascending ? 0 : 1)]; // Is there enough room to draw the image? if ((sortImage.Width < cellRect.Width) && (sortImage.Height < cellRect.Height)) { // Find the drawing location of the image int y = cellRect.Top + (cellRect.Height - sortImage.Height) / 2; int x = (rtl ? cellRect.X : cellRect.Right - sortImage.Width); // Grab the foreground color to use for the image Color imageColor = paletteContent.GetContentShortTextColor1(state); // Draw the image with remapping the image color to the foreground color using (ImageAttributes attribs = new ImageAttributes()) { ColorMap cm = new ColorMap(); cm.OldColor = Color.Black; cm.NewColor = CommonHelper.MergeColors(imageColor, 0.75f, Color.Transparent, 0.25f); attribs.SetRemapTable(new ColorMap[] { cm }, ColorAdjustType.Bitmap); context.Graphics.DrawImage(sortImage, new Rectangle(x, y, sortImage.Width, sortImage.Height), 0, 0, sortImage.Width, sortImage.Height, GraphicsUnit.Pixel, attribs); } // Reduce the cell rect by that used up cellRect.Width -= sortImage.Width; // With rtl we need to move across to the right if (rtl) cellRect.X += sortImage.Width; } return cellRect; }
/// <summary> /// Draw a grid row glyph. /// </summary> /// <param name="context">Render context.</param> /// <param name="rowGlyph">Row glyph.</param> /// <param name="cellRect">Available drawing rectangle space.</param> /// <param name="paletteContent">Palette to use for sourcing values.</param> /// <param name="state">State associated with rendering.</param> /// <param name="rtl">Should be drawn from right to left.</param> /// <returns>Remainder space left over for other drawing.</returns> public override Rectangle DrawGridRowGlyph(RenderContext context, GridRowGlyph rowGlyph, Rectangle cellRect, IPaletteContent paletteContent, PaletteState state, bool rtl) { Debug.Assert(context != null); Debug.Assert(paletteContent != null); // Get the appropriate each to draw Image rowImage = null; switch (rowGlyph) { case GridRowGlyph.ArrowStar: rowImage = _gridRowIndicators.Images[rtl ? 4 : 0]; break; case GridRowGlyph.Star: rowImage = _gridRowIndicators.Images[rtl ? 5 : 1]; break; case GridRowGlyph.Pencil: rowImage = _gridRowIndicators.Images[rtl ? 6 : 2]; break; case GridRowGlyph.Arrow: rowImage = _gridRowIndicators.Images[rtl ? 7 : 3]; break; } // Is there enough room to draw the image? if ((rowImage != null) && (rowImage.Width < cellRect.Width) && (rowImage.Height < cellRect.Height)) { // Find the drawing location of the image int y = cellRect.Top + (cellRect.Height - rowImage.Height) / 2; int x = (rtl ? cellRect.Right - rowImage.Width : cellRect.Left); // Grab the foreground color to use for the image Color imageColor = paletteContent.GetContentShortTextColor1(state); // Draw the image with remapping the image color to the foreground color using (ImageAttributes attribs = new ImageAttributes()) { ColorMap cm = new ColorMap(); cm.OldColor = Color.Black; cm.NewColor = CommonHelper.MergeColors(imageColor, 0.75f, Color.Transparent, 0.25f); attribs.SetRemapTable(new ColorMap[] { cm }, ColorAdjustType.Bitmap); context.Graphics.DrawImage(rowImage, new Rectangle(x, y, rowImage.Width, rowImage.Height), 0, 0, rowImage.Width, rowImage.Height, GraphicsUnit.Pixel, attribs); } // Reduce the cell rect by that used up cellRect.Width -= rowImage.Width; // With NOT rtl we need to move across to the right if (!rtl) cellRect.X += rowImage.Width; } return cellRect; }
/// <summary> /// Gets the first back color for the short text. /// </summary> /// <param name="state">Palette value should be applicable to this state.</param> /// <returns>Color value.</returns> public override Color GetContentShortTextColor1(PaletteState state) => _inherit.GetContentShortTextColor1(state);