Exemple #1
0
        public void AssignPasteKeyCombination(IEnsoService service)
        {
            List <Keys> selectedKeyCombination = KeyCombinationRetriever.Execute(null);

            if (selectedKeyCombination != null)
            {
                Settings.Current.pasteKeyCombination = CraftSynth.BuildingBlocks.UI.WindowsForms.KeysHelper.ToCommaSeparatedCodesString(selectedKeyCombination);
                Settings.Save();

                MessagesHandler.Display(CraftSynth.BuildingBlocks.UI.WindowsForms.KeysHelper.ToUserFriendlyString(selectedKeyCombination) + " is now key combination for paste operation. Please restart Selection Listener.");
            }
        }
Exemple #2
0
        public static List <Keys> Execute(string infoMessage)
        {
            List <Keys> result = null;

            _current = new KeyCombinationRetriever();
            if (infoMessage != null)
            {
                _current.Text = infoMessage;
            }

            DialogResult dialogResult;

            try
            {
                _current._userActivityHook = new CraftSynth.BuildingBlocks.WindowsNT.UserActivityHookNamespace.UserActivityHook(false, true);

                _current._pressedModifierKeys       = new List <Keys>();
                _current._lastKeyCombination        = new List <Keys>();
                _current._lastPressedKey            = Keys.None;
                _current._userActivityHook.KeyDown += new KeyEventHandler(_current.userActivityHook_KeyDown);
                _current._userActivityHook.KeyUp   += new KeyEventHandler(_current._userActivityHook_KeyUp);
                _current.Shown += new EventHandler(_current.OnShown);
                dialogResult    = _current.ShowDialog();
            }
            finally
            {
                _current._userActivityHook.Stop(false, true, true);
            }

            if (dialogResult == DialogResult.OK)
            {
                result = _current._lastKeyCombination;
            }

            return(result);
        }