/// <summary>
        /// Handles invocation of GetGroupHeaderStyle events
        /// </summary>
        internal void DoGetGroupHeaderStyleEvent(
            GridGroup gridRow, StyleType eStyle, ref GroupHeaderVisualStyle style)
        {
            if (GetGroupHeaderStyle != null)
            {
                GridGetGroupHeaderStyleEventArgs ev = new
                    GridGetGroupHeaderStyleEventArgs(gridRow.GridPanel, gridRow, eStyle, style);

                GetGroupHeaderStyle(this, ev);

                style = ev.Style;
            }
        }
        private void InitGroupHeaderStyles(DefaultVisualStyles visualStyle, ColorFactory factory)
        {
            GroupHeaderVisualStyle style = new GroupHeaderVisualStyle();

            style.AllowWrap = Tbool.True;
            style.Alignment = Alignment.MiddleLeft;
            style.Font = SystemFonts.DefaultFont;

            style.Background = new
                Background(factory.GetColor(0xFFFFFF));

            style.UnderlineColor = factory.GetColor(0x444444);

            style.RowHeaderStyle.Background = new Background(factory.GetColor(0xBABABA));
            style.RowHeaderStyle.BorderHighlightColor = GetBorderHighlight(factory);
            style.RowHeaderStyle.Font = SystemFonts.DefaultFont;

            visualStyle.GroupHeaderStyles[StyleType.Default] = style;
        }
 ///<summary>
 /// GridGetGroupHeaderStyleEventArgs
 ///</summary>
 ///<param name="gridPanel"></param>
 ///<param name="gridRow"></param>
 ///<param name="styleType"></param>
 ///<param name="style"></param>
 public GridGetGroupHeaderStyleEventArgs(
     GridPanel gridPanel, GridGroup gridRow, StyleType styleType, GroupHeaderVisualStyle style)
     : base(gridPanel)
 {
     _GridRow = gridRow;
     _StyleType = styleType;
     _Style = style;
 }
Exemple #4
0
        private void RenderHeaderUnderline(Graphics g,
            GridPanel panel, GroupHeaderVisualStyle style, Rectangle r)
        {
            if (panel.ShowGroupUnderline == true && style.UnderlineColor.IsEmpty == false)
            {
                switch (style.Alignment)
                {
                    case Alignment.MiddleLeft:
                    case Alignment.MiddleCenter:
                    case Alignment.MiddleRight:
                        r.Y += (r.Height + _TextSize.Height) / 2 + 4;
                        break;

                    case Alignment.TopLeft:
                    case Alignment.TopCenter:
                    case Alignment.TopRight:
                        r.Y += _TextSize.Height + 6;
                        break;

                    default:
                        r.Y = r.Bottom - _TextSize.Height / 2;
                        break;
                }

                if (r.Width > SViewRect.Width)
                    r.Width = SViewRect.Width;

                int n = r.Width;

                r.Height = 1;
                r.Width = (int)(r.Width * .75);

                Rectangle t = r;

                Color color1 = style.UnderlineColor;
                Color color2 = Color.Transparent;

                switch (style.Alignment)
                {
                    case Alignment.TopCenter:
                    case Alignment.MiddleCenter:
                    case Alignment.BottomCenter:
                        r.X += (n - r.Width) / 2;
                        r.Width /= 2;

                        color1 = Color.Transparent;
                        color2 = style.UnderlineColor;
                        break;

                    case Alignment.TopRight:
                    case Alignment.MiddleRight:
                    case Alignment.BottomRight:
                        r.X += n - r.Width;

                        color1 = Color.Transparent;
                        color2 = style.UnderlineColor;
                        break;
                }

                t.X = r.X;

                using (LinearGradientBrush br = new
                    LinearGradientBrush(r, color1, color2, 0f))
                {
                    br.WrapMode = WrapMode.TileFlipXY;

                    g.FillRectangle(br, t);
                }
            }
        }
        private void InitGroupHeaderStyles(DefaultVisualStyles visualStyle, ColorFactory factory)
        {
            MetroPartColors metroColors = _MetroPartColors;

            GroupHeaderVisualStyle style = new GroupHeaderVisualStyle();

            style.AllowWrap = Tbool.True;
            style.Alignment = Alignment.MiddleLeft;
            style.Font = SystemFonts.DefaultFont;

            style.Background = new
                Background(factory.GetColor(metroColors.CanvasColor));

            style.UnderlineColor = factory.GetColor(metroColors.ComplementColor);

            style.RowHeaderStyle.Background = new Background(factory.GetColor(metroColors.CanvasColorLighterShade));
            style.RowHeaderStyle.BorderHighlightColor = GetBorderHighlight();
            style.RowHeaderStyle.Font = SystemFonts.DefaultFont;

            style.TextColor = metroColors.TextColor;
            
            visualStyle.GroupHeaderStyles[StyleType.Default] = style;
        }
Exemple #6
0
        private void RenderHeaderText(Graphics g,
            GroupHeaderVisualStyle style, Rectangle r)
        {
            eTextFormat tf = style.GetTextFormatFlags();

            if (style.Alignment == Alignment.BottomLeft ||
                style.Alignment == Alignment.BottomCenter ||
                style.Alignment == Alignment.BottomRight)
            {
                r.Height -= 4;
            }

            if (r.Width > 0 && r.Height > 0)
            {
                if (_GroupTextMarkup != null)
                    RenderTextMarkup(g, _GroupTextMarkup, style, r);
                else
                    TextDrawing.DrawString(g, Text, style.Font, style.TextColor, r, tf);
            }
        }
