Пример #1
0
        private void ProcessFilterHit(GridGroupBox box)
        {
            if (_FilterMenu != null)
                _FilterMenu.Dispose();

            _LockedColumn = true;

            _FilterMenu = new FilterPopup(GridPanel);

            _FilterMenu.ActivatePopup(box.Column, box.FilterImageRelBounds, ResetState);
        }
Пример #2
0
        /// <summary>
        /// Handles invocation of PostRenderGroupBoxConnector events
        /// </summary>
        internal void DoPostRenderGroupBoxConnectorEvent(Graphics g,
            GridGroupByRow groupByRow, GridGroupBox box1, GridGroupBox box2)
        {
            if (PostRenderGroupBoxConnector != null)
            {
                GridPostRenderGroupBoxConnectorEventArgs ev = new
                    GridPostRenderGroupBoxConnectorEventArgs(g, groupByRow.GridPanel, groupByRow, box1, box2);

                PostRenderGroupBoxConnector(this, ev);
            }
        }
Пример #3
0
        /// <summary>
        /// Handles invocation of PostRenderGroupBox events
        /// </summary>
        internal void DoPostRenderGroupBoxEvent(Graphics g,
            GridGroupByRow groupByRow, GridGroupBox box, RenderParts parts, Rectangle bounds)
        {
            if (PostRenderGroupBox != null)
            {
                GridPostRenderGroupBoxEventArgs ev = new
                    GridPostRenderGroupBoxEventArgs(g, groupByRow.GridPanel, groupByRow, box, parts, bounds);

                PostRenderGroupBox(this, ev);
            }
        }
Пример #4
0
 ///<summary>
 /// GridPreRenderGroupBoxConnectorEventArgs
 ///</summary>
 ///<param name="graphics"></param>
 ///<param name="gridPanel"></param>
 ///<param name="groupByRow"></param>
 ///<param name="groupBox1"></param>
 ///<param name="groupBox2"></param>
 public GridPreRenderGroupBoxConnectorEventArgs(Graphics graphics, GridPanel gridPanel,
     GridGroupByRow groupByRow, GridGroupBox groupBox1, GridGroupBox groupBox2)
     : base(graphics, gridPanel, groupByRow, groupBox1, groupBox2)
 {
 }
Пример #5
0
 ///<summary>
 /// GridPreRenderGroupBoxEventArgs
 ///</summary>
 ///<param name="graphics"></param>
 ///<param name="gridPanel"></param>
 ///<param name="groupByRow"></param>
 ///<param name="gridGroupBox"></param>
 ///<param name="parts"></param>
 ///<param name="bounds"></param>
 public GridPreRenderGroupBoxEventArgs(Graphics graphics, GridPanel gridPanel,
     GridGroupByRow groupByRow, GridGroupBox gridGroupBox, RenderParts parts, Rectangle bounds)
     : base(graphics, gridPanel, groupByRow, gridGroupBox, parts, bounds)
 {
 }
Пример #6
0
        internal int GetCornerRadius(GridGroupBox box)
        {
            int maxRadius = Math.Min(
                box.RelativeBounds.Width, box.RelativeBounds.Height) / 2;

            int radius = Math.Min(box.CornerRadius, maxRadius);

            return (radius > 0 ? radius : 0);
        }
Пример #7
0
 ///<summary>
 /// GridConfigureGroupBoxEventArgs
 ///</summary>
 ///<param name="gridPanel"></param>
 ///<param name="groupByRow"></param>
 ///<param name="gridGroupBox"></param>
 public GridConfigureGroupBoxEventArgs(GridPanel gridPanel,
     GridGroupByRow groupByRow, GridGroupBox gridGroupBox)
     : base(gridPanel)
 {
     _GroupByRow = groupByRow;
     _GridGroupBox = gridGroupBox;
 }
Пример #8
0
        private void DragEnd()
        {
            _Dragging = false;

            if (_GroupBoxWindow != null)
            {
                _GroupBoxWindow.Close();

                _GroupBoxWindow = null;
                _MouseDownHitBox = null;

                InvalidateRender(_InsertRect);
                _InsertRect = Rectangle.Empty;

                SuperGrid.PostInternalMouseMove();
            }
        }
Пример #9
0
 private GroupByVisualStyle GetGroupByEffectiveStyle(GridGroupBox box)
 {
     return ((GroupByVisualStyle)
         GetEffectiveStyle(GetGroupByStyleType(box)));
 }
