Exemplo n.º 1
0
 public static void SaveSpecificSetting(string Setting, String Value)
 {
     using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml")))
     {
         reader.SetValue("atmolight", Setting, Value);
     }
 }
Exemplo n.º 2
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")))
            {
                // 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 SaveSpecificSetting(string setting, String value)
 {
     using (
         MediaPortal.Profile.Settings reader =
             new MediaPortal.Profile.Settings(
                 MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml")))
     {
         reader.SetValue("HyperionScreenCapture", setting, value);
     }
 }
Exemplo n.º 4
0
        public static DateTime LoadTimeSetting(MediaPortal.Profile.Settings reader, string name, string defaultTime)
        {
            string   s = reader.GetValueAsString("atmolight", name, defaultTime);
            DateTime dt;

            if (!DateTime.TryParse(s, out dt))
            {
                dt = DateTime.Parse(defaultTime);
            }
            return(dt);
        }
Exemplo n.º 5
0
 public static void LoadSpecificSetting(string setting, String value)
 {
     using (
         MediaPortal.Profile.Settings reader =
             new MediaPortal.Profile.Settings(
                 MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml")))
     {
         value = reader.GetValueAsString("AudioSwitcher", setting, "");
         reader.SetValue("AudioSwitcher", setting, value);
     }
 }
 public static void SaveSettings()
 {
     using (
         MediaPortal.Profile.Settings reader =
             new MediaPortal.Profile.Settings(
                 MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml")))
     {
         reader.SetValueAsBool("HyperionScreenCapture", "disableOnStart", DisableOnStart);
         reader.SetValueAsBool("HyperionScreenCapture", "onlyEnableWithMadVr", OnlyEnableWithMadVr);
         reader.SetValue("HyperionScreenCapture", "remoteToggleKey", RemoteToggleKey);
         reader.SetValue("HyperionScreenCapture", "apiPort", ApiPort);
     }
 }
 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);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Save changed vars to mediaportal settings file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetupForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                UInt16 portCheck = UInt16.Parse(textBoxPort.Text);
                if (portCheck == 0)
                {
                    resetPort();
                }
            }
            catch (Exception)
            {
                resetPort();
            }

            using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
            {
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "port", textBoxPort.Text);
                xmlwriter.SetValueAsBool(WifiRemote.PLUGIN_NAME, "disableBonjour", checkBoxDisableBonjour.Checked);
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "serviceName", textBoxName.Text);
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "username", WifiRemote.EncryptString(txtUsername.Text));
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "password", WifiRemote.EncryptString(txtPassword.Text));
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "passcode", WifiRemote.EncryptString(txtPasscode.Text));
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "auth", cbAuthMethod.SelectedIndex);
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "autologinTimeout", numericUpDownAutologin.Value);
                xmlwriter.SetValueAsBool(WifiRemote.PLUGIN_NAME, "showNotifications", checkBoxShowConnectionMessage.Checked);
                // Save plugins order, custom names and if they should be displayed
                List <string> pluginIdsToSave = new List <String>();

                foreach (WindowPlugin plugin in pluginsDataSource)
                {
                    pluginIdsToSave.Add(plugin.WindowId.ToString());
                    pluginIdsToSave.Add(plugin.Name);

                    // Don't display plugin
                    if (!plugin.DisplayPlugin && !ignoredPluginsList.Contains(plugin.WindowId))
                    {
                        // Plugin disabled, add to ignored plugins list
                        ignoredPluginsList.Add(plugin.WindowId);
                    }
                    else if (plugin.DisplayPlugin && ignoredPluginsList.Contains(plugin.WindowId))
                    {
                        // Plugin not disabled but on disabled list. Remove it.
                        ignoredPluginsList.Remove(plugin.WindowId);
                    }
                }
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "savedPlugins", String.Join("|", pluginIdsToSave.ToArray()));
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "ignoredPlugins", String.Join("|", ignoredPluginsList.ConvertAll <string>(x => x.ToString()).ToArray()));
            }
        }
Exemplo n.º 9
0
 public static void SaveToConfigFile()
 {
     Ares.Settings.Settings settings = Ares.Settings.Settings.Instance;
     using (MediaPortal.Profile.Settings writer = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "aresplugin.xml")))
     {
         String projectFile = settings.RecentFiles.GetFiles().Count > 0 ? settings.RecentFiles.GetFiles()[0].FilePath : "";
         writer.SetValue("Files", "ProjectFile", projectFile);
         writer.SetValue("Directories", "SoundsDirectory", settings.SoundDirectory);
         writer.SetValue("Directories", "MusicDirectory", settings.MusicDirectory);
         writer.SetValue("Network", "UDPPort", settings.UdpPort);
         writer.SetValue("Network", "TCPPort", settings.TcpPort);
         writer.SetValue("Network", "IPAddress", settings.IPAddress);
         writer.SetValue("Volume", "Global", settings.GlobalVolume);
         writer.SetValue("Volume", "Music", settings.MusicVolume);
         writer.SetValue("Volume", "Sounds", settings.SoundVolume);
         writer.SetValue("Files", "LocalPlayerPath", settings.LocalPlayerPath);
     }
 }
