Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        public void Start()
        {
            //  If the application GUI shouldn't be loaded
            if (_preventGUILaunch)
            {
                return;
            }

            using (ProcessLock processLock = new ProcessLock(configMutex))
            {
                if (processLock.AlreadyExists)
                {
                    Log.Warn("Main: Configuration is already running");
                    Win32API.ActivatePreviousInstance();
                }

                // Check for a MediaPortal Instance running and don't allow Configuration to start
                using (ProcessLock mpLock = new ProcessLock(mpMutex))
                {
                    if (mpLock.AlreadyExists)
                    {
                        DialogResult dialogResult = MessageBox.Show(
                            "MediaPortal has to be closed for configuration.\nClose MediaPortal and start Configuration?",
                            "MediaPortal", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        if (dialogResult == DialogResult.Yes)
                        {
                            Util.Utils.KillProcess("Watchdog");
                            Util.Utils.KillProcess("MediaPortal");
                            Log.Info("MediaPortal closed, continue running Configuration.");
                        }
                        else
                        {
                            Log.Warn("Main: MediaPortal is running - start of Configuration aborted");
                            return;
                        }
                    }
                }

                string MpConfig = Assembly.GetExecutingAssembly().Location;
#if !DEBUG
                // Check TvPlugin version
                string tvPlugin = Config.GetFolder(Config.Dir.Plugins) + "\\Windows\\TvPlugin.dll";
                if (File.Exists(tvPlugin) && !_avoidVersionChecking)
                {
                    string tvPluginVersion = FileVersionInfo.GetVersionInfo(tvPlugin).ProductVersion;
                    string CfgVersion      = FileVersionInfo.GetVersionInfo(MpConfig).ProductVersion;
                    if (CfgVersion != tvPluginVersion)
                    {
                        string strLine = "TvPlugin and MediaPortal don't have the same version.\r\n";
                        strLine += "Please update the older component to the same version as the newer one.\r\n";
                        strLine += "MpConfig Version: " + CfgVersion + "\r\n";
                        strLine += "TvPlugin Version: " + tvPluginVersion;
                        MessageBox.Show(strLine, "MediaPortal", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Log.Info(strLine);
                        return;
                    }
                }
#endif

                FileInfo mpFi = new FileInfo(MpConfig);
                Log.Info("Assembly creation time: {0} (UTC)", mpFi.LastWriteTimeUtc.ToUniversalTime());

                Form applicationForm = null;

                Thumbs.CreateFolders();

                switch (startupMode)
                {
                case StartupMode.Normal:
                    Log.Info("Create new standard setup");
                    applicationForm = new SettingsForm(_debugOptions);
                    break;
                }

                if (applicationForm != null)
                {
                    Log.Info("start application");
                    Application.Run(applicationForm);
                }
            }
        }
Exemplo n.º 2
0
    /// <summary>
    /// 
    /// </summary>
    public void Start()
    {
      //  If the application GUI shouldn't be loaded
      if (_preventGUILaunch)
        return;

      using (ProcessLock processLock = new ProcessLock(configMutex))
      {
        if (processLock.AlreadyExists)
        {
          Log.Warn("Main: Configuration is already running");
          Win32API.ActivatePreviousInstance();
        }

        // Check for a MediaPortal Instance running and don't allow Configuration to start
        using (ProcessLock mpLock = new ProcessLock(mpMutex))
        {
          if (mpLock.AlreadyExists)
          {
            DialogResult dialogResult = MessageBox.Show(
              "MediaPortal has to be closed for configuration.\nClose MediaPortal and start Configuration?",
              "MediaPortal", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Yes)
            {
              Util.Utils.KillProcess("Watchdog");
              Util.Utils.KillProcess("MediaPortal");
              Log.Info("MediaPortal closed, continue running Configuration.");
            }
            else
            {
              Log.Warn("Main: MediaPortal is running - start of Configuration aborted");
              return;
            }
          }
        }

        string MpConfig = Assembly.GetExecutingAssembly().Location;
#if !DEBUG
  // Check TvPlugin version
        string tvPlugin = Config.GetFolder(Config.Dir.Plugins) + "\\Windows\\TvPlugin.dll";
        if (File.Exists(tvPlugin) && !_avoidVersionChecking)
        {
          string tvPluginVersion = FileVersionInfo.GetVersionInfo(tvPlugin).ProductVersion;
          string CfgVersion = FileVersionInfo.GetVersionInfo(MpConfig).ProductVersion;
          if (CfgVersion != tvPluginVersion)
          {
            string strLine = "TvPlugin and MediaPortal don't have the same version.\r\n";
            strLine += "Please update the older component to the same version as the newer one.\r\n";
            strLine += "MpConfig Version: " + CfgVersion + "\r\n";
            strLine += "TvPlugin Version: " + tvPluginVersion;
            MessageBox.Show(strLine, "MediaPortal", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Log.Info(strLine);
            return;
          }
        }
#endif

        FileInfo mpFi = new FileInfo(MpConfig);
        Log.Info("Assembly creation time: {0} (UTC)", mpFi.LastWriteTimeUtc.ToUniversalTime());

        Form applicationForm = null;

        Thumbs.CreateFolders();

        switch (startupMode)
        {
          case StartupMode.Normal:
            Log.Info("Create new standard setup");
            applicationForm = new SettingsForm(_debugOptions);
            break;
        }

        if (applicationForm != null)
        {
          Log.Info("start application");
          Application.Run(applicationForm);
        }
      }
    }