Exemple #7
0
        private void RenderTextMarkup(Graphics g,
            BodyElement textMarkup, GroupHeaderVisualStyle 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;
            }
        }
Exemple #8
0
        private void RenderRowHeader(Graphics g,
            GridPanel panel, GroupHeaderVisualStyle style, Rectangle r)
        {
            if (CanShowRowHeader(panel) == true)
            {
                r.Width = panel.RowHeaderWidth;

                using (Brush br = style.RowHeaderStyle.Background.GetBrush(r))
                    g.FillRectangle(br, r);

                using (Pen pen = new Pen(style.RowHeaderStyle.BorderHighlightColor))
                {
                    g.DrawLine(pen, r.X + 1, r.Top, r.Right - 2, r.Top);
                    g.DrawLine(pen, r.X + 1, r.Top, r.X + 1, r.Bottom - 1);
                }

                GridPanelVisualStyle pstyle = panel.GetEffectiveStyle();

                using (Pen pen = new Pen(pstyle.HeaderLineColor))
                {
                    g.DrawLine(pen, r.X, r.Top - 1, r.Right - 1, r.Top - 1);
                    g.DrawLine(pen, r.X, r.Bottom - 1, r.Right - 2, r.Bottom - 1);
                    g.DrawLine(pen, r.Right - 1, r.Top, r.Right - 1, r.Bottom - 1);
                }

                r.X += 4;
                r.Width -= 4;

                int n = RenderIndicatorImage(g, panel, this, r);

                r.X += n;
                r.Width -= n;

                if (panel.ShowRowGridIndex == true)
                    RenderGridIndex(g, this, style.RowHeaderStyle, r);
            }
        }
Exemple #9
0
 private void RenderGroupBackground(
     Graphics g, GroupHeaderVisualStyle style, Rectangle r)
 {
     if (style.Background != null && style.Background.IsEmpty == false)
     {
         using (Brush br = style.Background.GetBrush(r))
             g.FillRectangle(br, r);
     }
 }
Exemple #10
0
        private Rectangle GetAdjustedBounds(GroupHeaderVisualStyle style, Rectangle r)
        {
            r.X += (style.Padding.Left);
            r.Width -= (style.Padding.Horizontal);

            r.Y += (style.Padding.Top + 2);
            r.Height -= (style.Padding.Vertical + 2);

            return (r);
        }
Exemple #11
0
        private Size GetMarkupTextSize(Graphics g,
            BodyElement textMarkup, GroupHeaderVisualStyle style, int width)
        {
            MarkupDrawContext d =
                new MarkupDrawContext(g, style.Font, style.TextColor, false);

            textMarkup.InvalidateElementsSize();
            textMarkup.Measure(new Size(width, 0), d);

            return (textMarkup.Bounds.Size);
        }
Exemple #12
0
        private Size MeasureHeaderText(Graphics g,
            GroupHeaderVisualStyle style, Size constraintSize)
        {
            Size size = Size.Empty;

            string s = Text;

            if (string.IsNullOrEmpty(s) == false)
            {
                if (_GroupTextMarkup != null)
                {
                    size = GetMarkupTextSize(g,
                        _GroupTextMarkup, style, constraintSize.Width);
                }
                else
                {
                    eTextFormat tf = style.GetTextFormatFlags();

                    size = (constraintSize.IsEmpty == true)
                               ? TextHelper.MeasureText(g, s, style.Font)
                               : TextHelper.MeasureText(g, s, style.Font, constraintSize, tf);
                }
            }

            return (size);
        }
Exemple #13
0
        private Size MeasureGroupText(Graphics g,
            GroupHeaderVisualStyle style, Size constraintSize)
        {
            _TextSize = Size.Empty;

            if (String.IsNullOrEmpty(Text) == false)
            {
                GridPanel panel = GridPanel;

                if (panel.IsSubPanel == false)
                {
                    if (panel.ShowGroupExpand == true)
                    {
                        constraintSize.Width = SViewRect.Width;

                        int n = panel.TreeButtonIndent +
                                (panel.LevelIndentSize.Width * IndentLevel);

                        constraintSize.Width -= n;
                    }
                }

                _TextSize = MeasureHeaderText(g, style, constraintSize);
            }

            return (_TextSize);
        }
Exemple #14
0
        private GroupHeaderVisualStyle GetStyle(StyleType e)
        {
            if (_EffectiveVisualStyles.IsValid(e) == false)
            {
                GroupHeaderVisualStyle style = new GroupHeaderVisualStyle();

                StyleType[] css = style.GetApplyStyleTypes(e);

                if (css != null)
                {
                    foreach (StyleType cs in css)
                    {
                        style.ApplyStyle(SuperGrid.BaseVisualStyles.GroupHeaderStyles[cs]);
                        style.ApplyStyle(SuperGrid.DefaultVisualStyles.GroupHeaderStyles[cs]);
                        style.ApplyStyle(GridPanel.DefaultVisualStyles.GroupHeaderStyles[cs]);

                        style.ApplyStyle(GroupHeaderVisualStyles[cs]);
                    }
                }

                SuperGrid.DoGetGroupHeaderStyleEvent(this, e, ref style);

                if (style.Background == null || style.Background.IsEmpty == true)
                    style.Background = new Background(Color.White);

                if (style.Font == null)
                    style.Font = SystemFonts.DefaultFont;

                if (style.TextColor.IsEmpty)
                    style.TextColor = Color.Black;

                _EffectiveVisualStyles[e] = style;
            }

            return (_EffectiveVisualStyles[e]);
        }