private void btResore_Click(object sender, EventArgs e) { HotkeysMapping h = new HotkeysMapping(); h.InitDefault(); BuildWrappers(h); }
/// <summary> /// Returns edited hotkey map /// </summary> /// <returns></returns> public HotkeysMapping GetHotkeys() { var result = new HotkeysMapping(); foreach (var w in wrappers) { result[w.ToKeyData()] = w.Action; } return(result); }
private void BuildWrappers(HotkeysMapping hotkeys) { var keys = new List <Keys>(hotkeys.Keys); keys.Sort(CompereKeys); wrappers.Clear(); foreach (var k in keys) { wrappers.Add(new HotkeyWrapper(k, hotkeys[k])); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if ((provider != null) && (((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService))) != null)) { var form = new HotkeysEditorForm(HotkeysMapping.Parse(value as string)); if (form.ShowDialog() == DialogResult.OK) { value = form.GetHotkeys().ToString(); } } return(value); }
public static HotkeysMapping Parse(string s) { var result = new HotkeysMapping(); result.Clear(); var cult = Thread.CurrentThread.CurrentUICulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; var kc = new KeysConverter(); foreach (var p in s.Split(',')) { var pp = p.Split('='); var k = (Keys)kc.ConvertFromString(pp[0].Trim()); var a = (FCTBAction)Enum.Parse(typeof(FCTBAction), pp[1].Trim()); result[k] = a; } Thread.CurrentThread.CurrentUICulture = cult; return(result); }
/// <summary> /// /// </summary> /// <param name="hotkeys"></param> public HotkeysEditorForm(HotkeysMapping hotkeys) { InitializeComponent(); BuildWrappers(hotkeys); dgv.DataSource = wrappers; }