diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-02-09 08:24:36 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-02-09 08:24:36 +0300 |
commit | 7086b371b2a2e55c3ab0b1861929acfb23ad0bed (patch) | |
tree | 33d98ca43ed679d23c495fc170699eb46652ade5 /SelectIconForm.cs | |
parent | 7bd3f9ccccbd52496c063b03564c2d5ee8458454 (diff) |
Should work now. Need to test, test, test.
Diffstat (limited to 'SelectIconForm.cs')
-rw-r--r-- | SelectIconForm.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/SelectIconForm.cs b/SelectIconForm.cs new file mode 100644 index 00000000..3f6ab0b2 --- /dev/null +++ b/SelectIconForm.cs @@ -0,0 +1,54 @@ +using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace com.clusterrr.hakchi_gui
+{
+ public partial class SelectIconForm : Form
+ {
+ public SelectIconForm(string selected = null)
+ {
+ InitializeComponent();
+ listBox.Items.Clear();
+ var files = Directory.GetFiles(NesMenuFolder.FolderImagesDirectory, "*.png", SearchOption.AllDirectories);
+ listBox.Items.AddRange((from f in files select Path.GetFileNameWithoutExtension(f)).ToArray());
+
+ if (selected != null)
+ for (int i = 0; i < listBox.Items.Count; i++)
+ if (listBox.Items[i].ToString() == selected)
+ {
+ listBox.SelectedIndex = i;
+ break;
+ }
+ }
+
+ private void listBox_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ if (listBox.SelectedItems.Count > 0)
+ {
+ buttonOk.Enabled = true;
+ pictureBoxArt.Image = Image.FromFile(Path.Combine(NesMenuFolder.FolderImagesDirectory, listBox.SelectedItems[0] + ".png"));
+ }
+ else
+ {
+ buttonOk.Enabled = false;
+ pictureBoxArt.Image = null;
+ }
+ }
+
+ private void listBox_DoubleClick(object sender, EventArgs e)
+ {
+ if (listBox.SelectedItem != null)
+ {
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ }
+ }
+}
|