public AppStateInfoViewModel(
            IApplicationCommands applicationCommands,
            IEventAggregator eventAggregator,
            IAppConfigurationService appConfigurationService,
            IKeyHookService keyHookService,
            IStorageService storageService)
        {
            KeyHookService          = keyHookService;
            ApplicationCommands     = applicationCommands;
            EventAggregator         = eventAggregator;
            AppConfigurationService = appConfigurationService;
            StorageService          = storageService;

            tokenKeyHandlerHome = KeyHookService.Add(System.Windows.Forms.Keys.Home, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));
            tokenKeyHandlerEnd  = KeyHookService.Add(System.Windows.Forms.Keys.End, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));

            //handle "unload" event from view to cleanup VM resources
            EventAggregator.GetEvent <ViewDestroyedEvent>()
            .Subscribe(
                HandleUnload,
                ThreadOption.UIThread,
                false,
                view => view.DataContext == this     //if view has this context then handle operation
                );
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            Instance = this;

            ValidateAppSingleInstanceState();

            IKeyHookService keyHookService = Resolve <IKeyHookService>();
            IStorageService storageService = Resolve <IStorageService>();

            disposableResources = new List <IDisposable>();

            this.Dispatcher.UnhandledException += Dispatcher_UnhandledException;
            RegisterDisposableResources();

            PresentationTraceSources.Refresh();
            PresentationTraceSources.DataBindingSource.Listeners.Add(new ConsoleTraceListener());
            //PresentationTraceSources.DataBindingSource.Listeners.Add(new DebugTraceListener());
            PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Warning | SourceLevels.Error;

            DumpAppConfig();

            LoadSettings();
            InitialNavigation();
        }
Esempio n. 3
0
        public AppInactivityViewModel(ILogService logService, IApplicationCommands applicationCommands, IKeyHookService keyHookService)
        {
            LogService          = logService;
            ApplicationCommands = applicationCommands;
            KeyHookService      = keyHookService;

            RequestAppStateUpdateCommand = new DelegateCommand(RequestAppStateUpdate);

            IsRequestAppStateUpdateEnabled = true;

            tokenKeyHandlerEnd  = KeyHookService.Add(System.Windows.Forms.Keys.Home, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));
            tokenKeyHandlerHome = KeyHookService.Add(System.Windows.Forms.Keys.End, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));
        }
        public TeamsPanelViewModel(
            IApplicationCommands applicationCommands,
            IAppConfigurationService appConfigurationService,
            IEventAggregator eventAggregator,
            IDataService userRankService,
            IKeyHookService keyHookService,
            ILogService logService,
            IStorageService storageService)
        {
            ApplicationCommands     = applicationCommands;
            AppConfigurationService = appConfigurationService;
            EventAggregator         = eventAggregator;
            UserRankService         = userRankService;
            KeyHookService          = keyHookService;
            LogService     = logService;
            StorageService = storageService;

            //ApplicationCommands.ShowWindow.Execute(null);

            updateTimer = new System.Timers.Timer(AppConfigurationService.TeamPanelUpdateTick)
            {
                AutoReset = true
            };
            updateTimer.Elapsed += UpdateTimer_Elapsed;
            updateTimer.Start();

            //assign home/end keys with window visibility toggle
            keyHandlerTokenHome = KeyHookService.Add(System.Windows.Forms.Keys.Home, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));
            keyHandlerTokenEnd  = KeyHookService.Add(System.Windows.Forms.Keys.End, () => ApplicationCommands.ToggleWindowVisibility.Execute(null));

            EventAggregator.GetEvent <ViewDestroyedEvent>()
            .Subscribe(
                HandleUnload,
                ThreadOption.UIThread,
                false,
                view => view.DataContext == this     //if view has this context then handle operation
                );
        }
        public MatchFoundNotificationViewModel(
            IKeyHookService keyHookService,
            IApplicationCommands applicationCommands,
            IEventAggregator eventAggregator,
            IAppCriticalExceptionHandlerService appCriticalExceptionHandlerService,
            IStorageService storageService)
        {
            KeyHookService      = keyHookService;
            ApplicationCommands = applicationCommands;
            EventAggregator     = eventAggregator;
            AppCriticalExceptionHandlerService = appCriticalExceptionHandlerService;
            StorageService = storageService;

            keyHandlerTokenHome = KeyHookService.Add(System.Windows.Forms.Keys.Home, DisplayMatch);
            keyHandlerTokenEnd  = KeyHookService.Add(System.Windows.Forms.Keys.End, HideWindowAndLoadMatchInBackground);

            EventAggregator.GetEvent <ViewDestroyedEvent>()
            .Subscribe(
                HandleUnload,
                ThreadOption.UIThread,
                false,
                view => view.DataContext == this //if view has this context then and only then handle operation
                );
        }