public SteamDepotFile[] GetFiles(InstallOptions installOptions) { if (installOptions == null) throw new ArgumentNullException("installOptions"); SteamDepotFileTypes filesType = installOptions.FilesType; if (filesType != SteamDepotFileTypes.None) { return FilesMap.GetFiles(filesType, installOptions.ApplicationCulture); } else return null; }
/// <summary> /// Installs application using specified installation options. /// </summary> /// <param name="application">SteamApplication object.</param> /// <param name="installOptions">InstallOptions object.</param> /// <param name="filesSize">Size of files for installation. Method calculate this size if parameter equals to -1.</param> /// <param name="worker">BackgroundWorker object.</param> /// <returns>Size of installed files.</returns> private Int64 InstallApplication(SteamApplication application, InstallOptions installOptions, Int64 filesSize, BackgroundWorker worker) { Int64 copiedFilesSize = 0L; if (installOptions.FilesType != SteamDepotFileTypes.None) { SteamDepotFile[] files = application.GetFiles(installOptions); if (files != null) { DirectoryInfo destDirectory = new DirectoryInfo(installOptions.InstallPath); if (filesSize == -1L) filesSize = application.GetFilesSize(application, installOptions); foreach (SteamDepotFile file in files) { if (worker.CancellationPending) break; copiedFilesSize += SgiUtils.CopyFile(file, Path.Combine(destDirectory.FullName, file.RelativeName), filesSize, copiedFilesSize, worker); } } } if (filesSize == 0L) worker.ReportProgress(100); return copiedFilesSize; }
private void ShowApplicationSize(Boolean isRecalculate) { if (isRecalculate) { #if JIT Object options = managerAssembly.CreateInstance("SteamGamesInstaller.InstallOptions", false, BindingFlags.CreateInstance, null, new Object[] { steamApplicationsComboBox.Text, installDirectoryTextBox.Text, applicationLanguageComboBox.Text, executeInstallScriptCheckBox.Checked, installApplicationCheckBox.Checked, installFixesCheckBox.Checked }, CultureInfo.InvariantCulture, null); #else Object options = new InstallOptions(steamApplicationsComboBox.Text, installDirectoryTextBox.Text, applicationLanguageComboBox.Text, executeInstallScriptCheckBox.Checked, installApplicationCheckBox.Checked, installFixesCheckBox.Checked); #endif appSize = manager.GetFilesSize(options); } if (!String.IsNullOrEmpty(installDirectoryTextBox.Text) && Directory.Exists(installDirectoryTextBox.Text) && appSize != -1) { DriveInfo drive = GetDrive(installDirectoryTextBox.Text); filesSizeInMbLabel.ForeColor = SystemColors.ControlText; filesSizeInMbLabel.Text = String.Format(CultureInfo.CurrentUICulture, Resources.AppSizeInMbMessage, appSize / 1024 / 1024); freeSpace = drive.AvailableFreeSpace; if (freeSpace <= appSize) { filesSizeInMbLabel.ForeColor = Color.Red; filesSizeInMbLabel.Text += String.Format(CultureInfo.CurrentUICulture, Resources.FreeSpaceMessage, drive.Name, freeSpace / 1024 / 1024); } } else filesSizeInMbLabel.Text = String.Empty; SetInstallButtonState(); }
/// <summary> /// Returns size of application files in bytes for specified installation options. /// </summary> /// <param name="application">SteamApplication object.</param> /// <param name="installOptions">Installation options.</param> /// <returns>Size of application files in bytes for specified installation options.</returns> private Int64 GetFilesSize(SteamApplication application, InstallOptions installOptions) { Int64 size = 0L; if (installOptions.FilesType != SteamDepotFileTypes.None) { SteamDepotFile[] files = application.GetFiles(installOptions); if (files != null) { foreach (SteamDepotFile file in files) size += new FileInfo(file.FullName).Length; } } return size; }
private void installButton_Click(object sender, EventArgs e) { if (!isInstalling) { isInstalling = true; SetInstallButtonState(); SetControlsState(false); toolStripProgressBar.Value = 0; toolStripStatusLabel.Text = String.Format(CultureInfo.InvariantCulture, Resources.InstallProgressMessage, 0); // Sets text to "0 %" worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(InstallApplication); worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged); worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted); worker.WorkerReportsProgress = true; worker.WorkerSupportsCancellation = true; #if JIT Object options = managerAssembly.CreateInstance("SteamGamesInstaller.InstallOptions", false, BindingFlags.CreateInstance, null, new Object[] { steamApplicationsComboBox.Text, installDirectoryTextBox.Text, applicationLanguageComboBox.Text, executeInstallScriptCheckBox.Checked, installApplicationCheckBox.Checked, installFixesCheckBox.Checked }, CultureInfo.InvariantCulture, null); #else Object options = new InstallOptions(steamApplicationsComboBox.Text, installDirectoryTextBox.Text, applicationLanguageComboBox.Text, executeInstallScriptCheckBox.Checked, installApplicationCheckBox.Checked, installFixesCheckBox.Checked); #endif worker.RunWorkerAsync(options); } }