private TableItem GetGroupTableItem(TableGroups groups, PointF local, ref float currentHeight) { //Check the groups and each rows collection inside groups foreach (TableGroup tableGroup in groups) { if (local.Y >= currentHeight && local.Y <= currentHeight + GroupHeight) { return(tableGroup); } currentHeight += GroupHeight; if (tableGroup.Expanded) { TableItem item = GetGroupTableItem(tableGroup.Groups, local, ref currentHeight); if (item != null) { return(item); } foreach (TableRow tableRow in tableGroup.Rows) { if (local.Y >= currentHeight && local.Y <= currentHeight + GroupHeight) { return(tableRow); } currentHeight += RowHeight; } } } return(null); }
//Copy all rows from source to target via clone public static void CopyGroups(TableGroups source, TableGroups target) { foreach (TableGroup group in source) { target.Add((TableGroup)group.Clone()); } }
public TableGroup(TableGroup prototype) : base(prototype) { _expanded = prototype.Expanded; Rows = new TableRows(); Groups = new TableGroups(); Table.CopyRows(prototype.Rows, Rows); Table.CopyGroups(prototype.Groups, Groups); }
//Constructors public Table() { Groups = new TableGroups(); Rows = new TableRows(); HeadingHeight = 40; Heading = "Heading"; SubHeading = "Sub Heading"; GroupHeight = 20; RowHeight = 20; Indent = 16; ExpandedSize = Size; ContractedSize = new SizeF(Size.Width, CalculateItemRectangles()); Expanded = true; DrawExpand = false; Forecolor = Color.Black; GradientColor = SystemColors.Control; DrawSelectedItem = true; }
private TableGroup GetTableGroupExpander(TableGroups groups, PointF local) { foreach (TableGroup group in groups) { RectangleF expander = new RectangleF(group.Indent + 4, group.Rectangle.Top + 4, 11, 11); if (expander.Contains(local)) { return(group); } //Sub groups TableGroup result = GetTableGroupExpander(group.Groups, local); if (result != null) { return(result); } } return(null); }
private void SetItemRectangles(TableGroups groups, TableRows rows, ref float height, float indent) { //Add sub groups foreach (TableGroup group in groups) { group.SetItemRectangle(new RectangleF(0, height, Width, GroupHeight)); group.SetIndent(indent); height += GroupHeight; if (group.Expanded) { SetItemRectangles(group.Groups, group.Rows, ref height, indent + Indent); } } //Add sub rows indent += Indent; foreach (TableRow row in rows) { row.SetItemRectangle(new RectangleF(0, height, Width, RowHeight)); row.SetIndent(indent); height += RowHeight; } }
public Table(Table prototype) : base(prototype) { _headingHeight = prototype.HeadingHeight; _heading = prototype.Heading; _subHeading = prototype.SubHeading; _groupHeight = prototype.GroupHeight; _rowHeight = prototype.RowHeight; _rowIndent = prototype.Indent; _expanded = prototype.Expanded; _drawExpand = prototype.DrawExpand; _forecolor = prototype.Forecolor; GradientColor = prototype.GradientColor; _drawSelectedItem = prototype.DrawSelectedItem; _font = prototype.Font; ContractedSize = prototype.ContractedSize; ExpandedSize = prototype.ExpandedSize; Groups = new TableGroups(); Rows = new TableRows(); Table.CopyGroups(prototype.Groups, Groups); Table.CopyRows(prototype.Rows, Rows); }
//Constructors public TableGroup() { Expanded = true; Rows = new TableRows(); Groups = new TableGroups(); }
private void RenderTableGroups(Table table, Graphics graphics, Render render, TableGroups groups, ref float iHeight) { foreach (TableGroup tableGroup in groups) { IFormsRenderer renderer = render.GetRenderer(tableGroup); renderer.RenderElement(tableGroup, graphics, render); iHeight += table.GroupHeight; //Render groups and rows recursively if (tableGroup.Groups.Count > 0 && tableGroup.Expanded) { RenderTableGroups(table, graphics, render, tableGroup.Groups, ref iHeight); } if (tableGroup.Rows.Count > 0 && tableGroup.Expanded) { RenderTableRows(table, graphics, render, tableGroup.Rows, ref iHeight); } } }
public void Clear() { TablePaths.Clear(); TableGroups.Clear(); }