public override void LoadSettings() { //Load parameters from XML File using (Settings xmlreader = new MPSettings()) { mpTextBoxHostname.Text = xmlreader.GetValueAsString("tvservice", "hostname", ""); mpCheckBoxPrefAC3.Checked = xmlreader.GetValueAsBool("tvservice", "preferac3", false); mpCheckBoxPrefAudioOverLang.Checked = xmlreader.GetValueAsBool("tvservice", "preferAudioTypeOverLang", true); _preferredAudioLanguages = xmlreader.GetValueAsString("tvservice", "preferredaudiolanguages", ""); _preferredSubLanguages = xmlreader.GetValueAsString("tvservice", "preferredsublanguages", ""); mpCheckBoxEnableDVBSub.Checked = xmlreader.GetValueAsBool("tvservice", "dvbbitmapsubtitles", false); mpCheckBoxEnableTTXTSub.Checked = xmlreader.GetValueAsBool("tvservice", "dvbttxtsubtitles", false); mpCheckBoxEnableCCSub.Checked = xmlreader.GetValueAsBool("tvservice", "ccsubtitles", false); mpCheckBoxAutoShowSubWhenTvStarts.Checked = xmlreader.GetValueAsBool("tvservice", "autoshowsubwhentvstarts", true); enableAudioDualMonoModes.Checked = xmlreader.GetValueAsBool("tvservice", "audiodualmono", false); cbHideAllChannels.Checked = xmlreader.GetValueAsBool("mytv", "hideAllChannelsGroup", false); cbShowChannelStateIcons.Checked = xmlreader.GetValueAsBool("mytv", "showChannelStateIcons", true); cbContinuousScrollGuide.Checked = xmlreader.GetValueAsBool("mytv", "continuousScrollGuide", false); cbRelaxTsReader.Checked = xmlreader.GetValueAsBool("mytv", "relaxTsReader", false); mpCheckBoxIsWakeOnLanEnabled.Checked = xmlreader.GetValueAsBool("tvservice", "isWakeOnLanEnabled", false); mpNumericTextBoxWOLTimeOut.Text = xmlreader.GetValueAsString("tvservice", "WOLTimeOut", "10"); mpCheckBoxIsAutoMacAddressEnabled.Checked = xmlreader.GetValueAsBool("tvservice", "isAutoMacAddressEnabled", true); mpTextBoxMacAddress.Text = xmlreader.GetValueAsString("tvservice", "macAddress", "00:00:00:00:00:00"); mpCheckBoxRatingAsMovie.Checked = xmlreader.GetValueAsBool("genreoptions", "specifympaaratedasmovie", true); chkRecnotifications.Checked = xmlreader.GetValueAsBool("mytv", "enableRecNotifier", false); txtNotifyBefore.Text = xmlreader.GetValueAsString("mytv", "notifyTVBefore", "300"); txtNotifyAfter.Text = xmlreader.GetValueAsString("mytv", "notifyTVTimeout", "15"); checkBoxNotifyPlaySound.Checked = xmlreader.GetValueAsBool("mytv", "notifybeep", true); int showEpisodeinfo = xmlreader.GetValueAsInt("mytv", "showEpisodeInfo", 0); if (showEpisodeinfo > this.ShowEpisodeOptions.Length) { showEpisodeinfo = 0; } comboboxShowEpisodeInfo.SelectedIndex = showEpisodeinfo; } // Populate the list of program genres from the tv database. Assembly assem = Assembly.LoadFrom(Config.GetFolder(Config.Dir.Base) + "\\TvControl.dll"); if (assem != null) { Type[] types = assem.GetExportedTypes(); foreach (Type exportedType in types) { try { if (exportedType.Name == "TvServer") { Object genreObject = null; genreObject = Activator.CreateInstance(exportedType); MethodInfo methodInfo = exportedType.GetMethod("GetGenres", BindingFlags.Public | BindingFlags.Instance); _allProgramGenres = methodInfo.Invoke(genreObject, null) as List<String>; using (Settings xmlreader = new MPSettings()) { // If the genre map does not contain any entries then we'll create an initial default map. if (!xmlreader.HasSection<string>("genremap")) { CreateDefaultGenres(xmlreader); } // Load the genre map from MP settings. if (_genreMap.Count == 0) { LoadGenreMap(xmlreader); } if (!xmlreader.HasSection<string>("genreoptions")) { xmlreader.SetValueAsBool("genreoptions", "specifympaaratedasmovie", true); // Rated programs are movies } // Populate the guide genre list with names. PopulateGuideGenreList(); } } } catch (TargetInvocationException ex) { Log.Warn("TVClient: Failed to load genres {0}", ex.ToString()); continue; } catch (Exception gex) { Log.Warn("TVClient: Failed to load settings {0}", gex.Message); } } } mpCheckBoxIsWakeOnLanEnabled_CheckedChanged(null, null); // Enable this Panel if the TvPlugin exists in the plug-in Directory Enabled = true; try { assem = Assembly.LoadFrom(Config.GetFolder(Config.Dir.Base) + "\\TvLibrary.Interfaces.dll"); if (assem != null) { Type[] types = assem.GetExportedTypes(); foreach (Type exportedType in types) { try { if (exportedType.Name == "Languages") { // Load available languages into variables. Object languageObject = null; languageObject = Activator.CreateInstance(exportedType); MethodInfo methodInfo = exportedType.GetMethod("GetLanguages", BindingFlags.Public | BindingFlags.Instance); _languagesAvail = methodInfo.Invoke(languageObject, null) as List<String>; methodInfo = exportedType.GetMethod("GetLanguageCodes", BindingFlags.Public | BindingFlags.Instance); _languageCodes = (List<String>)methodInfo.Invoke(languageObject, null); if (_languagesAvail == null || _languageCodes == null) { Log.Debug("Failed to load languages"); return; } else { mpListViewAvailAudioLang.Items.Clear(); mpListViewPreferredAudioLang.Items.Clear(); for (int i = 0; i < _languagesAvail.Count; i++) { ListViewItem item = new ListViewItem(new string[] { _languagesAvail[i], _languageCodes[i] }); item.Name = _languageCodes[i]; if (!_preferredAudioLanguages.Contains(item.Name)) { if (!mpListViewAvailAudioLang.Items.ContainsKey(item.Name)) { mpListViewAvailAudioLang.Items.Add(item); } } } mpListViewAvailAudioLang.ListViewItemSorter = _columnSorter = new ListViewColumnSorter(); _columnSorter.SortColumn = 0; _columnSorter.Order = SortOrder.Ascending; mpListViewAvailAudioLang.Sort(); if (_preferredAudioLanguages.Length > 0) { string[] langArr = _preferredAudioLanguages.Split(';'); for (int i = 0; i < langArr.Length; i++) { string langStr = langArr[i]; if (langStr.Trim().Length > 0) { for (int j = 0; j < _languagesAvail.Count; j++) { if (_languageCodes[j].Contains(langStr)) { ListViewItem item = new ListViewItem(new string[] {_languagesAvail[j], _languageCodes[j]}); item.Name = _languageCodes[j]; mpListViewPreferredAudioLang.Items.Add(item); break; } } } } } mpListViewAvailSubLang.Items.Clear(); mpListViewPreferredSubLang.Items.Clear(); for (int i = 0; i < _languagesAvail.Count; i++) { ListViewItem item = new ListViewItem(new string[] { _languagesAvail[i], _languageCodes[i] }); item.Name = _languageCodes[i]; if (!_preferredSubLanguages.Contains(item.Name)) { if (!mpListViewAvailSubLang.Items.ContainsKey(item.Name)) { mpListViewAvailSubLang.Items.Add(item); } } } mpListViewAvailSubLang.ListViewItemSorter = _columnSorter = new ListViewColumnSorter(); _columnSorter.SortColumn = 0; _columnSorter.Order = SortOrder.Ascending; mpListViewAvailSubLang.Sort(); if (_preferredSubLanguages.Length > 0) { string[] langArr = _preferredSubLanguages.Split(';'); for (int i = 0; i < langArr.Length; i++) { string langStr = langArr[i]; if (langStr.Trim().Length > 0) { for (int j = 0; j < _languagesAvail.Count; j++) { if (_languageCodes[j].Contains(langStr)) { ListViewItem item = new ListViewItem(new string[] {_languagesAvail[j], _languageCodes[j]}); item.Name = _languageCodes[j]; mpListViewPreferredSubLang.Items.Add(item); break; } } } } } } } } catch (TargetInvocationException ex) { Log.Warn("TVClient: Failed to load languages {0}", ex.ToString()); continue; } catch (Exception gex) { Log.Warn("TVClient: Failed to load settings {0}", gex.Message); } } } } catch (Exception ex) { Log.Debug("Configuration: Loading TVLibrary.Interface assembly"); Log.Debug("Configuration: Exception: {0}", ex); } _SingleSeat = Network.IsSingleSeat(); }