-
Notifications
You must be signed in to change notification settings - Fork 0
/
Selector.cs
57 lines (48 loc) · 1.51 KB
/
Selector.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ED7Editor
{
public partial class Selector : Form
{
public Selector(EditorBase editor)
{
this.editor = editor;
InitializeComponent();
foreach (var i in editor.GetSelector())
listBox1.Items.Add(i);
}
EditorBase editor;
private void Selector_Load(object sender, EventArgs e)
{
}
public int Result { get; private set; }
int? initValue = null;
public void SetSelect(int id)
{
initValue = id;
for (int i = 0; i < listBox1.Items.Count; i++)
if ((listBox1.Items[i] as SelectorItem).ID == id)
listBox1.SelectedIndex = i;
}
private void btnOK_Click(object sender, EventArgs e)
{
if (Result == initValue) DialogResult = DialogResult.Cancel;
DialogResult = DialogResult.OK;
}
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
var item = listBox1.SelectedItem as SelectorItem;
textBox1.Text = item.Description;
Result = item.ID;
}
}
}