Пример #1
0
        /// <summary>
        /// This button restores the clients Ranked Python files to the original state
        /// </summary>
        private void BF2sRestoreBtn_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(
                    "Restoring the BF2Statistics python files will erase any and all modifications to the BF2Statistics " +
                    "python files. Are you sure you want to continue?",
                    "Confirmation",
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Warning)
                == DialogResult.OK)
            {
                try
                {
                    // Lock the console to prevent errors!
                    this.Enabled = false;
                    if (StatsEnabled)
                    {
                        Directory.Delete(Paths.ServerPythonPath, true);
                        DirectoryExt.Copy(Path.Combine(MainForm.Root, "Python", "Ranked", "Original"), Paths.ServerPythonPath, true);
                    }
                    else
                    {
                        Directory.Delete(Paths.RankedPythonPath, true);
                        DirectoryExt.Copy(Path.Combine(MainForm.Root, "Python", "Ranked", "Original"), Paths.RankedPythonPath, true);
                    }

                    // Show Success Message
                    Notify.Show("Stats Python Files Have Been Restored!", AlertType.Success);
                    this.Enabled = true; // Unlock Form
                }
                catch (Exception E)
                {
                    ExceptionForm EForm = new ExceptionForm(E, false);
                    EForm.Message = "Failed to restore stats python files!";
                    EForm.Show();
                    this.Enabled = true;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// This button restores the clients Ranked Python files to the original state
        /// </summary>
        private void BF2sRestoreBtn_Click(object sender, EventArgs e)
        {
            // Confirm that the user wants to do this
            if (MessageBox.Show(
                    "Restoring the BF2Statistics python files will erase any and all modifications to the BF2Statistics " +
                    "python files. Are you sure you want to continue?",
                    "Confirmation",
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Warning)
                == DialogResult.OK)
            {
                // Lock the console to prevent errors!
                this.Enabled = false;
                LoadingForm.ShowScreen(this);

                // Replace files with the originals
                try
                {
                    if (StatsEnabled)
                    {
                        Directory.Delete(Paths.ServerPythonPath, true);
                        System.Threading.Thread.Sleep(750);
                        DirectoryExt.Copy(Path.Combine(Program.RootPath, "Python", "Ranked", "Original"), Paths.ServerPythonPath, true);
                    }
                    else
                    {
                        Directory.Delete(Paths.RankedPythonPath, true);
                        System.Threading.Thread.Sleep(750);
                        DirectoryExt.Copy(Path.Combine(Program.RootPath, "Python", "Ranked", "Original"), Paths.RankedPythonPath, true);
                    }

                    // Show Success Message
                    Notify.Show("Stats Python Files Have Been Restored!", "Operation Successful", AlertType.Success);
                }
                catch (Exception E)
                {
                    ExceptionForm EForm = new ExceptionForm(E, false);
                    EForm.Message = "Failed to restore stats python files!";
                    EForm.Show();
                }
                finally
                {
                    this.Enabled = true;
                    LoadingForm.CloseForm();
                }
            }
        }