Skip to content

Commit fd5bd9b

Browse files
author
tznind
committed
Add reset keymap button
1 parent adc69c8 commit fd5bd9b

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

src/UI/Windows/KeyBindingsUI.Designer.cs

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/UI/Windows/KeyBindingsUI.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ public KeyBindingsUI(KeyMap keyMap) {
2525
this.keyMap = keyMap;
2626
InitializeComponent();
2727

28-
_props = typeof(KeyMap).GetProperties().Where(p=>p.PropertyType == typeof(string)).ToArray();
29-
28+
_props = typeof(KeyMap).GetProperties()
29+
.Where(p=>p.PropertyType == typeof(string))
30+
.OrderBy(p=>p.Name)
31+
.ToArray();
32+
3033
tableView.Table = new EnumerableTableSource<PropertyInfo>(_props,
3134
new Dictionary<string, Func<PropertyInfo, object>>()
3235
{
@@ -58,6 +61,16 @@ public KeyBindingsUI(KeyMap keyMap) {
5861
prop.SetValue(this.keyMap,k.ToString());
5962
this.SetNeedsDraw();
6063
};
64+
btnReset.Accepting += (s, e) =>
65+
{
66+
var defaultMap = new KeyMap();
67+
foreach (var p in _props)
68+
{
69+
var def = p.GetValue(defaultMap);
70+
p.SetValue(this.keyMap, def);
71+
this.SetNeedsDraw();
72+
}
73+
};
6174

6275
btnSave.Accepting += (s, e) =>
6376
{

0 commit comments

Comments
 (0)