Пример #10
0
        private Rectangle GetInsertRect(Point pt)
        {
            _HitColumn = null;
            _AfterGroupBox = null;

            if (Bounds.Contains(pt) == true)
                return (GetGroupBoxInsertRect(pt));

            return (GetColumnInsertRect(pt));
        }
Пример #11
0
        private Rectangle GetGroupBoxInsertRect(Point pt)
        {
            Rectangle t = Bounds;

            _AfterGroupBox = FindGroupPartition(pt);

            pt = new Point(_AfterGroupBox.Bounds.Right, _AfterGroupBox.Bounds.Y);

            if (GroupBoxLayout == GroupBoxLayout.Flat)
            {
                int index = _GroupBoxes.IndexOf(_AfterGroupBox);

                if (index + 1 < _GroupBoxes.Count)
                {
                    GridGroupBox beforeBox = _GroupBoxes[index + 1];

                    if (index == 0 || beforeBox.Bounds.Y < pt.Y)
                        pt.Y = beforeBox.Bounds.Y;
                }

                pt.X -= 2;
                pt.Y -= 9;

                if (pt.Y < t.Y + 6)
                    pt.Y = t.Y + 6;
            }
            else
            {
                pt.X += 2;
                pt.Y -= 6;

                if (pt.Y < t.Y + 2)
                    pt.Y = t.Y + 2;
            }

            pt.X = Math.Max(pt.X, t.X + 2);

            if (pt.X + MarkerWidth + 2 > ViewRect.Right)
                pt.X = ViewRect.Right - MarkerWidth - 2;

            return (new Rectangle(pt.X, pt.Y, MarkerWidth, MarkerHeight));
        }
Пример #12
0
        internal bool DragStart(GridColumn column)
        {
            GridPanel panel = GridPanel;

            if (panel.VirtualMode == true)
                return (false);

            if (AllowSelection == true && panel.ColumnHeader.Visible == true &&
                column.GroupBoxEffectsEx != GroupBoxEffects.None)
            {
                Capture = true;

                _Dragging = true;

                _GroupBoxWindow = new FloatWindow();
                _GroupBoxWindow.Opacity = .5;
                _GroupBoxWindow.Owner = SuperGrid.FindForm();
                _GroupBoxWindow.Paint += GroupBoxWindowPaint;

                GridGroupBox box = new GridGroupBox(this, column);

                box.GroupBoxStyle = GroupBoxStyle;
                box.CornerRadius = CornerRadius;

                Size size = GetGroupBoxSize(box);
                Rectangle r = new Rectangle(Point.Empty, size);

                UpdateGroupBoxRects(GridPanel, box, ref r);

                box.RelativeBounds = r;
                box.IsDragBox = true;

                _GroupBoxWindow.Size = r.Size;

                int radius = GetCornerRadius(box);

                if (radius > 0 && box.GroupBoxStyle == GroupBoxStyle.RoundedRectangular)
                {
                    using (GraphicsPath path = GetRoundedPath(r, radius))
                    {
                        GraphicsPath cpath = (GraphicsPath)path.Clone();

                        using (Pen pen = new Pen(Color.Black, 2))
                            cpath.Widen(pen);

                        Region rgn = new Region(path);
                        rgn.Union(cpath);

                        _GroupBoxWindow.Region = rgn;
                    }
                }

                _GroupBoxWindow.Tag = box;

                return (true);
            }

            return (false);
        }
Пример #13
0
        internal override void InternalMouseUp(MouseEventArgs e)
        {
            base.InternalMouseUp(e);

            GridPanel panel = GridPanel;

            if (_GroupBoxWindow != null)
            {
                GridGroupBox box = (GridGroupBox)_GroupBoxWindow.Tag;

                if (_AfterGroupBox != null)
                {
                    int index = _GroupBoxes.IndexOf(_AfterGroupBox);

                    if (box.Column.GroupBoxEffectsEx == GroupBoxEffects.Move)
                        box.Column.Visible = false;

                    panel.InsertGroup(box.Column, index);
                }
                else if (box.Column.GroupBoxEffectsEx != GroupBoxEffects.None)
                {
                    if (_HitColumn != null)
                    {
                        box.Column.Visible = true;

                        if (_HitColumn != box.Column)
                            ReorderColumn(panel, box.Column);

                        panel.RemoveGroup(box.Column);

                        panel.NeedsSorted = true;
                    }
                }

                DragEnd();
            }
            else
            {
                if (_HitGroupBox != null && _HitGroupBox == _MouseDownHitBox)
                {
                    if (_HitArea == HeaderArea.InContent)
                    {
                        if (panel.IsSortable == true && _AllowUserSort == true)
                        {
                            if ((Control.ModifierKeys & Keys.Control) != Keys.Control)
                            {
                                panel.ColumnHeader.SortColumn(panel, _HitGroupBox.Column);

                                SuperGrid.PostInternalMouseMove();
                            }
                        }
                    }
                }
            }

            if (_MouseDownHitBox != null)
            {
                InvalidateRender(_MouseDownHitBox.Bounds);

                _MouseDownHitBox = null;
            }
        }
