public virtual void PageDestroy() { if (_running == false) { return; } GUIWindowManager.IsSwitchingToNewWindow = true; lock (thisLock) { GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, GetID, 0, 0, _parentWindowID, 0, null); OnMessage(msg); if (GUIWindowManager.RoutedWindow == GetID) { GUIWindowManager.UnRoute(); // only unroute if we still the routed window } _parentWindow = null; _running = false; } GUIWindowManager.IsSwitchingToNewWindow = false; while (IsAnimating(AnimationType.WindowClose) && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING) { GUIWindowManager.Process(); } }
public void DoModal(int dwParentId) { //Log.Debug("TvMiniGuide: DoModal"); _parentWindowID = dwParentId; _parentWindow = GUIWindowManager.GetWindow(_parentWindowID); if (null == _parentWindow) { //Log.Debug("TvMiniGuide: parentwindow = null"); _parentWindowID = 0; return; } GUIWindowManager.IsSwitchingToNewWindow = true; GUIWindowManager.RouteToWindow(GetID); // activate this window... GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, -1, 0, null); OnMessage(msg); GUIWindowManager.IsSwitchingToNewWindow = false; _running = true; GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Dialog); while (_running && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING) { GUIWindowManager.Process(); } Close(); }
public virtual void PageLoad(int ParentID) { CloseRoutedWindow(); _parentWindowID = ParentID; _parentWindow = GUIWindowManager.GetWindow(_parentWindowID); if (_parentWindow == null) { _parentWindowID = 0; return; } GUIWindowManager.IsSwitchingToNewWindow = true; lock (thisLock) { GUIWindowManager.RouteToWindow(GetID); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, _parentWindowID, 0, null); OnMessage(msg); _running = true; } GUIWindowManager.IsSwitchingToNewWindow = false; while (IsAnimating(AnimationType.WindowOpen) && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING) { GUIWindowManager.Process(); } }
private void HideAccountControls() { Username = string.Empty; Password = string.Empty; Email = string.Empty; if (btnUsername != null) { GUIControl.SetControlLabel(GetID, btnUsername.GetID, string.Empty); } if (btnPassword != null) { GUIControl.SetControlLabel(GetID, btnPassword.GetID, string.Empty); } if (btnEmail != null) { GUIControl.SetControlLabel(GetID, btnEmail.GetID, string.Empty); } if (lblTestConnect != null) { GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, string.Empty); } GUIUtils.SetProperty("#Trakt.Settings.Account.Dialog.Visible", "false"); GUIWindowManager.Process(); // Set Focus back to main window controls if (btnCreateNewAccount != null) { GUIControl.FocusControl(GetID, btnCreateNewAccount.GetID); } }
public void Progress() { if (m_bRunning) { GUIWindowManager.Process(); } }
/// <summary> /// Do this modal /// </summary> /// <param name="dwParentId"></param> public void DoModal(int parentId) { _parentWindowID = parentId; _parentWindow = GUIWindowManager.GetWindow(_parentWindowID); if (null == _parentWindow) { _parentWindowID = 0; return; } GUIWindowManager.IsSwitchingToNewWindow = true; GUIWindowManager.RouteToWindow(GetID); // activate this window... GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_INIT, GetID, 0, 0, -1, 0, null); OnMessage(msg); GUIWindowManager.IsSwitchingToNewWindow = false; _running = true; GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Dialog); while (_running && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING) { GUIWindowManager.Process(); if (!GUIGraphicsContext.Vmr9Active) { Thread.Sleep(50); } } GUILayerManager.UnRegisterLayer(this); }
private void ShowAccountControls(bool newUser) { // set conditions so skins can show controls for account login/creation // there were issues when trying to invoke a virtual keyboard from a dialog // ie. (dialog from with-in another dialog) hence the reason why // we are re-using existing window to show controls. GUIUtils.SetProperty("#Trakt.Settings.Account.Dialog.Visible", "true"); GUIUtils.SetProperty("#Trakt.Settings.Account.Dialog.NewUser", newUser.ToString().ToLowerInvariant()); GUIWindowManager.Process(); if (btnUsername != null) { GUIControl.FocusControl(GetID, btnUsername.GetID); } if (btnOk != null) { GUIControl.SetControlLabel(GetID, btnOk.GetID, newUser ? Translation.Create : Translation.Login); } if (lblTitle != null) { GUIControl.SetControlLabel(GetID, lblTitle.GetID, newUser ? Translation.CreateAccount : Translation.Login); } NewAccount = newUser; }
private void InitProperties() { Username = string.Empty; Password = string.Empty; Email = string.Empty; GUIUtils.SetProperty("#Trakt.Settings.Account.Dialog.HasUsername", "false"); GUIUtils.SetProperty("#Trakt.Settings.Account.Dialog.HasPassword", "false"); GUIUtils.SetProperty("#Trakt.Settings.Account.Dialog.Visible", "false"); GUIWindowManager.Process(); // Set Disconnect button Label / or Hide it if (btnDisconnectAccount != null) { if (TraktSettings.AccountStatus == ConnectionState.Connected) { GUIControl.SetControlLabel(GetID, btnDisconnectAccount.GetID, string.Format(Translation.DisconnectAccount, TraktSettings.Username)); btnDisconnectAccount.Visible = true; } else { // Hide Control, no account to disconnect btnDisconnectAccount.Visible = false; } } }
public void DoModal(int dwParentId) { _parentWindowId = dwParentId; _parentWindow = GUIWindowManager.GetWindow(_parentWindowId); if (null == _parentWindow) { _parentWindowId = 0; return; } GUIWindowManager.IsSwitchingToNewWindow = true; GUIWindowManager.RouteToWindow(GetID); GUILayerManager.RegisterLayer(this, GUILayerManager.LayerType.Dialog); // active this window... (with its own OnPageLoad) PageLoad(); GUIWindowManager.IsSwitchingToNewWindow = false; _keyboard.IsVisible = true; _keyboard.Position = _keyboard.TextEntered.Length; while (_keyboard.IsVisible && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING) { GUIWindowManager.Process(); } PageDestroy(); }
private void ShowWaitCursor() { HideWaitCursor(); if (WaitCursorThread == null) { ThreadStart ts = new ThreadStart(ShowWaitCursorAsync); WaitCursorThread = new Thread(ts); } else { if (WaitCursorThread.IsAlive) { WaitCursorThread.Abort(); } WaitCursorThread = null; ThreadStart ts = new ThreadStart(ShowWaitCursorAsync); WaitCursorThread = new Thread(ts); } WaitCursorActive = true; WaitCursorThread.IsBackground = true; WaitCursorThread.Name = "WaitCursorAsync"; WaitCursorThread.Start(); GUIWindowManager.Process(); }
public SlidePicture GetCurrentSlide(string slideFilePath) { // wait for any (needed) prefetching to complete lock (_prefetchingThreadLock) { bool itemFiles = File.Exists(slideFilePath); if (!itemFiles) { CurrentSlide = new SlidePicture(slideFilePath, false); return(CurrentSlide); } if (_prefetchingThread != null) { // only wait for the prefetching if it is for the slide file that we need if (_neededSlideFilePath == slideFilePath) { _prefetchingThread.Priority = ThreadPriority.AboveNormal; } else { // uneeded, abort _prefetchingThread.Abort(); _prefetchingThread = null; } } } while (_prefetchingThread != null) { GUIWindowManager.Process(); } lock (_slidesLock) { // try and use pre-fetched slide if appropriate if (NextSlide != null && NextSlide.FilePath == slideFilePath) { return(NextSlide); } else if (PrevSlide != null && PrevSlide.FilePath == slideFilePath) { return(PrevSlide); } else if (CurrentSlide != null && CurrentSlide.FilePath == slideFilePath) { return(CurrentSlide); } else { // slide is not in cache, so get it now CurrentSlide = new SlidePicture(slideFilePath, false); return(CurrentSlide); } } }
private void TestAccount(TraktAccount account) { TraktResponse response = null; if (NewAccount) { if (lblTestConnect != null) { GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, Translation.CreatingAccount); } GUIWindowManager.Process(); response = TraktAPI.TraktAPI.CreateAccount(account); } else { if (lblTestConnect != null) { GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, Translation.SigningIntoAccount); } GUIWindowManager.Process(); response = TraktAPI.TraktAPI.TestAccount(account); } if (response.Status == "failure") { string errorMessage = string.IsNullOrEmpty(response.Error) ? response.Message : response.Error; GUIUtils.ShowNotifyDialog(Translation.Error, errorMessage); if (lblTestConnect != null) { GUIControl.SetControlLabel(GetID, lblTestConnect.GetID, string.Empty); } } else { // Save New Account Settings TraktSettings.Username = account.Username; TraktSettings.Password = account.Password; if (!TraktSettings.UserLogins.Exists(u => u.Username == TraktSettings.Username)) { TraktSettings.UserLogins.Add(new TraktAuthentication { Username = TraktSettings.Username, Password = TraktSettings.Password }); } TraktSettings.AccountStatus = ConnectionState.Connected; HideAccountControls(); InitProperties(); // clear caches // watch lists are stored by user so dont need clearing. GUITraktFriends.ClearCache(); GUICalendar.ClearCache(); GUIRecommendationsMovies.ClearCache(); GUIRecommendationsShows.ClearCache(); } }
private void OnFindCoverArtDone(AmazonWebservice aws, EventArgs e) { string progressText = string.Format("{0}% -- Done", 100); SetCurrentCoverArtProgressLabel(progressText, 100); progCurrent.Percentage = 100; Application.DoEvents(); GUIWindowManager.Process(); }
private void UpdateAlbumScanProgress(string album, int albumCount, int curCount) { int progPrecent = (int)(((float)curCount / (float)albumCount) * 100f); string statusText = string.Format(SearchFolderNameFormatString, album); string progressText = string.Format(SearchFolderProgressFormatString, progPrecent, curCount, albumCount); SetCurrentProgressPercentage(progPrecent); lblCurrentProgress.Label = progressText; lblCurrentAlbum.Label = statusText; GUIWindowManager.Process(); }
private void GetAlbumCount(string folderPath, ref int count) { DirectoryInfo dirInfo = new DirectoryInfo(folderPath); DirectoryInfo[] dirs = dirInfo.GetDirectories(); //count += dirs.Length; foreach (DirectoryInfo di in dirs) { try { CheckForAppShutdown(); if (_Abort || _AbortedByUser || GUICoverArtGrabberResults.CancelledByUser) { break; } FileInfo[] files = di.GetFiles(); bool isMusicFolder = false; foreach (FileInfo fi in files) { if (Util.Utils.IsAudio(fi.FullName)) { // This appears to be a music folder isMusicFolder = true; if (_SkipIfCoverArtExists) { } break; } } if (isMusicFolder) { count++; } GetAlbumCount(di.FullName, ref count); Application.DoEvents(); } catch (Exception ex) { Log.Info("Cover art grabber exception:{0}", ex.ToString()); continue; } GUIWindowManager.Process(); } }
private void OnAlbumNotFoundRetryingFiltered(AmazonWebservice aws, string origAlbumName, string filteredAlbumName) { lblCurrentAlbum.Label = string.Format(GrabbingAlbumNameFormatString, filteredAlbumName); lblFilteredSearch.Label = string.Format("{0} not found", origAlbumName); lblFilteredSearch.Visible = true; string progressText = GetCurrentProgressString(0, filteredAlbumName); SetCurrentProgressPercentage(0); SetCurrentCoverArtProgressLabel(progressText, 0); GUIWindowManager.Process(); }
// The main function. private void GetAndDisplayArticle(string searchterm) { BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(DownloadWorker); worker.RunWorkerAsync(searchterm); while (_workerCompleted == false) { GUIWindowManager.Process(); } }
private void InitProperties() { GUIWindowManager.Process(); // Show Authorise caption in button or disconnect depending on state if (string.IsNullOrEmpty(TraktSettings.UserAccessToken)) { GUIControl.SetControlLabel(GetID, btnAuthoriseOrDisconnect.GetID, Translation.AuthorizeApplication); } else if (TraktSettings.AccountStatus == ConnectionState.Connected) { GUIControl.SetControlLabel(GetID, btnAuthoriseOrDisconnect.GetID, string.Format(Translation.DisconnectAccount, TraktSettings.Username)); } }
private void ShowWaitCursorAsync() { _WaitCursor = new WaitCursor(); while (WaitCursorActive) { Thread.Sleep(800); GUIWindowManager.Process(); } if (_WaitCursor != null) { _WaitCursor.Dispose(); _WaitCursor = null; } }
/// <summary> /// Constructor which initialises the external osd library handler /// </summary> /// <param name="player">Instance of external player</param> public ExternalOSDLibrary(MPlayerExtPlayer player) { _showingCacheStatus = false; _internalOSDHandler = new InternalOSDHandler(player, false); using (new WaitCursor()) { Thread thread = new Thread(OsdGetInstance); thread.Start(); while (thread.IsAlive) { GUIWindowManager.Process(); Thread.Sleep(100); } } _osd.ShowInit(LocalizeStrings.Get((int)LocalizedMessages.Initializing)); }
private void OnFindCoverArtProgress(AmazonWebservice aws, int progressPercent) { string albumName = aws.AlbumName; if (albumName.Length == 0) { albumName = GUILocalizeStrings.Get(4506); } string progressText = GetCurrentProgressString(progressPercent, albumName); SetCurrentProgressPercentage(progressPercent); SetCurrentCoverArtProgressLabel(progressText, progressPercent); Application.DoEvents(); GUIWindowManager.Process(); }
private void SetButtonsHidden(bool bHide) { if (bHide) { GUIControl.HideControl(GetID, (int)btnAlways.GetID); GUIControl.HideControl(GetID, (int)btnNever.GetID); GUIControl.ShowControl(GetID, (int)imgProgressBackground.GetID); ShowProgressBar(true); } else { GUIControl.ShowControl(GetID, (int)btnAlways.GetID); GUIControl.ShowControl(GetID, (int)btnNever.GetID); GUIControl.HideControl(GetID, (int)imgProgressBackground.GetID); ShowProgressBar(false); } // Handle messages GUIWindowManager.Process(); }
private bool InternalGetAlbumCovers(string artist, string album, string filteredAlbumText) { if (amazonWS.AbortGrab) { return(false); } amazonWS.ArtistName = artist; amazonWS.AlbumName = album; bool result = false; if (SearchMode == SearchDepthMode.Album) { GUIDialogProgress dlgProgress = (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS); if (dlgProgress != null) { dlgProgress.SetHeading(185); dlgProgress.SetLine(1, album); dlgProgress.SetLine(2, artist); dlgProgress.SetLine(3, filteredAlbumText); dlgProgress.SetPercentage(0); dlgProgress.Progress(); dlgProgress.ShowProgressBar(false); GUIWindowManager.Process(); } result = amazonWS.GetAlbumInfo(); } else { result = amazonWS.GetAlbumInfo(); } return(result); }
private void ShowError(int iError, string SourceOfError) { // ask user what to do SetLine(1, SourceOfError); SetLine(2, iError); SetButtonsHidden(false); GUIControl.HideControl(GetID, (int)btnAlways.GetID); GUIControl.HideControl(GetID, (int)btnNever.GetID); GUIControl.HideControl(GetID, (int)btnCancel.GetID); GUIControl.HideControl(GetID, (int)btnNo.GetID); // wait for input while (!m_bButtonYes) { GUIWindowManager.Process(); } SetLine(1, ""); SetLine(2, ""); SetButtonsHidden(true); GUIControl.ShowControl(GetID, (int)btnCancel.GetID); GUIControl.ShowControl(GetID, (int)btnNo.GetID); }
public virtual void PageDestroy() { if (_running == false) { return; } try { GUIWindowManager.IsSwitchingToNewWindow = true; if (!_destroyingPage) { _destroyingPage = true; GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, GetID, 0, 0, _parentWindowID, 0, null); OnMessage(msg); if (GUIWindowManager.RoutedWindow == GetID) { GUIWindowManager.UnRoute(); // only unroute if we still the routed window } _parentWindow = null; _running = false; _destroyingPage = false; } GUIWindowManager.IsSwitchingToNewWindow = false; while (IsAnimating(AnimationType.WindowClose) && GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.RUNNING) { GUIWindowManager.Process(); } } catch (System.Exception ex) { _destroyingPage = false; Log.Error("Error during PageDestroy(): " + ex.Message); } }
void filtersCreator_DoWork(object sender, DoWorkEventArgs e) { GUIDialogProgress progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); progressDialog.Reset(); progressDialog.ShowWaitCursor = true; progressDialog.SetHeading(Translation.CreatingFilters); progressDialog.Percentage = 0; progressDialog.SetLine(1, string.Empty); progressDialog.SetLine(2, string.Empty); progressDialog.StartModal(this.GetID); GUIWindowManager.Process(); TraktHandlers.MovingPictures.CreateMovingPicturesFilters(); progressDialog.SetHeading(Translation.UpdatingFilters); GUIWindowManager.Process(); TraktHandlers.MovingPictures.UpdateMovingPicturesFilters(); progressDialog.ShowWaitCursor = false; progressDialog.Close(); GUIWindowManager.Process(); }
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(); } }
private void FileItemMC(GUIListItem item) { if (m_bCanceled) { return; } // source file name string strItemFileName = item.Path.Replace(sourceFolder, ""); if (strItemFileName.StartsWith("\\") == true) { strItemFileName = strItemFileName.Remove(0, 1); } // Check protected share int iPincodeCorrect; if (m_directory.IsProtectedShare(item.Path, out iPincodeCorrect)) { ShowError(513, item.Path); return; } // update dialog information SetPercentage((m_iFileNr * 100) / m_iNrOfItems); string strFileOperation = ""; if (m_iFileMode == 1) { strFileOperation = GUILocalizeStrings.Get(116); } else { strFileOperation = GUILocalizeStrings.Get(115); } strFileOperation += " " + m_iFileNr.ToString() + "/" + m_iNrOfItems.ToString() + " " + GUILocalizeStrings.Get(507); SetNewHeading(strFileOperation); SetLine(1, strItemFileName); // Handle messages GUIWindowManager.Process(); if (item.IsFolder) { if (item.Label != "..") { string path = destinationFolder + strItemFileName; try { DirectoryInfo di = Directory.CreateDirectory(path); } catch (Exception) { ShowError(514, path); m_bCanceled = true; return; } List <GUIListItem> items = m_directory.GetDirectoryUnProtectedExt(item.Path, false); foreach (GUIListItem subItem in items) { FileItemMC(subItem); if (m_bCanceled) { return; } } // Move? if (m_iFileMode == 1 && strItemFileName != "") { try { Directory.Delete(item.Path); } catch (Exception) { ShowError(515, item.Path); m_bCanceled = true; return; } } } } else if (!item.IsRemote) { // Move,Copy m_iFileNr++; bool doNot = false; try { if (File.Exists(destinationFolder + strItemFileName)) { m_bButtonYes = false; m_bButtonNo = false; if (!m_bAlways && !m_bNever && !m_bCanceled) { // ask user what to do SetLine(2, 509); SetButtonsHidden(false); // wait for input while (!m_bButtonYes && !m_bButtonNo && !m_bAlways && !m_bNever && !m_bCanceled) { GUIWindowManager.Process(); } SetLine(2, ""); SetButtonsHidden(true); } if (m_bButtonYes || m_bAlways) { doNot = false; try { File.Delete(destinationFolder + strItemFileName); } catch (Exception) { ShowError(516, destinationFolder + strItemFileName); doNot = true; } } else { doNot = true; } } if (doNot == false) { FileInfo fi = new FileInfo(item.Path); if (m_iFileMode == 1) { fi.MoveTo(destinationFolder + strItemFileName); // delete from database DeleteFromDatabase(item); } else { fi.CopyTo(destinationFolder + strItemFileName, false); } } } catch (Exception) { // fatal error ShowError(517, item.Path); m_bCanceled = true; Log.Info("FileMenu Error: from {0} to {1} MC:{2}", item.Path, destinationFolder + strItemFileName, m_iFileMode); } } }
protected override void OnShowContextMenu() { var selectedItem = this.Facade.SelectedListItem; if (selectedItem == null) { return; } var selectedListItem = selectedItem.TVTag as TraktListItem; if (selectedListItem == 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; if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode) { // Mark As Watched if (!selectedListItem.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsWatched; } // Mark As UnWatched if (selectedListItem.IsWatched()) { listItem = new GUIListItem(Translation.MarkAsUnWatched); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.MarkAsUnWatched; } } if (SelectedType != TraktItemType.season && SelectedType != TraktItemType.person) { // Add/Remove Watchlist if (!selectedListItem.IsWatchlisted()) { listItem = new GUIListItem(Translation.AddToWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToWatchList; } else { listItem = new GUIListItem(Translation.RemoveFromWatchList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromWatchList; } } // Add to Custom list listItem = new GUIListItem(Translation.AddToList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToList; // Remove from Custom list (only if current user is the active user) if (TraktSettings.Username == CurrentUser) { listItem = new GUIListItem(Translation.RemoveFromList); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromList; } if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.episode) { // Add to Collection // Don't allow if it will be removed again on next sync // movie could be part of a DVD collection if (!selectedListItem.IsCollected() && !TraktSettings.KeepTraktLibraryClean) { listItem = new GUIListItem(Translation.AddToLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.AddToLibrary; } if (selectedListItem.IsCollected()) { listItem = new GUIListItem(Translation.RemoveFromLibrary); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.RemoveFromLibrary; } } // Related Movies/Shows if (SelectedType != TraktItemType.person) { listItem = new GUIListItem(SelectedType == TraktItemType.movie ? Translation.RelatedMovies : Translation.RelatedShows); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Related; } if (SelectedType != TraktItemType.season && SelectedType != TraktItemType.person) { // Rate listItem = new GUIListItem(Translation.Rate + "..."); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Rate; // Shouts listItem = new GUIListItem(Translation.Comments); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Shouts; } // Cast and Crew if (SelectedType == TraktItemType.movie || SelectedType == TraktItemType.show) { listItem = new GUIListItem(Translation.Cast); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Cast; listItem = new GUIListItem(Translation.Crew); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Crew; } // Trailers if (SelectedType != TraktItemType.person) { if (TraktHelper.IsTrailersAvailableAndEnabled) { listItem = new GUIListItem(Translation.Trailers); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.Trailers; } } // Search with mpNZB if (TraktHelper.IsMpNZBAvailableAndEnabled) { if ((selectedListItem.Movie != null && !selectedListItem.Movie.IsCollected()) || selectedListItem.Episode != null) { listItem = new GUIListItem(Translation.SearchWithMpNZB); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchWithMpNZB; } } // Search with MyTorrents if (TraktHelper.IsMyTorrentsAvailableAndEnabled) { if ((selectedListItem.Movie != null && !selectedListItem.Movie.IsCollected()) || selectedListItem.Episode != null) { listItem = new GUIListItem(Translation.SearchTorrent); dlg.Add(listItem); listItem.ItemId = (int)ContextMenuItem.SearchTorrent; } } // 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.MarkAsWatched): AddItemToWatchedHistory(selectedListItem); selectedItem.IsPlayed = true; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.MarkAsUnWatched): RemoveItemFromWatchedHistory(selectedListItem); selectedItem.IsPlayed = false; OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.AddToWatchList): AddItemToWatchList(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } GUIWatchListMovies.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.RemoveFromWatchList): RemoveItemFromWatchList(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } GUIWatchListMovies.ClearCache(TraktSettings.Username); break; case ((int)ContextMenuItem.AddToList): if (SelectedType == TraktItemType.movie) { TraktHelper.AddRemoveMovieInUserList(selectedListItem.Movie, false); } else if (SelectedType == TraktItemType.show) { TraktHelper.AddRemoveShowInUserList(selectedListItem.Show, false); } else if (SelectedType == TraktItemType.season) { TraktHelper.AddRemoveSeasonInUserList(selectedListItem.Season, false); } else if (SelectedType == TraktItemType.episode) { TraktHelper.AddRemoveEpisodeInUserList(selectedListItem.Episode, false); } else if (SelectedType == TraktItemType.person) { TraktHelper.AddRemovePersonInUserList(selectedListItem.Person, false); } break; case ((int)ContextMenuItem.RemoveFromList): if (!GUIUtils.ShowYesNoDialog(Translation.DeleteListItem, Translation.ConfirmDeleteListItem)) { break; } // Only do remove from current list // We could do same as Add (ie remove from multiple lists) but typically you only remove from the current list TraktHelper.AddRemoveItemInList((int)CurrentList.Ids.Trakt, GetSyncItems(selectedListItem), true); // clear the list item cache TraktLists.ClearListItemCache(CurrentUser, CurrentList.Ids.Trakt.ToString()); // remove item from collection CurrentListItems.RemoveAll(l => ListItemMatch(l, selectedListItem)); // clear the cache TraktLists.ClearListItemCache(TraktSettings.Username, CurrentList.Ids.Trakt.ToString()); // Remove from view if (Facade.Count > 1) { PreviousSelectedIndex = Facade.SelectedListItemIndex; SendListItemsToFacade(CurrentListItems); } else { // no more items left GUIControl.ClearControl(GetID, Facade.GetID); ClearProperties(); GUIWindowManager.Process(); // nothing left, exit GUIWindowManager.ShowPreviousWindow(); return; } break; case ((int)ContextMenuItem.AddToLibrary): AddItemToCollection(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.RemoveFromLibrary): RemoveItemFromCollection(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.Related): if (SelectedType == TraktItemType.movie) { TraktHelper.ShowRelatedMovies(selectedListItem.Movie); } else { //series, season & episode TraktHelper.ShowRelatedShows(selectedListItem.Show); } break; case ((int)ContextMenuItem.Rate): RateItem(selectedListItem); OnItemSelected(selectedItem, Facade); if (SelectedType == TraktItemType.movie) { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("MoviePoster"); } else { (Facade.SelectedListItem as GUICustomListItem).Images.NotifyPropertyChanged("ShowPoster"); } break; case ((int)ContextMenuItem.Shouts): if (SelectedType == TraktItemType.movie) { TraktHelper.ShowMovieShouts(selectedListItem.Movie); } else if (SelectedType == TraktItemType.show) { TraktHelper.ShowTVShowShouts(selectedListItem.Show); } else { TraktHelper.ShowEpisodeShouts(selectedListItem.Show, selectedListItem.Episode); } break; case ((int)ContextMenuItem.Cast): if (SelectedType == TraktItemType.movie) { GUICreditsMovie.Movie = selectedListItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Cast; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUICustomListItem).Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); } else if (SelectedType == TraktItemType.show) { GUICreditsShow.Show = selectedListItem.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Cast; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUICustomListItem).Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); } break; case ((int)ContextMenuItem.Crew): if (SelectedType == TraktItemType.movie) { GUICreditsMovie.Movie = selectedListItem.Movie; GUICreditsMovie.Type = GUICreditsMovie.CreditType.Crew; GUICreditsMovie.Fanart = TmdbCache.GetMovieBackdropFilename((selectedItem as GUICustomListItem).Images.MovieImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsMovie); } else if (SelectedType == TraktItemType.show) { GUICreditsShow.Show = selectedListItem.Show; GUICreditsShow.Type = GUICreditsShow.CreditType.Crew; GUICreditsShow.Fanart = TmdbCache.GetShowBackdropFilename((selectedItem as GUICustomListItem).Images.ShowImages); GUIWindowManager.ActivateWindow((int)TraktGUIWindows.CreditsShow); } break; case ((int)ContextMenuItem.Trailers): if (SelectedType == TraktItemType.movie) { GUICommon.ShowMovieTrailersMenu(selectedListItem.Movie); } else if (SelectedType == TraktItemType.episode) { GUICommon.ShowTVShowTrailersMenu(selectedListItem.Show, selectedListItem.Episode); } else if (SelectedType == TraktItemType.season && TraktHelper.IsTrailersAvailableAndEnabled) { GUICommon.ShowTVSeasonTrailersPluginMenu(selectedListItem.Show, selectedListItem.Season.Number); } break; case ((int)ContextMenuItem.SearchWithMpNZB): string loadingParam = String.Empty; if (selectedListItem.Movie != null) { loadingParam = string.Format("search:{0}", selectedListItem.Movie.Title); } else if (selectedListItem.Episode != null) { loadingParam = string.Format("search:{0} S{1}E{2}", selectedListItem.Show.Title, selectedListItem.Episode.Season.ToString("D2"), selectedListItem.Episode.Number.ToString("D2")); } GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam); break; case ((int)ContextMenuItem.SearchTorrent): string loadPar = String.Empty; if (selectedListItem.Movie != null) { loadPar = selectedListItem.Movie.Title; } else if (selectedListItem.Episode != null) { loadPar = string.Format("{0} S{1}E{2}", selectedListItem.Show.Title, selectedListItem.Episode.Season.ToString("D2"), selectedListItem.Episode.Number.ToString("D2")); } GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar); break; case ((int)ContextMenuItem.ChangeLayout): CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout, PreviousSelectedIndex); break; default: break; } base.OnShowContextMenu(); }
public List <string> deleteSeason(TVSeriesPlugin.DeleteMenuItems type) { List <string> resultMsg = new List <string>(); // Always delete from Local episode table if deleting from disk or database SQLCondition condition = new SQLCondition(); condition.Add(new DBEpisode(), DBEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); condition.Add(new DBEpisode(), DBEpisode.cSeasonIndex, this[DBSeason.cIndex], SQLConditionType.Equal); /* TODO will include hidden episodes as hidden attribute is only in onlineepisodes. maybe we should include it in localepisodes also.. * if hidden episodes are excluded then the if (resultMsg.Count is wrong and should do another select to get proper count * if (!DBOption.GetOptions(DBOption.cShowHiddenItems)) * { * //don't include hidden seasons unless the ShowHiddenItems option is set * condition.Add(new DBEpisode(), idden, 0, SQLConditionType.Equal); * } */ List <DBEpisode> episodes = DBEpisode.Get(condition, false); if (episodes != null) { bool hasLocalEpisodesToDelete = episodes.Exists(e => !string.IsNullOrEmpty(e[DBEpisode.cFilename])); hasLocalEpisodesToDelete &= (type == TVSeriesPlugin.DeleteMenuItems.disk || type == TVSeriesPlugin.DeleteMenuItems.diskdatabase); DBSeries series = Helper.getCorrespondingSeries(this[DBSeason.cSeriesID]); string seriesName = series == null ? this[DBSeason.cSeriesID].ToString() : series.ToString(); // show progress dialog as this can be a long process esp for network drives // will show new progress for each season if deleting from the series level GUIDialogProgress progressDialog = null; if (!Settings.isConfig) { progressDialog = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS); progressDialog.Reset(); progressDialog.DisplayProgressBar = true; progressDialog.ShowWaitCursor = false; progressDialog.DisableCancel(true); progressDialog.SetHeading(Translation.Delete); progressDialog.Percentage = 0; progressDialog.SetLine(1, string.Format("{0} {1} {2}", seriesName, Translation.Season, this[DBSeason.cIndex])); progressDialog.SetLine(2, string.Empty); // only show progress dialog if we have local files in season if (hasLocalEpisodesToDelete) { progressDialog.StartModal(GUIWindowManager.ActiveWindow); } } int counter = 0; foreach (DBEpisode episode in episodes) { string episodeName = string.Format("{0}x{1} - {2}", episode[DBOnlineEpisode.cSeasonIndex], episode[DBOnlineEpisode.cEpisodeIndex], episode[DBOnlineEpisode.cEpisodeName]); if (!Settings.isConfig) { progressDialog.SetLine(2, episodeName); } if (!Settings.isConfig) { GUIWindowManager.Process(); } resultMsg.AddRange(episode.deleteEpisode(type, true)); if (!Settings.isConfig) { progressDialog.Percentage = Convert.ToInt32(((double)++counter / (double)episodes.Count) * 100.0); } if (!Settings.isConfig) { GUIWindowManager.Process(); } } // close progress dialog if (!Settings.isConfig) { progressDialog.Close(); } // if we have removed all episodes in season without error, cleanup the online table if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.disk) { condition = new SQLCondition(); condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeasonIndex, this[DBSeason.cIndex], SQLConditionType.Equal); DBOnlineEpisode.Clear(condition); } } #region Facade Remote Color // if we were successful at deleting all episodes of season from disk, set HasLocalFiles to false // note: we only do this if the database entries still exist if (resultMsg.Count == 0 && type == TVSeriesPlugin.DeleteMenuItems.disk) { this[cHasLocalFiles] = false; this.Commit(); } // if we were successful at deleting all episodes of season from disk, // also check if any local episodes exist on disk for series and set HasLocalFiles to false if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.database) { // Check Series for Local Files SQLCondition episodeConditions = new SQLCondition(); episodeConditions.Add(new DBEpisode(), DBEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); List <DBEpisode> localEpisodes = DBEpisode.Get(episodeConditions); if (localEpisodes.Count == 0 && !DBSeries.IsSeriesRemoved) { DBSeries series = DBSeries.Get(this[DBSeason.cSeriesID]); if (series != null) { series[DBOnlineSeries.cHasLocalFiles] = false; series.Commit(); } } } #endregion #region Cleanup // if there are no error messages and if we need to delete from db if (resultMsg.Count == 0 && type != TVSeriesPlugin.DeleteMenuItems.disk) { condition = new SQLCondition(); condition.Add(new DBSeason(), DBSeason.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); condition.Add(new DBSeason(), DBSeason.cIndex, this[DBSeason.cIndex], SQLConditionType.Equal); DBSeason.Clear(condition); } DBSeries.IsSeriesRemoved = false; if (type != TVSeriesPlugin.DeleteMenuItems.disk) { // If local/online episode count is zero then delete the series and all seasons condition = new SQLCondition(); condition.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); episodes = DBEpisode.Get(condition, false); if (episodes.Count == 0) { // Delete Seasons condition = new SQLCondition(); condition.Add(new DBSeason(), DBSeason.cSeriesID, this[DBSeason.cSeriesID], SQLConditionType.Equal); DBSeason.Clear(condition); // Delete Local Series condition = new SQLCondition(); condition.Add(new DBSeries(), DBSeries.cID, this[DBSeason.cSeriesID], SQLConditionType.Equal); DBSeries.Clear(condition); // Delete Online Series condition = new SQLCondition(); condition.Add(new DBOnlineSeries(), DBOnlineSeries.cID, this[DBSeason.cSeriesID], SQLConditionType.Equal); DBOnlineSeries.Clear(condition); DBSeries.IsSeriesRemoved = true; } } #endregion return(resultMsg); }