Exemplo n.º 1
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 convertFromString = kc.ConvertFromString(pp[0].Trim());
                if (convertFromString == null)
                {
                    continue;
                }
                var k = (Keys)convertFromString;
                var a = (FctbAction)Enum.Parse(typeof(FctbAction), pp[1].Trim());
                result[k] = a;
            }
            Thread.CurrentThread.CurrentUICulture = cult;
            return(result);
        }
Exemplo n.º 2
0
        /* Handlers */
        private void ButtonClickHandler(object sender, EventArgs e)
        {
            var btn = (Button)sender;

            if (btn == null)
            {
                return;
            }
            switch (btn.Text.ToUpper())
            {
            case "ADD":
                _wrappers.Add(new HotkeyWrapper(Keys.None, FctbAction.None));
                break;

            case "REMOVE":
                for (int i = _dgv.RowCount - 1; i >= 0; i--)
                {
                    if (_dgv.Rows[i].Selected)
                    {
                        _dgv.Rows.RemoveAt(i);
                    }
                }
                break;

            case "RESTORE DEFAULT":
                var h = new HotkeysMapping();
                h.InitDefault();
                BuildWrappers(h);
                break;
            }
        }
Exemplo n.º 3
0
        public HotkeysMapping GetHotkeys()
        {
            var result = new HotkeysMapping();

            foreach (var w in _wrappers)
            {
                result[w.ToKeyData()] = w.Action;
            }
            return(result);
        }
Exemplo n.º 4
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (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 ?? string.Empty);
 }