private void DisplayList() { this.treeView1.Nodes.Clear(); if (this.value is TagList) { foreach (string s in ((TagList)this.value).Data) { this.treeView1.Nodes.Add(s); } } else { GroupedTagList gtl = (GroupedTagList)this.value; foreach (string g in gtl.GetGroups()) { TreeNode n = new TreeNode(g); n.ImageIndex = IMAGE_INDEX_GROUP; n.SelectedImageIndex = IMAGE_INDEX_GROUP; foreach (string v in gtl.GetValues(g)) { n.Nodes.Add(v); } this.treeView1.Nodes.Add(n); n.Expand(); } } }
private void btnSort_Click(object sender, EventArgs e) { if (this.value is GroupedTagList) { GroupedTagList gtl = (GroupedTagList)this.value; gtl.Sort(); } else { TagList tl = (TagList)this.value; tl.Data.Sort(); } DisplayList(); }
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { string s = this.textBox1.Text; if (this.value is GroupedTagList) { GroupedTagList gtl = (GroupedTagList)this.value; string group = GroupedTagList.DEFAULT_GROUP; TreeNode groupNode = this.treeView1.SelectedNode; if (groupNode != null) { if (this.treeView1.SelectedNode.Parent != null) { groupNode = this.treeView1.SelectedNode.Parent; } group = groupNode.Text; } if (gtl.Add(s, group)) { if (groupNode == null) { this.DisplayList(); } else { TreeNode n = new TreeNode(s); groupNode.Nodes.Add(n); this.treeView1.SelectedNode = n; } } } else { TagList tl = (TagList)this.value; if (tl.Add(s)) { this.treeView1.Nodes.Add(s); } } this.textBox1.Text = ""; } }
private void treeView1_KeyUp(object sender, KeyEventArgs e) { // Entf if (e.KeyValue == 46) { if (this.treeView1.SelectedNode == null) { return; } if (this.value is TagList) { string value = this.treeView1.SelectedNode.Text; TagList tl = (TagList)this.value; tl.Data.Remove(value); } else { GroupedTagList gtl = (GroupedTagList)this.value; if (this.treeView1.SelectedNode.Parent == null) { // group seleced string group = this.treeView1.SelectedNode.Text; gtl.Remove(group); } else { // value under group selected string value = this.treeView1.SelectedNode.Text; string group = this.treeView1.SelectedNode.Parent.Text; gtl.Remove(value, group); } } this.treeView1.SelectedNode.Remove(); } }