Exemplo n.º 10
0
        public static void SaveSettings()
        {
            using (
                MediaPortal.Profile.Settings reader =
                    new MediaPortal.Profile.Settings(
                        MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml")))
            {
                reader.SetValue("AudioSwitcher", "remoteKeyDialogContextMenu", RemoteKeyDialogContextMenu);
                reader.SetValue("AudioSwitcher", "defaultPlaybackDevice", DefaultPlaybackDevice);

                reader.SetValueAsBool("AudioSwitcher", "LAVbitstreamAlwaysShowToggleInContextMenu", LAVbitstreamAlwaysShowToggleInContextMenu);
                reader.SetValueAsBool("AudioSwitcher", "LAVbitstreamPerDevice", LAVbitstreamPerDevice);
                reader.SetValue("AudioSwitcher", "LAVbitstreamPropertyList", LAVbitstreamPropertyList);

                reader.SetValueAsBool("AudioSwitcher", "LAVaudioDelayControlsInContextMenu", LAVaudioDelayControlsInContextMenu);
                reader.SetValueAsBool("AudioSwitcher", "LAVaudioDelayEnabled", LAVaudioDelayEnabled);
                reader.SetValue("AudioSwitcher", "LAVaudioDelay", LAVaudioDelay);
            }
        }
Exemplo n.º 11
0
        private string CreateTemporaryConfiguration()
        {
            string tempSettingsFilename = Path.Combine(_tempDir, "MediaPortalTemp.xml");

            // check if Mediaportal has been configured, if not start configuration.exe in wizard mode
            var fi = new FileInfo(MPSettings.ConfigPathName);

            if (!File.Exists(MPSettings.ConfigPathName) || (fi.Length < 10000))
            {
                MessageBox.Show(Resources.MediaPortal_has_never_been_configured, Resources.Configuration_not_found, MessageBoxButtons.OK, MessageBoxIcon.Error);
                try
                {
                    var process = new Process
                    {
                        StartInfo = new ProcessStartInfo
                        {
                            FileName  = Config.GetFile(Config.Dir.Base, "configuration.exe"),
                            Arguments = @"/wizard"
                        }
                    };
                    process.Start();
                    process.WaitForExit();
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch {}
                // ReSharper restore EmptyGeneralCatchClause
            }

            try
            {
                File.Copy(MPSettings.ConfigPathName, tempSettingsFilename, true);
                using (var xmlreader = new Settings(tempSettingsFilename, false))
                {
                    xmlreader.SetValue("general", "loglevel", 3);
                }
            }
            catch (Exception)
            {
                File.Delete(tempSettingsFilename);
                throw;
            }
            return(tempSettingsFilename);
        }
Exemplo n.º 12
0
 private void btSave_Click(object sender, System.EventArgs e)
 {
     using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings("MediaPortal.xml"))
     {
         xmlwriter.SetValue("myLyrics", "useDefaultSitesMode", rdDefault.Checked.ToString());
         xmlwriter.SetValue("myLyrics", "defaultSitesModeValue", trackBar.Value);
         xmlwriter.SetValue("myLyrics", "limit", tbLimit.Text);
         xmlwriter.SetValue("myLyrics", "pluginsName", tbPluginName.Text);
         xmlwriter.SetValue("myLyrics", "useLyricWiki", cbLyricWiki.Checked.ToString());
         xmlwriter.SetValue("myLyrics", "useEvilLabs", cbEvilLabs.Checked.ToString());
         xmlwriter.SetValue("myLyrics", "useLyrics007", cbLyrics007.Checked.ToString());
         xmlwriter.SetValue("myLyrics", "useLyricsOnDemand", cbLyricsOnDemand.Checked.ToString());
         xmlwriter.SetValue("myLyrics", "useSeekLyrics", cbSeekLyrics.Checked.ToString());
         xmlwriter.SetValue("myLyrics", "useHotLyrics", cbHotLyrics.Checked.ToString());
         xmlwriter.SetValueAsBool("myLyrics", "automaticFetch", cbAutoFetch.Checked);
         xmlwriter.SetValueAsBool("myLyrics", "automaticUpdateWhenFirstFound", cbAutomaticUpdate.Checked);
         xmlwriter.SetValueAsBool("myLyrics", "moveLyricFromMarkedDatabase", cbMoveSongFrom.Checked);
     }
 }
Exemplo n.º 13
0
 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)
     {
     }
 }
Exemplo n.º 14
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")))
      {
        // 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);
      }
    }
