internal UnresolvedFieldInfo(IFieldInfo adapter) { if (adapter == null) throw new ArgumentNullException("adapter"); this.adapter = adapter; }
public static SyncVersion SetFieldValue(this SyncVersion syncVersion, IFieldInfo fieldInfo, string value) { SyncField field = syncVersion.Fields.FirstOrDefault(f => f.FieldID == fieldInfo.FieldId); var fieldIndex = syncVersion.Fields.IndexOf(field); syncVersion.Fields[fieldIndex].FieldValue = value; return syncVersion; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedField"/> class. /// </summary> /// <param name="info">The field info.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="example">The example comment.</param> public DocumentedField( IFieldInfo info, SummaryComment summary, RemarksComment remarks, ExampleComment example) : base(MemberClassification.Type, summary, remarks, example) { _definition = info.Definition; _identity = info.Identity; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentedField"/> class. /// </summary> /// <param name="info">The field info.</param> /// <param name="summary">The summary comment.</param> /// <param name="remarks">The remarks comment.</param> /// <param name="examples">The example comments.</param> /// <param name="metadata">The associated metadata.</param> public DocumentedField( IFieldInfo info, SummaryComment summary, RemarksComment remarks, IEnumerable<ExampleComment> examples, IDocumentationMetadata metadata) : base(MemberClassification.Type, summary, remarks, examples, metadata) { Definition = info.Definition; Identity = info.Identity; }
private void DoQuery() { List <TreeListNode> list = this.treelist.GetAllCheckedNodes(); if (list == null) { XtraMessageBox.Show("请勾选图层树。", "提示"); return; } string widemax = this.spWMax.Text; string widemin = this.spWMin.Text; string heightmax = this.spHMax.Text; string heightmin = this.spHMin.Text; foreach (TreeListNode node in list) { object obj = node.GetValue("NodeObject"); if (obj != null && obj is SubClass) { SubClass sc = obj as SubClass; if (sc.Parent == null) { continue; } string[] arrFc3DId = sc.Parent.Fc3D.Split(';'); if (arrFc3DId == null) { continue; } foreach (string fc3DId in arrFc3DId) { DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId); if (dffc == null) { continue; } FacilityClass facc = dffc.GetFacilityClass(); IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null || facc == null || facc.Name != this._facType) { continue; } DFDataConfig.Class.FieldInfo fi1 = facc.GetFieldInfoBySystemName("Diameter1"); DFDataConfig.Class.FieldInfo fi2 = facc.GetFieldInfoBySystemName("Diameter2"); if (fi1 == null || fi2 == null) { continue; } int index1 = fc.GetFields().IndexOf(fi1.Name); int index2 = fc.GetFields().IndexOf(fi2.Name); if (index1 == -1 || index2 == -1) { continue; } IFieldInfo fcfi1 = fc.GetFields().Get(index1); switch (fcfi1.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: continue; } IFieldInfo fcfi2 = fc.GetFields().Get(index2); switch (fcfi2.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: continue; } string clause = ""; if (heightmax == heightmin) { clause = "(" + fcfi1.Name + " <= " + widemax + " and " + fcfi1.Name + " >= " + widemin + ") and " + fcfi2.Name + "=0 or " + fcfi2.Name + " is null"; } else { clause = "(" + fcfi1.Name + " <= " + widemax + " and " + fcfi1.Name + " >= " + widemin + ") and (" + fcfi2.Name + " <= " + heightmax + " and " + fcfi2.Name + " >= " + heightmin + ") and " + fcfi2.Name + " <> 0 and " + fcfi2.Name + " is not null"; } string whereClause = "GroupId = " + sc.GroupId + " and ( " + clause + " )"; _dict.Add(sc, whereClause); } } } }
// 公共方法 private void bindDataToCatalogTree(IConnectionInfo ci) { try { if (dsFactory == null) { dsFactory = new DataSourceFactory(); } IDataSource ds = dsFactory.OpenDataSource(ci); myTreeNode sourceNode = null; if (ci.ConnectionType == gviConnectionType.gviConnectionMySql5x) { sourceNode = new myTreeNode(ci.Database + "@" + ci.Server, ci); } else { sourceNode = new myTreeNode(ci.Database, ci); } this.treeView1.Nodes.Add(sourceNode); // 获取dataset string[] setnames = (string[])ds.GetFeatureDatasetNames(); if (setnames.Length == 0) { return; } foreach (string setname in setnames) { IFeatureDataSet dataset = ds.OpenFeatureDataset(setname); TreeNode setNode = new TreeNode(setname, 1, 1); sourceNode.Nodes.Add(setNode); // 获取featureclass string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable); if (fcnames == null || fcnames.Length == 0) { continue; } foreach (string fcname in fcnames) { IFeatureClass fc = dataset.OpenFeatureClass(fcname); TreeNode fcNode = new TreeNode(fcname, 2, 2); fcNode.ContextMenuStrip = this.contextMenuStrip2; setNode.Nodes.Add(fcNode); // 获取属性字段 IFieldInfoCollection fieldinfos = fc.GetFields(); for (int i = 0; i < fieldinfos.Count; i++) { IFieldInfo fieldinfo = fieldinfos.Get(i); if (null == fieldinfo) { continue; } TreeNode fieldinfoNode = new TreeNode(fieldinfo.Name); fieldinfoNode.ContextMenuStrip = this.contextMenuStrip1; // 绑定右键菜单 fcNode.Nodes.Add(fieldinfoNode); } } } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); return; } }
private void Join(IFieldInfo left, IFieldInfo right, JoinType type) { mTable.AppendFormat(" {0} {1} on {2}.{3}={1}.{4}", Jions[(int)type], right.Table, left.Table, left.Name, right.Name); }
void axRenderControl1_RcMouseClickSelect(IPickResult PickResult, IPoint IntersectPoint, gviModKeyMask Mask, gviMouseSelectMode EventSender) { try { IPickResult pr = PickResult; if (pr == null) { return; } this.axRenderControl1.FeatureManager.UnhighlightAll(); if (EventSender == gviMouseSelectMode.gviMouseSelectClick) { if (pr.Type == gviObjectType.gviObjectFeatureLayer) { IFeatureLayerPickResult flpr = pr as IFeatureLayerPickResult; int fid = flpr.FeatureId; IFeatureLayer fl = flpr.FeatureLayer; foreach (IFeatureClass fc in fcMap.Keys) { if (fc.Guid.Equals(fl.FeatureClassId)) { //删除画包围框的RenderPolyline for (int i = 0; i < rPolylinelist.Count; i++) { this.axRenderControl1.ObjectManager.DeleteObject((rPolylinelist[i] as IRenderPolyline).Guid); } rPolylinelist.Clear(); DrawEnvelope(fid, fc, out rPolylinelist); // 选择用作水印的图片 IImage waterImg = new ResourceFactory().CreateImageFromFile(this.toolStripTextBoxPicturePath.Text); if (waterImg == null) { MessageBox.Show("水印图片对象为空,请先更换图片"); return; } DialogResult result = MessageBox.Show("加水印操作不可逆,是否继续进行", "警告", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } // 准备Model对象 string filterString = string.Format("oid={0}", fid); IQueryFilter filter = new QueryFilter(); filter.WhereClause = filterString; IFdeCursor cursor = null; try { cursor = fc.Search(filter, true); if (cursor != null) { IRowBuffer fdeRow = null; while ((fdeRow = cursor.NextRow()) != null) { IFieldInfoCollection col = fdeRow.Fields; for (int i = 0; i < col.Count; ++i) { IFieldInfo info = col.Get(i); if (info.GeometryDef != null && info.GeometryDef.GeometryColumnType == gviGeometryColumnType.gviGeometryColumnModelPoint) { int nPos = fdeRow.FieldIndex(info.Name); IModelPoint mp = fdeRow.GetValue(nPos) as IModelPoint; // 高亮选定模型边框 //DrawEnvelope(mp.Envelope, fc.FeatureDataSet.SpatialReference as ISpatialCRS); IResourceManager rm = fc.FeatureDataSet as IResourceManager; IModel model = rm.GetModel(mp.ModelName); // 加上水印 string[] imagenames = model.GetImageNames(); for (int j = 0; j < imagenames.Length; j++) { this.Text = string.Format("正在处理第{0}个图片/共{1}个", j, imagenames.Length); IImage image = rm.GetImage(imagenames[j]); image.EmbedWatermark(waterImg); rm.UpdateImage(imagenames[j], image); } this.axRenderControl1.FeatureManager.RefreshFeatureClass(fc); this.Text = "处理完成!"; } } } } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (cursor != null) { //Marshal.ReleaseComObject(cursor); cursor = null; } } //end try } // end " if (fc.Guid.Equals(fl.FeatureClassId))" } // end "foreach (IFeatureClass fc in fcMap.Keys)" } } } catch (System.Exception ex) { if (ex.GetType().Name.Equals("UnauthorizedAccessException")) { MessageBox.Show("需要标准runtime授权"); } else { MessageBox.Show(ex.Message); } } }
/// <summary>Creates a new IEntityField instance for usage in the EntityFields object for the AssetReclamationServiceChangeLogEntity. Which EntityField is created is specified by fieldIndex</summary> /// <param name="fieldIndex">The field which IEntityField instance should be created</param> /// <returns>The IEntityField instance for the field specified in fieldIndex</returns> public static IEntityField Create(AssetReclamationServiceChangeLogFieldIndex fieldIndex) { IFieldInfo info = FieldInfoProviderSingleton.GetInstance().GetFieldInfo("AssetReclamationServiceChangeLogEntity", (int)fieldIndex); return(new EntityField(info, PersistenceInfoProviderSingleton.GetInstance().GetFieldPersistenceInfo(info.ContainingObjectName, info.Name))); }
private static IEnumerable<Test> GetContractVerificationTests(IContract contract, IFieldInfo field) { var context = new ContractVerificationContext(field); return contract.GetContractVerificationTests(context); }
/// <summary> /// Verifies that the attribute is being used correctly. /// </summary> /// <param name="containingScope">The containing scope.</param> /// <param name="field">The field.</param> /// <exception cref="PatternUsageErrorException">Thrown if the attribute is being used incorrectly.</exception> protected virtual void Validate(IPatternScope containingScope, IFieldInfo field) { if (!containingScope.CanAddChildTest || field == null || ! field.IsInitOnly) ThrowUsageErrorException("This attribute can only be used on a read-only field within a test type."); if (field.IsStatic && field.DeclaringType.ContainsGenericParameters) ThrowUsageErrorException("A contract verifier field cannot be static when it is declared on a generic type. " + "Make the field non-static or make its declaring type non-generic."); }
/// <summary> /// Initializes a test for a contract verifier field after it has been added to the test model. /// </summary> /// <param name="fieldScope">The field scope.</param> /// <param name="field">The field.</param> protected virtual void InitializeTest(IPatternScope fieldScope, IFieldInfo field) { string xmlDocumentation = field.GetXmlDocumentation(); if (xmlDocumentation != null) fieldScope.TestBuilder.AddMetadata(MetadataKeys.XmlDocumentation, xmlDocumentation); fieldScope.Process(field); }
/// <summary> /// Generates static or dynamic tests from the contract. /// </summary> /// <param name="fieldScope">The field scope.</param> /// <param name="field">The field.</param> /// <param name="containingScope">The containing scope.</param> protected virtual void GenerateTestsFromContract(IPatternScope fieldScope, IFieldInfo field, IPatternScope containingScope) { if (field.IsStatic) { FieldInfo resolvedField = field.Resolve(false); if (resolvedField == null) { fieldScope.TestModelBuilder.AddAnnotation(new Annotation(AnnotationType.Info, field, "This test runner does not fully support static contract verifier methods " + "because the code that defines the contract cannot be executed " + "at test exploration time. Consider making the contract field non-static instead.")); return; } var contract = resolvedField.GetValue(null) as IContract; if (contract == null) { fieldScope.TestModelBuilder.AddAnnotation(new Annotation(AnnotationType.Error, field, "Expected the contract field to contain a value that is assignable " + "to type IContract.")); return; } IEnumerable<Test> contractTests = GetContractVerificationTests(contract, field); Test.BuildStaticTests(contractTests, fieldScope, field); } else { fieldScope.TestBuilder.TestInstanceActions.ExecuteTestInstanceChain.After(state => { var invoker = new FixtureMemberInvoker<IContract>(null, containingScope, field.Name); IContract contract; try { contract = invoker.Invoke(FixtureMemberInvokerTargets.Field); } catch (PatternUsageErrorException exception) { throw new TestFailedException( String.Format( "The field '{0}' must contain an instance of type IContract that describes a contract to be verified.", field.Name), exception); } IEnumerable<Test> contractTests = GetContractVerificationTests(contract, field); TestOutcome outcome = Test.RunDynamicTests(contractTests, field, null, null); if (outcome != TestOutcome.Passed) throw new SilentTestException(outcome); }); } }
/// <summary> /// Resolves a reflected field to its native <see cref="FieldInfo" /> object. /// </summary> /// <param name="field">The reflected type.</param> /// <param name="throwOnError">If true, throws an exception if resolution fails, /// otherwise returns an unresolved <see cref="FieldInfo" />.</param> /// <returns>The resolved <see cref="FieldInfo" />.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="field"/> /// is null.</exception> /// <exception cref="ReflectionResolveException">Thrown if <paramref name="field"/> /// could not be resolved.</exception> public static FieldInfo ResolveField(IFieldInfo field, bool throwOnError) { if (field == null) throw new ArgumentNullException("field"); try { Type resolvedType = field.DeclaringType.Resolve(throwOnError); if (! Reflector.IsUnresolved(resolvedType)) { FieldInfo resolvedField = resolvedType.GetField(field.Name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); if (resolvedField != null) return resolvedField; } } catch (Exception ex) { if (throwOnError) throw new ReflectionResolveException(field, ex); } if (throwOnError) throw new ReflectionResolveException(field); return UnresolvedCodeElementFactory.Instance.Wrap(field); }
private static object[] GetFieldValues(Type attType, out IFieldInfo[] fields, Attribute original, Attribute replicated) { var fieldsCandidates = attType.GetFields(BindingFlags.Public | BindingFlags.Instance); var selectedValues = new List<object>(fieldsCandidates.Length); var selectedFields = new List<IFieldInfo>(fieldsCandidates.Length); foreach (var field in fieldsCandidates) { var originalValue = field.GetValue(original); var replicatedValue = field.GetValue(replicated); if (AreAttributeElementsEqual(originalValue, replicatedValue)) { //this field has default value so we skip it continue; } selectedFields.Add(field.AsIFieldInfo()); selectedValues.Add(originalValue); } fields = selectedFields.ToArray(); return selectedValues.ToArray(); }
private void modifyFieldToolStripMenuItem_Click(object sender, EventArgs e) { string fieldInfo_name = selectNode.Text; string fc_name = selectNode.Parent.Text; string set_name = selectNode.Parent.Parent.Text; myTreeNode node = (myTreeNode)selectNode.Parent.Parent.Parent; IConnectionInfo ci = node.con; IDataSource ds = null; IFeatureDataSet dset = null; IFeatureClass fc = null; IFieldInfo newFieldInfo = null; try { ds = dsFactory.OpenDataSource(ci); dset = ds.OpenFeatureDataset(set_name); fc = dset.OpenFeatureClass(fc_name); // 获取fieldinfo对象 IFieldInfoCollection fieldinfos = fc.GetFields(); for (int i = 0; i < fieldinfos.Count; i++) { IFieldInfo fieldinfo = fieldinfos.Get(i); if (null == fieldinfo) { continue; } if (fieldInfo_name == fieldinfo.Name) { newFieldInfo = fieldinfo; break; } } OperateFieldInfoForm form = new OperateFieldInfoForm(newFieldInfo); if (form.ShowDialog() == DialogResult.OK) { newFieldInfo = form.newFieldInfo; fc.LockType = gviLockType.gviLockExclusiveSchema; fc.ModifyField(newFieldInfo); fc.LockType = gviLockType.gviLockSharedSchema; // 修改树上的节点 selectNode.Text = newFieldInfo.Name; MessageBox.Show("修改成功"); } } catch (COMException comEx) { System.Diagnostics.Trace.WriteLine(comEx.Message); MessageBox.Show("修改失败"); } catch (System.Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); MessageBox.Show("修改失败"); } finally { fc.LockType = gviLockType.gviLockSharedSchema; if (newFieldInfo != null) { //Marshal.ReleaseComObject(newFieldInfo); newFieldInfo = null; } if (fc != null) { //Marshal.ReleaseComObject(fc); fc = null; } if (dset != null) { //Marshal.ReleaseComObject(dset); dset = null; } if (ds != null) { //Marshal.ReleaseComObject(ds); ds = null; } } }
private void createFieldToolStripMenuItem_Click(object sender, EventArgs e) { string fc_name = selectNode.Text; string set_name = selectNode.Parent.Text; myTreeNode node = (myTreeNode)selectNode.Parent.Parent; IConnectionInfo ci = node.con; IDataSource ds = null; IFeatureDataSet dset = null; IFeatureClass fc = null; try { ds = dsFactory.OpenDataSource(ci); dset = ds.OpenFeatureDataset(set_name); fc = dset.OpenFeatureClass(fc_name); OperateFieldInfoForm form = new OperateFieldInfoForm(null); if (form.ShowDialog() == DialogResult.OK) { IFieldInfoCollection fieldinfos = fc.GetFields(); IFieldInfo newFieldInfo = form.newFieldInfo; for (int i = 0; i < fieldinfos.Count; i++) { IFieldInfo fieldinfo = fieldinfos.Get(i); if (null == fieldinfo) { continue; } if (newFieldInfo.Name == fieldinfo.Name) { MessageBox.Show("已有同名字段,添加失败"); return; } } fc.LockType = gviLockType.gviLockExclusiveSchema; fc.AddField(newFieldInfo); fc.LockType = gviLockType.gviLockSharedSchema; // 往树上挂节点 TreeNode fieldNode = new TreeNode(newFieldInfo.Name, 1, 1); selectNode.Nodes.Add(fieldNode); fieldNode.ContextMenuStrip = this.contextMenuStrip4; } } catch (COMException comEx) { System.Diagnostics.Trace.WriteLine(comEx.Message); MessageBox.Show("添加失败"); } catch (System.Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); MessageBox.Show("添加失败"); } finally { fc.LockType = gviLockType.gviLockSharedSchema; if (fc != null) { //Marshal.ReleaseComObject(fc); fc = null; } if (dset != null) { //Marshal.ReleaseComObject(dset); dset = null; } if (ds != null) { //Marshal.ReleaseComObject(ds); ds = null; } } }
/// <summary> /// 初始化控件 /// </summary> private void initControls() { IFeatureLayer pFeaLayer = (IFeatureLayer)m_FeaLay; if (pFeaLayer == null) { return; } IDatasetEditInfo pEdit = (IDatasetEditInfo)pFeaLayer.FeatureClass; ILayerEffects pLayerEff = (ILayerEffects)m_FeaLay; //数据源 IDataLayer pDataLayer = (IDataLayer)m_FeaLay; IDatasetName pDatasetName = pDataLayer.DataSourceName as IDatasetName; IWorkspaceName pWSName = pDatasetName.WorkspaceName; IFeatureClassName pFCName = pDatasetName as IFeatureClassName; string strDataSourceType = ""; string strFeatureDataSet = ""; if (pFCName.FeatureDatasetName == null) { strDataSourceType = "数据类型 :" + "个人空间数据库 要素类"; strFeatureDataSet = "数 据 集 :" + "无"; } else { strDataSourceType = "数据类型 :" + pFCName.FeatureDatasetName.Category + "(" + pFeaLayer.DataSourceType + ")"; strFeatureDataSet = "数 据 集 :" + pFCName.FeatureDatasetName.Name; } string strFeatureClass = "要 素 类 :" + pDatasetName.Name; string strFeatureType = "要素类型 :" + pFCName.FeatureType.ToString(); string strGeometyrType = "几何类型 :" + pFCName.ShapeType.ToString(); string strLocationPath = "位 置 :" + pWSName.PathName; string strRelativeBase = "相对路径 :" + pDataLayer.RelativeBase; this.txtSoureFile.Text = strDataSourceType + "\r\n" + strFeatureDataSet + "\r\n" + strFeatureClass + "\r\n" + strFeatureType + "\r\n" + strGeometyrType + "\r\n" + strRelativeBase + "\r\n" + strLocationPath; this.txtXMin.Text = m_FeaLay.AreaOfInterest.XMin.ToString(".##"); this.txtXMax.Text = m_FeaLay.AreaOfInterest.XMax.ToString(".##"); this.txtYMin.Text = m_FeaLay.AreaOfInterest.YMin.ToString(".##"); this.txtYMax.Text = m_FeaLay.AreaOfInterest.YMax.ToString(".##"); //基本信息 this.txtLayerName.Text = m_FeaLay.Name; if (pEdit != null) { this.chkEdit.Checked = pEdit.CanEdit; } if (m_FeaLay.FeatureClass != null) { int dfIndex = -1; this.chkVisible.Checked = pFeaLayer.Visible; this.cboDisplayField.Properties.Items.Clear(); for (int i = 0; i < m_FeaLay.FeatureClass.Fields.FieldCount; i++) { IField pField = m_FeaLay.FeatureClass.Fields.get_Field(i); if (pField.Name == pFeaLayer.DisplayField) { dfIndex = i; } Class.Item item = new Class.Item(pField.AliasName, pField.Name); cboDisplayField.Properties.Items.Add(item); } this.cboDisplayField.SelectedIndex = dfIndex; this.txtTransparency.Text = pLayerEff.Transparency.ToString(); //this.txtScaleMin.Text = (pFeaLayer as ILayerGeneralProperties).LastMinimumScale.ToString(); //this.txtScaleMax.Text = (pFeaLayer as ILayerGeneralProperties).LastMaximumScale.ToString(); this.txtScaleMin.Text = pFeaLayer.MinimumScale.ToString(); this.txtScaleMax.Text = pFeaLayer.MaximumScale.ToString(); this.txtDescription.Text = (pFeaLayer as ILayerGeneralProperties).LayerDescription; if (pFeaLayer.MinimumScale == 0 && pFeaLayer.MaximumScale == 0) { this.rdoGroupScale.SelectedIndex = 0; txtScaleMin.Enabled = false; txtScaleMax.Enabled = false; } else { this.rdoGroupScale.SelectedIndex = 1; txtScaleMin.Enabled = true; txtScaleMax.Enabled = true; } chkShowTip.Checked = pFeaLayer.ShowTips; if (pFeaLayer is IGeoFeatureLayer) { chkLabelAll.Checked = (pFeaLayer as IGeoFeatureLayer).DisplayAnnotation; } chkScaleSymbol.Checked = pFeaLayer.ScaleSymbols; m_pTableFields = pFeaLayer as ITableFields; //字段信息 string strType = ""; for (int i = 0; i < m_pTableFields.FieldCount; i++) { IField pField = m_pTableFields.get_Field(i); IFieldInfo pFieldInfo = m_pTableFields.get_FieldInfo(i); switch (pField.Type)//类型 { case esriFieldType.esriFieldTypeBlob: strType = "二进制块"; break; case esriFieldType.esriFieldTypeDate: strType = "日期型"; break; case esriFieldType.esriFieldTypeDouble: strType = "双精度"; break; case esriFieldType.esriFieldTypeGeometry: strType = "几何形体"; break; case esriFieldType.esriFieldTypeGlobalID: strType = "GlobalID"; break; case esriFieldType.esriFieldTypeGUID: strType = "GUID"; break; case esriFieldType.esriFieldTypeOID: strType = "OID"; break; case esriFieldType.esriFieldTypeRaster: strType = "栅格"; break; case esriFieldType.esriFieldTypeSingle: strType = "单精度"; break; case esriFieldType.esriFieldTypeSmallInteger: strType = "短整形"; break; case esriFieldType.esriFieldTypeString: strType = "字符型"; break; } TreeListNode node = this.listViewFieldInfo.Nodes.Add(new object[] { pField.AliasName, pField.Name, strType }); node.Checked = pFieldInfo.Visible; } //初始化过滤条件面板 initFilterCondition(); } }
private void MainForm_Load(object sender, System.EventArgs e) { // 初始化RenderControl控件 IPropertySet ps = new PropertySet(); ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL); this.axRenderControl1.Initialize(true, ps); this.axRenderControl1.Camera.FlyTime = 1; rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID; // 设置天空盒 if (System.IO.Directory.Exists(strMediaPath)) { string tmpSkyboxPath = strMediaPath + @"\skybox"; ISkyBox skybox = this.axRenderControl1.ObjectManager.GetSkyBox(0); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg"); } else { MessageBox.Show("请不要随意更改SDK目录名"); return; } // 加载FDB场景 try { IConnectionInfo ci = new ConnectionInfo(); ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x; string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB"); ci.Database = tmpFDBPath; IDataSourceFactory dsFactory = new DataSourceFactory(); IDataSource ds = dsFactory.OpenDataSource(ci); string[] setnames = (string[])ds.GetFeatureDatasetNames(); if (setnames.Length == 0) { return; } IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]); string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable); if (fcnames.Length == 0) { return; } fcMap = new Hashtable(fcnames.Length); foreach (string name in fcnames) { IFeatureClass fc = dataset.OpenFeatureClass(name); // 找到空间列字段 List <string> geoNames = new List <string>(); IFieldInfoCollection fieldinfos = fc.GetFields(); for (int i = 0; i < fieldinfos.Count; i++) { IFieldInfo fieldinfo = fieldinfos.Get(i); if (null == fieldinfo) { continue; } IGeometryDef geometryDef = fieldinfo.GeometryDef; if (null == geometryDef) { continue; } geoNames.Add(fieldinfo.Name); } fcMap.Add(fc, geoNames); } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); return; } // CreateFeautureLayer bool hasfly = false; foreach (IFeatureClass fc in fcMap.Keys) { List <string> geoNames = (List <string>)fcMap[fc]; foreach (string geoName in geoNames) { if (!geoName.Equals("Geometry")) { continue; } IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer( fc, geoName, null, null, rootId); if (!hasfly) { IFieldInfoCollection fieldinfos = fc.GetFields(); IFieldInfo fieldinfo = fieldinfos.Get(fieldinfos.IndexOf(geoName)); IGeometryDef geometryDef = fieldinfo.GeometryDef; IEnvelope env = geometryDef.Envelope; if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 && env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0)) { continue; } IEulerAngle angle = new EulerAngle(); angle.Set(0, -20, 0); this.axRenderControl1.Camera.LookAt(env.Center, 1000, angle); } hasfly = true; } } // 注册控件拾取事件 this.axRenderControl1.RcMouseClickSelect += new Gvitech.CityMaker.Controls._IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect); { this.helpProvider1.SetShowHelp(this.axRenderControl1, true); this.helpProvider1.SetHelpString(this.axRenderControl1, ""); this.helpProvider1.HelpNamespace = "EmbedWatermark.html"; } }
/// <summary> /// 保存图层属性 /// </summary> /// <returns></returns> public bool SaveProperties() { if (txtLayerName.Text.Trim() == "") { return(false); } if (this.rdoGroupScale.SelectedIndex == 1) { try { if (double.Parse(txtScaleMin.Text) <= double.Parse(txtScaleMax.Text)) { return(false); } } catch { return(false); } } m_FeaLay.Name = txtLayerName.Text; if (this.rdoGroupScale.SelectedIndex == 0) { m_FeaLay.MinimumScale = 0; m_FeaLay.MaximumScale = 0; } else if (this.rdoGroupScale.SelectedIndex == 1) { m_FeaLay.MinimumScale = double.Parse(txtScaleMin.Text); m_FeaLay.MaximumScale = double.Parse(txtScaleMax.Text); } (m_FeaLay as ILayerGeneralProperties).LayerDescription = txtDescription.Text; //地图描述 Class.Item item = cboDisplayField.SelectedItem as Class.Item; m_FeaLay.DisplayField = item.Value.ToString(); //主显示字段 m_FeaLay.Visible = chkVisible.Checked; //可见性 (m_FeaLay as ILayerEffects).Transparency = short.Parse(txtTransparency.Text); //透明度 m_FeaLay.ShowTips = chkShowTip.Checked; //显示主显示字段 if (m_FeaLay is IGeoFeatureLayer) { if (chkLabelAll.Checked) { ChangeLayerAnno(m_FeaLay); } (m_FeaLay as IGeoFeatureLayer).DisplayAnnotation = chkLabelAll.Checked; //标注图层中所有要素 } m_FeaLay.ScaleSymbols = chkScaleSymbol.Checked;//符号随比例尺缩放 ////////字段信息 m_pTableFields = m_FeaLay as ITableFields; for (int i = 0; i < listViewFieldInfo.Nodes.Count; i++) { int index = m_pTableFields.FindField(listViewFieldInfo.Nodes[i][2].ToString()); if (index > -1) { IFieldInfo pFieldInfo = m_pTableFields.get_FieldInfo(index); pFieldInfo.Visible = listViewFieldInfo.Nodes[i].Checked == true ? true : false; } } if (!CheckCondition(this.m_FeaLay, txtCondition.Text)) { MessageBox.Show("查询条件错误!"); } else { (this.m_FeaLay as IFeatureLayerDefinition).DefinitionExpression = txtCondition.Text; m_MapCtrl.ActiveView.Refresh(); } return(true); }
protected virtual bool IsOKToBeOnProxy(IFieldInfo field) { return IsGeneratedByTheCompiler(field); }
public override IParamBuilder GetCondition(IFieldInfo field, string fieldValue) { return(SqlParamBuilder.CreateEqualSql(Context, field, fieldValue)); }
/// <summary> /// 外联到指定的表字段 /// </summary> /// <param name="left">左表字段</param> /// <param name="right">右表字段</param> /// <returns>JoinTable</returns> public JoinTable OuterJoin(IFieldInfo left, IFieldInfo right) { Join(left, right, JoinType.Outer); return this; }
// Methods public static IFieldInfoCollection GetDataModel(string name, out string[] arrDBIndex) { IFieldInfoCollection infos = null; IFieldInfo newVal = null; arrDBIndex = null; infos = new FieldInfoCollectionClass(); switch (name) { case "OC_Catalog": newVal = new FieldInfoClass { Name = "Name", Alias = "名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Code", Alias = "设施类编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "PCode", Alias = "父节点ID", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "FacilityType", Alias = "设施类类型", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "LocationType", Alias = "位置类型", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "TurnerStyle", Alias = "拐角类型", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "TopoLayerId", Alias = "拓扑层ID", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Visible", Alias = "显示顺序", FieldType = gviFieldType.gviFieldInt32 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "RenderStyle", Alias = "渲染样式", FieldType = gviFieldType.gviFieldBlob }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "OrderBy", Alias = "显示顺序", FieldType = gviFieldType.gviFieldInt32 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Comment", Alias = "备注", FieldType = gviFieldType.gviFieldString, Length = 200 }; infos.Add(newVal); arrDBIndex = new string[] { "Code", "PCode", "FacilityType", "TopoLayerId" }; return(infos); case "OC_FieldConfig": newVal = new FieldInfoClass { Name = "FacClassCode", Alias = "设施类编码", FieldType = gviFieldType.gviFieldString, Length = 80, Nullable = false }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Name", Alias = "字段名称", FieldType = gviFieldType.gviFieldString, Length = 80, Nullable = false }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Alias", Alias = "字段别名", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "StdFieldName", Alias = "标准字段名", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "FieldType", Alias = "字段类型", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Length", Alias = "字段长度", FieldType = gviFieldType.gviFieldInt32 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Nullable", Alias = "是否可为空", FieldType = gviFieldType.gviFieldInt16 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Visible", Alias = "是否可见", FieldType = gviFieldType.gviFieldInt16 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "OrderBy", Alias = "显示排序", FieldType = gviFieldType.gviFieldInt16 }; infos.Add(newVal); arrDBIndex = new string[] { "FacClassCode" }; return(infos); case "OC_FacilityStyle": newVal = new FieldInfoClass { Name = "FacClassCode", Alias = "设施类编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "ObjectId", Alias = "唯一编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Name", Alias = "名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "StyleType", Alias = "风格类型", FieldType = gviFieldType.gviFieldString, Length = 50 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "StyleInfo", Alias = "风格信息", FieldType = gviFieldType.gviFieldBlob }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Thumbnail", Alias = "缩略图", FieldType = gviFieldType.gviFieldBlob }; infos.Add(newVal); arrDBIndex = new string[] { "FacClassCode", "ObjectId", "StyleType" }; return(infos); case "OC_ModelInfo": newVal = new FieldInfoClass { Name = "GroupId", Alias = "组编号", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "ObjectId", Alias = "唯一编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Name", Alias = "名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Code", Alias = "资源编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Thumbnail", Alias = "缩略图", FieldType = gviFieldType.gviFieldBlob }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Comment", Alias = "备注", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); arrDBIndex = new string[] { "GroupId", "ObjectId", "Name" }; return(infos); case "OC_TextureInfo": newVal = new FieldInfoClass { Name = "GroupId", Alias = "组编号", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "ObjectId", Alias = "唯一编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Name", Alias = "名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Code", Alias = "资源编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Thumbnail", Alias = "缩略图", FieldType = gviFieldType.gviFieldBlob }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Type", Alias = "类型", FieldType = gviFieldType.gviFieldString, Length = 50 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Comment", Alias = "备注", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); arrDBIndex = new string[] { "GroupId", "ObjectId", "Name" }; return(infos); case "OC_ColorInfo": newVal = new FieldInfoClass { Name = "GroupId", Alias = "组编号", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "ObjectId", Alias = "唯一编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Name", Alias = "名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Code", Alias = "资源编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Thumbnail", Alias = "缩略图", FieldType = gviFieldType.gviFieldBlob }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Type", Alias = "类型", FieldType = gviFieldType.gviFieldString, Length = 50 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Comment", Alias = "备注", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); arrDBIndex = new string[] { "GroupId", "ObjectId", "Name" }; return(infos); case "OC_FacilityClass": newVal = new FieldInfoClass { Name = "FacClassCode", Alias = "设施类编码", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Name", Alias = "名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "DataSetName", Alias = "数据集名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "FeatureClassId", Alias = "要素类ID", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "FcName", Alias = "要素类名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "DataType", Alias = "数据类型", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "FacilityType", Alias = "设施类类型", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass // 添加字段标定管线位置—地下\架空 FX 2014.04.01 { Name = "LocationType", Alias = "位置类型", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass // 添加字段标定拐角位置—直角\圆角 FX 2014.09.22 { Name = "TurnerStyle", Alias = "拐角类型", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "RenderStyle", Alias = "渲染样式", FieldType = gviFieldType.gviFieldBlob }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Comment", Alias = "备注", FieldType = gviFieldType.gviFieldString, Length = 300 }; infos.Add(newVal); arrDBIndex = new string[] { "FacClassCode", "FeatureClassId", "DataType", "FacilityType" }; return(infos); case "OC_TopoManage": newVal = new FieldInfoClass { Name = "ObjectId", Alias = "唯一编号", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "TopoLayerName", Alias = "拓扑层名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "TopoTableName", Alias = "拓扑信息表名称", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Tolerance", Alias = "容差值", FieldType = gviFieldType.gviFieldDouble }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "IgnoreZ", Alias = "空间建拓扑是否考虑Z", FieldType = gviFieldType.gviFieldInt16, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "ToleranceZ", Alias = "Z方向容差", FieldType = gviFieldType.gviFieldDouble }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Comment", Alias = "备注", FieldType = gviFieldType.gviFieldString, Length = 200 }; infos.Add(newVal); arrDBIndex = new string[] { "ObjectId", "TopoLayerName" }; return(infos); case "OC_TopoInfo": { newVal = new FieldInfoClass { Name = "GroupId", Alias = "逻辑组ID", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "A_FacClass", Alias = "边所在设施类", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Edge", Alias = "边对应的要素ID", FieldType = gviFieldType.gviFieldInt32 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "P_FacClass", Alias = "前点所在设施类", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "PNode", Alias = "前点要素ID", FieldType = gviFieldType.gviFieldInt32 }; infos.Add(newVal); newVal = new FieldInfoClass // FX 2014.04.03 { Name = "PDis", Alias = "前点距离", FieldType = gviFieldType.gviFieldDouble }; infos.Add(newVal); //-------------便于之后做退让判断20180305-------------- newVal = new FieldInfoClass { Name = "P_IsFusu", Alias = "前点是否具备风格", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); //----------------------------------------------------- newVal = new FieldInfoClass { Name = "E_FacClass", Alias = "后点所在设施类", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "E_FacClass", Alias = "后点所在设施类", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "ENode", Alias = "后点要素ID", FieldType = gviFieldType.gviFieldInt32 }; infos.Add(newVal); newVal = new FieldInfoClass // FX 2014.04.03 { Name = "EDis", Alias = "后点距离", FieldType = gviFieldType.gviFieldDouble }; infos.Add(newVal); //-------------便于之后做退让判断20180305-------------- newVal = new FieldInfoClass { Name = "E_IsFusu", Alias = "后点是否具备风格", FieldType = gviFieldType.gviFieldString, Length = 80 }; infos.Add(newVal); //----------------------------------------------------- newVal = new FieldInfoClass { Name = "ResistanceA", Alias = "正向权值", FieldType = gviFieldType.gviFieldInt16 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "ResistanceB", Alias = "反向权值", FieldType = gviFieldType.gviFieldInt16 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Length", Alias = "弧长", FieldType = gviFieldType.gviFieldDouble }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Topo_Error", Alias = "拓扑错误", FieldType = gviFieldType.gviFieldString, Length = 100 }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "LaseUpdate", Alias = "最后更新时间", FieldType = gviFieldType.gviFieldDate }; infos.Add(newVal); newVal = new FieldInfoClass { Name = "Geometry", Alias = "空间列", RegisteredRenderIndex = true, FieldType = gviFieldType.gviFieldGeometry }; IGeometryDef def = new GeometryDefClass { GeometryColumnType = gviGeometryColumnType.gviGeometryColumnPolyline, HasZ = true }; newVal.GeometryDef = def; infos.Add(newVal); arrDBIndex = new string[] { "GroupId", "A_FacClass", "Edge", "P_FacClass", "PNode", "E_FacClass", "ENode" }; return(infos); } } return(null); }
/// <inheritdoc /> public bool Equals(IFieldInfo other) { return Equals((object)other); }
public override IParamBuilder GetCondition(IFieldInfo field, string fieldValue) { string likeValue = string.Format(ObjectUtil.SysCulture, "%\"{0}\"%", fieldValue); return(SqlParamBuilder.CreateSingleSql(Context, field, "LIKE", likeValue)); }
private void toolStripMenuItemFieldInfo_Click(object sender, EventArgs e) { string fieldinfo_name = selectNode.Text; string fc_name = selectNode.Parent.Text; string set_name = selectNode.Parent.Parent.Text; myTreeNode node = (myTreeNode)selectNode.Parent.Parent.Parent; IConnectionInfo ci = node.con; IDataSource ds = null; IFeatureDataSet dataset = null; IFeatureClass fc = null; IFieldInfoCollection fieldinfos = null; try { ds = dsFactory.OpenDataSource(ci); dataset = ds.OpenFeatureDataset(set_name); fc = dataset.OpenFeatureClass(fc_name); fieldinfos = fc.GetFields(); for (int i = 0; i < fieldinfos.Count; i++) { IFieldInfo fieldinfo = fieldinfos.Get(i); if (null == fieldinfo) { continue; } if (fieldinfo_name == fieldinfo.Name) { FieldInfoForm form = new FieldInfoForm(fieldinfo); form.Show(); } } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (ds != null) { //Marshal.ReleaseComObject(ds); ds = null; } if (dataset != null) { //Marshal.ReleaseComObject(dataset); dataset = null; } if (fc != null) { //Marshal.ReleaseComObject(fc); fc = null; } if (fieldinfos != null) { //Marshal.ReleaseComObject(fieldinfos); fieldinfos = null; } } }
private void cbGlobe_CheckedChanged(object sender, EventArgs e) { if (cbGlobe.Checked) { // 重置RenderControl控件置为球 string tmpTedPath = (strMediaPath + @"\terrain\SingaporeGlobeTerrain.ted"); string wkt = this.axRenderControl1.GetTerrainCrsWKT(tmpTedPath, ""); this.axRenderControl1.Reset2(wkt); // 注册地形 this.axRenderControl1.Terrain.RegisterTerrain(tmpTedPath, ""); //this.axRenderControl1.Terrain.FlyTo(); cbUseEarthOrbitManipulator.Enabled = true; } else { // 重置RenderControl控件置为平面 string tmpTedPath = (strMediaPath + @"\terrain\SingaporePlanarTerrain.ted"); string wkt = this.axRenderControl1.GetTerrainCrsWKT(tmpTedPath, ""); this.axRenderControl1.Reset2(wkt); // 设置天空盒 if (System.IO.Directory.Exists(strMediaPath)) { string tmpSkyboxPath = strMediaPath + @"\skybox"; ISkyBox skybox = this.axRenderControl1.ObjectManager.GetSkyBox(0); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg"); } else { MessageBox.Show("请不要随意更改SDK目录名"); return; } // 注册地形 this.axRenderControl1.Terrain.RegisterTerrain(tmpTedPath, ""); //this.axRenderControl1.Terrain.FlyTo(); cbUseEarthOrbitManipulator.Enabled = false; } #region 加载FDB场景 try { IConnectionInfo ci = new ConnectionInfo(); ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x; string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB"); ci.Database = tmpFDBPath; IDataSourceFactory dsFactory = new DataSourceFactory(); IDataSource ds = dsFactory.OpenDataSource(ci); string[] setnames = (string[])ds.GetFeatureDatasetNames(); if (setnames.Length == 0) { return; } IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]); string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable); if (fcnames.Length == 0) { return; } fcMap = new Hashtable(fcnames.Length); foreach (string name in fcnames) { IFeatureClass fc = dataset.OpenFeatureClass(name); // 找到空间列字段 List <string> geoNames = new List <string>(); IFieldInfoCollection fieldinfos = fc.GetFields(); for (int i = 0; i < fieldinfos.Count; i++) { IFieldInfo fieldinfo = fieldinfos.Get(i); if (null == fieldinfo) { continue; } IGeometryDef geometryDef = fieldinfo.GeometryDef; if (null == geometryDef) { continue; } geoNames.Add(fieldinfo.Name); } fcMap.Add(fc, geoNames); } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); return; } // CreateFeautureLayer bool hasfly = false; foreach (IFeatureClass fc in fcMap.Keys) { List <string> geoNames = (List <string>)fcMap[fc]; foreach (string geoName in geoNames) { if (!geoName.Equals("Geometry")) { continue; } IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer( fc, geoName, null, null, rootId); if (!hasfly) { IFieldInfoCollection fieldinfos = fc.GetFields(); IFieldInfo fieldinfo = fieldinfos.Get(fieldinfos.IndexOf(geoName)); IGeometryDef geometryDef = fieldinfo.GeometryDef; IEnvelope env = geometryDef.Envelope; if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 && env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0)) { continue; } angle.Set(0, -20, 0); point = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ); point.SpatialCRS = fc.FeatureDataSet.SpatialReference; point.SetCoords(env.Center.X, env.Center.Y, env.Center.Z, 0, 0); this.axRenderControl1.Camera.LookAt2(point, 500, angle); } hasfly = true; } } #endregion }
public IList <RESULT> GetValues <RESULT, Entity>(IFieldInfo field, IConnectinContext cc, int pageindex, int pagesize) where Entity : Mappings.DataObject { return(GetValues <RESULT, Entity>(field, cc, new Region(pageindex, pagesize))); }
private void LayerFieldsPage_Load(object sender, EventArgs e) { this.listView1.ItemChecked += new ItemCheckedEventHandler(this.listView1_ItemChecked); if (this.ilayerFields_0 != null) { int num = -1; string displayField = ""; if (this.ilayer_0 is IFeatureLayer) { displayField = (this.ilayer_0 as IFeatureLayer).DisplayField; } else if (this.ilayer_0 is ITinLayer) { displayField = (this.ilayer_0 as ITinLayer).DisplayField; } try { string[] items = new string[5]; for (int i = 0; i < this.ilayerFields_0.FieldCount; i++) { IField field = this.ilayerFields_0.get_Field(i); IFieldInfo info = this.ilayerFields_0.get_FieldInfo(i); items[0] = field.Name; items[1] = info.Alias; items[2] = this.method_0(field.Type); items[3] = field.Length.ToString(); items[4] = field.Precision.ToString(); ListViewItem item = new ListViewItem(items) { Checked = info.Visible }; this.listView1.Items.Add(item); if (((field.Type != esriFieldType.esriFieldTypeGeometry) && (field.Type != esriFieldType.esriFieldTypeRaster)) && (field.Type != esriFieldType.esriFieldTypeBlob)) { this.cboFields.Properties.Items.Add(field.Name); if (field.Name == displayField) { num = this.cboFields.Properties.Items.Count - 1; } } } } catch { } this.listView1.ValueChanged += new ValueChangedHandler(this.method_2); if (displayField.Length == 0) { this.cboFields.Enabled = false; this.cboFields.Text = ""; } else { this.cboFields.Enabled = true; this.cboFields.SelectedIndex = num; } this.bool_1 = true; } }
public SFZConstraint(IFieldInfo field) : base(field, field.DisplayName + TkWebApp.SFZCMsg, @"^\d{15}$|^\d{17}[0-9x]$", RegexOptions.IgnoreCase) { }
public static RegNameList <ListTabSheet> CreateTabSheets(this CodeTable codeTable, TkDbContext context, IFieldInfo field) { DataSet ds = new DataSet() { Locale = ObjectUtil.SysCulture }; using (ds) { codeTable.Fill(ds, context); if (ds.Tables.Count == 0) { return(null); } DataTable table = ds.Tables[0]; if (table.Rows.Count == 0) { return(null); } RegNameList <ListTabSheet> result = new RegNameList <ListTabSheet>(); foreach (DataRow row in table.Rows) { object value = row[DecoderConst.CODE_NICK_NAME]; IParamBuilder builder = SqlParamBuilder.CreateEqualSql(context, field, value); ListTabSheet tab = new ListTabSheet(value.ToString(), row[DecoderConst.NAME_NICK_NAME].ToString(), builder); result.Add(tab); } return(result); } }
/// <summary> /// 添加数据源 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addDatasourceToolStripButton_Click(object sender, EventArgs e) { OpenDataSourceForm dsForm = new OpenDataSourceForm(false); if (dsForm.ShowDialog() != DialogResult.OK) { return; } IConnectionInfo ci = new ConnectionInfo(); switch (dsForm.ConnectionType) { case "gviConnectionMySql5x": ci.ConnectionType = gviConnectionType.gviConnectionMySql5x; break; case "gviConnectionFireBird2x": ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x; break; case "gviConnectionSQLite3": ci.ConnectionType = gviConnectionType.gviConnectionSQLite3; break; } ci.Server = dsForm.Server; ci.Port = dsForm.Port; ci.Database = dsForm.Database; ci.UserName = dsForm.UserName; ci.Password = dsForm.Password; IDataSource ds = null; IFeatureDataSet dataset = null; IFeatureClass fc = null; try { if (dsFactory == null) { dsFactory = new DataSourceFactory(); } ds = dsFactory.OpenDataSource(ci); myTreeNode sourceNode = null; if (ci.ConnectionType == gviConnectionType.gviConnectionMySql5x) { sourceNode = new myTreeNode(ci.Database + "@" + ci.Server, ci); } else { sourceNode = new myTreeNode(ci.Database, ci); } sourceNode.ContextMenuStrip = this.contextMenuStrip1; this.treeView1.Nodes.Add(sourceNode); // 获取dataset string[] setnames = (string[])ds.GetFeatureDatasetNames(); if (setnames.Length == 0) { return; } foreach (string setname in setnames) { dataset = ds.OpenFeatureDataset(setname); TreeNode setNode = new TreeNode(setname, 1, 1); setNode.ContextMenuStrip = this.contextMenuStrip2; sourceNode.Nodes.Add(setNode); // 获取featureclass string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable); if (fcnames == null || fcnames.Length == 0) { continue; } foreach (string fcname in fcnames) { fc = dataset.OpenFeatureClass(fcname); TreeNode fcNode = new TreeNode(fcname, 2, 2); fcNode.ContextMenuStrip = this.contextMenuStrip3; setNode.Nodes.Add(fcNode); // 获取属性字段 IFieldInfoCollection fieldinfos = fc.GetFields(); for (int i = 0; i < fieldinfos.Count; i++) { IFieldInfo fieldinfo = fieldinfos.Get(i); if (null == fieldinfo) { continue; } TreeNode fieldinfoNode = new TreeNode(fieldinfo.Name); fieldinfoNode.ContextMenuStrip = this.contextMenuStrip4; // 绑定右键菜单 fcNode.Nodes.Add(fieldinfoNode); } } } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (ds != null) { //Marshal.ReleaseComObject(ds); ds = null; } if (dataset != null) { //Marshal.ReleaseComObject(dataset); dataset = null; } if (fc != null) { //Marshal.ReleaseComObject(fc); fc = null; } } }
public override FieldInfo Wrap(IFieldInfo adapter) { return new UnresolvedFieldInfo(adapter); }
private void GetData() { if (this.cbLayer.SelectedItem == null) { return; } DF3DFeatureClass dffc = this.cbLayer.SelectedItem as DF3DFeatureClass; if (dffc == null) { return; } IFeatureClass fc = dffc.GetFeatureClass(); if (fc == null) { return; } if (_num > _count || _count == 0) { return; } ISpatialFilter filter = this._filter; filter.ResultBeginIndex = _num - 1; filter.ResultLimit = 1; IFdeCursor cursor = null; IRowBuffer row = null; try { cursor = fc.Search(filter, false); if ((row = cursor.NextRow()) != null) { #region 定位 int geoindex = row.FieldIndex("Geometry"); DF3DApplication app = DF3DApplication.Application; if (geoindex != -1 && !row.IsNull(geoindex) && app != null && app.Current3DMapControl != null) { ISurfaceSymbol ss = new SurfaceSymbolClass(); ss.Color = 0xcc00ff00; ICurveSymbol cs = new CurveSymbolClass(); cs.Color = 0xff00ff00; cs.Width = -5; ss.BoundarySymbol = cs; ISimplePointSymbol ps = new SimplePointSymbol(); ps.Size = SystemInfo.Instance.SymbolSize; ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16); IGeometry geo = row.GetValue(geoindex) as IGeometry; IPoint ptTL = null; if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline) { double x = 0; double y = 0; double z = 0; IMultiPolyline mPolyline = geo as IMultiPolyline; for (int m = 0; m < mPolyline.GeometryCount; m++) { IPolyline polyline = mPolyline.GetPolyline(m); IPoint pttemp = polyline.Midpoint; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolyline.GeometryCount; y = y / mPolyline.GeometryCount; z = z / mPolyline.GeometryCount; ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptTL.X = x; ptTL.Y = y; ptTL.Z = z; IRenderMultiPolyline rMPolyline = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolyline(mPolyline, cs, app.Current3DMapControl.ProjectTree.RootID); rMPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolyline.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rMPolyline.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rMPolyline.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolygon) { double x = 0; double y = 0; double z = 0; IMultiPolygon mPolygon = geo as IMultiPolygon; for (int m = 0; m < mPolygon.GeometryCount; m++) { IPolygon polygon = mPolygon.GetPolygon(m); IPoint pttemp = polygon.Centroid; x += pttemp.X; y += pttemp.Y; z += pttemp.Z; } x = x / mPolygon.GeometryCount; y = y / mPolygon.GeometryCount; z = z / mPolygon.GeometryCount; ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); ptTL.X = x; ptTL.Y = y; ptTL.Z = z; IRenderMultiPolygon rMPolygon = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(mPolygon, ss, app.Current3DMapControl.ProjectTree.RootID); rMPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rMPolygon.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rMPolygon.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rMPolygon.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryPolyline) { IPolyline polyline = geo as IPolyline; ptTL = polyline.Midpoint; IRenderPolyline rPolyline = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID); rPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolyline.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rPolyline.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rPolyline.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryPoint) { IPoint point = geo as IPoint; ptTL = point; IRenderPoint rPoint = app.Current3DMapControl.ObjectManager.CreateRenderPoint(point, ps, app.Current3DMapControl.ProjectTree.RootID); rPoint.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rPoint.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rPoint.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryPolygon) { IPolygon polygon = geo as IPolygon; ptTL = polygon.Centroid; IRenderPolygon rPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon, ss, app.Current3DMapControl.ProjectTree.RootID); rPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything; rPolygon.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(rPolygon.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(rPolygon.Guid, gviActionCode.gviActionJump); } else if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint) { ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ); IModelPoint mp = geo as IModelPoint; ptTL.X = mp.X; ptTL.Y = mp.Y; ptTL.Z = mp.Z; IModelPointSymbol mps = new ModelPointSymbol(); mps.SetResourceDataSet(fc.FeatureDataSet); IRenderGeometry render = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(mp, mps, app.Current3DMapControl.ProjectTree.RootID); render.Glow(8000); app.Current3DMapControl.ObjectManager.DelayDelete(render.Guid, 8000); app.Current3DMapControl.Camera.FlyToObject(render.Guid, gviActionCode.gviActionJump); } if (ptTL != null) { ITableLabel tl = DrawTool.CreateTableLabel1(1); tl.TitleText = "属性查询"; tl.SetRecord(0, 0, dffc.ToString()); if (ptTL != null) { tl.Position = ptTL; } app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo); app.Current3DMapControl.ObjectManager.DelayDelete(tl.Guid, 8000); } } #endregion FacilityClass facc = dffc.GetFacilityClass(); if (facc == null) { IFieldInfoCollection fiCol = fc.GetFields(); for (int i = 0; i < fiCol.Count; i++) { IFieldInfo fi = fiCol.Get(i); object obj = row.GetValue(i); string str = ""; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: continue; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } DataRow dr = this._dtShow.NewRow(); dr["Property"] = string.IsNullOrEmpty(fi.Alias) ? fi.Name : fi.Alias; dr["Value"] = str; this._dtShow.Rows.Add(dr); } } else { List <DFDataConfig.Class.FieldInfo> facFields = facc.FieldInfoCollection; if (facFields != null) { foreach (DFDataConfig.Class.FieldInfo facField in facFields) { if (!facField.CanQuery) { continue; } int index = row.FieldIndex(facField.Name); if (index != -1 && !row.IsNull(index)) { object obj = row.GetValue(index); string str = ""; IFieldInfo fiFC = row.Fields.Get(index); switch (fiFC.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldUnknown: case gviFieldType.gviFieldGeometry: continue; case gviFieldType.gviFieldFloat: case gviFieldType.gviFieldDouble: double d; if (double.TryParse(obj.ToString(), out d)) { str = d.ToString("0.00"); } break; default: str = obj.ToString(); break; } DataRow dr = this._dtShow.NewRow(); dr["Property"] = facField.ToString(); dr["Value"] = str; this._dtShow.Rows.Add(dr); } } } } } } catch (Exception ex) { } finally { if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } if (row != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(row); row = null; } } }
private void AddRecord() { try { this.beforeRowBufferMap.Clear(); SelectCollection.Instance().Clear(); DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } IFeatureLayer fl = featureClassInfo.GetFeatureLayer(); if (fl == null) { return; } IFieldInfoCollection fields = fc.GetFields(); int indexGeo = fields.IndexOf(fl.GeometryFieldName); if (indexGeo == -1) { return; } IFieldInfo fiGeo = fields.Get(indexGeo); if (fiGeo == null || fiGeo.GeometryDef == null) { return; } IGeometry geo = this._drawTool.GetGeo(); if (geo.GeometryType != gviGeometryType.gviGeometryPoint) { return; } IPoint pt = geo as IPoint; IPoint geoOut = pt.Clone2(fiGeo.GeometryDef.VertexAttribute) as IPoint; if (fiGeo.GeometryDef.HasZ) { geoOut.SetCoords(pt.X, pt.Y, pt.Z, 0, 0); } else { geoOut.SetCoords(pt.X, pt.Y, 0, 0, 0); } IRowBufferCollection rowCol = new RowBufferCollection(); IRowBufferFactory fac = new RowBufferFactory(); IRowBuffer row = fac.CreateRowBuffer(fields); row.SetValue(indexGeo, geoOut); foreach (DataRow dr in this._dt.Rows) { IFieldInfo fi = dr["F"] as IFieldInfo; if (fi == null) { continue; } string fn = fi.Name; int index = fields.IndexOf(fn); if (index != -1) { if (dr["FV"] == null) { row.SetNull(index); } else { string strobj = dr["FV"].ToString(); bool bRes = false; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: break; case gviFieldType.gviFieldFloat: float f; bRes = float.TryParse(strobj, out f); if (bRes) { row.SetValue(index, f); } else { row.SetNull(index); } break; case gviFieldType.gviFieldDouble: double d; bRes = double.TryParse(strobj, out d); if (bRes) { row.SetValue(index, d); } else { row.SetNull(index); } break; case gviFieldType.gviFieldFID: case gviFieldType.gviFieldUUID: case gviFieldType.gviFieldInt16: Int16 i16; bRes = Int16.TryParse(strobj, out i16); if (bRes) { row.SetValue(index, i16); } else { row.SetNull(index); } break; case gviFieldType.gviFieldInt32: Int32 i32; bRes = Int32.TryParse(strobj, out i32); if (bRes) { row.SetValue(index, i32); } else { row.SetNull(index); } break; case gviFieldType.gviFieldInt64: Int64 i64; bRes = Int64.TryParse(strobj, out i64); if (bRes) { row.SetValue(index, i64); } else { row.SetNull(index); } break;; case gviFieldType.gviFieldString: row.SetValue(index, strobj); break; case gviFieldType.gviFieldDate: DateTime dt; bRes = DateTime.TryParse(strobj, out dt); if (bRes) { row.SetValue(index, dt); } else { row.SetNull(index); } break; default: break; } } } } rowCol.Add(row); beforeRowBufferMap[featureClassInfo] = rowCol; UpdateDatabase(); } catch (Exception ex) { } }
private void DrawEnvelope(int fid, IFeatureClass fc, out ArrayList rPolylineList) { rPolylineList = new ArrayList(); string filterString = string.Format("oid={0}", fid); IQueryFilter filter = new QueryFilter(); filter.WhereClause = filterString; IFdeCursor cursor = null; try { cursor = fc.Search(filter, true); if (cursor != null) { IRowBuffer fdeRow = null; while ((fdeRow = cursor.NextRow()) != null) { IFieldInfoCollection col = fdeRow.Fields; for (int i = 0; i < col.Count; ++i) { IFieldInfo info = col.Get(i); if (info.GeometryDef != null && info.GeometryDef.GeometryColumnType == gviGeometryColumnType.gviGeometryColumnModelPoint) { int nPos = fdeRow.FieldIndex(info.Name); IModelPoint mp = fdeRow.GetValue(nPos) as IModelPoint; IEnvelope env = mp.Envelope; IPolyline polyline = new GeometryFactory().CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline; polyline.SpatialCRS = fc.FeatureDataSet.SpatialReference; IPoint point = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ); point.SpatialCRS = fc.FeatureDataSet.SpatialReference; ISimplePointSymbol psy = new SimplePointSymbol(); psy.FillColor = System.Drawing.Color.Yellow; psy.Size = 10; ICurveSymbol cSymbol = new CurveSymbol(); cSymbol.Color = System.Drawing.Color.Yellow; cSymbol.Width = 2; point.SetCoords(env.MinX, env.MinY, env.MinZ, 0, 0); //0 //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy); polyline.AppendPoint(point); point.SetCoords(env.MaxX, env.MinY, env.MinZ, 0, 1); //1 //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy); polyline.AppendPoint(point); point.SetCoords(env.MaxX, env.MaxY, env.MinZ, 0, 2); //2 //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy); polyline.AppendPoint(point); point.SetCoords(env.MinX, env.MaxY, env.MinZ, 0, 3); //3 //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy); polyline.AppendPoint(point); point.SetCoords(env.MinX, env.MinY, env.MinZ, 0, 4); //0 polyline.AppendPoint(point); //close rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId)); polyline.SetEmpty(); point.SetCoords(env.MinX, env.MaxY, env.MaxZ, 0, 0); //4 //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy); polyline.AppendPoint(point); point.SetCoords(env.MaxX, env.MaxY, env.MaxZ, 0, 0); //5 //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy); polyline.AppendPoint(point); point.SetCoords(env.MaxX, env.MinY, env.MaxZ, 0, 0); //6 //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy); polyline.AppendPoint(point); point.SetCoords(env.MinX, env.MinY, env.MaxZ, 0, 0); //7 //this.axRenderControl1.ObjectManager.CreateRenderPoint(point, psy); polyline.AppendPoint(point); point.SetCoords(env.MinX, env.MaxY, env.MaxZ, 0, 0); //4 polyline.AppendPoint(point); //close rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId)); polyline.SetEmpty(); point.SetCoords(env.MinX, env.MinY, env.MinZ, 0, 0); //0 polyline.AppendPoint(point); point.SetCoords(env.MinX, env.MinY, env.MaxZ, 0, 0); //7 polyline.AppendPoint(point); rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId)); polyline.SetEmpty(); point.SetCoords(env.MaxX, env.MinY, env.MinZ, 0, 0); //1 polyline.AppendPoint(point); point.SetCoords(env.MaxX, env.MinY, env.MaxZ, 0, 0); //6 polyline.AppendPoint(point); rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId)); polyline.SetEmpty(); point.SetCoords(env.MaxX, env.MaxY, env.MinZ, 0, 0); //2 polyline.AppendPoint(point); point.SetCoords(env.MaxX, env.MaxY, env.MaxZ, 0, 0); //5 polyline.AppendPoint(point); rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId)); polyline.SetEmpty(); point.SetCoords(env.MinX, env.MaxY, env.MinZ, 0, 0); //3 polyline.AppendPoint(point); point.SetCoords(env.MinX, env.MaxY, env.MaxZ, 0, 0); //4 polyline.AppendPoint(point); rPolylineList.Add(this.axRenderControl1.ObjectManager.CreateRenderPolyline(polyline, cSymbol, rootId)); } } } } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (cursor != null) { //Marshal.ReleaseComObject(cursor); cursor = null; } } }
private void LoadProperty() { try { DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } IFieldInfoCollection fiCol = fc.GetFields(); if (fiCol == null) { return; } FacilityClass fac = featureClassInfo.GetFacilityClass(); if (fac == null) { for (int i = 0; i < fiCol.Count; i++) { IFieldInfo fi = fiCol.Get(i); if (fi == null) { continue; } if (fi.Name == fc.FidFieldName) { continue; } if (fi.Name == this._classifyName) { continue; } if (fi.Name.ToLower() == "groupid") { continue; } switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: continue; //case gviFieldType.gviFieldFloat: //case gviFieldType.gviFieldDouble: // break; //case gviFieldType.gviFieldFID: //case gviFieldType.gviFieldUUID: //case gviFieldType.gviFieldInt16: //case gviFieldType.gviFieldInt32: //case gviFieldType.gviFieldInt64: // break; //case gviFieldType.gviFieldString: // break; //case gviFieldType.gviFieldDate: default: DataRow dr = this._dt.NewRow(); dr["FN"] = string.IsNullOrEmpty(fi.Alias) ? fi.Name : fi.Alias; dr["FV"] = null; if (fi.Name.ToLower() == "standard") { this._diameterName = "standard"; dr["FV"] = "1000"; } dr["F"] = fi; this._dt.Rows.Add(dr); break; } } } else { List <DFDataConfig.Class.FieldInfo> list = fac.FieldInfoCollection; if (list != null) { foreach (DFDataConfig.Class.FieldInfo fi1 in list) { if (!fi1.CanQuery) { continue; } int index = fiCol.IndexOf(fi1.Name); if (index == -1) { continue; } IFieldInfo fi = fiCol.Get(index); if (fi == null) { continue; } if (fi.Name == this._classifyName) { continue; } if (fi.Name.ToLower() == "groupid") { continue; } switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: continue; //case gviFieldType.gviFieldFloat: //case gviFieldType.gviFieldDouble: // break; //case gviFieldType.gviFieldFID: //case gviFieldType.gviFieldUUID: //case gviFieldType.gviFieldInt16: //case gviFieldType.gviFieldInt32: //case gviFieldType.gviFieldInt64: // break; //case gviFieldType.gviFieldString: // break; //case gviFieldType.gviFieldDate: default: DataRow dr = this._dt.NewRow(); dr["FN"] = fi1.ToString(); dr["FV"] = null; if (fi1.SystemName == "Diameter") { this._diameterName = fi1.Name; dr["FV"] = "1000"; } dr["F"] = fi; this._dt.Rows.Add(dr); break; } } } } } catch (Exception ex) { } }
// 初始化表结构 public DataTable CreateDataTable(IFeatureClass fc) { DataTable dt = new DataTable(); if (fc != null) { IFieldInfoCollection fInfoColl = fc.GetFields(); DataColumn dc = null; for (int i = 0; i < fInfoColl.Count; ++i) { IFieldInfo fInfo = fInfoColl.Get(i); if (fInfo.FieldType == gviFieldType.gviFieldGeometry || fInfo.FieldType == gviFieldType.gviFieldBlob) { continue; } dc = new DataColumn(fInfo.Name); switch (fInfo.FieldType) { case gviFieldType.gviFieldInt16: { dc.DataType = typeof(Int16); } break; case gviFieldType.gviFieldInt32: { dc.DataType = typeof(Int32); } break; case gviFieldType.gviFieldFID: { dc.DataType = typeof(Int32); dc.ReadOnly = true; } break; case gviFieldType.gviFieldInt64: dc.DataType = typeof(Int64); break; case gviFieldType.gviFieldString: case gviFieldType.gviFieldUUID: dc.DataType = typeof(String); break; case gviFieldType.gviFieldFloat: { dc.DataType = typeof(float); } break; case gviFieldType.gviFieldDouble: dc.DataType = typeof(Double); break; case gviFieldType.gviFieldDate: dc.DataType = typeof(DateTime); break; case gviFieldType.gviFieldGeometry: dc.DataType = typeof(object); break; default: dc.DataType = typeof(string); break; } dt.Columns.Add(dc); } dt.DefaultView.Sort = "oid asc"; } return(dt); }
private void AddRecord() { try { this.beforeRowBufferMap.Clear(); SelectCollection.Instance().Clear(); if (reg == null || tc == null) { return; } FacStyleClass style = this.cmbStyle.EditValue as FacStyleClass; if (style == null) { return; } SubClass sc = this.cmbClassify.EditValue as SubClass; DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } IResourceManager manager = fc.FeatureDataSet as IResourceManager; if (manager == null) { return; } IFeatureLayer fl = featureClassInfo.GetFeatureLayer(); if (fl == null) { return; } IFieldInfoCollection fields = fc.GetFields(); int indexOid = fields.IndexOf(fc.FidFieldName); if (indexOid == -1) { return; } int mpindex = fields.IndexOf(fl.GeometryFieldName); if (mpindex == -1) { return; } int indexShape = fields.IndexOf("Shape"); if (indexShape == -1) { return; } int indexFootPrint = fields.IndexOf("FootPrint"); if (indexFootPrint == -1) { return; } int indexStyleId = fields.IndexOf("StyleId"); if (indexStyleId == -1) { return; } int indexFacilityId = fields.IndexOf("FacilityId"); if (indexFacilityId == -1) { return; } IFieldInfo fiShape = fields.Get(indexShape); if (fiShape == null || fiShape.GeometryDef == null) { return; } IGeometry geo = this._drawTool.GetGeo(); if (geo.GeometryType != gviGeometryType.gviGeometryPolyline) { return; } IPolyline line = geo as IPolyline; IPolyline geoOut = this._geoFact.CreateGeometry(gviGeometryType.gviGeometryPolyline, fiShape.GeometryDef.VertexAttribute) as IPolyline; for (int i = 0; i < line.PointCount; i++) { IPoint ptGet = line.GetPoint(i); IPoint pttemp = ptGet.Clone2(fiShape.GeometryDef.VertexAttribute) as IPoint; if (fiShape.GeometryDef.HasZ) { pttemp.SetCoords(ptGet.X, ptGet.Y, ptGet.Z, 0, 0); } else { pttemp.SetCoords(ptGet.X, ptGet.Y, 0, 0, 0); } geoOut.AppendPoint(pttemp); } IQueryFilter filter = new QueryFilter(); filter.WhereClause = "1=1"; filter.ResultBeginIndex = 0; filter.ResultLimit = 1; filter.PostfixClause = "ORDER BY " + fc.FidFieldName + " desc"; IFdeCursor cursor = null; cursor = fc.Search(filter, false); IRowBuffer rowtemp = cursor.NextRow(); int oid = 0; if (rowtemp != null) { oid = int.Parse(rowtemp.GetValue(indexOid).ToString()); } if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } IRowBufferFactory fac = new RowBufferFactory(); IRowBuffer row = fac.CreateRowBuffer(fields); row.SetValue(indexOid, oid + 1); row.SetValue(indexShape, geoOut); row.SetValue(indexFootPrint, geoOut.Clone2(gviVertexAttribute.gviVertexAttributeNone)); row.SetValue(indexStyleId, style.ObjectId); row.SetValue(indexFacilityId, BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant()); if (sc != null) { int indexClassify = fields.IndexOf(this._classifyName); int indexGroupId = fields.IndexOf("GroupId"); if (indexClassify != -1 && indexGroupId != -1) { row.SetValue(indexClassify, sc.Name); row.SetValue(indexGroupId, sc.GroupId); } } foreach (DataRow dr in this._dt.Rows) { IFieldInfo fi = dr["F"] as IFieldInfo; if (fi == null) { continue; } string fn = fi.Name; int index = fields.IndexOf(fn); if (index != -1) { if (dr["FV"] == null) { row.SetNull(index); } else { string strobj = dr["FV"].ToString(); bool bRes = false; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: break; case gviFieldType.gviFieldFloat: float f; bRes = float.TryParse(strobj, out f); if (bRes) { row.SetValue(index, f); } else { row.SetNull(index); } break; case gviFieldType.gviFieldDouble: double d; bRes = double.TryParse(strobj, out d); if (bRes) { row.SetValue(index, d); } else { row.SetNull(index); } break; case gviFieldType.gviFieldFID: case gviFieldType.gviFieldUUID: case gviFieldType.gviFieldInt16: Int16 i16; bRes = Int16.TryParse(strobj, out i16); if (bRes) { row.SetValue(index, i16); } else { row.SetNull(index); } break; case gviFieldType.gviFieldInt32: Int32 i32; bRes = Int32.TryParse(strobj, out i32); if (bRes) { row.SetValue(index, i32); } else { row.SetNull(index); } break; case gviFieldType.gviFieldInt64: Int64 i64; bRes = Int64.TryParse(strobj, out i64); if (bRes) { row.SetValue(index, i64); } else { row.SetNull(index); } break; case gviFieldType.gviFieldString: row.SetValue(index, strobj); break; case gviFieldType.gviFieldDate: DateTime dt; bRes = DateTime.TryParse(strobj, out dt); if (bRes) { row.SetValue(index, dt); } else { row.SetNull(index); } break; default: break; } } } } Fac plf = new PipeLineFac(reg, style, row, tc, false, false); IModelPoint mp = null; IModel finemodel = null; IModel simplemodel = null; string name = ""; if (UCAuto3DCreate.RebuildModel(plf, style, out mp, out finemodel, out simplemodel, out name)) { if (finemodel == null || mp == null) { return; } mp.ModelEnvelope = finemodel.Envelope; row.SetValue(mpindex, mp); //if (mc != null) //{ // if (indexClassify != -1 && indexGroupid != -1) // { // } //} bool bRes = false; if (!string.IsNullOrEmpty(mp.ModelName)) { if (!manager.ModelExist(mp.ModelName)) { if (manager.AddModel(mp.ModelName, finemodel, simplemodel)) { bRes = true; } } else { if (manager.UpdateModel(mp.ModelName, finemodel) && manager.UpdateSimplifiedModel(mp.ModelName, simplemodel)) { bRes = true; } } } if (!bRes) { return; } IRowBufferCollection rowCol = new RowBufferCollection(); rowCol.Add(row); beforeRowBufferMap[featureClassInfo] = rowCol; UpdateDatabase(); app.Current3DMapControl.FeatureManager.RefreshFeatureClass(fc); } } catch (Exception ex) { } }
protected bool IsGeneratedByTheCompiler(IFieldInfo field) { // for example fields backing autoproperties //return Attribute.IsDefined(field, typeof(CompilerGeneratedAttribute)); return field.IsDefined(typeof(CompilerGeneratedAttribute)); }
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { try { if (e.RowHandle == -1) { return; } if (e.Column.FieldName == "FV") { DataRow dr = this.gridView1.GetDataRow(e.RowHandle); IFieldInfo fi = dr["F"] as IFieldInfo; if (fi != null) { string strobj = e.Value.ToString(); bool bRes = false; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: break; case gviFieldType.gviFieldFloat: float f; bRes = float.TryParse(strobj, out f); if (bRes) { dr["FV"] = strobj; } else { dr["FV"] = null; } break; case gviFieldType.gviFieldDouble: double d; bRes = double.TryParse(strobj, out d); if (bRes) { dr["FV"] = strobj; } else { dr["FV"] = null; } break; case gviFieldType.gviFieldFID: case gviFieldType.gviFieldUUID: case gviFieldType.gviFieldInt16: Int16 i16; bRes = Int16.TryParse(strobj, out i16); if (bRes) { dr["FV"] = strobj; } else { dr["FV"] = null; } break; case gviFieldType.gviFieldInt32: Int32 i32; bRes = Int32.TryParse(strobj, out i32); if (bRes) { dr["FV"] = strobj; } else { dr["FV"] = null; } break; case gviFieldType.gviFieldInt64: Int64 i64; bRes = Int64.TryParse(strobj, out i64); if (bRes) { dr["FV"] = strobj; } else { dr["FV"] = null; } break;; case gviFieldType.gviFieldString: if (this._diameterName == fi.Name && !ValidateDiameter(strobj)) { dr["FV"] = "1000"; } dr["FV"] = strobj; break; case gviFieldType.gviFieldDate: DateTime dt; bRes = DateTime.TryParse(strobj, out dt); if (bRes) { dr["FV"] = strobj; } else { dr["FV"] = null; } break; default: break; } this.gridView1.RefreshRow(e.RowHandle); } } } catch (Exception ex) { } }
/// <summary> /// 构建关联表 /// </summary> /// <param name="left">左表字段</param> /// <param name="right">右表字段</param> /// <param name="type">关联类型</param> public JoinTable(IFieldInfo left, IFieldInfo right,JoinType type) { mTable.AppendFormat(" {0} {1} {2} on {0}.{3}={2}.{4} ", left.Table, Jions[(int)type], right.Table, left.Name, right.Name); }
// 公共方法 void FeatureLayerVisualize(IConnectionInfo ci, bool needfly, string sourceName) { try { IDataSourceFactory dsFactory = new DataSourceFactory(); IDataSource ds = dsFactory.OpenDataSource(ci); string[] setnames = (string[])ds.GetFeatureDatasetNames(); if (setnames.Length == 0) { return; } IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]); string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable); if (fcnames.Length == 0) { return; } fcMap = new Hashtable(fcnames.Length); foreach (string name in fcnames) { IFeatureClass fc = dataset.OpenFeatureClass(name); _featureClass = fc; // 找到空间列字段 List <string> geoNames = new List <string>(); IFieldInfoCollection fieldinfos = fc.GetFields(); for (int i = 0; i < fieldinfos.Count; i++) { IFieldInfo fieldinfo = fieldinfos.Get(i); if (null == fieldinfo) { continue; } IGeometryDef geometryDef = fieldinfo.GeometryDef; if (null == geometryDef) { continue; } geoNames.Add(fieldinfo.Name); } fcMap.Add(fc, geoNames); } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); return; } // CreateFeautureLayer bool hasfly = !needfly; foreach (IFeatureClass fc in fcMap.Keys) { List <string> geoNames = (List <string>)fcMap[fc]; foreach (string geoName in geoNames) { IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer( fc, geoName, null, null, rootId); IFieldInfoCollection fieldinfos = fc.GetFields(); IFieldInfo fieldinfo = fieldinfos.Get(fieldinfos.IndexOf(geoName)); IGeometryDef geometryDef = fieldinfo.GeometryDef; IEnvelope env = geometryDef.Envelope; if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 && env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0)) { continue; } // 相机飞入 if (!hasfly) { IEulerAngle angle = new EulerAngle(); angle.Set(0, -20, 0); this.axRenderControl1.Camera.LookAt(env.Center, 1000, angle); } hasfly = true; } } }
/// <summary> /// 右联到指定的表字段 /// </summary> /// <param name="left">左表字段</param> /// <param name="right">右表字段</param> /// <returns>JoinTable</returns> public JoinTable RightJoin(IFieldInfo left, IFieldInfo right) { Join(left, right, JoinType.Right); return this; }
/// <summary>Creates a new IEntityField instance for usage in the EntityFields object for the EffectEntity. Which EntityField is created is specified by fieldIndex</summary> /// <param name="fieldIndex">The field which IEntityField instance should be created</param> /// <returns>The IEntityField instance for the field specified in fieldIndex</returns> public static IEntityField Create(EffectFieldIndex fieldIndex) { IFieldInfo info = FieldInfoProviderSingleton.GetInstance().GetFieldInfo("EffectEntity", (int)fieldIndex); return(new EntityField(info, PersistenceInfoProviderSingleton.GetInstance().GetFieldPersistenceInfo(info.ContainingObjectName, info.Name))); }
public static SyncVersion AddField(this SyncVersion syncItem, IFieldInfo field, string value) { syncItem.AddField(field.FieldId, field.Name, field.Key, value, true); return syncItem; }
/// <summary> /// Returns true if the field is assignable as a named attribute parameter. /// </summary> /// <param name="field">The field.</param> /// <returns>True if the field is assignable.</returns> public static bool IsAttributeField(IFieldInfo field) { return(!field.IsLiteral && !field.IsInitOnly && !field.IsStatic); }
private static DocumentedField MapField(IFieldInfo field, XmlDocumentationModel xmlModel) { SummaryComment summary = null; RemarksComment remarks = null; IEnumerable<ExampleComment> examples = null; // Get the documentation for the type. var member = xmlModel.Find(field.Identity); if (member != null) { // Get the comments for the type. summary = member.Comments.OfType<SummaryComment>().SingleOrDefault(); remarks = member.Comments.OfType<RemarksComment>().SingleOrDefault(); examples = member.Comments.OfType<ExampleComment>(); } return new DocumentedField(field, summary, remarks, examples, field.Metadata); }
private void toolStripButtonEditFeature_Click(object sender, EventArgs e) { this.dataGridView1.EndEdit(); //强制提交 if (dsFactory == null) { dsFactory = new DataSourceFactory(); } IDataSource ds = null; IFeatureDataSet dataset = null; IFeatureClass fc = null; IFdeCursor cursor = null; IFieldInfo field = null; try { if (dataGridView1.SelectedRows.Count == 1) { ds = dsFactory.OpenDataSource(Info.ci); dataset = ds.OpenFeatureDataset(Info.datasetName); fc = dataset.OpenFeatureClass(Info.featureclassName); // 比较是否修改了记录 int oid = int.Parse(dataGridView1.SelectedRows[0].Cells["oid"].Value.ToString()); IRowBuffer fdeRow = fc.GetRow(oid); bool isChanged = false; for (int i = 0; i < AttriTable.Columns.Count; ++i) { string strColName = AttriTable.Columns[i].ColumnName; int nPos = fdeRow.FieldIndex(strColName); if (nPos != -1) { field = fdeRow.Fields.Get(nPos); } if (nPos != -1 && strColName != "oid" && strColName != "GroupName" && field.FieldType != gviFieldType.gviFieldGeometry) { if (fdeRow.GetValue(nPos) == null || (!dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[i].EditedFormattedValue.Equals(fdeRow.GetValue(nPos).ToString()))) { isChanged = true; break; } } } if (!isChanged) { MessageBox.Show("该条记录无改动"); return; } for (int j = 0; j < AttriTable.Columns.Count; ++j) { string strColName = AttriTable.Columns[j].ColumnName; int nPos = fdeRow.FieldIndex(strColName); if (nPos != -1) { field = fdeRow.Fields.Get(nPos); } if (nPos != -1 && strColName != "oid" && strColName != "GroupName" && field.FieldType != gviFieldType.gviFieldGeometry) { fdeRow.SetValue(nPos, dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells[j].EditedFormattedValue); //插入字段值 } } // 修改数据库中记录 IRowBufferCollection col = new RowBufferCollection(); col.Add(fdeRow); fc.UpdateRows(col, false); MessageBox.Show("修改成功"); } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } finally { if (ds != null) { //Marshal.ReleaseComObject(ds); ds = null; } if (dataset != null) { //Marshal.ReleaseComObject(dataset); dataset = null; } if (fc != null) { //Marshal.ReleaseComObject(fc); fc = null; } if (cursor != null) { //Marshal.ReleaseComObject(cursor); cursor = null; } } }
/// <summary> /// Creates a <see cref="FieldInfo" /> wrapper for <see cref="IFieldInfo" />. /// </summary> /// <param name="adapter">The adapter.</param> /// <returns>The unresolved field.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="adapter"/> is null.</exception> public abstract FieldInfo Wrap(IFieldInfo adapter);
/// <summary> /// Returns true if the field is assignable as a named attribute parameter. /// </summary> /// <param name="field">The field.</param> /// <returns>True if the field is assignable.</returns> public static bool IsAttributeField(IFieldInfo field) { return !field.IsLiteral && !field.IsInitOnly && !field.IsStatic; }