Beispiel #1
0
        private void btnUnlock_Click(object sender, EventArgs e)
        {
            // Sets progress bar to green
            ModifyProgressBarColor.SetState(pbUnlocker, 1);

            if (isAlreadyRunning)
            {
                return;
            }
            else
            {
                isAlreadyRunning = true;

                pbUnlocker.Value = 0;

                if (tbFilePath.Text == "No file selected")
                {
                    return;
                }
                ;


                var saveDialog = new SaveFileDialog
                {
                    Title  = "Save unlocked file",
                    Filter = "Excel Workbook (*.xlsx)|*.xlsx|All files (*.*)|*.*"
                };
                saveDialog.ShowDialog();

                if (saveDialog.FileName == "")
                {
                    return;
                }

                Progress <int> progressBar = new Progress <int>();
                Progress <int> consoleProg = new Progress <int>();
                progressBar.ProgressChanged += (p, value) => pbUnlocker.Value = value;
                consoleProg.ProgressChanged += (p, value) => UpdateConsole(value, saveDialog.FileName);
                Task.Run(() => (UnlockClass.Unlock(saveDialog.FileName, tbFilePath.Text, cbOverwrite.Checked, cbUnlockVBA.Checked, cblRemoveVeryHidden.Checked, progressBar, consoleProg)));


                rtbConsole.Text       = "";
                btnChooseFile.Enabled = false;
                cbOverwrite.Enabled   = false;
                bwProgress.RunWorkerAsync();
                bwProgress.WorkerReportsProgress = true;

                btnChooseFile.Enabled = true;
                cbOverwrite.Enabled   = true;
                ScrollToBottomOfMessages();
                isAlreadyRunning = false;
            }
        }
Beispiel #2
0
        private void btnUnlock_Click(object sender, EventArgs e)
        {
            // Sets progress bar to green
            ModifyProgressBarColor.SetState(pbUnlocker, 1);

            if (isAlreadyRunning)
            {
                return;
            }
            else
            {
                isAlreadyRunning = true;

                pbUnlocker.Value = 0;

                if (tbFilePath.Text == "No file selected")
                {
                    return;
                }
                ;


                Progress <int> progressBar = new Progress <int>();
                Progress <int> consoleProg = new Progress <int>();
                progressBar.ProgressChanged += (p, value) => pbUnlocker.Value = value;
                consoleProg.ProgressChanged += (p, value) => UpdateConsole(value);
                Task.Run(() => (UnlockClass.Unlock(tbFilePath.Text, cbOverwrite.Checked, cbUnlockVBA.Checked, progressBar, consoleProg)));


                rtbConsole.Text       = "";
                btnChooseFile.Enabled = false;
                cbOverwrite.Enabled   = false;
                bwProgress.RunWorkerAsync();
                bwProgress.WorkerReportsProgress = true;

                btnChooseFile.Enabled = true;
                cbOverwrite.Enabled   = true;
                ScrollToBottomOfMessages();
                isAlreadyRunning = false;
            }
        }