Пример #1
0
        void Form1_Load(object sender, EventArgs e)
        {
            kbHook = new KeyboardHook();
            kbHook.Start();
            kbHook.OnKeyDownEvent += kbHook_OnKeyDownEvent;

            FileInfo fileInfo = new FileInfo(SettingPath);

            userSetting = UserSetting.Default;

            if (fileInfo.Exists)
            {
                try
                {
                    userSetting.AllSettings = XmlPersister.DeSerializeObject <RemoteDesktopShortCutSetting[]>(SettingPath);
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }

            if (userSetting != null)
            {
                for (int i = 0; i < 5; i++)
                {
                    m_textBoxes[i].Text             = userSetting[i].Title;
                    m_keyboardBindingLabels[i].Text = userSetting[i].ShortcutKey.HasValue ? userSetting[i].ShortcutKey.ToString() : EMPTY_KEYBOARD_SHORTCUT;
                    m_keyboardBindingLabels[i].Tag  = userSetting[i].ShortcutKey;
                }
            }
        }
Пример #2
0
        private void SaveUserSetting()
        {
            for (int i = 0; i < 5; i++)
            {
                userSetting[i] = new RemoteDesktopShortCutSetting()
                {
                    Title       = m_textBoxes[i].Text,
                    ShortcutKey = m_keyboardBindingLabels[i].Tag == null ? (Keys?)null : (Keys)m_keyboardBindingLabels[i].Tag
                };
            }

            XmlPersister.SerializeObject <RemoteDesktopShortCutSetting[]>(userSetting.AllSettings, SettingPath);
        }