Exemplo n.º 15
0
        /// <summary>
        /// Save changed vars to mediaportal settings file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetupForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                UInt16 portCheck = UInt16.Parse(textBoxPort.Text);
                if (portCheck == 0)
                {
                    resetPort();
                }
            }
            catch (Exception)
            {
                resetPort();
            }

            using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
            {
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "port", textBoxPort.Text);
                xmlwriter.SetValueAsBool(WifiRemote.PLUGIN_NAME, "disableBonjour", checkBoxDisableBonjour.Checked);
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "serviceName", textBoxName.Text);
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "username", WifiRemote.EncryptString(txtUsername.Text));
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "password", WifiRemote.EncryptString(txtPassword.Text));
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "passcode", WifiRemote.EncryptString(txtPasscode.Text));
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "auth", cbAuthMethod.SelectedIndex);
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "autologinTimeout", numericUpDownAutologin.Value);
                xmlwriter.SetValueAsBool(WifiRemote.PLUGIN_NAME, "showNotifications", checkBoxShowConnectionMessage.Checked);
                // Save plugins order, custom names and if they should be displayed
                List<string> pluginIdsToSave = new List<String>();

                foreach (WindowPlugin plugin in pluginsDataSource)
                {
                    pluginIdsToSave.Add(plugin.WindowId.ToString());
                    pluginIdsToSave.Add(plugin.Name);

                    // Don't display plugin
                    if (!plugin.DisplayPlugin && !ignoredPluginsList.Contains(plugin.WindowId))
                    {
                        // Plugin disabled, add to ignored plugins list
                        ignoredPluginsList.Add(plugin.WindowId);
                    }
                    else if (plugin.DisplayPlugin && ignoredPluginsList.Contains(plugin.WindowId))
                    {
                        // Plugin not disabled but on disabled list. Remove it.
                        ignoredPluginsList.Remove(plugin.WindowId);
                    }
                }
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "savedPlugins", String.Join("|", pluginIdsToSave.ToArray()));
                xmlwriter.SetValue(WifiRemote.PLUGIN_NAME, "ignoredPlugins", String.Join("|", ignoredPluginsList.ConvertAll<string>(x => x.ToString()).ToArray()));
            }
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        private void frmAvalonEditor_Load(object sender, EventArgs e)
        {
            LoadWindowPlugins();

            configDir = Config.GetFolder(Config.Dir.Base);

            string configDirXML = ReadConfig(configDir);
            //Log.Info("Avalon plugin: Skindir is " + configDirXML);
            configDir = configDirXML;

            // Check to see if Avalon is the selected skin (halt plugin if not)
            using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Base, "MediaPortalDirs.xml")))
            {
                myskin = "Avalon";
            }

            if (configDir == null)
                return;

            // Check to see if Avalon is the selected skin (halt plugin if not)
            using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
            {
                myskin = "Avalon";
            }

            musicViews = GetMusicViews();
            cboParameterViews.Items.Clear();
            theMusicViews.Clear();

            foreach (KeyValuePair<string, string> mvv in musicViews)
            {
                theMusicViews.Add(mvv.Value);
            }

            cboParameterViews.Visible = false;
            lblParameter.Visible = false;
            cB_onlinevideosOption.Visible = false;
            movPicsCategoryCombo.Visible = false;
            groupBox5.Visible = false;

            string filename = Path.Combine(Path.Combine(SkinInfo.mpPaths.pluginPath, "windows"), "MP-TVSeries.dll");
            if (AvalonHelper.IsAssemblyAvailable("MP-TVSeries", new Version(2, 6, 5, 1265), filename))
            {
                tvseriesViews = GetTVSeriesViews();

                cboParameterViews.Items.Clear();
                theTVSeriesViews.Clear();

                foreach (KeyValuePair<string, string> tvv in tvseriesViews)
                {
                    theTVSeriesViews.Add(tvv.Value);
                    //cboParameterViews.Items.Add(tvv.Value);
                }

            }

            filename = Path.Combine(Path.Combine(SkinInfo.mpPaths.pluginPath, "windows\\OnlineVideos"), "OnlineVideos.dll");
            if (AvalonHelper.IsAssemblyAvailable("OnlineVideos", new Version(0, 27, 0, 0), filename))
            {
                onlineVideosViews = GetOnlineVideosViews();

                cboParameterViews.Items.Clear();
                theOnlineVideosViews.Clear();

                foreach (KeyValuePair<string, string> ovv in onlineVideosViews)
                {
                    theOnlineVideosViews.Add(ovv.Value);
                }
            }

            filename = Path.Combine(Path.Combine(SkinInfo.mpPaths.pluginPath, "windows"), "MovingPictures.dll");
            if (AvalonHelper.IsAssemblyAvailable("MovingPictures", new Version(1, 1, 0, 0), filename))
            {
                // load categories
                LoadMovingPicturesCategories();
            }

            path = configDir + "\\" + myskin;
            if (System.IO.Directory.Exists(path))
            {

                WP_Path = configDir + "\\" + myskin + "\\Media\\BasicHomeBG";
                if (System.IO.Directory.Exists(WP_Path))
                {
                    string[] fileEntries = System.IO.Directory.GetFiles(WP_Path);
                    int count = 0;
                    foreach (string file in fileEntries)
                    {
                        fileEntries[count] = System.IO.Path.GetFileName(file);
                        count++;
                    }
                    new_bgimage.Items.AddRange(fileEntries);

                    //Log.Info("Avalon plugin: Path " + path + " found");
                    if (loadIDs(true) == true)
                    {
                        avail_list.Enabled = true;
                        //Enable whatever needs to be enabled...
                    }
                }
            }
            else
            {
                Log.Info("Avalon plugin: Path " + path + " not found");
            }

            if (loadMenuIDs(true) == true)
            {
                used_list.Enabled = true;
                used_list_submenu.Enabled = true;
                //Enable whatever needs to be enabled...
            }
        }
