-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKeybindsForm.cs
More file actions
80 lines (75 loc) · 2.35 KB
/
Copy pathKeybindsForm.cs
File metadata and controls
80 lines (75 loc) · 2.35 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MarsClientLauncher
{
public partial class KeybindsForm : Form
{
public KeybindsForm()
{
InitializeComponent();
UpdateBox();
}
private void UpdateBox()
{
picker.Items.Clear();
foreach (var kb in Data.keybinds.keybinds)
picker.Items.Add(kb);
}
private void confirm_Click(object sender, EventArgs e)
{
Close();
}
private void edit_Click(object sender, EventArgs e)
{
Keybind toEdit = (Keybind)picker.SelectedItem;
using (SingleKeybindEditor edit = new SingleKeybindEditor(toEdit))
{
edit.ShowDialog();
ApplyKeybindAfterEditing(edit, true, toEdit);
edit.Enabled = false;
delete.Enabled = false;
}
}
private void add_Click(object sender, EventArgs e)
{
using (SingleKeybindEditor edit = new SingleKeybindEditor())
{
edit.ShowDialog();
ApplyKeybindAfterEditing(edit, false, null);
}
}
private void picker_SelectedIndexChanged(object sender, EventArgs e)
{
edit.Enabled = true;
delete.Enabled = true;
}
private void ApplyKeybindAfterEditing(SingleKeybindEditor editor, bool edited, Keybind toReplace)
{
if (!editor.confirmed) return;
Keybind kb = editor.keybind;
if(edited)
Data.keybinds.ReplaceKeybind(toReplace, kb);
else
Data.keybinds.AddKeybind(kb);
UpdateBox();
}
private void delete_Click(object sender, EventArgs e)
{
Keybind toDelete = (Keybind)picker.SelectedItem;
Data.keybinds.DeleteKeybind(toDelete);
if(Data.keybinds.keybinds.Count == 0)
{
edit.Enabled = false;
delete.Enabled = false;
}
UpdateBox();
}
}
}