Пример #1
0
        private void kbtnRestoreDefault_Click(object sender, EventArgs e)
        {
            HotkeysMapping h = new HotkeysMapping();

            h.InitDefault();

            BuildWrappers(h);
        }
Пример #2
0
        public HotkeysEditorWindow(HotkeysMapping valuePairs)
        {
            InitializeComponent();

            BuildWrappers(valuePairs);

            dgv.DataSource = _wrapper;
        }
Пример #3
0
        /// <summary>
        /// Returns edited hotkey map
        /// </summary>
        /// <returns></returns>
        public HotkeysMapping GetHotkeys()
        {
            var result = new HotkeysMapping();

            foreach (var w in _wrapper)
            {
                result[w.ToKeyData()] = w.Action;
            }

            return(result);
        }
Пример #4
0
        private void BuildWrappers(HotkeysMapping hotkeys)
        {
            var keys = new List <Keys>(hotkeys.Keys);

            keys.Sort(CompereKeys);

            _wrapper.Clear();
            foreach (var k in keys)
            {
                _wrapper.Add(new HotkeyWrapper(k, hotkeys[k]));
            }
        }
Пример #5
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if ((provider != null) && (((IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService))) != null))
            {
                var form = new HotkeysEditorWindow(HotkeysMapping.Parse(value as string));

                if (form.ShowDialog() == DialogResult.OK)
                {
                    value = form.GetHotkeys().ToString();
                }
            }
            return(value);
        }
Пример #6
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);
        }