예제 #1
0
        private void Init()
        {
            _log.Information(LogHelper.GetMethodName(this), "Started ********************************************************************");

            if (_config.ExternalConfig.Channel == 99)      // Reset channel if Favourites were tracked at exit
            {
                _config.ExternalConfig.Channel = 0;
            }

            _songInfoListener.CheckTrackedRpPlayerStatus();
            if (_config.State.RpTrackingConfig.Players.Any())
            {
                _config.State.RpTrackingConfig.ActivePlayerId = _config.State.RpTrackingConfig.Players.FirstOrDefault().PlayerId;
            }

            if (_config.ExternalConfig.EnableFoobar2000Watcher)
            {
                _foobar2000Watcher.CheckPlayerState(out bool notUsedHere);
                _foobar2000Watcher.Start();
            }
            else if (_config.ExternalConfig.EnableMusicBeeWatcher)
            {
                _musicBeeWatcher.CheckPlayerState(out bool notUsedHere);
                _musicBeeWatcher.Start();
            }

            // Init fields
            _shortcutHelper.TryCreateShortcut();    // Add shortcut to Start menu (required for Toast Notifications)

            // Set up event handlers
            _log.Information(LogHelper.GetMethodName(this), "Create event listeners");
            _config.ExternalConfig.ExternalConfigChangeHandler += OnChange;
            _config.State.StateChangeHandler += OnChange;
            _config.State.RpTrackingConfig.RpTrackingConfigChangeHandler += OnChange;
            Application.ApplicationExit   += this.ApplicationExitHandler;
            SystemEvents.PowerModeChanged += WakeUpHandler;

            // Check queued application data delet request
            CheckQueuedDataDeleteRequest();

            // Start listen for song changes
            _songInfoListener.Start();

            // Add context menu
            _log.Information(LogHelper.GetMethodName(this), "Create tray icon");
            _rpTrayIcon.Init();
            _rpTrayIcon.NotifyIcon.MouseDoubleClick += TrayIconDoubleClickHandler;
        }
        private void TravelRequestApproved(TravelRequest travelRequest)
        {
            if (travelRequest != null)
            {
                this.travelRequestNotified = travelRequest;

                // Create the sortcut
                ShortcutHelper.TryCreateShortcut("MyCompany.Travel");

                // Create the toast and attach event listeners
                XmlDocument toastXml = CreateToast();
                var         node     = toastXml.FirstChild.FirstChild.FirstChild;
                ((XmlElement)node).SetAttribute("addImageQuery", "true");
                this.toast            = new ToastNotification(toastXml);
                this.toast.Activated += ToastActivated;
                ToastNotificationManager.CreateToastNotifier("MyCompany.Travel").Show(toast);
            }
        }