Ejemplo n.º 1
0
        private void OnConfigureSave(Object s, RoutedEventArgs e)
        {
            var key = (Key)Enum.Parse(typeof(Key), Key.SelectedValue.ToString());

            var lowerCase = LowerCaseLetters.Text.ToCharArray();
            var upperCase = UpperCaseLetters.Text.ToCharArray();

            if (lowerCase.Length != upperCase.Length)
            {
                _Error("Lower and upper case should contain an equal amount of symbols.");
                return;
            }

            LetterMappings.UpdateKey(key, lowerCase, upperCase);
            _Ok("Changes for " + key + " saved!");
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            var args = Environment.GetCommandLineArgs();

            var showWindow = false;

            // Parse command line args.
            foreach (var arg in args.Skip(1))
            {
                switch (arg)
                {
                case "--window":
                    showWindow = true;
                    break;

                default:
                    Console.Error.WriteLine("Unknown parameter: " + arg);
                    Environment.Exit(1); return;
                }
            }

            if (!showWindow)
            {
                this.Visibility    = System.Windows.Visibility.Hidden;
                this.ShowInTaskbar = false;
            }

            InitializeComponent();

            // Hook keyboard events.
            Handler.ValidateCAPSLOCKState();

            LetterMappings.InitializeWindowsAndBindings();

            // Register keys.
            foreach (var letter in LetterMappings.KeysToSymbols.Keys)
            {
                LowLevelListener.HookedKeys.Add(letter);
            }

            // Hook left, right arrow keys to move the selector.
            LowLevelListener.HookedKeys.Add(Key.Left);
            LowLevelListener.HookedKeys.Add(Key.Right);

            // Hook our "hot key".
            LowLevelListener.HookedKeys.Add(Key.CapsLock);
            LowLevelListener.HookedKeys.Add(Key.LeftShift);
            LowLevelListener.HookedKeys.Add(Key.RightShift);
            LowLevelListener.Register();

            LowLevelListener.KeyDown += new LowLevelListener.KeyHookEventHandler(e => Handler.HandleKeyPress(true, e));
            LowLevelListener.KeyUp   += new LowLevelListener.KeyHookEventHandler(e => Handler.HandleKeyPress(false, e));

            try
            {
                // Keep the app responsive even if system is busy.
                // I found that AboveNormal does not keep the app responsive enough if the system is particularly busy,
                // although even at High there can be a noticeable (but generally acceptable) lag for activation.
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
            }
            catch { }
        }
Ejemplo n.º 3
0
 private void OnDelConfigureClick(Object sender, RoutedEventArgs e)
 {
     LetterMappings.DeleteBindings();
 }