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); } }
/// <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; } }
public void GetAlbumCovers(string artist, string album, string strPath, int parentWindowID, bool checkForCompilationAlbum) { _SelectedAlbum = null; IsCompilationAlbum = false; if (checkForCompilationAlbum) { IsCompilationAlbum = GetIsCompilationAlbum(strPath, -1); } _Artist = artist; _Album = album; _AlbumPath = strPath; string origAlbumName = _Album; string filteredAlbumFormatString = GUILocalizeStrings.Get(4518); if (filteredAlbumFormatString.Length == 0) { filteredAlbumFormatString = "Album title not found\r\nTrying: {0}"; } _ThumbPath = GetCoverArtThumbPath(artist, album, strPath); amazonWS = new AmazonWebservice(); amazonWS.MaxSearchResultItems = MAX_SEARCH_ITEMS; amazonWS.FindCoverArtProgress += new AmazonWebservice.FindCoverArtProgressHandler(amazonWS_GetAlbumInfoProgress); amazonWS.FindCoverArtDone += new AmazonWebservice.FindCoverArtDoneHandler(amazonWS_FindCoverArtDone); Log.Info("Cover art grabber:getting cover art for [{0}-{1}]...", _Artist, _Album); if (IsCompilationAlbum) { Log.Info("Cover art grabber:compilation album found", _Artist, _Album); amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; _Artist = ""; string filterString = string.Format("{0} = \"{1}\"", GUILocalizeStrings.Get(484), " "); string filter = string.Format(filteredAlbumFormatString, filterString); Log.Info("Cover art grabber:trying again with blank artist name..."); InternalGetAlbumCovers(_Artist, _Album, filter); } else { InternalGetAlbumCovers(_Artist, _Album, string.Empty); } // Did we fail to find any albums? if (!amazonWS.HasAlbums && !amazonWS.AbortGrab) { // Check if the album title includes a disk number description that might // be altering the proper album title such as: White album (Disk 2) string cleanAlbumName = string.Empty; if (StripDiskNumberFromAlbumName(_Album, ref cleanAlbumName)) { amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; if (AlbumNotFoundRetryingFiltered != null) { AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, cleanAlbumName); } Log.Info("Cover art grabber:[{0}-{1}] not found. Trying [{0}-{2}]...", _Artist, _Album, cleanAlbumName); string filter = string.Format(filteredAlbumFormatString, cleanAlbumName); origAlbumName = _Album; InternalGetAlbumCovers(_Artist, cleanAlbumName, filter); } else if (GetProperAlbumName(_Album, ref cleanAlbumName)) { amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; if (AlbumNotFoundRetryingFiltered != null) { AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, cleanAlbumName); } Log.Info("Cover art grabber:[{0}-{1}] not found. Trying album name without sub-title [{0}-{2}]...", _Artist, _Album, cleanAlbumName); string filter = string.Format(filteredAlbumFormatString, cleanAlbumName); origAlbumName = _Album; InternalGetAlbumCovers(_Artist, cleanAlbumName, filter); } } // Still no albums? if (!IsCompilationAlbum && !amazonWS.HasAlbums && !amazonWS.AbortGrab) { amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; if (AlbumNotFoundRetryingFiltered != null) { AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, GUILocalizeStrings.Get(4506)); } string filterString = string.Format("{0} = \"{1}\"", GUILocalizeStrings.Get(483), " "); string filter = string.Format(filteredAlbumFormatString, filterString); // Try searching by artist only to get all albums for this artist... Log.Info("Cover art grabber:[{0}-{1}] not found. Trying again with blank album name...", _Artist, _Album); InternalGetAlbumCovers(_Artist, "", filter); } // if we're searching for a single album the progress dialog will // be displayed so we need to close it... if (SearchMode == SearchDepthMode.Album) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.SetPercentage(100); dlgProgress.Progress(); dlgProgress.Close(); } } amazonWS.FindCoverArtProgress -= new AmazonWebservice.FindCoverArtProgressHandler(amazonWS_GetAlbumInfoProgress); amazonWS.FindCoverArtDone -= new AmazonWebservice.FindCoverArtDoneHandler(amazonWS_FindCoverArtDone); }
public List <string> deleteSeason(TVSeriesPlugin.DeleteMenuItems type) { List <string> resultMsg = new List <string>(); // Always delete from Local episode table if deleting from disk or database SQLCondition condition = new SQLCondition(); condition.Add(new DBEpisode(), DBEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); condition.Add(new DBEpisode(), DBEpisode.cSeasonIndex, this[DBSeason.cIndex], SQLConditionType.Equal); /* TODO will include hidden episodes as hidden attribute is only in onlineepisodes. maybe we should include it in localepisodes also.. * if hidden episodes are excluded then the if (resultMsg.Count is wrong and should do another select to get proper count * if (!DBOption.GetOptions(DBOption.cShowHiddenItems)) * { * //don't include hidden seasons unless the ShowHiddenItems option is set * condition.Add(new DBEpisode(), idden, 0, SQLConditionType.Equal); * } */ List <DBEpisode> episodes = DBEpisode.Get(condition, false); if (episodes != null) { bool hasLocalEpisodesToDelete = episodes.Exists(e => !string.IsNullOrEmpty(e[DBEpisode.cFilename])); hasLocalEpisodesToDelete &= (type == TVSeriesPlugin.DeleteMenuItems.disk || type == TVSeriesPlugin.DeleteMenuItems.diskdatabase); DBSeries series = Helper.getCorrespondingSeries(this[DBSeason.cSeriesID]); string seriesName = series == null ? this[DBSeason.cSeriesID].ToString() : series.ToString(); // show progress dialog as this can be a long process esp for network drives // will show new progress for each season if deleting from the series level GUIDialogProgress progressDialog = null; if (!Settings.isConfig) { progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); progressDialog.Reset(); progressDialog.DisplayProgressBar = true; progressDialog.ShowWaitCursor = false; progressDialog.DisableCancel(true); progressDialog.SetHeading(Translation.Delete); progressDialog.Percentage = 0; progressDialog.SetLine(1, string.Format("{0} {1} {2}", seriesName, Translation.Season, this[DBSeason.cIndex])); progressDialog.SetLine(2, string.Empty); // only show progress dialog if we have local files in season if (hasLocalEpisodesToDelete) { progressDialog.StartModal(GUIWindowManager.ActiveWindow); } } int counter = 0; foreach (DBEpisode episode in episodes) { string episodeName = string.Format("{0}x{1} - {2}", episode[DBOnlineEpisode.cSeasonIndex], episode[DBOnlineEpisode.cEpisodeIndex], episode[DBOnlineEpisode.cEpisodeName]); if (!Settings.isConfig) { progressDialog.SetLine(2, episodeName); } if (!Settings.isConfig) { GUIWindowManager.Process(); } resultMsg.AddRange(episode.deleteEpisode(type, true)); if (!Settings.isConfig) { progressDialog.Percentage = Convert.ToInt32(((double)++counter / (double)episodes.Count) * 100.0); } if (!Settings.isConfig) { GUIWindowManager.Process(); } } // close progress dialog if (!Settings.isConfig) { progressDialog.Close(); } // if we have removed all episodes in season without error, cleanup the online table if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.disk) { condition = new SQLCondition(); condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeasonIndex, this[DBSeason.cIndex], SQLConditionType.Equal); DBOnlineEpisode.Clear(condition); } } #region Facade Remote Color // if we were successful at deleting all episodes of season from disk, set HasLocalFiles to false // note: we only do this if the database entries still exist if (resultMsg.Count == 0 && type == TVSeriesPlugin.DeleteMenuItems.disk) { this[cHasLocalFiles] = false; this.Commit(); } // if we were successful at deleting all episodes of season from disk, // also check if any local episodes exist on disk for series and set HasLocalFiles to false if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.database) { // Check Series for Local Files SQLCondition episodeConditions = new SQLCondition(); episodeConditions.Add(new DBEpisode(), DBEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); List <DBEpisode> localEpisodes = DBEpisode.Get(episodeConditions); if (localEpisodes.Count == 0 && !DBSeries.IsSeriesRemoved) { DBSeries series = DBSeries.Get(this[DBSeason.cSeriesID]); if (series != null) { series[DBOnlineSeries.cHasLocalFiles] = false; series.Commit(); } } } #endregion #region Cleanup // if there are no error messages and if we need to delete from db if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.disk) { condition = new SQLCondition(); condition.Add(new DBSeason(), DBSeason.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); condition.Add(new DBSeason(), DBSeason.cIndex, this[DBSeason.cIndex], SQLConditionType.Equal); DBSeason.Clear(condition); } DBSeries.IsSeriesRemoved = false; if (type != TVSeriesPlugin.DeleteMenuItems.disk) { // If local/online episode count is zero then delete the series and all seasons condition = new SQLCondition(); condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); episodes = DBEpisode.Get(condition, false); if (episodes.Count == 0) { // Delete Seasons condition = new SQLCondition(); condition.Add(new DBSeason(), DBSeason.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); DBSeason.Clear(condition); // Delete Local Series condition = new SQLCondition(); condition.Add(new DBSeries(), DBSeries.cID, this[DBSeason.cSeriesID], SQLConditionType.Equal); DBSeries.Clear(condition); // Delete Online Series condition = new SQLCondition(); condition.Add(new DBOnlineSeries(), DBOnlineSeries.cID, this[DBSeason.cSeriesID], SQLConditionType.Equal); DBOnlineSeries.Clear(condition); DBSeries.IsSeriesRemoved = true; } } #endregion return(resultMsg); }
void DoSubsequentLoad() { if (PreviousWindowId != OnlineVideos.MediaPortal1.Player.GUIOnlineVideoFullscreen.WINDOW_FULLSCREEN_ONLINEVIDEO && PluginConfiguration.Instance.updateOnStart != false && PluginConfiguration.Instance.lastFirstRun.AddHours(PluginConfiguration.Instance.updatePeriod) < DateTime.Now) { bool?doUpdate = PluginConfiguration.Instance.updateOnStart; if (!PluginConfiguration.Instance.updateOnStart.HasValue && !preventDialogOnLoad) { GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, Translation.Instance.PerformAutomaticUpdate); dlg.SetLine(2, Translation.Instance.UpdateAllYourSites); dlg.DoModal(GUIWindowManager.ActiveWindow); doUpdate = dlg.IsConfirmed; } } PluginConfiguration.Instance.lastFirstRun = DateTime.Now; if (doUpdate == true || PluginConfiguration.Instance.ThumbsAge >= 0) { GUIDialogProgress dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); if (dlgPrgrs != null) { dlgPrgrs.Reset(); dlgPrgrs.DisplayProgressBar = true; dlgPrgrs.ShowWaitCursor = false; dlgPrgrs.DisableCancel(true); dlgPrgrs.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow); } else { GUIWaitCursor.Init(); GUIWaitCursor.Show(); } new System.Threading.Thread(delegate() { if (doUpdate == true) { if (dlgPrgrs != null) { dlgPrgrs.SetHeading(string.Format("{0} - {1}", PluginConfiguration.Instance.BasicHomeScreenName, Translation.Instance.AutomaticUpdate)); } var onlineVersion = Sites.Updater.VersionOnline; if (OnlineVideos.Sites.Updater.VersionCompatible) { bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) => { if (dlgPrgrs != null) { if (!string.IsNullOrEmpty(m)) { dlgPrgrs.SetLine(1, m); } if (p != null) { dlgPrgrs.SetPercentage(p.Value); } return(dlgPrgrs.ShouldRenderLayer()); } else { return(true); } } ); if (updateResult == true && OnlineVideoSettings.Instance.SiteUtilsList.Count > 0) { GUISiteUpdater.ReloadDownloadedDlls(); } else if (updateResult == null || OnlineVideoSettings.Instance.SiteUtilsList.Count > 0) { OnlineVideoSettings.Instance.BuildSiteUtilsList(); } if (updateResult != false) { PluginConfiguration.Instance.BuildAutomaticSitesGroups(); SiteImageExistenceCache.ClearCache(); } } else { // inform the user that autoupdate is disabled due to outdated version! dlgPrgrs.SetLine(1, Translation.Instance.AutomaticUpdateDisabled); dlgPrgrs.SetLine(2, onlineVersion != null ? string.Format(Translation.Instance.LatestVersionRequired, onlineVersion) : "Check your Internet Connection!"); Thread.Sleep(5000); dlgPrgrs.SetLine(2, string.Empty); } } if (PluginConfiguration.Instance.ThumbsAge >= 0) { if (dlgPrgrs != null) { dlgPrgrs.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlgPrgrs.SetLine(1, Translation.Instance.DeletingOldThumbs); dlgPrgrs.Percentage = 0; } ImageDownloader.DeleteOldThumbs(PluginConfiguration.Instance.ThumbsAge, r => { if (dlgPrgrs != null) { dlgPrgrs.Percentage = r; } return(dlgPrgrs != null ? dlgPrgrs.ShouldRenderLayer() : true); }); } if (dlgPrgrs != null) { dlgPrgrs.Percentage = 100; dlgPrgrs.SetLine(1, Translation.Instance.Done); dlgPrgrs.Close(); } else { GUIWaitCursor.Hide(); } GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { DoPageLoad(); return(0); }, 0, 0, null); }) { Name = "OVLoad", IsBackground = true }.Start(); return; } } DoPageLoad(); }
public bool GetDialogInfo(GUIWindow.Window dialogWindow, ref string DialogTitle, ref string DialogHighlightedItem) { GUIListControl control = null; bool focus = false; switch (dialogWindow) { case GUIWindow.Window.WINDOW_DIALOG_YES_NO: case GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO: { GUIDialogYesNo window = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)dialogWindow); DialogTitle = string.Empty; foreach (object obj16 in window.controlList) { if (obj16.GetType() == typeof(GUIFadeLabel)) { GUIFadeLabel label3 = obj16 as GUIFadeLabel; if (DialogTitle == string.Empty) { if (label3.Label != string.Empty) { DialogTitle = label3.Label; } } else if (label3.Label != string.Empty) { DialogTitle = DialogTitle + " - " + label3.Label; } } if (obj16.GetType() == typeof(GUILabelControl)) { GUILabelControl control14 = obj16 as GUILabelControl; if (DialogTitle == string.Empty) { if (control14.Label != string.Empty) { DialogTitle = control14.Label; } } else if (control14.Label != string.Empty) { DialogTitle = DialogTitle + " - " + control14.Label; } } if (obj16.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control15 = obj16 as GUIButtonControl; if (!control15.Focus) { continue; } DialogHighlightedItem = control15.Description; } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_PROGRESS: { GUIDialogProgress progress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)dialogWindow); foreach (object obj6 in progress.controlList) { if (obj6.GetType() == typeof(GUILabelControl)) { GUILabelControl control6 = obj6 as GUILabelControl; if (control6.GetID == 1) { DialogTitle = control6.Label; } } } foreach (object obj7 in progress.controlList) { if (obj7.GetType() == typeof(GUIProgressControl)) { GUIProgressControl control7 = obj7 as GUIProgressControl; DialogHighlightedItem = "Progress: " + control7.Percentage.ToString() + "%"; } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_SELECT: { GUIDialogSelect select = (GUIDialogSelect)GUIWindowManager.GetWindow((int)dialogWindow); control = null; focus = false; foreach (object obj9 in select.controlList) { if (obj9.GetType() == typeof(GUIListControl)) { control = obj9 as GUIListControl; focus = control.Focus; } } if ((control != null) & focus) { string strLabel = string.Empty; string str5 = string.Empty; string strThumb = string.Empty; string strIndex = string.Empty; control.GetSelectedItem(ref strLabel, ref str5, ref strThumb, ref strIndex); DialogHighlightedItem = strLabel; } else { foreach (object obj10 in select.controlList) { if (obj10.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control10 = obj10 as GUIButtonControl; if (control10.Focus) { DialogHighlightedItem = control10.Description; } } } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_OK: { GUIDialogOK gok = (GUIDialogOK)GUIWindowManager.GetWindow((int)dialogWindow); foreach (object obj5 in gok.controlList) { if (obj5.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control4 = obj5 as GUIButtonControl; if (control4.Focus) { DialogHighlightedItem = control4.Description; Settings.Instance.LogInfo( "MiniDisplay.GetDialogInfo(): found WINDOW_DIALOG_OK buttoncontrol ID = {0} Label = \"{1}\" Desc = \"{2}\"", control4.GetID, control4.Label, control4.Description); } } if (obj5.GetType() == typeof(GUIFadeLabel)) { GUIFadeLabel label = obj5 as GUIFadeLabel; if (DialogTitle == string.Empty) { if (label.Label != string.Empty) { DialogTitle = label.Label; } } else if (label.Label != string.Empty) { DialogTitle = DialogTitle + " - " + label.Label; } } if (obj5.GetType() == typeof(GUILabelControl)) { GUILabelControl control5 = obj5 as GUILabelControl; if (DialogTitle == string.Empty) { if (control5.Label != string.Empty) { DialogTitle = control5.Label; } continue; } if (control5.Label != string.Empty) { DialogTitle = DialogTitle + " - " + control5.Label; } } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_SELECT2: { GUIDialogSelect2 select2 = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)dialogWindow); control = null; focus = false; foreach (object obj11 in select2.controlList) { if (obj11.GetType() == typeof(GUIListControl)) { control = obj11 as GUIListControl; focus = control.Focus; } } if ((control != null) & focus) { string str7 = string.Empty; string str8 = string.Empty; string str9 = string.Empty; string strIndex = string.Empty; control.GetSelectedItem(ref str7, ref str8, ref str9, ref strIndex); DialogHighlightedItem = str7; } else { foreach (object obj12 in select2.controlList) { if (obj12.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control11 = obj12 as GUIButtonControl; if (control11.Focus) { DialogHighlightedItem = control11.Description; } } } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_MENU: { GUIDialogMenu menu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)dialogWindow); foreach (object obj13 in menu.controlList) { if (obj13.GetType() == typeof(GUILabelControl)) { GUILabelControl control12 = obj13 as GUILabelControl; if (!control12.Label.Trim().ToLowerInvariant().Equals("menu")) { DialogTitle = control12.Label; } } } control = null; focus = false; foreach (object obj14 in menu.controlList) { if (obj14.GetType() == typeof(GUIListControl)) { control = obj14 as GUIListControl; focus = control.Focus; } } if ((control != null) & focus) { string str10 = string.Empty; string str11 = string.Empty; string str12 = string.Empty; string strIndex = string.Empty; control.GetSelectedItem(ref str10, ref str11, ref str12, ref strIndex); DialogHighlightedItem = str10; } else { foreach (object obj15 in menu.controlList) { if (obj15.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control13 = obj15 as GUIButtonControl; if (control13.Focus) { DialogHighlightedItem = control13.Description; } } } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_RATING: { GUIDialogSetRating rating = (GUIDialogSetRating)GUIWindowManager.GetWindow((int)dialogWindow); DialogTitle = string.Empty; foreach (object obj8 in rating.controlList) { if (obj8.GetType() == typeof(GUIFadeLabel)) { GUIFadeLabel label2 = obj8 as GUIFadeLabel; if (DialogTitle == string.Empty) { if (label2.Label != string.Empty) { DialogTitle = label2.Label; } } else if (label2.Label != string.Empty) { DialogTitle = DialogTitle + " - " + label2.Label; } } if (obj8.GetType() == typeof(GUILabelControl)) { GUILabelControl control8 = obj8 as GUILabelControl; if (DialogTitle == string.Empty) { if (control8.Label != string.Empty) { DialogTitle = control8.Label; } } else if (control8.Label != string.Empty) { DialogTitle = DialogTitle + " - " + control8.Label; } } if (obj8.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control9 = obj8 as GUIButtonControl; if (!control9.Focus) { continue; } DialogHighlightedItem = control9.Description; } } return(true); } case GUIWindow.Window.WINDOW_DIALOG_MENU_BOTTOM_RIGHT: { GUIDialogMenuBottomRight right = (GUIDialogMenuBottomRight)GUIWindowManager.GetWindow((int)dialogWindow); DialogTitle = string.Empty; foreach (object obj2 in right.controlList) { if (obj2.GetType() == typeof(GUILabelControl)) { GUILabelControl control2 = obj2 as GUILabelControl; if (!control2.Label.Trim().ToLowerInvariant().Equals("menu") && (control2.Label != string.Empty)) { if (DialogTitle == string.Empty) { DialogTitle = control2.Label; } else { DialogTitle = DialogTitle + " - " + control2.Label; } } } } control = null; focus = false; foreach (object obj3 in right.controlList) { if (obj3.GetType() == typeof(GUIListControl)) { control = obj3 as GUIListControl; focus = control.Focus; } } if ((control != null) & focus) { string str = string.Empty; string str2 = string.Empty; string str3 = string.Empty; string strIndex = string.Empty; control.GetSelectedItem(ref str, ref str2, ref str3, ref strIndex); DialogHighlightedItem = str; } else { foreach (object obj4 in right.controlList) { if (obj4.GetType() == typeof(GUIButtonControl)) { GUIButtonControl control3 = obj4 as GUIButtonControl; if (control3.Focus) { DialogHighlightedItem = control3.Description; } } } } return(true); } } return(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); }