Пример #14
0
 internal void ResetState()
 {
     _HitGroupBox = null;
     _LockedColumn = false;
 }
Пример #15
0
        private void UpdateGroupBoxRects(
            GridPanel panel, GridGroupBox box, ref Rectangle r)
        {
            Rectangle t = r;

            Rectangle ts = GetSortImageBounds(panel, box.Column, t);
            Rectangle tf = GetFilterImageBounds(panel, box.Column, t);

            if (ts.Width > 0)
                r.Width += (ts.Width + TextPad);

            if (tf.Width > 0)
                r.Width += (tf.Width + TextPad);

            r.Width += 3;

            box.RelativeBounds = r;

            if (tf.IsEmpty == false && ts.IsEmpty == false)
            {
                if (ts.X == tf.X)
                {
                    if (tf.X < r.X + r.Width / 2)
                        tf.X += ts.Width + TextPad;
                    else
                        ts.X += tf.Width + TextPad;
                }
                else
                {
                    if (tf.X < r.X + r.Width / 2)
                        ts.X = r.Right - (ts.Width + TextPad);
                    else
                        tf.X = r.Right - (tf.Width + TextPad);
                }
            }
            else
            {
                if (ts.Width > 0 && ts.X > r.X + r.Width / 2)
                    ts.X = r.Right - (ts.Width + TextPad);

                if (tf.Width > 0 && tf.X > r.X + r.Width / 2)
                    tf.X = r.Right - (tf.Width + TextPad);
            }

            box.FilterImageRelBounds = tf;
            box.SortImageRelBounds = ts;
        }
Пример #16
0
        private StyleType GetGroupByStyleType(GridGroupBox box)
        {
            if (IsMouseDown == true)
            {
                Point pt = Control.MousePosition;
                pt = SuperGrid.PointToClient(pt);

                if (box.FilterImageBounds.Contains(pt) == false)
                {
                    if (box.IsDragBox == true || box.IsEqualTo(_MouseDownHitBox))
                    {
                        if (box.IsEqualTo(_HitGroupBox) == true)
                            return (StyleType.SelectedMouseOver);

                        return (StyleType.Selected);
                    }

                    return (StyleType.Default);
                }
            }

            if (box.IsEqualTo(_HitGroupBox) == true)
                return (StyleType.MouseOver);

            return (StyleType.Default);
        }
Пример #17
0
        private void RenderGroupBox(GridPanel panel,
            GridGroupBox box, GridGroupBox lastBox, Graphics g, GridPanelVisualStyle pstyle)
        {
            StyleType type = GetGroupByStyleType(box);

            ColumnHeaderVisualStyle cstyle = panel.ColumnHeader.GetEffectiveStyle(box.Column, type);
            GroupByVisualStyle style = GetGroupByEffectiveStyle(box);

            Rectangle r = box.Bounds;

            if (r.Width > 0 && r.Height > 0)
            {
                if (SuperGrid.DoPreRenderGroupBoxEvent(g,
                    this, box, RenderParts.Background, r) == false)
                {
                    int radius = GetCornerRadius(box);

                    if (radius > 0 && box.GroupBoxStyle == GroupBoxStyle.RoundedRectangular)
                        RenderRoundedBox(g, style, cstyle, pstyle, lastBox, box, radius);
                    else
                        RenderRectBox(g, style, cstyle, pstyle, lastBox, box);

                    SuperGrid.DoPostRenderGroupBoxEvent(g,
                        this, box, RenderParts.Background, r);
                }

                Rectangle t = r;

                RenderSortImage(g, panel, box, ref t);
                RenderFilterImage(g, panel, box, ref t);

                int n = box.Padding.Left + TextHPad;

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

                if (t.Width - box.ContentSize.Width > 0)
                    t.Width = box.ContentSize.Width;

                if (SuperGrid.DoPreRenderGroupBoxEvent(g,
                    this, box, RenderParts.Content, t) == false)
                {
                    Rectangle t2 = t;

                    t.Y += box.Padding.Top;
                    t.Height = box.Column.HeaderTextSize.Height + 6;

                    RenderText(g, box.Column, style, cstyle, t);

                    SuperGrid.DoPostRenderGroupBoxEvent(g,
                        this, box, RenderParts.Content, t2);
                }
            }
        }
