-
Notifications
You must be signed in to change notification settings - Fork 15
/
FormItemFilter.cs
138 lines (130 loc) · 5.29 KB
/
FormItemFilter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Rawr
{
public partial class FormItemFilter : Form
{
public FormItemFilter()
{
InitializeComponent();
comboBoxMinItemQuality.DataSource = Enum.GetValues(typeof(ItemQuality));
comboBoxMaxItemQuality.DataSource = Enum.GetValues(typeof(ItemQuality));
}
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 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 buttonUp_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;
}
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;
}
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 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;
}
}
}
}
}