public void Add(ChangeListTree.TreeNode n) { if (this.Children == null) { this.Children = new List <ChangeListTree.TreeNode>(); } this.Children.Add(n); n.Level = this.Level + 1; n.Parent = this; }
private void DrawSubItemFunc(object sender, DrawListViewSubItemEventArgs e) { e.Graphics.FillRectangle((e.Item.Selected ? SystemBrushes.Highlight : Brushes.White), e.Bounds); if (e.ColumnIndex != 0) { TextRenderer.DrawText(e.Graphics, e.SubItem.Text, this.Font, e.Bounds, e.Item.ForeColor, TextFormatFlags.Default); return; } int left = e.Bounds.Left; Rectangle bounds = e.Bounds; Point point = new Point(left, bounds.Top); ChangeListTree.TreeNode tag = e.Item.Tag as ChangeListTree.TreeNode; point.X = point.X + tag.Level * 20; if ((e.Item.Tag as ChangeListTree.TreeNode).HasChildren) { int top = e.Bounds.Top; bounds = e.Bounds; int bottom = (top + bounds.Bottom) / 2; Rectangle rectangle = new Rectangle(point.X, bottom - 8, 16, 16); if (!Application.RenderWithVisualStyles) { Rectangle rectangle1 = rectangle; rectangle1.Inflate(-4, -4); e.Graphics.DrawRectangle(SystemPens.ControlDark, rectangle1); e.Graphics.DrawLine(SystemPens.ControlText, rectangle1.X + 2, rectangle1.Y + rectangle1.Height / 2, rectangle1.Right - 2, rectangle1.Y + rectangle1.Height / 2); if (!tag.Expanded) { e.Graphics.DrawLine(SystemPens.ControlText, rectangle1.X + rectangle1.Width / 2, rectangle1.Y + 2, rectangle1.X + rectangle1.Width / 2, rectangle1.Bottom - 2); } } else { (new VisualStyleRenderer((tag.Expanded ? VisualStyleElement.TreeView.Glyph.Opened : VisualStyleElement.TreeView.Glyph.Closed))).DrawBackground(e.Graphics, rectangle); } } point.X = point.X + 14; if (base.CheckBoxes) { Size glyphSize = CheckBoxRenderer.GetGlyphSize(e.Graphics, CheckBoxState.UncheckedNormal); this.checkSize = glyphSize.Width; CheckBoxRenderer.DrawCheckBox(e.Graphics, point, (e.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal)); point.X = point.X + this.checkSize; } int x = point.X; int y = point.Y; bounds = e.Bounds; int right = bounds.Right - point.X; bounds = e.Bounds; Rectangle rectangle2 = new Rectangle(x, y, right, bounds.Height); TextRenderer.DrawText(e.Graphics, e.Item.Text, this.Font, rectangle2, e.Item.ForeColor, TextFormatFlags.Default); }
private void collapseNode(ChangeListTree.TreeNode n) { if (n.Expanded) { int visibleChildNodeCount = n.getVisibleChildNodeCount(); n.Expanded = false; int num = this.mappedNodes.IndexOf(n); this.mappedNodes.RemoveRange(num + 1, visibleChildNodeCount); base.VirtualListSize = this.mappedNodes.Count; this.shiftSelection(num + 1, -visibleChildNodeCount); this.itemCache = null; this.Invalidate(); } }
private void expandNode(ChangeListTree.TreeNode n) { if (!n.Expanded && n.HasChildren) { n.Expanded = true; int num = this.mappedNodes.IndexOf(n); int virtualListSize = base.VirtualListSize; n.getVisibleChildNodes(this.mappedNodes, num); base.VirtualListSize = this.mappedNodes.Count; this.shiftSelection(num + 1, base.VirtualListSize - virtualListSize); this.itemCache = null; this.Invalidate(); } }
public GameData.Item GetItem(ChangeListTree.TreeNode node) { if (node == null) { return(null); } if (node is ChangeListTree.RootNode) { return((node as ChangeListTree.RootNode).Item); } if (!(node is ChangeListTree.ChangeData)) { return(null); } return(this.GetItem(node.Parent)); }
private void MouseDownFunc(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } ListViewItem itemAt = base.GetItemAt(e.X, e.Y); if (itemAt != null) { ChangeListTree.TreeNode tag = itemAt.Tag as ChangeListTree.TreeNode; int level = tag.Level * 20; if (e.X < level) { return; } if (base.CheckBoxes && e.X > level + 14 && e.X < level + 14 + this.checkSize) { tag.Checked = !tag.Checked; itemAt.Checked = tag.Checked; if (this.ItemChecked != null) { this.ItemChecked(this, new ChangeListTree.ItemCheckedEventArgs(tag)); } this.Invalidate(); return; } if (e.Clicks > 1 || e.X < level + 14) { if (tag.Expanded) { this.collapseNode(tag); return; } this.expandNode(tag); } } }
public void Remove(ChangeListTree.TreeNode node) { if (!(node is ChangeListTree.RootNode)) { node.Parent.Children.Remove(node); } else { this.Nodes.Remove(node as ChangeListTree.RootNode); } int num = this.mappedNodes.IndexOf(node); if (num >= 0) { int visibleChildNodeCount = node.getVisibleChildNodeCount() + 1; this.mappedNodes.RemoveRange(num, visibleChildNodeCount); base.VirtualListSize = base.VirtualListSize - visibleChildNodeCount; this.shiftSelection(num, -visibleChildNodeCount); this.mSelected = null; this.itemCache = null; this.Invalidate(); } }
public ItemCheckedEventArgs(ChangeListTree.TreeNode node) { this.Node = node; }