Пример #18
0
 internal bool IsEqualTo(GridGroupBox box)
 {
     return (box != null && box.Column == Column);
 }
Пример #19
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;
            }
        }
Пример #20
0
        private int GetGroupByHeight(GridPanel panel)
        {
            if (_GroupBoxes == null)
                _GroupBoxes = new List<GridGroupBox>();
            else
                _GroupBoxes.Clear();

            GridGroupBox box = new GridGroupBox(this, null);
            _GroupBoxes.Add(box);

            int rowHeight = (GroupBoxLayout == GroupBoxLayout.Hierarchical)
                                ? GetHierarchicalHeight(panel)
                                : GetFlatHeight(panel);

            rowHeight += (MarkerVPad * 2);

            TextRowVisualStyle tstyle = GetEffectiveStyle();

            rowHeight += tstyle.BorderThickness.Vertical +
                tstyle.Padding.Vertical + tstyle.Margin.Vertical;

            return (rowHeight);
        }
Пример #21
0
 ///<summary>
 /// GridPostRenderGroupBoxConnectorEventArgs
 ///</summary>
 ///<param name="graphics"></param>
 ///<param name="gridPanel"></param>
 ///<param name="groupByRow"></param>
 ///<param name="groupBox1"></param>
 ///<param name="groupBox2"></param>
 public GridPostRenderGroupBoxConnectorEventArgs(Graphics graphics,
     GridPanel gridPanel, GridGroupByRow groupByRow, GridGroupBox groupBox1, GridGroupBox groupBox2)
     : base(gridPanel)
 {
     _Graphics = graphics;
     _GroupByRow = groupByRow;
     _GridGroupBox1 = groupBox1;
     _GridGroupBox2 = groupBox2;
 }
Пример #22
0
        private int GetHierarchicalHeight(GridPanel panel)
        {
            int rowHeight = 0;
            int lastHeight = 0;

            foreach (GridColumn column in panel.GroupColumns)
            {
                GridGroupBox box = new GridGroupBox(this, column);

                box.GroupBoxStyle = GroupBoxStyle;
                box.CornerRadius = CornerRadius;

                _GroupBoxes.Add(box);

                Size size = GetGroupBoxSize(box);

                if (rowHeight == 0)
                {
                    rowHeight = size.Height;
                }
                else
                {
                    if (size.Height > lastHeight)
                        rowHeight += (size.Height - lastHeight / 2);
                    else
                        rowHeight += (size.Height / 2);
                }

                lastHeight = size.Height;
            }

            return (rowHeight);
        }
Пример #23
0
 ///<summary>
 /// GridPostRenderGroupBoxEventArgs
 ///</summary>
 ///<param name="graphics"></param>
 ///<param name="gridPanel"></param>
 ///<param name="groupByRow"></param>
 ///<param name="gridGroupBox"></param>
 ///<param name="parts"></param>
 ///<param name="bounds"></param>
 public GridPostRenderGroupBoxEventArgs(Graphics graphics, GridPanel gridPanel,
     GridGroupByRow groupByRow, GridGroupBox gridGroupBox, RenderParts parts, Rectangle bounds)
     : base(gridPanel)
 {
     _Graphics = graphics;
     _GroupByRow = groupByRow;
     _GridGroupBox = gridGroupBox;
     _RenderParts = parts;
     _Bounds = bounds;
 }
Пример #24
0
        private int GetFlatHeight(GridPanel panel)
        {
            int rowHeight = 0;

            foreach (GridColumn column in panel.GroupColumns)
            {
                GridGroupBox box = new GridGroupBox(this, column);

                box.GroupBoxStyle = GroupBoxStyle;
                box.CornerRadius = CornerRadius;

                _GroupBoxes.Add(box);

                Size size = GetGroupBoxSize(box);

                if (size.Height > rowHeight)
                    rowHeight = size.Height;
            }

            return (rowHeight);
        }
