Exemple #1
0
 /// <summary>
 /// Executes the cleanup sequence.
 /// </summary>
 private void PerformCleanup()
 {
     if (CleanDirs.Count > 0)
     {
         GuiHelpers.FormShowCleanup(CleanDirs, Text, AppStrings.PS_CleanupSuccess, BackUpDir, Platform.SteamProcName);
         Close();
     }
     else
     {
         MessageBox.Show(AppStrings.AC_NoItemsSelected, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemple #2
0
        /// <summary>
        /// Finalizes candidates find procedure.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Completion arguments and results.</param>
        private void GttWrk_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // Unlocking ListView...
            CM_FTable.EndUpdate();

            // Showing estimated of free space to be free after removing all found files...
            CM_Info.Text = String.Format(AppStrings.PS_FrFInfo, GuiHelpers.SclBytes(TotalSize));

            // Checking if candidates are found...
            if (CM_FTable.Items.Count == 0)
            {
                // Nothing found. Showing message and closing form...
                MessageBox.Show(AppStrings.PS_LoadErr, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CM_Clean.Enabled = false;
                Close();
            }
            else
            {
                // At least one candidate found. Enabling cleanup button...
                CM_Clean.Enabled = true;
            }
        }
Exemple #3
0
 /// <summary>
 /// "About" menu item click event handler.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">Event arguments.</param>
 private void LV_MenuHelpAbout_Click(object sender, EventArgs e)
 {
     // Show about dialog...
     GuiHelpers.FormShowAboutApp();
 }
Exemple #4
0
 /// <summary>
 /// "About" menu item and button click event handler.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="e">Event arguments.</param>
 private void AboutDlg(object sender, EventArgs e)
 {
     GuiHelpers.FormShowAboutApp();
 }
Exemple #5
0
        /// <summary>
        /// Installs standalone update.
        /// </summary>
        /// <param name="UpdateURL">Full download URL.</param>
        /// <returns>Result of operation.</returns>
        private bool InstallBinaryUpdate(string UpdateURL)
        {
            // Setting default value for result...
            bool Result = false;

            // Generating full paths to files...
            string UpdateFileName = UpdateManager.GenerateUpdateFileName(Path.Combine(AppUpdateDir, Path.GetFileName(UpdateURL)));

            // Downloading update from server...
            GuiHelpers.FormShowDownloader(UpMan.AppUpdateURL, UpdateFileName);

            // Checking if downloaded file exists...
            if (File.Exists(UpdateFileName))
            {
                // Checking hashes...
                if (UpMan.CheckAppHash(FileManager.CalculateFileSHA512(UpdateFileName)))
                {
                    // Setting last update check date...
                    UpdateTimeSetApp();

                    // Showing message about successful download...
                    MessageBox.Show(AppStrings.UPD_UpdateSuccessful, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Installing standalone update...
                    try
                    {
                        // Checking if app's installation directory is writable...
                        if (FileManager.IsDirectoryWritable(FullAppPath))
                        {
                            // Running installer with current access rights...
                            Platform.StartRegularProcess(UpdateFileName);
                        }
                        else
                        {
                            // Running installer with UAC access rights elevation...
                            Platform.StartElevatedProcess(UpdateFileName);
                        }
                        Result = true;
                    }
                    catch (Exception Ex)
                    {
                        MessageBox.Show(AppStrings.UPD_UpdateFailure, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Logger.Error(Ex, DebugStrings.AppDbgExUpdBinInst);
                    }
                }
                else
                {
                    // Hash missmatch. File was damaged. Removing it...
                    try
                    {
                        File.Delete(UpdateFileName);
                    }
                    catch (Exception Ex)
                    {
                        Logger.Warn(Ex);
                    }

                    // Showing message about hash missmatch...
                    MessageBox.Show(AppStrings.UPD_HashFailure, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                // Showing error about update failure...
                MessageBox.Show(AppStrings.UPD_UpdateFailure, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            // Returning result...
            return(Result);
        }
Exemple #6
0
        /// <summary>
        /// "Install" button click event handler.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void BtnInstall_Click(object sender, EventArgs e)
        {
            if (!(String.IsNullOrEmpty(InstallPath.Text)))
            {
                try
                {
                    // Generating full path to destination directory, depending on selected in main window game...
                    string InstallDir = IsUsingUserDir ? Path.Combine(CustomInstallDir, Properties.Settings.Default.UserCustDirName) : FullGamePath;

                    // Using different methods, based on source file extension...
                    switch (Path.GetExtension(InstallPath.Text))
                    {
                    // Installing demo file...
                    case ".dem": InstallFileNow(InstallPath.Text, FullGamePath);
                        break;

                    // Installing VPK package...
                    case ".vpk": InstallFileNow(InstallPath.Text, CustomInstallDir);
                        break;

                    // Installing game config...
                    case ".cfg": InstallFileNow(InstallPath.Text, Path.Combine(InstallDir, "cfg"));
                        break;

                    // Installing map...
                    case ".bsp": InstallFileNow(InstallPath.Text, Path.Combine(InstallDir, "maps"));
                        break;

                    // Installing hitsound...
                    case ".wav": InstallFileNow(InstallPath.Text, Path.Combine(InstallDir, "sound", "ui"));
                        break;

                    // Installing spray...
                    case ".vtf": InstallSprayNow(InstallPath.Text);
                        break;

                    // Installing contents of Zip archive...
                    case ".zip": GuiHelpers.FormShowArchiveExtract(InstallPath.Text, CustomInstallDir);
                        break;

                    // Installing binary plugin...
                    case ".dll": InstallFileNow(InstallPath.Text, Path.Combine(InstallDir, "addons"));
                        break;
                    }

                    // Showing message...
                    MessageBox.Show(AppStrings.QI_InstSuccessfull, PluginName, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    // Closing window...
                    Close();
                }
                catch (Exception Ex)
                {
                    // An error occured. Showing message and writing issue to logs...
                    MessageBox.Show(AppStrings.QI_Excpt, Properties.Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Logger.Error(Ex, DebugStrings.AppDbgExInstRun);
                }
            }
            else
            {
                // User selected nothing. Showing message...
                MessageBox.Show(AppStrings.QI_InstUnav, PluginName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #7
0
        /// <summary>
        /// Gets full list of files for deletion.
        /// </summary>
        /// <param name="CleanDirs">List of files and directories for cleanup.</param>
        /// <param name="Recursive">Enable recursive cleanup.</param>
        private void DetectFilesForCleanup(List <String> CleanDirs, bool Recursive)
        {
            foreach (string DirMs in CleanDirs)
            {
                // Extracting directory path and file mask from combined string...
                string CleanDir  = Path.GetDirectoryName(DirMs);
                string CleanMask = Path.GetFileName(DirMs);

                // Checking if directory exists...
                if (Directory.Exists(CleanDir))
                {
                    try
                    {
                        // Getting full contents of directory and adding them to result...
                        DirectoryInfo DInfo   = new DirectoryInfo(CleanDir);
                        FileInfo[]    DirList = DInfo.GetFiles(CleanMask);
                        foreach (FileInfo DItem in DirList)
                        {
                            ListViewItem LvItem = new ListViewItem(DItem.Name)
                            {
                                Checked     = !NoAutoCheck,
                                ToolTipText = Path.Combine(CleanDir, DItem.Name),
                                SubItems    =
                                {
                                    GuiHelpers.SclBytes(DItem.Length),
                                    DItem.LastWriteTime.ToString()
                                }
                            };

                            // Adding file to main list and incrementing counter...
                            Invoke((MethodInvoker) delegate() { CM_FTable.Items.Add(LvItem); });
                            TotalSize += DItem.Length;
                        }

                        if (Recursive)
                        {
                            try
                            {
                                // Getting subdirectories...
                                List <String> SubDirs = new List <string>();
                                foreach (DirectoryInfo Dir in DInfo.GetDirectories())
                                {
                                    SubDirs.Add(Path.Combine(Dir.FullName, CleanMask));
                                }

                                // If subdirectories exists, run this method recursively...
                                if (SubDirs.Count > 0)
                                {
                                    DetectFilesForCleanup(SubDirs, true);
                                }
                            }
                            catch (Exception Ex)
                            {
                                Logger.Warn(Ex);
                            }
                        }
                    }
                    catch (Exception Ex)
                    {
                        Logger.Warn(Ex);
                    }
                }
            }
        }