protected override void OnShowContextMenu() { int iItem = GetSelectedItemNo(); GUIListItem pItem = GetItem(iItem); if (pItem == null) { return; } if (pItem.IsFolder) { ScheduleSummary schedule = pItem.TVTag as ScheduleSummary; if (schedule != null) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(schedule.Name ?? string.Empty); dlg.Add(Utility.GetLocalizedText(TextId.Settings)); if (schedule.IsActive) { dlg.Add(Utility.GetLocalizedText(TextId.CancelThisSchedule)); } else { dlg.Add(Utility.GetLocalizedText(TextId.UnCancelThisSchedule)); } dlg.Add(Utility.GetLocalizedText(TextId.DeleteThisSchedule)); dlg.DoModal(GetID); Schedule _sched = Proxies.SchedulerService.GetScheduleById(schedule.ScheduleId).Result; switch (dlg.SelectedLabel) { case 0: if (_sched != null) { var programs = Proxies.SchedulerService.GetUpcomingPrograms(_sched, true).Result; if (programs != null && programs.Count > 0) { OnEditSchedule(programs[0]); } } break; case 1: if (_sched != null) { if (_sched.IsActive) { _sched.IsActive = false; Proxies.SchedulerService.SaveSchedule(_sched).Wait(); } else { _sched.IsActive = true; Proxies.SchedulerService.SaveSchedule(_sched).Wait(); } } break; case 2: { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.Reset(); dlgYesNo.SetHeading(schedule.Name); dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.DeleteThisSchedule)); dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure)); dlgYesNo.SetLine(3, string.Empty); dlgYesNo.SetDefaultToYes(false); dlgYesNo.DoModal(GetID); if (dlgYesNo.IsConfirmed) { Proxies.SchedulerService.DeleteSchedule(schedule.ScheduleId).Wait(); _selectedSchedule = null; } } } break; } m_iSelectedItem = GetSelectedItemNo(); LoadUpcomingPrograms(null); } } else { UpcomingProgram upcoming = pItem.TVTag as UpcomingProgram; if (upcoming != null) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(upcoming.Title); dlg.Add(Utility.GetLocalizedText(TextId.Settings)); dlg.Add(Utility.GetLocalizedText(TextId.Priority)); if (upcoming.IsCancelled) { if (upcoming.CancellationReason == UpcomingCancellationReason.Manual) { dlg.Add(Utility.GetLocalizedText(TextId.UncancelThisShow)); } } else { dlg.Add(Utility.GetLocalizedText(TextId.CancelThisShow)); } dlg.DoModal(GetID); switch (dlg.SelectedLabel) { case 0: // settings/information OnEditSchedule(upcoming); break; case 1: // Priority OnChangePriority(upcoming); break; case 2: // (Un)Cancel if (upcoming.IsCancelled) { Proxies.SchedulerService.UncancelUpcomingProgram(upcoming.ScheduleId, upcoming.GuideProgramId, upcoming.Channel.ChannelId, upcoming.StartTime).Wait(); } else { Proxies.SchedulerService.CancelUpcomingProgram(upcoming.ScheduleId, upcoming.GuideProgramId, upcoming.Channel.ChannelId, upcoming.StartTime).Wait(); } m_iSelectedItem = GetSelectedItemNo(); LoadUpcomingPrograms(null); break; } } } }
protected override void OnClicked(int controlId, GUIControl control, global::MediaPortal.GUI.Library.Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); if (control == _searchButton) { _selectedTitleIndex = 0; _selectedProgramIndex = 0; if (_rules.Count > 0) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.Attention)); dlgYesNo.SetLine(1, Utility.GetLocalizedText(TextId.ContinueWithPrevResults)); dlgYesNo.SetDefaultToYes(true); dlgYesNo.DoModal(GetID); if (!dlgYesNo.IsConfirmed) { _rules.Clear(); if (_viewsList != null && _viewsList.Count > 0) { _viewsList.Clear(); } } } } VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD); if (keyboard != null) { keyboard.Reset(); keyboard.IsSearchKeyboard = true; keyboard.Text = String.Empty; keyboard.DoModal(GetID); if (keyboard.IsConfirmed) { if (keyboard.Text == string.Empty) { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoValidSearchText)); dlgOk.DoModal(GetID); } } else { switch (_currentSearchMethod) { case SearchInMethod.Title: _rules.Add(ScheduleRuleType.TitleContains, keyboard.Text); break; case SearchInMethod.Description: _rules.Add(ScheduleRuleType.DescriptionContains, keyboard.Text); break; case SearchInMethod.ProgramInfo: _rules.Add(ScheduleRuleType.ProgramInfoContains, keyboard.Text); break; case SearchInMethod.Actor: _rules.Add(ScheduleRuleType.WithActor, keyboard.Text); break; case SearchInMethod.DirectedBy: _rules.Add(ScheduleRuleType.DirectedBy, keyboard.Text); break; } ShowSearchResults(string.Empty); } } } } else if (control == _searchMethodButton) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(467); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnTitle)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDescription)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnProgramInfo)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnActor)); dlg.Add(Utility.GetLocalizedText(TextId.SearchOnDirectedBy)); dlg.SelectedLabel = (int)_currentSearchMethod; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _currentSearchMethod = (SearchInMethod)(dlg.SelectedLabel); UpdateButtonStates(); } else if (control == _selectChannelsButton) { List <ChannelGroup> groups = new List <ChannelGroup>(PluginMain.Navigator.GetGroups(this._channelType)); ChannelGroup _selectedGroup = new ChannelGroup(); if (groups.Count > 0) { if (groups.Count > 1) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectGroup)); foreach (ChannelGroup group in groups) { dlg.Add(group.GroupName); } // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _selectedGroup = groups[dlg.SelectedId - 1]; } else { _selectedGroup = groups[0]; } List <Channel> channels = new List <Channel>(); if (_channelArguments.Count > 0) { List <Channel> channels2 = new List <Channel>(Proxies.SchedulerService.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true).Result); foreach (Channel channel in channels2) { if (!_channelArguments.Contains(channel.ChannelId)) { channels.Add(channel); } } } else { channels = new List <Channel>(Proxies.SchedulerService.GetChannelsInGroup(_selectedGroup.ChannelGroupId, true).Result); } if (channels.Count > 0) { GUIDialogMenu dlg2 = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg2 == null) { return; } dlg2.Reset(); dlg2.SetHeading(GetChannelArgumentsString(true)); foreach (Channel channel in channels) { dlg2.Add(channel.DisplayName); } // show dialog and wait for result dlg2.DoModal(GetID); if (dlg2.SelectedId == -1) { return; } _channelArguments.Add(channels[dlg2.SelectedId - 1].ChannelId); UpdateButtonStates(); } else { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreChannelsToAdd)); dlgOk.DoModal(GetID); } } } } else if (control == _selectCategoriesButton) { List <string> categories = new List <string>(); var _categories = Proxies.GuideService.GetAllCategories().Result; foreach (string categorie in _categories) { if (!_categorieArguments.Contains(categorie)) { categories.Add(categorie); } } if (categories.Count > 0) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GetCategorieArgumentString(true)); foreach (string categorie in categories) { dlg.Add(categorie); } // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _categorieArguments.Add(dlg.SelectedLabelText); UpdateButtonStates(); } else { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (dlgOk != null) { dlgOk.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlgOk.SetLine(1, Utility.GetLocalizedText(TextId.NoMoreCategoriesToAdd)); dlgOk.DoModal(GetID); } } } else if (control == _clearButton) { OnClearRules(true); ShowSearchResults(string.Empty); UpdateButtonStates(); } else if (control == _sortByButton) { if (_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/name // 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; OnSort(); } } else 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) { OnSelectItem(iItem); } if (actionType == Action.ActionType.ACTION_SHOW_INFO) { OnShowContextMenu(); } } }
public static bool ShowGameDialog(Game game, GUIPresenter presenter, int selectedLabel = 0) { if (game == null) { return(false); } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { int windowID = Plugin.WINDOW_ID; dlg.Reset(); dlg.SetHeading(Options.Instance.GetStringOption("shownname")); GUIListItem playItem = new GUIListItem("Play"); dlg.Add(playItem); GUIListItem profileItem = new GUIListItem(Translator.Instance.profile) { Label2 = game.CurrentProfile.Title }; dlg.Add(profileItem); GUIListItem favouriteItem = new GUIListItem(Translator.Instance.favourite) { Label2 = game.Favourite.ToString() }; dlg.Add(favouriteItem); GUIListItem gradeItem = new GUIListItem(Translator.Instance.grade) { Label2 = game.Grade.ToString() }; dlg.Add(gradeItem); GUIListItem discItem = new GUIListItem(Translator.Instance.disc); if (game.Discs.Count > 1) { discItem.Label2 = game.CurrentDiscNum.ToString(); dlg.Add(discItem); } GUIListItem goodmergeItem = new GUIListItem(Translator.Instance.goodmerge); if (game.IsGoodmerge) { goodmergeItem.Label2 = game.CurrentDisc.LaunchFile.Replace(game.Filename, "").Trim(); dlg.Add(goodmergeItem); } GUIListItem viewItem = new GUIListItem(Translator.Instance.switchview); dlg.Add(viewItem); GUIListItem importItem = new GUIListItem(Translator.Instance.retrieveonlineinfo); dlg.Add(importItem); GUIListItem runImportItem = new GUIListItem(Translator.Instance.runimport); dlg.Add(runImportItem); GUIListItem settingsItem = new GUIListItem(Translator.Instance.options); dlg.Add(settingsItem); dlg.SelectedLabel = selectedLabel; dlg.DoModal(windowID); selectedLabel = dlg.SelectedLabel; int id = dlg.SelectedId; bool result = false; bool reload = true; if (id < 1) { return(false); } if (id == playItem.ItemId) { LaunchHandler.Instance.StartLaunch(game); reload = false; } else if (id == profileItem.ItemId) { int profileId = game.SelectedProfileId; if (showProfileDialog(ref profileId, game.GetProfiles(), windowID)) { game.SelectedProfileId = profileId; game.SaveGamePlayInfo(); result = true; } } else if (id == favouriteItem.ItemId) { bool favourite = game.Favourite; if (ShowBoolDialog(ref favourite, windowID)) { game.Favourite = favourite; game.SaveGamePlayInfo(); result = true; } } else if (id == gradeItem.ItemId) { int grade = game.Grade; if (showGradeDialog(ref grade, windowID)) { game.Grade = grade; game.SaveGamePlayInfo(); result = true; } } else if (id == discItem.ItemId) { int disc = game.CurrentDiscNum; if (showDiscSelect(ref disc, game.Discs, windowID)) { game.CurrentDiscNum = disc; game.SaveGamePlayInfo(); result = true; } } else if (id == goodmergeItem.ItemId) { try { int selectedGoodmergeIndex; List <string> games = Extractor.Instance.ViewFiles(game, out selectedGoodmergeIndex); if (games != null) { string launchFile = games[selectedGoodmergeIndex]; if (ShowGoodmergeSelect(ref launchFile, games, game.Filename, windowID)) { game.CurrentDisc.LaunchFile = launchFile; game.CurrentDisc.Save(); result = true; } } } catch (ExtractException ex) { Emulators2Settings.Instance.ShowMPDialog("{0} - {1}", Translator.Instance.goodmergeerror, ex.Message); } } else if (id == viewItem.ItemId) { presenter.SwitchView(); reload = false; } else if (id == importItem.ItemId) { presenter.AddToImporter(game); reload = false; } else if (id == runImportItem.ItemId) { presenter.RestartImporter(); reload = false; } else if (id == settingsItem.ItemId) { if (ShowSettingsDialog()) { presenter.ReloadOptions(); result = true; } } if (reload) { result = ShowGameDialog(game, presenter, selectedLabel) || result; } return(result); } return(false); }
internal void MyContextMenu() { try { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(924); //Play Menu Item GUIListItem pItem = new GUIListItem(); pItem.Label = Translation.View; pItem.ItemId = 1; dlg.Add(pItem); pItem = new GUIListItem(); pItem.Label = GUILocalizeStrings.Get(940); pItem.ItemId = 2; dlg.Add(pItem); pItem = new GUIListItem(); pItem.Label = Translation.Update; pItem.ItemId = 3; dlg.Add(pItem); //Show Dialog dlg.DoModal(Utils.ActiveWindow); if (dlg.SelectedLabel < 0) { return; } switch (dlg.SelectedId) { case 1: { PlayPictures(GUIWindowManager.GetWindow(Utils.ActiveWindow)); break; } case 2: { InfoPictures(); break; } case 3: { GetLatestPictures(); break; } } } catch (Exception ex) { logger.Error("MyContextMenu: " + ex.ToString()); } }
public void SearchItemClicked(TorrentMatch match) { GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); dlg.SetHeading("Download this torrent?"); dlg.SetLine(1, match.Title); dlg.SetLine(2, UnitConvert.SizeToString(match.Size)); //dlg.SetLine(3, item.Label3); dlg.DoModal(GUIWindowManager.ActiveWindow); if (!dlg.IsConfirmed) { return; } label = DialogAskLabel.Ask(); if (label == null) { return; } Log.Instance().Print("label is " + label.Name); List <DownloadDir> predefined = TorrentEngine.Instance().TorrentSession.ListDirs(); if (predefined == null) { //MyTorrents.Instance().DisplayError("Unable to connect", "Connection error. Please open your Torrent client before retrying."); //return; } GUIDialogMenu chooser = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (chooser == null) { return; } chooser.Reset(); chooser.SetHeading("Download options"); chooser.Add("No change"); //foreach (DownloadDir dir in predefined) //{ // GUIListItem element = new GUIListItem(); // element.Label = dir.path; // element.Label2 = String.Format("{0} MB Free", Convert.ToString(dir.available)); // chooser.Add(element); //} chooser.Add("Browse Folders"); chooser.DoModal(GUIWindowManager.ActiveWindow); if (chooser.SelectedId == -1) { return; } int selecteddirId = chooser.SelectedId; string selectedText = chooser.SelectedLabelText; Log.Instance().Print("download option is " + selectedText); bool ok = false; // KAT hack string dowOption = ""; if (_searchEngine.GetType() == typeof(TorrentSearch_Combiner)) { Log.Instance().Print("Selected engine is Combiner"); TorrentSearch_Combiner _eng = (TorrentSearch_Combiner)_searchEngine; if (_searchEngine.Parameters.ContainsKey("Options")) { dowOption = _eng.Engines.Where(e => e.Name == match.tracker).First().Parameters["Options"].ToString().Replace("%id%", match.Id); } } else { if (_searchEngine.Parameters.ContainsKey("Options")) { dowOption = _searchEngine.Parameters["Options"].ToString().Replace("%id%", match.Id); } } switch (selectedText) { case "Browse Folders": //FolderBrowser ViewFolders = new FolderBrowser(TorrentEngine.Instance().TorrentSession, label, match, dowOption); Log.Instance().Print("Loading file browser"); MyTorrents.ListType = "FolderBrowser"; MyTorrents.Instance().ShowFolderBrowser(); break; case "No change": if (label != null) { Log.Instance().Print("Starting torrent file downloading"); ok = TorrentEngine.Instance().StartDownloading(match.Url, label.Name, true, match.cookie, match.Id, dowOption, ""); } break; default: if (label != null) { Log.Instance().Print("Starting torrent file downloading"); ok = TorrentEngine.Instance().StartDownloading(match.Url, label.Name, true, match.cookie, match.Id, dowOption, String.Format("&download_dir={0}", selecteddirId - 2)); } break; } /* * if (!ok) * { * GUIDialogNotify notify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); * notify.Reset(); * notify.SetHeading("Failed!"); * notify.SetText("Unable to start download."); * notify.DoModal(GUIWindowManager.ActiveWindow); * * Log.Instance().Print("Downloading failed"); * } * */ }
private void OnGroupSelected(GUIListItem item, int iItem) { ChannelGroup group = item.TVTag as ChannelGroup; GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(group.GroupName); dlg.Add(Utility.GetLocalizedText(TextId.SelectThisGroup)); dlg.Add(Utility.GetLocalizedText(TextId.DeleteThisGroup)); if (group.VisibleInGuide) { dlg.Add(Utility.GetLocalizedText(TextId.HideFromGuide)); } else { dlg.Add(Utility.GetLocalizedText(TextId.ShowInGuide)); } dlg.DoModal(GetID); if (dlg.SelectedId > 0) { switch (dlg.SelectedLabel) { case 0: { foreach (GUIListItem Item in _channelGroupsList.ListItems) { Item.IsRemote = false; } item.IsRemote = true; SaveChannelsForCurrentGroup(); LoadAll(group); } break; case 1: { //_channelGroupsList.RemoveItem(iItem); SchedulerAgent.DeleteChannelGroup(group.ChannelGroupId, true, true); LoadAll(null); } break; case 2: { if (group.VisibleInGuide) { item.IsPlayed = true; group.VisibleInGuide = false; } else { item.IsPlayed = false; group.VisibleInGuide = true; } SchedulerAgent.SaveChannelGroup(group); } break; } } } }
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; } }
// Main folders (drives, net shares) private void OnAddEditFolder() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(496); // Menu dlg.AddLocalizedString(300009); // Name dlg.AddLocalizedString(300058); // Path if (_section == "movies") { if (_globalVideoThumbsEnaled) { dlg.AddLocalizedString(109); // Create thumbs } dlg.AddLocalizedString(300221); // Each folder is movie } //dlg.AddLocalizedString(1374); // layout dlg.AddLocalizedString(300059);// Pin if (_selectedOption != -1) { dlg.SelectedLabel = _selectedOption; } // Show dialog menu dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } _selectedOption = dlg.SelectedLabel; switch (dlg.SelectedId) { case 300009: OnAddName(); break; case 300058: _selectedLabelIndex = -1; OnAddPath(); break; case 109: OnThumb(); break; case 300221: OnMovieFolder(); break; //case 1374: // OnAddLayout(); // break; case 300059: OnAddPin(); break; } }
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 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); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { // we don't want the user to start another search while one is already active if (_workerCompleted == false) { return; } // Here we want to open the OSD Keyboard to enter the searchstring if (control == buttonSearch) { // If the search Button was clicked we need to bring up the search keyboard. VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD); if (null == keyboard) { return; } string searchterm = string.Empty; //keyboard.IsSearchKeyboard = true; keyboard.Reset(); keyboard.Text = ""; keyboard.DoModal(GetID); // show it... Log.Info("Wikipedia: OSD keyboard loaded!"); // If input is finished, the string is saved to the searchterm var. if (keyboard.IsConfirmed) { searchterm = keyboard.Text; // If there was a string entered try getting the article. if (searchterm != "") { Log.Info("Wikipedia: Searchterm gotten from OSD keyboard: {0}", searchterm); GetAndDisplayArticle(searchterm); } // Else display an error dialog. else { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlg.SetHeading(GUILocalizeStrings.Get(257)); // Error dlg.SetLine(1, GUILocalizeStrings.Get(2500)); // No searchterm entered! dlg.SetLine(2, string.Empty); dlg.SetLine(3, GUILocalizeStrings.Get(2501)); // Please enter a valid searchterm! dlg.DoModal(GUIWindowManager.ActiveWindow); } } } // This is the control to select the local Wikipedia site. if (control == buttonLocal) { // Create a new selection dialog. GUIDialogMenu pDlgOK = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (pDlgOK != null) { pDlgOK.Reset(); pDlgOK.SetHeading(GUILocalizeStrings.Get(2502)); //Select your local Wikipedia: // Add all the local sites we want to be displayed starting with int 0. Settings langreader = new Settings(Config.GetFile(Config.Dir.Config, "wikipedia.xml")); String allsites = langreader.GetValueAsString("Allsites", "sitenames", ""); Log.Info("Wikipedia: available sites: " + allsites); String[] siteArray = allsites.Split(','); for (int i = 0; i < siteArray.Length; i++) { int stringno = langreader.GetValueAsInt(siteArray[i], "string", 2006); pDlgOK.Add(GUILocalizeStrings.Get(stringno)); //English, German, French ... } pDlgOK.DoModal(GetID); if (pDlgOK.SelectedLabel >= 0) { SelectLocalWikipedia(pDlgOK.SelectedLabel, siteArray); } } } // The Button holding the Links to other articles if (control == buttonLinks) { if (linkArray.Count > 0) { // Create a new selection dialog. GUIDialogMenu pDlgOK = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (pDlgOK != null) { pDlgOK.Reset(); pDlgOK.SetHeading(GUILocalizeStrings.Get(2505)); //Links to other articles: // Add all the links from the linkarray. foreach (string link in linkArray) { pDlgOK.Add(link); } pDlgOK.DoModal(GetID); if (pDlgOK.SelectedLabel >= 0) { Log.Info("Wikipedia: new search from the links array: {0}", pDlgOK.SelectedLabelText); GetAndDisplayArticle(pDlgOK.SelectedLabelText); } } } else { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlg.SetHeading(GUILocalizeStrings.Get(257)); // Error dlg.SetLine(1, GUILocalizeStrings.Get(2506)); // No Links from this article. dlg.DoModal(GUIWindowManager.ActiveWindow); } } // The Button containing a list of all images from the article if (control == buttonImages) { if (imagedescArray.Count > 0) { // Create a new selection dialog. GUIDialogMenu pDlgOK = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (pDlgOK != null) { pDlgOK.Reset(); pDlgOK.SetHeading(GUILocalizeStrings.Get(2507)); //Images from this article // Add all the images from the imagearray. foreach (string image in imagedescArray) { pDlgOK.Add(image); } pDlgOK.DoModal(GetID); if (pDlgOK.SelectedLabel >= 0) { Log.Info("Wikipedia: new search from the image array: {0}", imagedescArray[pDlgOK.SelectedId - 1]); GetAndDisplayImage(imagenameArray[pDlgOK.SelectedId - 1].ToString(), imagedescArray[pDlgOK.SelectedId - 1].ToString()); } } } else { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlg.SetHeading(GUILocalizeStrings.Get(257)); // Error dlg.SetLine(1, GUILocalizeStrings.Get(2508)); // No Images referenced in this article. dlg.DoModal(GUIWindowManager.ActiveWindow); } } // Back to the text button to switch from image view if (control == buttonBack) { if (!txtArticle.IsVisible) { GUIControl.ShowControl(GetID, txtArticle.GetID); } if (imageControl.IsVisible) { GUIControl.HideControl(GetID, imageControl.GetID); } if (!searchtermLabel.IsVisible) { GUIControl.ShowControl(GetID, searchtermLabel.GetID); } if (imagedescLabel.IsVisible) { GUIControl.HideControl(GetID, imagedescLabel.GetID); } if (buttonBack.IsVisible) { GUIControl.HideControl(GetID, buttonBack.GetID); GUIControl.FocusControl(GetID, buttonSearch.GetID); } } base.OnClicked(controlId, control, actionType); }
protected virtual void OnShowViews() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(499); // Views menu dlg.AddLocalizedString(134); // Shares foreach (ViewDefinition view in handler.Views) { dlg.Add(view.LocalizedName); } bool isVideoWindow = (this.GetID == (int)Window.WINDOW_VIDEOS || this.GetID == (int)Window.WINDOW_VIDEO_TITLE); // set the focus to currently used view if (this.GetID == (int)Window.WINDOW_VIDEOS || this.GetID == (int)Window.WINDOW_MUSIC_FILES) { dlg.SelectedLabel = 0; } else if (this.GetID == (int)Window.WINDOW_VIDEO_TITLE || this.GetID == (int)Window.WINDOW_MUSIC_GENRE) { dlg.SelectedLabel = handler.CurrentViewIndex + 1; } // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedId) { case 134: // Shares { int nNewWindow; if (isVideoWindow) { nNewWindow = (int)Window.WINDOW_VIDEOS; } else { nNewWindow = (int)Window.WINDOW_MUSIC_FILES; } StateBase.StartWindow = nNewWindow; if (nNewWindow != GetID) { if (isVideoWindow) { MediaPortal.GUI.Video.GUIVideoFiles.Reset(); } GUIWindowManager.ReplaceWindow(nNewWindow); } } break; case 4540: // Now playing { int nPlayingNowWindow = (int)Window.WINDOW_MUSIC_PLAYING_NOW; MediaPortal.GUI.Music.GUIMusicPlayingNow guiPlayingNow = (MediaPortal.GUI.Music.GUIMusicPlayingNow)GUIWindowManager.GetWindow(nPlayingNowWindow); if (guiPlayingNow != null) { guiPlayingNow.MusicWindow = (MediaPortal.GUI.Music.GUIMusicBaseWindow) this; GUIWindowManager.ActivateWindow(nPlayingNowWindow); } } break; default: // a db view { ViewDefinition selectedView = (ViewDefinition)handler.Views[dlg.SelectedLabel - 1]; handler.CurrentView = selectedView.Name; StateBase.View = selectedView.Name; int nNewWindow; if (isVideoWindow) { nNewWindow = (int)Window.WINDOW_VIDEO_TITLE; } else { nNewWindow = (int)Window.WINDOW_MUSIC_GENRE; } if (GetID != nNewWindow) { StateBase.StartWindow = nNewWindow; if (nNewWindow != GetID) { GUIWindowManager.ReplaceWindow(nNewWindow); } } else { LoadDirectory(string.Empty); if (facadeLayout.Count <= 0) { GUIControl.FocusControl(GetID, btnLayouts.GetID); } } } break; } }
protected virtual void OnShowLayouts() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(792); // Layouts menu int dlgItems = 0; int totalLayouts = Enum.GetValues(typeof(GUIFacadeControl.Layout)).Length; bool[] allowedLayouts = new bool[totalLayouts]; for (int i = 0; i < totalLayouts; i++) { string layoutName = Enum.GetName(typeof(GUIFacadeControl.Layout), i); GUIFacadeControl.Layout layout = GetLayoutNumber(layoutName); if (AllowLayout(layout)) { if (!facadeLayout.IsNullLayout(layout)) { dlg.Add(GUIFacadeControl.GetLayoutLocalizedName(layout)); dlgItems++; allowedLayouts[i] = true; } } } dlg.SelectedLabel = -1; for (int i = 0; i <= (int)CurrentLayout; i++) { if (allowedLayouts[i]) { dlg.SelectedLabel++; } } if (dlg.SelectedLabel >= dlgItems) { dlg.SelectedLabel = dlgItems; } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } int iSelectedLayout = dlg.SelectedLabel; int allowedItemsFound = -1; for (int i = 0; i < allowedLayouts.Length; i++) { if (allowedLayouts[i]) { iSelectedLayout = i; allowedItemsFound++; if (allowedItemsFound == dlg.SelectedLabel) { break; } } } CurrentLayout = (Layout)iSelectedLayout; SwitchLayout(); UpdateButtonStates(); }
private void OnChangeKeepUntilMode() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.DefaultKeepMode)); dlg.Add(Utility.GetLocalizedText(TextId.UntilSpaceNeeded)); dlg.Add(Utility.GetLocalizedText(TextId.NumberOfDays)); dlg.Add(Utility.GetLocalizedText(TextId.NumberOfEpisodes)); dlg.Add(Utility.GetLocalizedText(TextId.NumberOfWatchedEpisodes)); dlg.Add(Utility.GetLocalizedText(TextId.Forever)); int selectedId = 0; switch (_currentKeepUntilMode) { case KeepUntilMode.UntilSpaceIsNeeded: selectedId = 0; break; case KeepUntilMode.NumberOfDays: selectedId = 1; break; case KeepUntilMode.NumberOfEpisodes: selectedId = 2; break; case KeepUntilMode.NumberOfWatchedEpisodes: selectedId = 3; break; case KeepUntilMode.Forever: selectedId = 4; break; } dlg.SelectedLabel = selectedId; dlg.DoModal(GetID); if (dlg.SelectedId > 0) { switch (dlg.SelectedLabel) { case 0: _currentKeepUntilMode = KeepUntilMode.UntilSpaceIsNeeded; break; case 1: _currentKeepUntilMode = KeepUntilMode.NumberOfDays; break; case 2: _currentKeepUntilMode = KeepUntilMode.NumberOfEpisodes; break; case 3: _currentKeepUntilMode = KeepUntilMode.NumberOfWatchedEpisodes; break; case 4: _currentKeepUntilMode = KeepUntilMode.Forever; break; } if (_currentKeepUntilMode != KeepUntilMode.Forever && _currentKeepUntilMode != KeepUntilMode.UntilSpaceIsNeeded) { DataTable valueTable = KeepUntilControlUtility.CreateValueTable(_currentKeepUntilMode, null); _currentKeepUntilValue = (int)valueTable.Rows[0][KeepUntilControlUtility.ValueColumnName]; } } } }
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(); }
private void OnShowLogs() { string text = string.Empty; string[] modules = LogServiceAgent.GetAllModules(); string selectedModule = string.Empty; LogSeverity selectedSeverity = LogSeverity.Error; bool showAllSeverities = true; bool showAllModules = true; if (modules != null && modules.Length > 1) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading("Select module"); dlg.Add(Utility.GetLocalizedText(TextId.All)); foreach (string module in modules) { dlg.Add(module); } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } if (dlg.SelectedId > 0) { if (dlg.SelectedLabel > 0) { showAllModules = false; } selectedModule = dlg.SelectedLabelText; } } } GUIDialogMenu dlg2 = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg2 != null) { dlg2.Reset(); dlg2.SetHeading("Select severity"); dlg2.Add(Utility.GetLocalizedText(TextId.All)); dlg2.Add(LogSeverity.Error.ToString()); dlg2.Add(LogSeverity.Fatal.ToString()); dlg2.Add(LogSeverity.Information.ToString()); dlg2.Add(LogSeverity.Warning.ToString()); dlg2.DoModal(GetID); if (dlg2.SelectedId == -1) { return; } if (dlg2.SelectedId > 0) { if (dlg2.SelectedLabel > 0) { showAllSeverities = false; } switch (dlg2.SelectedLabel) { case 1: selectedSeverity = LogSeverity.Error; break; case 2: selectedSeverity = LogSeverity.Fatal; break; case 3: selectedSeverity = LogSeverity.Information; break; case 4: selectedSeverity = LogSeverity.Warning; break; } } } bool maxReached; LogEntry[] entries = null; if (showAllModules && showAllSeverities) { SortedList <DateTime, LogEntry> _entries = new SortedList <DateTime, LogEntry>(); foreach (string module in modules) { entries = LogServiceAgent.GetLogEntriesByModule(module, DateTime.Now.AddDays(-_daysToGetLogsFrom), DateTime.Now, _maxLogEntries / 2, out maxReached); if (entries != null && entries.Length > 0) { foreach (LogEntry entry in entries) { if (!_entries.ContainsKey(entry.LogTime)) { _entries.Add(entry.LogTime, entry); } } } } if (_entries != null && _entries.Count > 0) { for (int i = _entries.Count - 1; i >= 0; i--) { text += "#" + _entries.Values[i].LogSeverity.ToString() + ":" + _entries.Values[i].LogTime.ToString() + ":" + _entries.Values[i].Module.ToString() + ":" + _entries.Values[i].Message + "\n"; } } } else if (!showAllModules && showAllSeverities) { entries = LogServiceAgent.GetLogEntriesByModule(selectedModule, DateTime.Now.AddDays(-_daysToGetLogsFrom), DateTime.Now, _maxLogEntries, out maxReached); if (entries != null && entries.Length > 0) { for (int i = 0; i < entries.Length; i++) { text += "#" + entries[i].LogSeverity.ToString() + ":" + entries[i].LogTime.ToString() + ":" + entries[i].Message + "\n"; } } } else if (showAllModules && !showAllSeverities) { entries = LogServiceAgent.GetLogEntriesBySeverity(selectedSeverity, DateTime.Now.AddDays(-_daysToGetLogsFrom), DateTime.Now, _maxLogEntries, out maxReached); if (entries != null && entries.Length > 0) { for (int i = 0; i < entries.Length; i++) { text += "#" + entries[i].LogTime.ToString() + ":" + entries[i].Module.ToString() + ":" + entries[i].Message + "\n"; } } } else if (!showAllModules && !showAllSeverities) { entries = LogServiceAgent.GetLogEntriesByModuleAndSeverity(selectedModule, selectedSeverity, DateTime.Now.AddDays(-_daysToGetLogsFrom), DateTime.Now, _maxLogEntries, out maxReached); if (entries != null && entries.Length > 0) { for (int i = 0; i < entries.Length; i++) { text += "#" + entries[i].LogTime.ToString() + ":" + entries[i].Message + "\n"; } } } GUIDialogText dlg3 = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT); if (dlg3 != null) { dlg3.Reset(); dlg3.SetHeading("Log entries"); dlg3.SetText(text); dlg3.DoModal(GetID); } }
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(); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == btnSkin) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(166); // menu List <string> installedSkins = new List <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, true) != 0) { btnSkin.Label = dlg.SelectedLabelText; OnSkinChanged(); } return; } if (control == btnLanguage) { GUIDialogMenu 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].ToLower() == currentLanguage.ToLower()) { dlg.SelectedLabel = i; break; } } dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } if (String.Compare(dlg.SelectedLabelText, btnLanguage.Label, true) != 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(); }
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 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()); } }
private void OnChannelSelected(GUIListItem item, int iItem, bool isAllChannelList) { Channel channel = item.TVTag as Channel; if (channel == null) { return; } if (isAllChannelList) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(channel.DisplayName); dlg.Add(Utility.GetLocalizedText(TextId.AddToGroup)); if (channel.VisibleInGuide) { dlg.Add(Utility.GetLocalizedText(TextId.HideFromGuide)); } else { dlg.Add(Utility.GetLocalizedText(TextId.ShowInGuide)); } string text = Utility.GetLocalizedText(TextId.None); if (channel.GuideChannelId.HasValue) { GuideChannel ch = GetGuideChannelForChannel(channel); if (ch != null) { text = ch.Name; } } dlg.Add(Utility.GetLocalizedText(TextId.GuideChannel) + ": " + text); dlg.Add(Utility.GetLocalizedText(TextId.DeleteChannel)); dlg.DoModal(GetID); if (dlg.SelectedId > 0) { _savingNeeded = true; switch (dlg.SelectedLabel) { case 0: { _channelsInGroupList.Add(item); _allChannelsList.RemoveItem(iItem); } break; case 1: { if (channel.VisibleInGuide) { item.IsPlayed = true; channel.VisibleInGuide = false; } else { item.IsPlayed = false; channel.VisibleInGuide = true; } SchedulerAgent.SaveChannel(channel); } break; case 2: { OnChangeGuideChannel(channel); item.TVTag = SchedulerAgent.GetChannelById(channel.ChannelId); } break; case 3: { if (OnDeleteChannel(channel)) { _allChannelsList.RemoveItem(iItem); } } break; } } } } else// channels in group list { if (!item.IsRemote) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(channel.DisplayName); dlg.Add(Utility.GetLocalizedText(TextId.MoveChannel)); dlg.Add(Utility.GetLocalizedText(TextId.DeleteChannelFromGroup)); if (channel.VisibleInGuide) { dlg.Add(Utility.GetLocalizedText(TextId.HideFromGuide)); } else { dlg.Add(Utility.GetLocalizedText(TextId.ShowInGuide)); } string text = Utility.GetLocalizedText(TextId.None); if (channel.GuideChannelId.HasValue) { GuideChannel ch = GetGuideChannelForChannel(channel); if (ch != null) { text = ch.Name; } } dlg.Add(Utility.GetLocalizedText(TextId.GuideChannel) + ": " + text); dlg.Add(Utility.GetLocalizedText(TextId.DeleteChannel)); dlg.DoModal(GetID); if (dlg.SelectedId > 0) { _savingNeeded = true; switch (dlg.SelectedLabel) { case 0: item.IsRemote = true; break; case 1: { _channelsInGroupList.RemoveItem(iItem); _allChannelsList.Add(item); } break; case 2: { if (channel.VisibleInGuide) { item.IsPlayed = true; channel.VisibleInGuide = false; } else { item.IsPlayed = false; channel.VisibleInGuide = true; } SchedulerAgent.SaveChannel(channel); } break; case 3: { OnChangeGuideChannel(channel); item.TVTag = SchedulerAgent.GetChannelById(channel.ChannelId); } break; case 4: { if (OnDeleteChannel(channel)) { _channelsInGroupList.RemoveItem(iItem); } } break; } } } } else { item.IsRemote = false; } } }
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(); } } }
public static bool ShowSettingsDialog(int selectedLabel = 0) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(Translator.Instance.options); int startup; var startupStates = Options.Instance.GetStartupOptions(out startup); string startupValue = startupStates.Single(s => s.Value == startup).Name; dlg.Add(new GUIListItem(Translator.Instance.startupview) { Label2 = startupValue }); bool clickToDetails = Options.Instance.GetBoolOption("clicktodetails"); dlg.Add(new GUIListItem(Translator.Instance.clicktodetails) { Label2 = clickToDetails.ToString() }); bool stopMedia = Options.Instance.GetBoolOption("stopmediaplayback"); dlg.Add(new GUIListItem(Translator.Instance.stopmediaplayback) { Label2 = stopMedia.ToString() }); bool showSortValue = Options.Instance.GetBoolOption("showsortvalue"); dlg.Add(new GUIListItem(Translator.Instance.showsortvalue) { Label2 = showSortValue.ToString() }); dlg.SelectedLabel = selectedLabel; dlg.DoModal(Plugin.WINDOW_ID); selectedLabel = dlg.SelectedLabel; if (dlg.SelectedId > 0) { switch (dlg.SelectedId) { case 1: if (ShowStringSelect(ref startupValue, startupStates.Select(s => s.Name).ToArray(), Plugin.WINDOW_ID)) { Options.Instance.UpdateOption("startupstate", startupStates.Single(s => s.Name == startupValue).Value); } break; case 2: if (ShowBoolDialog(ref clickToDetails, Plugin.WINDOW_ID)) { Options.Instance.UpdateOption("clicktodetails", clickToDetails); } break; case 3: if (ShowBoolDialog(ref stopMedia, Plugin.WINDOW_ID)) { Options.Instance.UpdateOption("stopmediaplayback", stopMedia); } break; case 4: if (ShowBoolDialog(ref showSortValue, Plugin.WINDOW_ID)) { Options.Instance.UpdateOption("showsortvalue", showSortValue); } break; } ShowSettingsDialog(selectedLabel); return(true); } } return(false); }
internal void MyContextMenu() { try { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(924); //Add Details Menu Item //Play Menu Item GUIListItem pItem = new GUIListItem(Translation.Play); dlg.Add(pItem); pItem.ItemId = 1; pItem = new GUIListItem(Translation.MovieDetails); dlg.Add(pItem); pItem.ItemId = 2; //Add Watched/Unwatched Filter Menu Item if (CurrentFacade.UnWatched) { pItem = new GUIListItem(Translation.ShowUnwatchedMovies); dlg.Add(pItem); pItem.ItemId = 3; } else { pItem = new GUIListItem(Translation.ShowAllMovies); dlg.Add(pItem); pItem.ItemId = 3; } //Add Latests/Watched/Rated Menu Item pItem = new GUIListItem("[^] " + CurrentFacade.Title); dlg.Add(pItem); pItem.ItemId = 4; pItem = new GUIListItem(); pItem.Label = Translation.Update; pItem.ItemId = 5; dlg.Add(pItem); //Show Dialog dlg.DoModal(Utils.ActiveWindow); if (dlg.SelectedLabel == -1) { return; } switch (dlg.SelectedId) { case 1: { PlayMovie(GUIWindowManager.GetWindow(Utils.ActiveWindow)); break; } case 2: { ShowInfo(); break; } case 3: { CurrentFacade.UnWatched = !CurrentFacade.UnWatched; MyVideosUpdateLatest(); break; } case 4: { IDialogbox ldlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (ldlg == null) { return; } ldlg.Reset(); ldlg.SetHeading(924); //Add Types Menu Items pItem = new GUIListItem((CurrentFacade.Type == LatestsFacadeType.Latests ? "[x] " : string.Empty) + Translation.LabelLatestAdded); ldlg.Add(pItem); pItem.ItemId = 1; pItem = new GUIListItem((CurrentFacade.Type == LatestsFacadeType.Watched ? "[x] " : string.Empty) + Translation.LabelLatestWatched); ldlg.Add(pItem); pItem.ItemId = 2; pItem = new GUIListItem((CurrentFacade.Type == LatestsFacadeType.Rated ? "[x] " : string.Empty) + Translation.LabelHighestRated); ldlg.Add(pItem); pItem.ItemId = 3; //Show Dialog ldlg.DoModal(Utils.ActiveWindow); if (ldlg.SelectedLabel == -1) { return; } switch (ldlg.SelectedId - 1) { case 0: CurrentFacade.Type = LatestsFacadeType.Latests; break; case 1: CurrentFacade.Type = LatestsFacadeType.Watched; break; case 2: CurrentFacade.Type = LatestsFacadeType.Rated; break; } MyVideosUpdateLatest(); break; } case 5: { MyVideosUpdateLatest(); break; } } } catch (Exception ex) { logger.Error("MyContextMenu: " + ex.ToString()); } }