public NavigationPresenter(INavigationView view,
            ISettingsSerializer settingsSerializer,
            IKeyboardListener keyboardListener,
            IMatchModelMapper matchModelMapper,
            IPresentationService presentationService,
            INavigationServiceBuilder navigationServiceBuilder)
        {
            _view = view;
            _settingsSerializer = settingsSerializer;
            _keyboardListener = keyboardListener;
            _matchModelMapper = matchModelMapper;
            _navigationServiceBuilder = navigationServiceBuilder;
            _presentationService = presentationService;

            Settings settings = _settingsSerializer.Deserialize();

            _keyboardListener.KeyCombinationPressed += GlobalKeyCombinationPressed;
            _keyboardListener.StartListening(settings.GlobalKeyCombination);

            _view.CurrentSettings = settings;
            _view.ShowMatches(new List<MatchModel> {new MatchModel(_matchModelMapper, Resources.InitialMatchesMessage)});
            _view.ShowInitializingScreen = true;

            //Initialize navigation service asynchronously, as it may require a long operation (file system parsing).
            //Clone settings to avoid any coupling
            Settings settingsCopy = settings.Clone() as Settings;
            InitializeDelegate initialize = Initialize;
            initialize.BeginInvoke(settingsCopy, EndInitialize, initialize);
        }
Example #2
0
        public ConfigurationViewModel(IMouseListener mouseListener, IKeyboardListener keyboardListener)
        {
            this.ScreenElements = MacroData.Current.ScreenElements;
            this._mouseListener = mouseListener;
            this._keyboardListener = keyboardListener;

            _mouseListener.MouseMove += OnMouseMove;
            _keyboardListener.KeyUp += OnKeyUp;

            this.SelectedScreenElement = this.ScreenElements.FirstOrDefault();

            this.HelpInfo = new StringBuilder()
                .AppendLine("Keyboard Shortcuts")
                .AppendLine("F1: \tSelect previous screen element")
                .AppendLine("F2: \tAssign current mouse position to selected screen element")
                .AppendLine("F3: \tSelect next screen element")
                .AppendLine()
                .AppendLine("Screen Elements")
                .AppendLine("Jet Bay 1 - 8: \t\tpositions to select each jet bay")
                .AppendLine("Hero Slot 1 - 5: \t\tpositions to select heroes in the Deploy screen")
                .AppendLine("Prev/Next Hero Page: \tthe left/right arrows on the Deploy screen")
                .AppendLine("Confirm Button: \t\tthe big Confirm button on the Deploy screen")
                .AppendLine("Collect All: \t\tthe Collect All button to collect when deploys are over.\r\nNote: this is assumed to become visible by clicking Jet Bay 1")
                .ToString();
        }
Example #3
0
        private MessagePreviewResult NotifyListener(IKeyboardListener listener, Control target, Message msg)
        {
            MessagePreviewResult result = MessagePreviewResult.NotProcessed;
            Keys keyData;

            switch (msg.Msg)
            {
            case NativeMethods.WM_KEYDOWN:
            case NativeMethods.WM_SYSKEYDOWN:
                keyData = ((Keys)((int)((long)msg.WParam))) | Control.ModifierKeys;
                result  = listener.OnPreviewKeyDown(target, new KeyEventArgs(keyData));
                break;

            case NativeMethods.WM_CHAR:
            case NativeMethods.WM_SYSCHAR:
                KeyPressEventArgs e = new KeyPressEventArgs((char)((ushort)((long)msg.WParam)));
                result = listener.OnPreviewKeyPress(target, e);
                break;

            case NativeMethods.WM_KEYUP:
            case NativeMethods.WM_SYSKEYUP:
                keyData = ((Keys)((int)((long)msg.WParam))) | Control.ModifierKeys;
                result  = listener.OnPreviewKeyUp(target, new KeyEventArgs(keyData));
                break;
            }

            return(result);
        }