Exemplo n.º 19
0
        // Save settings to file
        private void btSave_Click(object sender, EventArgs e)
        {
            using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "Avalon.xml")))
            {
                if (configloaded)
                {
                    int a = 0;
                    do
                    {
                      xmlwriter.RemoveEntry("AvalonBasicHome", "menuItemName" + a);
                      xmlwriter.RemoveEntry("AvalonBasicHome", "menuItemHyperlink" + a);
                        xmlwriter.RemoveEntry("AvalonBasicHome", "AvalonBasicHomeSubmenu" + a);
                        xmlwriter.RemoveEntry("AvalonBasicHome", "menuItemBgImage" + a);
                        xmlwriter.RemoveEntry("AvalonBasicHome", "menuItemParameter" + a);
                        xmlwriter.RemoveEntry("AvalonBasicHome", "menuItemRecentMedia" + a);

                        int b = 0;
                        do
                        {
                            xmlwriter.RemoveEntry("AvalonBasicHomeSubmenu" + a, "submenuItemName" + b);
                            xmlwriter.RemoveEntry("AvalonBasicHomeSubmenu" + a, "submenuItemHyperlink" + b);
                            xmlwriter.RemoveEntry("AvalonBasicHomeSubmenu" + a, "submenuItemBgImage" + b);
                            xmlwriter.RemoveEntry("AvalonBasicHomeSubmenu" + a, "submenuItemParameter" + b);
                            xmlwriter.RemoveEntry("AvalonBasicHomeSubmenu" + a, "submenuItemRecentMedia" + b);
                            b++;
                        } while (b < 250);

                        a++;
                    } while (a < 25);
                }

                int mycount = 0;
                //menuItems.Sort(delegate(menuItem li1, menuItem li2) { return li1.identifier.CompareTo(li2.identifier); });

                foreach (menuItem item in menuItems)
                {
                    xmlwriter.SetValue("AvalonBasicHome", "menuItemName" + mycount, item.name);
                    xmlwriter.SetValue("AvalonBasicHome", "menuItemHyperlink" + mycount, item.hyperlink);
                    if (item.bgImage != string.Empty)
                    {
                      xmlwriter.SetValue("AvalonBasicHome", "menuItemBgImage" + mycount, item.bgImage);
                    }
                    if (item.property != string.Empty)
                    {
                      xmlwriter.SetValue("AvalonBasicHome", "menuItemParameter" + mycount, item.property);
                    }
                    if (item.media != string.Empty)
                    {
                      xmlwriter.SetValue("AvalonBasicHome", "menuItemRecentMedia" + mycount, item.media);
                    }

                    int mycount2 = 0;
                    foreach (Child mychild in singleChildren)
                    {
                        if (item.identifier == mychild.Owner)
                        {
                            xmlwriter.SetValue("AvalonBasicHomeSubmenu" + mycount, "submenuItemName" + mycount2, mychild.Name);
                            xmlwriter.SetValue("AvalonBasicHomeSubmenu" + mycount, "submenuItemHyperlink" + mycount2, mychild.Hyperlink);
                            if (mychild.property != string.Empty)
                            {
                              xmlwriter.SetValue("AvalonBasicHomeSubmenu" + mycount, "submenuItemParameter" + mycount2, mychild.property);
                            }
                            mycount2++;
                        }
                    }
                    mycount++;
                }

            }

            this.Close();
        }
Exemplo n.º 20
0
        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();
        }
Exemplo n.º 21
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")))
            {
                // 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);
            }
        }
