-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormIcon.cs
54 lines (51 loc) · 1.95 KB
/
FormIcon.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
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using static Micro.Menu.Core;
namespace Micro.Menu {
public partial class FormIcon : Form {
public FormIcon() {
InitializeComponent();
view.SmallImageList = new ImageList() { ColorDepth = ColorDepth.Depth32Bit };
view.LargeImageList = new ImageList() { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(32, 32) };
}
void switchSmallLarge(object sender, EventArgs e)
=> view.View = larger.Checked ? View.LargeIcon : View.SmallIcon;
void txtPathKey(object sender, KeyEventArgs e) {
if (e.KeyCode == Keys.Enter)
refresh(sender, e);
}
void txtPathSelect(object sender, EventArgs e) {
if (txtPath.SelectedIndex >= 0)
refresh(sender, e);
}
void viewSelect(object sender, EventArgs e) {
if (view.SelectedItems.Count > 0)
txtResult.Text = $"{txtPath.Text},{view.SelectedItems[0].Text}";
}
void refresh(object sender, EventArgs e) {
Cursor = Cursors.WaitCursor;
view.Clear();
view.SmallImageList.Images.Clear();
view.LargeImageList.Images.Clear();
if (File.Exists(txtPath.Text)) {
int max = -1;
try {
for (int i = 0; true; i++) {
max = i;
var s = i + "";
var ic = ExtractIcons(txtPath.Text, i);
view.SmallImageList.Images.Add(s, ic[0]);
view.LargeImageList.Images.Add(s, ic[1]);
}
} catch { }
for (int i = 0; i < max; i++) {
var s = i + "";
view.Items.Add(new ListViewItem(s, s));
}
}
Cursor = Cursors.Default;
}
}
}