Example #4
0
        /// <summary>
        /// Adds the given tool.
        /// </summary>
        /// <param name="tool">The tool.</param>
        public void AddTool(ITool tool)
        {
            tool.Controller = this;
            //add the tool to the collection even if it doesn't attach to anything (yet)
            registeredTools.Add(tool);

            IMouseListener mouseTool = null;

            if ((mouseTool = tool as IMouseListener) != null)
            {
                mouseListeners.Add(mouseTool);
            }

            IKeyboardListener keyboardTool = null;

            if ((keyboardTool = tool as IKeyboardListener) != null)
            {
                keyboardListeners.Add(keyboardTool);
            }

            IDragDropListener dragdropTool = null;

            if ((dragdropTool = tool as IDragDropListener) != null)
            {
                dragdropListeners.Add(dragdropTool);
            }
        }
Example #5
0
        public void RemoveTool(ITool tool)
        {
            if (tool == null)
            {
                return;
            }
            tool.Controller = null;
            registeredTools.Remove(tool);

            IMouseListener mouseTool = tool as IMouseListener;

            if (mouseTool != null)
            {
                mouseListeners.Remove(mouseTool);
            }
            IKeyboardListener keyboardTool = tool as IKeyboardListener;

            if (keyboardTool != null)
            {
                keyboardListeners.Remove(keyboardTool);
            }
            IDragDropListener dragdropTool = tool as IDragDropListener;

            if (dragdropTool != null)
            {
                dragdropListeners.Remove(dragdropTool);
            }

            tool.OnToolActivate   -= new EventHandler <ToolEventArgs>(AddedTool_OnToolActivate);
            tool.OnToolDeactivate -= new EventHandler <ToolEventArgs>(AddedTool_OnToolDeactivate);
        }
        public NavigationPresenter(INavigationView view,
                                   ISettingsSerializer settingsSerializer,
                                   IKeyboardListener keyboardListener,
                                   IMatchModelMapper matchModelMapper,
                                   IPresentationService presentationService,
                                   INavigationServiceBuilder navigationServiceBuilder)
        {
            _view = view;
            _settingsSerializer       = settingsSerializer;
            _keyboardListener         = keyboardListener;
            _matchModelMapper         = matchModelMapper;
            _navigationServiceBuilder = navigationServiceBuilder;
            _presentationService      = presentationService;

            Settings settings = _settingsSerializer.Deserialize();

            _keyboardListener.KeyCombinationPressed += GlobalKeyCombinationPressed;
            _keyboardListener.StartListening(settings.GlobalKeyCombination);

            _view.CurrentSettings = settings;
            _view.ShowMatches(new List <MatchModel> {
                new MatchModel(_matchModelMapper, Resources.InitialMatchesMessage)
            });
            _view.ShowInitializingScreen = true;

            //Initialize navigation service asynchronously, as it may require a long operation (file system parsing).
            //Clone settings to avoid any coupling
            Settings           settingsCopy = settings.Clone() as Settings;
            InitializeDelegate initialize   = Initialize;

            initialize.BeginInvoke(settingsCopy, EndInitialize, initialize);
        }
Example #7
0
        private MessagePreviewResult NotifyListener(
            IKeyboardListener listener,
            Control target,
            Message msg)
        {
            MessagePreviewResult messagePreviewResult = MessagePreviewResult.NotProcessed;

            switch (msg.Msg)
            {
            case 256:
            case 260:
                Keys keyData1 = (Keys)(long)msg.WParam | Control.ModifierKeys;
                messagePreviewResult = listener.OnPreviewKeyDown(target, new KeyEventArgs(keyData1));
                break;

            case 257:
            case 261:
                Keys keyData2 = (Keys)(long)msg.WParam | Control.ModifierKeys;
                messagePreviewResult = listener.OnPreviewKeyUp(target, new KeyEventArgs(keyData2));
                break;

            case 258:
            case 262:
                KeyPressEventArgs e = new KeyPressEventArgs((char)(long)msg.WParam);
                messagePreviewResult = listener.OnPreviewKeyPress(target, e);
                break;
            }
            return(messagePreviewResult);
        }
Example #8
0
        /// <summary>
        /// Sets the element that will receive key events
        /// </summary>
        /// <param name="element">element.</param>
        public void SetKeyboardFocus(IKeyboardListener element)
        {
            // clean up if we are removing focus
            if (element == null)
            {
                _lastPressedKeys = _emptyKeys;
                ClearKeyRepeatTimer();
            }

            if (_keyboardFocusElement == element)
            {
                return;
            }

            var oldKeyboardFocus = _keyboardFocusElement;

            if (oldKeyboardFocus != null)
            {
                oldKeyboardFocus.LostFocus();
            }

            _keyboardFocusElement = element;
            if (_keyboardFocusElement != null)
            {
                _keyboardFocusElement.GainedFocus();
            }
        }
