private void UpdateTimerTick(object sender, EventArgs eventArgs) { if (PlayerControl.PlayerState == PlayerState.Closed || PlayerControl.PlayerState == PlayerState.Stopped) { return; } var duration = Math.Max(1, PlayerControl.MediaDuration); Taskbar.SetProgressValue((int)(PlayerControl.MediaPosition * 1000 / duration), 1000); }
private static void UpdateTimerTick(object sender, EventArgs eventArgs) { if (Player.State == PlayerState.Closed || Player.State == PlayerState.Stopped) { return; } var duration = Math.Max(1, Media.Duration); Taskbar.SetProgressValue((int)Math.Min(1000, Media.Position * 1000 / duration), 1000); }
//int count = 0; void downloader_ProgressChanged(object sender, ProgressChangedEventArgs e) { if (!Program.IsClosing) { var downloader = sender as Downloader; var item = downloader.Tag as ListViewItem; switch (e.ProgressPercentage) { case Downloader.STATUS: //TaskList_ColumnClick(null, null); Log(e.UserState as string, sender); break; case Downloader.FILEINFO: item.SubItems[ITEM_NAME].Text = downloader.FileName; if (downloader.FileSize > 0) { item.SubItems[ITEM_SIZE].Text = Util.ToSize(downloader.FileSize); } break; case Downloader.CHANGEURL: item.Name = e.UserState as string; break; case Downloader.NEWURL: StartDownload(e.UserState as string); break; default: #if false if (count == 0) { TaskList.BeginUpdate(); } count++; #endif long progress = (long)e.UserState; long filesize = downloader.FileSize; int speed = downloader.Speed; item.SubItems[ITEM_SIZE].Text = Util.ToSize(downloader.FileSize); item.SubItems[ITEM_SPEED].Text = Util.ToSpeed(speed); if (filesize > 0) { string s = (progress / (double)filesize).ToString("P1"); if (s == "100.0%" && progress < filesize) { s = "99.9%"; } item.SubItems[ITEM_DONE].Text = s; Taskbar.SetProgressValue(progress, filesize); item.SubItems[ITEM_ETA].Text = speed != 0 ? TimeSpan.FromSeconds((filesize - progress) / speed).ToString() : string.Empty; } #if false if (count >= PWeb.Count) { count = 0; TaskList.EndUpdate(); } #endif break; } } }