Exemplo n.º 22
0
        public static void SaveSettings()
        {
            using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml")))
            {
                reader.SetValue("atmolight", "atmowinexe", atmowinExe);
                reader.SetValue("atmolight", "effectVideo", effectVideo.ToString());
                reader.SetValue("atmolight", "effectMusic", effectMusic.ToString());
                reader.SetValue("atmolight", "effectRadio", effectRadio.ToString());
                reader.SetValue("atmolight", "effectMenu", effectMenu.ToString());
                reader.SetValue("atmolight", "effectMPExit", effectMPExit.ToString());
                reader.SetValue("atmolight", "killbutton", (int)killButton);
                reader.SetValue("atmolight", "cmbutton", (int)profileButton);
                reader.SetValue("atmolight", "menubutton", (int)menuButton);
                reader.SetValueAsBool("atmolight", "OffOnStart", manualMode);
                reader.SetValueAsBool("atmolight", "SBS_3D_ON", sbs3dOn);
                reader.SetValueAsBool("atmolight", "lowCPU", lowCPU);
                reader.SetValue("atmolight", "lowCPUTime", lowCPUTime);
                reader.SetValueAsBool("atmolight", "Delay", delay);
                reader.SetValue("atmolight", "DelayTime", delayReferenceTime);
                reader.SetValue("atmolight", "DelayRefreshRate", delayReferenceRefreshRate);
                reader.SetValue("atmolight", "DelayTime23", delayReferenceTime23);
                reader.SetValue("atmolight", "DelayTime24", delayReferenceTime24);
                reader.SetValue("atmolight", "DelayTime50", delayReferenceTime50);
                reader.SetValue("atmolight", "DelayTime59", delayReferenceTime59);
                reader.SetValueAsBool("atmolight", "ExitAtmoWin", exitAtmoWin);
                reader.SetValueAsBool("atmolight", "StartAtmoWin", startAtmoWin);
                reader.SetValueAsBool("atmolight", "atmoWakeHelperEnabled", atmoWakeHelperEnabled);
                reader.SetValue("atmolight", "atmoWakeHelperComPort", atmoWakeHelperComPort);
                reader.SetValue("atmolight", "atmoWakeHelperResumeDelay", atmoWakeHelperResumeDelay);
                reader.SetValue("atmolight", "atmoWakeHelperDisconnectDelay", atmoWakeHelperDisconnectDelay);
                reader.SetValue("atmolight", "atmoWakeHelperConnectDelay", atmoWakeHelperConnectDelay);
                reader.SetValue("atmolight", "atmoWakeHelperReinitializationDelay", atmoWakeHelperReinitializationDelay);
                reader.SetValue("atmolight", "excludeTimeStart", excludeTimeStart.ToString("HH:mm"));
                reader.SetValue("atmolight", "excludeTimeEnd", excludeTimeEnd.ToString("HH:mm"));
                reader.SetValue("atmolight", "currentLanguage", currentLanguage);
                reader.RemoveEntry("atmolight", "currentLanguageFile");
                reader.SetValue("atmolight", "StaticColorRed", staticColorRed);
                reader.SetValue("atmolight", "StaticColorGreen", staticColorGreen);
                reader.SetValue("atmolight", "StaticColorBlue", staticColorBlue);
                reader.SetValueAsBool("atmolight", "RestartOnError", restartOnError);
                reader.SetValueAsBool("atmolight", "TrueGrabbing", trueGrabbing);
                reader.SetValueAsBool("atmolight", "BlackbarDetection", blackbarDetection);
                reader.SetValue("atmolight", "BlackbarDetectionTime", blackbarDetectionTime);
                reader.SetValue("atmolight", "GIFFile", gifFile);
                reader.SetValue("atmolight", "captureWidth", (int)captureWidth);
                reader.SetValue("atmolight", "captureHeight", (int)captureHeight);
                reader.SetValueAsBool("atmolight", "monitorScreensaverState", monitorScreensaverState);
                reader.SetValueAsBool("atmolight", "monitorWindowState", monitorWindowState);
                reader.SetValue("atmolight", "hyperionIP", hyperionIP);
                reader.SetValue("atmolight", "hyperionPort", (int)hyperionPort);
                reader.SetValue("atmolight", "hyperionPriority", (int)hyperionPriority);
                reader.SetValue("atmolight", "hyperionReconnectDelay", (int)hyperionReconnectDelay);
                reader.SetValue("atmolight", "hyperionReconnectAttempts", (int)hyperionReconnectAttempts);
                reader.SetValue("atmolight", "hyperionStaticColorPriority", (int)hyperionPriorityStaticColor);
                reader.SetValueAsBool("atmolight", "hyperionLiveReconnect", hyperionLiveReconnect);
                reader.SetValue("atmolight", "hueExe", hueExe);
                reader.SetValueAsBool("atmolight", "hueStart", hueStart);
                reader.SetValueAsBool("atmolight", "hueIsRemoteMachine", hueIsRemoteMachine);
                reader.SetValue("atmolight", "hueIP", hueIP);
                reader.SetValue("atmolight", "huePort", (int)huePort);
                reader.SetValue("atmolight", "hueReconnectDelay", (int)hueReconnectDelay);
                reader.SetValue("atmolight", "hueReconnectAttempts", (int)hueReconnectAttempts);
                reader.SetValueAsBool("atmolight", "hueBridgeEnableOnResume", hueBridgeEnableOnResume);
                reader.SetValueAsBool("atmolight", "hueBridgeDisableOnSuspend", hueBridgeDisableOnSuspend);
                reader.SetValueAsBool("atmolight", "hueTheaterEnabled", hueTheaterEnabled);
                reader.SetValueAsBool("atmolight", "hueTheaterRestoreLights", hueTheaterRestoreLights);
                reader.SetValueAsBool("atmolight", "hueTheaterEnabledVU", hueTheaterEnabledVU);
                reader.SetValue("atmolight", "boblightIP", boblightIP);
                reader.SetValue("atmolight", "boblightPort", boblightPort);
                reader.SetValue("atmolight", "boblightMaxFPS", boblightMaxFPS);
                reader.SetValue("atmolight", "boblightMaxReconnectAttempts", boblightMaxReconnectAttempts);
                reader.SetValue("atmolight", "boblightReconnectDelay", boblightReconnectDelay);
                reader.SetValue("atmolight", "boblightSpeed", boblightSpeed);
                reader.SetValue("atmolight", "boblightAutospeed", boblightAutospeed);
                reader.SetValue("atmolight", "boblightSaturation", boblightSaturation);
                reader.SetValue("atmolight", "boblightValue", boblightValue);
                reader.SetValue("atmolight", "boblightThreshold", boblightThreshold);
                reader.SetValueAsBool("atmolight", "boblightInterpolation", boblightInterpolation);
                reader.SetValue("atmolight", "boblightGamma", boblightGamma.ToString());
                reader.SetValue("atmolight", "blackbarDetectionThreshold", blackbarDetectionThreshold.ToString());
                reader.SetValue("atmolight", "powerModeChangedDelay", powerModeChangedDelay.ToString());
                reader.SetValue("atmolight", "ambiBoxIP", ambiBoxIP.ToString());
                reader.SetValue("atmolight", "ambiBoxPort", ambiBoxPort.ToString());
                reader.SetValue("atmolight", "ambiBoxMaxReconnectAttempts", ambiBoxMaxReconnectAttempts.ToString());
                reader.SetValue("atmolight", "ambiBoxReconnectDelay", ambiBoxReconnectDelay.ToString());
                reader.SetValue("atmolight", "ambiBoxChangeImageDelay", ambiBoxChangeImageDelay.ToString());
                reader.SetValue("atmolight", "ambiBoxMediaPortalProfile", ambiBoxMediaPortalProfile.ToString());
                reader.SetValue("atmolight", "ambiBoxExternalProfile", ambiBoxExternalProfile.ToString());
                reader.SetValue("atmolight", "ambiBoxPath", ambiBoxPath.ToString());
                reader.SetValueAsBool("atmolight", "ambiBoxAutoStart", ambiBoxAutoStart);
                reader.SetValueAsBool("atmolight", "ambiBoxAutoStop", ambiBoxAutoStop);
                reader.SetValue("atmolight", "vuMeterMindB", vuMeterMindB.ToString());
                reader.SetValue("atmolight", "vuMeterMinHue", vuMeterMinHue.ToString());
                reader.SetValue("atmolight", "vuMeterMaxHue", vuMeterMaxHue.ToString());
                reader.SetValueAsBool("atmolight", "atmoWinTarget", atmoWinTarget);
                reader.SetValueAsBool("atmolight", "boblightTarget", boblightTarget);
                reader.SetValueAsBool("atmolight", "hueTarget", hueTarget);
                reader.SetValueAsBool("atmolight", "hyperionTarget", hyperionTarget);
                reader.SetValueAsBool("atmolight", "ambiBoxTarget", ambiBoxTarget);
                reader.SetValueAsBool("atmolight", "atmoOrbTarget", atmoOrbTarget);
                reader.SetValue("atmolight", "atmoOrbBlackThreshold", atmoOrbBlackThreshold.ToString());
                reader.SetValue("atmolight", "atmoOrbBroadcastPort", atmoOrbBroadcastPort.ToString());
                reader.SetValue("atmolight", "atmoOrbGamma", atmoOrbGamma.ToString());
                reader.SetValue("atmolight", "atmoOrbMinDiversion", atmoOrbMinDiversion.ToString());
                reader.SetValue("atmolight", "atmoOrbSaturation", atmoOrbSaturation.ToString());
                reader.SetValue("atmolight", "atmoOrbThreshold", atmoOrbThreshold.ToString());
                reader.SetValueAsBool("atmolight", "atmoOrbUseOverallLightness", atmoOrbUseOverallLightness);
                reader.SetValueAsBool("atmolight", "atmoOrbUseSmoothing", atmoOrbUseSmoothing);
                reader.SetValue("atmolight", "atmoOrbSmoothingThreshold", atmoOrbSmoothingThreshold.ToString());

                string atmoOrbLampsTemp = "";
                for (int i = 0; i < atmoOrbLamps.Count; i++)
                {
                    if (i > 0)
                    {
                        atmoOrbLampsTemp += "|";
                    }
                    atmoOrbLampsTemp += atmoOrbLamps[i];
                }
                reader.SetValue("atmolight", "atmoOrbLamps", atmoOrbLampsTemp);
                reader.SetValue("atmolight", "hueMinDiversion", hueMinDiversion.ToString());
                reader.SetValue("atmolight", "hueThreshold", hueThreshold.ToString());
                reader.SetValue("atmolight", "hueBlackThreshold", hueBlackThreshold.ToString());
                reader.SetValue("atmolight", "hueSaturation", hueSaturation.ToString());
                reader.SetValueAsBool("atmolight", "hueUseOverallLightness", hueUseOverallLightness);
                reader.SetValueAsBool("atmolight", "blackbarDetectionHorizontal", blackbarDetectionHorizontal);
                reader.SetValueAsBool("atmolight", "blackbarDetectionVertical", blackbarDetectionVertical);
                reader.SetValueAsBool("atmolight", "blackbarDetectionLinkAreas", blackbarDetectionLinkAreas);
                reader.SetValueAsBool("atmolight", "remoteApiServer", remoteApiServer);
                reader.SetValueAsBool("atmolight", "doNotShowConnectionErrorsDuringPlayback", doNotShowConnectionErrorsDuringPlayback);
            }
        }
