private void ProcessFilterHit(GridGroupBox box) { if (_FilterMenu != null) _FilterMenu.Dispose(); _LockedColumn = true; _FilterMenu = new FilterPopup(GridPanel); _FilterMenu.ActivatePopup(box.Column, box.FilterImageRelBounds, ResetState); }
/// <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); } }
/// <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); } }
///<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) { }
///<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) { }
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); }
///<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; }
private void DragEnd() { _Dragging = false; if (_GroupBoxWindow != null) { _GroupBoxWindow.Close(); _GroupBoxWindow = null; _MouseDownHitBox = null; InvalidateRender(_InsertRect); _InsertRect = Rectangle.Empty; SuperGrid.PostInternalMouseMove(); } }
private GroupByVisualStyle GetGroupByEffectiveStyle(GridGroupBox box) { return ((GroupByVisualStyle) GetEffectiveStyle(GetGroupByStyleType(box))); }
private Rectangle GetInsertRect(Point pt) { _HitColumn = null; _AfterGroupBox = null; if (Bounds.Contains(pt) == true) return (GetGroupBoxInsertRect(pt)); return (GetColumnInsertRect(pt)); }
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)); }
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); }
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; } }
internal void ResetState() { _HitGroupBox = null; _LockedColumn = false; }
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; }
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); }
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); } } }
internal bool IsEqualTo(GridGroupBox box) { return (box != null && box.Column == Column); }
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; } }
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); }
///<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; }
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); }
///<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; }
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); }
/// <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); } }
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); }
/// <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); }
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; }
/// <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); }
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); } } }