private void ExecMerge(object sender, EventArgs e) { RootDir = RootDirTextBox.Text; Filename = FileNameTextBox.Text; OutDir = SaveToRootDirCheckBox.Checked ? RootDir : OutDirTextBox.Text; AddOutputsToMap = AddData2MapCheckBox.Checked; OverwriteOutput = OverwriteOptCheckBox.Checked; if (Common.IsPathInValid(RootDir)) { MessageBox.Show("Invalid root folder path."); return; } if (Common.IsFileInValid(Filename)) { MessageBox.Show("Invalid filename."); return; } if (Common.IsPathInValid(OutDir)) { MessageBox.Show("Invalid output folder path."); return; } MS.Save(); DialogResult = DialogResult.OK; }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { MgSettings MS = new MgSettings(); if (!Directory.Exists(MS.RootDir)) { MS.RootDir = Environment.GetFolderPath(Environment.SpecialFolder.Personal); } if (!Directory.Exists(MS.OutDir)) { MS.OutDir = MS.RootDir; } MS.Save(); MainForm M = new MainForm(); if (M.ShowDialog() == DialogResult.OK) { MergeFunc MF = new MergeFunc(M.RootDir, M.Filename, M.OutDir); TM = new System.Windows.Forms.Timer(); SW.Reset(); Geoprocessor GP = new Geoprocessor() { AddOutputsToMap = M.AddOutputsToMap, OverwriteOutput = M.OverwriteOutput }; GP.ToolExecuting += GP_ToolExecuting; GP.ToolExecuted += GP_ToolExecuted; TM.Tick += TM_Tick; ITrackCancel pTrackCancel = new CancelTrackerClass(); IProgressDialogFactory pProgDlgFactory = new ProgressDialogFactoryClass(); pProDlg = pProgDlgFactory.Create(pTrackCancel, m_application.hWnd) as IProgressDialog2; pProDlg.CancelEnabled = true; pProDlg.Title = "Merge in progress..."; pProDlg.Description = "Please wait patiently..."; pProDlg.Animation = esriProgressAnimationTypes.esriProgressSpiral; pStepPro = pProDlg as IStepProgressor; pStepPro.MinRange = 0; pStepPro.MaxRange = 100; pStepPro.StepValue = 1; pStepPro.Message = "Initiating..."; GP.Execute(MF.GetMerge(), pTrackCancel); } M.Dispose(); }