Exemplo n.º 23
0
 public static void SaveSettings()
 {
   using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml")))
   {
     reader.SetValue("atmolight", "atmowinexe", atmowinExe);
     reader.SetValue("atmolight", "effectVideo", effectVideo.ToString());
     reader.SetValue("atmolight", "effectMusic", effectMusic.ToString());
     reader.SetValue("atmolight", "effectRadio", effectRadio.ToString());
     reader.SetValue("atmolight", "effectMenu", effectMenu.ToString());
     reader.SetValue("atmolight", "effectMPExit", effectMPExit.ToString());
     reader.SetValue("atmolight", "killbutton", (int)killButton);
     reader.SetValue("atmolight", "cmbutton", (int)profileButton);
     reader.SetValue("atmolight", "menubutton", (int)menuButton);
     reader.SetValueAsBool("atmolight", "OffOnStart", manualMode);
     reader.SetValueAsBool("atmolight", "SBS_3D_ON", sbs3dOn);
     reader.SetValueAsBool("atmolight", "lowCPU", lowCPU);
     reader.SetValue("atmolight", "lowCPUTime", lowCPUTime);
     reader.SetValueAsBool("atmolight", "Delay", delay);
     reader.SetValue("atmolight", "DelayTime", delayReferenceTime);
     reader.SetValueAsBool("atmolight", "ExitAtmoWin", exitAtmoWin);
     reader.SetValueAsBool("atmolight", "StartAtmoWin", startAtmoWin);
     reader.SetValueAsBool("atmolight", "atmoWakeHelperEnabled", atmoWakeHelperEnabled);
     reader.SetValue("atmolight", "atmoWakeHelperComPort", atmoWakeHelperComPort);
     reader.SetValue("atmolight", "atmoWakeHelperResumeDelay", atmoWakeHelperResumeDelay);
     reader.SetValue("atmolight", "atmoWakeHelperDisconnectDelay", atmoWakeHelperDisconnectDelay);
     reader.SetValue("atmolight", "atmoWakeHelperConnectDelay", atmoWakeHelperConnectDelay);
     reader.SetValue("atmolight", "atmoWakeHelperReinitializationDelay", atmoWakeHelperReinitializationDelay);
     reader.SetValue("atmolight", "excludeTimeStart", excludeTimeStart.ToString("HH:mm"));
     reader.SetValue("atmolight", "excludeTimeEnd", excludeTimeEnd.ToString("HH:mm"));
     reader.SetValue("atmolight", "CurrentLanguageFile", currentLanguageFile);
     reader.SetValue("atmolight", "StaticColorRed", staticColorRed);
     reader.SetValue("atmolight", "StaticColorGreen", staticColorGreen);
     reader.SetValue("atmolight", "StaticColorBlue", staticColorBlue);
     reader.SetValueAsBool("atmolight", "RestartOnError", restartOnError);
     reader.SetValueAsBool("atmolight", "TrueGrabbing", trueGrabbing);
     reader.SetValue("atmolight", "DelayRefreshRate", delayReferenceRefreshRate);
     reader.SetValueAsBool("atmolight", "BlackbarDetection", blackbarDetection);
     reader.SetValue("atmolight", "BlackbarDetectionTime", blackbarDetectionTime);
     reader.SetValue("atmolight", "GIFFile", gifFile);
     reader.SetValue("atmolight", "captureWidth", (int)captureWidth);
     reader.SetValue("atmolight", "captureHeight", (int)captureHeight);
     reader.SetValueAsBool("atmolight", "monitorScreensaverState", monitorScreensaverState);
     reader.SetValueAsBool("atmolight", "monitorWindowState", monitorWindowState);
     reader.SetValue("atmolight", "hyperionIP", hyperionIP);
     reader.SetValue("atmolight", "hyperionPort", (int)hyperionPort);
     reader.SetValue("atmolight", "hyperionPriority", (int)hyperionPriority);
     reader.SetValue("atmolight", "hyperionReconnectDelay", (int)hyperionReconnectDelay);
     reader.SetValue("atmolight", "hyperionReconnectAttempts", (int)hyperionReconnectAttempts);
     reader.SetValue("atmolight", "hyperionStaticColorPriority", (int)hyperionPriorityStaticColor);
     reader.SetValueAsBool("atmolight", "hyperionLiveReconnect", hyperionLiveReconnect);
     reader.SetValue("atmolight", "hueExe", hueExe);
     reader.SetValueAsBool("atmolight", "hueStart", hueStart);
     reader.SetValueAsBool("atmolight", "hueIsRemoteMachine", hueIsRemoteMachine);
     reader.SetValue("atmolight", "hueIP", hueIP);
     reader.SetValue("atmolight", "huePort", (int)huePort);
     reader.SetValue("atmolight", "hueReconnectDelay", (int)hueReconnectDelay);
     reader.SetValue("atmolight", "hueReconnectAttempts", (int)hueReconnectAttempts);
     reader.SetValueAsBool("atmolight", "hueBridgeEnableOnResume", hueBridgeEnableOnResume);
     reader.SetValueAsBool("atmolight", "hueBridgeDisableOnSuspend", hueBridgeDisableOnSuspend);
     reader.SetValueAsBool("atmolight", "hueTheaterEnabled", hueTheaterEnabled);
     reader.SetValueAsBool("atmolight", "hueTheaterRestoreLights", hueTheaterRestoreLights);
     reader.SetValue("atmolight", "boblightIP", boblightIP);
     reader.SetValue("atmolight", "boblightPort", boblightPort);
     reader.SetValue("atmolight", "boblightMaxFPS", boblightMaxFPS);
     reader.SetValue("atmolight", "boblightMaxReconnectAttempts", boblightMaxReconnectAttempts);
     reader.SetValue("atmolight", "boblightReconnectDelay", boblightReconnectDelay);
     reader.SetValue("atmolight", "boblightSpeed", boblightSpeed);
     reader.SetValue("atmolight", "boblightAutospeed", boblightAutospeed);
     reader.SetValue("atmolight", "boblightSaturation", boblightSaturation);
     reader.SetValue("atmolight", "boblightValue", boblightValue);
     reader.SetValue("atmolight", "boblightThreshold", boblightThreshold);
     reader.SetValueAsBool("atmolight", "boblightInterpolation", boblightInterpolation);
     reader.SetValue("atmolight", "boblightGamma", boblightGamma.ToString());
     reader.SetValue("atmolight", "blackbarDetectionThreshold", blackbarDetectionThreshold.ToString());
     reader.SetValue("atmolight", "powerModeChangedDelay", powerModeChangedDelay.ToString());
     reader.SetValue("atmolight", "ambiBoxIP", ambiBoxIP.ToString());
     reader.SetValue("atmolight", "ambiBoxPort", ambiBoxPort.ToString());
     reader.SetValue("atmolight", "ambiBoxMaxReconnectAttempts", ambiBoxMaxReconnectAttempts.ToString());
     reader.SetValue("atmolight", "ambiBoxReconnectDelay", ambiBoxReconnectDelay.ToString());
     reader.SetValue("atmolight", "ambiBoxMediaPortalProfile", ambiBoxMediaPortalProfile.ToString());
     reader.SetValue("atmolight", "ambiBoxExternalProfile", ambiBoxExternalProfile.ToString());
     reader.SetValue("atmolight", "ambiBoxPath", ambiBoxPath.ToString());
     reader.SetValueAsBool("atmolight", "ambiBoxAutoStart", ambiBoxAutoStart);
     reader.SetValueAsBool("atmolight", "ambiBoxAutoStop", ambiBoxAutoStop);
     reader.SetValue("atmolight", "vuMeterMindB", vuMeterMindB.ToString());
     reader.SetValue("atmolight", "vuMeterMinHue", vuMeterMinHue.ToString());
     reader.SetValue("atmolight", "vuMeterMaxHue", vuMeterMaxHue.ToString());
     reader.SetValueAsBool("atmolight", "atmoWinTarget", atmoWinTarget);
     reader.SetValueAsBool("atmolight", "boblightTarget", boblightTarget);
     reader.SetValueAsBool("atmolight", "hueTarget", hueTarget);
     reader.SetValueAsBool("atmolight", "hyperionTarget", hyperionTarget);
     reader.SetValueAsBool("atmolight", "ambiBoxTarget", ambiBoxTarget);
     reader.SetValueAsBool("atmolight", "atmoOrbTarget", atmoOrbTarget);
     reader.SetValue("atmolight", "atmoOrbBlackThreshold", atmoOrbBlackThreshold.ToString());
     reader.SetValue("atmolight", "atmoOrbBroadcastPort", atmoOrbBroadcastPort.ToString());
     reader.SetValue("atmolight", "atmoOrbGamma", atmoOrbGamma.ToString());
     reader.SetValue("atmolight", "atmoOrbMinDiversion", atmoOrbMinDiversion.ToString());
     reader.SetValue("atmolight", "atmoOrbSaturation", atmoOrbSaturation.ToString());
     reader.SetValue("atmolight", "atmoOrbThreshold", atmoOrbThreshold.ToString());
     reader.SetValueAsBool("atmolight", "atmoOrbUseOverallLightness", atmoOrbUseOverallLightness);
     string atmoOrbLampsTemp = "";
     for (int i = 0; i < atmoOrbLamps.Count; i++)
     {
       if (i > 0)
       {
         atmoOrbLampsTemp += "|";
       }
       atmoOrbLampsTemp += atmoOrbLamps[i];
     }
     reader.SetValue("atmolight", "atmoOrbLamps", atmoOrbLampsTemp);
     reader.SetValue("atmolight", "hueMinDiversion", hueMinDiversion.ToString());
     reader.SetValue("atmolight", "hueThreshold", hueThreshold.ToString());
     reader.SetValue("atmolight", "hueBlackThreshold", hueBlackThreshold.ToString());
     reader.SetValue("atmolight", "hueSaturation", hueSaturation.ToString());
     reader.SetValueAsBool("atmolight", "hueUseOverallLightness", hueUseOverallLightness);
     reader.SetValueAsBool("atmolight", "blackbarDetectionHorizontal", blackbarDetectionHorizontal);
     reader.SetValueAsBool("atmolight", "blackbarDetectionVertical", blackbarDetectionVertical);
     reader.SetValueAsBool("atmolight", "blackbarDetectionLinkAreas", blackbarDetectionLinkAreas);
     reader.SetValueAsBool("atmolight", "remoteApiServer", remoteApiServer);
   }
 }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 25
