private bool CheckGroupHeight(TableItem check, TableGroup parent, ref float height) { height += GroupHeight; if (parent.Expanded) { //Add sub groups foreach (TableGroup subgroup in parent.Groups) { if (subgroup == check) { return(true); } if (CheckGroupHeight(check, subgroup, ref height)) { return(true); } } //Add sub rows if (GetRowsHeight(check, parent, ref height)) { return(true); } } return(false); }
//Returns the first visible group or row from the item provided. private TableItem GetVisibleItem(TableItem item) { List <TableItem> list = new List <TableItem>(); list.Add(item); TableItem child = item; //Create a list parent items while (child.Parent != null) { list.Insert(0, child.Parent); child = child.Parent; } //Loop through list and find bottom most viisble item foreach (TableItem loop in list) { if (loop is TableGroup) { TableGroup group = loop as TableGroup; if (!group.Expanded) { return(group); } } } return(item); }
//Fired when a group or top level row is added to the table private void TableItems_InsertItem(object sender, TableItemsEventArgs e) { TableItem item = e.Value; //Set common values and event handlers for row or group item.SetTable(this); item.Backcolor = GradientColor; //If is a row then set the indent if (item is TableRow) { item.SetIndent(Indent); } if (item is TableGroup) { TableGroup group = (TableGroup)item; group.HeightChanged += new EventHandler(TableGroup_HeightChanged); group.ExpandedChanged += new ExpandedChangedEventHandler(TableGroup_ExpandedChanged); //Set all the table references correctly group.SetTable(); } item.TableItemInvalid += new EventHandler(TableItems_TableItemInvalid); SetHeight(); //Make sure diagram is redrawn OnElementInvalid(); }
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); }
public override void LocatePort(Port port) { if (port is TablePort) { TablePort tablePort = port as TablePort; if (tablePort.TableItem == null) { base.LocatePort(port); return; } //Calculate position of port based on position of table item TableItem visibleItem = GetVisibleItem(tablePort.TableItem); PointF start = TransformRectangle.Location; start.Y += visibleItem.Rectangle.Top + (visibleItem.Rectangle.Height / 2); //Determine which side of the shape the port should be placed if (tablePort.Orientation == PortOrientation.Right) { start.X += visibleItem.Rectangle.Width; } tablePort.Validate = false; tablePort.Location = start; tablePort.Validate = true; } else { base.LocatePort(port); } }
public virtual PointF GetItemPosition(TableItem item) { float height = HeadingHeight + 2; //Add top level groups foreach (TableGroup group in Groups) { if (group == item) { return(new PointF(0, height)); } if (CheckGroupHeight(item, group, ref height)) { return(new PointF(0, height)); } } //Add top level rows foreach (TableRow row in Rows) { if (row == item) { return(new PointF(0, height)); } height += RowHeight; } return(Point.Empty); }
public virtual bool ExecuteMouseCommand(MouseCommand command) { //Only consider left button if (command.MouseButtons != MouseCommandButtons.Left) { return(false); } //Only process mouse down if (command is MouseDownCommand) { PointF location = command.Location; //view.PointToDiagram(e.X, e.Y); PointF local = PointToElement(location); TableItem old = SelectedItem; SelectedItem = GetTableItemFromLocation(local); if (SelectedItem != old && Selected) { return(true); } //Check to see if any groups can be expanded TableGroup group = GetTableGroupExpander(Groups, local); if (group != null) { group.Expanded = !group.Expanded; return(true); } } return(false); }
//Inserts an elelemnt into the list public virtual void Insert(int index, TableItem value) { if (value == null) throw new ArgumentNullException("TableItem parameter cannot be null reference.","value"); if (! mBaseType.IsInstanceOfType(value) && ! value.GetType().IsSubclassOf(mBaseType)) throw new ArgumentException("Items added to this collection must be of or inherit from type '" + mBaseType.ToString()); List.Insert(index, value); if (! mSuspendEvents && InsertItem!=null) InsertItem(this, new TableItemsEventArgs((TableItem) value)); }
//Removes an TableItem from the list public virtual void Remove(TableItem value) { List.Remove(value); if (!mSuspendEvents && RemoveItem != null) { RemoveItem(this, new TableItemsEventArgs((TableItem)value)); } }
public TableItem(TableItem prototype) { mText = prototype.Text; mFont = prototype.Font; mForecolor = prototype.Forecolor; mBackcolor = prototype.Backcolor; mIndent = prototype.Indent; mTag = prototype.Tag; mParent = prototype.Parent; mTable = prototype.Table; }
public TableItem(TableItem prototype) { _text = prototype.Text; _font = prototype.Font; _forecolor = prototype.Forecolor; _backcolor = prototype.Backcolor; _indent = prototype.Indent; _tag = prototype.Tag; _parent = prototype.Parent; _table = prototype.Table; }
public TableItem(TableItem prototype) { mText = prototype.Text; mFont = prototype.Font; mForecolor = prototype.Forecolor; mBackcolor = prototype.Backcolor; mIndent = prototype.Indent; mTag = prototype.Tag; mParent = prototype.Parent; mTable = prototype.Table; }
private bool GetRowsHeight(TableItem check, TableGroup parent, ref float height) { //Add top level rows foreach (TableRow row in parent.Rows) { if (row == check) { return(true); } height += RowHeight; } return(false); }
private void TableItems_RemoveItem(object sender, TableItemsEventArgs e) { TableItem item = e.Value; //Remove handlers if (item is TableGroup) { TableGroup group = (TableGroup)item; group.HeightChanged -= new EventHandler(TableGroup_HeightChanged); group.ExpandedChanged -= new ExpandedChangedEventHandler(TableGroup_ExpandedChanged); } item.TableItemInvalid -= new EventHandler(TableItems_TableItemInvalid); SetHeight(); OnElementInvalid(); }
//Inserts an elelemnt into the list public virtual void Insert(int index, TableItem value) { if (value == null) { throw new ArgumentNullException("TableItem parameter cannot be null reference.", "value"); } if (!mBaseType.IsInstanceOfType(value) && !value.GetType().IsSubclassOf(mBaseType)) { throw new ArgumentException("Items added to this collection must be of or inherit from type '" + mBaseType.ToString()); } List.Insert(index, value); if (!mSuspendEvents && InsertItem != null) { InsertItem(this, new TableItemsEventArgs((TableItem)value)); } }
public virtual PointF GetItemPosition(TableItem item) { float height = HeadingHeight + 2; //Add top level groups foreach (TableGroup group in Groups) { if (group == item) return new PointF(0, height); if (GetGroupHeight(item, group, ref height)) return new PointF(0, height); } //Add top level rows foreach (TableRow row in Rows) { if (row == item) return new PointF(0, height); height += RowHeight; } return Point.Empty; }
private bool GetGroupHeight(TableItem check, TableGroup parent, ref float height) { height += GroupHeight; if (parent.Expanded) { //Add sub groups foreach (TableGroup subgroup in parent.Groups) { if (subgroup == check) return true; if (GetGroupHeight(check, subgroup, ref height)) return true; } //Add sub rows if (GetRowsHeight(check, parent, ref height)) return true; } return false; }
private bool GetRowsHeight(TableItem check, TableGroup parent, ref float height) { //Add top level rows foreach (TableRow row in parent.Rows) { if (row == check) return true; height += RowHeight; } return false; }
//Returns true if list contains TableItem public virtual bool Contains(TableItem value) { return List.Contains(value); }
public TableItemsEventArgs(TableItem value) { mValue = value; }
//Returns the index of an TableItem public virtual int IndexOf(TableItem value) { return List.IndexOf(value); }
//Sets the internal table reference protected internal virtual void SetParent(TableItem parent) { mParent = parent; }
private void ResetTable(TableItem item, Table table) { if (item is TableRow) { TableRow tableRow = (TableRow)item; if (tableRow is EsriTableRow) { ((EsriTableRow)tableRow).SetTable2(table); } } else if (item is TableGroup) { TableGroup tableGroup = (TableGroup)item; if (tableGroup is EsriTableGroup) { ((EsriTableGroup)tableGroup).SetTable2(table); } foreach (TableItem item2 in tableGroup.Groups) { this.ResetTable(item2, table); } foreach (TableItem item3 in tableGroup.Rows) { this.ResetTable(item3, table); } } }
//Sets the internal table reference protected internal virtual void SetParent(TableItem parent) { _parent = parent; }
public TableItemsEventArgs(TableItem value) { mValue = value; }
//Returns the index of an TableItem public virtual int IndexOf(TableItem value) { return(List.IndexOf(value)); }
//Returns true if list contains TableItem public virtual bool Contains(TableItem value) { return(List.Contains(value)); }
public TablePort(TableItem tableItem) : base(0F) { TableItem = tableItem; Fixed = true; }
//Removes an TableItem from the list public virtual void Remove(TableItem value ) { List.Remove(value); if (! mSuspendEvents && RemoveItem!=null) RemoveItem(this, new TableItemsEventArgs((TableItem) value)); }