protected override void ApplyStyleEx(TextRowVisualStyle style, StyleType[] css) { foreach (StyleType cs in css) { style.ApplyStyle(SuperGrid.BaseVisualStyles.FooterStyles[cs]); style.ApplyStyle(SuperGrid.DefaultVisualStyles.FooterStyles[cs]); style.ApplyStyle(GridPanel.DefaultVisualStyles.FooterStyles[cs]); } }
private void RenderTextMarkup( Graphics g, TextRowVisualStyle style, Rectangle r) { MarkupDrawContext d = new MarkupDrawContext(g, style.Font, style.TextColor, false); _TextMarkup.Arrange(new Rectangle(r.Location, r.Size), d); Size size = _TextMarkup.Bounds.Size; switch (style.Alignment) { case Alignment.MiddleLeft: case Alignment.MiddleCenter: case Alignment.MiddleRight: if (r.Height > size.Height) r.Y += (r.Height - size.Height)/2; break; default: if (r.Height > size.Height) r.Y = r.Bottom - size.Height; break; } _TextMarkup.Bounds = new Rectangle(r.Location, size); Region oldClip = g.Clip; try { g.SetClip(r, CombineMode.Intersect); _TextMarkup.Render(d); } finally { g.Clip = oldClip; } }
protected void RenderRowText(Graphics g, TextRowVisualStyle style, Rectangle r) { string s = _Text; if (string.IsNullOrEmpty(s) == false) { if (r.Width > 0 && r.Height > 0) { if (_TextMarkup != null) { RenderTextMarkup(g, style, r); } else { eTextFormat tf = style.GetTextFormatFlags(); TextDrawing.DrawString(g, s, style.Font, style.TextColor, r, tf); } } } }
protected void RenderRowBorder(Graphics g, TextRowVisualStyle style, Rectangle r) { if (style.BorderPattern == null || style.BorderThickness == null || style.BorderColor == null) { return; } Rectangle t = r; t.X += style.Margin.Left; t.Width -= style.Margin.Horizontal; t.Y += style.Margin.Top; t.Height -= style.Margin.Vertical; if (style.BorderColor.IsUniform == true && style.BorderThickness.IsUniform == true && style.BorderPattern.IsUniform == true) { if (style.BorderThickness.Top > 0 && style.BorderColor.Top.IsEmpty == false) { t.Width -= style.BorderThickness.Top; t.Height -= style.BorderThickness.Top; using (Pen pen = new Pen(style.BorderColor.Top, style.BorderThickness.Top)) { LinePattern pattern = (style.BorderPattern.Top == LinePattern.NotSet) ? LinePattern.Solid : style.BorderPattern.Top; pen.DashStyle = (DashStyle)pattern; g.DrawRectangle(pen, t); } } } else { Pen[] pens = style.GetBorderPens(); if (pens[(int)BorderSide.Right] != null) { int right = t.Right - (style.BorderThickness.Right / 2); g.DrawLine(pens[(int)BorderSide.Right], right, t.Top, right, t.Bottom); } if (pens[(int)BorderSide.Bottom] != null) { int bottom = t.Bottom - ((style.BorderThickness.Bottom - 1) / 2); g.DrawLine(pens[(int)BorderSide.Bottom], t.X, bottom, t.Right, bottom); } if (pens[(int)BorderSide.Left] != null) g.DrawLine(pens[(int)BorderSide.Left], t.X, t.Top, t.X, t.Bottom); if (pens[(int)BorderSide.Top] != null) g.DrawLine(pens[(int)BorderSide.Top], t.X, t.Top, t.Right, t.Top); foreach (Pen pen in pens) { if (pen != null) pen.Dispose(); } } }
protected void RenderRowBackground( Graphics g, TextRowVisualStyle style, Rectangle r) { r.Width--; r.Height--; using (Brush br = style.Background.GetBrush(r)) g.FillRectangle(br, r); if (_BackgroundImage != null) { Rectangle sr = r; sr.Location = Point.Empty; switch (_BackgroundImageLayout) { case GridBackgroundImageLayout.TopRight: OffsetRight(ref sr, ref r); g.DrawImage(_BackgroundImage, r, sr, GraphicsUnit.Pixel); break; case GridBackgroundImageLayout.BottomLeft: OffsetBottom(ref sr, ref r); g.DrawImage(_BackgroundImage, r, sr, GraphicsUnit.Pixel); break; case GridBackgroundImageLayout.BottomRight: OffsetRight(ref sr, ref r); OffsetBottom(ref sr, ref r); g.DrawImage(_BackgroundImage, r, sr, GraphicsUnit.Pixel); break; case GridBackgroundImageLayout.Center: RenderImageCentered(g, _BackgroundImage, r); break; case GridBackgroundImageLayout.Stretch: g.DrawImage(_BackgroundImage, r); break; case GridBackgroundImageLayout.Zoom: RenderImageScaled(g, _BackgroundImage, r); break; case GridBackgroundImageLayout.Tile: using (TextureBrush tbr = new TextureBrush(_BackgroundImage)) { tbr.TranslateTransform(r.X, r.Y); g.FillRectangle(tbr, r); } break; default: g.DrawImage(_BackgroundImage, r, sr, GraphicsUnit.Pixel); break; } } }
private Rectangle GetAdjustedBounds(TextRowVisualStyle style, Rectangle r) { r.X += (style.BorderThickness.Left + style.Margin.Left + style.Padding.Left); r.Width -= (style.BorderThickness.Horizontal + style.Margin.Horizontal + style.Padding.Horizontal + 1); r.Y += (style.BorderThickness.Top + style.Margin.Top + style.Padding.Top); r.Height -= (style.BorderThickness.Vertical + style.Margin.Vertical + style.Padding.Vertical + 1); return (r); }
private Rectangle GetItemBounds(GridPanel panel, Image image, TextRowVisualStyle style, Rectangle r, out Rectangle tb, out Rectangle ib) { Rectangle v = ViewRect; if (panel.IsSubPanel == false) { r.X = Math.Max(r.X, v.X); r.Width = v.Width; } if (CanShowRowHeader(panel) == true) { r.X += panel.RowHeaderWidth; r.Width -= panel.RowHeaderWidth; } tb = GetAdjustedBounds(style, style.GetNonImageBounds(image, r)); ib = style.GetImageBounds(image, tb); return (r); }
protected override void ApplyStyleEx(TextRowVisualStyle style, StyleType[] css) { GroupByVisualStyle gstyle = style as GroupByVisualStyle; if (gstyle != null) { foreach (StyleType cs in css) { gstyle.ApplyStyle(SuperGrid.BaseVisualStyles.GroupByStyles[cs]); gstyle.ApplyStyle(SuperGrid.DefaultVisualStyles.GroupByStyles[cs]); gstyle.ApplyStyle(GridPanel.DefaultVisualStyles.GroupByStyles[cs]); } if (gstyle.GroupBoxBorderColor == Color.Empty) gstyle.GroupBoxBorderColor = Color.Blue; if (gstyle.WatermarkTextColor == Color.Empty) gstyle.WatermarkTextColor = Color.Gray; if (gstyle.WatermarkFont == null) gstyle.WatermarkFont = SystemFonts.DefaultFont; } InsertMarker = null; }
private Size GetTextSize( GridLayoutInfo layoutInfo, TextRowVisualStyle style, int width) { Size size = Size.Empty; if (string.IsNullOrEmpty(_Text) == false) { if (_TextMarkup != null) { size = GetMarkupTextSize(layoutInfo, style, width); } else { eTextFormat tf = style.GetTextFormatFlags(); if (width <= 0) { if (style.AllowWrap == Tbool.True) tf &= ~eTextFormat.WordBreak; } size = TextHelper.MeasureText( layoutInfo.Graphics, _Text, style.Font, new Size(width, 0), tf); } } return (size); }
protected virtual void ApplyStyleEx(TextRowVisualStyle style, StyleType[] css) { }
/// <summary> /// Handles invocation of GetTextRowStyle events /// </summary> internal void DoGetTextRowStyleEvent( GridTextRow gridTextRow, StyleType eStyle, ref TextRowVisualStyle style) { if (GetTextRowStyle != null) { GridGetTextRowStyleEventArgs ev = new GridGetTextRowStyleEventArgs(gridTextRow.GridPanel, gridTextRow, eStyle, style); GetTextRowStyle(this, ev); style = ev.Style; } }
///<summary> /// GridGetTextRowStyleEventArgs ///</summary> ///<param name="gridPanel"></param> ///<param name="gridTextRow"></param> ///<param name="styleType"></param> ///<param name="style"></param> public GridGetTextRowStyleEventArgs( GridPanel gridPanel, GridTextRow gridTextRow, StyleType styleType, TextRowVisualStyle style) : base(gridPanel) { _GridTextRow = gridTextRow; _StyleType = styleType; _Style = style; }
private void InitTextRowStyles(DefaultVisualStyles visualStyle, ColorFactory factory) { TextRowVisualStyle style = new TextRowVisualStyle(); style.Alignment = Alignment.MiddleCenter; style.AllowWrap = Tbool.True; style.Background = new Background(factory.GetColor(0x6A6A6A)); style.BorderColor = new BorderColor(factory.GetColor(0x444444)); style.Padding.All = 2; style.TextColor = factory.GetColor(0xE2E2E2); style.RowHeaderStyle.Background = new Background(factory.GetColor(0x6A6A6A)); style.RowHeaderStyle.BorderHighlightColor = GetBorderHighlight(factory); visualStyle.TitleStyles[StyleType.Default] = style; visualStyle.HeaderStyles[StyleType.Default] = style.Copy(); visualStyle.FooterStyles[StyleType.Default] = style.Copy(); style = style.Copy(); style.Background = new Background(factory.GetColor(0x686868)); visualStyle.CaptionStyles[StyleType.Default] = style; }
private void InitTextRowStyles(DefaultVisualStyles visualStyle, ColorFactory factory) { TextRowVisualStyle style = new TextRowVisualStyle(); style.Alignment = Alignment.MiddleCenter; style.AllowWrap = Tbool.True; style.Background = new Background(factory.GetColor(0xEFF5FB), factory.GetColor(0xE2ECFA), BackFillType.Angle); style.BorderColor = new BorderColor(factory.GetColor(0x849DBD)); style.Padding.All = 2; style.TextColor = factory.GetColor(0x1E395B); style.RowHeaderStyle.Background = new Background(factory.GetColor(0xEFF5FB), factory.GetColor(0xE2ECFA), BackFillType.Angle); style.RowHeaderStyle.BorderHighlightColor = GetBorderHighlight(factory); visualStyle.TitleStyles[StyleType.Default] = style; visualStyle.HeaderStyles[StyleType.Default] = style.Copy(); visualStyle.FooterStyles[StyleType.Default] = style.Copy(); style = style.Copy(); style.Background = new Background(Color.Transparent); visualStyle.CaptionStyles[StyleType.Default] = style; }
private void InitTextRowStyles(DefaultVisualStyles visualStyle, ColorFactory factory) { TextRowVisualStyle style = new TextRowVisualStyle(); MetroPartColors metroColors = _MetroPartColors; style.Alignment = Alignment.MiddleCenter; style.AllowWrap = Tbool.True; style.Background = new Background(factory.GetColor(metroColors.CanvasColor)); style.BorderColor = new BorderColor(factory.GetColor(metroColors.CanvasColorLighterShade)); style.Padding.All = 2; style.TextColor = factory.GetColor(metroColors.TextColor); style.RowHeaderStyle.Background = new Background(factory.GetColor(metroColors.CanvasColorLighterShade)); style.RowHeaderStyle.BorderHighlightColor = GetBorderHighlight(); visualStyle.TitleStyles[StyleType.Default] = style; visualStyle.HeaderStyles[StyleType.Default] = style.Copy(); visualStyle.FooterStyles[StyleType.Default] = style.Copy(); style = style.Copy(); style.Background = new Background(Color.Transparent); visualStyle.CaptionStyles[StyleType.Default] = style; }
private void RenderRowImage(Graphics g, GridPanel panel, TextRowVisualStyle style, Rectangle r) { if (r.Width > 0 && r.Height > 0) { Image image = style.GetImage(panel); if (image != null) g.DrawImageUnscaledAndClipped(image, r); } }
private Size GetMarkupTextSize( GridLayoutInfo layoutInfo, TextRowVisualStyle style, int width) { Graphics g = layoutInfo.Graphics; MarkupDrawContext d = new MarkupDrawContext(g, style.Font, style.TextColor, false); _TextMarkup.InvalidateElementsSize(); _TextMarkup.Measure(new Size(width, 0), d); return (_TextMarkup.Bounds.Size); }
private void InitTextRowStyles(DefaultVisualStyles visualStyle, ColorFactory factory) { TextRowVisualStyle style = new TextRowVisualStyle(); style.Alignment = Alignment.MiddleCenter; style.AllowWrap = Tbool.True; style.Background = new Background(factory.GetColor(0xF5F7F9), factory.GetColor(0xEFF2F6), BackFillType.Angle); style.BorderColor = new BorderColor(factory.GetColor(0xA5ACB5)); style.Padding.All = 2; style.TextColor = factory.GetColor(0x3B3B3B); style.RowHeaderStyle.Background = new Background(factory.GetColor(0xF5F7F9), factory.GetColor(0xEFF2F6), BackFillType.Angle); style.RowHeaderStyle.BorderHighlightColor = GetBorderHighlight(factory); visualStyle.TitleStyles[StyleType.Default] = style; visualStyle.HeaderStyles[StyleType.Default] = style.Copy(); visualStyle.FooterStyles[StyleType.Default] = style.Copy(); style = style.Copy(); style.Background = new Background(factory.GetColor(0xE9EDF1)); visualStyle.CaptionStyles[StyleType.Default] = style; }