Пример #25
0
        /// <summary>
        /// Handles invocation of ConfigureGroupBox events
        /// </summary>
        internal void DoConfigureGroupBoxEvent(
            GridGroupByRow groupByRow, GridGroupBox gridGroupBox)
        {
            if (ConfigureGroupBox != null)
            {
                GridConfigureGroupBoxEventArgs ev = new
                    GridConfigureGroupBoxEventArgs(groupByRow.GridPanel, groupByRow, gridGroupBox);

                ConfigureGroupBox(this, ev);
            }
        }
Пример #26
0
        private Size GetGroupBoxSize(GridGroupBox box)
        {
            Size size = new Size();

            size.Width = box.Column.HeaderTextSize.Width + TextHPad;
            size.Height = box.Column.HeaderTextSize.Height + TextVPad;

            box.ContentSize = size;

            SuperGrid.DoConfigureGroupBoxEvent(this, box);

            size = box.ContentSize;

            size.Width += box.Padding.Horizontal;
            size.Height += box.Padding.Vertical;

            if (size.Width > _MaxGroupBoxWidth)
                size.Width = _MaxGroupBoxWidth;

            size.Width += MarkerHPad + TextHPad;

            if (size.Width < 20)
                size.Width = 20;

            if (size.Height < 15)
                size.Height = 15;

            box.RelativeBounds = new Rectangle(Point.Empty, size);

            return (size);
        }
Пример #27
0
        /// <summary>
        /// Handles invocation of PreRenderGroupBoxConnector events
        /// </summary>
        internal bool DoPreRenderGroupBoxConnectorEvent(Graphics g,
            GridGroupByRow groupByRow, GridGroupBox box1, GridGroupBox box2)
        {
            if (PreRenderGroupBoxConnector != null)
            {
                GridPreRenderGroupBoxConnectorEventArgs ev = new
                    GridPreRenderGroupBoxConnectorEventArgs(g, groupByRow.GridPanel, groupByRow, box1, box2);

                PreRenderGroupBoxConnector(this, ev);

                return (ev.Cancel);
            }

            return (false);
        }
Пример #28
0
        private void UpdateGroupBoxes(GridPanel panel, Rectangle r)
        {
            TextRowVisualStyle tstyle = GetEffectiveStyle();

            r = GetAdjustedBounds(tstyle, r);
            r.Size = Size.Empty;

            if (CanShowRowHeader(panel) == true)
                r.X += panel.RowHeaderWidth;

            r.X += (MarkerWidth - MarkerHPad);
            r.Y += (MarkerVPad - MarkerHeight + TextPad);

            GridGroupBox box = _GroupBoxes[0];
            box.RelativeBounds = r;

            int lastHeight = MarkerHeight;
            int midline = Bounds.Y + Bounds.Height / 2 - 1;

            for (int i = 1; i < _GroupBoxes.Count; i++)
            {
                box = _GroupBoxes[i];

                r.X += (r.Width + BoxSpacing);
                r.Size = box.RelativeBounds.Size;

                if (GroupBoxLayout == GroupBoxLayout.Hierarchical)
                {
                    r.Y += (r.Height > lastHeight)
                        ? lastHeight / 2 : lastHeight - r.Height / 2;
                }
                else
                {
                    r.Y = midline - (r.Height / 2);
                }

                UpdateGroupBoxRects(panel, box, ref r);

                lastHeight = r.Height;
            }

            _AfterGroupBox = null;
        }
Пример #29
0
        /// <summary>
        /// Handles invocation of PreRenderGroupBox events
        /// </summary>
        internal bool DoPreRenderGroupBoxEvent(Graphics g,
            GridGroupByRow groupByRow, GridGroupBox box, RenderParts parts, Rectangle bounds)
        {
            if (PreRenderGroupBox != null)
            {
                GridPreRenderGroupBoxEventArgs ev = new
                    GridPreRenderGroupBoxEventArgs(g, groupByRow.GridPanel, groupByRow, box, parts, bounds);

                PreRenderGroupBox(this, ev);

                return (ev.Cancel);
            }

            return (false);
        }
Пример #30
0
        internal override void InternalMouseDown(MouseEventArgs e)
        {
            base.InternalMouseDown(e);

            if (e.Button == MouseButtons.Left)
            {
                _MouseDownHitBox = _HitGroupBox;

                if (_MouseDownHitBox != null)
                {
                    Capture = true;

                    if (_HitGroupBox.FilterImageRelBounds.Contains(e.Location) == true)
                        ProcessFilterHit(_MouseDownHitBox);
                    else
                        ProcessContentHit();

                    InvalidateRender(_MouseDownHitBox.Bounds);
                }
            }
        }