Exemple #1
0
        private bool UpdateSection(Label label, MetroProgressSpinner spinner, Func<bool> method)
        {
            label.ForeColor = System.Drawing.Color.Black;

            spinner.Invoke((MethodInvoker)(() =>
            {
                spinner.Value = 20;
            }));

            var success = false;
            try
            {
                success = method.Invoke();
            }
            catch (Exception ex)
            {
                logBox.Invoke((MethodInvoker)(() =>
                {
                    logBox.AppendText(ex.Message);
                }));
                success = false;
            }

            spinner.Invoke((MethodInvoker)(() =>
            {
                spinner.Value = 100;
                spinner.ForeColor = (success) ? Color.ForestGreen : Color.Crimson;
            }));

            return success;
        }
Exemple #2
0
        private bool UpdateSection(Label label, MetroProgressSpinner spinner, InstallSection section)
        {
            label.ForeColor = System.Drawing.Color.Black;

            spinner.Invoke((MethodInvoker)(() =>
            {
                spinner.Value = 20;
            }));

            var success = false;
            try
            {
                switch (section)
                {
                    case InstallSection.Prepare:
                        success = Helper.Instance.PrepareFiles();
                        break;
                    case InstallSection.Install:
                        success = Helper.Instance.Install("0", "0",
                            addressTxtBox.Text, webRootTxtBox.Text, "FOG",
                            (logSwitch.Checked) ? "1" : "0");
                        break;
                    case InstallSection.Configure:
                        success = Configure();
                        break;
                    case InstallSection.Secure:
                        success = InstallCerts();
                        break;
                }
            }
            catch (Exception ex)
            {
                logBox.Invoke((MethodInvoker)(() =>
                {
                    logBox.AppendText(ex.Message);
                }));
                success = false;
            }

            spinner.Invoke((MethodInvoker)(() =>
            {
                spinner.Value = 100;
                spinner.ForeColor = (success) ? Color.ForestGreen : Color.Crimson;
            }));

            return success;
        }