void VideoDownloader_ProgressChanged(object sender, DownloadEventArgs e) { if (dlgProgress != null) { dlgProgress.SetLine(2, string.Format("{0} Mb / {1} Mb ({2}%)", e.TotalFileSize / 1024 / 1024, e.CurrentFileSize / 1024 / 1024, e.PercentDone)); dlgProgress.ShowProgressBar(true); dlgProgress.SetPercentage(e.PercentDone); dlgProgress.Progress(); } }
public int DoReorg() { /// Todo: move this statement to the GUI. /// Database Reorg now fully in music.database /// GUIDialogProgress pDlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); if (null == pDlgProgress) { return((int)Errors.ERROR_REORG_SONGS); } pDlgProgress.SetHeading(313); pDlgProgress.SetLine(2, ""); pDlgProgress.SetLine(3, ""); pDlgProgress.SetPercentage(0); pDlgProgress.Progress(); pDlgProgress.SetLine(1, 316); pDlgProgress.ShowProgressBar(true); ///TFRO71 4 june 2005 ///Connect the event to a method that knows what to do with the event. MusicDatabase.DatabaseReorgChanged += new MusicDBReorgEventHandler(SetPercentDonebyEvent); ///Execute the reorganisation int appel = m_dbs.MusicDatabaseReorg(null); ///Tfro Disconnect the event from the method. MusicDatabase.DatabaseReorgChanged -= new MusicDBReorgEventHandler(SetPercentDonebyEvent); pDlgProgress.SetLine(2, "Klaar"); return((int)Errors.ERROR_OK); }
void _progressTimer_Elapsed(object sender, ElapsedEventArgs e) { GUIDialogProgress _progress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); int percentage = _progress.Percentage; percentage = percentage + (int)(100.0 / _steps); _progress.SetPercentage(percentage > 100 ? 100 : percentage); _progress.ShowProgressBar(true); _progress.Progress(); }
private void UpdateNews(bool bShowWarning) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); try { if (m_strSiteURL.ToLowerInvariant().StartsWith("http://") == false && m_strSiteURL.ToLowerInvariant().StartsWith("file://") == false) { m_strSiteURL = "http://" + m_strSiteURL; } long startTime = Environment.TickCount; dlgProgress.SetHeading(704); dlgProgress.SetLine(1, GUILocalizeStrings.Get(705) + " " + m_strSiteName); dlgProgress.SetLine(2, ""); dlgProgress.SetLine(3, ""); dlgProgress.ShowProgressBar(false); dlgProgress.StartModal(GetID); dlgProgress.Progress(); Uri newURL = new Uri(m_strSiteURL); Download(newURL); UpdateButtons(); // Leave dialog on screen for minimum of 1 seconds // to eliminate the horrible flash of dialog before user can reed it long endTime = Environment.TickCount; if (endTime - startTime < 1000) { Thread.Sleep((int)(1000 - (endTime - startTime))); } dlgProgress.Close(); } catch (Exception e) { dlgProgress.Close(); if (bShowWarning) { GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SHOW_WARNING, 0, 0, 0, 0, 0, 0); msg.Param1 = 9; //my news msg.Param2 = 912; //Unable to download latest news msg.Param3 = 0; msg.Label3 = m_strSiteURL; GUIWindowManager.SendMessage(msg); Log.Error(e); } } }
public void UpdateSearchResults(string sortOrder) { GUIDialogProgress dlg = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); dlg.Reset(); dlg.SetHeading("Torrents"); dlg.SetLine(1, "Fetching torrents..."); dlg.SetPercentage(0); dlg.ShowProgressBar(true); dlg.StartModal(GUIWindowManager.ActiveWindow); _progressDlg = new ProgressUpdater(); _progressDlg.SetAutoUpdate(1000, 20); TorrentEngine.Instance().SearchTorrent(_searchEngine.Name, _searchString, sortOrder, dlg); }
public void OnProgress(string line1, string line2, string line3, int percent) { if (!GUIWindowManager.IsRouted) { return; } GUIDialogProgress pDlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); pDlgProgress.ShowProgressBar(true); pDlgProgress.SetLine(1, line1); pDlgProgress.SetLine(2, line2); if (percent > 0) { pDlgProgress.SetPercentage(percent); } pDlgProgress.Progress(); }
private bool InternalGetAlbumCovers(string artist, string album, string filteredAlbumText) { if (amazonWS.AbortGrab) { return(false); } amazonWS.ArtistName = artist; amazonWS.AlbumName = album; bool result = false; if (SearchMode == SearchDepthMode.Album) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.SetHeading(185); dlgProgress.SetLine(1, album); dlgProgress.SetLine(2, artist); dlgProgress.SetLine(3, filteredAlbumText); dlgProgress.SetPercentage(0); dlgProgress.Progress(); dlgProgress.ShowProgressBar(false); GUIWindowManager.Process(); } result = amazonWS.GetAlbumInfo(); } else { result = amazonWS.GetAlbumInfo(); } return(result); }
private void amazonWS_GetAlbumInfoProgress(AmazonWebservice aws, int progressPercent) { if (SearchMode == SearchDepthMode.Album) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.ShowProgressBar(true); dlgProgress.SetPercentage(progressPercent); dlgProgress.Progress(); } } else { // The GUICoverArtGrabberProgress window will manage showing cover art grabber progress if (FindCoverArtProgress != null) { FindCoverArtProgress(amazonWS, progressPercent); } } }
/// <summary> /// Called when [show context menu]. /// </summary> protected override void OnShowContextMenu() { GUIListItem selectedItem = listControl.SelectedListItem; YouTubeEntry videoEntry; LocalFileStruct file = selectedItem.MusicTag as LocalFileStruct; if (file != null) { Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + file.VideoId); Video video = Youtube2MP.request.Retrieve <Video>(videoEntryUrl); videoEntry = video.YouTubeEntry; } else { videoEntry = selectedItem.MusicTag as YouTubeEntry; } if (videoEntry == null) { return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // menu dlg.Add("Related Videos"); dlg.Add("Video responses for this video"); dlg.Add("All videos from this user : "******"Add to playlist"); dlg.Add("Add All to playlist"); dlg.Add("Add to favorites"); dlg.Add("Options"); dlg.Add("Download Video"); dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedLabel) { case 0: //relatated { if (videoEntry.RelatedVideosUri != null) { YouTubeQuery query = new YouTubeQuery(videoEntry.RelatedVideosUri.Content); YouTubeFeed vidr = service.Query(query); if (vidr.Entries.Count > 0) { SaveListState(true); addVideos(vidr, false, query); UpdateGui(); } else { Err_message("No item was found !"); } } } break; case 1: //respponse { if (videoEntry.VideoResponsesUri != null) { YouTubeQuery query = new YouTubeQuery(videoEntry.VideoResponsesUri.Content); YouTubeFeed vidr = service.Query(query); if (vidr.Entries.Count > 0) { SaveListState(true); addVideos(vidr, false, query); UpdateGui(); } else { Err_message("No response was found !"); } } } break; case 2: //relatated { if (videoEntry.RelatedVideosUri != null) { Video video = Youtube2MP.request.Retrieve <Video>(new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoEntry.VideoId)); YouTubeQuery query = new YouTubeQuery(string.Format("http://gdata.youtube.com/feeds/api/users/{0}/uploads", video.Author)); YouTubeFeed vidr = service.Query(query); if (vidr.Entries.Count > 0) { SaveListState(true); addVideos(vidr, false, query); UpdateGui(); } else { Err_message("No item was found !"); } } } break; case 3: { VideoInfo inf = SelectQuality(videoEntry); if (inf.Quality != VideoQuality.Unknow) { AddItemToPlayList(selectedItem, inf); } } break; case 4: { VideoInfo inf = SelectQuality(videoEntry); inf.Items = new Dictionary <string, string>(); foreach (GUIListItem item in listControl.ListView.ListItems) { AddItemToPlayList(item, new VideoInfo(inf)); } } break; case 5: { try { service.Insert(new Uri(YouTubeQuery.CreateFavoritesUri(null)), videoEntry); } catch (Exception) { Err_message("Wrong request or wrong user identification"); } } break; case 6: DoOptions(); break; case 7: // download { if (Youtube2MP._settings.LocalFile.Get(videoEntry.VideoId) != null) { Err_message("Item already downloaded !"); } else { if (VideoDownloader.IsBusy) { Err_message("Another donwnload is in progress"); dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetHeading("Download progress"); dlgProgress.SetLine(1, ""); dlgProgress.SetLine(2, ""); dlgProgress.SetPercentage(0); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); dlgProgress.DoModal(GetID); } } else { VideoInfo inf = SelectQuality(videoEntry); string streamurl = Youtube2MP.StreamPlaybackUrl(videoEntry, inf); VideoDownloader.AsyncDownload(streamurl, Youtube2MP._settings.DownloadFolder + "\\" + Utils.GetFilename(videoEntry.Title.Text + "{" + videoEntry.VideoId + "}") + Path.GetExtension(streamurl)); VideoDownloader.Entry = videoEntry; } } } break; } }
protected override void OnShowContextMenu() { if (listControl == null || listControl.SelectedListItem == null) { return; } GUIListItem selectedItem = listControl.SelectedListItem; YouTubeEntry videoEntry = selectedItem.MusicTag as YouTubeEntry; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // menu if (Youtube2MP.player.CurrentSong > -1 || Youtube2MP.temp_player.CurrentSong > -1) { dlg.Add(Translation.PlayNext); } dlg.Add(Translation.ShowPreviousWindow); dlg.Add(Translation.Fullscreen); if (videoEntry != null) { dlg.Add(Translation.AddPlaylist); dlg.Add(Translation.AddAllPlaylist); dlg.Add(Translation.Info); if (Youtube2MP.service.Credentials != null) { dlg.Add(Translation.AddFavorites); dlg.Add(Translation.AddWatchLater); } } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } if (dlg.SelectedLabelText == Translation.ShowPreviousWindow) { GUIWindowManager.ShowPreviousWindow(); } else if (dlg.SelectedLabelText == Translation.Fullscreen) { g_Player.ShowFullScreenWindow(); } else if (dlg.SelectedLabelText == Translation.AddPlaylist) { VideoInfo inf = SelectQuality(videoEntry); if (inf.Quality != VideoQuality.Unknow) { AddItemToPlayList(selectedItem, inf); } } else if (dlg.SelectedLabelText == Translation.AddAllPlaylist) { VideoInfo inf = SelectQuality(videoEntry); inf.Items = new Dictionary <string, string>(); if (inf.Quality != VideoQuality.Unknow) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetHeading(Translation.AddAllPlaylist); dlgProgress.SetLine(1, ""); dlgProgress.SetLine(2, ""); dlgProgress.SetPercentage(0); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); dlgProgress.StartModal(GetID); } int i = 0; for (int j = 0; j < listControl.Count; j++) { GUIListItem item = listControl[j]; if (dlgProgress != null) { double pr = ((double)i / (double)listControl.Count) * 100; dlgProgress.SetLine(1, item.Label); dlgProgress.SetLine(2, i.ToString() + "/" + listControl.Count.ToString()); dlgProgress.SetPercentage((int)pr); dlgProgress.Progress(); if (dlgProgress.IsCanceled) { break; } } i++; AddItemToPlayList(item, new VideoInfo(inf)); } if (dlgProgress != null) { dlgProgress.Close(); } } } else if (dlg.SelectedLabelText == Translation.AddFavorites) { try { Youtube2MP.service.Insert(new Uri(YouTubeQuery.CreateFavoritesUri(null)), videoEntry); } catch (Exception) { Err_message(Translation.WrongRequestWrongUser); } } else if (dlg.SelectedLabelText == Translation.AddWatchLater) { PlayListMember pm = new PlayListMember(); pm.Id = videoEntry.VideoId; Youtube2MP.request.Insert(new Uri("https://gdata.youtube.com/feeds/api/users/default/watch_later"), pm); } else if (dlg.SelectedLabelText == Translation.Info) { YoutubeGuiInfoEx scr = (YoutubeGuiInfoEx)GUIWindowManager.GetWindow(29053); scr.YouTubeEntry = videoEntry; //if (entry!=null) //{ // ArtistItem artistItem=ent //} GUIWindowManager.ActivateWindow(29053); } else if (dlg.SelectedLabelText == Translation.PlayNext) { PlayNext(videoEntry); } }
private static void ThreadEncodeTrack() { m_Ripping = true; try { CreateTempFolder(); if (mp3Background) { GUIWaitCursor.Show(); } else if (dlgProgress != null) { dlgProgress.Reset(); dlgProgress.SetPercentage(0); dlgProgress.StartModal(GetID); dlgProgress.Progress(); dlgProgress.ShowProgressBar(true); } while (importQueue.Count > 0) { TrackInfo trackInfo = (TrackInfo)importQueue.Dequeue(); if ((dlgProgress != null) && !mp3Background) { if (importQueue.Count > 0) { dlgProgress.SetHeading( string.Format(GUILocalizeStrings.Get(1105) + " ({0} " + GUILocalizeStrings.Get(1104) + ")", importQueue.Count + 1)); } else { dlgProgress.SetHeading(GUILocalizeStrings.Get(1103)); } dlgProgress.SetLine(2, string.Format("{0:00}. {1} - {2}", trackInfo.MusicTag.Track, trackInfo.MusicTag.Artist, trackInfo.MusicTag.Title)); //dlgProgress.SetLine(2, trackInfo.TempFileName); if (dlgProgress.IsCanceled) { m_CancelRipping = true; } } if (!m_CancelRipping) { m_Drive = new CDDrive(); SaveTrack(trackInfo); if (File.Exists(trackInfo.TempFileName) && !m_CancelRipping) { #region Tagging try { Tags tags = Tags.FromFile(trackInfo.TempFileName); tags["TRCK"] = trackInfo.MusicTag.Track.ToString() + "/" + trackInfo.TrackCount.ToString(); tags["TALB"] = trackInfo.MusicTag.Album; tags["TPE1"] = trackInfo.MusicTag.Artist; tags["TIT2"] = trackInfo.MusicTag.Title; tags["TCON"] = trackInfo.MusicTag.Genre; if (trackInfo.MusicTag.Year > 0) { tags["TYER"] = trackInfo.MusicTag.Year.ToString(); } tags["TENC"] = "MediaPortal / Lame"; tags.Save(trackInfo.TempFileName); } catch { } #endregion #region Database try { if (!Directory.Exists(trackInfo.TargetDir)) { Directory.CreateDirectory(trackInfo.TargetDir); } if (File.Exists(trackInfo.TargetFileName)) { if (mp3ReplaceExisting) { File.Delete(trackInfo.TargetFileName); } } if (!File.Exists(trackInfo.TargetFileName)) { File.Move(trackInfo.TempFileName, trackInfo.TargetFileName); } if (File.Exists(trackInfo.TargetFileName) && mp3Database) { if (importUnknown || (trackInfo.MusicTag.Artist != "Unknown Artist") || (trackInfo.MusicTag.Album != "Unknown Album")) { MusicDatabase dbs = MusicDatabase.Instance; dbs.AddSong(trackInfo.TargetFileName); } } } catch { Log.Info("CDIMP: Error moving encoded file {0} to new location {1}", trackInfo.TempFileName, trackInfo.TargetFileName); } #endregion } } } if (mp3Background) { GUIWaitCursor.Hide(); } else { dlgProgress.Close(); } } finally { CleanupTempFolder(); } m_CancelRipping = false; m_Ripping = false; }
private static bool WakeupSystem(byte[] hwAddress, string wakeupTarget, int timeout) { int waited = 0; WakeOnLanManager wakeOnLanManager = new WakeOnLanManager(); Log.Debug("WOLMgr: Ping {0}", wakeupTarget); if (wakeOnLanManager.Ping(wakeupTarget, 200)) { Log.Debug("WOLMgr: {0} already started", wakeupTarget); return(true); } GUIDialogProgress progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow(101); //(int)Window.WINDOW_DIALOG_PROGRESS progressDialog.Reset(); progressDialog.SetHeading(GUILocalizeStrings.Get(1990)); progressDialog.ShowProgressBar(true); progressDialog.SetLine(1, GUILocalizeStrings.Get(1991)); progressDialog.StartModal(GUIWindowManager.ActiveWindow); // First, try to send WOL Packet if (!wakeOnLanManager.SendWakeOnLanPacket(hwAddress, IPAddress.Broadcast)) { Log.Debug("WOLMgr: FAILED to send the first wake-on-lan packet!"); } while (waited < timeout) { int percentange = (waited * 100) / timeout; progressDialog.SetPercentage(percentange); progressDialog.Progress(); Log.Debug("WOLMgr: Ping {0}", wakeupTarget); if (wakeOnLanManager.Ping(wakeupTarget, 200)) { progressDialog.SetPercentage(100); progressDialog.Progress(); progressDialog.Close(); int waittime; using (Settings xmlreader = new MPSettings()) { waittime = xmlreader.GetValueAsInt("WOL", "WaitTimeAfterWOL", 0); } if (waittime > 0) { GUIDialogProgress progressDialog2 = (GUIDialogProgress)GUIWindowManager.GetWindow(101); //(int)Window.WINDOW_DIALOG_PROGRESS progressDialog2.Reset(); progressDialog2.SetHeading(string.Empty); progressDialog2.ShowProgressBar(true); progressDialog2.SetLine(1, GUILocalizeStrings.Get(1994)); progressDialog2.StartModal(GUIWindowManager.ActiveWindow); waited = waittime; for (int i = waited; waited != 0; waited--) { percentange = (waited * 100) / waittime; progressDialog2.SetPercentage(percentange); progressDialog2.Progress(); System.Threading.Thread.Sleep(1000); } progressDialog2.SetPercentage(0); progressDialog2.Progress(); progressDialog2.Close(); } return(true); } // Send WOL Packet if (!wakeOnLanManager.SendWakeOnLanPacket(hwAddress, IPAddress.Broadcast)) { Log.Debug("WOLMgr: Sending the wake-on-lan packet failed (local network maybe not ready)! {0}s", waited); } Log.Debug("WOLMgr: System {0} still not reachable, waiting... {1}s", wakeupTarget, waited); System.Threading.Thread.Sleep(1000); waited++; } // Timeout was reached and WOL packet can't be send (we stop here) Log.Debug("WOLMgr: FAILED to send wake-on-lan packet after the timeout {0}, try increase the value!", timeout); progressDialog.SetPercentage(100); progressDialog.Progress(); progressDialog.Close(); GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(GUILocalizeStrings.Get(1992)); // Not available dlgOk.SetLine(1, GUILocalizeStrings.Get(1993)); dlgOk.DoModal(GUIWindowManager.ActiveWindow); return(false); }