コード例 #1
0
        private void btResore_Click(object sender, EventArgs e)
        {
            HotkeysMapping h = new HotkeysMapping();

            h.InitDefault();
            BuildWrappers(h);
        }
コード例 #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);
        }
コード例 #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]));
            }
        }
コード例 #4
0
ファイル: Hotkeys.cs プロジェクト: the-alex-mark/proglib-cs
        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);
        }
コード例 #5
0
ファイル: Hotkeys.cs プロジェクト: the-alex-mark/proglib-cs
        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);
        }
コード例 #6
0
 public HotkeysEditorForm(HotkeysMapping hotkeys)
 {
     InitializeComponent();
     BuildWrappers(hotkeys);
     dgv.DataSource = wrappers;
 }