Пример #1
0
        void SetMinScaleTolerance(ICadastralFabric pFab, double ScaleTolerance)
        {
            IDatasetComponent   pDSComponent       = (IDatasetComponent)pFab;
            IDEDataset          pDEDS              = pDSComponent.DataElement;
            IDECadastralFabric3 pDECadaFab3        = (IDECadastralFabric3)pDEDS;
            IPropertySet        pPropSetEdSettings = null;

            pDECadaFab3.GetPropertySet(esriCadastralPropertySetType.esriCadastralPropSetEditSettings, out pPropSetEdSettings);
            pPropSetEdSettings.SetProperty("esriMinScaleTolerance", ScaleTolerance);
            pDECadaFab3.SetPropertySet(esriCadastralPropertySetType.esriCadastralPropSetEditSettings, pPropSetEdSettings);

            //Update the schema
            ICadastralFabricSchemaEdit pSchemaEd  = (ICadastralFabricSchemaEdit)pFab;
            IDECadastralFabric         pDECadaFab = (IDECadastralFabric)pDECadaFab3;

            pSchemaEd.UpdateSchema(pDECadaFab);
        }
        public bool CadastralTableAddFieldV1(ICadastralFabric pCadaFab, esriCadastralFabricTable eTable, esriFieldType FieldType,
                                             string FieldName, string FieldAlias, int FieldLength)
        {
            ITable pTable = pCadaFab.get_CadastralTable(eTable);

            // First check to see if a field with this name already exists
            if (pTable.FindField(FieldName) > -1)
            {
                if (pTable != null)
                {
                    Marshal.ReleaseComObject(pTable);
                }
                return(false);
            }

            IDatasetComponent  pDSComponent = (IDatasetComponent)pCadaFab;
            IDEDataset         pDEDS        = pDSComponent.DataElement;
            IDECadastralFabric pDECadaFab   = (IDECadastralFabric)pDEDS;

            IField2 pField = null;

            try
            {
                //Create a new Field
                pField = new FieldClass();
                //QI for IFieldEdit
                IFieldEdit2 pFieldEdit = (IFieldEdit2)pField;
                pFieldEdit.Type_2       = FieldType;
                pFieldEdit.Editable_2   = true;
                pFieldEdit.IsNullable_2 = true;
                pFieldEdit.Name_2       = FieldName;
                pFieldEdit.AliasName_2  = FieldAlias;
                pFieldEdit.Length_2     = FieldLength;
                //'.RasterDef_2 = pRasterDef
            }
            catch (COMException ex)
            {
                if (pField != null)
                {
                    Marshal.ReleaseComObject(pField);
                }
                MessageBox.Show(ex.Message);
                return(false);
            }

            IArray pArr = pDECadaFab.CadastralTableFieldEdits;

            bool found = false;
            int  cnt   = pArr.Count;
            ICadastralTableFieldEdits pCadaTableFldEdits = null;
            IFields pFields = null;

            for (int i = 0; i <= (cnt - 1); i++)
            {
                pCadaTableFldEdits = (ICadastralTableFieldEdits)pArr.get_Element(i);
                IFieldsEdit pNewFields = new FieldsClass();
                int         fldCnt     = 0;
                if (pCadaTableFldEdits.CadastralTable == eTable)
                {
                    pFields = pCadaTableFldEdits.ExtendedAttributeFields;
                    //Copy existing fields
                    if (pFields != null)
                    {
                        fldCnt = pFields.FieldCount;
                        pNewFields.FieldCount_2 = fldCnt + 1;
                        for (int j = 0; j <= (fldCnt - 1); j++)
                        {
                            pNewFields.Field_2[j] = pFields.get_Field(j);
                        }
                    }
                    else
                    {
                        pNewFields.FieldCount_2 = 1;
                    }

                    //Add the new field
                    pNewFields.Field_2[fldCnt] = pField;
                    //reset extended attribute fields
                    pCadaTableFldEdits.ExtendedAttributeFields = pNewFields;
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                pCadaTableFldEdits = new CadastralTableFieldEditsClass();
                pCadaTableFldEdits.CadastralTable = eTable; //add the field to the table
                pFields = new FieldsClass();
                int         fldCnt      = pFields.FieldCount;
                IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;
                pFieldsEdit.FieldCount_2    = fldCnt + 1;
                pFieldsEdit.Field_2[fldCnt] = pField;
                pCadaTableFldEdits.ExtendedAttributeFields = pFields;
                pArr.Add(pCadaTableFldEdits);
                Marshal.ReleaseComObject(pFields);
            }

            //Set the CadastralTableFieldEdits property on the DE to the array
            pDECadaFab.CadastralTableFieldEdits = pArr;

            // Update the schema
            ICadastralFabricSchemaEdit pSchemaEd = (ICadastralFabricSchemaEdit)pCadaFab;

            pSchemaEd.UpdateSchema(pDECadaFab);

            Marshal.ReleaseComObject(pField);
            return(true);
        }