0
 protected override void OnPageDestroy(int newWindowId)
 {
   LogMyFilms.Debug("MyFilmsDetail.OnPageDestroy(" + newWindowId.ToString() + ") started.");
   if (MyFilms.conf.PersonsEnableDownloads)
   {
     if (downloadingWorker.IsBusy) downloadingWorker.CancelAsync();
     // while (downloadingWorker.IsBusy) System.Windows.Forms.Application.DoEvents();
     // downloadingWorker = null;
     downloadingWorker.ProgressChanged -= new ProgressChangedEventHandler(downloadingWorker_ProgressChanged);
   }
   if (Configuration.CurrentConfig != "")
     Configuration.SaveConfiguration(Configuration.CurrentConfig, MyFilms.conf.StrIndex, MyFilms.conf.StrTIndex);
   using (var xmlreader = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
   {
     string currentmoduleid = "7986";
     bool currentmodulefullscreen = (GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_TVFULLSCREEN || GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_MUSIC || GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO || GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_TELETEXT);
     string currentmodulefullscreenstate = GUIPropertyManager.GetProperty("#currentmodulefullscreenstate");
     // if MP was closed/hibernated by the use of remote control, we have to retrieve the fullscreen state in an alternative manner.
     if (!currentmodulefullscreen && currentmodulefullscreenstate == "True")
       currentmodulefullscreen = true;
     xmlreader.SetValue("general", "lastactivemodule", currentmoduleid);
     xmlreader.SetValueAsBool("general", "lastactivemodulefullscreen", currentmodulefullscreen);
     LogMyFilms.Debug("SaveLastActiveModule - module {0}", currentmoduleid);
     LogMyFilms.Debug("SaveLastActiveModule - fullscreen {0}", currentmodulefullscreen);
   }
   LogMyFilms.Debug("MyFilms.OnPageDestroy(" + newWindowId + ") completed.");
   base.OnPageDestroy(newWindowId);
 }
Exemplo n.º 26
0
        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;
        }
