Example #1
0
        private void ButtonSlap_Click(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Shift)
            {
                _restart = false;
            }

            int totalCheckedItems = checkedListBoxTweaks.CheckedItems.Count + checkedListBoxSoftware.CheckedItems.Count + checkedListBoxAdvanced.CheckedItems.Count + checkedListBoxAppearance.CheckedItems.Count;

            if (totalCheckedItems == 0)
            {
                string caption      = "Notice";
                string errorMessage = "No items selected.";
                MessageBox.Show(errorMessage, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!ShowDisclaimer())
            {
                return;
            }

            Hide();
            SlapForm = new SlapForm();
            SlapForm.Show();

            backgroundWorker1.RunWorkerAsync(300); //300 gives a total of 3 seconds pause
        }
Example #2
0
        private void ButtonSlap_Click(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Shift)
            {
                _restart = false;
            }

            int totalCheckedItems;

            if (Globals.winmajor == "11")
            {
                totalCheckedItems = checkedListBoxWin11Tweaks.CheckedItems.Count + checkedListBoxWin11Software.CheckedItems.Count + checkedListBoxWin11Advanced.CheckedItems.Count + checkedListBoxWin11Appearance.CheckedItems.Count;
            }
            else
            {
                totalCheckedItems = checkedListBoxWin10Tweaks.CheckedItems.Count + checkedListBoxWin10Software.CheckedItems.Count + checkedListBoxWin10Advanced.CheckedItems.Count + checkedListBoxWin10Appearance.CheckedItems.Count;
            }

            if (totalCheckedItems == 0)
            {
                string caption      = "Notice";
                string errorMessage = "No items selected.";
                MessageBox.Show(errorMessage, caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!ShowDisclaimer())
            {
                return;
            }

            Hide();
            SlapForm = new SlapForm();
            SlapForm.Show();

            backgroundWorker1.RunWorkerAsync(300); //300 gives a total of 3 seconds pause

            if (checkedListBoxWin10Software.CheckedItems.Count != 0 || checkedListBoxWin11Software.CheckedItems.Count != 0)
            {
                Process          process1   = new Process();
                ProcessStartInfo startInfo1 = new ProcessStartInfo();
                startInfo1.WindowStyle = ProcessWindowStyle.Hidden;
                startInfo1.FileName    = "cmd.exe";
                startInfo1.Arguments   = "/C where winget";
                process1.StartInfo     = startInfo1;
                process1.Start();
                process1.WaitForExit();
                if (process1.ExitCode != 0)
                {
                    Slapper.InstallWinGet();
                }

                Process          process2   = new Process();
                ProcessStartInfo startInfo2 = new ProcessStartInfo();
                startInfo2.WindowStyle            = ProcessWindowStyle.Hidden;
                startInfo2.FileName               = "cmd.exe";
                startInfo2.Arguments              = "/C winget --version";
                startInfo2.UseShellExecute        = false;
                startInfo2.RedirectStandardOutput = true;
                process2.StartInfo = startInfo2;
                process2.Start();
                string output2 = process2.StandardOutput.ReadToEnd();
                process2.WaitForExit();
                if (output2.Contains("v1.0") || output2.Contains("v1.1") || output2.Contains("v1.2"))
                {
                    Slapper.InstallWinGet();
                }
            }
        }