public static void LoadSettings() { using ( MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings( MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml"))) { // Load previously incorrectly set value if it exists and clear afterwards int RemoteKeyDialogContextMenuOld = reader.GetValueAsInt("VideoCleaner", "remoteKeyDialogContextMenu", -1); if (RemoteKeyDialogContextMenuOld != -1) { RemoteKeyDialogContextMenu = RemoteKeyDialogContextMenuOld; reader.RemoveEntry("VideoCleaner", "remoteKeyDialogContextMenu"); } else { RemoteKeyDialogContextMenu = reader.GetValueAsInt("AudioSwitcher", "remoteKeyDialogContextMenu", 0); } RemoteKeyDialogContextMenu = reader.GetValueAsInt("AudioSwitcher", "remoteKeyDialogContextMenu", 0); DefaultPlaybackDevice = reader.GetValueAsString("AudioSwitcher", "defaultPlaybackDevice", ""); LAVbitstreamAlwaysShowToggleInContextMenu = reader.GetValueAsBool("AudioSwitcher", "LAVbitstreamAlwaysShowToggleInContextMenu", false); LAVbitstreamPerDevice = reader.GetValueAsBool("AudioSwitcher", "LAVbitstreamPerDevice", false); LAVbitstreamPropertyList = reader.GetValueAsString("AudioSwitcher", "LAVbitstreamPropertyList", ""); LAVaudioDelayControlsInContextMenu = reader.GetValueAsBool("AudioSwitcher", "LAVaudioDelayControlsInContextMenu", false); LAVaudioDelayEnabled = reader.GetValueAsBool("AudioSwitcher", "LAVaudioDelayEnabled", false); LAVaudioDelay = reader.GetValueAsString("AudioSwitcher", "LAVaudioDelay", "0"); } }
public static void LoadSettings() { using ( MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings( MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml"))) { DisableOnStart = reader.GetValueAsBool("HyperionScreenCapture", "disableOnStart", true); OnlyEnableWithMadVr = reader.GetValueAsBool("HyperionScreenCapture", "onlyEnableWithMadVr", false); RemoteToggleKey = reader.GetValueAsInt("HyperionScreenCapture", "remoteToggleKey", 0); ApiPort = reader.GetValueAsInt("HyperionScreenCapture", "apiPort", 29445); } }
public static void ReadFromConfigFile() { Ares.Settings.Settings settings = Ares.Settings.Settings.Instance; try { using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "aresplugin.xml"))) { settings.RecentFiles.AddFile(new Settings.RecentFiles.ProjectEntry(reader.GetValue("Files", "ProjectFile"), "")); settings.SoundDirectory = reader.GetValue("Directories", "SoundsDirectory"); settings.MusicDirectory = reader.GetValue("Directories", "MusicDirectory"); settings.UdpPort = reader.GetValueAsInt("Network", "UDPPort", 8009); settings.TcpPort = reader.GetValueAsInt("Network", "TCPPort", 11112); settings.IPAddress = reader.GetValue("Network", "IPAddress"); settings.GlobalVolume = reader.GetValueAsInt("Volume", "Global", 100); settings.MusicVolume = reader.GetValueAsInt("Volume", "Music", 100); settings.SoundVolume = reader.GetValueAsInt("Volume", "Sounds", 100); settings.LocalPlayerPath = reader.GetValue("Files", "LocalPlayerPath"); } } catch (Exception) { } }
public SetupForm() { InitializeComponent(); labelDefaultPort.Text = String.Format("(Default: {0})", WifiRemote.DEFAULT_PORT); // load port from settings using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { originalPort = reader.GetValue(WifiRemote.PLUGIN_NAME, "port"); checkBoxDisableBonjour.Checked = reader.GetValueAsBool(WifiRemote.PLUGIN_NAME, "disableBonjour", false); textBoxName.Text = reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "serviceName", WifiRemote.GetServiceName()); checkBoxShowConnectionMessage.Checked = reader.GetValueAsBool(WifiRemote.PLUGIN_NAME, "showNotifications", false); txtUsername.Text = WifiRemote.DecryptString(reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "username", "")); txtPassword.Text = WifiRemote.DecryptString(reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "password", "")); txtPasscode.Text = WifiRemote.DecryptString(reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "passcode", "")); cbAuthMethod.SelectedIndex = reader.GetValueAsInt(WifiRemote.PLUGIN_NAME, "auth", 0); numericUpDownAutologin.Value = reader.GetValueAsInt(WifiRemote.PLUGIN_NAME, "autologinTimeout", 0); resetPort(); // Read plugin ids and convert them to int String[] savedPluginStrings = reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "savedPlugins", "").Split('|'); savedPlugins = new Dictionary<int, string>(); for (int j = 0; j + 1 < savedPluginStrings.Length; j = j + 2) { // Add plugin id and name int i; if (int.TryParse(savedPluginStrings[j], out i)) { savedPlugins.Add(i, savedPluginStrings[j + 1]); } } // Read ignored plugins // Ignored by default: // -1: // 0: home // 3005: GUITopbar // 730716: fanart handler String[] ignoredPluginsString = reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "ignoredPlugins", "-1|0|3005|730716").Split('|'); ignoredPluginsList = new List<int>(); foreach (String pluginId in ignoredPluginsString) { int i; if (int.TryParse(pluginId, out i)) { ignoredPluginsList.Add(i); } } } // Test if Bonjour is installed try { Version bonjourVersion = ZeroconfService.NetService.DaemonVersion; buttonDownloadBonjour.Enabled = false; checkBoxDisableBonjour.Enabled = false; buttonDownloadBonjour.Text = "Bonjour already installed"; } catch { if (Is64Bit() || Is32BitProcessOn64BitProcessor()) { // 64 bit windows is64bit = true; buttonDownloadBonjour.Enabled = true; checkBoxDisableBonjour.Enabled = true; buttonDownloadBonjour.Text = "Download and install Bonjour (64 bit)"; } else { // 32 bit windows is64bit = false; buttonDownloadBonjour.Enabled = true; checkBoxDisableBonjour.Enabled = true; buttonDownloadBonjour.Text = "Download and install Bonjour (32 bit)"; } } // Setup plugins list availablePlugins = new ArrayList(); plugins = new ArrayList(); pluginIcons = new ImageList(); pluginIcons.ImageSize = new Size(20, 20); EnumerateWindowPlugins(); LoadPlugins(); LoadSettings(); // Add saved plugins to list for ordering foreach (var aSavedPlugin in savedPlugins) { // Find saved plugin with this window id var query = from ItemTag p in plugins where p.WindowId == aSavedPlugin.Key select p; // Add the first found plugin to the list foreach (ItemTag plugin in query) { if (plugin.IsEnabled) { pluginsDataSource.Add(new WindowPlugin(aSavedPlugin.Value, aSavedPlugin.Key, (plugin.ActiveImage != null) ? ImageHelper.imageToByteArray(plugin.ActiveImage, System.Drawing.Imaging.ImageFormat.Png) : ImageHelper.imageToByteArray(Properties.Resources.NoPluginImage, System.Drawing.Imaging.ImageFormat.Png), !ignoredPluginsList.Contains(aSavedPlugin.Key))); } break; } } // Add rest of the plugins to the list foreach (ItemTag plugin in plugins) { if (!savedPlugins.ContainsKey(plugin.WindowId)) { addPluginToList(plugin); } } dataGridViewPluginList.AutoGenerateColumns = false; dataGridViewPluginList.AutoSize = true; dataGridViewPluginList.DataSource = pluginsDataSource; dataGridViewPluginList.CurrentCellDirtyStateChanged += new EventHandler(dataGridViewPluginList_CurrentCellDirtyStateChanged); DataGridViewCheckBoxColumn displayColumn = new DataGridViewCheckBoxColumn(); displayColumn.ReadOnly = false; displayColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader; displayColumn.DataPropertyName = "DisplayPlugin"; displayColumn.Name = ""; dataGridViewPluginList.Columns.Add(displayColumn); DataGridViewImageColumn iconColumn = new DataGridViewImageColumn(false); iconColumn.ReadOnly = true; iconColumn.ImageLayout = DataGridViewImageCellLayout.Zoom; iconColumn.Width = 20; iconColumn.DataPropertyName = "Icon"; iconColumn.Name = ""; dataGridViewPluginList.Columns.Add(iconColumn); DataGridViewColumn nameColumn = new DataGridViewTextBoxColumn(); nameColumn.ReadOnly = false; nameColumn.MinimumWidth = 200; nameColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; nameColumn.DataPropertyName = "Name"; nameColumn.Name = "Plugin"; dataGridViewPluginList.Columns.Add(nameColumn); }
public bool loadMenuIDs(bool onLoad) { menuItems.Clear(); used_list.Enabled = true; used_list.Items.Clear(); used_list_submenu.Items.Clear(); using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "Avalon.xml"))) { int a = 0; do { //Read menu if (xmlreader.GetValueAsString("AvalonBasicHome", "menuItemName" + a, "") != "") { Parents.Add(new Owner(a, xmlreader.GetValueAsString("AvalonBasicHome", "menuItemName" + a, ""), xmlreader.GetValueAsInt("AvalonBasicHome", "menuItemName" + a, 0), xmlreader.GetValueAsString("AvalonBasicHome", "menuItemParameter" + a, ""))); menuItem used_item = new menuItem(); used_item.identifier = a; used_item.name = xmlreader.GetValueAsString("AvalonBasicHome", "menuItemName" + a, ""); used_item.hyperlink = xmlreader.GetValueAsInt("AvalonBasicHome", "menuItemHyperlink" + a, 0); used_item.bgImage = xmlreader.GetValueAsString("AvalonBasicHome", "menuItemBgImage" + a, ""); used_item.property = xmlreader.GetValueAsString("AvalonBasicHome", "menuItemParameter" + a, ""); used_item.media = xmlreader.GetValueAsString("AvalonBasicHome", "menuItemRecentMedia" + a, ""); menuItems.Add(used_item); used_list.Items.Add(used_item.name); configloaded = true; int b = 0; do { //Read submenu if (xmlreader.GetValueAsString("AvalonBasicHomeSubmenu" + a, "submenuItemName" + b, "") != "") { //Log.Info("found some submenus, :" + a + ", " + b + "navn: " + xmlreader.GetValueAsString("AvalonBasicHomeSubmenu" + a, "submenuItemName" + b, "")); singleChildren.Add(new Child(a, b, xmlreader.GetValueAsString("AvalonBasicHomeSubmenu" + a, "submenuItemName" + b, ""), xmlreader.GetValueAsInt("AvalonBasicHomeSubmenu" + a, "submenuItemHyperlink" + b, 0), xmlreader.GetValueAsString("AvalonBasicHomeSubmenu" + a, "submenuItemBgImage" + b, ""), xmlreader.GetValueAsString("AvalonBasicHomeSubmenu" + a, "submenuItemParameter" + b, ""), xmlreader.GetValueAsString("AvalonBasicHome", "menuItemRecentMedia" + a, ""))); } b++; } while (b < 250); } a++; } while (a < 25); cB_FanartHandler.Checked = false; new_bgimage.Visible = false; cB_singleImage.Checked = false; combo_FanartHandler.Visible = false; bt_browse.Visible = false; rB_Movies.Visible = false; rB_MyFilms.Visible = false; rB_Music.Visible = false; rB_Recordings.Visible = false; rB_Pictures.Visible = false; rB_Series.Visible = false; cB_FanartHandler.Location = new Point(12, 42); } //return true; if (used_list.Items.Count > 0) { return true; } else { // Dont need to complain when first loading the app as its possible that the skin isnt installed if (!onLoad) MessageBox.Show("Error reading directory."); return false; } // Remove double entries int cnt = used_list.Items.Count; for (int i = 1; i < (cnt / 2) + 1; i++) { used_list.Items.RemoveAt(i); menuItems.RemoveAt(i); } cnt = used_list.Items.Count - 1; used_list.Items.RemoveAt(cnt); menuItems.RemoveAt(cnt); }
public MyLyricsSetup() { LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, MyLyricsSettings.LogName)); //LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log)); #region Initialize GUI and class InitializeComponent(); lyricsLibraryUC = new MyLyricsSetup_LyricsLibrary(this); this.tabPageLyricsDatabase.Controls.Add(lyricsLibraryUC); // initialize delegates m_DelegateLyricFound = new DelegateLyricFound(this.lyricFoundMethod); m_DelegateLyricNotFound = new DelegateLyricNotFound(this.lyricNotFoundMethod); m_DelegateThreadFinished = new DelegateThreadFinished(this.ThreadFinishedMethod); m_DelegateThreadException = new DelegateThreadException(this.ThreadExceptionMethod); // Grab music database MusicDatabase dbs = new MusicDatabase(); m_TotalTitles = dbs.GetNumOfSongs(); #endregion #region Get settings from in MediaPortal.xml using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml")) { try { tbLimit.Text = xmlreader.GetValueAsString("myLyrics", "limit", m_TotalTitles.ToString()); tbPluginName.Text = xmlreader.GetValueAsString("myLyrics", "pluginsName", "My Lyrics"); cbAutoFetch.Checked = xmlreader.GetValueAsBool("myLyrics", "automaticFetch", true); cbAutomaticUpdate.Checked = xmlreader.GetValueAsBool("myLyrics", "automaticUpdateWhenFirstFound", false); cbMoveSongFrom.Checked = xmlreader.GetValueAsBool("myLyrics", "moveLyricFromMarkedDatabase", true); lbSongsLimitNote.Text = ("(You have currently " + m_TotalTitles.ToString() + " titles in your music database)"); rdDefault.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useDefaultSitesMode", "True")).ToString().Equals("True") ? true : false; trackBar.Value = ((int)xmlreader.GetValueAsInt("myLyrics", "defaultSitesModeValue", 2)); trackBar_Scroll(null, null); if (!rdDefault.Checked) { trackBar.Enabled = false; rbUserDefined.Checked = true; cbLyricWiki.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyricWiki", "True")).ToString().Equals("True") ? true : false; cbEvilLabs.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useEvilLabs", "True")).ToString().Equals("True") ? true : false; cbLyrics007.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyrics007", "True")).ToString().Equals("True") ? true : false; cbLyricsOnDemand.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyricsOnDemand", "True")).ToString().Equals("True") ? true : false; cbSeekLyrics.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useSeekLyrics", "True")).ToString().Equals("True") ? true : false; cbHotLyrics.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useHotLyrics", "True")).ToString().Equals("True") ? true : false; } } catch { MessageBox.Show("Something has gone wrong when reading Mediaportal.xml"); } } #endregion #region Serialzie/deserialize lyricsdatabases string lyricsXMLpath = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Base, MyLyricsSettings.LyricsXMLName); FileInfo lyricsXMLfileInfo = new FileInfo(lyricsXMLpath); // If lyrics.xml present, then convert database to new format... if (lyricsXMLfileInfo.Exists) { string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); FileInfo fileInfo = new FileInfo(path); // .. but only if it hasn't already been converted if (fileInfo.Exists == false) { if (MessageBox.Show(this, "Your database will have to be upgraded to work with this version\r\nUpgrade now?", "Upgrade lyricsdatabase", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { ConvertFromXMLtoLyricsDatabase convertFromXMLtoLyricsDatabase = new ConvertFromXMLtoLyricsDatabase(); MyLyricsSettings.LyricsDB = convertFromXMLtoLyricsDatabase.Convert(lyricsXMLpath); // Create file to save the database to FileStream fs = new FileStream(path, FileMode.Create); // Create a BinaryFormatter object to perform the serialization BinaryFormatter bf = new BinaryFormatter(); // Use the BinaryFormatter object to serialize the database to the file bf.Serialize(fs, MyLyricsSettings.LyricsDB); fs.Close(); // Create likewise a database for the remainingLyrics path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsMarkedDBName); fs = new FileStream(path, FileMode.Create); MyLyricsSettings.LyricsMarkedDB = new LyricsDatabase(); bf.Serialize(fs, MyLyricsSettings.LyricsMarkedDB); // Close the file fs.Close(); } } // ... else deserialize the databases and save reference in LyricsDB and LyricsMarkedDB else { DeserializeBothDB(); } } // If no Lyrics.xml present in base, then create new serialized databases else { string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); FileInfo fileInfo = new FileInfo(path); // .. but only if the databases hasn't been created if (fileInfo.Exists == false) { path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); // Serialize empty LyricsDatabase if no lyrics.xml present FileStream fs = new FileStream(path, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); MyLyricsSettings.LyricsDB = new LyricsDatabase(); bf.Serialize(fs, MyLyricsSettings.LyricsDB); fs.Close(); // Serialize empty LyricsMarkedDatabase path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsMarkedDBName); fs = new FileStream(path, FileMode.Create); MyLyricsSettings.LyricsMarkedDB = new LyricsDatabase(); bf.Serialize(fs, MyLyricsSettings.LyricsMarkedDB); fs.Close(); } else { DeserializeBothDB(); } } MyLyricsSetup_LyricsLibrary.CurrentDB = MyLyricsSettings.LyricsDB; #endregion lyricsLibraryUC.updateLyricsTree(); }
private void DoFirstLoad() { // Set layout to Listview facadeLayout.CurrentLayout = GUIFacadeControl.Layout.List; // Load settings from XML-file using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "HeadWeb.xml"))) { HeadWebSettings.Instance.s_username = xmlreader.GetValueAsString("Settings", "Username", ""); HeadWebSettings.Instance.s_password = xmlreader.GetValueAsString("Settings", "Password", ""); HeadWebSettings.Instance.s_pincode = xmlreader.GetValueAsString("Settings", "PINCode", ""); HeadWebSettings.Instance.s_video_quality = xmlreader.GetValueAsString("Settings", "VideoQuality", ""); if (xmlreader.GetValueAsInt("Settings", "AutoLogin", 0) != 0) HeadWebSettings.Instance.s_autologin = true; if (xmlreader.GetValueAsInt("Settings", "PinApprovePurchase", 0) != 0) HeadWebSettings.Instance.s_pinapprovepurchase = true; if (xmlreader.GetValueAsInt("Settings", "DisableAdultMovies", 0) != 0) HeadWebSettings.Instance.s_disableadultmovies = true; if (xmlreader.GetValueAsInt("Settings", "UseOrginalName", 0) != 0) HeadWebSettings.Instance.s_useoriginalname = true; } // Try to log in (if auto-login is enabled) if (HeadWebSettings.Instance.s_autologin) { bool loginresult = loginUser(HeadWebSettings.Instance.s_username, HeadWebSettings.Instance.s_password); if (loginresult) { HeadWebSettings.Instance.s_loggedin = true; // Load favorites getFavorites(true); } } // Add a special reversed proxy handler for rtmp ReverseProxy.Instance.AddHandler(RTMP_LIB.RTMPRequestHandler.Instance); // Replace g_player's ShowFullScreenWindowVideo g_Player.ShowFullScreenWindowVideo = ShowFullScreenWindowHandler; g_Player.PlayBackEnded += new g_Player.EndedHandler(g_Player_PlayBackEnded); // Load translated strings into GUI foreach (string name in Translation.Strings.Keys) { GUIPropertyManager.SetProperty("#HeadWeb.Translation." + name + ".Label", Translation.Strings[name]); } // First load done, don't do it again firstLoadDone = true; }
public SetupForm() { InitializeComponent(); labelDefaultPort.Text = String.Format("(Default: {0})", WifiRemote.DEFAULT_PORT); // load port from settings using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) { originalPort = reader.GetValue(WifiRemote.PLUGIN_NAME, "port"); checkBoxDisableBonjour.Checked = reader.GetValueAsBool(WifiRemote.PLUGIN_NAME, "disableBonjour", false); textBoxName.Text = reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "serviceName", WifiRemote.GetServiceName()); checkBoxShowConnectionMessage.Checked = reader.GetValueAsBool(WifiRemote.PLUGIN_NAME, "showNotifications", false); txtUsername.Text = WifiRemote.DecryptString(reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "username", "")); txtPassword.Text = WifiRemote.DecryptString(reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "password", "")); txtPasscode.Text = WifiRemote.DecryptString(reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "passcode", "")); cbAuthMethod.SelectedIndex = reader.GetValueAsInt(WifiRemote.PLUGIN_NAME, "auth", 0); numericUpDownAutologin.Value = reader.GetValueAsInt(WifiRemote.PLUGIN_NAME, "autologinTimeout", 0); resetPort(); // Read plugin ids and convert them to int String[] savedPluginStrings = reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "savedPlugins", "").Split('|'); savedPlugins = new Dictionary <int, string>(); for (int j = 0; j + 1 < savedPluginStrings.Length; j = j + 2) { // Add plugin id and name int i; if (int.TryParse(savedPluginStrings[j], out i)) { try { savedPlugins.Add(i, savedPluginStrings[j + 1]); } catch (Exception e) { WifiRemote.LogMessage("Adding saved plugin from config failed: " + e.Message, WifiRemote.LogType.Debug); } } } // Read ignored plugins // Ignored by default: // -1: // 0: home // 3005: GUITopbar // 730716: fanart handler String[] ignoredPluginsString = reader.GetValueAsString(WifiRemote.PLUGIN_NAME, "ignoredPlugins", "-1|0|3005|730716").Split('|'); ignoredPluginsList = new List <int>(); foreach (String pluginId in ignoredPluginsString) { int i; if (int.TryParse(pluginId, out i)) { try { ignoredPluginsList.Add(i); } catch (Exception e) { WifiRemote.LogMessage("Adding ignored plugin from config failed: " + e.Message, WifiRemote.LogType.Debug); } } } } // Test if Bonjour is installed try { Version bonjourVersion = ZeroconfService.NetService.DaemonVersion; buttonDownloadBonjour.Enabled = false; checkBoxDisableBonjour.Enabled = false; buttonDownloadBonjour.Text = "Bonjour already installed"; } catch { if (Is64Bit() || Is32BitProcessOn64BitProcessor()) { // 64 bit windows is64bit = true; buttonDownloadBonjour.Enabled = true; checkBoxDisableBonjour.Enabled = true; buttonDownloadBonjour.Text = "Download and install Bonjour (64 bit)"; } else { // 32 bit windows is64bit = false; buttonDownloadBonjour.Enabled = true; checkBoxDisableBonjour.Enabled = true; buttonDownloadBonjour.Text = "Download and install Bonjour (32 bit)"; } } // Setup plugins list availablePlugins = new ArrayList(); plugins = new ArrayList(); pluginIcons = new ImageList(); pluginIcons.ImageSize = new Size(20, 20); EnumerateWindowPlugins(); LoadPlugins(); LoadSettings(); // Add saved plugins to list for ordering foreach (var aSavedPlugin in savedPlugins) { // Find saved plugin with this window id var query = from ItemTag p in plugins where p.WindowId == aSavedPlugin.Key select p; // Add the first found plugin to the list foreach (ItemTag plugin in query) { if (plugin.IsEnabled) { pluginsDataSource.Add(new WindowPlugin(aSavedPlugin.Value, aSavedPlugin.Key, (plugin.ActiveImage != null) ? ImageHelper.imageToByteArray(plugin.ActiveImage, System.Drawing.Imaging.ImageFormat.Png) : ImageHelper.imageToByteArray(Properties.Resources.NoPluginImage, System.Drawing.Imaging.ImageFormat.Png), !ignoredPluginsList.Contains(aSavedPlugin.Key))); } break; } } // Add rest of the plugins to the list foreach (ItemTag plugin in plugins) { if (!savedPlugins.ContainsKey(plugin.WindowId)) { addPluginToList(plugin); } } dataGridViewPluginList.AutoGenerateColumns = false; dataGridViewPluginList.AutoSize = true; dataGridViewPluginList.DataSource = pluginsDataSource; dataGridViewPluginList.CurrentCellDirtyStateChanged += new EventHandler(dataGridViewPluginList_CurrentCellDirtyStateChanged); DataGridViewCheckBoxColumn displayColumn = new DataGridViewCheckBoxColumn(); displayColumn.ReadOnly = false; displayColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader; displayColumn.DataPropertyName = "DisplayPlugin"; displayColumn.Name = ""; dataGridViewPluginList.Columns.Add(displayColumn); DataGridViewImageColumn iconColumn = new DataGridViewImageColumn(false); iconColumn.ReadOnly = true; iconColumn.ImageLayout = DataGridViewImageCellLayout.Zoom; iconColumn.Width = 20; iconColumn.DataPropertyName = "Icon"; iconColumn.Name = ""; dataGridViewPluginList.Columns.Add(iconColumn); DataGridViewColumn nameColumn = new DataGridViewTextBoxColumn(); nameColumn.ReadOnly = false; nameColumn.MinimumWidth = 200; nameColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; nameColumn.DataPropertyName = "Name"; nameColumn.Name = "Plugin"; dataGridViewPluginList.Columns.Add(nameColumn); }
public static void LoadSettings() { using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml"))) { // Legacy support // The effect settings were integers in the past, but now are strings. // In order to avoid a lot of people loosing their effect settings during an update, // we convert the old settings to the new ones. int effectVideoInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectVideo", "MediaPortalLiveMode"), out effectVideoInt)) { effectVideo = OldIntToNewContentEffect(effectVideoInt); SaveSpecificSetting("effectVideo", effectVideo.ToString()); } else { effectVideo = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectVideo", "MediaPortalLiveMode")); } int effectMusicInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMusic", "LEDsDisabled"), out effectMusicInt)) { effectMusic = OldIntToNewContentEffect(effectMusicInt); SaveSpecificSetting("effectMusic", effectMusic.ToString()); } else { effectMusic = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMusic", "LEDsDisabled")); } int effecRadioInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectRadio", "LEDsDisabled"), out effecRadioInt)) { effectRadio = OldIntToNewContentEffect(effecRadioInt); SaveSpecificSetting("effectRadio", effectRadio.ToString()); } else { effectRadio = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectRadio", "LEDsDisabled")); } int effectMenuInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMenu", "LEDsDisabled"), out effectMenuInt)) { effectMenu = OldIntToNewContentEffect(effectMenuInt); SaveSpecificSetting("effectMenu", effectMenu.ToString()); } else { effectMenu = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMenu", "LEDsDisabled")); } int effectMPExitInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMPExit", "LEDsDisabled"), out effectMPExitInt)) { effectMPExit = OldIntToNewContentEffect(effectMPExitInt == 4 ? 5 : effectMPExitInt); SaveSpecificSetting("effectMPExit", effectMPExit.ToString()); } else { effectMPExit = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMPExit", "LEDsDisabled")); } currentLanguage = reader.GetValueAsString("atmolight", "currentLanguage", "English"); // Check for presence of legacy file location (1.7.0.5 or lower) currentLanguageFileLegacy = reader.GetValueAsString("atmolight", "currentLanguageFile", ""); if (!string.IsNullOrEmpty(currentLanguageFileLegacy)) { if (currentLanguageFileLegacy.Contains("nl.xml")) { currentLanguage = "Dutch"; } else if (currentLanguageFileLegacy.Contains("en.xml")) { currentLanguage = "English"; } else if (currentLanguageFileLegacy.Contains("fr.xml")) { currentLanguage = "French"; } else if (currentLanguageFileLegacy.Contains("de.xml")) { ; currentLanguage = "German"; } } string mediaportalLanguageDir = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Language) + "\\"; if (string.IsNullOrEmpty(mediaportalLanguageDir) || !Directory.Exists(mediaportalLanguageDir)) { mediaportalLanguageDir = @"C:\ProgramData\Team MediaPortal\MediaPortal\Language\"; } try { switch (currentLanguage) { case "Dutch": currentLanguageFileLocation = mediaportalLanguageDir + "\\AtmoLight\\nl.xml"; break; case "English": currentLanguageFileLocation = mediaportalLanguageDir + "\\AtmoLight\\en.xml"; break; case "French": currentLanguageFileLocation = mediaportalLanguageDir + "\\AtmoLight\\fr.xml"; break; case "German": currentLanguageFileLocation = mediaportalLanguageDir + "\\AtmoLight\\de.xml"; break; } } catch (Exception ex) { Log.Error("Error during LoadSettings"); Log.Error(ex.Message); throw; } // Normal settings loading atmowinExe = reader.GetValueAsString("atmolight", "atmowinexe", ""); killButton = reader.GetValueAsInt("atmolight", "killbutton", 4); profileButton = reader.GetValueAsInt("atmolight", "cmbutton", 4); menuButton = reader.GetValueAsInt("atmolight", "menubutton", 4); excludeTimeStart = LoadTimeSetting(reader, "excludeTimeStart", "00:00"); excludeTimeEnd = LoadTimeSetting(reader, "excludeTimeEnd", "00:00"); manualMode = reader.GetValueAsBool("atmolight", "OffOnStart", false); sbs3dOn = reader.GetValueAsBool("atmolight", "SBS_3D_ON", false); lowCPU = reader.GetValueAsBool("atmolight", "lowCPU", false); lowCPUTime = reader.GetValueAsInt("atmolight", "lowCPUTime", 0); delay = reader.GetValueAsBool("atmolight", "Delay", false); delayReferenceRefreshRate = reader.GetValueAsInt("atmolight", "DelayRefreshRate", 0); // Legacy reference time delayReferenceTime = reader.GetValueAsInt("atmolight", "DelayTime", 0); // New reference times delayReferenceTime23 = reader.GetValueAsInt("atmolight", "DelayTime23", 0); delayReferenceTime24 = reader.GetValueAsInt("atmolight", "DelayTime24", 0); delayReferenceTime50 = reader.GetValueAsInt("atmolight", "DelayTime50", 0); delayReferenceTime59 = reader.GetValueAsInt("atmolight", "DelayTime59", 0); // If all of the specific refresh values are 0, assume upgrade setting from single rate if (delayReferenceTime23 == 0 && delayReferenceTime24 == 0 && delayReferenceTime50 == 0 && delayReferenceTime59 == 0) { switch (delayReferenceRefreshRate) { case 23: delayReferenceTime23 = delayReferenceTime; break; case 24: delayReferenceTime24 = delayReferenceTime; break; case 50: delayReferenceTime50 = delayReferenceTime; break; case 59: delayReferenceTime59 = delayReferenceTime; break; } } exitAtmoWin = reader.GetValueAsBool("atmolight", "ExitAtmoWin", true); startAtmoWin = reader.GetValueAsBool("atmolight", "StartAtmoWin", true); atmoWakeHelperEnabled = reader.GetValueAsBool("atmolight", "atmoWakeHelperEnabled", false); atmoWakeHelperComPort = reader.GetValueAsString("atmolight", "atmoWakeHelperComPort", ""); atmoWakeHelperResumeDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperResumeDelay", 2500); atmoWakeHelperDisconnectDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperDisconnectDelay", 1500); atmoWakeHelperConnectDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperConnectDelay", 1500); atmoWakeHelperReinitializationDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperReinitializationDelay", 0); staticColorRed = reader.GetValueAsInt("atmolight", "StaticColorRed", 0); staticColorGreen = reader.GetValueAsInt("atmolight", "StaticColorGreen", 0); staticColorBlue = reader.GetValueAsInt("atmolight", "StaticColorBlue", 0); restartOnError = reader.GetValueAsBool("atmolight", "RestartOnError", true); trueGrabbing = reader.GetValueAsBool("atmolight", "TrueGrabbing", true); blackbarDetection = reader.GetValueAsBool("atmolight", "BlackbarDetection", false); blackbarDetectionTime = reader.GetValueAsInt("atmolight", "BlackbarDetectionTime", 1000); gifFile = reader.GetValueAsString("atmolight", "GIFFile", ""); captureWidth = reader.GetValueAsInt("atmolight", "captureWidth", 64); captureHeight = reader.GetValueAsInt("atmolight", "captureHeight", 64); monitorScreensaverState = reader.GetValueAsBool("atmolight", "monitorScreensaverState", true); monitorWindowState = reader.GetValueAsBool("atmolight", "monitorWindowState", true); hyperionIP = reader.GetValueAsString("atmolight", "hyperionIP", "127.0.0.1"); hyperionPort = reader.GetValueAsInt("atmolight", "hyperionPort", 19445); hyperionReconnectDelay = reader.GetValueAsInt("atmolight", "hyperionReconnectDelay", 10000); hyperionReconnectAttempts = reader.GetValueAsInt("atmolight", "hyperionReconnectAttempts", 5); hyperionPriority = reader.GetValueAsInt("atmolight", "hyperionPriority", 1); hyperionPriorityStaticColor = reader.GetValueAsInt("atmolight", "hyperionStaticColorPriority", 1); hyperionLiveReconnect = reader.GetValueAsBool("atmolight", "hyperionLiveReconnect", false); hueExe = reader.GetValueAsString("atmolight", "hueExe", ""); hueStart = reader.GetValueAsBool("atmolight", "hueStart", true); hueIsRemoteMachine = reader.GetValueAsBool("atmolight", "hueIsRemoteMachine", false); hueIP = reader.GetValueAsString("atmolight", "hueIP", "127.0.0.1"); huePort = reader.GetValueAsInt("atmolight", "huePort", 20123); hueReconnectDelay = reader.GetValueAsInt("atmolight", "hueReconnectDelay", 10000); hueReconnectAttempts = reader.GetValueAsInt("atmolight", "hueReconnectAttempts", 5); hueBridgeEnableOnResume = reader.GetValueAsBool("atmolight", "hueBridgeEnableOnResume", false); hueBridgeDisableOnSuspend = reader.GetValueAsBool("atmolight", "hueBridgeDisableOnSuspend", false); hueTheaterEnabled = reader.GetValueAsBool("atmolight", "hueTheaterEnabled", false); hueTheaterRestoreLights = reader.GetValueAsBool("atmolight", "hueTheaterRestoreLights", false); hueTheaterEnabledVU = reader.GetValueAsBool("atmolight", "hueTheaterEnabledVU", false); boblightIP = reader.GetValueAsString("atmolight", "boblightIP", "127.0.0.1"); boblightPort = reader.GetValueAsInt("atmolight", "boblightPort", 19333); boblightMaxFPS = reader.GetValueAsInt("atmolight", "boblightMaxFPS", 10); boblightMaxReconnectAttempts = reader.GetValueAsInt("atmolight", "boblightMaxReconnectAttempts", 5); boblightReconnectDelay = reader.GetValueAsInt("atmolight", "boblightReconnectDelay", 5000); boblightSpeed = reader.GetValueAsInt("atmolight", "boblightSpeed", 100); boblightAutospeed = reader.GetValueAsInt("atmolight", "boblightAutospeed", 0); boblightInterpolation = reader.GetValueAsBool("atmolight", "boblightInterpolation", true); boblightSaturation = reader.GetValueAsInt("atmolight", "boblightSaturation", 1); boblightValue = reader.GetValueAsInt("atmolight", "boblightValue", 1); boblightThreshold = reader.GetValueAsInt("atmolight", "boblightThreshold", 20); boblightGamma = Double.Parse(reader.GetValueAsString("atmolight", "boblightGamma", "2.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoWinTarget = reader.GetValueAsBool("atmolight", "atmoWinTarget", true); boblightTarget = reader.GetValueAsBool("atmolight", "boblightTarget", false); hueTarget = reader.GetValueAsBool("atmolight", "hueTarget", false); hyperionTarget = reader.GetValueAsBool("atmolight", "hyperionTarget", false); blackbarDetectionThreshold = reader.GetValueAsInt("atmolight", "blackbarDetectionThreshold", 20); powerModeChangedDelay = reader.GetValueAsInt("atmolight", "powerModeChangedDelay", 5000); ambiBoxTarget = reader.GetValueAsBool("atmolight", "ambiBoxTarget", false); ambiBoxIP = reader.GetValueAsString("atmolight", "ambiBoxIP", "127.0.0.1"); ambiBoxPort = reader.GetValueAsInt("atmolight", "ambiBoxPort", 3636); ambiBoxMaxReconnectAttempts = reader.GetValueAsInt("atmolight", "ambiBoxMaxReconnectAttempts", 5); ambiBoxReconnectDelay = reader.GetValueAsInt("atmolight", "ambiBoxReconnectDelay", 5000); ambiBoxChangeImageDelay = reader.GetValueAsInt("atmolight", "ambiBoxChangeImageDelay", 10); ambiBoxMediaPortalProfile = reader.GetValueAsString("atmolight", "ambiBoxMediaPortalProfile", "MediaPortal"); ambiBoxExternalProfile = reader.GetValueAsString("atmolight", "ambiBoxExternalProfile", "External"); ambiBoxPath = reader.GetValueAsString("atmolight", "ambiBoxPath", "C:\\Program Files (x86)\\AmbiBox\\AmbiBox.exe"); ambiBoxAutoStart = reader.GetValueAsBool("atmolight", "ambiBoxAutoStart", false); ambiBoxAutoStop = reader.GetValueAsBool("atmolight", "ambiBoxAutoStop", false); atmoOrbTarget = reader.GetValueAsBool("atmolight", "atmoOrbTarget", false); atmoOrbBlackThreshold = reader.GetValueAsInt("atmolight", "atmoOrbBlackThreshold", 16); atmoOrbBroadcastPort = reader.GetValueAsInt("atmolight", "atmoOrbBroadcastPort", 49692); atmoOrbGamma = Double.Parse(reader.GetValueAsString("atmolight", "atmoOrbGamma", "1").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoOrbMinDiversion = reader.GetValueAsInt("atmolight", "atmoOrbMinDiversion", 16); atmoOrbSaturation = Double.Parse(reader.GetValueAsString("atmolight", "atmoOrbSaturation", "0.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoOrbThreshold = reader.GetValueAsInt("atmolight", "atmoOrbThreshold", 0); atmoOrbUseOverallLightness = reader.GetValueAsBool("atmolight", "atmoOrbUseOverallLightness", true); atmoOrbUseSmoothing = reader.GetValueAsBool("atmolight", "atmoOrbUseSmoothing", true); atmoOrbSmoothingThreshold = reader.GetValueAsInt("atmolight", "atmoOrbSmoothingThreshold", 200); string atmoOrbLampTemp = reader.GetValueAsString("atmolight", "atmoOrbLamps", ""); string[] atmoOrbLampTempSplit = atmoOrbLampTemp.Split('|'); for (int i = 0; i < atmoOrbLampTempSplit.Length; i++) { if (!string.IsNullOrEmpty(atmoOrbLampTempSplit[i])) { atmoOrbLamps.Add(atmoOrbLampTempSplit[i]); } } vuMeterMindB = reader.GetValueAsInt("atmolight", "vuMeterMindB", -24); vuMeterMinHue = Double.Parse(reader.GetValueAsString("atmolight", "vuMeterMinHue", "0,74999").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); vuMeterMaxHue = Double.Parse(reader.GetValueAsString("atmolight", "vuMeterMaxHue", "0,95833").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); hueThreshold = reader.GetValueAsInt("atmolight", "hueThreshold", 16); hueBlackThreshold = reader.GetValueAsInt("atmolight", "hueBlackThreshold", 16); hueMinDiversion = reader.GetValueAsInt("atmolight", "hueMinDiversion", 16); hueSaturation = Double.Parse(reader.GetValueAsString("atmolight", "hueSaturation", "0.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); hueUseOverallLightness = reader.GetValueAsBool("atmolight", "hueUseOverallLightness", true); blackbarDetectionHorizontal = reader.GetValueAsBool("atmolight", "blackbarDetectionHorizontal", true); blackbarDetectionVertical = reader.GetValueAsBool("atmolight", "blackbarDetectionVertical", true); blackbarDetectionLinkAreas = reader.GetValueAsBool("atmolight", "blackbarDetectionLinkAreas", true); remoteApiServer = reader.GetValueAsBool("atmolight", "remoteApiServer", false); doNotShowConnectionErrorsDuringPlayback = reader.GetValueAsBool("atmolight", "doNotShowConnectionErrorsDuringPlayback", false); } }
public static void LoadSettings() { using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml"))) { // Legacy support // The effect settings were integers in the past, but now are strings. // In order to avoid a lot of people loosing their effect settings during an update, // we convert the old settings to the new ones. int effectVideoInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectVideo", "MediaPortalLiveMode"), out effectVideoInt)) { effectVideo = OldIntToNewContentEffect(effectVideoInt); SaveSpecificSetting("effectVideo", effectVideo.ToString()); } else { effectVideo = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectVideo", "MediaPortalLiveMode")); } int effectMusicInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMusic", "LEDsDisabled"), out effectMusicInt)) { effectMusic = OldIntToNewContentEffect(effectMusicInt); SaveSpecificSetting("effectMusic", effectMusic.ToString()); } else { effectMusic = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMusic", "LEDsDisabled")); } int effecRadioInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectRadio", "LEDsDisabled"), out effecRadioInt)) { effectRadio = OldIntToNewContentEffect(effecRadioInt); SaveSpecificSetting("effectRadio", effectRadio.ToString()); } else { effectRadio = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectRadio", "LEDsDisabled")); } int effectMenuInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMenu", "LEDsDisabled"), out effectMenuInt)) { effectMenu = OldIntToNewContentEffect(effectMenuInt); SaveSpecificSetting("effectMenu", effectMenu.ToString()); } else { effectMenu = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMenu", "LEDsDisabled")); } int effectMPExitInt; if (int.TryParse(reader.GetValueAsString("atmolight", "effectMPExit", "LEDsDisabled"), out effectMPExitInt)) { effectMPExit = OldIntToNewContentEffect(effectMPExitInt == 4 ? 5 : effectMPExitInt); SaveSpecificSetting("effectMPExit", effectMPExit.ToString()); } else { effectMPExit = (ContentEffect)Enum.Parse(typeof(ContentEffect), reader.GetValueAsString("atmolight", "effectMPExit", "LEDsDisabled")); } currentLanguageFile = reader.GetValueAsString("atmolight", "CurrentLanguageFile", Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\en.xml"); if (currentLanguageFile.Substring(currentLanguageFile.Length - 3, 3).ToLower() == "lng") { int lastBackslash = currentLanguageFile.LastIndexOf("\\") + 1; int lastDot = currentLanguageFile.LastIndexOf("."); switch (currentLanguageFile.Substring(lastBackslash, lastDot - lastBackslash)) { case "GermanDE": currentLanguageFile = Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\de.xml"; break; case "DutchNL": currentLanguageFile = Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\nl.xml"; break; case "FrenchFR": currentLanguageFile = Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\fr.xml"; break; default: case "EnglishUS": currentLanguageFile = Win32API.GetSpecialFolder(Win32API.CSIDL.CSIDL_COMMON_APPDATA) + "\\Team MediaPortal\\MediaPortal\\language\\AtmoLight\\en.xml"; break; } } // Normal settings loading atmowinExe = reader.GetValueAsString("atmolight", "atmowinexe", ""); killButton = reader.GetValueAsInt("atmolight", "killbutton", 4); profileButton = reader.GetValueAsInt("atmolight", "cmbutton", 4); menuButton = reader.GetValueAsInt("atmolight", "menubutton", 4); excludeTimeStart = LoadTimeSetting(reader, "excludeTimeStart", "00:00"); excludeTimeEnd = LoadTimeSetting(reader, "excludeTimeEnd", "00:00"); manualMode = reader.GetValueAsBool("atmolight", "OffOnStart", false); sbs3dOn = reader.GetValueAsBool("atmolight", "SBS_3D_ON", false); lowCPU = reader.GetValueAsBool("atmolight", "lowCPU", false); lowCPUTime = reader.GetValueAsInt("atmolight", "lowCPUTime", 0); delay = reader.GetValueAsBool("atmolight", "Delay", false); delayReferenceTime = reader.GetValueAsInt("atmolight", "DelayTime", 0); exitAtmoWin = reader.GetValueAsBool("atmolight", "ExitAtmoWin", true); startAtmoWin = reader.GetValueAsBool("atmolight", "StartAtmoWin", true); atmoWakeHelperEnabled = reader.GetValueAsBool("atmolight", "atmoWakeHelperEnabled", false); atmoWakeHelperComPort = reader.GetValueAsString("atmolight", "atmoWakeHelperComPort", ""); atmoWakeHelperResumeDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperResumeDelay", 2500); atmoWakeHelperDisconnectDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperDisconnectDelay", 1500); atmoWakeHelperConnectDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperConnectDelay", 1500); atmoWakeHelperReinitializationDelay = reader.GetValueAsInt("atmolight", "atmoWakeHelperReinitializationDelay", 0); staticColorRed = reader.GetValueAsInt("atmolight", "StaticColorRed", 0); staticColorGreen = reader.GetValueAsInt("atmolight", "StaticColorGreen", 0); staticColorBlue = reader.GetValueAsInt("atmolight", "StaticColorBlue", 0); restartOnError = reader.GetValueAsBool("atmolight", "RestartOnError", true); trueGrabbing = reader.GetValueAsBool("atmolight", "TrueGrabbing", true); delayReferenceRefreshRate = reader.GetValueAsInt("atmolight", "DelayRefreshRate", 50); blackbarDetection = reader.GetValueAsBool("atmolight", "BlackbarDetection", false); blackbarDetectionTime = reader.GetValueAsInt("atmolight", "BlackbarDetectionTime", 1000); gifFile = reader.GetValueAsString("atmolight", "GIFFile", ""); captureWidth = reader.GetValueAsInt("atmolight", "captureWidth", 64); captureHeight = reader.GetValueAsInt("atmolight", "captureHeight", 64); monitorScreensaverState = reader.GetValueAsBool("atmolight", "monitorScreensaverState", true); monitorWindowState = reader.GetValueAsBool("atmolight", "monitorWindowState", true); hyperionIP = reader.GetValueAsString("atmolight", "hyperionIP", "127.0.0.1"); hyperionPort = reader.GetValueAsInt("atmolight", "hyperionPort", 19445); hyperionReconnectDelay = reader.GetValueAsInt("atmolight", "hyperionReconnectDelay", 10000); hyperionReconnectAttempts = reader.GetValueAsInt("atmolight", "hyperionReconnectAttempts", 5); hyperionPriority = reader.GetValueAsInt("atmolight", "hyperionPriority", 1); hyperionPriorityStaticColor = reader.GetValueAsInt("atmolight", "hyperionStaticColorPriority", 1); hyperionLiveReconnect = reader.GetValueAsBool("atmolight", "hyperionLiveReconnect", false); hueExe = reader.GetValueAsString("atmolight", "hueExe", ""); hueStart = reader.GetValueAsBool("atmolight", "hueStart", true); hueIsRemoteMachine = reader.GetValueAsBool("atmolight", "hueIsRemoteMachine", false); hueIP = reader.GetValueAsString("atmolight", "hueIP", "127.0.0.1"); huePort = reader.GetValueAsInt("atmolight", "huePort", 20123); hueReconnectDelay = reader.GetValueAsInt("atmolight", "hueReconnectDelay", 10000); hueReconnectAttempts = reader.GetValueAsInt("atmolight", "hueReconnectAttempts", 5); hueBridgeEnableOnResume = reader.GetValueAsBool("atmolight", "hueBridgeEnableOnResume", false); hueBridgeDisableOnSuspend = reader.GetValueAsBool("atmolight", "hueBridgeDisableOnSuspend", false); hueTheaterEnabled = reader.GetValueAsBool("atmolight", "hueTheaterEnabled", false); hueTheaterRestoreLights = reader.GetValueAsBool("atmolight", "hueTheaterRestoreLights", false); boblightIP = reader.GetValueAsString("atmolight", "boblightIP", "127.0.0.1"); boblightPort = reader.GetValueAsInt("atmolight", "boblightPort", 19333); boblightMaxFPS = reader.GetValueAsInt("atmolight", "boblightMaxFPS", 10); boblightMaxReconnectAttempts = reader.GetValueAsInt("atmolight", "boblightMaxReconnectAttempts", 5); boblightReconnectDelay = reader.GetValueAsInt("atmolight", "boblightReconnectDelay", 5000); boblightSpeed = reader.GetValueAsInt("atmolight", "boblightSpeed", 100); boblightAutospeed = reader.GetValueAsInt("atmolight", "boblightAutospeed", 0); boblightInterpolation = reader.GetValueAsBool("atmolight", "boblightInterpolation", true); boblightSaturation = reader.GetValueAsInt("atmolight", "boblightSaturation", 1); boblightValue = reader.GetValueAsInt("atmolight", "boblightValue", 1); boblightThreshold = reader.GetValueAsInt("atmolight", "boblightThreshold", 20); boblightGamma = Double.Parse(reader.GetValueAsString("atmolight", "boblightGamma", "2.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoWinTarget = reader.GetValueAsBool("atmolight", "atmoWinTarget", true); boblightTarget = reader.GetValueAsBool("atmolight", "boblightTarget", false); hueTarget = reader.GetValueAsBool("atmolight", "hueTarget", false); hyperionTarget = reader.GetValueAsBool("atmolight", "hyperionTarget", false); blackbarDetectionThreshold = reader.GetValueAsInt("atmolight", "blackbarDetectionThreshold", 20); powerModeChangedDelay = reader.GetValueAsInt("atmolight", "powerModeChangedDelay", 5000); ambiBoxTarget = reader.GetValueAsBool("atmolight", "ambiBoxTarget", false); ambiBoxIP = reader.GetValueAsString("atmolight", "ambiBoxIP", "127.0.0.1"); ambiBoxPort = reader.GetValueAsInt("atmolight", "ambiBoxPort", 3636); ambiBoxMaxReconnectAttempts = reader.GetValueAsInt("atmolight", "ambiBoxMaxReconnectAttempts", 5); ambiBoxReconnectDelay = reader.GetValueAsInt("atmolight", "ambiBoxReconnectDelay", 5000); ambiBoxMediaPortalProfile = reader.GetValueAsString("atmolight", "ambiBoxMediaPortalProfile", "MediaPortal"); ambiBoxExternalProfile = reader.GetValueAsString("atmolight", "ambiBoxExternalProfile", "External"); ambiBoxPath = reader.GetValueAsString("atmolight", "ambiBoxPath", "C:\\Program Files (x86)\\AmbiBox\\AmbiBox.exe"); ambiBoxAutoStart = reader.GetValueAsBool("atmolight", "ambiBoxAutoStart", false); ambiBoxAutoStop = reader.GetValueAsBool("atmolight", "ambiBoxAutoStop", false); atmoOrbTarget = reader.GetValueAsBool("atmolight", "atmoOrbTarget", false); atmoOrbBlackThreshold = reader.GetValueAsInt("atmolight", "atmoOrbBlackThreshold", 16); atmoOrbBroadcastPort = reader.GetValueAsInt("atmolight", "atmoOrbBroadcastPort", 49692); atmoOrbGamma = Double.Parse(reader.GetValueAsString("atmolight", "atmoOrbGamma", "1").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoOrbMinDiversion = reader.GetValueAsInt("atmolight", "atmoOrbMinDiversion", 16); atmoOrbSaturation = Double.Parse(reader.GetValueAsString("atmolight", "atmoOrbSaturation", "0.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); atmoOrbThreshold = reader.GetValueAsInt("atmolight", "atmoOrbThreshold", 0); atmoOrbUseOverallLightness = reader.GetValueAsBool("atmolight", "atmoOrbUseOverallLightness", true); string atmoOrbLampTemp = reader.GetValueAsString("atmolight", "atmoOrbLamps", ""); string[] atmoOrbLampTempSplit = atmoOrbLampTemp.Split('|'); for (int i = 0; i < atmoOrbLampTempSplit.Length; i++) { if (!string.IsNullOrEmpty(atmoOrbLampTempSplit[i])) { atmoOrbLamps.Add(atmoOrbLampTempSplit[i]); } } vuMeterMindB = reader.GetValueAsInt("atmolight", "vuMeterMindB", -24); vuMeterMinHue = Double.Parse(reader.GetValueAsString("atmolight", "vuMeterMinHue", "0,74999").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); vuMeterMaxHue = Double.Parse(reader.GetValueAsString("atmolight", "vuMeterMaxHue", "0,95833").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); hueThreshold = reader.GetValueAsInt("atmolight", "hueThreshold", 16); hueBlackThreshold = reader.GetValueAsInt("atmolight", "hueBlackThreshold", 16); hueMinDiversion = reader.GetValueAsInt("atmolight", "hueMinDiversion", 16); hueSaturation = Double.Parse(reader.GetValueAsString("atmolight", "hueSaturation", "0.2").Replace(",", "."), CultureInfo.InvariantCulture.NumberFormat); hueUseOverallLightness = reader.GetValueAsBool("atmolight", "hueUseOverallLightness", true); blackbarDetectionHorizontal = reader.GetValueAsBool("atmolight", "blackbarDetectionHorizontal", true); blackbarDetectionVertical = reader.GetValueAsBool("atmolight", "blackbarDetectionVertical", true); blackbarDetectionLinkAreas = reader.GetValueAsBool("atmolight", "blackbarDetectionLinkAreas", true); remoteApiServer = reader.GetValueAsBool("atmolight", "remoteApiServer", false); } }
private static void initLogger() { // backup the current log file and clear for the new one try { FileInfo logFile = new FileInfo(Config.GetFile(Config.Dir.Log, logFileName)); if (logFile.Exists) { if (File.Exists(Config.GetFile(Config.Dir.Log, oldLogFileName))) { File.Delete(Config.GetFile(Config.Dir.Log, oldLogFileName)); } logFile.CopyTo(Config.GetFile(Config.Dir.Log, oldLogFileName)); logFile.Delete(); } } catch (Exception) { } // if no configuration exists go ahead and create one if (LogManager.Configuration == null) { LogManager.Configuration = new LoggingConfiguration(); } // build the logging target for moving pics logging FileTarget movPicsLogTarget = new FileTarget(); movPicsLogTarget.Name = "moving-pictures"; movPicsLogTarget.FileName = Config.GetFile(Config.Dir.Log, logFileName); movPicsLogTarget.Layout = "${date:format=dd-MMM-yyyy HH\\:mm\\:ss} " + "${level:fixedLength=true:padding=5} " + "[${logger:fixedLength=true:padding=20:shortName=true}]: ${message} " + "${exception:format=tostring}"; LogManager.Configuration.AddTarget("moving-pictures", movPicsLogTarget); // Get current Log Level from MediaPortal LogLevel logLevel; MediaPortal.Profile.Settings xmlreader = MediaPortalSettings; switch ((Level)xmlreader.GetValueAsInt("general", "loglevel", 0)) { case Level.Error: logLevel = LogLevel.Error; break; case Level.Warning: logLevel = LogLevel.Warn; break; case Level.Information: logLevel = LogLevel.Info; break; case Level.Debug: default: logLevel = LogLevel.Debug; break; } #if DEBUG logLevel = LogLevel.Debug; #endif // set the logging rules for moving pics logging LoggingRule movPicsRule = new LoggingRule("MediaPortal.Plugins.MovingPictures.*", logLevel, movPicsLogTarget); LoggingRule cornerstoneRule = new LoggingRule("Cornerstone.*", logLevel, movPicsLogTarget); LogManager.Configuration.LoggingRules.Add(movPicsRule); LogManager.Configuration.LoggingRules.Add(cornerstoneRule); // force NLog to reload the configuration data LogManager.Configuration = LogManager.Configuration; }