コード例 #1
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
        protected override void OnPageLoad()
        {
            _GUIInitialized = false;
            _currentHandler = null;
            _backupHandler = null;
            _backupHandlerSet = false;
            _shouldDeleteButtonVisible = false;
            _clearedMedia = false;
            _subtitleFilesForCurrentMedia.Clear();
            _subtitlesExistForCurrentMedia = false;
            _mediaAvailable = false;
            _checkMediaForSubtitlesOnOpenDone = false;
            View = ViewMode.NONE;
            ModifySearchSearchType = SubtitlesSearchType.NONE;
            _oldModifySearchSearchType = SubtitlesSearchType.NONE;
            ListControlViewState = ListControlViewState.GROUPSANDPROVIDERS;

            _subtitlesSortMethod = Settings.SettingsManager.Properties.GUISettings.SortMethod;
            _subtitlesSortAsc = Settings.SettingsManager.Properties.GUISettings.SortAscending;

            GUIUtils.SetProperty("#currentmodule", SubCentralUtils.PluginName());

            //if (searchButton == null) {
            if (!CheckAndTranslateSkin()) {
                // if the component didn't load properly we probably have a bad skin file
                GUIUtils.ShowOKDialog(Localization.Error, Localization.CannotLoadSkin);
                GUIWindowManager.ShowPreviousWindow();
                logger.Error("Failed to load all components from skin file. Skin is outdated or invalid.");
                return;
            }
            // test SubtitleDownloader assembly
            if (!core.SubtitleDownloaderInitialized) {
                GUIUtils.ShowOKDialog(Localization.Error, string.Concat(Localization.UnableToLoadSubtitleDownloader, "\n", Localization.SubtitleDownloaderUnavailable));
                GUIWindowManager.ShowPreviousWindow();
                logger.Error("SubtitleDownloader: not available");
                return;
            }

            base.OnPageLoad();
            _GUIInitialized = true;

            GUIControl.DisableControl(GetID, deleteButton.GetID);

            if (sortButton != null)
                sortButton.SortChanged += new SortEventHandler(OnSortChanged);

            // initialize properties
            InitSearchProperties();

            // initialize list control
            _lastSelectedGroupsAndProvidersItemIndex = 0;
            _lastSelectedSubtitlesItemIndex = 1;
            FillProviderGroupsAndProviders(false);

            // get last active module
            int lastActiveWindow = GUIWindowManager.GetPreviousActiveWindow();

            // just entering from the home or basic home or plugins screen, show the main screen
            if (MainWindowIDs.Contains(lastActiveWindow)) {
                logger.Debug("Entered plugin from Home or Basic Home or Plugins screen");
                View = ViewMode.MAIN;
                CurrentHandler = null;
            }

            // entering from a plugin
            else {
                //try to load data from it and if we fail return back to the calling plugin.
                if (!LoadFromPlugin(lastActiveWindow)) {
                    logger.Error("Entered plugin from ID #{0}, but failed to load an appropriate handler.", lastActiveWindow);

                    // show a popup notifying the user
                    if (!GUIUtils.ShowCustomYesNoDialog(Localization.Warning, string.Format(Localization.UnableToImportDataFrom, CurrentHandler == null ? Localization.ExternalPlugin : CurrentHandler.PluginName), Localization.ManualSearch, Localization.Back)) {
                        GUIWindowManager.ShowPreviousWindow();
                        return;
                    }
                    //View = ViewMode.MAIN;
                    OnModifySearch();
                }

                // we loaded details successfully, we are now in file view.
                else {
                    logger.Debug("Entered plugin from {0} ({1})", CurrentHandler.PluginName, CurrentHandler.ID);
                    SubtitlesSearchType searchType = SubCentralUtils.getSubtitlesSearchTypeFromMediaDetail(CurrentHandler.MediaDetail);
                    View = ViewMode.SEARCH;

                    //if (searchType != SubtitlesSearchType.NONE)
                    {
                        EnableDisableProviderGroupsAndProviders(searchType != SubtitlesSearchType.NONE);

                        if (CurrentHandler.MediaDetail.Files != null && CurrentHandler.MediaDetail.Files.Count > 0) {
                          _shouldDeleteButtonVisible = true;
                          GUIControl.EnableControl(GetID, deleteButton.GetID);
                        }

                        if (Settings.SettingsManager.Properties.GUISettings.CheckMediaForSubtitlesOnOpen) {
                            CheckMediaForSubtitlesOnOpen(CurrentHandler);
                        }

                        if (Settings.SettingsManager.Properties.GeneralSettings.PluginLoadWithSearchData == OnPluginLoadWithSearchData.SearchDefaults) {
                            SettingsGroup defaultGroup = SubCentralUtils.getDefaultGroupForSearchType(searchType);
                            if (defaultGroup != null) {
                                _lastSelectedGroupsAndProvidersItemIndex = LocateGroupInListControl(defaultGroup);
                                PerformSearch(defaultGroup);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
        private void OnShowDialogSortOptions()
        {
            List<GUIListItem> items = new List<GUIListItem>();
            items.Add(new GUIListItem(Localization.GroupProviderDefault));
            items.Add(new GUIListItem(Localization.SortByMediaTags));
            items.Add(new GUIListItem(Localization.SortByLanguage));
            items.Add(new GUIListItem(Localization.SortByName));

            int dlgResult = GUIUtils.ShowMenuDialog(Localization.Sorting, items, (int)_subtitlesSortMethod);

            if (dlgResult < 0) return;

            switch (dlgResult) {
                case 0:
                    _subtitlesSortMethod = SubtitlesSortMethod.DefaultNoSort;
                    break;
                case 1:
                    _subtitlesSortMethod = SubtitlesSortMethod.MediaTags;
                    break;
                case 2:
                    _subtitlesSortMethod = SubtitlesSortMethod.SubtitleLanguage;
                    break;
                case 3:
                    _subtitlesSortMethod = SubtitlesSortMethod.SubtitleName;
                    break;
            }

            OnSort();
            GUIControl.FocusControl(GetID, (int)GUIControls.SORTBUTTON);
        }