/// <summary> /// Handles the Click event of the btResore control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void btResore_Click(object sender, EventArgs e) { HotkeysMapping h = new HotkeysMapping(); h.InitDefault(); BuildWrappers(h); }
/// <summary> /// Returns edited hotkey map /// </summary> /// <returns>HotkeysMapping.</returns> public HotkeysMapping GetHotkeys() { var result = new HotkeysMapping(); foreach (var w in wrappers) { result[w.ToKeyData()] = w.Action; } return(result); }
/// <summary> /// Builds the wrappers. /// </summary> /// <param name="hotkeys">The hotkeys.</param> 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])); } }
/// <summary> /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle" /> method. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that can be used to gain additional context information.</param> /// <param name="provider">An <see cref="T:System.IServiceProvider" /> that this editor can use to obtain services.</param> /// <param name="value">The object to edit.</param> /// <returns>The new value of the object. If the value of the object has not changed, this should return the same object it was passed.</returns> 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); }
/// <summary> /// Parses the specified s. /// </summary> /// <param name="s">The s.</param> /// <returns>HotkeysMapping.</returns> 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> /// Initializes a new instance of the <see cref="HotkeysEditorForm"/> class. /// </summary> /// <param name="hotkeys">The hotkeys.</param> public HotkeysEditorForm(HotkeysMapping hotkeys) { InitializeComponent(); BuildWrappers(hotkeys); dgv.DataSource = wrappers; }