Exemplo n.º 1
0
        public void InitFields()
        {
            IFields requiredFields;

            if (this.IsFeatureClass)
            {
                IFeatureClassDescription description;
                IGeometryDef             geometryDef;
                if (this.FeatureType == esriFeatureType.esriFTSimple)
                {
                    description    = new FeatureClassDescriptionClass();
                    requiredFields = (description as IObjectClassDescription).RequiredFields;
                    this.ifield_0  = requiredFields.get_Field(requiredFields.FindField(description.ShapeFieldName));
                    geometryDef    = (this.ifield_0 as IFieldEdit2).GeometryDef;
                    (geometryDef as IGeometryDefEdit).GeometryType_2 = m_pObjectClassHelper.ShapeType;
                    if (this.ispatialReference_0 != null)
                    {
                        (geometryDef as IGeometryDefEdit).SpatialReference_2 = this.ispatialReference_0;
                    }
                    (geometryDef as IGeometryDefEdit).HasZ_2    = this.bool_3;
                    (geometryDef as IGeometryDefEdit).HasM_2    = this.bool_4;
                    (this.ifield_0 as IFieldEdit).GeometryDef_2 = geometryDef as IGeometryDefEdit;
                    this.ifields_0 = requiredFields;
                }
                else if (this.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    description    = new AnnotationFeatureClassDescriptionClass();
                    requiredFields = (description as IObjectClassDescription).RequiredFields;
                    this.ifield_0  = requiredFields.get_Field(requiredFields.FindField(description.ShapeFieldName));
                    geometryDef    = (this.ifield_0 as IFieldEdit2).GeometryDef;
                    if (this.ispatialReference_0 != null)
                    {
                        (geometryDef as IGeometryDefEdit).SpatialReference_2 = this.ispatialReference_0;
                    }
                    this.ifields_0 = requiredFields;
                }
                else if (this.FeatureType == esriFeatureType.esriFTDimension)
                {
                    description    = new DimensionClassDescriptionClass();
                    requiredFields = (description as IObjectClassDescription).RequiredFields;
                    this.ifield_0  = requiredFields.get_Field(requiredFields.FindField(description.ShapeFieldName));
                    geometryDef    = (this.ifield_0 as IFieldEdit2).GeometryDef;
                    if (this.ispatialReference_0 != null)
                    {
                        (geometryDef as IGeometryDefEdit).SpatialReference_2 = this.ispatialReference_0;
                    }
                    this.ifields_0 = requiredFields;
                }
            }
            else
            {
                IObjectClassDescription description2 = new FeatureClassDescriptionClass();
                requiredFields = description2.RequiredFields;
                this.ifields_0 = requiredFields;
            }
        }
        private bool FeatureClassWellKnown(UID uid)
        {
            IObjectClassDescription ocDescription = new AnnotationFeatureClassDescriptionClass();

            if ((ocDescription.ClassExtensionCLSID.Value.ToString() == uid.Value.ToString()) && (ocDescription.ClassExtensionCLSID.SubType == uid.SubType))
            {
                return(true);
            }

            ocDescription = new DimensionClassDescriptionClass();
            if ((ocDescription.ClassExtensionCLSID.Value.ToString() == uid.Value.ToString()) && (ocDescription.ClassExtensionCLSID.SubType == uid.SubType))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        private IFields method_1()
        {
            if (NewObjectClassHelper.m_pObjectClassHelper.IsFeatureClass)
            {
                IFeatureClassDescription description;
                IFields      requiredFields;
                IGeometryDef geometryDef;
                if (NewObjectClassHelper.m_pObjectClassHelper.FeatureType == esriFeatureType.esriFTSimple)
                {
                    description    = new FeatureClassDescriptionClass();
                    requiredFields = (description as IObjectClassDescription).RequiredFields;
                    IField field = requiredFields.get_Field(requiredFields.FindField(description.ShapeFieldName));
                    geometryDef = (field as IFieldEdit2).GeometryDef;
                    (geometryDef as IGeometryDefEdit).GeometryType_2 =
                        NewObjectClassHelper.m_pObjectClassHelper.ShapeType;
                    (field as IFieldEdit).GeometryDef_2 = geometryDef as IGeometryDefEdit;
                    return(requiredFields);
                }
                if (NewObjectClassHelper.m_pObjectClassHelper.FeatureType == esriFeatureType.esriFTAnnotation)
                {
                    description    = new AnnotationFeatureClassDescriptionClass();
                    requiredFields = (description as IObjectClassDescription).RequiredFields;
                    geometryDef    =
                        (requiredFields.get_Field(requiredFields.FindField(description.ShapeFieldName)) as IFieldEdit2)
                        .GeometryDef;
                    return(requiredFields);
                }
                if (NewObjectClassHelper.m_pObjectClassHelper.FeatureType == esriFeatureType.esriFTDimension)
                {
                    description    = new DimensionClassDescriptionClass();
                    requiredFields = (description as IObjectClassDescription).RequiredFields;
                    geometryDef    =
                        (requiredFields.get_Field(requiredFields.FindField(description.ShapeFieldName)) as IFieldEdit2)
                        .GeometryDef;
                    return(requiredFields);
                }
                return(null);
            }
            IObjectClassDescription description2 = new FeatureClassDescriptionClass();

            return(description2.RequiredFields);
        }
        protected override void OnClick()
        {
            try
            {
                if (this.pGxApp.Selection.Count != 1)
                {
                    return;
                }

                IGxObject pGxObject = this.pGxApp.SelectedObject;


                if (!(pGxObject is IGxDataset))
                {
                    return;
                }

                IGxDataset pGxDataset = pGxObject as IGxDataset;

                if (pGxDataset == null)
                {
                    return;
                }

                if (((pGxObject as IGxDataset).Type) != esriDatasetType.esriDTFeatureDataset)
                {
                    MessageBox.Show("Select a Feature Dataset!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                IFeatureDataset   fDataset         = pGxDataset.Dataset as IFeatureDataset;
                IWorkspace2       workspace        = fDataset.Workspace as IWorkspace2;
                IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace;


                DialogResult dialogResult =
                    MessageBox.Show($@"Remove custom extension for all Feature Classes in {fDataset.Name}", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dialogResult == DialogResult.Yes)
                {
                    IEnumDataset enumDataset = fDataset.Subsets;
                    IDataset     dataset     = enumDataset.Next();

                    IObjectClassDescription ocDescriptionAnnotation = new AnnotationFeatureClassDescriptionClass();
                    IObjectClassDescription ocDescriptionDimension  = new DimensionClassDescriptionClass();

                    while (dataset != null)
                    {
                        if (dataset is IClass)
                        {
                            IClass pClass = dataset as IClass;
                            if (pClass.EXTCLSID != null)
                            {
                                if ((pClass.EXTCLSID.Value.ToString().ToLower() != ocDescriptionAnnotation.ClassExtensionCLSID.Value.ToString().ToLower()) &&
                                    (pClass.EXTCLSID.SubType != ocDescriptionAnnotation.ClassExtensionCLSID.SubType) &&
                                    (pClass.EXTCLSID.Value.ToString().ToLower() != ocDescriptionDimension.ClassExtensionCLSID.Value.ToString().ToLower()) &&
                                    (pClass.EXTCLSID.SubType != ocDescriptionDimension.ClassExtensionCLSID.SubType))
                                {
                                    clsGenericStudioAT.RemoveClsExt(pClass);
                                }
                            }
                        }

                        dataset = enumDataset.Next();
                    }

                    MessageBox.Show("All Extension removed!", "Ok", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception errore)
            {
                MessageBox.Show(errore.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
        protected override void OnClick()
        {
            try
            {
                if (this.pGxApp.Selection.Count != 1)
                {
                    return;
                }


                IGxObject pGxObject = this.pGxApp.SelectedObject;


                if (!(pGxObject is IGxDataset))
                {
                    return;
                }

                IGxDataset pGxDataset = pGxObject as IGxDataset;
                if (pGxDataset == null)
                {
                    return;
                }

                if (((pGxObject as IGxDataset).Type) != esriDatasetType.esriDTFeatureClass)
                {
                    return;
                }

                try
                {
                    IDataset a = pGxDataset.Dataset;
                }
                catch (COMException COMex)
                {
                    if (COMex.ErrorCode == -2147467259)
                    {
                        if (MessageBox.Show("Not found component register so I don't see the UID: do I have to remove class extension? Are you sure?", "Remove class extension", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            try
                            {
                                IGxObject gxObject = pGxObject.Parent;
                                if (!(gxObject is IGxDatabase2))
                                {
                                    gxObject = gxObject.Parent;
                                }

                                IFeatureWorkspaceSchemaEdit featureWorkspaceSchemaEdit = ((gxObject as IGxDatabase2).Workspace) as IFeatureWorkspaceSchemaEdit;
                                featureWorkspaceSchemaEdit.AlterClassExtensionCLSID(pGxDataset.DatasetName.Name, null, null);

                                IObjectClassDescription featureClassDescription = new FeatureClassDescriptionClass();
                                featureWorkspaceSchemaEdit.AlterInstanceCLSID(pGxDataset.DatasetName.Name, featureClassDescription.InstanceCLSID);

                                MessageBox.Show("Class extension removed: success! Restart ArcCatalog!", "Remove Class Extension", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Error " + ex.Message);
                                return;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Error " + COMex.ErrorCode.ToString() + ": " + COMex.Message);
                    }

                    return;
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message);
                    return;
                }


                if (!(pGxDataset.Dataset is IClass))
                {
                    return;
                }

                IClass pClass = pGxDataset.Dataset as IClass;

                if (pClass.EXTCLSID == null)
                {
                    MessageBox.Show("No class extension!");
                    return;
                }
                else
                {
                    IObjectClassDescription ocDescription = new AnnotationFeatureClassDescriptionClass();
                    if ((pClass.EXTCLSID.Value.ToString() == ocDescription.ClassExtensionCLSID.Value.ToString()) && (pClass.EXTCLSID.SubType == ocDescription.ClassExtensionCLSID.SubType))
                    {
                        MessageBox.Show("Class extension well-know: I don't remove it (annotation)!", "Remove Class Extension", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    ocDescription = new DimensionClassDescriptionClass();
                    if ((pClass.EXTCLSID.Value.ToString() == ocDescription.ClassExtensionCLSID.Value.ToString()) && (pClass.EXTCLSID.SubType == ocDescription.ClassExtensionCLSID.SubType))
                    {
                        MessageBox.Show("Class extension well-know: I don't remove it (dimension)!", "Remove Class Extension", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }



                    if (MessageBox.Show(string.Format("Class extension: {0}: do I have to remove class extension?", pClass.EXTCLSID.Value.ToString()), "Remove Class Extension", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        if (this.RemoveClsExt(pClass))
                        {
                            MessageBox.Show("Class extension removed: success!", "Remove Class Extension", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Class extension removed: error! I have problem with exclusive schema lock ", "Remove Class Extension", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message.ToString());
            }
        }
Exemplo n.º 6
0
 public void InitFields()
 {
     if (this.m_IsFeatureClass)
     {
         IFeatureClassDescription description;
         IField            field;
         IGeometryDef      geometryDef;
         ISpatialReference spatialReference;
         if (this.m_FeatreType == esriFeatureType.esriFTSimple)
         {
             description         = new FeatureClassDescriptionClass();
             this.ShapeFieldName = description.ShapeFieldName;
             this.m_pFieds       = (description as IObjectClassDescription).RequiredFields;
             field       = this.m_pFieds.get_Field(this.m_pFieds.FindField(description.ShapeFieldName));
             geometryDef = field.GeometryDef;
             if (this.ifeatureDataset_0 != null)
             {
                 spatialReference = (this.ifeatureDataset_0 as IGeoDataset).SpatialReference;
             }
             else
             {
                 spatialReference = geometryDef.SpatialReference;
                 this.method_0(spatialReference);
             }
             (geometryDef as IGeometryDefEdit).SpatialReference_2 = spatialReference;
             (field as IFieldEdit).GeometryDef_2 = geometryDef;
         }
         else if (this.m_FeatreType == esriFeatureType.esriFTDimension)
         {
             description         = new DimensionClassDescriptionClass();
             this.ShapeFieldName = description.ShapeFieldName;
             this.m_pFieds       = (description as IObjectClassDescription).RequiredFields;
             field       = this.m_pFieds.get_Field(this.m_pFieds.FindField(description.ShapeFieldName));
             geometryDef = field.GeometryDef;
             if (this.ifeatureDataset_0 != null)
             {
                 spatialReference = (this.ifeatureDataset_0 as IGeoDataset).SpatialReference;
             }
             else
             {
                 spatialReference = geometryDef.SpatialReference;
                 this.method_0(spatialReference);
             }
             (geometryDef as IGeometryDefEdit).SpatialReference_2 = spatialReference;
             (field as IFieldEdit).GeometryDef_2 = geometryDef;
         }
         else if (this.m_FeatreType == esriFeatureType.esriFTAnnotation)
         {
             description         = new AnnotationFeatureClassDescriptionClass();
             this.ShapeFieldName = description.ShapeFieldName;
             this.m_pFieds       = (description as IObjectClassDescription).RequiredFields;
             field       = this.m_pFieds.get_Field(this.m_pFieds.FindField(description.ShapeFieldName));
             geometryDef = field.GeometryDef;
             if (this.ifeatureDataset_0 != null)
             {
                 spatialReference = (this.ifeatureDataset_0 as IGeoDataset).SpatialReference;
             }
             else
             {
                 spatialReference = geometryDef.SpatialReference;
                 this.method_0(spatialReference);
             }
             (geometryDef as IGeometryDefEdit).SpatialReference_2 = spatialReference;
             (field as IFieldEdit).GeometryDef_2 = geometryDef;
         }
     }
     else
     {
         IObjectClassDescription description2 = new ObjectClassDescriptionClass();
         this.m_pFieds = description2.RequiredFields;
     }
 }