/// <summary> /// Displays a OK dialog with heading and up to 4 lines split by \n in lines string. /// </summary> public static void ShowOKDialog(string heading, string lines) { if (GUIGraphicsContext.form.InvokeRequired) { ShowOKDialogDelegate d = ShowOKDialog; GUIGraphicsContext.form.Invoke(d, heading, lines); return; } GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlgOK.Reset(); dlgOK.SetHeading(heading); int lineid = 1; foreach (string line in lines.Split(new string[] { "\\n", "\n" }, StringSplitOptions.None)) { dlgOK.SetLine(lineid, line); lineid++; } for (int i = lineid; i <= 4; i++) { dlgOK.SetLine(i, string.Empty); } dlgOK.DoModal(GUIWindowManager.ActiveWindow); }
public static void DialogMsg(string title, string msg) { GUIDialogOK dlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (null == dlgOK) { return; } dlgOK.Reset(); dlgOK.SetHeading(title); string[] lines = msg.Split('\n'); BaseConfig.MyAnimeLog.Write("lines: " + lines.Length.ToString()); if (lines.Length == 1) { dlgOK.SetLine(1, lines[0]); } if (lines.Length == 2) { dlgOK.SetLine(2, lines[1]); } if (lines.Length == 3) { dlgOK.SetLine(2, lines[2]); } dlgOK.DoModal(GUIWindowManager.ActiveWindow); }
/// <summary> /// Show an ok dialog in MediaPortal /// </summary> /// <param name="title">Dialog title</param> /// <param name="text">Dialog text</param> internal static void ShowOkDialog(string title, string text) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(title); dlg.SetLine(1, text); dlg.DoModal(GUIWindowManager.ActiveWindow); } }
public void ShowNotifyDialog(int timeOut, string header, string icon, string text, Helper.PLUGIN_NOTIFY_WINDOWS notifyType) { try { GUIWindow guiWindow = GUIWindowManager.GetWindow((int)notifyType); switch (notifyType) { default: case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_AUTO: if (text.Length <= 60) { ShowNotifyDialog(timeOut, header, icon, text, Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_NOTIFY); } else { ShowNotifyDialog(timeOut, header, icon, text, Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_TEXT); } break; case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_NOTIFY: GUIDialogNotify notifyDialog = (GUIDialogNotify)guiWindow; notifyDialog.Reset(); notifyDialog.TimeOut = timeOut; notifyDialog.SetImage(icon); notifyDialog.SetHeading(header); notifyDialog.SetText(text); notifyDialog.DoModal(GUIWindowManager.ActiveWindow); break; case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_OK: GUIDialogOK okDialog = (GUIDialogOK)guiWindow; okDialog.Reset(); okDialog.SetHeading(header); okDialog.SetLine(1, (text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))[0]); okDialog.DoModal(GUIWindowManager.ActiveWindow); break; case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_TEXT: GUIDialogText textDialog = (GUIDialogText)guiWindow; textDialog.Reset(); try { textDialog.SetImage(icon); } catch (Exception e) { Debug.WriteLine(e.ToString()); } textDialog.SetHeading(header); textDialog.SetText(text); textDialog.DoModal(GUIWindowManager.ActiveWindow); break; } } catch (Exception ex) { Log.Error(ex); } }
internal static void ReloadDownloadedDlls() { Log.Instance.Info("Reloading SiteUtil Dlls at runtime."); bool stopPlayback = (MediaPortal.Player.g_Player.Player != null && MediaPortal.Player.g_Player.Player.GetType().Assembly == typeof(GUISiteUpdater).Assembly); bool stopDownload = DownloadManager.Instance.Count > 0; if (stopDownload || stopPlayback) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, Translation.Instance.NewDllDownloaded); int i = 1; if (stopDownload) { dlg.SetLine(i++, Translation.Instance.DownloadsWillBeAborted); } if (stopPlayback) { dlg.SetLine(i++, Translation.Instance.PlaybackWillBeStopped); } dlg.DoModal(GUIWindowManager.ActiveWindow); } } // stop playback if an OnlineVideos video is playing if (stopPlayback) { MediaPortal.Player.g_Player.Stop(); } // stop downloads DownloadManager.Instance.StopAll(); // reset the GuiOnlineVideos instance and stop the LatestVideos Thread GUIOnlineVideos ovGuiInstance = (GUIOnlineVideos)GUIWindowManager.GetWindow(GUIOnlineVideos.WindowId); if (ovGuiInstance != null) { ovGuiInstance.ResetToFirstView(); ovGuiInstance.LatestVideosManager.Stop(); } // now reload the appdomain OnlineVideoSettings.Reload(); TranslationLoader.SetTranslationsToSingleton(); OnlineVideoSettings.Instance.BuildSiteUtilsList(); GC.Collect(); GC.WaitForFullGCComplete(); // restart the LatestVideos thread ovGuiInstance.LatestVideosManager.Start(); }
/// <summary> /// Checks if the local Version is at least equal to the latest online available version and presents a message if not. /// </summary> /// <returns>true if the local version is equal or higher than the online version, otherwise false.</returns> bool CheckOnlineVideosVersion() { if (!Sites.Updater.VersionCompatible) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, Translation.Instance.AutomaticUpdateDisabled); dlg.SetLine(2, string.Format(Translation.Instance.LatestVersionRequired, Sites.Updater.VersionOnline)); dlg.DoModal(GUIWindowManager.ActiveWindow); } return(false); } return(true); }
public void ShowMessage(string heading, string line1, string line2, string line3, string line4) { GUIDialogOK dialog = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dialog.Reset(); dialog.SetHeading(heading); if (line1 != null) { dialog.SetLine(1, line1); } if (line2 != null) { dialog.SetLine(2, line2); } if (line3 != null) { dialog.SetLine(3, line3); } if (line4 != null) { dialog.SetLine(4, line4); } dialog.DoModal(GetID); }
/// <summary> /// Try to connect to the core service, if not connected. /// </summary> /// <param name="showHomeOnError"></param> /// <param name="schowError"></param> /// <returns></returns> internal static bool EnsureConnection(bool showHomeOnError, bool schowError) { if (!Proxies.IsInitialized) { bool succeeded = false; string errorMessage = string.Empty; ServerSettings serverSettings = LoadServerSettings(); if (IsSingleSeat) { StartServices(serverSettings.ServerName); } /*else * { * if (!NetworkAvailable) * { * if (((showHomeOnError || !_connectionErrorShown) * && GUIWindowManager.ActiveWindow != 0) && schowError) * { * GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); * dlg.Reset(); * dlg.SetHeading(Utility.GetLocalizedText(TextId.Error)); * dlg.SetLine(1, "Failed to connect to ARGUS TV"); * dlg.SetLine(2, "No internet connection!"); * dlg.SetLine(3, ""); * dlg.DoModal(GUIWindowManager.ActiveWindow); * _connectionErrorShown = true; * } * * _connected = false; * return false; * } * }*/ succeeded = Utility.InitialiseServerSettings(serverSettings, out errorMessage); if (!succeeded && !IsSingleSeat) { StartServices(serverSettings.ServerName); succeeded = Utility.InitialiseServerSettings(serverSettings, out errorMessage); } if (!succeeded) { if (((showHomeOnError || !_connectionErrorShown) && GUIWindowManager.ActiveWindow != 0) && schowError) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.Reset(); dlg.SetHeading("Failed to connect to ARGUS TV"); dlg.SetLine(1, serverSettings.ServiceUrlPrefix); dlg.SetLine(2, errorMessage); dlg.SetLine(3, "Check plugin setup in Configuration"); dlg.DoModal(GUIWindowManager.ActiveWindow); _connectionErrorShown = true; } } } if (!Proxies.IsInitialized) { if (showHomeOnError && GUIWindowManager.ActiveWindow != 0) { using (Settings xmlreader = new MPSettings()) { bool _startWithBasicHome = xmlreader.GetValueAsBool("gui", "startbasichome", false); if (_startWithBasicHome && System.IO.File.Exists(GUIGraphicsContext.Skin + @"\basichome.xml")) { GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_SECOND_HOME); } else { GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_HOME); } } } _connected = false; return(false); } _connected = true; return(true); }
void ShowOptionsForSite(OnlineVideosWebservice.Site site) { SiteSettings localSite = null; int localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(site.Name, out localSite); GUIDialogMenu dlgSel = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); dlgSel.ShowQuickNumbers = false; if (dlgSel != null) { dlgSel.Reset(); dlgSel.SetHeading(Translation.Instance.Actions); if (localSiteIndex == -1) { if (site.State != OnlineVideosWebservice.SiteState.Broken) { dlgSel.Add(Translation.Instance.AddToMySites); } } else { if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 2 && site.State != OnlineVideosWebservice.SiteState.Broken) { dlgSel.Add(Translation.Instance.UpdateMySite); dlgSel.Add(Translation.Instance.UpdateMySiteSkipCategories); } dlgSel.Add(Translation.Instance.RemoveFromMySites); } if (GUI_infoList.Count > 1) { dlgSel.Add(Translation.Instance.RemoveAllFromMySites); dlgSel.Add(Translation.Instance.UpdateAll); dlgSel.Add(Translation.Instance.UpdateAllSkipCategories); } if (!string.IsNullOrEmpty(site.Owner_FK) && localSiteIndex >= 0) // !only local && ! only global { dlgSel.Add(Translation.Instance.ShowReports); if (site.State != OnlineVideosWebservice.SiteState.Broken) { dlgSel.Add(Translation.Instance.ReportBroken); } } } dlgSel.DoModal(GUIWindowManager.ActiveWindow); if (dlgSel.SelectedId == -1) { return; // ESC used, nothing selected } if (dlgSel.SelectedLabelText == Translation.Instance.AddToMySites || dlgSel.SelectedLabelText == Translation.Instance.UpdateMySite || dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories) { if (CheckOnlineVideosVersion()) { Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback( () => { bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites(null, new List <OnlineVideosWebservice.Site> { site }, false, dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories); if (updateResult == true) { newDllsDownloaded = true; } else if (updateResult == null) { newDataSaved = true; } return(updateResult != false); }, (success, result) => { if (success && (bool)result) { SiteImageExistenceCache.UnCacheImageForSite(site.Name); RefreshDisplayedOnlineSites(); } }, Translation.Instance.GettingSiteXml, true); } } else if (dlgSel.SelectedLabelText == Translation.Instance.UpdateAll || dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories) { if (CheckOnlineVideosVersion()) { GUIDialogProgress dlgPrgrs = PrepareProgressDialog(Translation.Instance.FullUpdate); new System.Threading.Thread(delegate() { bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) => { if (dlgPrgrs != null) { if (!string.IsNullOrEmpty(m)) { dlgPrgrs.SetLine(1, m); } if (p != null) { dlgPrgrs.SetPercentage(p.Value); } return(dlgPrgrs.ShouldRenderLayer()); } else { return(true); } }, GUI_infoList.ListItems.Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList(), dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories); if (updateResult == true) { newDllsDownloaded = true; } else if (updateResult == null) { newDataSaved = true; } if (updateResult != false) { SiteImageExistenceCache.ClearCache(); } if (dlgPrgrs != null) { dlgPrgrs.Close(); } GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { RefreshDisplayedOnlineSites(); return(0); }, 0, 0, null); }) { Name = "OVSelectUpdate", IsBackground = true }.Start(); } } else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveFromMySites) { OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex); OnlineVideoSettings.Instance.SaveSites(); newDataSaved = true; RefreshDisplayedOnlineSites(GUI_infoList.SelectedListItemIndex); } else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveAllFromMySites) { bool needRefresh = false; foreach (var siteToRemove in GUI_infoList.ListItems.Where(g => g.IsPlayed).Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList()) { localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(siteToRemove.Name, out localSite); if (localSiteIndex >= 0) { OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex); needRefresh = true; } } if (needRefresh) { OnlineVideoSettings.Instance.SaveSites(); newDataSaved = true; RefreshDisplayedOnlineSites(); } } else if (dlgSel.SelectedLabelText == Translation.Instance.ShowReports) { Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback( () => { OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService(); return(ws.GetReports(site.Name)); }, (success, result) => { if (success) { OnlineVideosWebservice.Report[] reports = result as OnlineVideosWebservice.Report[]; if (reports == null || reports.Length == 0) { GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); if (dlg != null) { dlg.Reset(); dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon")); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetText(Translation.Instance.NoReportsForSite); dlg.DoModal(GUIWindowManager.ActiveWindow); } } else { selectedSite = site.Name; GUIControl.ClearControl(GetID, GUI_infoList.GetID); Array.Sort(reports, new Comparison <OnlineVideosWebservice.Report>(delegate(OnlineVideosWebservice.Report a, OnlineVideosWebservice.Report b) { return(b.Date.CompareTo(a.Date)); })); foreach (OnlineVideosWebservice.Report report in reports) { string shortMsg = report.Message.Replace(Environment.NewLine, " ").Replace("\n", " ").Replace("\r", " "); GUIListItem loListItem = new GUIListItem(shortMsg.Length > 44 ? shortMsg.Substring(0, 40) + " ..." : shortMsg); loListItem.TVTag = report; loListItem.Label2 = report.Type.ToString(); loListItem.Label3 = report.Date.ToString("g", OnlineVideoSettings.Instance.Locale); loListItem.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(OnReportSelected); GUI_infoList.Add(loListItem); } GUIControl.SelectItemControl(GetID, GUI_infoList.GetID, 0); GUIPropertyManager.SetProperty("#itemcount", GUI_infoList.Count.ToString()); GUIPropertyManager.SetProperty("#itemtype", Translation.Instance.Reports); } } }, Translation.Instance.GettingReports, true); } else if (dlgSel.SelectedLabelText == Translation.Instance.ReportBroken) { if (CheckOnlineVideosVersion()) { if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 1) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(site.Name); dlg.SetLine(1, Translation.Instance.PleaseUpdateLocalSite); dlg.DoModal(GUIWindowManager.ActiveWindow); } } else { string userReason = ""; if (GUIOnlineVideos.GetUserInputString(ref userReason, false)) { if (userReason.Length < 15) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, Translation.Instance.PleaseEnterDescription); dlg.DoModal(GUIWindowManager.ActiveWindow); } } else { OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService(); string message = ""; bool success = ws.SubmitReport(site.Name, userReason, OnlineVideosWebservice.ReportType.Broken, out message); GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); if (dlg != null) { dlg.Reset(); dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName); dlg.SetLine(1, success ? Translation.Instance.Done : Translation.Instance.Error); dlg.SetLine(2, message); dlg.DoModal(GUIWindowManager.ActiveWindow); } if (success) { // reload online sites OnlineVideos.Sites.Updater.GetRemoteOverviews(true); RefreshDisplayedOnlineSites(); } } } } } } }
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); }
private bool TestConnection() { bool wasConnected = false; bool portChanged = false; bool serverChanged = false; string errorMessage = string.Empty; PluginMain.ForceNoConnection = true; if (ServiceChannelFactories.IsInitialized) { wasConnected = true; if (_serverNameButton.Label != ServiceChannelFactories.ServerSettings.ServerName) { serverChanged = true; } if (Int32.Parse(_tcpPortButton.Label) != ServiceChannelFactories.ServerSettings.Port) { portChanged = true; } } _serverSettings.ServerName = _serverNameButton.Label; _serverSettings.Transport = ServiceTransport.NetTcp; _serverSettings.Port = Int32.Parse(_tcpPortButton.Label); _serverSettings.WakeOnLan.Enabled = _enableWolButton.Selected; _serverSettings.WakeOnLan.TimeoutSeconds = Int32.Parse(_WolTimeoutButton.SpinLabel); _isSingleSeat = Utility.IsThisASingleSeatSetup(_serverSettings.ServerName); if (Utility.InitialiseServerSettings(_serverSettings, out errorMessage)) { GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (pDlgOK != null) { pDlgOK.Reset(); pDlgOK.SetHeading(Utility.GetLocalizedText(TextId.Information)); pDlgOK.SetLine(1, Utility.GetLocalizedText(TextId.ConnectionSucceeded)); pDlgOK.SetLine(2, "Single seat:" + _isSingleSeat); pDlgOK.DoModal(this.GetID); } SaveSettings(true); PluginMain.ForceNoConnection = false; if (wasConnected && (serverChanged || portChanged)) { //we switched between 2 different servers, we suggest to restart mp. _mpRestartNeeded = true; } return(true); } else { if (wasConnected) { //load settings that worked before the test button was pressed. LoadSettings(true); UpdateButtons(); string error; if (Utility.InitialiseServerSettings(_serverSettings, out error)) { PluginMain.ForceNoConnection = false; } } GUIDialogOK pDlgOK = (GUIDialogOK)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_OK); if (pDlgOK != null) { pDlgOK.Reset(); pDlgOK.SetHeading(Utility.GetLocalizedText(TextId.Error)); pDlgOK.SetLine(1, Utility.GetLocalizedText(TextId.ConnectionFailed)); pDlgOK.SetLine(2, errorMessage); pDlgOK.DoModal(this.GetID); } } return(false); }
private void ShowSearchResults(string selectedTitle) { GUIControl.ClearControl(GetID, _viewsList.GetID); if (_rules == null || _rules.Count == 0) { _viewsList.Clear(); _selectedTitle = string.Empty; _isInSubDirectory = false; return; } List <ScheduleRule> rules = new List <ScheduleRule>(); for (int i = 0; i < _rules.Count; i++) { rules.Add(_rules[i]); } if (selectedTitle != string.Empty) { rules.Add(ScheduleRuleType.TitleEquals, selectedTitle); } if (_categorieArguments.Count > 0) { rules.Add(ScheduleRuleType.CategoryEquals, _categorieArguments.ToArray()); } if (_channelArguments.Count > 0) { rules.Add(ScheduleRuleType.Channels, _channelArguments.ToArray()); } Schedule _schedule = SchedulerAgent.CreateNewSchedule(this._channelType, ScheduleType.Recording); _schedule.Rules = rules; UpcomingProgram[] _searchResults = SchedulerAgent.GetUpcomingPrograms(_schedule, true); if (_searchResults.Length < 1) { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.Information)); dlg.SetLine(1, Utility.GetLocalizedText(TextId.NoProgrammesFound)); dlg.DoModal(GUIWindowManager.ActiveWindow); _isInSubDirectory = false; _selectedTitle = string.Empty; return; } _selectedTitle = selectedTitle; if (selectedTitle == string.Empty) { List <String> upcomingTitles = new List <String>(); foreach (UpcomingProgram program in _searchResults) { if (!upcomingTitles.Contains(program.Title)) { upcomingTitles.Add(program.Title); _viewsList.Add(CreateListItem(program, true)); } } _isInSubDirectory = false; } else { GUIListItem item = new GUIListItem(); item.Label = _parentDirectoryLabel; item.IsFolder = true; Utils.SetDefaultIcons(item); _viewsList.Add(item); foreach (UpcomingProgram program in _searchResults) { _viewsList.Add(CreateListItem(program, false)); } _isInSubDirectory = true; } string strObjects = string.Format("{0}", _viewsList.Count - (_isInSubDirectory ? 1 : 0)); GUIPropertyManager.SetProperty("#itemcount", strObjects); OnSort(); int selectedItemIndex; if (_isInSubDirectory) { selectedItemIndex = _selectedProgramIndex; } else { selectedItemIndex = _selectedTitleIndex; } while (selectedItemIndex >= _viewsList.Count && selectedItemIndex > 0) { selectedItemIndex--; } GUIControl.SelectItemControl(GetID, _viewsList.GetID, selectedItemIndex); UpdateProperties(); }