Example #9
0
 public void AddListener(IKeyboardListener listener)
 {
     if (!this.ContainsListener(listener))
     {
         this.listeners.Add(listener);
         this.UpdateHook();
     }
 }
Example #10
0
        public MainVM(IKeyboardListener kbListener, ITextFetcher textFetcher, IDataServiceFacade dataServiceFacade)
        {
            _kbListener        = kbListener;
            _textFetcher       = textFetcher;
            _dataServiceFacade = dataServiceFacade;

            _kbListener.MagicCombinationPressed += _kbListener_MagicCombinationPressed;
        }
Example #11
0
        public void RemoveListener(IKeyboardListener listener)
        {
            int index = this.listeners.IndexOf(listener);

            if (index >= 0)
            {
                this.listeners.RemoveAt(index);
                this.UpdateHook();
            }
        }
Example #12
0
 protected BaseShotter()
 {
     try {
         _keyboard = KeyboardListenerFactory.Get();
         _keyboard.WatchFor(Keys.Escape);
         _keyboard.KeyUp += OnKeyUp;
     } catch (Exception e) {
         AcToolsLogging.Write("Can’t set listener: " + e);
     }
 }
Example #13
0
 public BMBApplication(
     IProcessListener processListener,
     IProcessHandler processHandler,
     IKeyboardListener keyboardListener,
     IKeyboardHandler keyboardHandler)
 {
     this.processListener  = processListener;
     this.processHandler   = processHandler;
     this.keyboardListener = keyboardListener;
     this.keyboardHandler  = keyboardHandler;
 }
Example #14
0
 public MemoryListener()
 {
     try {
         _keyboard = KeyboardListenerFactory.Get();
         _keyboard.WatchFor(Keys.Escape);
         _keyboard.PreviewKeyDown += OnKeyDown;
         _keyboard.PreviewKeyUp   += OnKeyUp;
     } catch (Exception e) {
         Logging.Error(e);
     }
 }
Example #15
0
        public HUDKeyboard ShowKeyboard(IKeyboardListener reciever)
        {
            if (_keyboard != null)
            {
                HideKeyboard();
            }

            _keyboard = new HUDKeyboard(reciever);

            AddModal(_keyboard, true);

            return(_keyboard);
        }
Example #16
0
            public MemoryListener(CancellationTokenSource sharedCancellationTokenSource)
            {
                _sharedCancellationTokenSource = sharedCancellationTokenSource;

                try {
                    _keyboard = KeyboardListenerFactory.Get();
                    _keyboard.WatchFor(Keys.Escape);
                    _keyboard.KeyUp += OnKeyUp;
                } catch (Exception e) {
                    Logging.Error(e);
                }

                AcSharedMemory.Instance.Start += OnStart;
            }
Example #17
0
        public KeyboardManager(
            IEventBroker <ClickerEventArgs> eventBroker,
            IFsm <ClickerEventArgs> fsm,
            IKeyboardListener keyboardListener
            )
        {
            _eventBroker      = eventBroker;
            _fsm              = fsm;
            _keyboardListener = keyboardListener;

            _handler = new RawKeyEventHandler(OnKeyDown);

            //_hnd = GCHandle.Alloc(_keyboardListener);
        }
Example #18
0
        public void Show(UIView parent, CGPoint position)
        {
            _keyboardListener = parent as IKeyboardListener;

            _keyboardListener?.Pause();

            Application.Instance.RegisterSchemeForEditMode(_scheme);
            Application.Instance.RegisterSchemeForViewMode(_scheme);

            var suggestionsSize = _suggestionsView.ChangeWidthAndLayout((float)parent.Frame.Width / 3f);

            Frame = new CGRect(position, suggestionsSize);

            parent.Add(this);
        }
Example #19
0
 public static void AddKeyboardListener([NotNull] IKeyboardListener listener) => KeyboardListeners.Add(listener);