Exemplo n.º 27
0
 public static void SaveSpecificSetting(string Setting, String Value)
 {
   using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml")))
   {
     reader.SetValue("atmolight", Setting, Value);
   }
 }
Exemplo n.º 28
0
    private string CreateTemporaryConfiguration()
    {
      string tempSettingsFilename = Path.Combine(_tempDir, "MediaPortalTemp.xml");

      // check if Mediaportal has been configured, if not start configuration.exe in wizard mode
      var fi = new FileInfo(MPSettings.ConfigPathName);
      if (!File.Exists(MPSettings.ConfigPathName) || (fi.Length < 10000))
      {
        MessageBox.Show(Resources.MediaPortal_has_never_been_configured, Resources.Configuration_not_found, MessageBoxButtons.OK, MessageBoxIcon.Error);
        try
        {
          var process = new Process
                          {
                            StartInfo = new ProcessStartInfo
                                          {
                                            FileName = Config.GetFile(Config.Dir.Base, "configuration.exe"),
                                            Arguments = @"/wizard"
                                          }
                          };
          process.Start();
          process.WaitForExit();
        }
        // ReSharper disable EmptyGeneralCatchClause
        catch {}
        // ReSharper restore EmptyGeneralCatchClause
      }

      try
      {
        File.Copy(MPSettings.ConfigPathName, tempSettingsFilename, true);
        using (var xmlreader = new Settings(tempSettingsFilename, false))
        {
          xmlreader.SetValue("general", "loglevel", 3);
        }
      }
      catch (Exception)
      {
        File.Delete(tempSettingsFilename);
        throw;
      }
      return tempSettingsFilename;
    }
Exemplo n.º 29
0
        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;
        }