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 OnPlayBackEnded(global::MediaPortal.Player.g_Player.MediaType type, string filename) { GUIWindowManager.ActivateWindow(WindowId.TvHome); }
private void FileItemDialog() { // active this window... GUIWindowManager.IsSwitchingToNewWindow = true; GUIWindowManager.RouteToWindow(GetID); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, m_dwParentWindowID, 0, null); OnMessage(msg); string strFileOperation = ""; if (m_iFileMode == 1) { strFileOperation = GUILocalizeStrings.Get(116); } else { strFileOperation = GUILocalizeStrings.Get(115); } SetHeading(strFileOperation); SetLine(1, 505); SetButtonsHidden(true); ShowProgressBar(true); SetPercentage(0); GUIWindowManager.Process(); // calc nr of files m_dwTotalSize = 0; m_iNrOfItems = 0; FileItemGetNrOfFiles(m_itemSourceItem); // set number of objects strFileOperation += " " + m_iNrOfItems.ToString() + " " + GUILocalizeStrings.Get(507) + " ("; if (m_dwTotalSize > 1024 * 1024) { strFileOperation += (m_dwTotalSize / (1024 * 1024)).ToString() + " MB)"; } else if (m_dwTotalSize > 1024) { strFileOperation += (m_dwTotalSize / 1024).ToString() + " KB)"; } else { strFileOperation += m_dwTotalSize.ToString() + " Bytes)"; } SetNewHeading(strFileOperation); SetLine(1, GUILocalizeStrings.Get(508) + " \"" + destinationFolder + "\" ?"); m_bButtonYes = false; m_bCanceled = false; m_bBusy = false; m_bButtonNo = false; m_bAlways = false; m_bNever = false; m_bReload = false; m_iFileNr = 1; sourceFolder = Path.GetDirectoryName(m_itemSourceItem.Path); GUIWindowManager.IsSwitchingToNewWindow = false; m_bRunning = true; while (m_bRunning && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING) { GUIWindowManager.Process(); } }
public override void OnAction(Action action) { switch (action.wID) { ////case Action.ActionType.ACTION_PREV_ITEM: //// { //// //g_playlistPlayer.PlayPrevious(); //// } //// break; ////case Action.ActionType.ACTION_NEXT_ITEM: //// { //// //g_playlistPlayer.PlayNext(); //// } //// break; case Action.ActionType.ACTION_PREVIOUS_MENU: case Action.ActionType.ACTION_MOUSE_CLICK: case Action.ActionType.ACTION_SHOW_GUI: { GUIGraphicsContext.IsFullScreenVideo = false; GUIWindowManager.ShowPreviousWindow(); return; } case Action.ActionType.ACTION_MOVE_DOWN: case Action.ActionType.ACTION_BIG_STEP_BACK: { double currentpos = g_Player.CurrentPosition; double duration = g_Player.Duration; double percent = (currentpos / duration) * 100d; percent -= 10d; if (percent < 0) { percent = 0; } g_Player.SeekAsolutePercentage((int)percent); return; } case Action.ActionType.ACTION_MOVE_UP: case Action.ActionType.ACTION_BIG_STEP_FORWARD: { double currentpos = g_Player.CurrentPosition; double duration = g_Player.Duration; double percent = (currentpos / duration) * 100d; percent += 10d; if (percent > 100d) { percent = 100d; } g_Player.SeekAsolutePercentage((int)percent); return; } case Action.ActionType.ACTION_STOP: { Log.Info("GUIMusicFullscreen:stop"); g_Player.Stop(); GUIWindowManager.ShowPreviousWindow(); } break; case Action.ActionType.ACTION_SMALL_STEP_BACK: { if (g_Player.CanSeek) { // seek back 5 sec double dPos = g_Player.CurrentPosition; if (dPos > 5) { g_Player.SeekAbsolute(dPos - 5.0d); } } } break; case Action.ActionType.ACTION_SMALL_STEP_FORWARD: { if (g_Player.CanSeek) { // seek forward 5 sec double dPos = g_Player.Duration - g_Player.CurrentPosition; if (dPos > 5) { g_Player.SeekAbsolute(g_Player.CurrentPosition + 5.0d); } } } break; case Action.ActionType.ACTION_PLAY: case Action.ActionType.ACTION_MUSIC_PLAY: { g_Player.StepNow(); g_Player.Speed = 1; if (g_Player.Paused) { g_Player.Pause(); } } break; case Action.ActionType.ACTION_PLAY_AGAIN: { g_Player.SeekAsolutePercentage(0); return; } break; } base.OnAction(action); }
private void SendListsToFacade(IEnumerable <TraktUserList> lists) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (lists.Count() == 0 && TraktSettings.Username != CurrentUser) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), string.Format(Translation.NoUserLists, CurrentUser)); CurrentUser = TraktSettings.Username; GUIWindowManager.ShowPreviousWindow(); return; } if (lists.Count() == 0) { if (!GUIUtils.ShowYesNoDialog(Translation.Lists, Translation.NoListsFound, true)) { // nothing to do, exit GUIWindowManager.ShowPreviousWindow(); return; } TraktList list = new TraktList(); if (TraktLists.GetListDetailsFromUser(ref list)) { TraktLogger.Info("Creating new '{0}' list '{1}'", list.Privacy, list.Name); CreateList(list); } return; } int itemId = 0; // Add each list foreach (var list in lists) { GUIListItem item = new GUIListItem(list.Name); item.Label2 = TraktLists.GetPrivacyLevelTranslation(list.Privacy); item.TVTag = list; item.ItemId = Int32.MaxValue - itemId; item.IconImage = "defaultFolder.png"; item.IconImageBig = "defaultFolderBig.png"; item.ThumbnailImage = "defaultFolderBig.png"; item.OnItemSelected += OnItemSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout("List"); GUIControl.FocusControl(GetID, Facade.GetID); if (PreviousSelectedIndex >= lists.Count()) { Facade.SelectIndex(PreviousSelectedIndex - 1); } else { Facade.SelectIndex(PreviousSelectedIndex); } // set facade properties GUIUtils.SetProperty("#itemcount", lists.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", lists.Count().ToString(), lists.Count() > 1 ? Translation.Lists : Translation.List)); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { //if (GUIBackgroundTask.Instance.IsBusy) return; switch (controlId) { #region SEARCH LIST CONTROL SELECTED case (3): if (actionType == Action.ActionType.ACTION_SELECT_ITEM) { GUIListItem item = resultListControl.SelectedListItem as GUIListItem; #if DEBUG TraktLogger.Info("The button pressed has a tvTAG as: {0}, ad has a string value of: {1}", item.TVTag.GetType(), item.TVTag.ToString()); #endif #region SCROBBLEMOVIE if (item.TVTag is TraktMovieSummary) { // Get movie from traktmoviesummary TraktMovie currentMovieSelected = new TraktMovie { Title = ((TraktMovieSummary)item.TVTag).Title, Year = ((TraktMovieSummary)item.TVTag).Year, Ids = ((TraktMovieSummary)item.TVTag).Ids }; var data = new TraktScrobbleMovie { Movie = currentMovieSelected, Progress = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()), AppDate = TraktSettings.BuildDate, AppVersion = TraktSettings.Version }; EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData((TraktMovieSummary)item.TVTag)); EbasicHandler.overrideCurrentProgram((TraktMovieSummary)item.TVTag); EbasicHandler.StartScrobble(data); } #endregion else if (item.TVTag is TraktShowSummary) //search for seasons { TraktLogger.Info("TraktShowSummary Detected"); currentTvShow = (TraktShowSummary)item.TVTag; searchStack.Push(currentSearch); PopulateListControl(EbasicHandler.SearchShowSeasons(((TraktShowSummary)item.TVTag).Ids.Slug), searchlevel++); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null); OnMessage(msg); } else if (item.TVTag is TraktSeasonSummary) //Episode for episodes { #if DEBUG TraktLogger.Info("SeasonSummary Detected"); TraktLogger.Info("Season '{0}' for show {1} selected. Getting Episodes.", ((TraktSeasonSummary)item.TVTag).Number, currentTvShow.Ids.Slug); #endif searchStack.Push(currentSearch); PopulateListControl(EbasicHandler.SearchSeasonEpisodes(currentTvShow.Ids.Slug, ((TraktSeasonSummary)item.TVTag).Number.ToString()), searchlevel++); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null); OnMessage(msg); } #region SCROBBLESHOW else if (item.TVTag is TraktEpisodeSummary) //found! { TraktLogger.Info("EpisodeSummary Detected"); var data = new TraktScrobbleEpisode { Show = new TraktShow { Title = currentTvShow.Title, Year = currentTvShow.Year, Ids = currentTvShow.Ids }, Episode = new TraktEpisode { Season = ((TraktEpisodeSummary)item.TVTag).Season, Number = ((TraktEpisodeSummary)item.TVTag).Number, Title = ((TraktEpisodeSummary)item.TVTag).Title, Ids = ((TraktEpisodeSummary)item.TVTag).Ids }, Progress = EbasicHandler.GetPlayerProgress(EbasicHandler.getCurrentProgram()), AppDate = TraktSettings.BuildDate, AppVersion = TraktSettings.Version }; #if DEBUG TraktLogger.Info(currentTvShow.ToString()); #endif EPGCache.addOnCache(EbasicHandler.getCurrentProgram().getOriginalTitle(), EPGCache.createData(currentTvShow)); EbasicHandler.overrideCurrentProgram(currentTvShow, data.Episode); EbasicHandler.StartScrobble(data); } #endregion else if (item.TVTag.ToString() == "FirstButton") { if ((item.Label).ToString() == "Manual Search") { //popup the input dialog to search. I need to call the full GUI here. #if DEBUG TraktLogger.Info("Manual search selected"); #endif VirtualKeyboard keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD); //keyboard.IsSearchKeyboard = true; keyboard.Reset(); keyboard.Text = EbasicHandler.getCurrentProgram().Title; keyboard.DoModal(GUIWindowManager.ActiveWindow); if (keyboard.IsConfirmed) { //PopulateControlWithShows(keyboard.Text); //PopulateListControl(TraktAPI.TraktAPI.SearchShowByName(keyboard.Text)); //GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null); //OnMessage(msg); //GUIShowSelectGUI.setCurrentSearch(TraktAPI.TraktAPI.SearchByName(keyboard.Text)); //GUIWindowManager.ActivateWindow((int)TraktGUIWindows.EPGShowSelect); GUIShowSelectGUI.callSearchGUI(TraktAPI.TraktAPI.SearchByName(keyboard.Text)); } } else //this handles back button { TraktLogger.Info("BackButtonDetected"); PopulateListControl(searchStack.Pop(), searchlevel--); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, 0, 0, null); OnMessage(msg); } } } break; #endregion default: TraktLogger.Info("I don't know what's the object."); base.OnClicked(controlId, control, actionType); break; } }
public void GetAlbumCovers(string artist, string album, string strPath, int parentWindowID, bool checkForCompilationAlbum) { _SelectedAlbum = null; IsCompilationAlbum = false; if (checkForCompilationAlbum) { IsCompilationAlbum = GetIsCompilationAlbum(strPath, -1); } _Artist = artist; _Album = album; _AlbumPath = strPath; string origAlbumName = _Album; string filteredAlbumFormatString = GUILocalizeStrings.Get(4518); if (filteredAlbumFormatString.Length == 0) { filteredAlbumFormatString = "Album title not found\r\nTrying: {0}"; } _ThumbPath = GetCoverArtThumbPath(artist, album, strPath); amazonWS = new AmazonWebservice(); amazonWS.MaxSearchResultItems = MAX_SEARCH_ITEMS; amazonWS.FindCoverArtProgress += new AmazonWebservice.FindCoverArtProgressHandler(amazonWS_GetAlbumInfoProgress); amazonWS.FindCoverArtDone += new AmazonWebservice.FindCoverArtDoneHandler(amazonWS_FindCoverArtDone); Log.Info("Cover art grabber:getting cover art for [{0}-{1}]...", _Artist, _Album); if (IsCompilationAlbum) { Log.Info("Cover art grabber:compilation album found", _Artist, _Album); amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; _Artist = ""; string filterString = string.Format("{0} = \"{1}\"", GUILocalizeStrings.Get(484), " "); string filter = string.Format(filteredAlbumFormatString, filterString); Log.Info("Cover art grabber:trying again with blank artist name..."); InternalGetAlbumCovers(_Artist, _Album, filter); } else { InternalGetAlbumCovers(_Artist, _Album, string.Empty); } // Did we fail to find any albums? if (!amazonWS.HasAlbums && !amazonWS.AbortGrab) { // Check if the album title includes a disk number description that might // be altering the proper album title such as: White album (Disk 2) string cleanAlbumName = string.Empty; if (StripDiskNumberFromAlbumName(_Album, ref cleanAlbumName)) { amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; if (AlbumNotFoundRetryingFiltered != null) { AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, cleanAlbumName); } Log.Info("Cover art grabber:[{0}-{1}] not found. Trying [{0}-{2}]...", _Artist, _Album, cleanAlbumName); string filter = string.Format(filteredAlbumFormatString, cleanAlbumName); origAlbumName = _Album; InternalGetAlbumCovers(_Artist, cleanAlbumName, filter); } else if (GetProperAlbumName(_Album, ref cleanAlbumName)) { amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; if (AlbumNotFoundRetryingFiltered != null) { AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, cleanAlbumName); } Log.Info("Cover art grabber:[{0}-{1}] not found. Trying album name without sub-title [{0}-{2}]...", _Artist, _Album, cleanAlbumName); string filter = string.Format(filteredAlbumFormatString, cleanAlbumName); origAlbumName = _Album; InternalGetAlbumCovers(_Artist, cleanAlbumName, filter); } } // Still no albums? if (!IsCompilationAlbum && !amazonWS.HasAlbums && !amazonWS.AbortGrab) { amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS; if (AlbumNotFoundRetryingFiltered != null) { AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, GUILocalizeStrings.Get(4506)); } string filterString = string.Format("{0} = \"{1}\"", GUILocalizeStrings.Get(483), " "); string filter = string.Format(filteredAlbumFormatString, filterString); // Try searching by artist only to get all albums for this artist... Log.Info("Cover art grabber:[{0}-{1}] not found. Trying again with blank album name...", _Artist, _Album); InternalGetAlbumCovers(_Artist, "", filter); } // if we're searching for a single album the progress dialog will // be displayed so we need to close it... if (SearchMode == SearchDepthMode.Album) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.SetPercentage(100); dlgProgress.Progress(); dlgProgress.Close(); } } amazonWS.FindCoverArtProgress -= new AmazonWebservice.FindCoverArtProgressHandler(amazonWS_GetAlbumInfoProgress); amazonWS.FindCoverArtDone -= new AmazonWebservice.FindCoverArtDoneHandler(amazonWS_FindCoverArtDone); }
// 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; } }
private void OnAddPath() { GUIDialogSelect dlg = (GUIDialogSelect)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(300049); // Folder browser dlg.EnableButton(true); dlg.SetButtonLabel(424); // manual // Get drive list if (_folderLvl == 0) { ClearFolders(); GetDrives(); } // Add list to dlg menu foreach (GUIListItem drive in _folders) { dlg.Add(drive.Label); if (drive.IsPlayed) { dlg.SelectedLabel = _folders.IndexOf(drive); } } // Show dialog menu dlg.MarkSelectedItemOnButton = true; dlg.DoModal(GetID); // Folder is selected - return if (dlg.IsButtonPressed) { GUIListItem item = (GUIListItem)_folders[dlg.SelectedItemLabelIndexNoFocus]; _folderPath = item.Label2; // Reset browsing history ClearFolders(); OnAddEditFolder(); return; } //ESC pressed, go back folder or if it's lvl=0 (Drives) return if (dlg.SelectedLabel == -1) { if (_folderLvl > 0) { GetFolderHistory(); OnAddPath(); return; } else { ClearFolders(); _userNetFolder = GUILocalizeStrings.Get(145); // Network OnAddEditFolder(); return; } } // Browse folders further _selectedLabelIndex = dlg.SelectedLabel; GUIListItem selectedItem = (GUIListItem)_folders[dlg.SelectedItemLabelIndexNoFocus]; GetFolders(selectedItem); OnAddPath(); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { base.OnClicked(controlId, control, actionType); // Default folder (select/deselect on click) - settings saved if (control == videosShareListcontrol) { OnSetDefaultFolder(); } // Add new folder if (control == btnAdd) { // reset menu position _selectedOption = -1; // reset folder browser ClearFolders(); // Clear folder info ClearFolderInfoData(); _userNetFolder = GUILocalizeStrings.Get(145); // Network // Show menu OnAddEditFolder(); // Define new folder GUIListItem item = new GUIListItem(); // Watch for last parameter (my version with selective thumbs will use that) ShareData shareData = new ShareData("", "", "", true); item.AlbumInfoTag = shareData; _shareFolderListItem = item; // Check new data CheckCurrentShareData(); if (_error) { _error = false; GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(257); dlgOk.SetLine(1, GUILocalizeStrings.Get(300053)); // Error in folder data dlgOk.SetLine(2, GUILocalizeStrings.Get(300054)); // Name or path couldn't be empty dlgOk.DoModal(GUIWindowManager.ActiveWindow); return; } // Prepare folder info data FolderInfo(_shareFolderListItem).DefaultLayout = SettingsSharesHelper.ProperLayoutFromDefault(_folderDefaultLayoutIndex); FolderInfo(_shareFolderListItem).Name = _folderName; FolderInfo(_shareFolderListItem).Folder = _folderPath; FolderInfo(_shareFolderListItem).CreateThumbs = _folderCreateThumbs; FolderInfo(_shareFolderListItem).EachFolderIsMovie = _folderEachFolderIsMovie; FolderInfo(_shareFolderListItem).PinCode = _folderPin; // Almost forgot this, needed for proper sort :) _shareFolderListItem.Label = _folderName; _shareFolderListItem.OnItemSelected += OnItemSelected; // Add new folder in list videosShareListcontrol.Add(_shareFolderListItem); GUIListItem newItem = _shareFolderListItem; Sort(); int index = videosShareListcontrol.ListItems.IndexOf(newItem); videosShareListcontrol.SelectedListItemIndex = index; } // Edit folder if (control == btnEdit) { string name = _folderName; string path = _folderPath; // reset menu position _selectedOption = -1; OnAddEditFolder(); // Check new data CheckCurrentShareData(); if (_error) { _error = false; GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(257); dlgOk.SetLine(1, GUILocalizeStrings.Get(300053)); // Error in folder data dlgOk.SetLine(2, GUILocalizeStrings.Get(300054)); // Name or path couldn't be empty dlgOk.DoModal(GUIWindowManager.ActiveWindow); _folderName = name; _folderPath = path; return; } // Update changes FolderInfo(_shareFolderListItem).Name = _folderName; _shareFolderListItem.Label = _folderName; FolderInfo(_shareFolderListItem).Folder = _folderPath; FolderInfo(_shareFolderListItem).PinCode = _folderPin; FolderInfo(_shareFolderListItem).CreateThumbs = _folderCreateThumbs; FolderInfo(_shareFolderListItem).EachFolderIsMovie = _folderEachFolderIsMovie; FolderInfo(_shareFolderListItem).DefaultLayout = SettingsSharesHelper.ProperLayoutFromDefault(_folderDefaultLayoutIndex); // Add changes to a listitem videosShareListcontrol.SelectedListItem.AlbumInfoTag = _shareFolderListItem.AlbumInfoTag; videosShareListcontrol.SelectedListItem.Label = _folderName; // Sort list GUIListItem newItem = _shareFolderListItem; Sort(); int index = videosShareListcontrol.ListItems.IndexOf(newItem); videosShareListcontrol.SelectedListItemIndex = index; } // Remove folder - settings saved if (control == btnRemove) { OnRemoveFolder(); } // Reset folders - settings saved if (control == btnReset) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(GUILocalizeStrings.Get(927)); // Warning dlgYesNo.SetLine(1, GUILocalizeStrings.Get(300055)); // this will delete folders dlgYesNo.DoModal(GetID); if (dlgYesNo.IsConfirmed) { OnResetFolders(); } } } }
/// <summary> /// Network share enumeration from netShare parameter resource /// </summary> /// <param name="netShare">Network resource</param> private void GetNetworkFolders(string netShare) { ArrayList netComputers = NetShareCollection.GetComputersOnNetwork(); if (netComputers == null || netComputers.Count == 0) { GUIDialogOK dlgOk = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); dlgOk.SetHeading(GUILocalizeStrings.Get(1020)); dlgOk.SetLine(1, GUILocalizeStrings.Get(300056)); //No network resources found. dlgOk.SetLine(2, GUILocalizeStrings.Get(300057)); // Try manual search. dlgOk.DoModal(GetID); GetStringFromKeyboard(ref netShare, -1); } else { GUIDialogSelect dlg = (GUIDialogSelect)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(924); // Menu dlg.EnableButton(true); dlg.SetButtonLabel(413); // manual // Add list to dlg menu foreach (string netWrkst in netComputers) { dlg.Add(netWrkst); } // Show dialog menu dlg.DoModal(GetID); if (dlg.IsButtonPressed) { GetStringFromKeyboard(ref netShare, -1); } else if (dlg.SelectedLabel == -1) { return; } else { netShare = dlg.SelectedLabelText; } } if (string.IsNullOrEmpty(netShare) || !netShare.StartsWith(@"\\") || (netShare.StartsWith(@"\\") && netShare.Length <= 2)) { netShare = GUILocalizeStrings.Get(145); return; } // Get selected network resource shared folders _userNetFolder = netShare; NetShareCollection netShares = NetShareCollection.GetShares(netShare); SetFolderHistory(); _folders.Clear(); GUIListItem goBack = new GUIListItem(); goBack.Label = ".."; goBack.Label2 = ".."; _folders.Add(goBack); foreach (NetShare share in netShares) { if (share.IsFileSystem && share.ShareType == ShareType.Disk) { GUIListItem netFolder = new GUIListItem(); string nFolder = Path.GetFileName(share.Root.FullName); netFolder.Label = nFolder.ToUpperInvariant(); netFolder.Label2 = share.Root.FullName; _folders.Add(netFolder); } } }
public override bool Play(string strFile) { updateTimer = DateTime.Now; m_speedRate = 10000; m_bVisible = false; m_iVolume = 100; m_state = PlayState.Init; if (strFile != DUMMY_URL) { m_strCurrentFile = strFile; // hack to get around the MP 1.3 Alpha bug with non http URLs } m_bFullScreen = true; m_ar = GUIGraphicsContext.ARType; VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent; _updateNeeded = true; Logger.Instance.Info("AirPlayerVideo: Play '{0}'", m_strCurrentFile); m_bStarted = false; if (!GetInterfaces()) { m_strCurrentFile = ""; CloseInterfaces(); return(false); } AnalyseStreams(); SelectSubtitles(); SelectAudioLanguage(); OnInitialized(); int hr = mediaEvt.SetNotifyWindow(GUIGraphicsContext.ActiveForm, WM_GRAPHNOTIFY, IntPtr.Zero); if (hr < 0) { Error.SetError("Unable to play movie", "Can not set notifications"); m_strCurrentFile = ""; CloseInterfaces(); return(false); } if (videoWin != null) { videoWin.put_Owner(GUIGraphicsContext.ActiveForm); videoWin.put_WindowStyle( (WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipChildren + (int)WindowStyle.ClipSiblings)); videoWin.put_MessageDrain(GUIGraphicsContext.form.Handle); } if (basicVideo != null) { hr = basicVideo.GetVideoSize(out m_iVideoWidth, out m_iVideoHeight); if (hr < 0) { Error.SetError("Unable to play movie", "Can not find movie width/height"); m_strCurrentFile = ""; CloseInterfaces(); return(false); } } DirectShowUtil.SetARMode(graphBuilder, AspectRatioMode.Stretched); try { hr = mediaCtrl.Run(); DsError.ThrowExceptionForHR(hr); if (hr == 1) // S_FALSE from IMediaControl::Run means: The graph is preparing to run, but some filters have not completed the transition to a running state. { // wait max. 20 seconds for the graph to transition to the running state DateTime startTime = DateTime.Now; FilterState filterState; do { Thread.Sleep(100); hr = mediaCtrl.GetState(100, out filterState); // check with timeout max. 10 times a second if the state changed }while ((hr != 0) && ((DateTime.Now - startTime).TotalSeconds <= 20)); if (hr != 0) // S_OK { DsError.ThrowExceptionForHR(hr); throw new Exception(string.Format("IMediaControl.GetState after 20 seconds: 0x{0} - '{1}'", hr.ToString("X8"), DsError.GetErrorText(hr))); } } } catch (Exception error) { Logger.Instance.Warn("AirPlayerVideo: Unable to play with reason: {0}", error.Message); } if (hr != 0) // S_OK { Error.SetError("Unable to play movie", "Unable to start movie"); m_strCurrentFile = ""; CloseInterfaces(); return(false); } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msg.Label = CurrentFile; GUIWindowManager.SendThreadMessage(msg); m_state = PlayState.Playing; m_iPositionX = GUIGraphicsContext.VideoWindow.X; m_iPositionY = GUIGraphicsContext.VideoWindow.Y; m_iWidth = GUIGraphicsContext.VideoWindow.Width; m_iHeight = GUIGraphicsContext.VideoWindow.Height; m_ar = GUIGraphicsContext.ARType; _updateNeeded = true; SetVideoWindow(); mediaPos.get_Duration(out m_dDuration); Logger.Instance.Info("AirPlayerVideo: Duration {0} sec", m_dDuration.ToString("F")); return(true); }
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); }
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; } // CurrentFacade.Facade = Utils.GetLatestsFacade(CurrentFacade.ControlID); switch (dlg.SelectedId) { case 1: { PlayMovingPicture(GUIWindowManager.GetWindow(Utils.ActiveWindow)); break; } case 2: { ShowInfo(); break; } case 3: { CurrentFacade.UnWatched = !CurrentFacade.UnWatched; MovingPictureUpdateLatest(); 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; } MovingPictureUpdateLatest(); break; } case 5: { MovingPictureUpdateLatest(); break; } } } catch (Exception ex) { logger.Error("MyContextMenu: " + ex.ToString()); } }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem as GUIMovieListItem; if (selectedItem == null) { return; } var selectedAnticipatedItem = selectedItem.TVTag as TraktMovieAnticipated; 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.CreateMoviesContextMenu(ref dlg, selectedAnticipatedItem.Movie, false); // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } switch (dlg.SelectedId) { case ((int)MediaContextMenuItem.MarkAsWatched): TraktHelper.AddMovieToWatchHistory(selectedAnticipatedItem.Movie); selectedItem.IsPlayed = true; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); LoadAnticipatedMovies(CurrentPage); break; case ((int)MediaContextMenuItem.MarkAsUnWatched): TraktHelper.RemoveMovieFromWatchHistory(selectedAnticipatedItem.Movie); selectedItem.IsPlayed = false; OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.AddToWatchList): TraktHelper.AddMovieToWatchList(selectedAnticipatedItem.Movie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); if (TraktSettings.AnticipatedMoviesHideWatchlisted) { LoadAnticipatedMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.RemoveFromWatchList): TraktHelper.RemoveMovieFromWatchList(selectedAnticipatedItem.Movie, true); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.AddToList): TraktHelper.AddRemoveMovieInUserList(selectedAnticipatedItem.Movie, false); break; case ((int)MediaContextMenuItem.AddToLibrary): TraktHelper.AddMovieToCollection(selectedAnticipatedItem.Movie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); LoadAnticipatedMovies(CurrentPage); break; case ((int)MediaContextMenuItem.RemoveFromLibrary): TraktHelper.RemoveMovieFromCollection(selectedAnticipatedItem.Movie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); break; case ((int)MediaContextMenuItem.Related): TraktHelper.ShowRelatedMovies(selectedAnticipatedItem.Movie); break; case ((int)MediaContextMenuItem.Rate): GUICommon.RateMovie(selectedAnticipatedItem.Movie); OnMovieSelected(selectedItem, Facade); (Facade.SelectedListItem as GUIMovieListItem).Images.NotifyPropertyChanged("Poster"); LoadAnticipatedMovies(CurrentPage); break; case ((int)MediaContextMenuItem.Filters): if (GUICommon.ShowMovieFiltersMenu()) { PreviousSelectedIndex = CurrentPage == 1 ? 0 : 1; UpdateButtonState(); LoadAnticipatedMovies(CurrentPage); } break; case ((int)MediaContextMenuItem.Shouts): TraktHelper.ShowMovieShouts(selectedAnticipatedItem.Movie); break; case ((int)MediaContextMenuItem.Cast): GUICreditsMovie.Movie = selectedAnticipatedItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)MediaContextMenuItem.Crew): GUICreditsMovie.Movie = selectedAnticipatedItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename(selectedItem.Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); break; case ((int)MediaContextMenuItem.Trailers): GUICommon.ShowMovieTrailersMenu(selectedAnticipatedItem.Movie); break; case ((int)MediaContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; case ((int)MediaContextMenuItem.SearchWithMpNZB): string loadingParam = string.Format("search:{0}", selectedAnticipatedItem.Movie.Title); GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)MediaContextMenuItem.SearchTorrent): string loadPar = selectedAnticipatedItem.Movie.Title; GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; default: break; } base.OnShowContextMenu(); }
protected override void OnShowContextMenu() { try { GUIListItem currentitem = this.m_Facade.SelectedListItem; if (currentitem == null) { return; } VideoLocalVM vid = currentitem.TVTag as VideoLocalVM; if (vid == null) { return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlg.Reset(); dlg.SetHeading("File options"); dlg.Add("Play file"); dlg.Add("Rehash file"); dlg.Add("Ignore file"); dlg.Add("Delete file from disk"); dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId == 1) { MainWindow.vidHandler.ResumeOrPlay(vid); return; } if (dlg.SelectedId == 2) { JMMServerVM.Instance.clientBinaryHTTP.RehashFile(vid.VideoLocalID); Utils.DialogMsg("Done", "Action has been queued on server"); return; } if (dlg.SelectedId == 3) { JMMServerVM.Instance.clientBinaryHTTP.SetIgnoreStatusOnFile(vid.VideoLocalID, true); RefreshUnlinkedFiles(); return; } if (dlg.SelectedId == 4) { if (!Utils.DialogConfirm("Are you sure you want to delete this file?")) { return; } JMMServerVM.Instance.clientBinaryHTTP.DeleteVideoLocalAndFile(vid.VideoLocalID); RefreshUnlinkedFiles(); } } catch (Exception ex) { BaseConfig.MyAnimeLog.Write("Error in menu: {0}", ex); } }
private void SendAnticipatedMoviesToFacade(TraktMoviesAnticipated anticipatedItems) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (anticipatedItems == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); AnticipatedMoviePages = null; return; } // filter movies var filteredAnticipatedList = FilterAnticipatedMovies(anticipatedItems.Movies).Where(m => !string.IsNullOrEmpty(m.Movie.Title)).ToList(); // sort movies filteredAnticipatedList.Sort(new GUIListItemMovieSorter(TraktSettings.SortByAnticipatedMovies.Field, TraktSettings.SortByAnticipatedMovies.Direction)); int itemId = 0; var movieImages = new List <GUITmdbImage>(); // Add Previous Page Button if (anticipatedItems.CurrentPage != 1) { var prevPageItem = new GUIMovieListItem(Translation.PreviousPage, (int)TraktGUIWindows.AnticipatedMovies); prevPageItem.IsPrevPageItem = true; prevPageItem.IconImage = "traktPreviousPage.png"; prevPageItem.IconImageBig = "traktPreviousPage.png"; prevPageItem.ThumbnailImage = "traktPreviousPage.png"; prevPageItem.OnItemSelected += OnPreviousPageSelected; prevPageItem.IsFolder = true; Facade.Add(prevPageItem); itemId++; } // Add each movie mark remote if not in collection foreach (var anticipatedItem in filteredAnticipatedList) { // add image for download var images = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = anticipatedItem.Movie.Ids.Tmdb } }; movieImages.Add(images); var item = new GUIMovieListItem(anticipatedItem.Movie.Title, (int)TraktGUIWindows.AnticipatedMovies); item.Label2 = anticipatedItem.Movie.Year == null ? "----" : anticipatedItem.Movie.Year.ToString(); item.TVTag = anticipatedItem; item.Movie = anticipatedItem.Movie; item.Images = images; item.IsPlayed = anticipatedItem.Movie.IsWatched(); item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnMovieSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Add Next Page Button if (anticipatedItems.CurrentPage != anticipatedItems.TotalPages) { var nextPageItem = new GUIMovieListItem(Translation.NextPage, (int)TraktGUIWindows.AnticipatedMovies); nextPageItem.IsNextPageItem = true; nextPageItem.IconImage = "traktNextPage.png"; nextPageItem.IconImageBig = "traktNextPage.png"; nextPageItem.ThumbnailImage = "traktNextPage.png"; nextPageItem.OnItemSelected += OnNextPageSelected; nextPageItem.IsFolder = true; Facade.Add(nextPageItem); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", filteredAnticipatedList.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", filteredAnticipatedList.Count(), filteredAnticipatedList.Count() > 1 ? Translation.Movies : Translation.Movie)); // Page Properties GUIUtils.SetProperty("#Trakt.Facade.CurrentPage", anticipatedItems.CurrentPage.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalPages", anticipatedItems.TotalPages.ToString()); GUIUtils.SetProperty("#Trakt.Facade.TotalItemsPerPage", TraktSettings.MaxAnticipatedMoviesRequest.ToString()); // Download movie images Async and set to facade GUIMovieListItem.GetImages(movieImages); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { MainMenu menu = new MainMenu(); menu.Add(btnAddTag, () => { string tag = Utils.PromptSelectTag(""); if (!MainWindow.RandomWindow_SeriesTags.Contains(tag, StringComparer.InvariantCultureIgnoreCase)) { MainWindow.RandomWindow_SeriesTags.Add(tag); SetDisplayDetails(); } }); menu.Add(btnEpisodeAddTag, () => { string tag = Utils.PromptSelectTag(""); if (!MainWindow.RandomWindow_EpisodeTags.Contains(tag, StringComparer.InvariantCultureIgnoreCase)) { MainWindow.RandomWindow_EpisodeTags.Add(tag); SetDisplayDetails(); } }); menu.Add(btnClearTags, () => { MainWindow.RandomWindow_SeriesTags.Clear(); SetDisplayDetails(); }); menu.Add(btnEpisodeClearTags, () => { MainWindow.RandomWindow_EpisodeTags.Clear(); SetDisplayDetails(); }); menu.Add(btnAllAnyTags, () => { MainWindow.RandomWindow_SeriesAllTags = !MainWindow.RandomWindow_SeriesAllTags; SetDisplayDetails(); }); menu.Add(btnEpisodeAllAnyTags, () => { MainWindow.RandomWindow_EpisodeAllTags = !MainWindow.RandomWindow_EpisodeAllTags; SetDisplayDetails(); }); menu.Add(btnRandom, () => { if (togWatched != null) { MainWindow.RandomWindow_SeriesWatched = togWatched.Selected; } if (togUnwatched != null) { MainWindow.RandomWindow_SeriesUnwatched = togUnwatched.Selected; } if (togPartiallyWatched != null) { MainWindow.RandomWindow_SeriesPartiallyWatched = togPartiallyWatched.Selected; } if (togCompleteOnly != null) { MainWindow.RandomWindow_SeriesOnlyComplete = togCompleteOnly.Selected; } if (togEpisodeUnwatched != null) { MainWindow.RandomWindow_EpisodeUnwatched = togEpisodeUnwatched.Selected; } if (togEpisodeWatched != null) { MainWindow.RandomWindow_EpisodeWatched = togEpisodeWatched.Selected; } MainWindow.RandomWindow_CurrentEpisode = null; MainWindow.RandomWindow_CurrentSeries = null; btnRandom.IsFocused = true; LoadData(); }); menu.Add(btnSwitchSeries, () => { btnSwitchSeries.IsFocused = false; btnRandom.IsFocused = true; MainWindow.RandomWindow_RandomType = RandomObjectType.Series; LoadData(); }); menu.Add(btnSwitchEpisode, () => { btnSwitchEpisode.IsFocused = false; btnRandom.IsFocused = true; MainWindow.RandomWindow_RandomType = RandomObjectType.Episode; LoadData(); }); menu.AddFunc(btnPlayEpisode, () => { if (MainWindow.RandomWindow_CurrentEpisode == null) { return(false); } MainWindow.vidHandler.ResumeOrPlay(MainWindow.RandomWindow_CurrentEpisode); return(true); }); menu.AddFunc(btnEpisodeList, () => { if (MainWindow.RandomWindow_CurrentSeries == null) { return(false); } MainWindow.Breadcrumbs = new List <History> { new History { Selected = GroupFilterHelper.AllGroupsFilter } }; // find the group for this series VM_AnimeGroup_User grp = ShokoServerHelper.GetGroup(MainWindow.RandomWindow_CurrentSeries.AnimeGroupID); if (grp == null) { BaseConfig.MyAnimeLog.Write("Group not found"); return(false); } MainWindow.Breadcrumbs.Add(new History { Listing = GroupFilterHelper.AllGroupsFilter, Selected = grp }); MainWindow.Breadcrumbs.Add(new History { Listing = grp, Selected = MainWindow.RandomWindow_CurrentSeries }); bool foundEpType = false; if (MainWindow.RandomWindow_CurrentSeries.EpisodeTypesToDisplay.Count == 1) { MainWindow.Breadcrumbs.Add(new History { Listing = MainWindow.RandomWindow_CurrentSeries, Selected = null }); } else { foreach (VM_AnimeEpisodeType anEpType in MainWindow.RandomWindow_CurrentSeries.EpisodeTypesToDisplay) { if (anEpType.EpisodeType == enEpisodeType.Episode) { MainWindow.Breadcrumbs.Add(new History { Listing = MainWindow.RandomWindow_CurrentSeries, Selected = anEpType }); MainWindow.Breadcrumbs.Add(new History { Listing = anEpType, Selected = null }); foundEpType = true; break; } } if (!foundEpType) { return(false); } } GUIWindowManager.CloseCurrentWindow(); GUIWindowManager.ActivateWindow(Constants.WindowIDs.MAIN, false); return(true); }); if (menu.Check(control)) { return; } base.OnClicked(controlId, control, actionType); }
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); }
protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) { return; } var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedUser = selectedItem.TVTag as TraktUserSummary; if (selectedUser == 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; // Follow User // Only show menu item if user has an account as this is an unprotected area. if (!string.IsNullOrEmpty(TraktSettings.UserAccessToken) && !((selectedItem as GUIUserListItem).IsFollowed)) { listItem = new GUIListItem(Translation.FollowUser); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.FollowUser; } // User Profile if (!selectedUser.IsPrivate) { listItem = new GUIListItem(Translation.UserProfile); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.UserProfile; } // 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.FollowUser): if (GUIUtils.ShowYesNoDialog(Translation.Network, string.Format(Translation.SendFollowRequest, selectedItem.Label), true)) { GUINetwork.FollowUser(selectedUser); GUINetwork.ClearCache(); (selectedItem as GUIUserListItem).IsFollowed = true; } break; case ((int)ContextMenuItem.UserProfile): GUIUserProfile.CurrentUser = selectedUser.Username; GUIWindowManager.ActivateWindow((int)TraktGUIWindows.UserProfile); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; } base.OnShowContextMenu(); }
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()); } }
private void SendSearchResultsToFacade(IEnumerable <TraktUserSummary> users) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (users == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); Users = null; return; } if (users.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound); GUIWindowManager.ShowPreviousWindow(); Users = null; return; } int itemId = 0; var userImages = new List <GUITraktImage>(); // Add each user foreach (var user in users) { // add image to download var images = new GUITraktImage { UserImages = user.Images }; userImages.Add(images); var item = new GUIUserListItem(user.Username, (int)TraktGUIWindows.SearchUsers); item.Images = images; item.TVTag = user; item.ItemId = Int32.MaxValue - itemId; item.IconImage = "defaultTraktUser.png"; item.IconImageBig = "defaultTraktUserBig.png"; item.ThumbnailImage = "defaultTraktUserBig.png"; item.OnItemSelected += OnUserSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.CurrentLayout = CurrentLayout; GUIControl.FocusControl(GetID, Facade.GetID); if (SearchTermChanged) { PreviousSelectedIndex = 0; } Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", users.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", users.Count().ToString(), users.Count() > 1 ? Translation.Users : Translation.User)); // Download images Async and set to facade GUIUserListItem.GetImages(userImages); }
protected override void OnShowContextMenu() { if (GUIBackgroundTask.Instance.IsBusy) { return; } GUIListItem selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } TraktUserList selectedList = (TraktUserList)selectedItem.TVTag; IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUIUtils.PluginName()); GUIListItem listItem = null; // only allow add/delete/update if viewing your own lists if (CurrentUser == TraktSettings.Username) { listItem = new GUIListItem(Translation.CreateList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Create; listItem = new GUIListItem(Translation.EditList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Edit; listItem = new GUIListItem(Translation.DeleteList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Delete; } else { // copy a friends list listItem = new GUIListItem(Translation.CopyList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Copy; } // Show Context Menu dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId < 0) { return; } TraktList currentList = new TraktList { Name = selectedList.Name, Description = selectedList.Description, Privacy = selectedList.Privacy, Slug = selectedList.Slug, ShowNumbers = selectedList.ShowNumbers, AllowShouts = selectedList.AllowShouts }; switch (dlg.SelectedId) { case ((int)ContextMenuItem.Create): TraktList list = new TraktList(); if (TraktLists.GetListDetailsFromUser(ref list)) { if (Lists.ToList().Exists(l => l.Name == list.Name)) { // list with that name already exists GUIUtils.ShowNotifyDialog(Translation.Lists, Translation.ListNameAlreadyExists); return; } TraktLogger.Info("Creating new '{0}' list '{1}'", list.Privacy, list.Name); CreateList(list); } break; case ((int)ContextMenuItem.Delete): DeleteList(selectedList); break; case ((int)ContextMenuItem.Edit): if (TraktLists.GetListDetailsFromUser(ref currentList)) { TraktLogger.Info("Editing list '{0}'", currentList.Slug); EditList(currentList); } break; case ((int)ContextMenuItem.Copy): if (TraktLists.GetListDetailsFromUser(ref currentList)) { CopyList(selectedList, currentList); } break; default: break; } base.OnShowContextMenu(); }
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == buttonReset) { labelCurrent.Label = DEFAULT_SETTING; SetCheckMarksBasedOnString(DEFAULT_SETTING); } else if (control == buttonAdd) { VirtualKeyboard vk = (VirtualKeyboard)GUIWindowManager.GetWindow((int)Window.WINDOW_VIRTUAL_KEYBOARD); vk.Reset(); vk.DoModal(GetID); string newStep = vk.Text; if (newStep == string.Empty || newStep == null) { return; } string error = verifySkipStep(newStep); if (error != null) { GUIDialogOK errDialog = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); errDialog.SetHeading(257); errDialog.SetLine(1, error); errDialog.DoModal(GetID); } else { AddStep(Convert.ToInt16(newStep)); // Already verifed, so no numberformatexception can occur } } else if (control == buttonRemove) { GUIDialogSelect2 dlgSel = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_SELECT2); dlgSel.Reset(); foreach (string token in labelCurrent.Label.Split(new char[] { ',', ';', ' ' })) { if (token == string.Empty) { continue; } dlgSel.Add(token); } dlgSel.SetHeading(200040); // Remove skip step dlgSel.DoModal(GetID); if (dlgSel.SelectedLabel != -1) { try { RemoveStep(Convert.ToInt16(dlgSel.SelectedLabelText)); } catch (Exception) { // Should never happen } } } else if (control is GUICheckMarkControl) { int stepSize = 5; if (control == checkMarkButtonStep1) { stepSize = 5; } else if (control == checkMarkButtonStep2) { stepSize = 15; } else if (control == checkMarkButtonStep3) { stepSize = 30; } else if (control == checkMarkButtonStep4) { stepSize = 45; } else if (control == checkMarkButtonStep5) { stepSize = 60; } else if (control == checkMarkButtonStep6) { stepSize = 180; } else if (control == checkMarkButtonStep7) { stepSize = 300; } else if (control == checkMarkButtonStep8) { stepSize = 420; } else if (control == checkMarkButtonStep9) { stepSize = 600; } else if (control == checkMarkButtonStep10) { stepSize = 900; } else if (control == checkMarkButtonStep11) { stepSize = 1800; } else if (control == checkMarkButtonStep12) { stepSize = 2700; } else if (control == checkMarkButtonStep13) { stepSize = 3600; } else if (control == checkMarkButtonStep14) { stepSize = 5400; } else if (control == checkMarkButtonStep15) { stepSize = 7200; } else if (control == checkMarkButtonStep16) { stepSize = 10800; } if (!((GUICheckMarkControl)control).Selected) { RemoveStep(stepSize); } else { AddStep(stepSize); } } base.OnClicked(controlId, control, actionType); }
public override bool Play(string strFile) { try { if (_iTunesApplication == null) { _iTunesApplication = new iTunesAppClass(); _iTunesApplication.OnPlayerPlayEvent += new _IiTunesEvents_OnPlayerPlayEventEventHandler(_iTunesApplication_OnPlayerPlayEvent); _iTunesApplication.OnPlayerStopEvent += new _IiTunesEvents_OnPlayerStopEventEventHandler(_iTunesApplication_OnPlayerStopEvent); _iTunesApplication.OnPlayerPlayingTrackChangedEvent += new _IiTunesEvents_OnPlayerPlayingTrackChangedEventEventHandler( _iTunesApplication_OnPlayerPlayingTrackChangedEvent); IITPlaylist playList = null; foreach (IITPlaylist pl in _iTunesApplication.LibrarySource.Playlists) { if (pl.Name.Equals("MediaPortalTemporaryPlaylist")) { playList = pl; break; } } if (playList == null) { _playList = (IITUserPlaylist)_iTunesApplication.CreatePlaylist("MediaPortalTemporaryPlaylist"); } else { _playList = (IITUserPlaylist)playList; } _playList.SongRepeat = ITPlaylistRepeatMode.ITPlaylistRepeatModeOff; } // stop other media which might be active until now. if (g_Player.Playing) { g_Player.Stop(); } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msg.Label = strFile; GUIWindowManager.SendThreadMessage(msg); _started = false; _ended = false; foreach (IITTrack track in _playList.Tracks) { track.Delete(); } _playList.AddFile(strFile); _playList.PlayFirstTrack(); _playerIsPaused = false; _currentFile = strFile; _duration = -1; _currentPosition = -1; _playerState = ITPlayerState.ITPlayerStateStopped; _updateTimer = DateTime.MinValue; UpdateStatus(); _notifyPlaying = true; return(true); } catch (Exception ex) { Log.Error("ITunesPlugin.Play: Exception"); Log.Error(ex); _notifyPlaying = false; _iTunesApplication = null; } return(false); }
private void SendSearchResultsToFacade(IEnumerable <TraktPersonSummary> people) { // clear facade GUIControl.ClearControl(GetID, Facade.GetID); if (people == null) { GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral); GUIWindowManager.ShowPreviousWindow(); People = null; return; } if (people.Count() == 0) { GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.NoSearchResultsFound); GUIWindowManager.ShowPreviousWindow(); People = null; return; } int itemId = 0; var personImages = new List <GUITmdbImage>(); // Add each movie foreach (var person in people) { // add image for download var images = new GUITmdbImage { PeopleImages = new TmdbPeopleImages { Id = person.Ids.TmdbId } }; personImages.Add(images); var item = new GUIPersonListItem(person.Name.Trim(), (int)TraktGUIWindows.SearchPeople); item.TVTag = person; item.Images = images; item.ItemId = Int32.MaxValue - itemId; item.IconImage = GUIImageHandler.GetDefaultPoster(false); item.IconImageBig = GUIImageHandler.GetDefaultPoster(); item.ThumbnailImage = GUIImageHandler.GetDefaultPoster(); item.OnItemSelected += OnPersonSelected; Utils.SetDefaultIcons(item); Facade.Add(item); itemId++; } // Set Facade Layout Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout)); GUIControl.FocusControl(GetID, Facade.GetID); if (SearchTermChanged) { PreviousSelectedIndex = 0; } Facade.SelectIndex(PreviousSelectedIndex); // set facade properties GUIUtils.SetProperty("#itemcount", people.Count().ToString()); GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", people.Count().ToString(), people.Count() > 1 ? Translation.People : Translation.Person)); // Download images Async and set to facade GUIPersonListItem.GetImages(personImages); }
protected override void OnPageLoad() { base.OnPageLoad(); if (!g_Player.Playing || !g_Player.IsTV) { GUIWindowManager.CloseCurrentWindow(); return; } g_Player.PlayBackStopped += new global::MediaPortal.Player.g_Player.StoppedHandler(OnPlayBackStopped); g_Player.PlayBackEnded += new global::MediaPortal.Player.g_Player.EndedHandler(OnPlayBackEnded); g_Player.PlayBackChanged += new global::MediaPortal.Player.g_Player.ChangedHandler(OnPlayBackChanged); LiveStream _livestream = PluginMain.Navigator.LiveStream; Channel _channel = PluginMain.Navigator.CurrentChannel; if (g_Player.Playing && g_Player.IsTV && _livestream != null && _channel != null && PluginMain.IsConnected()) { ServiceTuning _serviceTuning = ControlAgent.GetLiveStreamTuningDetails(_livestream); if (_livestream.RtspUrl.StartsWith("rtsp://", StringComparison.CurrentCultureIgnoreCase)) { GUIPropertyManager.SetProperty("#TV.TuningDetails.RTSPURL.value", _livestream.RtspUrl); } else { GUIPropertyManager.SetProperty("#TV.TuningDetails.RTSPURL.value", Utility.GetLocalizedText(TextId.UnavailableText)); } if (g_Player.CurrentFile.StartsWith("rtsp:", StringComparison.InvariantCultureIgnoreCase)) { GUIPropertyManager.SetProperty("#TV.TuningDetails.StreamingMode.value", "RTSP"); } else { GUIPropertyManager.SetProperty("#TV.TuningDetails.StreamingMode.value", "UNC"); } if (g_Player.EnableSubtitle) { if ((g_Player.SubtitleStreams > 0 /*|| g_Player.SupportsCC*/) && g_Player.CurrentSubtitleStream >= 0) { GUIPropertyManager.SetProperty("#TV.TuningDetails.SubtitleStream.value", g_Player.SubtitleLanguage(g_Player.CurrentSubtitleStream)); } else { GUIPropertyManager.SetProperty("#TV.TuningDetails.SubtitleStream.value", Utility.GetLocalizedText(TextId.UnavailableText)); } } else { GUIPropertyManager.SetProperty("#TV.TuningDetails.SubtitleStream.value", Utility.GetLocalizedText(TextId.Off)); } GUIPropertyManager.SetProperty("#TV.TuningDetails.RTSPURL.label", "RTSP URL"); GUIPropertyManager.SetProperty("#TV.TuningDetails.SubtitleStream.label", Utility.GetLocalizedText(TextId.CurrentSubtitle)); GUIPropertyManager.SetProperty("#TV.TuningDetails.StreamingMode.label", Utility.GetLocalizedText(TextId.StreamingMode)); GUIPropertyManager.SetProperty("#TV.TuningDetails.AudioType.label", Utility.GetLocalizedText(TextId.AudioType)); GUIPropertyManager.SetProperty("#TV.TuningDetails.AudioType.value", g_Player.AudioType(g_Player.CurrentAudioStream)); GUIPropertyManager.SetProperty("#TV.TuningDetails.AudioLanguage.label", Utility.GetLocalizedText(TextId.AudioLanguage)); GUIPropertyManager.SetProperty("#TV.TuningDetails.AudioLanguage.value", g_Player.AudioLanguage(g_Player.CurrentAudioStream)); GUIPropertyManager.SetProperty("#TV.TuningDetails.VideoResolution.label", Utility.GetLocalizedText(TextId.VideoResolution)); GUIPropertyManager.SetProperty("#TV.TuningDetails.VideoResolution.value", g_Player.Width.ToString() + "x" + g_Player.Height.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelName.label", Utility.GetLocalizedText(TextId.Channel)); GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelName.value", _serviceTuning.Name); GUIPropertyManager.SetProperty("#TV.TuningDetails.Frequency.label", Utility.GetLocalizedText(TextId.Frequency)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Frequency.value", _serviceTuning.Frequency.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Provider.label", Utility.GetLocalizedText(TextId.Provider)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Provider.value", _serviceTuning.ProviderName); GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelType.label", Utility.GetLocalizedText(TextId.Type)); GUIPropertyManager.SetProperty("#TV.TuningDetails.SignalLevel.label", Utility.GetLocalizedText(TextId.SignalLevel)); GUIPropertyManager.SetProperty("#TV.TuningDetails.SignalQuality.label", Utility.GetLocalizedText(TextId.SignalQuality)); switch (_serviceTuning.CardType) { case CardType.Analog: GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelType.value", "Analog"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Provider.value", Utility.GetLocalizedText(TextId.Unknown)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.value", ""); break; case CardType.Atsc: GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelType.value", "ATSC"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Provider.value", Utility.GetLocalizedText(TextId.Unknown)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.label", Utility.GetLocalizedText(TextId.Encrypted)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.value", _serviceTuning.IsFreeToAir ? Utility.GetLocalizedText(TextId.No) : Utility.GetLocalizedText(TextId.Yes)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.label", Utility.GetLocalizedText(TextId.Modulation)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.value", _serviceTuning.Modulation.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.label", "Symbol Rate"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.value", _serviceTuning.SymbolRate.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.label", "Service ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.value", _serviceTuning.SID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.label", "Transport ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.value", _serviceTuning.TSID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.label", "InnerFecRate"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.value", _serviceTuning.InnerFecRate.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.label", "Physical Channel"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.value", _serviceTuning.PhysicalChannel.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.value", ""); break; case CardType.DvbC: GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelType.value", "DVB-C"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.label", Utility.GetLocalizedText(TextId.Encrypted)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.value", _serviceTuning.IsFreeToAir ? Utility.GetLocalizedText(TextId.No) : Utility.GetLocalizedText(TextId.Yes)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.label", Utility.GetLocalizedText(TextId.Modulation)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.value", _serviceTuning.Modulation.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.label", "Symbol Rate"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.value", _serviceTuning.SymbolRate.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.label", "Service ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.value", _serviceTuning.SID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.label", "Network ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.value", _serviceTuning.ONID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.label", "Transport ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.value", _serviceTuning.TSID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.label", "InnerFecRate"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.value", _serviceTuning.InnerFecRate.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.label", "OuterFecRate"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.value", _serviceTuning.OuterFecRate.ToString()); break; case CardType.DvbS: if (_serviceTuning.IsDvbS2) { GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelType.value", "DVB-S2"); } else { GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelType.value", "DVB-S"); } GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.label", Utility.GetLocalizedText(TextId.SatellitePosition)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.value", _serviceTuning.OrbitalPosition.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.label", Utility.GetLocalizedText(TextId.Encrypted)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.value", _serviceTuning.IsFreeToAir ? Utility.GetLocalizedText(TextId.No) : Utility.GetLocalizedText(TextId.Yes)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.label", Utility.GetLocalizedText(TextId.Modulation)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.value", _serviceTuning.Modulation.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.label", Utility.GetLocalizedText(TextId.Polarisation)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.value", _serviceTuning.SignalPolarisation.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.label", "Symbol Rate"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.value", _serviceTuning.SymbolRate.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.label", "Service ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.value", _serviceTuning.SID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.label", "Network ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.value", _serviceTuning.ONID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.label", "Transport ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.value", _serviceTuning.TSID.ToString()); break; case CardType.DvbT: GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelType.value", "DVB-T"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.label", Utility.GetLocalizedText(TextId.Encrypted)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.value", _serviceTuning.IsFreeToAir ? Utility.GetLocalizedText(TextId.No) : Utility.GetLocalizedText(TextId.Yes)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.label", Utility.GetLocalizedText(TextId.Modulation)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.value", _serviceTuning.Modulation.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.label", Utility.GetLocalizedText(TextId.Bandwidth)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.value", _serviceTuning.Bandwidth.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.label", "Service ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.value", _serviceTuning.SID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.label", "Network ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.value", _serviceTuning.ONID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.label", "Transport ID"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.value", _serviceTuning.TSID.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.label", "InnerFecRate"); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.value", _serviceTuning.InnerFecRate.ToString()); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.label", Utility.GetLocalizedText(TextId.TransmissionMode)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.value", _serviceTuning.TransmissionMode.ToString()); break; default: GUIPropertyManager.SetProperty("#TV.TuningDetails.ChannelType.value", Utility.GetLocalizedText(TextId.Unknown)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Provider.value", Utility.GetLocalizedText(TextId.Unknown)); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail1.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail2.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail3.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail4.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail5.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail6.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail7.value", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.label", ""); GUIPropertyManager.SetProperty("#TV.TuningDetails.Detail8.value", ""); break; } } }
public override bool Play(string strFile) { _isCDA = false; _graphState = PlayState.Init; _currentFile = strFile; Log.Info("AudioPlayerWMP9: Disabling DX9 exclusive mode"); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 0, 0, null); GUIWindowManager.SendMessage(msg); _notifyPlaying = true; GC.Collect(); CreateInstance(); LoadStreamingSettings(); if (_wmp10Player == null) { return(false); } if (_wmp10Player.cdromCollection == null) { return(false); } VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent; _wmp10Player.PlayStateChange += new _WMPOCXEvents_PlayStateChangeEventHandler(OnPlayStateChange); _wmp10Player.Buffering += new _WMPOCXEvents_BufferingEventHandler(OnBuffering); //_wmp10Player.enableContextMenu = false; //_wmp10Player.Ctlenabled = false; if (strFile.IndexOf("cdda:") >= 0) { string strTrack = strFile.Substring(5); int iTrack = Convert.ToInt32(strTrack); if (_wmp10Player.cdromCollection.count <= 0) { return(false); } if (_wmp10Player.cdromCollection.Item(0).Playlist == null) { return(false); } if (iTrack > _wmp10Player.cdromCollection.Item(0).Playlist.count) { return(false); } _wmp10Player.currentMedia = _wmp10Player.cdromCollection.Item(0).Playlist.get_Item(iTrack - 1); if (_wmp10Player.currentMedia == null) { return(false); } _isCDA = true; Log.Info("Audioplayer: play track:{0}/{1}", iTrack, _wmp10Player.cdromCollection.Item(0).Playlist.count); } else if (strFile.IndexOf(".cda") >= 0) { string strTrack = ""; int pos = strFile.IndexOf(".cda"); if (pos >= 0) { pos--; while (Char.IsDigit(strFile[pos]) && pos > 0) { strTrack = strFile[pos] + strTrack; pos--; } } if (_wmp10Player.cdromCollection.count <= 0) { return(false); } string strDrive = strFile.Substring(0, 1); strDrive += ":"; int iCdRomDriveNr = 0; while ((_wmp10Player.cdromCollection.Item(iCdRomDriveNr).driveSpecifier != strDrive) && (iCdRomDriveNr < _wmp10Player.cdromCollection.count)) { iCdRomDriveNr++; } int iTrack = Convert.ToInt32(strTrack); if (_wmp10Player.cdromCollection.Item(iCdRomDriveNr).Playlist == null) { return(false); } int tracks = _wmp10Player.cdromCollection.Item(iCdRomDriveNr).Playlist.count; if (iTrack > tracks) { return(false); } _wmp10Player.currentMedia = _wmp10Player.cdromCollection.Item(iCdRomDriveNr).Playlist.get_Item(iTrack - 1); if (_wmp10Player.currentMedia == null) { return(false); } /* * string strStart=strFile.Substring(0,2)+@"\"; * int ipos=strFile.LastIndexOf("+"); * if (ipos >0) strStart += strFile.Substring(ipos+1); * strFile=strStart; * _currentFile=strFile; * Log.Info("Audioplayer:play {0}", strFile);*/ //_wmp10Player.URL=strFile; _currentFile = strFile; _isCDA = true; } else { Log.Info("Audioplayer:play {0}", strFile); _wmp10Player.URL = strFile; } _wmp10Player.Ctlcontrols.play(); _wmp10Player.ClientSize = new Size(0, 0); _wmp10Player.Visible = false; // When file is internetstream if (_wmp10Player.URL.StartsWith("http") || _wmp10Player.URL.StartsWith("mms") || _wmp10Player.URL.StartsWith("HTTP") || _wmp10Player.URL.StartsWith("MMS")) { _bufferCompleted = false; using (WaitCursor waitcursor = new WaitCursor()) { GUIGraphicsContext.Overlay = false; while (_bufferCompleted != true) { { // if true then could not load stream if (_wmp10Player.playState.Equals(WMPPlayState.wmppsReady)) { _bufferCompleted = true; } if (GUIGraphicsContext.Overlay) { GUIGraphicsContext.Overlay = false; } _graphState = PlayState.Playing; GUIWindowManager.Process(); } } GUIGraphicsContext.Overlay = true; } if (_bufferCompleted && _wmp10Player.playState.Equals(WMPPlayState.wmppsReady)) { Log.Info("Audioplayer: failed to load {0}", strFile); return(false); } } GUIMessage msgPb = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msgPb.Label = strFile; GUIWindowManager.SendThreadMessage(msgPb); _graphState = PlayState.Playing; GC.Collect(); _needUpdate = true; _isFullScreen = GUIGraphicsContext.IsFullScreenVideo; _positionX = GUIGraphicsContext.VideoWindow.Left; _positionY = GUIGraphicsContext.VideoWindow.Top; _videoWidth = GUIGraphicsContext.VideoWindow.Width; _videoHeight = GUIGraphicsContext.VideoWindow.Height; SetVideoWindow(); return(true); }
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)); }
/// <summary> /// Shows a Trakt Rate Dialog (Love/Hate) or 10-Heart based on settings /// </summary> /// <param name="rateObject">Type of object being rated</param> public static string ShowRateDialog <T>(T rateObject) { if (GUIGraphicsContext.form.InvokeRequired) { ShowRateDialogDelegate <T> d = ShowRateDialog <T>; return((string)GUIGraphicsContext.form.Invoke(d, rateObject)); } TraktRateValue currentRating = TraktRateValue.unrate; GUIRateDialog ratingDlg = (GUIRateDialog)GUIWindowManager.GetWindow(GUIRateDialog.ID); ratingDlg.Reset(); ratingDlg.SetHeading(Translation.RateHeading); // show simple love/hate icons or 10-heart icons ratingDlg.ShowAdvancedRatings = TraktSettings.ShowAdvancedRatingsDialog; // if item is not rated, it will default to love if (rateObject is TraktRateEpisode) { TraktRateEpisode item = rateObject as TraktRateEpisode; ratingDlg.SetLine(1, string.Format("{0} - {1}x{2}", item.Title, item.Season, item.Episode)); if (ratingDlg.ShowAdvancedRatings) { ratingDlg.Rated = item.Rating == "0" || !item.Rating.IsNumber() ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Rating); } else { ratingDlg.Rated = item.Rating == "0" || !item.Rating.IsNumber() ? TraktRateValue.ten : (TraktRateValue)Convert.ToInt32(item.Rating); } } else if (rateObject is TraktRateSeries) { TraktRateSeries item = rateObject as TraktRateSeries; ratingDlg.SetLine(1, item.Title); if (ratingDlg.ShowAdvancedRatings) { ratingDlg.Rated = item.Rating == "0" || !item.Rating.IsNumber() ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Rating); } else { ratingDlg.Rated = item.Rating == "0" || !item.Rating.IsNumber() ? TraktRateValue.ten : (TraktRateValue)Convert.ToInt32(item.Rating); } } else { TraktRateMovie item = rateObject as TraktRateMovie; ratingDlg.SetLine(1, item.Title); if (ratingDlg.ShowAdvancedRatings) { ratingDlg.Rated = item.Rating == "0" || !item.Rating.IsNumber() ? TraktRateValue.seven : (TraktRateValue)Convert.ToInt32(item.Rating); } else { ratingDlg.Rated = item.Rating == "0" || !item.Rating.IsNumber() ? TraktRateValue.ten : (TraktRateValue)Convert.ToInt32(item.Rating); } } // show dialog ratingDlg.DoModal(ratingDlg.GetID); if (!ratingDlg.IsSubmitted) { return("-1"); } if (rateObject is TraktRateEpisode) { TraktRateEpisode item = rateObject as TraktRateEpisode; currentRating = ratingDlg.Rated; item.Rating = (int)currentRating != 0 ? ((int)currentRating).ToString() : "unrate"; Thread rateThread = new Thread(delegate(object obj) { TraktRateResponse response = TraktAPI.TraktAPI.RateEpisode(item); TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else if (rateObject is TraktRateSeries) { TraktRateSeries item = rateObject as TraktRateSeries; currentRating = ratingDlg.Rated; item.Rating = (int)currentRating != 0 ? ((int)currentRating).ToString() : "unrate"; Thread rateThread = new Thread(delegate(object obj) { TraktRateResponse response = TraktAPI.TraktAPI.RateSeries(item); TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } else { TraktRateMovie item = rateObject as TraktRateMovie; currentRating = ratingDlg.Rated; item.Rating = (int)currentRating != 0 ? ((int)currentRating).ToString() : "unrate"; Thread rateThread = new Thread(delegate(object obj) { TraktRateResponse response = TraktAPI.TraktAPI.RateMovie(item); TraktLogger.LogTraktResponse(response); }) { IsBackground = true, Name = "Rate" }; rateThread.Start(item); } // return new rating (0 - 10) // old love / hate enum values are deprecated // if using basic ratings 1 = hate and 10 = love // 0 is unrate return(((int)currentRating).ToString()); }