示例#1
0
        private void OnStartup()
        {
            // start the splashscreen
            string version = ConfigurationManager.AppSettings["version"];

            splashScreen.Version = version;
            splashScreen.Run();
            Log.Info("SettingsForm constructor");
            // Required for Windows Form Designer support
            InitializeComponent();
            this.linkLabel1.Links.Add(0, linkLabel1.Text.Length, "http://www.team-mediaportal.com/donate.html");
            // Build options tree
            if (splashScreen != null)
            {
                splashScreen.SetInformation("Loading language...");
            }
            string strLanguage;

            using (Settings xmlreader = new MPSettings())
            {
                strLanguage   = xmlreader.GetValueAsString("gui", "language", "English");
                hintShowCount = xmlreader.GetValueAsInt("general", "ConfigModeHintCount", 0);

                if (splashScreen != null)
                {
                    splashScreen.SetInformation("Loading config options...");
                }
                CheckModeHintDisplay(hintShowCount);
                // The initial hint allows to choose a mode so we need to ask before loading that setting
                advancedMode = xmlreader.GetValueAsBool("general", "AdvancedConfigMode", false);
            }
            toolStripButtonSwitchAdvanced.Text    = AdvancedMode ? "Switch to standard mode" : "Switch to expert mode";
            toolStripButtonSwitchAdvanced.Checked = AdvancedMode;
            GUILocalizeStrings.Load(strLanguage);
            // Register Bass.Net
            BassRegistration.BassRegistration.Register();
            Log.Info("add project section");
            if (splashScreen != null)
            {
                splashScreen.SetInformation("Adding project section...");
            }
            Project project = new Project();

            AddSection(new ConfigPage(null, project, false));

            AddTabGeneral();
            AddTabGui();
            AddTabMovies();
            AddTabBD();
            AddTabDvd();
            AddTabTelevision();
            AddTabMusic();
            AddTabPictures();
            AddTabRemote();
            AddTabFilters();
            //Mantis 3772 - Weather.com API is not free any more
            //temporarily disable plugin
            //AddTabWeather();
            AddTabPlugins();
            AddTabThirdPartyChecks();

            // reset the last used state
            ToggleSectionVisibility(advancedMode);

            // Select first item in the section tree
            if (sectionTree.Nodes.Count > 0)
            {
                sectionTree.SelectedNode = sectionTree.Nodes[0];
            }

            if (splashScreen != null)
            {
                splashScreen.Stop(1000);
                splashScreen = null;
                BackgroundWorker FrontWorker = new BackgroundWorker();
                FrontWorker.DoWork += new DoWorkEventHandler(Worker_BringConfigToForeground);
                FrontWorker.RunWorkerAsync();
            }

            Log.Info("settingsform constructor done");
            GUIGraphicsContext.Skin = Config.GetFile(Config.Dir.Skin, "Default", string.Empty);
            Log.Info("SKIN : " + GUIGraphicsContext.Skin);
        }
示例#2
0
        public Startup(string[] arguments)
        {
            Thread.CurrentThread.Name     = "Config Main";
            Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;

            // Logger should write into Configuration.log
            Log.SetConfigurationMode();
            Log.BackupLogFile(LogType.Config);

            FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath);

            Log.Info("Configuration v" + versionInfo.FileVersion + " is starting up on " + OSInfo.OSInfo.GetOSDisplayVersion());
#if DEBUG
            Log.Info("Debug build: " + Application.ProductVersion);
#else
            Log.Info("Build: " + Application.ProductVersion);
#endif

            //Check for unsupported operating systems
            OSPrerequisites.OSPrerequisites.OsCheck(true);

            Log.Info("Verifying DirectX 9");
            if (!DirectXCheck.IsInstalled())
            {
                string strLine = "Please install a newer DirectX 9.0c redist!\r\n";
                strLine = strLine + "MediaPortal cannot run without DirectX 9.0c redist (August 2008)\r\n";
                strLine = strLine + "http://install.team-mediaportal.com/DirectX";
                MessageBox.Show(strLine, "MediaPortal", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Log.Info("Using Directories:");
            foreach (string options in Enum.GetNames(typeof(Config.Dir)))
            {
                Log.Info("{0} - {1}", options, Config.GetFolder((Config.Dir)Enum.Parse(typeof(Config.Dir), options)));
            }

            // rtv: disabled Wizard due to frequent bug reports on serveral sections.
            // please fix those before re-enabling.
            //
            //if (!File.Exists(Config.GetFile(Config.Dir.Config, "mediaportal.xml")))
            //  startupMode = StartupMode.Wizard;
            //else
            if (arguments != null)
            {
                foreach (string argument in arguments)
                {
                    string trimmedArgument = argument.ToLowerInvariant();

                    if (trimmedArgument.StartsWith("/wizard"))
                    {
                        //startupMode = StartupMode.Wizard;
                        //Log.Debug("Startup: Argument did request Wizard mode - {0}", trimmedArgument);
                        Log.Warn("Startup: Wizard mode invoked but currently disabled: argument ignored!");
                    }

                    if (trimmedArgument.StartsWith("/section"))
                    {
                        string[] subArguments = argument.Split('=');

                        if (subArguments.Length >= 2)
                        {
                            sectionsConfiguration = subArguments[1];
                        }
                    }

                    //  deploymode used to upgrade the configuration files
                    if (trimmedArgument == "--deploymode")
                    {
                        Log.Info("Running in deploy mode - upgrading config file");

                        try
                        {
                            ISettingsProvider mpConfig = new XmlSettingsProvider(MPSettings.ConfigPathName);
                            SettingsUpgradeManager.Instance.UpgradeToLatest(mpConfig);
                            SettingsUpgradeManager.Instance.ApplyDeploySettingUpgrade(mpConfig);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Unhandled exception when upgrading config file '" + MPSettings.ConfigPathName + "'\r\n\r\n" + ex.ToString());
                        }
                        finally
                        {
                            _preventGUILaunch = true;
                        }
                    }

                    if (trimmedArgument == "/debugoptions")
                    {
                        _debugOptions = true;
                    }

                    if (trimmedArgument.ToLowerInvariant() == "/avoidversioncheck")
                    {
                        _avoidVersionChecking = true;
                        Log.Warn("Version check is disabled by command line switch \"/avoidVersionCheck\"");
                    }
                }
            }

            // we are not in deploy mode but there is not mediaportal.xml file
            // create one and apply any updates from deploy.xml
            if (!_preventGUILaunch && !File.Exists(Config.GetFile(Config.Dir.Config, "mediaportal.xml")))
            {
                Log.Info("mediaportal.xml does not exist.   Creating a new file and applying deploy tool parameters");
                SettingsUpgradeManager.Instance.ApplyDeploySetting();
            }
        }