Beispiel #1
0
        public About()
        {
            InitializeComponent();

            versionChecker = new VersionChecker();
            versionChecker.CheckVersionComplete += new EventHandler <CheckVersionCompleteEventArgs>(versionChecker_CheckVersionComplete);
        }
Beispiel #2
0
        private void App_OnExit(object sender, ExitEventArgs e)
        {
            Analytics.TrackEvent(Analytics.ToastifyEventCategory.General, Analytics.ToastifyEvent.AppTermination);
            Spotify.DisposeInstance();
            VersionChecker.DisposeInstance();

            logger.Info($"Toastify terminated with exit code {e.ApplicationExitCode}.");
        }
Beispiel #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Load settings from XML
            LoadSettings();

            string version = VersionChecker.Version;

            Telemetry.TrackEvent(TelemetryCategory.General, Telemetry.TelemetryEvent.AppLaunch, version);

            if (SettingsXml.Current.PreviousOS != version)
            {
                Telemetry.TrackEvent(TelemetryCategory.General, Telemetry.TelemetryEvent.AppUpgraded, version);

                SettingsXml.Current.PreviousOS = version;
            }

            //Init toast(color settings)
            InitToast();

            //Init tray icon
            trayIcon         = new System.Windows.Forms.NotifyIcon();
            trayIcon.Icon    = Toastify.Properties.Resources.spotifyicon;
            trayIcon.Text    = "Toastify";
            trayIcon.Visible = true;

            trayIcon.ContextMenu = new System.Windows.Forms.ContextMenu();

            //Init tray icon menu
            System.Windows.Forms.MenuItem menuSettings = new System.Windows.Forms.MenuItem();
            menuSettings.Text   = "Settings";
            menuSettings.Click += (s, ev) => { Settings.Launch(this); };

            trayIcon.ContextMenu.MenuItems.Add(menuSettings);

            System.Windows.Forms.MenuItem menuAbout = new System.Windows.Forms.MenuItem();
            menuAbout.Text   = "About Toastify...";
            menuAbout.Click += (s, ev) => { new About().ShowDialog(); };

            trayIcon.ContextMenu.MenuItems.Add(menuAbout);

            trayIcon.ContextMenu.MenuItems.Add("-");

            System.Windows.Forms.MenuItem menuExit = new System.Windows.Forms.MenuItem();
            menuExit.Text   = "Exit";
            menuExit.Click += (s, ev) => { Application.Current.Shutdown(); }; //this.Close(); };

            trayIcon.ContextMenu.MenuItems.Add(menuExit);

            trayIcon.MouseClick += (s, ev) => { if (ev.Button == System.Windows.Forms.MouseButtons.Left)
                                                {
                                                    DisplayAction(SpotifyAction.ShowToast, null);
                                                }
            };

            trayIcon.DoubleClick += (s, ev) => { Settings.Launch(this); };

            //Init watch timer
            watchTimer          = new Timer(1000);
            watchTimer.Elapsed += (s, ev) =>
            {
                watchTimer.Stop();
                CheckTitle();
                watchTimer.Start();
            };

            this.Deactivated += Toast_Deactivated;

            //Remove from ALT+TAB
            WinHelper.AddToolWindowStyle(this);

            //Check if Spotify is running.
            AskUserToStartSpotify();
            LoadPlugins();

            //Let the plugins know we're started.
            foreach (var p in this.Plugins)
            {
                try
                {
                    p.Started();
                }
                catch (Exception)
                {
                    //For now we swallow any plugin errors.
                }
            }

            if (!SettingsXml.Current.DisableToast)
            {
                watchTimer.Enabled = true; //Only need to be enabled if we are going to show the toast.
            }
            versionChecker = new VersionChecker();
            versionChecker.CheckVersionComplete += new EventHandler <CheckVersionCompleteEventArgs>(versionChecker_CheckVersionComplete);
            versionChecker.BeginCheckVersion();

            // TODO: right now this is pretty dumb - kick off update notifications every X hours, this might get annoying
            //       and really we should just pop a notification once per version and probably immediately after a song toast
            var updateTimer = new System.Windows.Threading.DispatcherTimer();

            updateTimer.Tick    += (timerSender, timerE) => { versionChecker.BeginCheckVersion(); };
            updateTimer.Interval = new TimeSpan(6, 0, 0);
            updateTimer.Start();
        }