/// <summary> /// 根据数据库体类型初始化界面 /// </summary> /// <param name="pFeaType">库体类型:参照库体、目标库体</param> private void InitialFrm(EnumFeatureType pFeaType) { btnOK.Enabled = false; object[] TagDBType = new object[] { "SDE", "GDB", "PDB" }; comBoxType.Items.AddRange(TagDBType); comBoxType.SelectedIndex = 0; if (pFeaType == EnumFeatureType.参照要素) { //历史数据,sde上的 comBoxType.Enabled = true; } else if (pFeaType == EnumFeatureType.更新要素) { //Exception err = null; /////获取工程项目名称 XmlDocument xmlDoc = new XmlDocument(); if (!File.Exists(ModData.v_projectXML)) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "找不到配置文件\n" + ModData.v_projectXML); return; } xmlDoc.Load(ModData.v_projectXML); XmlElement rootElem = xmlDoc.DocumentElement; //根元素 string proID = ""; //项目ID string proName = ""; //项目名称 proID = rootElem.GetAttribute("当前库体编号"); XmlNode proCurNode = null; //工程节点 proCurNode = rootElem.SelectSingleNode(".//工程[@编号='" + proID + "']"); if (proCurNode == null) { return; } proName = (proCurNode as XmlElement).GetAttribute("名称"); XmlNode conNode = null;//连接信息节点元素 conNode = proCurNode.FirstChild.FirstChild.FirstChild; if (conNode == null) { return; } comBoxType.Text = (conNode as XmlElement).GetAttribute("类型"); txtServer.Text = (conNode as XmlElement).GetAttribute("服务器"); txtInstance.Text = (conNode as XmlElement).GetAttribute("服务名"); txtDB.Text = (conNode as XmlElement).GetAttribute("数据库"); txtUser.Text = (conNode as XmlElement).GetAttribute("用户"); txtPassword.Text = (conNode as XmlElement).GetAttribute("密码"); txtVersion.Text = (conNode as XmlElement).GetAttribute("版本"); comBoxType.Enabled = false; txtServer.Enabled = false; txtInstance.Enabled = false; txtDB.Enabled = false; txtUser.Enabled = false; txtPassword.Enabled = false; txtVersion.Enabled = false; m_DBName = (conNode.FirstChild as XmlElement).GetAttribute("名称"); } }
public frmDBPropertySet1(Plugin.Application.IAppGISRef pHook, EnumFeatureType pFeaType) { InitializeComponent(); m_Hook = pHook; if (m_Hook == null) { return; } //if (m_HookHelp == null) return; m_FeaType = pFeaType; InitialFrm(pFeaType); //if (pFeaType == EnumFeatureType.更新要素) //{ // ModData.m_ComboBox.Items.Clear(); // ModData.m_ComboBox.Update(); //} }
/// <summary> /// 向地图控件添加指定类型的CAD图层 /// </summary> /// <param name="mapControl"></param> /// <param name="cadFullPath"></param> /// <param name="featureType"></param> public static void addCadLayersToMap(AxMapControl mapControl, string cadFullPath, EnumFeatureType featureType) { string fileName = System.IO.Path.GetFileName(cadFullPath); string fileDir = System.IO.Path.GetDirectoryName(cadFullPath); IFeatureWorkspace ws = openCadWorkspace(fileDir) as IFeatureWorkspace; IFeatureClass fc = ws.OpenFeatureClass(fileName + ":" + featureType.ToString()); IFeatureLayer layer = new FeatureLayerClass(); layer.FeatureClass = fc; layer.Name = fileName; List <string> cadLayers = getUniqeValues(fc as ITable, "Layer", ""); if (cadLayers == null || cadLayers.Count == 0) { return; } foreach (string layerName in cadLayers) { string where = "Layer = '" + layerName + "'"; IFeatureLayer layer_filtered = createFilterLayer(layer, layerName, where); layer_filtered.Visible = false; mapControl.Map.AddLayer(layer_filtered); mapControl.ActiveView.Refresh(); } }
/// <summary> /// 获取选择的要素 /// </summary> /// <param name="pMap">地图</param> /// <param name="pFeaType">要素类型:参照要素、目标要素</param> /// <param name="pError">异常</param> /// <returns>返回选中的要素</returns> public static IFeature getFea(IMap pMap, EnumFeatureType pFeaType, out Exception pError) { pError = null; //异常 IFeature pFea = null; //用来保存返回的要素 //必须要选择要素 if (pMap.SelectionCount == 0) { pError = new Exception("请选择一个需要更新的要素"); return(null); } if (pMap.SelectionCount > 1) { pError = new Exception("请只选择一个参照要素!"); return(null); } //遍历控件上的所有图层 for (int i = 0; i < pMap.LayerCount; i++) { //ILayer pLayer = pMap.get_Layer(i); //if (pLayer is IGroupLayer) //{ //} //获得图层 IFeatureLayer pFeaLayer = pMap.get_Layer(i) as IFeatureLayer; if (pFeaLayer == null) { return(null); } //获得图层的选择集 IFeatureSelection pFeaSelection = pFeaLayer as IFeatureSelection; if (pFeaSelection == null) { continue; } ISelectionSet pSelectionSet = pFeaSelection.SelectionSet; if (pSelectionSet == null) { continue; } if (pSelectionSet.Count == 0) { continue; } IEnumIDs pEnumIDs = pSelectionSet.IDs; pEnumIDs.Reset(); int pOID = pEnumIDs.Next(); if (pOID != -1) { //若存在选择集 //图层对应的要素类 IFeatureClass pFeaCls = pFeaLayer.FeatureClass; if (pFeaCls == null) { return(null); } //获得选择的要素 pFea = pFeaCls.GetFeature(pOID); if (pFea == null) { if (pFeaType == EnumFeatureType.参照要素) { pError = new Exception("获取参照要素失败!"); return(null); } else if (pFeaType == EnumFeatureType.更新要素) { pError = new Exception("获取更新要素失败!"); return(null); } } } break; } return(pFea); }
public DialogCadImport(EnumFeatureType featureType) { InitializeComponent(); this.featureType = featureType; init(); }