This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContentSelectionDialog.cs
96 lines (76 loc) · 2.41 KB
/
ContentSelectionDialog.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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace LEdit
{
public partial class ContentSelectionDialog : Form
{
#region STATIC
public static Dictionary<Content.ContentType, ContentSelectionDialog> Map =
new Dictionary<Content.ContentType, ContentSelectionDialog>();
public static void StaticUnload()
{
foreach (KeyValuePair<Content.ContentType, ContentSelectionDialog> x in Map)
x.Value.Dispose();
Map.Clear();
}
#endregion
public int SelectedID = -1;
int w, h;
public ContentSelectionDialog(string Title)
{
InitializeComponent();
Text = Title;
w = Width;
h = Height;
}
public void AddItem(Content item)
{
ListViewItem listItem = new ListViewItem(item.GetName());
listItem.Tag = item.ID;
listItem.ToolTipText =
"ID: " + Content.FormatID(item.ID) + Environment.NewLine +
"Name: " + item.GetName();
Bitmap icon = item.GetIcon();
if (icon != null)
{
listItem.ImageIndex = iconList.Images.Count;
iconList.Images.Add(icon);
}
listView.Items.Add(listItem);
}
private void ContentSelectionDialog_Load(object sender, EventArgs e)
{
listView.SelectedItems.Clear();
}
private void button2_Click(object sender, EventArgs e)
{
if (listView.SelectedItems.Count > 0)
{
SelectedID = (int)listView.SelectedItems[0].Tag;
}
else
{
SelectedID = -1;
}
}
private void listView_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void listView_DoubleClick(object sender, EventArgs e)
{
if(listView.SelectedItems.Count > 0)
button2.PerformClick();
}
private void listView_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter && listView.SelectedItems.Count > 0)
button2.PerformClick();
}
}
}