Ejemplo n.º 1
0
        private void UpdateProgressToast(string videoId, DownloadOperation op)
        {
            if (!Services.Helpers.ApiContractHelper.IsCreatorsUpdateAvailable)
            {
                return;
            }

            // Construct a NotificationData object;
            string toastTag   = $"{videoId}";
            string toastGroup = "hohoema_cache_dl";

            var progress     = op.Progress.BytesReceived / (double)op.Progress.TotalBytesToReceive;
            var progressText = (progress * 100).ToString("F0");
            // Create NotificationData with new values;
            // Make sure that sequence number is incremented since last update, or assign with value 0 for updating regardless of order;
            var data = new NotificationData {
                SequenceNumber = 0
            };

            data.Values["progressValue"]  = progress.ToString("F1"); // 固定小数点、整数部と小数一桁までを表示
            data.Values["progressString"] = $"{progressText}%";
            data.Values["progressStatus"] = "donwloading";

            // Updating a previously sent toast with tag, group, and new data;
            NotificationUpdateResult updateResult = ToastNotificationManager.CreateToastNotifier().Update(data, toastTag, toastGroup);
        }
Ejemplo n.º 2
0
        public static void UpdateProgress(double progress)
        {
            // Construct a NotificationData object;
            string tag   = "appInstall";
            string group = "Install1";

            // Create NotificationData with new values;
            // Make sure that sequence number is incremented since last update, or assign with value 0 for updating regardless of order;
            var data = new NotificationData {
                SequenceNumber = 2
            };

            data.Values["changingText4Mobile"] = String.Format("Install Progress at {0}%", progress);
            data.Values["progressValue"]       = String.Format("{0}", progress / 100);
            data.Values["progressString"]      = String.Format("{0}%", progress);

            // Updating a previously sent toast with tag, group, and new data;
            NotificationUpdateResult updateResult = ToastNotificationManager.CreateToastNotifier().Update(data, tag, group);
        }
Ejemplo n.º 3
0
 public void OnPlayPositionChange(TimeSpan ts)
 {
     Common.Invoke(() =>
     {
         try
         {
             AudioInfo tai = HyPlayList.NowPlayingItem.AudioInfo;
             if (Common.Setting.toastLyric)
             {
                 NotificationData data = new NotificationData()
                 {
                     SequenceNumber = 0
                 };
                 data.Values["Title"]              = HyPlayList.NowPlayingItem.Name;
                 data.Values["PureLyric"]          = HyPlayList.Lyrics[HyPlayList.lyricpos].PureLyric;
                 data.Values["Translation"]        = HyPlayList.Lyrics[HyPlayList.lyricpos].Translation is null ? " " : HyPlayList.Lyrics[HyPlayList.lyricpos].Translation;
                 data.Values["TotalValueString"]   = TimeSpan.FromMilliseconds(tai.LengthInMilliseconds).ToString(@"hh\:mm\:ss");
                 data.Values["CurrentValueString"] = HyPlayList.Player.PlaybackSession.Position.ToString(@"hh\:mm\:ss");
                 data.Values["CurrentValue"]       = (HyPlayList.Player.PlaybackSession.Position / TimeSpan.FromMilliseconds(tai.LengthInMilliseconds)).ToString();
                 NotificationUpdateResult res      = ToastNotificationManager.CreateToastNotifier().Update(data, "HyPlayerDesktopLyrics");
             }
             TbSingerName.Text       = tai.Artist;
             TbSongName.Text         = tai.SongName;
             SliderProgress.Value    = HyPlayList.Player.PlaybackSession.Position.TotalMilliseconds;
             TextBlockTotalTime.Text =
                 TimeSpan.FromMilliseconds(tai.LengthInMilliseconds).ToString(@"hh\:mm\:ss");
             TextBlockNowTime.Text =
                 HyPlayList.Player.PlaybackSession.Position.ToString(@"hh\:mm\:ss");
             PlayStateIcon.Glyph =
                 HyPlayList.Player.PlaybackSession.PlaybackState == MediaPlaybackState.Playing
                     ? "\uEDB4"
                     : "\uEDB5";
             //SliderAudioRate.Value = mp.Volume;
         }
         catch (Exception)
         {
         }
     });
 }