private void doSave() { if (string.IsNullOrWhiteSpace(CurrentEdit.FileName)) { DialogWin.Show("没有关联布局文件。", DialogWinImage.Warning); return; } if (!CurrentEdit.IsShortcutValid) { DialogWin.Show("无效的快捷键。", DialogWinImage.Warning); return; } if (_dictShortcuts.ContainsKey(CurrentEdit.ShortcutString)) { if (!(bool)DialogWin.Show("已存在相同的快捷键设置,是否要覆盖旧的快捷键?", "覆盖确认", true, DialogWinImage.None)) { return; } } //判断快捷键是否可用。 try { KeyGesture kg = new KeyGesture(CurrentEdit.Key, CurrentEdit.Modifiers); } catch (NotSupportedException) { DialogWin.Show($"不支持当前快捷键组合:{CurrentEdit.ShortcutString}", DialogWinImage.Error); return; } _dictShortcuts[CurrentEdit.ShortcutString] = CurrentEdit; Shortcuts = new ObservableCollection <ShortcutItem>(_dictShortcuts.Values); CurrentEdit = new ShortcutItem(); }
private void doClear() { if ((bool)DialogWin.Show("确定清除所有快捷键?", DialogWinImage.Information)) { _dictShortcuts.Clear(); Shortcuts = new ObservableCollection <ShortcutItem>(_dictShortcuts.Values); } }