Example #20
0
        public static async Task <Result> StartAsync(IAcsStarter starter, StartProperties properties, IProgress <ProgressState> progress = null,
                                                     CancellationToken cancellation = default(CancellationToken))
        {
            if (_busy)
            {
                return(null);
            }
            _busy = true;

            if (OptionDebugMode)
            {
                progress?.Report(ProgressState.Waiting);
                await Task.Delay(500, cancellation);

                _busy = false;
                return(GetResult(DateTime.MinValue));
            }

            RemoveResultJson();
            IKeyboardListener listener = null;

            if (properties.SetKeyboardListener)
            {
                try {
                    listener = KeyboardListenerFactory.Get();
                    listener.Subscribe();
                } catch (Exception e) {
                    AcToolsLogging.Write("Can’t set listener: " + e);
                }
            }

            var start = DateTime.Now;

            try {
                progress?.Report(ProgressState.Preparing);
                await Task.Run(() => properties.Set(), cancellation);

                if (cancellation.IsCancellationRequested || OptionRaceIniTestMode)
                {
                    return(null);
                }

                progress?.Report(ProgressState.Launching);
                await starter.RunAsync(cancellation);

                if (cancellation.IsCancellationRequested)
                {
                    return(null);
                }

                var process = await starter.WaitUntilGameAsync(cancellation);

                await Task.Run(() => properties.SetGame(process), cancellation);

                if (cancellation.IsCancellationRequested)
                {
                    return(null);
                }

                progress?.Report(ProgressState.Waiting);
                await starter.WaitGameAsync(cancellation);

                if (cancellation.IsCancellationRequested)
                {
                    return(null);
                }
            } finally {
                _busy = false;

                if (cancellation.IsCancellationRequested)
                {
                    starter.CleanUp();
                }
                else
                {
                    progress?.Report(ProgressState.Finishing);
                    await starter.CleanUpAsync(cancellation);
                }

                properties.RevertChanges();
                listener?.Dispose();
            }

            return(GetResult(start));
        }
Example #21
0
 public void SetUp()
 {
     _keyboardListener = new KeyboardListener();
     _keyboardListener.KeyCombinationPressed += HandleKeyCombinationPressed;
     _keyPressHandled = false;
 }
Example #22
0
 public static void RemoveKeyboardListener([NotNull] IKeyboardListener listener) =>
 KeyboardListeners.Remove(listener);
Example #23
0
 public bool ContainsListener(IKeyboardListener listener)
 {
     return(this.listeners.IndexOf(listener) >= 0);
 }
Example #24
0
 /// <summary>
 /// Subscribe an keyboard listener
 /// </summary>
 /// <param name="listener"></param>
 public void SubscribeKeyboardListener(IKeyboardListener listener)
 {
     // Subscribe passed keyboard listener to the input manager
     _inputManager.AddListener((listener).OnNewKeyboardInput);
 }
Example #25
0
 public void Add(IKeyboardListener listener)
 {
     simple.Enter();
     subscribers.Add(listener);
     simple.Exit();
 }
Example #26
0
 public void Remove(IKeyboardListener listener)
 {
     simple.Enter();
     subscribers.Remove(listener);
     simple.Exit();
 }
Example #27
0
 public HUDKeyboard(IKeyboardListener owner, int depth = 0)
 {
     Focusable = false;
     Depth     = depth;
     _owner    = owner;
 }
 public void Remove(IKeyboardListener listener)
 {
   simple.Enter();
   subscribers.Remove(listener);
   simple.Exit();
 }
 public void SetUp()
 {
     _keyboardListener = new KeyboardListener();
     _keyboardListener.KeyCombinationPressed += HandleKeyCombinationPressed;
     _keyPressHandled = false;
 }
Example #30
0
 /// <summary>
 /// Subscrible a keyboard listener
 /// </summary>
 /// <param name="pListener"></param>
 public void SubscribeListener(IKeyboardListener pListener)
 {
     inputManager.AddListener(pListener.OnNewKeyboardInput);
 }
 public void Add(IKeyboardListener listener)
 {
   simple.Enter();
   subscribers.Add(listener);
   simple.Exit();
 }