コード例 #1
0
        private void StartOperation()
        {
            bool tempRequired = TempRequired();

            if (tempRequired || (!App.IsAdministrator() && Data.Action != SetupData.Actions.Extract))
            {
                if (!App.Restart(Data.MakeArgs(), tempRequired))
                {
                    App.ShowMessage("The setup can not proceed without Administrative permissions.");
                }
                return;
            }

            ShowPanel(Panels.Progress);

            prgress.Value    = 0;
            Worker           = new SetupWorker(Data);
            Worker.Progress += (s, e) =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    if (e.Message != null)
                    {
                        txtProgress.Text += e.Message + "\r\n";

                        txtProgress.Focus();
                        txtProgress.CaretIndex = txtProgress.Text.Length;
                        txtProgress.ScrollToEnd();

                        if (e.Show)
                        {
                            App.ShowMessage(e.Message);
                        }
                    }
                    if (e.Progress >= 0 && e.Progress <= 100)
                    {
                        prgress.Value = e.Progress;
                    }
                });
            };
            Worker.Finished += (s, e) =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    prgress.Value = 100;
                    Worker        = null;
                    Completed     = true;
                    UpdatePanel();
                });
            };
            Worker.Start();
        }
コード例 #2
0
        private void BtnBrowse_Click(object sender, RoutedEventArgs e)
        {
            using (var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog())
            {
                folderBrowserDialog.Description  = "Please select a directory";
                folderBrowserDialog.RootFolder   = Environment.SpecialFolder.MyComputer;
                folderBrowserDialog.SelectedPath = txtInstallDir.Text;
                if (folderBrowserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                if (SetupWorker.IsUnsafePath(folderBrowserDialog.SelectedPath))
                {
                    txtInstallDir.Text = folderBrowserDialog.SelectedPath + @"\" + SetupData.AppKey;
                }
                else
                {
                    txtInstallDir.Text = folderBrowserDialog.SelectedPath;
                }
            }
        }