private void DisplayOnDistrict(string DistrictName) { if (m_SkylineHook.SGWorld.Project.Name != "") { try { int LayerID = m_SkylineHook.SGWorld.ProjectTree.FindItem("分区"); if (LayerID >= 0) { int ModelID = m_SkylineHook.SGWorld.ProjectTree.FindItem(ConfigurationManager.AppSettings["LayerPath"]); if (ModelID >= 0) { //根据DistricName从分区shp表中读取相应Code,再将SGModel中相应Code的模型显示出来 ILayer61 DistrictLayer = m_SkylineHook.SGWorld.ProjectTree.GetLayer(LayerID); IFeatureGroup61 Polygons = DistrictLayer.FeatureGroups.Polygon; string Code = "all"; foreach (IFeature61 a in Polygons) { if (a.FeatureAttributes.GetFeatureAttribute("Name").Value == DistrictName) { Code = a.FeatureAttributes.GetFeatureAttribute("Code").Value; } } ILayer61 ModelLayer = m_SkylineHook.SGWorld.ProjectTree.GetLayer(ModelID); IFeatureGroup61 Models = ModelLayer.FeatureGroups.Point; //MessageBox.Show(Models.GetProperty("File Name").ToString()); foreach (IFeature61 m in Models) { if (Code == "all") { m.FeatureAttributes.GetFeatureAttribute("Display").Value = m.FeatureAttributes.GetFeatureAttribute("ModelPath").Value; } else { if (m.FeatureAttributes.GetFeatureAttribute("Code").Value == Code) { m.FeatureAttributes.GetFeatureAttribute("Display").Value = m.FeatureAttributes.GetFeatureAttribute("ModelPath").Value; } else { m.FeatureAttributes.GetFeatureAttribute("Display").Value = ""; } } } ModelLayer.Save(); ModelLayer.Refresh(); //由于Display字段变化,二次加载时可能无法全部显示 } } } catch { MessageBox.Show("对不起,分区显示过程出现了错误!这通常是由于配置不当引起的。"); } } }
private void toolStripButton1_Click(object sender, EventArgs e) { FrmAddVersion frmRemark = new FrmAddVersion(); if (frmRemark.ShowDialog() == DialogResult.OK) { try { int GroupID = this.m_Hook.ProjectTree.FindItem(strLabel); if (GroupID > 0) { ILayer61 lyrModel = this.m_Hook.ProjectTree.GetLayer(GroupID); // string strFile = Guid.NewGuid().ToString() + ".shp"; //Application.StartupPath + "\\GuiHua\\Versions\\" + Guid.NewGuid().ToString() + ".Shp"; lyrModel.Save(); string strOld = lyrModel.DataSourceInfo.ConnectionString; string[] strs = strOld.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); strOld = strs[0]; strOld = strOld.Substring(strOld.IndexOf("=") + 1); string strFolder = System.IO.Path.GetDirectoryName(strOld); string strName = System.IO.Path.GetFileNameWithoutExtension(strOld); string strSource = strFolder + "\\" + strName; string strTarget = Application.StartupPath + "\\GuiHua\\Versions\\" + Guid.NewGuid().ToString(); try { File.Copy(strSource + ".shp", strTarget + ".shp"); File.Copy(strSource + ".shx", strTarget + ".shx"); File.Copy(strSource + ".dbf", strTarget + ".dbf"); File.Copy(strSource + ".shp.xml", strTarget + ".shp.xml"); File.Copy(strSource + ".prj", strTarget + ".prj"); File.Copy(strSource + ".sbx", strTarget + ".sbx"); File.Copy(strSource + ".sbn", strTarget + ".sbn"); } catch { } if (ProjectHelper.AddVersion(this.m_ProjectID, strTarget + ".shp", frmRemark.Description)) { XtraMessageBox.Show("添加成功"); this.Refresh(); } else { XtraMessageBox.Show("添加失败"); } } } catch { XtraMessageBox.Show("对不起,添加操作出现了错误,这通常是因为配置不当引起的。"); } } }
public override void OnClick() { m_Flag = !m_Flag; if (m_Flag) { m_UcCompare.FinishCompare(); m_UcCompare.ControlMode = enum3DControlMode.One; } else { if (m_UcCompare == null) { Control parent = m_SkylineHook.Window.Parent; parent.Controls.Remove(m_SkylineHook.Window); m_UcCompare = new UCSchemaCompare(m_SkylineHook.Window as AxTerraExplorerX.AxTE3DWindow); m_UcCompare.CreateHooker(out Program.sgworld, out teTopRight, out teBottomLeft, out teBottomRight); parent.Controls.Add(m_UcCompare); m_UcCompare.Dock = DockStyle.Fill; } if (Bussiness.Environment.m_Project.Schemas == null) { return; } // 加载fly string flyURL = Bussiness.Environment.m_Project.File; string flyURL1 = null, flyURL2 = null, flyURL3 = null; string urlTopRight = null, urlBottomLeft = null, urlBottomRight = null; enum3DControlMode modeCurrent = enum3DControlMode.One; // 设置屏模式 if (Bussiness.Environment.m_Project.Schemas.Count > 0 && Bussiness.Environment.m_Project.Schemas.Count < 4) { modeCurrent = (enum3DControlMode)(Bussiness.Environment.m_Project.Schemas.Count); if (modeCurrent == enum3DControlMode.Tow) { flyURL2 = flyURL; urlBottomLeft = Bussiness.Environment.m_Project.Schemas[0].File; } if (modeCurrent == enum3DControlMode.Three) { flyURL1 = flyURL; flyURL3 = flyURL; urlTopRight = Bussiness.Environment.m_Project.Schemas[0].File; urlBottomRight = Bussiness.Environment.m_Project.Schemas[1].File; } if (modeCurrent == enum3DControlMode.Four) { urlTopRight = Bussiness.Environment.m_Project.Schemas[0].File; urlBottomLeft = Bussiness.Environment.m_Project.Schemas[1].File; urlBottomRight = Bussiness.Environment.m_Project.Schemas[2].File; flyURL1 = flyURL; flyURL2 = flyURL; flyURL3 = flyURL; } } m_UcCompare.CompareSchema(flyURL1, flyURL2, flyURL3); try { // 修改模型shp string strLabel = ConfigurationManager.AppSettings["LayerPath"]; int GroupID = -1; ILayer61 lyrModel = null; if (!string.IsNullOrWhiteSpace(urlTopRight)) { GroupID = teTopRight.ProjectTree.FindItem(strLabel); if (GroupID > 0) { lyrModel = teTopRight.ProjectTree.GetLayer(GroupID); lyrModel.DataSourceInfo.ConnectionString = string.Format("FileName={0};TEPlugName=OGR;", urlTopRight); lyrModel.Save(); lyrModel.Refresh(); } } if (!string.IsNullOrWhiteSpace(urlBottomLeft)) { GroupID = teBottomLeft.ProjectTree.FindItem(strLabel); if (GroupID > 0) { lyrModel = teBottomLeft.ProjectTree.GetLayer(GroupID); lyrModel.DataSourceInfo.ConnectionString = string.Format("FileName={0};TEPlugName=OGR;", urlBottomLeft); lyrModel.Save(); lyrModel.Refresh(); } } if (!string.IsNullOrWhiteSpace(urlBottomRight)) { GroupID = teBottomRight.ProjectTree.FindItem(strLabel); if (GroupID > 0) { lyrModel = teBottomRight.ProjectTree.GetLayer(GroupID); lyrModel.DataSourceInfo.ConnectionString = string.Format("FileName={0};TEPlugName=OGR;", urlBottomRight); lyrModel.Save(); lyrModel.Refresh(); } } m_UcCompare.ControlMode = modeCurrent; } catch { MessageBox.Show("抱歉,出错了,很可能的原因是方案模型文件不存在或移动了"); } } }