Пример #1
0
        public void showViaToast(ToastForm myForm, String track, String artist)
        {
            myForm.setArtist(artist);
            myForm.setTrack(track);
            myForm.setAlbum("");
            myForm.setAlbumImage(spotifytoaster.Properties.Resources.album_missing);

            // Attempt to load additional information about the track
            if (albumInfo.loadAlbumInfoAsync(artist, track))
            {
                // Set Album Title if we have one
                if (!string.IsNullOrEmpty(albumInfo.getAlbumTitle()))
                {
                    myForm.setAlbum(albumInfo.getAlbumTitle());
                }

                // Set Album Image URL if we have one
                if (!string.IsNullOrEmpty(albumInfo.getAlbumImageURL()))
                {
                    myForm.setAlbumImageUrl(albumInfo.getAlbumImageURL());
                }

                // Add Track Number to the title if we have one
                if (null != albumInfo.getTrackNumber())
                {
                    myForm.setTrack($"{albumInfo.getTrackNumber()}. {track}");
                }
            }

            myForm.Show();
        }
Пример #2
0
 /// <summary>
 /// Displays message that the app is exiting
 /// </summary>
 public static void ExitMessageShow()
 {
     if (_exitMessageToastForm == null)
     {
         try
         {
             _exitMessageToastForm = new ToastForm(R.GetString("ExitingACAT"), -1);
             Windows.SetWindowPosition(_exitMessageToastForm, Windows.WindowPosition.CenterScreen);
             _exitMessageToastForm.Show();
         }
         catch
         {
         }
     }
 }
Пример #3
0
        private static void ShowNextMsg()
        {
            if (QueueMsg.Count <= 0)
            {
                IsBusy = false;
                return;
            }
            ToastMsg  tm = QueueMsg.Dequeue();
            ToastForm tf = new ToastForm(tm.Content, tm.Delay, tm.Context);

            tf.TopMost = true;
            tf.Show();
            tf.FormClosed += (s, e) =>
            {
                ShowNextMsg();
            };
        }
Пример #4
0
        /// <summary>
        /// Create a new toast.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="color">Background color</param>
        /// <param name="duration">Toast duration (0 is infinite)</param>
        /// <param name="onClose">On close callback</param>
        /// <returns></returns>
        public static int Create(string text, Color color, int duration = 3000, Action onClose = null)
        {
            var form      = new ToastForm(text, color, duration, index++);
            var currentId = counter++;

            form.FormClosed += (sender, e) =>
            {
                index--;
                toasts.Remove(currentId);

                onClose?.Invoke();
            };

            form.Show();
            toasts.Add(currentId, form);

            return(currentId);
        }
Пример #5
0
        /// <summary>
        /// User selected a language from the list.  If reqd,
        /// ask the user to confirm the switch
        /// </summary>
        /// <param name="cultureInfo">Cultureinfo of the language selected</param>
        /// <returns>true on success</returns>
        private void onLanguageSelected(CultureInfo cultureInfo)
        {
            if (DialogUtils.ConfirmScanner(String.Format(R.GetString("ConfirmSwitchLanguage"), cultureInfo.DisplayName)))
            {
                Windows.SetVisible(this, false);

                var toastForm = new ToastForm(R.GetString("PleaseWait"), -1);
                Windows.SetWindowPosition(toastForm, Windows.WindowPosition.CenterScreen);
                toastForm.Show();

                Invoke(new MethodInvoker(delegate
                {
                    Context.ChangeCulture(cultureInfo);
                }));

                toastForm.Close();

                var prefs = ACATPreferences.Load();
                prefs.Language = cultureInfo.Name;
                prefs.Save();

                Windows.CloseAsync(this);
            }
        }