コード例 #1
0
        private void tsbCopyComponents_Click(object sender, EventArgs e)
        {
            var settings = new CopySettings
            {
                SourceSolutions = sourceSolutionPicker.SelectedSolutions,
                TargetSolutions = targetSolutionPicker.SelectedSolutions
            };

            var csForm = new ComponentTypeSelector();

            if (csForm.ShowDialog(ParentForm) == DialogResult.OK)
            {
                settings.ComponentsTypes = csForm.SelectedComponents;
            }
            else
            {
                return;
            }

            WorkAsync("Starting copy...",
                      (bw, evt) => sManager.CopyComponents((CopySettings)evt.Argument, bw),
                      evt =>
            {
                if (evt.Error != null)
                {
                    MessageBox.Show(ParentForm, "An error occured: " + evt.Error.Message, "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            },
                      evt => SetWorkingMessage(evt.UserState.ToString()),
                      settings);
        }
コード例 #2
0
        private void tsbCopyComponents_Click(object sender, EventArgs e)
        {
            var settings = new CopySettings
            {
                SourceSolutions   = sourceSolutionPicker.SelectedSolutions,
                TargetSolutions   = targetSolutionPicker.SelectedSolutions,
                ConnectionDetail  = ConnectionDetail,
                CheckBestPractice = chkCheckBestPractice.Checked
            };
            var csForm = new ComponentTypeSelector(_omc);

            if (csForm.ShowDialog(ParentForm) == DialogResult.OK)
            {
                settings.ComponentsTypes = csForm.SelectedComponents;
            }
            else
            {
                return;
            }

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Starting copy...",
                AsyncArgument = settings,
                Work          = (bw, evt) =>
                {
                    sManager.CopyComponents((CopySettings)evt.Argument, _omc, bw);
                },
                PostWorkCallBack = evt =>
                {
                    if (evt.Error != null)
                    {
                        MessageBox.Show(ParentForm, "An error occured: " + evt.Error.Message, "Error",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                },
                ProgressChanged = evt =>
                {
                    if (evt.ProgressPercentage == 0)
                    {
                        SetWorkingMessage(evt.UserState.ToString());
                    }
                    else if (evt.ProgressPercentage == -1)
                    {
                        lvLogs.Items.Add(new ListViewItem(evt.UserState.ToString())
                        {
                            ForeColor = Color.Red
                        });
                    }
                    else if (evt.ProgressPercentage == 1)
                    {
                        lvLogs.Items.Add(new ListViewItem(evt.UserState.ToString())
                        {
                            ForeColor = Color.Green
                        });
                    }
                }
            });
        }