/// <summary> /// Adds to favorites. /// </summary> /// <param name="p">The station id.</param> private void AddToFavorites(string presetid) { var tempresets = new List <RadioTimeOutline>(); var folderid = ""; var selectedID = ""; var tempGrabber = new RadioTime(); tempGrabber.Settings = _setting; tempGrabber.GetData(_setting.PresetsUrl, false, false, Translation.Presets); var folderCount = 0; foreach (var body in tempGrabber.Body) { if (body.Type == RadioTimeOutline.OutlineType.link) { folderCount++; } } if (folderCount == 0) // only one preset folder (main) - plugin chooses first empty space to put preset { // first i have to fill the list with taken preset numbers var takenPresets = new List <int>(); foreach (var body in tempGrabber.Body) { if (!string.IsNullOrEmpty(body.PresetNumber)) { takenPresets.Add(body.PresetNumberAsInt); } } var i = 1; while (takenPresets.Contains(i)) // find empty space { i++; } selectedID = i.ToString(); } else // more folders - ask user { var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(Translation.SelectPresetFolder); foreach (var body in tempGrabber.Body) { if (body.Type == RadioTimeOutline.OutlineType.link) { dlg.Add(body.Text); } } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } folderid = tempGrabber.Body[dlg.SelectedId - 1].GuidId; tempGrabber.GetData(tempGrabber.Body[dlg.SelectedId - 1].Url, false, false); // first i have to find out the largest preset number var biggestPresetNumber = 0; foreach (var body in tempGrabber.Body) { if (!string.IsNullOrEmpty(body.PresetNumber) && body.PresetNumberAsInt > biggestPresetNumber) { biggestPresetNumber = body.PresetNumberAsInt; } } // then i fill x number of presets for (var i = 0; i < (biggestPresetNumber + Settings.LocalPresetsNumber); i++) { tempresets.Add(new RadioTimeOutline()); } // then i fill the list with existing presets from the folder foreach (var body in tempGrabber.Body) { if (!string.IsNullOrEmpty(body.PresetNumber) && body.PresetNumberAsInt - 1 < tempresets.Count) { tempresets[body.PresetNumberAsInt - 1] = body; } } dlg.Reset(); dlg.SetHeading(Translation.SelectPresetNumber); for (var i = 0; i < tempresets.Count; i++) { var outline = tempresets[i]; if (string.IsNullOrEmpty(outline.Text)) { dlg.Add(string.Format("<{0}>", Translation.Empty)); } else { dlg.Add(outline.Text); } } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } selectedID = dlg.SelectedId.ToString(); } try { grabber.AddPreset(presetid, folderid, selectedID); //UpdateList(); } catch (Exception) { ErrMessage(Translation.ComunicationError); } }
public void ShowFileMenu(GUIListItem item) { m_bReload = false; string iPincodeCorrect; if (item == null) { return; } if (item.IsFolder && item.Label == "..") { return; } if (m_directory.IsProtectedShare(item.Path, out iPincodeCorrect)) { ShowErrorDialog(513, item.Path); Close(); return; } if (m_preselectDelete) { bool readOnly; if (Directory.Exists(item.Path)) { readOnly = CheckDirectoryReadOnlyAttributes(item.Path); } else { FileAttributes attributes = File.GetAttributes(item.Path); readOnly = ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly); } if (readOnly) { OnDeleteReadOnlyItem(item); } else { OnDeleteItem(item); } return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(500); // File menu sourceFolder = Path.GetDirectoryName(item.Path); if ((destinationFolder != "") && (destinationFolder != sourceFolder)) { dlg.AddLocalizedString(115); //copy if (!Util.Utils.IsDVD(item.Path)) { dlg.AddLocalizedString(116); //move } } if (!Util.Utils.IsDVD(item.Path)) { dlg.AddLocalizedString(118); //rename } if (!Util.Utils.IsDVD(item.Path)) { dlg.AddLocalizedString(117); //delete } if (!Util.Utils.IsDVD(item.Path)) { dlg.AddLocalizedString(119); //new folder } if (item.IsFolder && !Util.Utils.IsDVD(item.Path)) { dlg.AddLocalizedString(501); // Set as destination } if (destinationFolder != "") { dlg.AddLocalizedString(504); // Goto destination } dlg.DoModal(m_dwParentWindowID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedId) { case 117: // delete bool readOnly; if (Directory.Exists(item.Path)) { readOnly = CheckDirectoryReadOnlyAttributes(item.Path); } else { FileAttributes attributes = File.GetAttributes(item.Path); readOnly = ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly); } if (readOnly) { OnDeleteReadOnlyItem(item); } else { OnDeleteItem(item); } break; case 118: // rename { string strSourceName = ""; string strExtension = Path.GetExtension(item.Path); if (item.IsFolder && !VirtualDirectory.IsImageFile(strExtension)) { strSourceName = Path.GetFileName(item.Path); } else { strSourceName = Path.GetFileNameWithoutExtension(item.Path); } string strDestinationName = strSourceName; if (GetUserInputString(ref strDestinationName) == true) { if (item.IsFolder && !VirtualDirectory.IsImageFile(strExtension)) { // directory rename if (Directory.Exists(sourceFolder + "\\" + strSourceName)) { try { Directory.Move(sourceFolder + "\\" + strSourceName, sourceFolder + "\\" + strDestinationName); } catch (Exception) { ShowErrorDialog(dlg.SelectedId, sourceFolder + "\\" + strSourceName); } m_bReload = true; } } else { // file rename if (File.Exists(item.Path)) { string strDestinationFile = sourceFolder + "\\" + strDestinationName + strExtension; try { File.Move(item.Path, strDestinationFile); } catch (Exception) { ShowErrorDialog(dlg.SelectedId, sourceFolder + "\\" + strSourceName); } m_bReload = true; } } } } break; case 115: // copy { SetMode(0); // copy FileItemDialog(); } break; case 116: // move { SetMode(1); // move FileItemDialog(); m_bReload = true; } break; case 119: // make dir { MakeDir(); m_bReload = true; } break; case 501: // set as destiantion destinationFolder = Path.GetFullPath(item.Path) + "\\"; break; case 504: // goto destination { sourceFolder = destinationFolder; m_bReload = true; } break; } }
private void AddLocation() { string city = ""; if (!GetKeyboard(ref city) || String.IsNullOrEmpty(city)) { return; } try { // Perform actual search WeatherChannel weather = new WeatherChannel(); ArrayList cities = weather.SearchCity(city); if (cities.Count <= 0) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.SetHeading(8); dlg.SetLine(1, 412); dlg.SetLine(2, ""); dlg.DoModal(GetID); return; } GUIDialogMenu dialogCitySelect = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dialogCitySelect != null) { dialogCitySelect.Reset(); dialogCitySelect.ShowQuickNumbers = false; dialogCitySelect.SetHeading(396); // Select Location foreach (WeatherChannel.City _city in cities) { dialogCitySelect.Add(_city.Name + " (" + _city.Id + ")"); } dialogCitySelect.DoModal(GetID); if (dialogCitySelect.SelectedLabel >= 0) { WeatherChannel.City newcity = (WeatherChannel.City)cities[dialogCitySelect.SelectedLabel]; LocationInfo loc = new LocationInfo(); loc.City = newcity.Name; loc.CityCode = newcity.Id; loc.UrlSattelite = ""; loc.UrlTemperature = ""; loc.UrlUvIndex = ""; loc.UrlWinds = ""; loc.UrlHumidity = ""; loc.UrlPrecip = ""; availableLocations.Add(loc); SaveLocations(); SetDefaultLocation(); // Reset the default location as necessary InitDefaultLocation(); // Refresh default location button as necessary } } } catch (Exception ex) { Log.Error("MyWeather settings error: {0}", ex.ToString()); } }
protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) { return; } var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem; if (selectedItem == null) { return; } var selectedMovie = selectedItem.TVTag as TraktMovieSummary; if (selectedMovie == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Mark As Watched if (!selectedMovie.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (selectedMovie.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } // Add/Remove Watchlist if (!selectedMovie.IsWatchlisted()) { listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } else { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } // Add to Custom list listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Add to Library // Don't allow if it will be removed again on next sync // movie could be part of a DVD collection if (!selectedMovie.IsCollected() && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedMovie.IsCollected()) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } // Related Movies listItem = new GUIListItem(Translation.RelatedMovies); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Movie listItem = new GUIListItem(Translation.RateMovie); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Cast and Crew listItem = new GUIListItem(Translation.Cast); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Cast; listItem = new GUIListItem(Translation.Crew); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Crew; // Trailers if (TraktHelper.IsTrailersAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (!selectedMovie.IsCollected() && TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for movie with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (!selectedMovie.IsCollected() && TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for movie with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.MarkAsWatched): TraktHelper.AddMovieToWatchHistory(selectedMovie); selectedItem.IsPlayed = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveMovieFromWatchHistory(selectedMovie); selectedItem.IsPlayed = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddMovieToWatchList(selectedMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveMovieFromWatchList(selectedMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveMovieInUserList(selectedMovie, false); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddMovieToCollection(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromCollection(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.Related): TraktHelper.ShowRelatedMovies(selectedMovie); break; case ((int)ContextMenuItem.Rate): GUICommon.RateMovie(selectedMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowMovieShouts(selectedMovie); break; case ((int)ContextMenuItem.Cast): GUICreditsMovie.Movie = selectedMovie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)ContextMenuItem.Crew): GUICreditsMovie.Movie = selectedMovie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowMovieTrailersMenu(selectedMovie); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedMovie.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = selectedMovie.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
private void OnGlobalMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_NOTIFY: ShowNotify(message.Label, message.Label2, message.Label3); break; case GUIMessage.MessageType.GUI_MSG_ASKYESNO: string Head = "", Line1 = "", Line2 = "", Line3 = "", Line4 = ""; bool DefaultYes = false; if (message.Param1 != 0) { Head = GUILocalizeStrings.Get(message.Param1); } else if (message.Label != string.Empty) { Head = message.Label; } if (message.Param2 != 0) { Line1 = GUILocalizeStrings.Get(message.Param2); } else if (message.Label2 != string.Empty) { Line1 = message.Label2; } if (message.Param3 != 0) { Line2 = GUILocalizeStrings.Get(message.Param3); } else if (message.Label3 != string.Empty) { Line2 = message.Label3; } if (message.Param4 != 0) { Line3 = GUILocalizeStrings.Get(message.Param4); } else if (message.Label4 != string.Empty) { Line3 = message.Label4; } if (message.Object != null && message.Object is int && (int)message.Object != 0) { Line4 = GUILocalizeStrings.Get((int)message.Object); } else if (message.Object != null && message.Object is string && (string)message.Object != string.Empty) { Line4 = (string)message.Object; } if (message.Object2 != null && message.Object2 is bool) { DefaultYes = (bool)message.Object2; } if (AskYesNo(Head, Line1, Line2, Line3, Line4, DefaultYes)) { message.Param1 = 1; } else { message.Param1 = 0; } break; case GUIMessage.MessageType.GUI_MSG_SHOW_WARNING: { string strHead = "", strLine1 = "", strLine2 = ""; if (message.Param1 != 0) { strHead = GUILocalizeStrings.Get(message.Param1); } else if (message.Label != string.Empty) { strHead = message.Label; } if (message.Param2 != 0) { strLine1 = GUILocalizeStrings.Get(message.Param2); } else if (message.Label2 != string.Empty) { strLine2 = message.Label2; } if (message.Param3 != 0) { strLine2 = GUILocalizeStrings.Get(message.Param3); } else if (message.Label3 != string.Empty) { strLine2 = message.Label3; } ShowInfo(strHead, strLine1, strLine2); } break; case GUIMessage.MessageType.GUI_MSG_GET_STRING: VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD); if (null == keyboard) { return; } keyboard.Reset(); keyboard.Text = message.Label; keyboard.DoModal(GUIWindowManager.ActiveWindow); if (keyboard.IsConfirmed) { message.Label = keyboard.Text; } else { message.Label = ""; } break; case GUIMessage.MessageType.GUI_MSG_GET_PASSWORD: VirtualKeyboard keyboard2 = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD); if (null == keyboard2) { return; } keyboard2.Reset(); keyboard2.Password = true; keyboard2.Text = message.Label; keyboard2.DoModal(GUIWindowManager.ActiveWindow); if (keyboard2.IsConfirmed) { message.Label = keyboard2.Text; } else { message.Label = ""; } break; case GUIMessage.MessageType.GUI_MSG_WRONG_PASSWORD: using (Profile.Settings xmlreader = new Profile.MPSettings() ) { if (!xmlreader.GetValueAsBool("general", "hidewrongpin", false)) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo == null) { return; } dlgYesNo.SetHeading(771); // The entered PIN could not be accepted dlgYesNo.SetLine(1, 772); // Do you want to try again? dlgYesNo.SetDefaultToYes(true); dlgYesNo.DoModal(GetID); message.Object = dlgYesNo.IsConfirmed; } else { message.Object = false; } } break; } }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem as GUIShowListItem; if (selectedItem == null) { return; } var selectedAnticipatedItem = selectedItem.TVTag as TraktShowAnticipated; if (selectedAnticipatedItem == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUICommon.CreateShowsContextMenu(ref dlg, selectedAnticipatedItem.Show, false); // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)MediaContextMenuItem.AddToWatchList): TraktHelper.AddShowToWatchList(selectedAnticipatedItem.Show); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.AnticipatedShowsHideWatchlisted) { LoadAnticipatedShows(CurrentPage); } break; case ((int)MediaContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedAnticipatedItem.Show.ToJSON()); break; case ((int)MediaContextMenuItem.MarkAsWatched): GUICommon.MarkShowAsWatched(selectedAnticipatedItem.Show); LoadAnticipatedShows(CurrentPage); break; case ((int)MediaContextMenuItem.AddToLibrary): GUICommon.AddShowToCollection(selectedAnticipatedItem.Show); LoadAnticipatedShows(CurrentPage); break; case ((int)MediaContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveShowFromWatchList(selectedAnticipatedItem.Show); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.AddToList): TraktHelper.AddRemoveShowInUserList(selectedAnticipatedItem.Show, false); break; case ((int)MediaContextMenuItem.Filters): if (GUICommon.ShowTVShowFiltersMenu()) { PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; UpdateButtonState(); LoadAnticipatedShows(CurrentPage); } break; case ((int)MediaContextMenuItem.Related): TraktHelper.ShowRelatedShows(selectedAnticipatedItem.Show); break; case ((int)MediaContextMenuItem.Cast): GUICreditsShow.Show = selectedAnticipatedItem.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Cast; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); break; case ((int)MediaContextMenuItem.Crew): GUICreditsShow.Show = selectedAnticipatedItem.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Crew; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename(selectedItem.Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); break; case ((int)MediaContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedAnticipatedItem.Show); break; case ((int)MediaContextMenuItem.Shouts): TraktHelper.ShowTVShowShouts(selectedAnticipatedItem.Show); break; case ((int)MediaContextMenuItem.Rate): GUICommon.RateShow(selectedAnticipatedItem.Show); OnShowSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIShowListItem).Images.NotifyPropertyChanged("Poster"); LoadAnticipatedShows(CurrentPage); break; case ((int)MediaContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)MediaContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedAnticipatedItem.Show.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)MediaContextMenuItem.SearchTorrent): string loadPar = selectedAnticipatedItem.Show.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
public void ContextMenu(object info) { WatchItem watch = info as WatchItem; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading("Torrent watchlist"); dlg.Add("Add Series"); dlg.Add("Search Series"); dlg.Add("Add Movie"); dlg.Add("Add custom"); dlg.Add("Manual Search"); dlg.Add("Remove selected"); dlg.Add("Clear list"); dlg.Add("Force RSS update"); dlg.DoModal(GUIWindowManager.ActiveWindow); switch (dlg.SelectedLabelText) { case "Add Series": { AddSeries(); MyTorrents.Instance().ShowTorrentWatch(); break; } case "Search Series": { SearchSeries(); } break; case "Add Movie": break; case "Manual Search": MyTorrents.Instance()._torrentWatchlist.SearchTorrent(); break; case "Add custom": { VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD); keyboard.Reset(); keyboard.Text = ""; keyboard.DoModal(GUIWindowManager.ActiveWindow); if (!keyboard.IsConfirmed) { return; } watch = new WatchItem(); watch.SearchTerm = keyboard.Text; TorrentLabel label = DialogAskLabel.Ask(); if (label != null) { watch.Label = label.Name; MyTorrents.Instance()._torrentWatchlist.AddWatch(watch); Log.Instance().Print(String.Format("Watch [{0}] added.", watch.SearchTerm)); } break; } case "Clear list": { MyTorrents.Instance()._torrentWatchlist.Clear(); break; } case "Remove selected": { MyTorrents.Instance()._torrentWatchlist.RemoveWatch(watch); // torrentList.RemoveItem(torrentList.SelectedListItemIndex); break; } case "Force RSS update": { RSSChannelManager.Instance().UpdateChannels(true); break; } } MyTorrents.Instance().ShowTorrentWatch(); }
public string ShowSelectDriveDialog(int parentId, bool DVDonly) { Log.Info("SelectDVDHandler: ShowSelectDVDDialog()"); //check if dvd is inserted List <GUIListItem> rootDrives = VirtualDirectories.Instance.Movies.GetRootExt(); for (int i = rootDrives.Count - 1; i >= 0; i--) { GUIListItem item = (GUIListItem)rootDrives[i]; if (Util.Utils.getDriveType(item.Path) == 5) //cd or dvd drive { string driverLetter = item.Path.Substring(0, 1); string fileName = DVDonly ? String.Format(@"{0}:\VIDEO_TS\VIDEO_TS.IFO", driverLetter) : String.Format(@"{0}:\", driverLetter); if (DVDonly && !File.Exists(fileName)) { rootDrives.RemoveAt(i); } else if (!DVDonly && !Directory.Exists(fileName)) { rootDrives.RemoveAt(i); } } else { rootDrives.RemoveAt(i); } } if (rootDrives.Count > 0) { try { if (rootDrives.Count == 1) { GUIListItem ritem = (GUIListItem)rootDrives[0]; return(ritem.Path); // Only one DVD available, play it! } SetIMDBThumbs(rootDrives, false); // Display a dialog with all drives to select from GUIDialogSelect2 dlgSel = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_SELECT2); if (null == dlgSel) { Log.Info("SelectDVDHandler: Could not open dialog, defaulting to first drive found"); GUIListItem ritem = (GUIListItem)rootDrives[0]; return(ritem.Path); } dlgSel.Reset(); dlgSel.SetHeading(DVDonly ? 196 : 2201); // Choose movie | select source for (int i = 0; i < rootDrives.Count; i++) { GUIListItem dlgItem = new GUIListItem(); dlgItem = (GUIListItem)rootDrives[i]; Log.Debug("SelectDVDHandler: adding list item of possible playback location - {0}", dlgItem.Path); dlgSel.Add(dlgItem); } dlgSel.DoModal(parentId); if (dlgSel.SelectedLabel != -1) { return(dlgSel.SelectedLabelText.Substring(1, 2)); } else { return(null); } } catch (Exception ex) { Log.Warn("SelectDVDHandler: could not determine dvd path - {0},{1}", ex.Message, ex.StackTrace); return(null); } } //no disc in drive... GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(1020); //information Log.Error("SelectDVDHandler: ShowSelectDriveDialog - Plz Insert Disk"); dlgOk.SetLine(1, 219); //no disc dlgOk.DoModal(parentId); Log.Info("SelectDVDHandler: did not find a movie"); return(null); }
public static VideoInfo SelectQuality(YouTubeEntry vid) { VideoInfo info = new VideoInfo(); info.Get(GetVideoId(vid)); if (!String.IsNullOrEmpty(info.Reason)) { Err_message(info.Reason); info.Quality = VideoQuality.Unknow; return(info); } switch (_settings.VideoQuality) { case 0: info.Quality = VideoQuality.Normal; break; case 1: info.Quality = VideoQuality.High; break; case 2: info.Quality = VideoQuality.HD; break; case 3: info.Quality = VideoQuality.FullHD; break; case 4: { string title = vid.Title.Text; if (info.FmtMap.Contains("18")) { info.Quality = VideoQuality.High; } if (info.FmtMap.Contains("22")) { info.Quality = VideoQuality.HD; } if (info.FmtMap.Contains("37")) { info.Quality = VideoQuality.FullHD; } break; } case 5: { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { info.Quality = VideoQuality.Normal; } dlg.Reset(); dlg.SetHeading("Select video quality"); dlg.Add("Normal quality"); dlg.Add("High quality"); if (info.FmtMap.Contains("22")) { dlg.Add("HD quality"); } if (info.FmtMap.Contains("37")) { dlg.Add("Full HD quality"); } dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId == -1) { info.Quality = VideoQuality.Unknow; } switch (dlg.SelectedLabel) { case 0: info.Quality = VideoQuality.Normal; break; case 1: info.Quality = VideoQuality.High; break; case 2: info.Quality = VideoQuality.HD; break; case 3: info.Quality = VideoQuality.FullHD; break; } } break; } return(info); }
public IRSSChannel RSSContextMenu(IRSSChannel channel) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return(null); } dlg.Reset(); dlg.SetHeading("RSS Feeds"); dlg.Add("Search"); dlg.Add("Update selected"); dlg.Add("Update all"); dlg.DoModal(GUIWindowManager.ActiveWindow); switch (dlg.SelectedLabelText) { case "Update selected": { if (channel == null) { return(null); } if (channel != null) { channel.Update(); } return(null); } case "Update all": { RSSChannelManager.Instance().UpdateChannels(true); return(null); } case "Search": { VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD); keyboard.Reset(); keyboard.Text = ""; keyboard.DoModal(GUIWindowManager.ActiveWindow); if (!keyboard.IsConfirmed) { return(null); } Regex re = new Regex(keyboard.Text, RegexOptions.IgnoreCase); RSSChannel search = new RSSChannel("MediaPortal"); if (channel != null && channel.Url != "MediaPortal") { foreach (RSSItem item in channel.Items) { if (re.IsMatch(item.Title)) { search.Items.Add(item); } } } //this.ShowSelectedRSS() = search; //UpdateListItems(); return(search); } } return(null); }
public bool OnPlayDVD(String drive, int parentId) { Log.Info("SelectDVDHandler: OnPlayDVD() playing DVD {0}", drive); if (g_Player.Playing && g_Player.IsDVD) { if (g_Player.CurrentFile.Equals(drive + @"\VIDEO_TS\VIDEO_TS.IFO")) { return(true); } } if (Util.Utils.getDriveType(drive) == 5) //cd or dvd drive { string driverLetter = drive.Substring(0, 1); string fileName = String.Format(@"{0}:\VIDEO_TS\VIDEO_TS.IFO", driverLetter); if (!VirtualDirectories.Instance.Movies.RequestPin(fileName)) { return(false); } if (File.Exists(fileName)) { IMDBMovie movieDetails = new IMDBMovie(); VideoDatabase.GetMovieInfo(fileName, ref movieDetails); int idFile = VideoDatabase.GetFileId(fileName); int idMovie = VideoDatabase.GetMovieId(fileName); int timeMovieStopped = 0; byte[] resumeData = null; if ((idMovie >= 0) && (idFile >= 0)) { timeMovieStopped = VideoDatabase.GetMovieStopTimeAndResumeData(idFile, out resumeData, g_Player.SetResumeBDTitleState); //Log.Info("GUIVideoFiles: OnPlayBackStopped for DVD - idFile={0} timeMovieStopped={1} resumeData={2}", idFile, timeMovieStopped, resumeData); if (timeMovieStopped > 0) { string title = Path.GetFileName(fileName); VideoDatabase.GetMovieInfoById(idMovie, ref movieDetails); if (movieDetails.Title != string.Empty) { title = movieDetails.Title; } GUIResumeDialog.Result result = GUIResumeDialog.ShowResumeDialog(title, timeMovieStopped, GUIResumeDialog.MediaType.DVD); if (result == GUIResumeDialog.Result.Abort) { return(false); } if (result == GUIResumeDialog.Result.PlayFromBeginning) { timeMovieStopped = 0; } } } if (g_Player.Playing) { g_Player.Stop(); } g_Player.PlayDVD(drive + @"\VIDEO_TS\VIDEO_TS.IFO"); g_Player.ShowFullScreenWindow(); if (g_Player.Playing && timeMovieStopped > 0) { if (g_Player.IsDVD) { g_Player.Player.SetResumeState(resumeData); } else { Log.Debug("SelectDVDHandler.OnPlayDVD - skipping"); g_Player.SeekAbsolute(timeMovieStopped); } } return(true); } } //no disc in drive... GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(3); //my videos Log.Error("SelectDVDHandler: OnPlayDVD() Plz Insert Disk (ShowSelectDriveDialog)"); dlgOk.SetLine(1, 219); //no disc dlgOk.DoModal(parentId); return(false); }
private void OnAudioCodec() { string strAudioCodec = ""; using (Settings xmlreader = new MPSettings()) { strAudioCodec = xmlreader.GetValueAsString("dvdplayer", "audiocodec", ""); } ArrayList availableAudioFilters = FilterHelper.GetFilters(MediaType.Audio, MediaSubType.Mpeg2Audio); //Remove Muxer's from Audio decoder list to avoid confusion. while (availableAudioFilters.Contains("CyberLink MPEG Muxer")) { availableAudioFilters.Remove("CyberLink MPEG Muxer"); } while (availableAudioFilters.Contains("Ulead MPEG Muxer")) { availableAudioFilters.Remove("Ulead MPEG Muxer"); } while (availableAudioFilters.Contains("PDR MPEG Muxer")) { availableAudioFilters.Remove("PDR MPEG Muxer"); } while (availableAudioFilters.Contains("Nero Mpeg2 Encoder")) { availableAudioFilters.Remove("Nero Mpeg2 Encoder"); } availableAudioFilters.Sort(); GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUILocalizeStrings.Get(496)); //Menu int selected = 0; int count = 0; foreach (string codec in availableAudioFilters) { dlg.Add(codec); //delete if (codec == strAudioCodec) { selected = count; } count++; } dlg.SelectedLabel = selected; dlg.DoModal(GetID); if (dlg.SelectedLabel < 0) { OnAudio(); return; } using (Settings xmlwriter = new MPSettings()) { xmlwriter.SetValue("dvdplayer", "audiocodec", (string)availableAudioFilters[dlg.SelectedLabel]); } OnAudio(); }
private void DialogContextMenu() { try { // Showing context menu var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); dlg.Reset(); dlg.SetHeading("Audio switcher"); dlg.Add(new GUIListItem("Change playback device")); if (Settings.LAVbitstreamPerDevice || Settings.LAVbitstreamAlwaysShowToggleInContextMenu) { bool bitstreamingIsEnabled = Convert.ToBoolean(Convert.ToInt16(IsLavBitstreamingEnabled())); dlg.Add(bitstreamingIsEnabled ? new GUIListItem("Disable LAV bitstreaming") : new GUIListItem("Enable LAV bitstreaming")); } if (Settings.LAVaudioDelayControlsInContextMenu) { ReadAllLavDelaySettings(); if (!Settings.LAVaudioDelayEnabled) { dlg.Add(new GUIListItem("Enable LAV audio delay")); } else { dlg.Add(new GUIListItem(string.Format("Change LAV audio delay ( {0}ms )", Settings.LAVaudioDelay))); dlg.Add(new GUIListItem("Disable LAV audio delay")); } } dlg.SelectedLabel = 0; dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedLabelText == "Change playback device") { var devices = GetPlaybackDevices(); var dlgSetPlaybackDevice = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); dlgSetPlaybackDevice.Reset(); dlgSetPlaybackDevice.SetHeading("Select playback device"); dlgSetPlaybackDevice.SelectedLabel = 0; var i = 0; if (devices != null) { foreach (var device in devices) { dlgSetPlaybackDevice.Add(device.FullName); if (device.IsDefaultDevice) { dlgSetPlaybackDevice.SelectedLabel = i; } i++; } } else { dlgSetPlaybackDevice.Add("No playback devices found!"); } dlgSetPlaybackDevice.DoModal(GUIWindowManager.ActiveWindow); if (dlgSetPlaybackDevice.SelectedLabel >= 0) { var selectedDevice = dlgSetPlaybackDevice.SelectedLabelText; if (selectedDevice != "No playback devices found!" && !string.IsNullOrEmpty(selectedDevice)) { var device = devices.ElementAt(dlgSetPlaybackDevice.SelectedLabel); SetPlaybackDevice(device); } } } if (dlg.SelectedLabelText == "Enable LAV bitstreaming") { ToggleLAVBitstreaming(true, "", true); } if (dlg.SelectedLabelText == "Disable LAV bitstreaming") { ToggleLAVBitstreaming(false, "", true); } if (dlg.SelectedLabelText.StartsWith("Disable LAV audio delay")) { SetLavAudioDelay(false, ""); RestartVideoPlayback(false, ""); } if (dlg.SelectedLabelText == "Enable LAV audio delay" || dlg.SelectedLabelText.StartsWith("Change LAV audio delay")) { SelectLavAudioDelay(); } // Save settings Settings.SaveSettings(); } catch (Exception ex) { Log.Error("Error occured during DialogContextMenu()"); Log.Error(ex.Message); } }
public bool ResumeOrPlay(DBEpisode episode) { try { MPTVSeriesLog.Write("Attempting to play: ", episode[DBEpisode.cFilename].ToString(), MPTVSeriesLog.LogLevel.Debug); // don't have this file ! if (episode[DBEpisode.cFilename].ToString().Length == 0) { return(false); } // check that we are not playing an episode out of episode if unwatched // ignore specials as they can be pretty out of wack! #region PlayBack Order // check sort order so our check is accurate var series = Helper.getCorrespondingSeries(episode[DBOnlineEpisode.cSeriesID]); bool dvdSortOrder = series[DBOnlineSeries.cEpisodeSortOrder] == "DVD"; string seasonField = dvdSortOrder ? DBOnlineEpisode.cDVDSeasonNumber : DBOnlineEpisode.cSeasonIndex; string episodeField = dvdSortOrder ? DBOnlineEpisode.cDVDEpisodeNumber : DBOnlineEpisode.cEpisodeIndex; if (DBOption.GetOptions(DBOption.cCheckPlayOutOfOrder) && !episode[DBOnlineEpisode.cWatched] && episode[seasonField] > 0 && episode[episodeField] > 1) { // first get the next unwatched episode from previously played // we are only interested in current season (could be multi-user watching multiple seasons) // API for GetNextUnwatched is not desirable as that works from Date Watched, we only care about watched here var conditions = new SQLCondition(); conditions.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, episode[DBOnlineSeries.cSeriesID], SQLConditionType.Equal); conditions.Add(new DBOnlineEpisode(), seasonField, episode[seasonField], SQLConditionType.Equal); conditions.Add(new DBOnlineEpisode(), episodeField, episode[episodeField], SQLConditionType.LessThan); conditions.Add(new DBOnlineEpisode(), episodeField, 0, SQLConditionType.GreaterThan); var episodes = DBEpisode.Get(conditions, false); if (episodes != null && episodes.Count > 0) { // set logical playback order based on sort order episodes.Sort(); // if the previous found episode is not watched then we are playing out of order // if we have a gap in episode collection then assume it has not been watched (this check is needed when user does not download all episode info) if (!episodes.Last()[DBOnlineEpisode.cWatched] || (episode[episodeField] - episodes.Last()[episodeField]) > 1) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); dlgYesNo.SetHeading(Translation.Warning); dlgYesNo.SetLine(1, Translation.PlaybackOutOfOrderLine1); dlgYesNo.SetLine(2, string.Format("{0} - {1}x{2}", series.ToString(), episode[seasonField], episode[episodeField] - 1)); dlgYesNo.SetLine(3, Translation.PlaybackOutOfOrderLine2); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (!dlgYesNo.IsConfirmed) { return(false); } } } } #endregion m_previousEpisode = m_currentEpisode; m_currentEpisode = episode; int timeMovieStopped = m_currentEpisode[DBEpisode.cStopTime]; // Check if file is an Image e.g. ISO string filename = m_currentEpisode[DBEpisode.cFilename]; m_bIsImageFile = Helper.IsImageFile(filename); #region Invoke Before Playback // see if we have an invokeOption set up string invoke = (string)DBOption.GetOptions(DBOption.cInvokeExtBeforePlayback); if (!string.IsNullOrEmpty(invoke)) { string invokeArgs = (string)DBOption.GetOptions(DBOption.cInvokeExtBeforePlaybackArgs); try { // replace any placeholders in the arguments for the script if any have been supplied. if (!string.IsNullOrEmpty(invokeArgs)) { invokeArgs = FieldGetter.resolveDynString(invokeArgs, m_currentEpisode, true); } invoke = FieldGetter.resolveDynString(invoke, m_currentEpisode, true); // use ProcessStartInfo instead of Process.Start(string) as latter produces a "cannot find file" // error if you pass in command line arguments. // also allows us to run the script hidden, preventing, for example, a command prompt popping up. ProcessStartInfo psi = new ProcessStartInfo(invoke, invokeArgs); psi.WindowStyle = ProcessWindowStyle.Hidden; Process proc = System.Diagnostics.Process.Start(psi); MPTVSeriesLog.Write(string.Format("Sucessfully Invoked BeforeFilePlay Command: '{0}' '{1}'", invoke, invokeArgs)); // if not present in database this evaluates to false. If present and not a valid bool then // it evaluates to true bool waitForExit = (bool)DBOption.GetOptions(DBOption.cInvokeExtBeforePlaybackWaitForExit); // if true this thread will wait for the external user script to complete before continuing. if (waitForExit) { proc.WaitForExit(); } } catch (Exception e) { MPTVSeriesLog.Write(string.Format("Unable to Invoke BeforeFilePlay Command: '{0}' '{1}'", invoke, invokeArgs)); MPTVSeriesLog.Write(e.Message); } } #endregion #region Removable Media Handling if (!File.Exists(m_currentEpisode[DBEpisode.cFilename])) { string episodeVolumeLabel = m_currentEpisode[DBEpisode.cVolumeLabel].ToString(); if (string.IsNullOrEmpty(episodeVolumeLabel)) { episodeVolumeLabel = LocalParse.getImportPath(m_currentEpisode[DBEpisode.cFilename]); } // ask the user to input cd/dvd, usb disk or confirm network drive is connected GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (null == dlgOK) { return(false); } dlgOK.SetHeading(Translation.insertDisk); dlgOK.SetLine(1, Translation.InsertDiskMessage1); dlgOK.SetLine(2, Translation.InsertDiskMessage2); dlgOK.SetLine(3, Translation.InsertDiskMessage3); dlgOK.SetLine(4, string.Format(Translation.InsertDiskMessage4, episodeVolumeLabel)); dlgOK.DoModal(GUIWindowManager.ActiveWindow); if (!File.Exists(m_currentEpisode[DBEpisode.cFilename])) { return(false); // still not found, return to list } } #endregion #region Ask user to Resume // skip this if we are using an External Player bool bExternalPlayer = m_bIsImageFile ? m_bIsExternalDVDPlayer : m_bIsExternalPlayer; if (timeMovieStopped > 0 && !bExternalPlayer) { MPTVSeriesLog.Write("Asking user to resume episode from: " + Utils.SecondsToHMSString(timeMovieStopped)); GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (null != dlgYesNo) { dlgYesNo.SetHeading(Translation.ResumeEpisode); dlgYesNo.SetLine(1, m_currentEpisode.onlineEpisode.CompleteTitle); dlgYesNo.SetLine(2, GUILocalizeStrings.Get(936) + " " + Utils.SecondsToHMSString(timeMovieStopped)); dlgYesNo.SetDefaultToYes(true); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); // reset resume data in DB if (!dlgYesNo.IsConfirmed) { timeMovieStopped = 0; m_currentEpisode[DBEpisode.cStopTime] = timeMovieStopped; m_currentEpisode.Commit(); MPTVSeriesLog.Write("User selected to start episode from beginning", MPTVSeriesLog.LogLevel.Debug); } else { MPTVSeriesLog.Write("User selected to resume episode", MPTVSeriesLog.LogLevel.Debug); // dont scrobble first of double episode if resuming past halfway double duration = m_currentEpisode[DBEpisode.cLocalPlaytime]; } } } #endregion Play(timeMovieStopped); return(true); } catch (Exception e) { MPTVSeriesLog.Write("TVSeriesPlugin.VideoHandler.ResumeOrPlay()\r\n" + e.ToString()); return(false); } }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedEpisodeSummary = selectedItem.TVTag as TraktEpisodeSummary; if (selectedEpisodeSummary == null) { return; } var selectedSeries = selectedEpisodeSummary.Show; var selectedEpisode = selectedEpisodeSummary.Episode; var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; if (CurrentUser == TraktSettings.Username) { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Add to Custom List listItem = new GUIListItem(Translation.AddToList + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for show with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for show with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.RemoveFromWatchList): RemovingWatchListItem = true; PreviousSelectedIndex = this.Facade.SelectedListItemIndex; TraktHelper.RemoveEpisodeFromWatchList(selectedSeries, selectedEpisode); if (this.Facade.Count >= 1) { // remove from list _WatchListEpisodes = null; userWatchList.Remove(CurrentUser); LoadWatchListEpisodes(); } else { // no more shows left ClearProperties(); GUIControl.ClearControl(GetID, Facade.GetID); _WatchListEpisodes = null; userWatchList.Remove(CurrentUser); // notify and exit GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoShowWatchList); GUIWindowManager.ShowPreviousWindow(); return; } break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveEpisodeInUserList(selectedSeries.Title, selectedSeries.Year.ToString(), selectedEpisode.Season.ToString(), selectedEpisode.Number.ToString(), selectedSeries.Tvdb, false); break; case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedSeries, selectedEpisode); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowEpisodeShouts(selectedSeries, selectedEpisode); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0} S{1}E{2}", selectedSeries.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = string.Format("{0} S{1}E{2}", selectedSeries.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } TraktTrendingShow selectedShow = (TraktTrendingShow)selectedItem.TVTag; IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUICommon.CreateTrendingShowsContextMenu(ref dlg, selectedShow, false); // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)TrendingContextMenuItem.AddToWatchList): TraktHelper.AddShowToWatchList(selectedShow); selectedShow.InWatchList = true; OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); if (TraktSettings.TrendingShowsHideWatchlisted) { LoadTrendingShows(); } break; case ((int)TrendingContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); break; case ((int)TrendingContextMenuItem.MarkAsWatched): GUICommon.MarkShowAsSeen(selectedShow); if (TraktSettings.TrendingShowsHideWatched) { LoadTrendingShows(); } break; case ((int)TrendingContextMenuItem.AddToLibrary): GUICommon.AddShowToLibrary(selectedShow); if (TraktSettings.TrendingShowsHideCollected) { LoadTrendingShows(); } break; case ((int)TrendingContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveShowFromWatchList(selectedShow); selectedShow.InWatchList = false; OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); break; case ((int)TrendingContextMenuItem.AddToList): TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false); break; case ((int)TrendingContextMenuItem.Filters): if (GUICommon.ShowTVShowFiltersMenu()) { UpdateButtonState(); LoadTrendingShows(); } break; case ((int)TrendingContextMenuItem.Related): TraktHelper.ShowRelatedShows(selectedShow); break; case ((int)TrendingContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(selectedShow); break; case ((int)TrendingContextMenuItem.Shouts): TraktHelper.ShowTVShowShouts(selectedShow); break; case ((int)TrendingContextMenuItem.Rate): GUICommon.RateShow(selectedShow); OnShowSelected(selectedItem, Facade); selectedShow.Images.NotifyPropertyChanged("PosterImageFilename"); if (TraktSettings.TrendingShowsHideRated) { LoadTrendingShows(); } break; case ((int)TrendingContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout); break; case ((int)TrendingContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedShow.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)TrendingContextMenuItem.SearchTorrent): string loadPar = selectedShow.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedEpisodeSummary = selectedItem.TVTag as TraktEpisodeSummary; if (selectedEpisodeSummary == null) { return; } var selectedEpisode = selectedEpisodeSummary.Episode; if (selectedEpisode == null) { return; } var selectedShow = selectedEpisodeSummary.Show; if (selectedShow == null) { return; } IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Show Season Information listItem = new GUIListItem(Translation.ShowSeasonInfo); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ShowSeasonInfo; if (!selectedEpisode.InWatchList) { listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } else { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } // Add to Custom List listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Mark As Watched if (!selectedEpisode.Watched) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (selectedEpisode.Watched) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } // Add to Library // Don't allow if it will be removed again on next sync // movie could be part of a DVD collection if (!selectedEpisode.InCollection && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedEpisode.InCollection) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } // Related Shows listItem = new GUIListItem(Translation.RelatedShows + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; // Rate Episode listItem = new GUIListItem(Translation.RateEpisode); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Shouts + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; if (TraktHelper.IsOnlineVideosAvailableAndEnabled) { // Trailers listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (!selectedEpisode.InCollection && TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for movie with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (!selectedEpisode.InCollection && TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for movie with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.ShowSeasonInfo): GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON()); break; case ((int)ContextMenuItem.MarkAsWatched): TraktHelper.MarkEpisodeAsWatched(selectedShow, selectedEpisode); if (selectedEpisode.Plays == 0) { selectedEpisode.Plays = 1; } selectedEpisode.Watched = true; selectedItem.IsPlayed = true; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.MarkEpisodeAsUnWatched(selectedShow, selectedEpisode); selectedEpisode.Watched = false; selectedItem.IsPlayed = false; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddEpisodeToWatchList(selectedShow, selectedEpisode); selectedEpisode.InWatchList = true; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveEpisodeFromWatchList(selectedShow, selectedEpisode); selectedEpisode.InWatchList = false; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveEpisodeInUserList(selectedShow, selectedEpisode, false); break; case ((int)ContextMenuItem.Trailers): PreviousUser = CurrentUser; GUICommon.ShowTVShowTrailersMenu(selectedShow, selectedEpisode); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddEpisodeToLibrary(selectedShow, selectedEpisode); selectedEpisode.InCollection = true; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveEpisodeFromLibrary(selectedShow, selectedEpisode); selectedEpisode.InCollection = false; OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.Related): TraktHelper.ShowRelatedShows(selectedShow); break; case ((int)ContextMenuItem.Rate): GUICommon.RateEpisode(selectedShow, selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowEpisodeShouts(selectedShow, selectedEpisode); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0} S{1}E{2}", selectedShow.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = string.Format("{0} S{1}E{2}", selectedShow.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); MusicDatabase dbs; if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // Menu dlg.AddLocalizedString(930); //Add to favorites if (CurrentTrackTag.Album != null) { dlg.AddLocalizedString(33041); } if (PluginManager.IsPluginNameEnabled2("LastFMScrobbler")) { dlg.AddLocalizedString(34010); //last.fm love dlg.AddLocalizedString(34011); //last.fm ban } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedId) { case 928: // Find Coverart if (_MusicWindow != null) { string albumFolderPath = Path.GetDirectoryName(CurrentTrackFileName); _MusicWindow.FindCoverArt(false, CurrentTrackTag.Artist, CurrentTrackTag.Album, albumFolderPath, CurrentTrackTag, -1); CurrentThumbFileName = GUIMusicBaseWindow.GetCoverArt(false, CurrentTrackFileName, CurrentTrackTag); if (CurrentThumbFileName.Length > 0) { // let us test if there is a larger cover art image string strLarge = Util.Utils.ConvertToLargeCoverArt(CurrentThumbFileName); if (Util.Utils.FileExistsInCache(strLarge)) { CurrentThumbFileName = strLarge; } AddImageToImagePathContainer(CurrentThumbFileName); UpdateImagePathContainer(); } } break; case 4521: // Show Album Info if (_MusicWindow != null) { string albumFolderPath = Path.GetDirectoryName(CurrentTrackFileName); if (_MusicWindow != null) { _MusicWindow.ShowAlbumInfo(GetID, CurrentTrackTag.Artist, CurrentTrackTag.Album); } } break; case 930: // add to favorites dbs = MusicDatabase.Instance; Song currentSong = new Song(); string strFile = g_Player.Player.CurrentFile; bool songFound = dbs.GetSongByFileName(strFile, ref currentSong); if (songFound) { if (currentSong == null) { return; } if (currentSong.Id < 0) { return; } currentSong.Favorite = true; dbs.SetFavorite(currentSong); } break; case 33041: //Play this album try { if (CurrentTrackTag != null) { dbs = MusicDatabase.Instance; ArrayList albumSongs = new ArrayList(); String strAlbum = CurrentTrackTag.Album; bool albumSongsFound = dbs.GetSongsByAlbum(strAlbum, ref albumSongs); if (albumSongsFound) { for (int i = albumSongs.Count - 1; i >= 0; i--) { Song song = (Song)albumSongs[i]; if (song.Title != CurrentTrackTag.Title && song.Artist == CurrentTrackTag.Artist) { AddSongToPlaylist(ref song); } } OnSongInserted(); } } } catch (Exception ex) { Log.Error("GUIMusicPlayingNow: error while adding album tracks for {0} - {1}", CurrentTrackTag.Album, ex.Message); } break; } }
public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: { base.OnMessage(message); LoadSettings(); if (m_bAutoShuffle) { GUIControl.SelectControl(GetID, (int)Controls.CONTROL_AUTOSHUFFLE); } return(true); } case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: { SaveSettings(); } break; case GUIMessage.MessageType.GUI_MSG_CLICKED: { int iControl = message.SenderControlId; if (iControl == (int)Controls.CONTROL_AUTOSHUFFLE) { m_bAutoShuffle = !m_bAutoShuffle; } if (iControl == (int)Controls.CONTROL_BTNDELALBUMINFO) { MusicDatabaseReorg dbreorg = new MusicDatabaseReorg(); dbreorg.DeleteAlbumInfo(); } if (iControl == (int)Controls.CONTROL_BTNDELALBUM) { MusicDatabaseReorg dbreorg = new MusicDatabaseReorg(); dbreorg.DeleteSingleAlbum(); } if (iControl == (int)Controls.CONTROL_BTNREORGDB) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (null != dlgYesNo) { dlgYesNo.SetHeading(333); dlgYesNo.SetLine(1, ""); dlgYesNo.SetLine(2, ""); dlgYesNo.SetLine(3, ""); dlgYesNo.DoModal(GetID); if (dlgYesNo.IsConfirmed) { MusicDatabaseReorg reorg = new MusicDatabaseReorg(GetID); Work work = new Work(new DoWorkHandler(reorg.ReorgAsync)); work.ThreadPriority = ThreadPriority.Lowest; GlobalServiceProvider.Get <IThreadPool>().Add(work, QueuePriority.Low); } } } } break; } return(base.OnMessage(message)); }
private void OnPlay(int type) { string strHowToPlay = string.Empty; string strType = string.Empty; using (Settings xmlreader = new MPSettings()) { if (type == 2135) // Audio { strType = "autoplay_video"; } if (type == 2134) // Video { strType = "autoplay_audio"; } if (type == 300006) // photo { strType = "autoplay_photo"; } strHowToPlay = xmlreader.GetValueAsString("general", strType, "Ask"); } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUILocalizeStrings.Get(496)); //Options dlg.AddLocalizedString(208); // Play dlg.AddLocalizedString(300007); // Do not play dlg.AddLocalizedString(300008); // Ask what to do // Set options from config switch (strHowToPlay) { case "Yes": dlg.SelectedLabel = 0; break; case "No": dlg.SelectedLabel = 1; break; case "Ask": dlg.SelectedLabel = 2; break; default: dlg.SelectedLabel = 2; break; } // Show options dlg.DoModal(GetID); if (dlg.SelectedId == -1) { OnAutoPlay(); return; } switch (dlg.SelectedId) { case 208: // Play strHowToPlay = "Yes"; break; case 300007: // Do not play strHowToPlay = "No"; break; case 300008: // Ask what to do strHowToPlay = "Ask"; break; } using (Settings xmlwriter = new MPSettings()) { xmlwriter.SetValue("general", strType, strHowToPlay); } OnAutoPlay(); }
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; if (Settings.Instance.ExtensiveLogging) { Log.Info( "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().ToLower().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().ToLower().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); }
/// <summary> /// Handle the facade message /// </summary> /// <param name="message">Message sent from client</param> /// <param name="server">Instance of the socket server</param> /// <param name="client">Socket that sent the message (for return messages)</param> internal static void HandleFacadeMessage(Newtonsoft.Json.Linq.JObject message, SocketServer server, AsyncSocket client) { String action = (string)message["FacadeAction"]; GUIWindow currentPlugin = GUIWindowManager.GetWindow(GUIWindowManager.ActiveWindow); if (action.Equals("get")) { MessageFacade returnMessage = new MessageFacade(); if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50); List <FacadeItem> items = MpFacadeHelper.GetHomeItems(menu); returnMessage.FacadeItems = items; returnMessage.ViewType = "Home"; } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); if (facade != null) { List <FacadeItem> items = MpFacadeHelper.GetFacadeItems(currentPlugin.GetID, 50); returnMessage.ViewType = facade.CurrentLayout.ToString(); returnMessage.FacadeItems = items; } } returnMessage.WindowId = currentPlugin.GetID; server.SendMessageToClient(returnMessage, client); } else if (action.Equals("setselected")) { if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); int selected = (int)message["SelectedIndex"]; facade.SelectedListItemIndex = selected; } } else if (action.Equals("getselected")) { if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { //TODO: find a way to retrieve the currently selected home button } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); int selected = facade.SelectedListItemIndex; } } else if (action.Equals("getcount")) { if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50); int count = menu.ButtonInfos.Count; } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); int count = facade.Count; } } else if (action.Equals("select")) { int selected = (int)message["SelectedIndex"]; if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50); MenuButtonInfo info = menu.ButtonInfos[selected]; GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, info.PluginID, 0, null); GUIWindowManager.SendThreadMessage(msg); } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); //TODO: is there a better way to select a list item facade.SelectedListItemIndex = selected; new Communication().SendCommand("ok"); } } else if (action.Equals("context")) { int selected = (int)message["SelectedIndex"]; if (currentPlugin.GetType() == typeof(MediaPortal.GUI.Home.GUIHome)) { GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50); MenuButtonInfo info = menu.ButtonInfos[selected]; GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, info.PluginID, 0, null); GUIWindowManager.SendThreadMessage(msg); } else { GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50); //TODO: is there a better way to select a list item facade.SelectedListItemIndex = selected; new Communication().SendCommand("info"); } } }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedEpisode = selectedItem.TVTag as TraktEpisodeSummary; if (selectedEpisode == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; if (selectedEpisode.IsWatched(Show)) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } else { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } if (selectedEpisode.IsCollected(Show)) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } else { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedEpisode.IsWatchlisted()) { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } else { listItem = new GUIListItem(Translation.AddEpisodeToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } // Add to Custom List listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Rate listItem = new GUIListItem(Translation.Rate + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; if (TraktHelper.IsMpNZBAvailableAndEnabled) { // Search for show with mpNZB listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { // Search for show with MyTorrents listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVShowTrailersMenu(Show, selectedEpisode); break; case ((int)ContextMenuItem.MarkAsWatched): TraktHelper.AddEpisodeToWatchHistory(selectedEpisode); TraktCache.AddEpisodeToWatchHistory(Show, selectedEpisode); Facade.SelectedListItem.IsPlayed = true; OnEpisodeSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveEpisodeFromWatchHistory(selectedEpisode); TraktCache.RemoveEpisodeFromWatchHistory(Show, selectedEpisode); Facade.SelectedListItem.IsPlayed = false; OnEpisodeSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToLibrary): TraktHelper.AddEpisodeToCollection(selectedEpisode); TraktCache.AddEpisodeToCollection(Show, selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveEpisodeFromCollection(selectedEpisode); TraktCache.RemoveEpisodeFromCollection(Show, selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToWatchList): TraktHelper.AddEpisodeToWatchList(selectedEpisode); TraktCache.AddEpisodeToWatchlist(Show, selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveEpisodeFromWatchList(selectedEpisode); OnEpisodeSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.Rate): GUICommon.RateEpisode(Show, selectedEpisode); OnEpisodeSelected(Facade.SelectedListItem, Facade); (Facade.SelectedListItem as GUIEpisodeListItem).Images.NotifyPropertyChanged("Screen"); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveEpisodeInUserList(selectedEpisode, false); break; case ((int)ContextMenuItem.Shouts): TraktHelper.ShowEpisodeShouts(Show, selectedEpisode); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0} S{1}E{2}", Show.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = string.Format("{0} S{1}E{2}", Show.Title, selectedEpisode.Season.ToString("D2"), selectedEpisode.Number.ToString("D2")); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem; if (selectedItem == null) { return; } var selectedPopularMovie = selectedItem.TVTag as TraktMovieSummary; if (selectedPopularMovie == null) { return; } var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUICommon.CreateMoviesContextMenu(ref dlg, selectedPopularMovie, false); // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)MediaContextMenuItem.MarkAsWatched): TraktHelper.AddMovieToWatchHistory(selectedPopularMovie); selectedItem.IsPlayed = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.PopularMoviesHideWatched) { LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveMovieFromWatchHistory(selectedPopularMovie); selectedItem.IsPlayed = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.AddToWatchList): TraktHelper.AddMovieToWatchList(selectedPopularMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.PopularMoviesHideWatchlisted) { LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveMovieFromWatchList(selectedPopularMovie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.AddToList): TraktHelper.AddRemoveMovieInUserList(selectedPopularMovie, false); break; case ((int)MediaContextMenuItem.AddToLibrary): TraktHelper.AddMovieToCollection(selectedPopularMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.PopularMoviesHideCollected) { LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromCollection(selectedPopularMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.Related): TraktHelper.ShowRelatedMovies(selectedPopularMovie); break; case ((int)MediaContextMenuItem.Rate): GUICommon.RateMovie(selectedPopularMovie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.PopularMoviesHideRated) { LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.Filters): if (ShowMovieFiltersMenu()) { PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; UpdateButtonState(); LoadPopularMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.Shouts): TraktHelper.ShowMovieShouts(selectedPopularMovie); break; case ((int)MediaContextMenuItem.Cast): GUICreditsMovie.Movie = selectedPopularMovie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)MediaContextMenuItem.Crew): GUICreditsMovie.Movie = selectedPopularMovie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)MediaContextMenuItem.Trailers): GUICommon.ShowMovieTrailersMenu(selectedPopularMovie); break; case ((int)MediaContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)MediaContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedPopularMovie.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)MediaContextMenuItem.SearchTorrent): string loadParm = selectedPopularMovie.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadParm); break; default: break; } base.OnShowContextMenu(); }
public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: { base.OnMessage(message); m_pParentWindow = null; m_bRunning = false; GUIGraphicsContext.Overlay = m_bOverlay; //base.OnMessage(message); Dispose(); DeInitControls(); GUILayerManager.UnRegisterLayer(this); return(true); } case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: { m_bDialogActive = true; base.OnMessage(message); GUIGraphicsContext.Overlay = base.IsOverlayAllowed; m_pParentWindow = GUIWindowManager.GetWindow(m_dwParentWindowID); GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Dialog); } return(true); case GUIMessage.MessageType.GUI_MSG_CLICKED: { int iAction = message.Param1; int iControl = message.SenderControlId; if (btnCancel != null && iControl == (int)btnCancel.GetID) { m_bCanceled = true; if (!m_bBusy) { Close(); } } if (btnYes != null && iControl == (int)btnYes.GetID) { if (!m_bBusy) { m_bBusy = true; FileItemMC(m_itemSourceItem); m_bBusy = false; Close(); } else { m_bButtonYes = true; } } if (btnNo != null && iControl == (int)btnNo.GetID) { m_bButtonNo = true; } if (btnAlways != null && iControl == (int)btnAlways.GetID) { m_bAlways = true; } if (btnNever != null && iControl == (int)btnNever.GetID) { m_bNever = true; } } break; } if (m_pParentWindow != null) { if (message.TargetWindowId == m_pParentWindow.GetID) { return(m_pParentWindow.OnMessage(message)); } } return(base.OnMessage(message)); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == _btnSkin) { var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(166); // menu IEnumerable <string> installedSkins = GetInstalledSkins(); foreach (string skin in installedSkins) { dlg.Add(skin); } dlg.SelectedLabel = _btnSkin.SelectedItem; dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } if (String.Compare(dlg.SelectedLabelText, _btnSkin.Label, StringComparison.OrdinalIgnoreCase) != 0) { _btnSkin.Label = dlg.SelectedLabelText; // prevent MP from rendering when resource are disposed during live changing of a skin lock (GUIGraphicsContext.RenderLock) { GUIGraphicsContext.IsSwitchingToNewSkin = true; OnSkinChanged(); GUIGraphicsContext.IsSwitchingToNewSkin = false; } } return; } if (control == _btnLanguage) { var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(248); // menu string[] languages = GUILocalizeStrings.SupportedLanguages(); foreach (string lang in languages) { dlg.Add(lang); } string currentLanguage = _btnLanguage.Label; dlg.SelectedLabel = 0; for (int i = 0; i < languages.Length; i++) { if (languages[i].ToLowerInvariant() == currentLanguage.ToLowerInvariant()) { dlg.SelectedLabel = i; break; } } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } if (String.Compare(dlg.SelectedLabelText, _btnLanguage.Label, StringComparison.OrdinalIgnoreCase) != 0) { _btnLanguage.Label = dlg.SelectedLabelText; OnLanguageChanged(); } return; } if (control == _btnLanguagePrefix) { SettingsChanged(true); } base.OnClicked(controlId, control, actionType); }
private void OnKeep() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(1042); dlg.AddLocalizedString(1043); //Until watched dlg.AddLocalizedString(1044); //Until space needed dlg.AddLocalizedString(1045); //Until date dlg.AddLocalizedString(1046); //Always switch ((KeepMethodType)currentProgram.KeepUntil) { case KeepMethodType.UntilWatched: dlg.SelectedLabel = 0; break; case KeepMethodType.UntilSpaceNeeded: dlg.SelectedLabel = 1; break; case KeepMethodType.TillDate: dlg.SelectedLabel = 2; break; case KeepMethodType.Always: dlg.SelectedLabel = 3; break; } dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedId) { case 1043: currentProgram.KeepUntil = (int)KeepMethodType.UntilWatched; break; case 1044: currentProgram.KeepUntil = (int)KeepMethodType.UntilSpaceNeeded; break; case 1045: currentProgram.KeepUntil = (int)KeepMethodType.TillDate; dlg.Reset(); dlg.ShowQuickNumbers = false; dlg.SetHeading(1045); for (int iDay = 1; iDay <= 100; iDay++) { DateTime dt = currentProgram.StartTime.AddDays(iDay); if (currentProgram.StartTime < DateTime.Now) { dt = DateTime.Now.AddDays(iDay); } dlg.Add(dt.ToLongDateString()); } TimeSpan ts = (currentProgram.KeepUntilDate - currentProgram.StartTime); if (currentProgram.StartTime < DateTime.Now) { ts = (currentProgram.KeepUntilDate - DateTime.Now); } int days = (int)ts.TotalDays; if (days >= 100) { days = 30; } dlg.SelectedLabel = days - 1; dlg.DoModal(GetID); if (dlg.SelectedLabel < 0) { return; } if (currentProgram.StartTime < DateTime.Now) { currentProgram.KeepUntilDate = DateTime.Now.AddDays(dlg.SelectedLabel + 1); } else { currentProgram.KeepUntilDate = currentProgram.StartTime.AddDays(dlg.SelectedLabel + 1); } break; case 1046: currentProgram.KeepUntil = (int)KeepMethodType.Always; break; } currentProgram.Persist(); }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedSeason = selectedItem.TVTag as TraktShowSeason; var dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // Trailers if (TraktHelper.IsTrailersAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } // Mark season as watched listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; // Add season to Library listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; // Add to Custom List listItem = new GUIListItem(Translation.AddToList + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Sort By listItem = new GUIListItem(TraktSettings.SortSeasonsAscending ? Translation.SortSeasonsDescending : Translation.SortSeasonsAscending); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Sort; // Change Layout listItem = new GUIListItem(Translation.ChangeLayout); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.ChangeLayout; // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)ContextMenuItem.Trailers): GUICommon.ShowTVSeasonTrailersPluginMenu(Show, selectedSeason.Season); break; case ((int)ContextMenuItem.MarkAsWatched): GUICommon.MarkSeasonAsSeen(Show, selectedSeason.Season); break; case ((int)ContextMenuItem.AddToLibrary): GUICommon.AddSeasonToLibrary(Show, selectedSeason.Season); break; case ((int)ContextMenuItem.AddToList): TraktHelper.AddRemoveSeasonInUserList(Show.Title, Show.Year.ToString(), selectedSeason.Season.ToString(), Show.Tvdb, false); break; case ((int)ContextMenuItem.Sort): TraktSettings.SortSeasonsAscending = !TraktSettings.SortSeasonsAscending; LoadShowSeasons(); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; default: break; } base.OnShowContextMenu(); }
protected override void OnClicked(int controlId, GUIControl control, global::MediaPortal.GUI.Library.Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (control == _programTypeButton) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(467); dlg.Add(Utility.GetLocalizedText(TextId.UpcomingTypeRecordings)); dlg.Add(Utility.GetLocalizedText(TextId.UpcomingTypeAlerts)); dlg.Add(Utility.GetLocalizedText(TextId.UpcomingTypeSuggestions)); switch (_currentProgramType) { case ScheduleType.Recording: dlg.SelectedLabel = 0; break; case ScheduleType.Alert: dlg.SelectedLabel = 1; break; case ScheduleType.Suggestion: dlg.SelectedLabel = 2; break; } // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedLabel) { case 0: _currentProgramType = ScheduleType.Recording; break; case 1: _currentProgramType = ScheduleType.Alert; break; case 2: _currentProgramType = ScheduleType.Suggestion; break; } m_iSelectedItem = 0; m_iSelectedItemInFolder = 0; LoadUpcomingPrograms(null); } if (control == _groupBySchedButton) { m_iSelectedItem = 0; m_iSelectedItemInFolder = 0; LoadUpcomingPrograms(null); } if (control == _newProgramButton) { OnNewSchedule(); } if (control == _sortByButton) // sort by { if (!_groupBySchedButton.Selected || _isInSubDirectory) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(495); //Sort Options dlg.AddLocalizedString(620); //channel dlg.AddLocalizedString(621); //date dlg.AddLocalizedString(268); //title // set the focus to currently used sort method dlg.SelectedLabel = (int)_currentSortMethod; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _currentSortMethod = (SortMethod)dlg.SelectedLabel; } else { //we don't have a time and channel for schedules,so we can only use the title/name sorting. _currentSortMethod = SortMethod.Name; } OnSort(); } if (control == _viewsList) { GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECTED, GetID, 0, control.GetID, 0, 0, null); OnMessage(msg); int iItem = (int)msg.Param1; if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { OnEditSchedule(iItem); } if (actionType == Action.ActionType.ACTION_SHOW_INFO) { OnShowContextMenu(); } } }
protected override void OnShowContextMenu() { var selectedItem = listControl.SelectedListItem; if (selectedItem != null) { if (selectedItem.Label != ".." && selectedItem.MusicTag != null && !selectedItem.IsFolder) { try { var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(498); // menu var station = new RadioTimeStation { Grabber = grabber }; station.Get(((RadioTimeOutline)selectedItem.MusicTag).GuidId); var show = false; if (station.IsPreset) { dlg.Add(Translation.RemoveFromFavorites); show = true; } else { dlg.Add(Translation.AddToFavorites); show = true; } if (station.HasSchedule) { dlg.Add(Translation.ShowGiuide); show = true; } if (!show) { return; } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } if (dlg.SelectedLabelText == Translation.AddToFavorites) { AddToFavorites(((RadioTimeOutline)selectedItem.MusicTag).GuidId); } if (dlg.SelectedLabelText == Translation.RemoveFromFavorites) { RemoveFavorites(((RadioTimeOutline)selectedItem.MusicTag).PresetId); } if (dlg.SelectedLabelText == Translation.ShowGiuide) { var miniGuide = (MiniGuide)GUIWindowManager.GetWindow(25651); miniGuide.GuidId = ((RadioTimeOutline)selectedItem.MusicTag).GuidId; miniGuide.grabber = new RadioTime(); miniGuide.grabber.Settings = grabber.Settings; miniGuide.DoModal(GetID); } } catch (SoapException ex) { Log.Error("[RadioTime] Comunication error or wrong user name or password "); Log.Error(ex); } } } }