예제 #1
0
        public Main()
        {
            // Run in the background
            Visibility = Visibility.Hidden;
            ShowInTaskbar = false;
            SetupTaskTrayIcon();

            // Load the current config
            _config = new PlainTextConfig(true);
            _eventListener = new EventListener(_config);
        }
예제 #2
0
        public EventListener(PlainTextConfig config)
        {
            // Read in the config
            _config = config;

            // Hardcode the keys
            _key = Key.V;
            _keyMod1 = "WIN";
            _keyMod2 = "";
            _keyMod3 = "";

            // Add key to listen for
            _gkh.HookedKeys.Add(_key);

            // Listen for keyboard events
            _gkh.KeyDown += new KeyEventHandler(gkh_KeyDown);
        }
예제 #3
0
        public OptionsWindow(EventListener eventListener, PlainTextConfig config)
        {
            InitializeComponent();
            ShowInTaskbar = false;

            _eventListener = eventListener;
            _config = config;

            if (_config.RunAtStatup)
            {
                RunAtStartupCheckbox.IsChecked = true;
            }

            if (_config.PlaySound)
            {
                PlaySoundCheckbox.IsChecked = true;
            }
        }
예제 #4
0
        public void UpdateFromNewConfig(PlainTextConfig newconfig)
        {
            if (RunAtStatup != newconfig.RunAtStatup)
            {
                RunAtStatup = newconfig.RunAtStatup;

                if (newconfig.RunAtStatup)
                {
                    RegistryKey key = Registry.CurrentUser.OpenSubKey(RunAtStatupKeyPath, true);
                    key.SetValue("PlainTexter", Assembly.GetExecutingAssembly().Location, RegistryValueKind.String);
                }
                else
                {
                    RegistryKey key = Registry.CurrentUser.OpenSubKey(RunAtStatupKeyPath, true);
                    key.DeleteValue("PlainTexter");
                }
            }

            if (PlaySound != newconfig.PlaySound)
            {
                PlaySound = newconfig.PlaySound;

                EnsureAppKeyExists();

                if (newconfig.PlaySound)
                {
                    RegistryKey key = Registry.CurrentUser.OpenSubKey(AppKeyPath, true);
                    key.SetValue("PlaySound", "true", RegistryValueKind.String);
                }
                else
                {
                    RegistryKey key = Registry.CurrentUser.OpenSubKey(AppKeyPath, true);
                    key.SetValue("PlaySound", "false", RegistryValueKind.String);
                }
            }
        }
예제 #5
0
        private void SaveSettingshButton_Click(object sender, RoutedEventArgs e)
        {
            PlainTextConfig newconfig = new PlainTextConfig();

            if ((bool)RunAtStartupCheckbox.IsChecked)
            {
                newconfig.RunAtStatup = true;
            }
            else
            {
                newconfig.RunAtStatup = false;
            }

            if ((bool)PlaySoundCheckbox.IsChecked)
            {
                newconfig.PlaySound = true;
            }
            else
            {
                newconfig.PlaySound = false;
            }

            _config.UpdateFromNewConfig(newconfig);
        }