public static Sites.SiteUtilBase ShowDialog(Sites.SiteUtilBase selectedSite) { List <OnlineVideos.Reflection.FieldPropertyDescriptorByRef> actualProps = selectedSite.GetUserConfigurationProperties(); // limit to what the UI can show actualProps = actualProps.Where(prop => (prop.IsEnum || prop.Namespace == "System")).ToList(); if (actualProps.Count > 0) { bool changes = false; int selectIndex = 0; do { int windowId = GUIDialogSiteUserSettings.GUIDIALOGMENU_ONLINEVIDEO; // try our special dialog first GUIDialogMenu dlgSiteOptions = (GUIDialogMenu)GUIWindowManager.GetWindow(windowId) as GUIDialogSiteUserSettings; if (dlgSiteOptions == null || !((GUIDialogSiteUserSettings)dlgSiteOptions).IsAvailable) // if not available use the default one { windowId = (int)GUIWindow.Window.WINDOW_DIALOG_MENU; dlgSiteOptions = (GUIDialogMenu)GUIWindowManager.GetWindow(windowId); } if (dlgSiteOptions == null) { return(selectedSite); } dlgSiteOptions.Reset(); dlgSiteOptions.SetHeading(string.Format("{0}: {1}", selectedSite.Settings.Name, GUILocalizeStrings.Get(5))); foreach (var ovsUserCfg in actualProps) { /*object valueO = ovsUserCfg.GetValue(selectedSite); * string value = valueO != null ? valueO.ToString() : string.Empty;*/ string value = selectedSite.GetConfigValueAsString(ovsUserCfg); if (ovsUserCfg.IsPassword) { value = new string('*', value.Length); } string desc = ovsUserCfg.Description; dlgSiteOptions.Add(new GUIListItem(ovsUserCfg.DisplayName, value, "", false, null) { // don't set Label3 if we are not using our custom dialog Label3 = windowId == GUIDialogSiteUserSettings.GUIDIALOGMENU_ONLINEVIDEO && !string.IsNullOrEmpty(desc) ? desc : string.Empty }); } dlgSiteOptions.SelectedLabel = selectIndex; dlgSiteOptions.DoModal(GUIWindowManager.ActiveWindow); selectIndex = dlgSiteOptions.SelectedLabel; if (dlgSiteOptions.SelectedId == -1) { break; } else { OnlineVideos.Reflection.FieldPropertyDescriptorByRef prop = actualProps.First(a => a.DisplayName == dlgSiteOptions.SelectedLabelText); if (prop.IsBool) { bool currVal = selectedSite.GetConfigValueAsString(prop) == true.ToString(); selectedSite.SetConfigValueFromString(prop, (!currVal).ToString()); changes = true; } else if (prop.IsEnum) { GUIDialogMenu dlgEnum = (GUIDialogMenu)GUIWindowManager.GetWindow(windowId); dlgEnum.Reset(); dlgEnum.SetHeading(string.Format("{0}: {1}", selectedSite.Settings.Name, prop.DisplayName)); string value = selectedSite.GetConfigValueAsString(prop); int i = 0; foreach (string e in prop.GetEnumValues()) { dlgEnum.Add(e); if (e == value) { dlgEnum.SelectedLabel = i; } i++; } dlgEnum.DoModal(GUIWindowManager.ActiveWindow); if (dlgEnum.SelectedId != -1) { if (value != dlgEnum.SelectedLabelText) { selectedSite.SetConfigValueFromString(prop, dlgEnum.SelectedLabelText); changes = true; } } } else { string value = selectedSite.GetConfigValueAsString(prop); string newValue = (string)value.Clone(); if (GUIOnlineVideos.GetUserInputString(ref newValue, prop.IsPassword)) { if (value != newValue) { try { selectedSite.SetConfigValueFromString(prop, newValue); changes = true; } catch (Exception ex) { // conversion from string not possible, show error GUIDialogOK dlg_error = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg_error != null) { dlg_error.Reset(); dlg_error.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg_error.SetLine(1, Translation.Instance.Error); dlg_error.SetLine(2, ex.Message); dlg_error.DoModal(GUIWindowManager.ActiveWindow); } } } } } } } while (true); if (changes) { var newUtilInstance = Sites.SiteUtilFactory.CloneFreshSiteFromExisting(selectedSite); OnlineVideoSettings.Instance.SiteUtilsList[newUtilInstance.Settings.Name] = newUtilInstance; return(newUtilInstance); } } return(selectedSite); }