Example #1
0
        private void ShowDeleteMenu(DBSeries series, DBSeason season, DBEpisode episode)
        {
            String sDialogHeading = String.Empty;

            switch (this.listLevel)
            {
                case Listlevel.Series:
                    sDialogHeading = Translation.Delete_that_series;
                    break;

                case Listlevel.Season:
                    sDialogHeading = Translation.Delete_that_season;
                    break;

                case Listlevel.Episode:
                    sDialogHeading = Translation.Delete_that_episode;
                    break;
            }

            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            if (dlg == null)
                return;

            dlg.Reset();
            dlg.SetHeading(sDialogHeading);

            // Add Menu items
            GUIListItem pItem = null;

            pItem = new GUIListItem(Translation.DeleteFromDisk);
            dlg.Add(pItem);
            pItem.ItemId = (int)DeleteMenuItems.disk;

            pItem = new GUIListItem(Translation.DeleteFromDatabase);
            dlg.Add(pItem);
            pItem.ItemId = (int)DeleteMenuItems.database;

            pItem = new GUIListItem(Translation.DeleteFromFileDatabase);
            dlg.Add(pItem);
            pItem.ItemId = (int)DeleteMenuItems.diskdatabase;

            if (this.listLevel == Listlevel.Episode && episode != null && episode.checkHasLocalSubtitles())
            {
                pItem = new GUIListItem(Translation.DeleteSubtitles);
                dlg.Add(pItem);
                pItem.ItemId = (int)DeleteMenuItems.subtitles;
            }

            pItem = new GUIListItem(Translation.Cancel);
            dlg.Add(pItem);
            pItem.ItemId = (int)DeleteMenuItems.cancel;

            // Show Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0 || dlg.SelectedId == (int)DeleteMenuItems.cancel)
                return;

            List<string> resultMsg = null;
            string msgDlgCaption = string.Empty;

            #region Delete Subtitles
            if (dlg.SelectedId == (int)DeleteMenuItems.subtitles)
            {
                msgDlgCaption = Translation.UnableToDeleteSubtitles;
                switch (this.listLevel)
                {
                    case Listlevel.Episode:
                        if (episode == null) return;
                        resultMsg = episode.deleteLocalSubTitles();
                        break;
                }
            }
            #endregion

            #region Delete From Disk, Database or Both
            if (dlg.SelectedId != (int)DeleteMenuItems.subtitles)
            {
                msgDlgCaption = Translation.UnableToDelete;
                switch (this.listLevel)
                {
                    #region Delete Series
                    case Listlevel.Series:
                        resultMsg = series.deleteSeries((DeleteMenuItems)dlg.SelectedId);
                        break;
                    #endregion

                    #region Delete Season
                    case Listlevel.Season:
                        resultMsg = season.deleteSeason((DeleteMenuItems)dlg.SelectedId);
                        break;
                    #endregion

                    #region Delete Episode
                    case Listlevel.Episode:
                        resultMsg = episode.deleteEpisode((DeleteMenuItems)dlg.SelectedId);
                        break;
                    #endregion
                }
                // only update the counts if the database entry for the series still exists
                if (!DBSeries.IsSeriesRemoved) DBSeries.UpdateEpisodeCounts(series);
            }
            #endregion

            // Re-load the facade to accurately reflect actions taked above
            LoadFacade();

            // Show errors, if any
            if (resultMsg != null && resultMsg.Count > 0)
            {
                GUIDialogText errorDialog = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT);
                errorDialog.SetHeading(msgDlgCaption);
                errorDialog.SetText(string.Join("\n", resultMsg.ToArray()));
                errorDialog.DoModal(GUIWindowManager.ActiveWindow);
            }
        }