Example #1
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            hotkeyService = new HotkeyService(this);
            hotkeyService.Install();

            hotkeyService.Add(new TurnMonitorOffHandler(this));
            hotkeyService.Add(new NetworkConnectionsHandler());
            hotkeyService.Add(new LockWorkStationHandler(this));
            hotkeyService.Add(new PinTopMostHotkeyHandler());
            hotkeyService.Add(new PinToAllDesktopsHotkeyHandler());

            SystemSuspendHandler suspendHandler = new SystemSuspendHandler();

            hotkeyService.Add(suspendHandler.SleepHotkey, suspendHandler.Handle);
            hotkeyService.Add(suspendHandler.HibernateHotkey, suspendHandler.Handle);

            ClockHandler = new ClockHandler();
            hotkeyService.Add(ClockHandler.LargeHotkey, ClockHandler.Handle);
            hotkeyService.Add(ClockHandler.MediumHotkey, ClockHandler.Handle);

            // http://stackoverflow.com/questions/34139450/getwindowrect-returns-a-size-including-invisible-borders
            stickService = new StickService(Dispatcher);
            stickService.Install();

            hotkeyService.Add(new SetSizeHotkeyHandler());
        }
Example #2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            ErrorReportingService.Initialize();

            Trace.WriteLine("App Application_Startup");

            if (!SingleInstanceAppMutex.TakeExclusivity())
            {
                Trace.WriteLine("App Application_Startup TakeExclusivity failed");
                Current.Shutdown();
                return;
            }

            ((ThemeManager)Resources["ThemeManager"]).SetTheme(ThemeData.GetBrushData());

            var deviceManager = DataModelFactory.CreateAudioDeviceManager();

            DiagnosticsService.Advise(deviceManager);

            _viewModel        = new MainViewModel(deviceManager);
            _viewModel.Ready += MainViewModel_Ready;

            _flyoutWindow = new FlyoutWindow(_viewModel, new FlyoutViewModel(_viewModel));
            _trayIcon     = new TrayIcon(new TrayViewModel(_viewModel));

            HotkeyService.Register(SettingsService.Hotkey);
            HotkeyService.KeyPressed += (_, __) => _viewModel.OpenFlyout();

            StartupUWPDialogDisplayService.ShowIfAppropriate();

            Trace.WriteLine($"App Application_Startup Exit");
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShellViewModel" /> class.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="settingsService">The settings service.</param>
        /// <param name="keyCodeService">The key code service.</param>
        /// <param name="buildService">The build service.</param>
        /// <param name="settingsViewModel">The settings view model.</param>
        /// <param name="eventAggregator">The event aggregator.</param>
        public ShellViewModel(SimpleContainer container, SettingsService settingsService, HotkeyService keyCodeService, BuildService buildService, SettingsViewModel settingsViewModel, IEventAggregator eventAggregator)
        {
            this._eventAggregator   = eventAggregator;
            this._settingsService   = settingsService;
            this._keyCodeService    = keyCodeService;
            this._buildService      = buildService;
            this._container         = container;
            this._settingsViewModel = settingsViewModel;

            this._openingTask             = this.WaitForPoe(false);
            this.StartWithWindows         = File.Exists(this.ShortcutFilePath);
            this.ShowInTaskBar            = true;
            this._settingsService.OnSave += this.SettingsService_OnSave;
            if (settingsService.FirstLaunch)
            {
                if (this.StartWithWindows)
                {
                    // RefreshShortcut
                    File.Delete(this.ShortcutFilePath);
                    this.CreateLink();
                }

                settingsService.FirstLaunch = false;
                this._showUpdateSuccess     = true;
                settingsService.Save(false);

                if (settingsService.ShowReleaseNote)
                {
                    Process.Start("https://github.com/C1rdec/Poe-Lurker/releases/latest");
                }
            }

            // this.ActivateItem(IoC.Get<TutorialViewModel>());
            this._eventAggregator.Subscribe(this);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SettingsViewModel" /> class.
        /// </summary>
        /// <param name="windowManager">The window manager.</param>
        /// <param name="keyboardHelper">The keyboard helper.</param>
        /// <param name="settingsService">The settings service.</param>
        /// <param name="hotkeyService">The key code service.</param>
        /// <param name="soundService">The sound service.</param>
        /// <param name="githubService">The github service.</param>
        /// <param name="pushBulletService">The PushBullet service.</param>
        public SettingsViewModel(
            IWindowManager windowManager,
            KeyboardHelper keyboardHelper,
            SettingsService settingsService,
            HotkeyService hotkeyService,
            SoundService soundService,
            GithubService githubService,
            PushBulletService pushBulletService)
            : base(windowManager)
        {
            this._keyboardHelper       = keyboardHelper;
            this._settingService       = settingsService;
            this._hotkeyService        = hotkeyService;
            this._soundService         = soundService;
            this.DisplayName           = "Settings";
            this._excludePropertyNames = this.GetExcludedPropertyNames();
            this.PropertyChanged      += this.SettingsViewModel_PropertyChanged;

            if (!AssetService.Exists(LottieFileName))
            {
                AssetService.Create(LottieFileName, GetResourceContent(LottieFileName));
            }

            this.BuildManager = new BuildManagerViewModel(this.ShowMessage, githubService);
            this.PushBullet   = new PushBulletViewModel(pushBulletService);
            this.SetupHotkeys();
        }
Example #5
0
        public MainService(HwndSource source)
        {
            Source = source;

            var backlightService = new BacklightService();

            var powerService = new PowerService();

            powerService.LidSwitchStatusChanged += OnLidSwitchStatusChanged;
            powerService.PowerStatusChanged     += OnPowerChangeStatusChanged;

            var hotkeyservice = new HotkeyService();

            hotkeyservice.HotKeyTriggered += OnHotkeyTriggered;

            var idleService = new IdleService();

            idleService.IdleStateChanged += OnIdleStateChanged;

            ServiceManager.RegisterService <IBacklightService>(backlightService);
            ServiceManager.RegisterService <IPowerService>(powerService);
            ServiceManager.RegisterService <IHotkeyService>(hotkeyservice);
            ServiceManager.RegisterService <IIdleService>(idleService);


            foreach (var registeredService in ServiceManager.RegisteredServices)
            {
                registeredService.Owner = this;
                registeredService.Start();
                Logger.Write($"{registeredService.GetType().Name} started.");
            }

            backlightService.Mode = powerService.AcPowerPluggedIn ? BacklightMode.Ac : BacklightMode.Battery;
        }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KeyboardLurker" /> class.
        /// </summary>
        /// <param name="processId">The process identifier.</param>
        /// <param name="settingsService">The settings service.</param>
        /// <param name="hotkeyService">The key code service.</param>
        /// <param name="keyboardHelper">The keyboard helper.</param>
        public KeyboardLurker(int processId, SettingsService settingsService, HotkeyService hotkeyService, PoeKeyboardHelper keyboardHelper)
        {
            this._processId       = processId;
            this._settingsService = settingsService;
            this._hotkeyService   = hotkeyService;
            this._keyboardHelper  = keyboardHelper;

            this._itemParser = new ItemParser();
            this._itemParser.CheckPledgeStatus();
            this._settingsService.OnSave += this.SettingsService_OnSave;
            this._keyboardHook            = new KeyboardHook(this._processId);
        }
        private void HotkeySelect_Click(object sender, RoutedEventArgs e)
        {
            HotkeyService.Unregister();

            var win = new HotkeySelectionWindow();

            win.Owner = this;
            win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            if ((bool)win.ShowDialog())
            {
                _viewModel.Hotkey = win.Hotkey;
            }

            HotkeyService.Register(_viewModel.Hotkey);
        }
Example #8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            using (var control = new PlayerControllerService())
            {
                control.Player.OnAboutToPromptUserToQuitEvent += Application.Exit;

                // Hotkey service
                using (var hotkeyService = new HotkeyService())
                {
                    control.RegisterHotkeyService(hotkeyService);

                    var selectSongVisualService = new VisualService
                    {
                        Form = new SelectSongForm(control.Player),
                        MenuEntry = "&Select song"
                    };
                    hotkeyService.RegisterHotKey("SelectSong",
                        (o, e) => selectSongVisualService.Activate());

                    // Tray service
                    using (var trayService = new TrayService(new[] { selectSongVisualService,
                        new VisualService {
                            Form = new MainForm(control),
                            MenuEntry = "Show &MiniPlayer"
                        },
                        new VisualService {
                            Form = new SettingsForm(),
                            MenuEntry = "S&ettings"
                        }
                    }))
                    {
                        control.RegisterNotificationService(trayService);
                        using (new OSDService(control))
                        {
                            Application.Run();
                        }
                    }
                }
            }
        }
        public void RegisterHotkeyService(HotkeyService hotkeyService)
        {
            hotkeyService.RegisterHotKey("PlayPause", (o,e) => PlayPause());
            hotkeyService.RegisterHotKey("NextTrack", (o, e) => NextTrack());
            hotkeyService.RegisterHotKey("PrevTrack", (o, e) => PrevTrack());

            hotkeyService.RegisterHotKey("ChangeWindowSize", (o, e) => ChangeWindowSize());
            hotkeyService.RegisterHotKey("RepeatCurrentSong", (o, e) => RepeatCurrentSong());

            hotkeyService.RegisterHotKey("SetNoStars", (o, e) => AssignStars(0));
            hotkeyService.RegisterHotKey("SetOneStar", (o, e) => AssignStars(20));
            hotkeyService.RegisterHotKey("SetTwoStars", (o, e) => AssignStars(40));
            hotkeyService.RegisterHotKey("SetThreeStars", (o, e) => AssignStars(60));
            hotkeyService.RegisterHotKey("SetFourStars", (o, e) => AssignStars(80));
            hotkeyService.RegisterHotKey("SetFiveStars", (o, e) => AssignStars(100));
        }