Beispiel #1
0
        private void btResore_Click(object sender, EventArgs e)
        {
            HotkeysMapping h = new HotkeysMapping();

            h.InitDefault();
            BuildWrappers(h);
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        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]));
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 public HotkeysEditorForm(HotkeysMapping hotkeys)
 {
     InitializeComponent();
     BuildWrappers(hotkeys);
     dgv.DataSource = wrappers;
 }