示例#1
0
    public DeployTool()
    {
      //Create necessary directory tree
      if (!Directory.Exists(Application.StartupPath + "\\deploy"))
        Directory.CreateDirectory(Application.StartupPath + "\\deploy");

      //Set default folders
      InstallationProperties.Instance.Set("MPDir",
                                          Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) +
                                          "\\Team MediaPortal\\MediaPortal");
      InstallationProperties.Instance.Set("TVServerDir",
                                          Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) +
                                          "\\Team MediaPortal\\MediaPortal TV Server");

      string tmpPrg = Environment.GetEnvironmentVariable("ProgramW6432");
      if (!string.IsNullOrEmpty(tmpPrg))
      {
        InstallationProperties.Instance.Set("ProgramFiles", tmpPrg);
      }
      else
      {
        InstallationProperties.Instance.Set("ProgramFiles", Environment.GetEnvironmentVariable("ProgramFiles"));
      }

      // Paint first screen
      InitializeComponent();
      Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath);
      Localizer.SwitchCulture("en-US");
      UpdateUI();

      // Delete Run registry key
      DialogType firstDlg;
      if (Utils.AutoRunApplication("delete"))
      {
        firstDlg = DialogType.Installation;
        InstallationProperties.Instance.Load();
        Localizer.SwitchCulture(InstallationProperties.Instance["language"]);
        _restart = true;
      }
      else
      {
        firstDlg = DialogType.Welcome;
        Localizer.SwitchCulture("en-US");
        _restart = false;
      }
      _currentDialog = DialogFlowHandler.Instance.GetDialogInstance(firstDlg);
      splitContainer2.Panel1.Controls.Add(_currentDialog);
      InstallationProperties.Instance.Set("InstallTypeHeader", "Choose installation type");
      backButton.Visible = false;
      UpdateUI();
      if (_restart)
      {
        nextButton.Text = Localizer.GetBestTranslation("Install_buttonInstall");
      }
      nextButton.Focus();
    }
示例#2
0
    private void nextButton_Click(object sender, EventArgs e)
    {
      //
      // check Internet connection unless files have already been downloaded
      //
      if (_currentDialog.type == DialogType.DownloadOnly &&
          Directory.GetFiles(Application.StartupPath + "\\deploy").Length < 3)
      {
        if (!InstallationChecks.InternetChecker.CheckConnection())
        {
          MessageBox.Show(Localizer.GetBestTranslation("DownloadOnly_NoConnectionWarning"), "MediaPortal",
                          MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
      }

      // 
      // check if there's is sufficient hard disk space for installation
      // 
      if (_currentDialog.type == DialogType.DBMSSettings || _currentDialog.type == DialogType.TvServerSettings ||
          _currentDialog.type == DialogType.MPSettings)
      {
        // at least 0.5 GB free disk space are required for installation
        const double requiredDiskSpace = 0.5;
        double actualDiskSpace =
          InstallationChecks.DiskSpaceChecker.GetRemainingHardDiskCapacity(_currentDialog.installationPath);

        if (actualDiskSpace < requiredDiskSpace)
        {
          MessageBox.Show(string.Format(Localizer.GetBestTranslation("DiskSpace_Error"), requiredDiskSpace * 1000),
                          "MediaPortal", MessageBoxButtons.OK, MessageBoxIcon.Error);
          return;
        }
      }

      if (nextButton.Text == Localizer.GetBestTranslation("MainWindow_buttonClose"))
      {
        //
        // If in download_only mode, start explorer to show downloaded stuff
        //
        if (InstallationProperties.Instance["InstallType"] == "download_only")
        {
          try
          {
            Process process = new Process();
            process.StartInfo.FileName = "explorer.exe";
            process.StartInfo.Arguments = "/e, " + Application.StartupPath + "\\deploy";
            process.StartInfo.UseShellExecute = true;
            process.Start();
          }
            // Starting processes might fail - prefer a not opening Explorer instead of a big crash window...
          catch (Exception)
          {
          }
        }
        Close();
        return;
      }
      if (nextButton.Text == Localizer.GetBestTranslation("Install_buttonDownload") ||
          nextButton.Text == Localizer.GetBestTranslation("Install_buttonInstall"))
      {
        nextButton.Enabled = false;
      }
      if (!_currentDialog.SettingsValid())
        return;
      _currentDialog.SetProperties();
      if (InstallationProperties.Instance["language"] != _currentCulture)
      {
        _currentCulture = InstallationProperties.Instance["language"];
        Localizer.SwitchCulture(_currentCulture);
        UpdateUI();
      }
      _currentDialog = _currentDialog.GetNextDialog();
      SwitchDialog(_currentDialog);
      if (!backButton.Visible)
        backButton.Visible = true;
      if (InstallationProperties.Instance["finished"] == "yes")
      {
        backButton.Visible = false;
        nextButton.Enabled = true;
        nextButton.Text = Localizer.GetBestTranslation("MainWindow_buttonClose");
      }
      if (!_restart && InstallationProperties.Instance["Install_Dialog"] == "yes")
      {
        nextButton.Text = InstallationProperties.Instance["InstallType"] == "download_only"
                            ? Localizer.GetBestTranslation("Install_buttonDownload")
                            : Localizer.GetBestTranslation("Install_buttonInstall");
        InstallationProperties.Instance.Set("Install_Dialog", "no");
      }
    }
示例#3
0
 private void backButton_Click(object sender, EventArgs e)
 {
   bool isFirstDlg = false;
   _currentDialog = DialogFlowHandler.Instance.GetPreviousDlg(ref isFirstDlg);
   if (isFirstDlg)
     backButton.Visible = false;
   nextButton.Text = Localizer.GetBestTranslation("MainWindow_nextButton");
   SwitchDialog(_currentDialog);
 }
示例#4
0
 private void SwitchDialog(DeployDialog dlg)
 {
   splitContainer2.Panel1.Controls.Clear();
   splitContainer2.Panel1.Controls.Add(dlg);
   dlg.Focus();
   nextButton.Focus();
 }