Example #1
0
        private void SaveAndApplySettings()
        {
            settings.Save(replaceCurrent: true);

            toast.InitToast();
            toast.DisplayAction(SpotifyAction.SettingsSaved, null);
        }
Example #2
0
        private void Window_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (dragging)
            {
                dragging = false;

                // save the new window position
                SettingsXml settings = SettingsXml.Current;

                settings.PositionLeft = this.Left;
                settings.PositionTop  = this.Top;

                settings.Save();
            }
        }
Example #3
0
        private void EnsureSpotify()
        {
            SettingsXml settings = SettingsXml.Current;

            //Make sure Spotify is running when starting Toastify.
            //If not ask the user and try to start it.

            if (!Spotify.IsAvailable())
            {
                if ((settings.AlwaysStartSpotify.HasValue && settings.AlwaysStartSpotify.Value) || (MessageBox.Show("Spotify doesn't seem to be running.\n\nDo you want Toastify to try and start it for you?", "Toastify", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes))
                {
                    string spotifyPath = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Spotify", string.Empty, string.Empty) as string;  //string.Empty = (Default) value

                    // try in the secondary location
                    if (string.IsNullOrEmpty(spotifyPath))
                    {
                        spotifyPath = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall\Spotify", "InstallLocation", string.Empty) as string;  //string.Empty = (Default) value
                    }

                    if (string.IsNullOrEmpty(spotifyPath))
                    {
                        MessageBox.Show("Unable to find Spotify. Make sure it is installed and/or start it manually.", "Toastify", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        try
                        {
                            System.Diagnostics.Process.Start(System.IO.Path.Combine(spotifyPath, "Spotify.exe"));

                            if (!settings.AlwaysStartSpotify.HasValue)
                            {
                                var ret = MessageBox.Show("Do you always want to start Spotify if it's not already running?", "Toastify", MessageBoxButton.YesNo, MessageBoxImage.Question);
                                settings.AlwaysStartSpotify = (ret == MessageBoxResult.Yes);
                                settings.Save();
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("An unknown error occurd when trying to start Spotify.\nPlease start Spotify manually.", "Toastify", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                }
            }
        }