protected virtual void OnMapSettingFinished(CGMapEventArgs e) { if (this.MapSettingFinished != null) { this.MapSettingFinished(this, e); } }
private void button_MapBetweenVersions_Click(object sender, EventArgs e) { Global.mappingVersionRange = "ADJACENTVERSIONS"; //置映射范围为相邻版本 //创建CGMapEventArgs对象,并赋予映射系统的信息 CGMapEventArgs ee = new CGMapEventArgs(); ee.srcStr = this.textBox1.Text.ToString(); ee.destStr = this.textBox2.Text.ToString(); this.Close(); OnMapSettingFinished(ee); //引发MapSettingFinished事件 //if (this.MapSettingFinished != null)//可以用这两行替换上一条语句和OnMapSettingFinished方法 //{ this.MapSettingFinished(sender, new EventArgs()); } }
private void button_MapAll_Click(object sender, EventArgs e) { if (!this.checkBox_functions.Checked && !this.checkBox_blocks.Checked) { this.label_Warning2.ForeColor = Color.Red; this.label_Warning2.Text = "Please check on at least one granularity type!"; return; } this.Close(); Global.mappingVersionRange = "ALLVERSIONS"; //置映射范围为全部版本 Global.mainForm.GetCRDDirFromTreeView1(); //获取CRD文件所在文件夹路径 DirectoryInfo dir = null; #region 在funtions粒度上映射所有版本 if (this.checkBox_functions.Checked) { try { dir = new DirectoryInfo(CloneRegionDescriptor.CrdDir + @"\functions"); } catch (Exception ee) { MessageBox.Show("Get CRD directory of functions failed! " + ee.Message); } FileInfo[] crdFiles = null; try { crdFiles = dir.GetFiles(); } catch (Exception ee) { MessageBox.Show("Get CRD files on functions failed! " + ee.Message); } List <string> fileNames = new List <string>(); foreach (FileInfo info in crdFiles) { if ((info.Attributes & FileAttributes.Hidden) != 0) //不处理隐藏文件 { continue; } else { //选出所有带有"_functions-"标签的-withCRD.xml文件,记录它们的文件名(不包含路径) if (info.Name.IndexOf("-withCRD.xml") != -1 && info.Name.IndexOf("_functions-") != -1) { fileNames.Add(info.Name); } } } if (fileNames.Count > 1) { for (int i = 0; i < fileNames.Count - 1; i++) { CGMapEventArgs ee = new CGMapEventArgs(); ee.srcStr = fileNames[i]; ee.destStr = fileNames[i + 1]; //OnMapSettingFinished(ee); //不采取触发事件的方式,原因:并发进程的处理问题?? AdjacentVersionMapping adjMap = new AdjacentVersionMapping(); adjMap.OnStartMapping(this, ee); //直接调用事件的响应函数OnStartMapping } MessageBox.Show("Mapping All Versions on Functions level Finished!"); } else { MessageBox.Show("No withCRD.xml file at Functions level for mapping!"); } if (Global.MapState != 2) //置映射状态为完成某粒度下所有相邻版本的映射 { Global.MapState = 2; } } #endregion #region 在blocks粒度上映射所有版本 if (this.checkBox_blocks.Checked) { try { dir = new DirectoryInfo(CloneRegionDescriptor.CrdDir + @"\blocks"); } catch (Exception ee) { MessageBox.Show("Get CRD directory of blocks failed! " + ee.Message); } FileInfo[] crdFiles = null; try { crdFiles = dir.GetFiles(); } catch (Exception ee) { MessageBox.Show("Get CRD files on blocks failed! " + ee.Message); } List <string> fileNames = new List <string>(); foreach (FileInfo info in crdFiles) { if ((info.Attributes & FileAttributes.Hidden) != 0) //不处理隐藏文件 { continue; } else { //选出所有带有"_blocks-"标签的-withCRD.xml文件,记录它们的文件名(不包含路径) if (info.Name.IndexOf("-withCRD.xml") != -1 && info.Name.IndexOf("_blocks-") != -1) { fileNames.Add(info.Name); } } } if (fileNames.Count > 1) { for (int i = 0; i < fileNames.Count - 1; i++) { CGMapEventArgs ee = new CGMapEventArgs(); ee.srcStr = fileNames[i]; ee.destStr = fileNames[i + 1]; //OnMapSettingFinished(ee); //不采取触发事件的方式,原因:并发进程的处理问题?? AdjacentVersionMapping adjMap = new AdjacentVersionMapping(); adjMap.OnStartMapping(this, ee); //直接调用事件的响应函数OnStartMapping } MessageBox.Show("Mapping All Versions on Blocks level Finished!"); } else { MessageBox.Show("No withCRD.xml files at Blocks level for mapping!"); } if (Global.MapState != 2) { Global.MapState = 2; } } #endregion }