private void buttonDelete_Click(object sender, EventArgs e) { TreeNode node = itemFilterTreeView.SelectedNode; ItemFilterRegex regex = (ItemFilterRegex)node.Tag; int index = node.Index; TreeNode parent = node.Parent; if (parent == null) { itemFilterTreeView.Nodes.RemoveAt(index); ItemFilter.FilterList.RemoveAt(index); } else { parent.Nodes.RemoveAt(index); ItemFilterRegex parentRegex = (ItemFilterRegex)parent.Tag; parentRegex.RegexList.RemoveAt(index); } itemFilterTreeView.SelectedNode = null; bindingSourceItemFilter.DataSource = typeof(Rawr.ItemFilterRegex); buttonDelete.Enabled = false; buttonNewSubfilter.Enabled = false; buttonUp.Enabled = false; buttonDown.Enabled = false; }
private void buttonNewFilter_Click(object sender, EventArgs e) { ItemFilterRegex regex = new ItemFilterRegex(); TreeNode node = itemFilterTreeView.GetNode(regex); ItemFilter.FilterList.Add(regex); itemFilterTreeView.Nodes.Add(node); itemFilterTreeView.SelectedNode = node; }
private void buttonNewSubfilter_Click(object sender, EventArgs e) { TreeNode parent = itemFilterTreeView.SelectedNode; ItemFilterRegex parentRegex = (ItemFilterRegex)parent.Tag; ItemFilterRegex regex = new ItemFilterRegex(); TreeNode node = itemFilterTreeView.GetNode(regex); parentRegex.RegexList.Add(regex); parent.Nodes.Add(node); itemFilterTreeView.SelectedNode = node; }
private void itemFilterTreeView_AfterSelect(object sender, TreeViewEventArgs e) { buttonDelete.Enabled = itemFilterTreeView.SelectedNode != null; buttonNewSubfilter.Enabled = itemFilterTreeView.SelectedNode != null; buttonUp.Enabled = e.Node != null && e.Node.PrevNode != null; buttonDown.Enabled = e.Node != null && e.Node.NextNode != null; checkBoxAdditiveFilter.Enabled = (e.Node.Parent == null); ItemFilterRegex regex = (ItemFilterRegex)e.Node.Tag; bindingSourceItemFilter.DataSource = regex; }
private void bindingSourceItemFilter_CurrentItemChanged(object sender, EventArgs e) { TreeNode node = itemFilterTreeView.SelectedNode; if (node != null) { ItemFilterRegex regex = (ItemFilterRegex)bindingSourceItemFilter.Current; // sanity check if (regex == node.Tag && node.Text != regex.Name) { node.Text = regex.Name; } } }
private void SetChildNodes(TreeNode node, bool value) { ItemFilterRegex regex = (ItemFilterRegex)node.Tag; node.Checked = value; if (regex != null) { regex.Enabled = value; regex.OtherRegexEnabled = value; } foreach (TreeNode child in node.Nodes) { SetChildNodes(child, value); } }
private void AutoDisable(TreeNode node) { if (node != null) { foreach (TreeNode child in node.Nodes) { if (child.Checked) { return; } } node.Checked = false; ItemFilterRegex regex = (ItemFilterRegex)node.Tag; regex.Enabled = false; AutoDisable(node.Parent); } }
public TreeNode GetNode(ItemFilterRegex regex) { TreeNode node = new TreeNode(regex.Name); node.Checked = regex.Enabled; node.Tag = regex; if (regex.RegexList.Count > 0) { foreach (ItemFilterRegex childRegex in regex.RegexList) { node.Nodes.Add(GetNode(childRegex)); } if (!EditMode) { TreeNode otherNode = new TreeNode("Other"); otherNode.Checked = regex.OtherRegexEnabled; node.Nodes.Add(otherNode); } } return(node); }
private void buttonDown_Click(object sender, EventArgs e) { TreeNode node = itemFilterTreeView.SelectedNode; ItemFilterRegex regex = (ItemFilterRegex)node.Tag; int index = node.Index; TreeNode parent = node.Parent; if (parent == null) { itemFilterTreeView.Nodes.RemoveAt(index); itemFilterTreeView.Nodes.Insert(index + 1, node); ItemFilter.FilterList.RemoveAt(index); ItemFilter.FilterList.Insert(index + 1, regex); } else { parent.Nodes.RemoveAt(index); parent.Nodes.Insert(index + 1, node); ItemFilterRegex parentRegex = (ItemFilterRegex)parent.Tag; parentRegex.RegexList.RemoveAt(index); parentRegex.RegexList.Insert(index + 1, regex); } itemFilterTreeView.SelectedNode = node; }
public ItemFilterOther(ItemFilterRegex parent) : base() { this.Parent = parent; Name = "Other"; }
protected override void OnAfterCheck(TreeViewEventArgs e) { base.OnAfterCheck(e); if (e.Action != TreeViewAction.Unknown) { // user changed checked state TreeNode node = e.Node; ItemFilterRegex regex = (ItemFilterRegex)node.Tag; if (regex != null) { // enabled on a regex changed if (node.Checked) { SetChildNodes(node, true); // it got checked, make sure parents are checked also while (regex != null) { node.Checked = true; regex.Enabled = true; node = node.Parent; if (node != null) { regex = (ItemFilterRegex)node.Tag; } else { regex = null; } } } else { // it got unchecked, make sure all child nodes are unchecked SetChildNodes(node, false); AutoDisable(node.Parent); } } else { // enabled for other got changed, there are no child nodes if (node.Parent == null) { // this is the global other ItemFilter.OtherEnabled = node.Checked; } else { // other below a regex if (node.Checked) { // make sure all parents are checked node = node.Parent; regex = (ItemFilterRegex)node.Tag; regex.OtherRegexEnabled = true; while (regex != null && !regex.Enabled) { node.Checked = true; regex.Enabled = true; node = node.Parent; if (node != null) { regex = (ItemFilterRegex)node.Tag; } else { regex = null; } } } else { // just disable it node = node.Parent; regex = (ItemFilterRegex)node.Tag; regex.OtherRegexEnabled = false; AutoDisable(node.Parent); } } } // trigger item update FormMain.Instance.Cursor = Cursors.WaitCursor; ItemCache.OnItemsChanged(); FormMain.Instance.Cursor = Cursors.Default; } }