Ejemplo n.º 1
0
        internal ColumnHeaderVisualStyle GetHeaderStyle(StyleType e)
        {
            ValidateStyle();

            if (EffectiveStyles == null)
                EffectiveStyles = new ColumnHeaderVisualStyles();

            if (EffectiveStyles.IsValid(e) == false)
            {
                ColumnHeaderVisualStyle style = new ColumnHeaderVisualStyle();

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

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

                SuperGrid.DoGetColumnHeaderStyleEvent(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;

                EffectiveStyles[e] = style;
            }

            return (EffectiveStyles[e]);
        }
Ejemplo n.º 2
0
 ///<summary>
 /// GridGetColumnHeaderStyleEventArgs
 ///</summary>
 ///<param name="gridPanel"></param>
 ///<param name="gridColumn"></param>
 ///<param name="styleType"></param>
 ///<param name="style"></param>
 public GridGetColumnHeaderStyleEventArgs(
     GridPanel gridPanel, GridColumn gridColumn, StyleType styleType, ColumnHeaderVisualStyle style)
     : base(gridPanel, gridColumn)
 {
     _StyleType = styleType;
     _Style = style;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles invocation of GetColumnHeader events
        /// </summary>
        internal void DoGetColumnHeaderStyleEvent(
            GridColumn gridColumn, StyleType eStyle, ref ColumnHeaderVisualStyle style)
        {
            if (GetColumnHeaderStyle != null)
            {
                GridGetColumnHeaderStyleEventArgs ev = new
                    GridGetColumnHeaderStyleEventArgs(gridColumn.GridPanel, gridColumn, eStyle, style);

                GetColumnHeaderStyle(this, ev);

                style = ev.Style;
            }
        }
        private void InitColumnStyles(DefaultVisualStyles visualStyle, ColorFactory factory)
        {
            ColumnHeaderVisualStyle colStyle = new ColumnHeaderVisualStyle();

            colStyle.Alignment = Alignment.MiddleCenter;
            colStyle.BorderColor = new BorderColor(factory.GetColor(0xA0B0C7));
            colStyle.BorderPattern.All = LinePattern.Solid;
            colStyle.BorderThickness.All = 0;
            colStyle.Font = SystemFonts.CaptionFont;
            colStyle.ImageAlignment = Alignment.MiddleLeft;
            colStyle.Margin.All = 0;
            colStyle.ImageOverlay = ImageOverlay.None;
            colStyle.TextColor = Color.Black;

            colStyle.Background = new Background(factory.GetColor(0xEFF4FB), factory.GetColor(0xE1ECFA));
            visualStyle.ColumnHeaderStyles[StyleType.Default] = colStyle;

            colStyle = new ColumnHeaderVisualStyle();
            colStyle.Background = new Background(factory.GetColor(0xFFDF6B), factory.GetColor(0xFFFCE6));
            visualStyle.ColumnHeaderStyles[StyleType.MouseOver] = colStyle;

            colStyle = new ColumnHeaderVisualStyle();
            colStyle.Background = GetDefaultSelectedColumnBackground(factory);
            visualStyle.ColumnHeaderStyles[StyleType.Selected] = colStyle;

            colStyle = new ColumnHeaderVisualStyle();
            colStyle.Background = GetSelectedColumnMouseOverBackground(factory);
            visualStyle.ColumnHeaderStyles[StyleType.SelectedMouseOver] = colStyle;
        }
        private void InitColumnStyles(DefaultVisualStyles visualStyle, ColorFactory factory)
        {
            ColumnHeaderVisualStyle colStyle = new ColumnHeaderVisualStyle();

            colStyle.Alignment = Alignment.MiddleCenter;
            colStyle.Font = SystemFonts.CaptionFont;
            colStyle.ImageAlignment = Alignment.MiddleLeft;
            colStyle.Margin.All = 0;
            colStyle.ImageOverlay = ImageOverlay.None;
            colStyle.TextColor = factory.GetColor(0xE2E2E2);

            colStyle.Background = new Background(factory.GetColor(0x6A6A6A));
            visualStyle.ColumnHeaderStyles[StyleType.Default] = colStyle;
            colStyle = new ColumnHeaderVisualStyle();

            colStyle.Background = new Background(factory.GetColor(0xFFDF6B), factory.GetColor(0xFFFCE6));
            colStyle.TextColor = factory.GetColor(0x444444);
            visualStyle.ColumnHeaderStyles[StyleType.MouseOver] = colStyle;

            colStyle = new ColumnHeaderVisualStyle();
            colStyle.Background = GetDefaultSelectedColumnBackground(factory);
            colStyle.TextColor = factory.GetColor(0x444444);
            visualStyle.ColumnHeaderStyles[StyleType.Selected] = colStyle;

            colStyle = new ColumnHeaderVisualStyle();
            colStyle.Background = GetSelectedColumnMouseOverBackground(factory);
            colStyle.TextColor = factory.GetColor(0x444444);
            visualStyle.ColumnHeaderStyles[StyleType.SelectedMouseOver] = colStyle;
        }
Ejemplo n.º 6
0
        private int GetPartSizeNeeded(Image image,
            ColumnHeaderVisualStyle style, Alignment alignment, ref Size sizeNeeded)
        {
            int height = 0;

            if (image != null)
            {
                if (alignment != Alignment.TopCenter &&
                    alignment != Alignment.MiddleCenter &&
                    alignment != Alignment.BottomCenter)
                {
                    sizeNeeded.Width += (image.Width + 4);
                }

                if (alignment == Alignment.MiddleLeft ||
                    alignment == Alignment.MiddleCenter ||
                    alignment == Alignment.MiddleRight ||
                    VAlignment(alignment) == VAlignment(style.Alignment))
                {
                    sizeNeeded.Height = Math.Max(sizeNeeded.Height, image.Height);
                }
                else
                {
                    height = (image.Height + 2);
                }
            }

            return (height);
        }
Ejemplo n.º 7
0
        private void InitColumnStyles(DefaultVisualStyles visualStyle, ColorFactory factory)
        {
            ColumnHeaderVisualStyle colStyle = new ColumnHeaderVisualStyle();
            MetroPartColors metroColors = _MetroPartColors;

            colStyle.Alignment = Alignment.MiddleCenter;
            colStyle.BorderColor = new BorderColor(factory.GetColor(metroColors.CanvasColorLightShade));
            colStyle.BorderPattern.All = LinePattern.Solid;
            colStyle.BorderThickness.All = 0;
            colStyle.Font = SystemFonts.CaptionFont;
            colStyle.ImageAlignment = Alignment.MiddleLeft;
            colStyle.Margin.All = 0;
            colStyle.ImageOverlay = ImageOverlay.None;
            colStyle.TextColor = factory.GetColor(metroColors.TextColor);

            colStyle.Background = new Background(factory.GetColor(metroColors.CanvasColorLighterShade));

            visualStyle.ColumnHeaderStyles[StyleType.Default] = colStyle;
            visualStyle.ColumnHeaderStyles[StyleType.ReadOnly] = colStyle.Copy();
            visualStyle.ColumnHeaderStyles[StyleType.ReadOnly].Font = null;

            colStyle = new ColumnHeaderVisualStyle();
            colStyle.Background = new Background(factory.GetColor(metroColors.CanvasColorLightShade));
            visualStyle.ColumnHeaderStyles[StyleType.MouseOver] = colStyle;
            visualStyle.ColumnHeaderStyles[StyleType.ReadOnlyMouseOver] = colStyle.Copy();

            colStyle = new ColumnHeaderVisualStyle();
            colStyle.Background = GetDefaultSelectedColumnBackground(factory);
            visualStyle.ColumnHeaderStyles[StyleType.Selected] = colStyle;
            visualStyle.ColumnHeaderStyles[StyleType.ReadOnlySelected] = colStyle.Copy();

            colStyle = new ColumnHeaderVisualStyle();
            colStyle.Background = GetSelectedColumnMouseOverBackground();
            visualStyle.ColumnHeaderStyles[StyleType.SelectedMouseOver] = colStyle;
            visualStyle.ColumnHeaderStyles[StyleType.ReadOnlySelectedMouseOver] = colStyle.Copy();
        }
Ejemplo n.º 8
0
        private Rectangle UpdateContentRect(Rectangle r,
            Rectangle t, Alignment alignment, ColumnHeaderVisualStyle style, GridColumn column)
        {
            switch (GetStringAlignment(alignment))
            {
                case StringAlignment.Near:
                    int n1 = r.Right - t.Left;

                    switch (GetStringAlignment(style.Alignment))
                    {
                        case StringAlignment.Center:
                            if (n1 + 3 > (t.Width - column.HeaderTextSize.Width) / 2)
                            {
                                t.X = r.Right;
                                t.Width -= n1;
                            }
                            break;

                        default:
                            t.X = r.Right;
                            t.Width -= n1;
                            break;
                    }
                    break;

                case StringAlignment.Far:
                    int n2 = t.Right - r.Left;

                    switch (GetStringAlignment(style.Alignment))
                    {
                        case StringAlignment.Center:
                            if (n2 + 3 > (t.Width - column.HeaderTextSize.Width) / 2)
                                t.Width -= n2;
                            break;

                        default:
                            t.Width -= n2;
                            break;
                    }
                    break;
            }

            return (t);
        }
Ejemplo n.º 9
0
        private void RenderHeaderImage(Graphics g, GridPanel panel,
            ColumnHeaderVisualStyle style, Rectangle bounds, Rectangle r)
        {
            if (_ShowHeaderImages == true)
            {
                Image image = style.GetImage(panel);

                if (image != null)
                {
                    Rectangle t = style.GetImageBounds(image, r);
                    bounds.Inflate(-1, -1);
                    t.Intersect(bounds);

                    if (t.Width > 0 && t.Height > 0)
                        g.DrawImageUnscaledAndClipped(image, t);
                }
            }
        }
Ejemplo n.º 10
0
        private Rectangle RenderSortAndFilterImage(
            Graphics g, GridColumn column, ColumnHeaderVisualStyle style, Rectangle t)
        {
            GridPanel panel = column.Parent as GridPanel;

            if (panel != null)
            {
                Alignment falign = (_FilterImageAlignment == Alignment.NotSet)
                    ? Alignment.MiddleLeft : _FilterImageAlignment;

                Alignment salign = (_SortImageAlignment == Alignment.NotSet)
                    ? Alignment.TopCenter : _SortImageAlignment;

                Rectangle rf = GetFilterImageBounds(panel, column);

                if (rf.IsEmpty == false)
                {
                    Image filterImage = GetColumnFilterImage(column);

                    if (filterImage != null)
                        g.DrawImageUnscaledAndClipped(filterImage, rf);
                }

                Rectangle rs = GetSortImageBounds(panel, column, salign, falign, rf);

                if (rs.IsEmpty == false)
                {
                    Image sortImage = GetColumnSortImage(panel, column);

                    if (sortImage != null)
                        g.DrawImageUnscaledAndClipped(sortImage, rs);
                }

                if (rf.IsEmpty == false)
                    t = UpdateContentRect(rf, t, falign, style, column);

                if (rs.IsEmpty == false)
                    t = UpdateContentRect(rs, t, salign, style, column);
            }

            t.X += 2;
            t.Width -= 4;

            return (t);
        }
Ejemplo n.º 11
0
        private Rectangle GetBorderRect(
            ColumnHeaderVisualStyle style, Rectangle r)
        {
            r.X += style.Margin.Left;
            r.Width -= style.Margin.Horizontal;

            r.Y += style.Margin.Top;
            r.Height -= style.Margin.Vertical;

            return (r);
        }
Ejemplo n.º 12
0
        private void RenderRoundedBox(Graphics g, GroupByVisualStyle style,
            ColumnHeaderVisualStyle cstyle, GridPanelVisualStyle pstyle,
            GridGroupBox leftBox, GridGroupBox box, int radius)
        {
            Rectangle r = box.Bounds;

            using (GraphicsPath path = GetRoundedPath(r, radius))
            {
                SmoothingMode sm = g.SmoothingMode;
                g.SmoothingMode = SmoothingMode.AntiAlias;

                if (_UseColumnHeaderColors == true)
                {
                    using (Brush br = cstyle.Background.GetBrush(r))
                        g.FillPath(br, path);

                    using (Pen pen = new Pen(pstyle.HeaderLineColor))
                        g.DrawPath(pen, path);
                }
                else
                {
                    using (Brush br = style.GroupBoxBackground.GetBrush(r))
                        g.FillPath(br, path);

                    using (Pen pen = new Pen(style.GroupBoxBorderColor))
                        g.DrawPath(pen, path);
                }

                if (leftBox != null)
                {
                    Region oldClip = g.Clip;
                    Region newClip = new Region(Bounds);

                    newClip.Exclude(path);

                    g.SetClip(newClip, CombineMode.Intersect);

                    try
                    {
                        if (SuperGrid.DoPreRenderGroupBoxConnectorEvent(g, this, leftBox, box) == false)
                        {
                            RenderBoxConnector(g, style, leftBox.Bounds, box.Bounds, true);

                            SuperGrid.DoPostRenderGroupBoxConnectorEvent(g, this, leftBox, box);
                        }
                    }
                    finally
                    {
                        g.Clip = oldClip;
                    }
                }

                g.SmoothingMode = sm;
            }
        }
Ejemplo n.º 13
0
        private void RenderText(Graphics g, GridColumn column,
            GroupByVisualStyle style, ColumnHeaderVisualStyle cstyle, Rectangle bounds)
        {
            string s = column.GetHeaderText();

            if (s != null)
            {
                if (column.HeaderTextMarkup != null)
                {
                    RenderTextMarkup(g, column.HeaderTextMarkup, cstyle, bounds);
                }
                else
                {
                    if (_UseColumnHeaderColors == true)
                    {
                        eTextFormat tf = cstyle.GetTextFormatFlags();

                        TextDrawing.DrawString(g, s,
                            cstyle.Font, cstyle.TextColor, bounds, tf);
                    }
                    else
                    {
                        eTextFormat tf = style.GetTextFormatFlags();

                        TextDrawing.DrawString(g, s,
                            cstyle.Font, style.GroupBoxTextColor, bounds, tf);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private void RenderRectBox(Graphics g, GroupByVisualStyle style,
            ColumnHeaderVisualStyle cstyle, GridPanelVisualStyle pstyle,
            GridGroupBox leftBox, GridGroupBox box)
        {
            Rectangle r = box.Bounds;

            if (_UseColumnHeaderColors == true)
            {
                using (Brush br = cstyle.Background.GetBrush(r))
                    g.FillRectangle(br, r);

                using (Pen pen = new Pen(pstyle.HeaderLineColor))
                    g.DrawRectangle(pen, r);
            }
            else
            {
                using (Brush br = style.GroupBoxBackground.GetBrush(r))
                    g.FillRectangle(br, r);

                using (Pen pen = new Pen(style.GroupBoxBorderColor))
                    g.DrawRectangle(pen, r);
            }

            if (leftBox != null)
            {
                if (SuperGrid.DoPreRenderGroupBoxConnectorEvent(g, this, leftBox, box) == false)
                {
                    RenderBoxConnector(g, style, leftBox.Bounds, r, false);

                    SuperGrid.DoPostRenderGroupBoxConnectorEvent(g, this, leftBox, box);
                }
            }
        }