Ejemplo n.º 1
0
 public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
 {
     if (this.idisplayFeedback_0 != null)
     {
         IEnvelope spatialReference = (this.idisplayFeedback_0 as INewEnvelopeFeedback).Stop();
         if (!spatialReference.IsEmpty)
         {
             if ((spatialReference.Width == 0 ? false : spatialReference.Height != 0))
             {
                 spatialReference.SpatialReference = this._context.FocusMap.SpatialReference;
                 Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
                 try
                 {
                     ITopology          mTopology    = CmdSelectTopology.m_Topology;
                     ISegmentCollection polygonClass = new Polygon() as ISegmentCollection;
                     polygonClass.SetRectangle(spatialReference);
                     IPolygon dirtyArea = mTopology.DirtyArea[polygonClass as IPolygon];
                     mTopology.ValidateTopology(dirtyArea.Envelope);
                     this._context.ActiveView.Refresh();
                 }
                 catch (COMException cOMException)
                 {
                     CErrorLog.writeErrorLog(this, cOMException, "");
                 }
                 catch (Exception exception)
                 {
                     CErrorLog.writeErrorLog(this, exception, "");
                 }
                 Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void App_ActiveHookChanged(object object_0)
 {
     if (this.iactiveViewEvents_Event_0 != null)
     {
         try
         {
             this.iactiveViewEvents_Event_0.AfterDraw -=
                 new IActiveViewEvents_AfterDrawEventHandler(this.ActiveView_AfterDraw);
         }
         catch
         {
         }
         this.iactiveViewEvents_Event_0 = null;
     }
     try
     {
         this.iactiveViewEvents_Event_0 = _context.ActiveView as IActiveViewEvents_Event;
         if (this.iactiveViewEvents_Event_0 != null)
         {
             this.iactiveViewEvents_Event_0.AfterDraw +=
                 new IActiveViewEvents_AfterDrawEventHandler(this.ActiveView_AfterDraw);
         }
     }
     catch (Exception exception)
     {
         CErrorLog.writeErrorLog(this, exception, "");
     }
 }
Ejemplo n.º 3
0
 public override void OnClick()
 {
     if (((IGxSelection)_context.GxSelection).FirstObject is IGxDatabase)
     {
         GxCatalogCommon.ConnectGDB(((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase);
         if ((((IGxSelection)_context.GxSelection).FirstObject as IGxDatabase).Workspace != null)
         {
             frmCreateGDBRasterDataset _frmCreateGDBRasterDataset = new frmCreateGDBRasterDataset()
             {
                 OutLocation = ((IGxSelection)_context.GxSelection).FirstObject
             };
             try
             {
                 if (_frmCreateGDBRasterDataset.ShowDialog() == DialogResult.OK)
                 {
                     ((IGxSelection)_context.GxSelection).FirstObject.Refresh();
                 }
             }
             catch (Exception exception)
             {
                 CErrorLog.writeErrorLog(this, exception, "");
             }
         }
     }
 }
Ejemplo n.º 4
0
        private bool UpdateFieldValue(IField pField, object str)
        {
            IWorkspaceEdit workspace = (this.m_pFeatLayer.FeatureClass as IDataset).Workspace as IWorkspaceEdit;
            bool           flag      = false;

            try
            {
                ICursor cursor;
                workspace.StartEditOperation();
                int index = this.m_pFeatLayer.FeatureClass.Fields.FindField(pField.Name);
                (this.m_pFeatLayer as IFeatureSelection).SelectionSet.Search(null, false, out cursor);
                for (IRow row = cursor.NextRow(); row != null; row = cursor.NextRow())
                {
                    row.set_Value(index, str);
                    row.Store();
                }
                ComReleaser.ReleaseCOMObject(cursor);
                workspace.StopEditOperation();
                try
                {
                }
                catch
                {
                }
                flag = true;
            }
            catch (Exception exception)
            {
                MessageBox.Show("输入数据格式错误");
                CErrorLog.writeErrorLog(null, exception, "");
            }
            return(flag);
        }
Ejemplo n.º 5
0
 private void cmdOK_Click(object sender, EventArgs e)
 {
     if (this.method_2())
     {
         System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
         try
         {
             IEnvelope extent  = (this.ifeatureClass_0 as IGeoDataset).Extent;
             ITinEdit  tinEdit = new Tin() as ITinEdit;
             tinEdit.InitNew(extent);
             tinEdit.StartEditing();
             IField pHeightField = null;
             bool   flag         = false;
             if (this.cboHeightField.Text != "")
             {
                 if (this.cboHeightField.SelectedIndex == 0)
                 {
                     flag = true;
                 }
                 else
                 {
                     int num = this.ifeatureClass_0.FindField(this.cboHeightField.Text);
                     if (num != -1)
                     {
                         pHeightField = this.ifeatureClass_0.Fields.get_Field(num);
                     }
                 }
             }
             IField pTagValueField = null;
             object obj            = flag;
             tinEdit.AddFromFeatureClass(this.ifeatureClass_0, null, pHeightField, pTagValueField, (esriTinSurfaceType)this.cboTinSurfaceType.SelectedIndex, ref obj);
             object obj2     = true;
             string tempPath = System.IO.Path.GetTempPath();
             int    num2     = 0;
             string text     = tempPath + "tmptin";
             while (Directory.Exists(text))
             {
                 text = tempPath + "tmptin" + num2++.ToString();
             }
             tinEdit.SaveAs(text, ref obj2);
             tinEdit.StopEditing(true);
             if (this.m_pMap != null)
             {
                 ILayerFactoryHelper layerFactoryHelper = new LayerFactoryHelper();
                 IEnumLayer          enumLayer          = layerFactoryHelper.CreateLayersFromName((tinEdit as IDataset).FullName);
                 enumLayer.Reset();
                 ILayer pLayer = enumLayer.Next();
                 this.m_pMap.AddLayer(pLayer);
             }
             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
             base.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
         catch (Exception exception_)
         {
             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
             System.Windows.Forms.MessageBox.Show("无法创建TIN,请确保输入要素的是否合适!");
             CErrorLog.writeErrorLog(this, exception_, "");
         }
     }
 }
Ejemplo n.º 6
0
 private void btnApply_Click(object sender, EventArgs e)
 {
     if (this.ilayer_0 != null)
     {
         this.attributeQueryBuliderControl_0.Apply();
         try
         {
             IQueryFilter filter = new QueryFilter
             {
                 WhereClause = this.attributeQueryBuliderControl_0.WhereCaluse
             };
             IFeatureSelection selection = this.ilayer_0 as IFeatureSelection;
             if (selection != null)
             {
                 selection.SelectFeatures(filter, this.esriSelectionResultEnum_0, false);
                 if (selection.SelectionSet.Count < 1)
                 {
                     MessageBox.Show("没有符合条件的纪录!");
                 }
                 else
                 {
                     (this.ibasicMap_0 as IActiveView).Refresh();
                 }
             }
         }
         catch (Exception exception)
         {
             CErrorLog.writeErrorLog(this, exception, "");
         }
     }
 }
Ejemplo n.º 7
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.CanDo())
         {
             RasterUtil rasterUtil = new RasterUtil();
             if (!(this.m_pOutName is IRasterCatalogName))
             {
                 IRasterWorkspaceEx rasterWorkspaceEx = this.m_pOutName.Open() as IRasterWorkspaceEx;
                 for (int i = 0; i < this.m_pInNames.Count; i++)
                 {
                     IRasterDataset2 rasterDataset2           = (this.m_pInNames[i] as IName).Open() as IRasterDataset2;
                     string          fileNameWithoutExtension =
                         Path.GetFileNameWithoutExtension((rasterDataset2 as IDataset).Name);
                     if ((fileNameWithoutExtension[0] < '0' ? false : fileNameWithoutExtension[0] <= '9'))
                     {
                         fileNameWithoutExtension = string.Concat("A", fileNameWithoutExtension);
                     }
                     if (rasterWorkspaceEx is IWorkspace2)
                     {
                         int    num = 1;
                         string str = fileNameWithoutExtension;
                         try
                         {
                             while (
                                 (rasterWorkspaceEx as IWorkspace2).NameExists[
                                     esriDatasetType.esriDTFeatureClass, str])
                             {
                                 str = string.Concat(fileNameWithoutExtension, "_", num.ToString());
                                 num++;
                             }
                         }
                         catch
                         {
                         }
                         fileNameWithoutExtension = str;
                     }
                     ((IGeometryDefEdit)(new GeometryDef())).SpatialReference_2 =
                         (rasterDataset2 as IGeoDataset).SpatialReference;
                     rasterWorkspaceEx.SaveAsRasterDataset(fileNameWithoutExtension,
                                                           rasterDataset2.CreateFullRaster(), null, "", null, null);
                 }
             }
             else
             {
                 IFeatureClass featureClass = this.m_pOutName.Open() as IFeatureClass;
                 rasterUtil.ToRasterCatalog(this.m_pInNames, featureClass);
             }
         }
     }
     catch (Exception exception1)
     {
         Exception exception = exception1;
         CErrorLog.writeErrorLog(this, exception, "");
         MessageBox.Show(exception.Message);
     }
     this.progressBar1.Visible = false;
 }
Ejemplo n.º 8
0
 private void listView1_ValueChanged(object sender, ValueChangedEventArgs e)
 {
     try
     {
         IPoint tag = this.listView1.Items[e.Row].Tag as IPoint;
         if (tag != null)
         {
             if (e.Column == 1)
             {
                 tag.X = double.Parse((string)e.NewValue);
             }
             else if (e.Column == 2)
             {
                 tag.Y = double.Parse((string)e.NewValue);
             }
             else if (e.Column == 3)
             {
                 if (this.m_HasZ)
                 {
                     tag.Z = double.Parse((string)e.NewValue);
                 }
                 else
                 {
                     tag.M = double.Parse((string)e.NewValue);
                 }
             }
             else if (e.Column == 4)
             {
                 tag.M = double.Parse((string)e.NewValue);
             }
             if ((this.m_pGeometry is IPolygon) || (this.m_pGeometry is IPolyline))
             {
                 IPointCollection points =
                     (this.m_pGeometry as IGeometryCollection).get_Geometry(this.listBox1.SelectedIndex) as
                     IPointCollection;
                 points.UpdatePoint(e.Row, tag);
                 if ((points as ICurve).IsClosed && (e.Row == 0))
                 {
                     points.UpdatePoint(points.PointCount - 1, tag);
                 }
             }
             IWorkspaceEdit workspace = (this.m_pEditFeature.Class as IDataset).Workspace as IWorkspaceEdit;
             (this.m_pMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
                                                         this.m_pEditFeature.Extent);
             workspace.StartEditOperation();
             this.m_pEditFeature.Shape = this.m_pGeometry;
             this.m_pEditFeature.Store();
             workspace.StopEditOperation();
             (this.m_pMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
                                                         this.m_pGeometry.Envelope);
             this.SetStatus();
         }
     }
     catch (Exception exception)
     {
         CErrorLog.writeErrorLog(null, exception, "");
     }
 }
Ejemplo n.º 9
0
        public void LoadTools(IApplication pApp, string FileName)
        {
            LoadComponent component = new LoadComponent();
            ComponentList list      = new ComponentList(FileName);

            list.beginRead();
            string str     = "";
            string str2    = "";
            int    subType = -1;

            for (int i = 0; i < list.GetComponentCount(); i++)
            {
                str2    = list.getClassName(i);
                str     = Application.StartupPath + @"\" + list.getfilename(i);
                subType = list.getSubType(i);
                bool flag = component.LoadComponentLibrary(str);
                try
                {
                    ICommand pCommand = null;
                    pCommand = component.LoadClass(str2) as ICommand;
                    if (pCommand == null)
                    {
                        Logger.Current.Error("", null, "无法创建:" + str2);
                    }
                    else
                    {
                        pCommand.OnCreate(pApp);
                        if (subType != -1)
                        {
                            (pCommand as ICommandSubType).SetSubType(subType);
                        }
                        BarItem item = this.barManager1.Items[pCommand.Name];
                        if (item == null)
                        {
                            item = this.CreateBarItem(pCommand);
                        }
                        if ((pCommand is IBarEditItem) && (item is BarEditItem))
                        {
                            (pCommand as IBarEditItem).BarEditItem = new YTComboxBarItem(item);
                        }
                        if (item != null)
                        {
                            item.Tag = pCommand;
                        }
                    }
                }
                catch (Exception exception)
                {
                    CErrorLog.writeErrorLog(null, exception, "");
                }
            }
        }
Ejemplo n.º 10
0
        public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
        {
            IEnvelope envelope;
            IGeometry geometry;

            if (CmdSelectTopology.m_TopologyGraph != null)
            {
                this.bool_0 = false;
                if (this.idisplayFeedback_0 != null)
                {
                    IPoint         mapPoint      = this._context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_2, int_3);
                    IWorkspaceEdit editWorkspace = Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace;
                    editWorkspace.StartEditOperation();
                    try
                    {
                        IAffineTransformation2D affineTransformation2DClass = new AffineTransformation2D() as IAffineTransformation2D;
                        affineTransformation2DClass.Move(mapPoint.X - this.ipoint_0.X, mapPoint.Y - this.ipoint_0.Y);
                        CmdSelectTopology.m_TopologyGraph.TransformSelection(esriTransformDirection.esriTransformForward, affineTransformation2DClass, false);
                        CmdSelectTopology.m_TopologyGraph.Post(out envelope);
                        this._context.ActiveView.Refresh();
                    }
                    catch (Exception exception)
                    {
                        CErrorLog.writeErrorLog(this, exception, "");
                    }
                    editWorkspace.StopEditOperation();
                    this.idisplayFeedback_0 = null;
                }
                else if (this.inewEnvelopeFeedback_0 != null)
                {
                    geometry = this.inewEnvelopeFeedback_0.Stop();
                    CmdSelectTopology.m_TopologyGraph.SelectByGeometry(3, esriTopologySelectionResultEnum.esriTopologySelectionResultNew, geometry);
                    this.inewEnvelopeFeedback_0 = null;
                }
                else
                {
                    double searchTolerance = 3.5;
                    if (this._context.Hook is IApplication)
                    {
                        searchTolerance = (double)(this._context.Hook as IApplication).SelectionEnvironment.SearchTolerance;
                    }
                    searchTolerance = Common.ConvertPixelsToMapUnits((IActiveView)this._context.FocusMap, searchTolerance);
                    geometry        = ((ITopologicalOperator)this.ipoint_0).Buffer(searchTolerance);
                    CmdSelectTopology.m_TopologyGraph.SelectByGeometry(1, esriTopologySelectionResultEnum.esriTopologySelectionResultNew, geometry);
                    if (CmdSelectTopology.m_TopologyGraph.NodeSelection.Count == 0)
                    {
                        CmdSelectTopology.m_TopologyGraph.SelectByGeometry(2, esriTopologySelectionResultEnum.esriTopologySelectionResultNew, geometry);
                    }
                }
                this._context.ActiveView.Refresh();
            }
        }
Ejemplo n.º 11
0
        public void Excute()
        {
            IPolygon     tempLine         = SketchToolAssist.TempLine as IPolygon;
            IInvalidArea invalidAreaClass = new InvalidArea()
            {
                Display = (_context.FocusMap as IActiveView).ScreenDisplay
            };

            invalidAreaClass.Add(tempLine);
            tempLine.SimplifyPreserveFromTo();
            IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature;

            featureSelection.Reset();
            IFeature feature = featureSelection.Next();

            if (feature != null)
            {
                IPolygon shapeCopy = feature.ShapeCopy as IPolygon;
                if (!(shapeCopy as IRelationalOperator).Disjoint(tempLine))
                {
                    IGeometry geometry = (shapeCopy as ITopologicalOperator).Difference(tempLine);
                    if (!geometry.IsEmpty)
                    {
                        invalidAreaClass.Add(feature);
                        Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(geometry, shapeCopy);
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
                        try
                        {
                            feature.Shape = geometry;
                            feature.Store();
                            IGeometry geometry1 = (shapeCopy as ITopologicalOperator).Difference(geometry);
                            if (!geometry1.IsEmpty)
                            {
                                Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(geometry1, shapeCopy);
                                IFeature feature1 = RowOperator.CreatRowByRow(feature as Row) as IFeature;
                                feature1.Shape = geometry1;
                                feature1.Store();
                            }
                        }
                        catch (Exception exception)
                        {
                            CErrorLog.writeErrorLog(this, exception, "");
                        }
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
                        _context.UpdateUI();
                    }
                }
            }
            invalidAreaClass.Invalidate(-2);
        }
Ejemplo n.º 12
0
 public override void OnClick()
 {
     try
     {
         if (this._context.OperationStack.RedoOperation != null)
         {
             this._context.OperationStack.Redo();
             this._context.ActiveView.Refresh();
         }
     }
     catch (Exception exception_)
     {
         CErrorLog.writeErrorLog(this, exception_, "");
     }
 }
Ejemplo n.º 13
0
        private void btnSelectInputFeatures_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile();

            file.AddFilter(new MyGxFilterFeatureClasses(), true);
            if (file.DoModalSave() == DialogResult.OK)
            {
                IArray items = file.Items;
                if (items.Count != 0)
                {
                    System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
                    try
                    {
                        IWorkspaceName name     = null;
                        IGxObject      obj2     = items.get_Element(0) as IGxObject;
                        string         str      = "";
                        string         fullName = "";
                        if (obj2 is IGxDatabase)
                        {
                            BufferHelper.m_BufferHelper.m_pOutFeatureWorksapce =
                                (obj2 as IGxDatabase).Workspace as IFeatureWorkspace;
                            fullName = obj2.FullName;
                        }
                        else if (obj2 is IGxFolder)
                        {
                            name = new WorkspaceNameClass
                            {
                                WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory",
                                PathName = (obj2.InternalObjectName as IFileName).Path
                            };
                            BufferHelper.m_BufferHelper.m_pOutFeatureWorksapce =
                                (name as IName).Open() as IFeatureWorkspace;
                            fullName = (obj2.InternalObjectName as IFileName).Path;
                            str      = ".shp";
                        }
                        BufferHelper.m_BufferHelper.m_FeatClassName = file.SaveName;
                        this.txtOutName.Text = fullName + @"\" + file.SaveName + str;
                    }
                    catch (Exception exception)
                    {
                        CErrorLog.writeErrorLog(null, exception, "");
                    }
                    System.Windows.Forms.Cursor.Current = Cursors.Default;
                }
            }
        }
Ejemplo n.º 14
0
 public override void OnClick()
 {
     this.ipageLayoutControl_0 = this._context.Hook as IPageLayoutControl;
     if (this.ipageLayoutControl_0 != null)
     {
         try
         {
             FormPrinterSetup formPrinterSetup = new FormPrinterSetup();
             formPrinterSetup.setPageLayout(ref this.ipageLayoutControl_0);
             formPrinterSetup.ShowDialog();
         }
         catch (Exception exception1)
         {
             Exception exception = exception1;
             MessageBox.Show("无法启动打印!");
             CErrorLog.writeErrorLog(this, exception, "");
         }
     }
 }
Ejemplo n.º 15
0
        private static IList PointSplitLine(IPolycurve pPolycurve, IPoint pt)
        {
            int   num;
            int   num2;
            bool  flag;
            IList list = new ArrayList();

            pPolycurve.SplitAtPoint(pt, true, true, out flag, out num2, out num);
            if (flag)
            {
                object before = Missing.Value;
                try
                {
                    int num3;
                    IGeometryCollection geometrys = new PolylineClass();
                    for (num3 = 0; num3 < num2; num3++)
                    {
                        geometrys.AddGeometry((pPolycurve as IGeometryCollection).get_Geometry(num3), ref before,
                                              ref before);
                    }
                    if ((geometrys as IPointCollection).PointCount > 1)
                    {
                        list.Add(geometrys);
                    }
                    geometrys = new PolylineClass();
                    for (num3 = num2; num3 < (pPolycurve as IGeometryCollection).GeometryCount; num3++)
                    {
                        geometrys.AddGeometry((pPolycurve as IGeometryCollection).get_Geometry(num3), ref before,
                                              ref before);
                    }
                    if ((geometrys as IPointCollection).PointCount > 1)
                    {
                        list.Add(geometrys);
                    }
                }
                catch (Exception exception)
                {
                    CErrorLog.writeErrorLog(null, exception, "");
                }
            }
            return(list);
        }
Ejemplo n.º 16
0
 public override void OnDblClick()
 {
     if (this.inewPolygonFeedback_0 != null)
     {
         try
         {
             IPolygon polygon = this.inewPolygonFeedback_0.Stop();
             polygon.SpatialReference = this._context.FocusMap.SpatialReference;
             (polygon as ITopologicalOperator).Simplify();
             new frmDir
             {
                 FocusMap     = this._context.FocusMap,
                 ClipGeometry = polygon
             }.ShowDialog();
         }
         catch (Exception exception_)
         {
             CErrorLog.writeErrorLog(this, exception_, "");
         }
         this.inewPolygonFeedback_0 = null;
     }
 }
Ejemplo n.º 17
0
 public override void OnClick()
 {
     Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
     try
     {
         ITopology          mTopology    = CmdSelectTopology.m_Topology;
         ISegmentCollection polygonClass = new Polygon() as ISegmentCollection;
         polygonClass.SetRectangle((mTopology as IGeoDataset).Extent);
         IPolygon dirtyArea = mTopology.DirtyArea[polygonClass as IPolygon];
         mTopology.ValidateTopology(dirtyArea.Envelope);
         this._context.ActiveView.Refresh();
     }
     catch (COMException cOMException)
     {
         CErrorLog.writeErrorLog(this, cOMException, "");
     }
     catch (Exception exception)
     {
         CErrorLog.writeErrorLog(this, exception, "");
     }
     Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
 }
Ejemplo n.º 18
0
        private bool UpdateFieldValue(IField pField, object str)
        {
            if (this.cboLayer.SelectedIndex == -1)
            {
                return(false);
            }
            LayerObject   selectedItem = this.cboLayer.SelectedItem as LayerObject;
            IFeatureLayer layer        = selectedItem.Layer as IFeatureLayer;

            if (layer == null)
            {
                return(false);
            }
            IWorkspaceEdit editWorkspace = Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace;
            bool           flag          = false;

            try
            {
                ICursor cursor;
                editWorkspace.StartEditOperation();
                int index = layer.FeatureClass.Fields.FindField(pField.Name);
                (layer as IFeatureSelection).SelectionSet.Search(null, false, out cursor);
                for (IRow row = cursor.NextRow(); row != null; row = cursor.NextRow())
                {
                    row.set_Value(index, str);
                    row.Store();
                }
                ComReleaser.ReleaseCOMObject(cursor);
                editWorkspace.StopEditOperation();
                flag = true;
            }
            catch (Exception exception)
            {
                MessageBox.Show("输入数据格式错误");
                CErrorLog.writeErrorLog(null, exception, "");
            }
            return(flag);
        }
Ejemplo n.º 19
0
        public override void OnClick()
        {
            try
            {
                if (_dockService == null)
                {
                    _dockService = _context.Container.GetInstance <GeometryInfoDockPanelService>();
                }
                this._dockService.Presenter.EditWorkspace =
                    Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace as IWorkspace;


                if (_dockService.Visible == false)
                {
                    _dockService.Show();
                    return;
                }
            }
            catch (Exception exception_)
            {
                CErrorLog.writeErrorLog(this, exception_, "");
            }
        }
Ejemplo n.º 20
0
        private bool UpdateFieldValue(IField pField, object str)
        {
            if (this.m_pObject == null)
            {
                return(false);
            }
            IWorkspaceEdit workspace = (this.m_pObject.Class as IDataset).Workspace as IWorkspaceEdit;
            bool           flag      = false;

            try
            {
                workspace.StartEditOperation();
                int index = this.m_pObject.Fields.FindField(pField.Name);
                this.m_pObject.set_Value(index, str);
                this.m_pObject.Store();
                workspace.StopEditOperation();
                try
                {
                    if ((this.m_pObject is IFeature) && ((this.m_pObject as IFeature).Shape != null))
                    {
                        this.m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
                                                          (this.m_pObject as IFeature).Shape.Envelope);
                    }
                }
                catch
                {
                }
                flag = true;
            }
            catch (Exception exception)
            {
                MessageBox.Show("输入数据格式错误");
                CErrorLog.writeErrorLog(null, exception, "");
            }
            return(flag);
        }
Ejemplo n.º 21
0
 public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
 {
     if (this.irotateTrackerFeedback_0 != null)
     {
         if (int_0 == 1 && this.bool_2)
         {
             _context.ActiveView.Refresh();
         }
         else if (this.bool_1)
         {
             this.bool_1 = false;
             if (this.irotateTrackerFeedback_0 != null)
             {
                 this.irotateTrackerFeedback_0.ClearGeometry();
                 if (this.irotateTrackerFeedback_0.Angle != 0)
                 {
                     IEnvelope    envelope         = null;
                     IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature;
                     featureSelection.Reset();
                     for (IFeature i = featureSelection.Next(); i != null; i = featureSelection.Next())
                     {
                         ITransform2D shapeCopy = i.ShapeCopy as ITransform2D;
                         if (envelope != null)
                         {
                             envelope.Union((shapeCopy as IGeometry).Envelope);
                         }
                         else
                         {
                             envelope = (shapeCopy as IGeometry).Envelope;
                         }
                         if (shapeCopy != null)
                         {
                             shapeCopy.Rotate(this.irotateTrackerFeedback_0.Origin,
                                              this.irotateTrackerFeedback_0.Angle);
                             Yutai.ArcGIS.Common.Editor.Editor.StartEditOperation(i.Class as IDataset);
                             try
                             {
                                 i.Shape = shapeCopy as IGeometry;
                                 i.Store();
                                 envelope.Union((shapeCopy as IGeometry).Envelope);
                             }
                             catch (Exception exception)
                             {
                                 CErrorLog.writeErrorLog(this, exception, "");
                             }
                             Yutai.ArcGIS.Common.Editor.Editor.StopEditOperation(i.Class as IDataset);
                         }
                     }
                     if (envelope != null)
                     {
                         double mapUnits = Common.ConvertPixelsToMapUnits(_context.ActiveView, 10);
                         envelope.Expand(mapUnits, mapUnits, false);
                         _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
                                                            envelope);
                     }
                     _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                        null);
                     this.irotateTrackerFeedback_0.Origin = null;
                 }
             }
         }
     }
 }
Ejemplo n.º 22
0
        private void ReadBarItems(object items, XmlNode pNode)
        {
            string[] itemAttribute = this.GetItemAttribute(pNode);
            Bitmap   bitmap        = null;

            if (((itemAttribute[6] != null) && (itemAttribute[6].Length > 3)) && (itemAttribute[6][1] != ':'))
            {
                itemAttribute[6] = System.Windows.Forms.Application.StartupPath + @"\" + itemAttribute[6];
                try
                {
                    if (File.Exists(itemAttribute[6]))
                    {
                        bitmap = new Bitmap(itemAttribute[6]);
                    }
                }
                catch
                {
                }
            }
            ICommand command = null;

            if ((itemAttribute[2] != null) && (itemAttribute[3] != null))
            {
                try
                {
                    if (itemAttribute[2][1] != ':')
                    {
                        itemAttribute[2] = System.Windows.Forms.Application.StartupPath + @"\" + itemAttribute[2];
                    }
                    if (File.Exists(itemAttribute[2]))
                    {
                        command = this.GetLoadComponent(itemAttribute[2]).LoadClass(itemAttribute[3]) as ICommand;
                        if (command != null)
                        {
                            command.OnCreate(this.m_pApp);
                            if (command is ITOCNodePopmenuItem)
                            {
                                (command as ITOCNodePopmenuItem).InMapCtrl         = this.m_pInMapCtrl;
                                (command as ITOCNodePopmenuItem).PageLayoutControl = this.m_pPageLayoutCtrl;
                                (command as ITOCNodePopmenuItem).TreeView          = this.m_pTOCTreeView;
                            }
                            if (itemAttribute[4] != null)
                            {
                                try
                                {
                                    int subType = int.Parse(itemAttribute[4]);
                                    (command as ICommandSubType).SetSubType(subType);
                                }
                                catch
                                {
                                    CErrorLog.writeErrorLog("null", null,
                                                            string.Format("创建{0}中的类{1}的子命令设置失败", itemAttribute[4], itemAttribute[5]));
                                }
                            }
                        }
                        else
                        {
                            CErrorLog.writeErrorLog("null", null,
                                                    string.Format("创建{0}中的类{1}的失败,无法创建该工具", itemAttribute[4], itemAttribute[5]));
                        }
                    }
                    else
                    {
                        CErrorLog.writeErrorLog("null", null, string.Format("文件{0}不存在!", itemAttribute[4]));
                    }
                }
                catch (Exception exception)
                {
                    CErrorLog.writeErrorLog("null", exception,
                                            string.Format("创建{0}中的类{1}的失败", itemAttribute[4], itemAttribute[5]));
                }
            }
            if ((itemAttribute[0] != null) || (command != null))
            {
                if ((command != null) && (command.Name != null))
                {
                    itemAttribute[0] = command.Name;
                }
                BarItem item = null;
                if (itemAttribute[0].Length > 0)
                {
                    item = this.m_barManager1.Items[itemAttribute[0]];
                }
                if (item == null)
                {
                    if (pNode.ChildNodes.Count > 0)
                    {
                        item = new BarSubItem();
                        this.m_barManager1.Items.Add(item);
                    }
                    else
                    {
                        item            = new BarButtonItem();
                        item.ItemClick += new ItemClickEventHandler(this.pBarItem_ItemClick);
                        this.m_barManager1.Items.Add(item);
                    }
                    if (items == null)
                    {
                        this.baritems.Add(item);
                        if (itemAttribute[5] != null)
                        {
                            this.isgroups.Add(bool.Parse(itemAttribute[5]));
                        }
                        else
                        {
                            this.isgroups.Add(false);
                        }
                    }
                    item.Name = itemAttribute[0];
                    item.Tag  = command;
                    if (itemAttribute[1] != null)
                    {
                        item.Caption = itemAttribute[1];
                    }
                    if (command != null)
                    {
                        if (command.Tooltip != null)
                        {
                            item.Hint = command.Tooltip;
                        }
                        else if (command.Caption != null)
                        {
                            item.Hint = command.Caption;
                        }
                        if (bitmap != null)
                        {
                            item.Glyph = bitmap;
                        }
                        else if (command.Bitmap != 0)
                        {
                            try
                            {
                                IntPtr hbitmap = new IntPtr(command.Bitmap);
                                item.Glyph = Image.FromHbitmap(hbitmap);
                            }
                            catch
                            {
                            }
                        }
                        if (itemAttribute[1] == null)
                        {
                            item.Caption = command.Caption;
                        }
                    }
                }
                BarItemLink link = null;
                if (items is BarSubItem)
                {
                    link = (items as BarSubItem).AddItem(item);
                    if ((link != null) && (itemAttribute[5] != null))
                    {
                        link.BeginGroup = bool.Parse(itemAttribute[5]);
                    }
                }
                for (int i = 0; i < pNode.ChildNodes.Count; i++)
                {
                    this.ReadBarItems(item, pNode.ChildNodes[i]);
                }
            }
        }
Ejemplo n.º 23
0
 public static void UsingRasterClassifyRendered(IRasterLayer irasterLayer_0, int int_0, string string_0)
 {
     try
     {
         bool        flag;
         IRaster     raster = irasterLayer_0.Raster;
         IRasterBand band   = (raster as IRasterBandCollection).Item(0);
         band.HasTable(out flag);
         if (flag)
         {
             int  num2;
             bool flag2;
             IRasterClassifyColorRampRenderer renderer = new RasterClassifyColorRampRenderer();
             IRasterRenderer renderer2 = renderer as IRasterRenderer;
             renderer2.Raster = raster;
             ITable          attributeTable = band.AttributeTable;
             ITableHistogram tableHistogram = new BasicTableHistogram() as ITableHistogram;
             tableHistogram.Field = string_0;
             tableHistogram.Table = attributeTable;
             ITableHistogram histogram = tableHistogram as ITableHistogram;
             double          maximum   = (histogram as IStatisticsResults).Maximum;
             IClassify       classify  = new EqualInterval() as IClassify;
             (classify as IClassifyMinMax).Minimum = (histogram as IStatisticsResults).Minimum;
             (classify as IClassifyMinMax).Maximum = (histogram as IStatisticsResults).Maximum;
             int_0--;
             classify.Classify(ref int_0);
             object classBreaks = classify.ClassBreaks;
             UID    classID     = classify.ClassID;
             IRasterClassifyUIProperties properties = renderer as IRasterClassifyUIProperties;
             properties.ClassificationMethod = classID;
             renderer.ClassCount             = int_0;
             renderer.ClassField             = string_0;
             for (num2 = 0; num2 < int_0; num2++)
             {
                 renderer.set_Break(num2, ((double[])classBreaks)[num2]);
             }
             IColorRamp ramp = ColorManage.CreateColorRamp();
             ramp.Size = int_0;
             ramp.CreateRamp(out flag2);
             IFillSymbol symbol = new SimpleFillSymbol();
             for (num2 = 0; num2 < renderer.ClassCount; num2++)
             {
                 double num4;
                 symbol.Color = ramp.get_Color(num2);
                 renderer.set_Symbol(num2, symbol as ISymbol);
                 double num3 = ((double[])classBreaks)[num2];
                 if (num2 == (renderer.ClassCount - 1))
                 {
                     num4 = maximum;
                 }
                 else
                 {
                     num4 = ((double[])classBreaks)[num2 + 1];
                 }
                 renderer.set_Label(num2, num3.ToString() + "-" + num4.ToString());
             }
             renderer2.Update();
             irasterLayer_0.Renderer = renderer as IRasterRenderer;
         }
         else
         {
             UsingRasterClassifyRendered1(irasterLayer_0, int_0, string_0);
         }
     }
     catch (Exception exception)
     {
         CErrorLog.writeErrorLog(null, exception, "栅格渲染");
     }
 }
Ejemplo n.º 24
0
 public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
 {
     if (int_0 != 2 && this.bool_0)
     {
         this.bool_0 = false;
         IActiveView activeView = (IActiveView)_context.FocusMap;
         IEnvelope   envelope   = null;
         IPoint      point      = null;
         if (this.inewEnvelopeFeedback_0 == null)
         {
             point = this.ipoint_0;
         }
         else
         {
             envelope = this.inewEnvelopeFeedback_0.Stop();
             this.inewEnvelopeFeedback_0 = null;
             if (envelope.Width == 0.0 || envelope.Height == 0.0)
             {
                 point    = this.ipoint_0;
                 envelope = null;
             }
         }
         IList        list        = new ArrayList();
         IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature;
         enumFeature.Reset();
         IFeature            feature            = enumFeature.Next();
         IGeometryCollection geometryCollection = new GeometryBag() as IGeometryCollection;
         object value = Missing.Value;
         while (feature != null)
         {
             list.Add(feature);
             geometryCollection.AddGeometry(feature.ShapeCopy, ref value, ref value);
             feature = enumFeature.Next();
         }
         IEnvelope envelope2 = (geometryCollection as IGeometryBag).Envelope;
         IPoint    point2    = new Point
         {
             X = (envelope2.XMax + envelope2.XMin) / 2.0,
             Y = (envelope2.YMax + envelope2.YMin) / 2.0
         };
         double num;
         double num2;
         if (envelope != null)
         {
             IPoint point3 = new Point
             {
                 X = (envelope.XMax + envelope.XMin) / 2.0,
                 Y = (envelope.YMax + envelope.YMin) / 2.0
             };
             num  = point2.X - point3.X;
             num2 = point2.Y - point3.Y;
             double num3 = envelope.Width / envelope2.Width;
             double num4 = envelope.Height / envelope2.Height;
             num3 = ((num3 > num4) ? num4 : num3);
             (geometryCollection as ITransform2D).Scale(point2, num3, num3);
         }
         else
         {
             num  = point2.X - point.X;
             num2 = point2.Y - point.Y;
         }
         (geometryCollection as ITransform2D).Move(-num, -num2);
         Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
         for (int i = 0; i < list.Count; i++)
         {
             feature = (list[i] as IFeature);
             try
             {
                 IFeature feature2 = RowOperator.CreatRowByRow(feature) as IFeature;
                 feature2.Shape = geometryCollection.get_Geometry(i);
                 feature2.Store();
             }
             catch (Exception exception_)
             {
                 CErrorLog.writeErrorLog(this, exception_, "");
             }
         }
         Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
         activeView.Refresh();
     }
 }
Ejemplo n.º 25
0
        public override void OnMouseDown(int int_0, int Shift, int int_2, int int_3)
        {
            double num;
            double num1;
            double num2;
            double num3;

            if (int_0 == 1)
            {
                IActiveView activeView    = _context.FocusMap as IActiveView;
                IPoint      mPAnchorPoint = SketchShareEx.m_pAnchorPoint;
                if (SketchToolAssist.Feedback != null)
                {
                    try
                    {
                        IEnvelope        envelope      = (SketchToolAssist.Feedback as INewEnvelopeFeedback).Stop();
                        IPointCollection polylineClass = null;
                        IFeatureLayer    featureLayer  = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer;
                        if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                        {
                            polylineClass = new Polyline();
                        }
                        else if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon)
                        {
                            return;
                        }
                        else
                        {
                            polylineClass = new Polygon();
                        }
                        envelope.QueryCoords(out num, out num1, out num2, out num3);
                        object value      = Missing.Value;
                        IPoint pointClass = new Point();
                        pointClass.PutCoords(num, num1);
                        polylineClass.AddPoint(pointClass, ref value, ref value);
                        pointClass = new Point();
                        pointClass.PutCoords(num, num3);
                        polylineClass.AddPoint(pointClass, ref value, ref value);
                        pointClass = new Point();
                        pointClass.PutCoords(num2, num3);
                        polylineClass.AddPoint(pointClass, ref value, ref value);
                        pointClass = new Point();
                        pointClass.PutCoords(num2, num1);
                        polylineClass.AddPoint(pointClass, ref value, ref value);
                        pointClass = new Point();
                        pointClass.PutCoords(num, num1);
                        polylineClass.AddPoint(pointClass, ref value, ref value);
                        CreateFeatureTool.CreateFeature(polylineClass as IGeometry, _context.FocusMap as IActiveView,
                                                        Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer);
                    }
                    catch (Exception exception)
                    {
                        CErrorLog.writeErrorLog(this, exception, "");
                    }
                    SketchShareEx.m_bInUse           = false;
                    SketchShareEx.LastPoint          = null;
                    SketchShareEx.PointCount         = 0;
                    SketchToolAssist.Feedback        = null;
                    SketchShareEx.m_LastPartGeometry = null;
                }
                else
                {
                    SketchToolAssist.Feedback         = new NewEnvelopeFeedback();
                    SketchToolAssist.Feedback.Display = activeView.ScreenDisplay;
                    (SketchToolAssist.Feedback as INewEnvelopeFeedback2).Start(mPAnchorPoint);
                    SketchShareEx.m_bInUse = true;
                }
            }
        }
Ejemplo n.º 26
0
        public override void OnClick()
        {
            int      i;
            IFeature feature;

            if (Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate == null ||
                Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer == null)
            {
                return;
            }
            IFeatureLayer    featureLayer = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer;
            esriGeometryType shapeType    = featureLayer.FeatureClass.ShapeType;

            CmdEditCopy.m_pEnumFeature.Reset();
            IFeature       item         = CmdEditCopy.m_pEnumFeature.Next();
            IFeatureClass  featureClass = featureLayer.FeatureClass;
            IWorkspaceEdit workspace    = (featureClass as IDataset).Workspace as IWorkspaceEdit;

            workspace.StartEditOperation();
            IArray arrayClass = new ESRI.ArcGIS.esriSystem.Array();
            object value      = Missing.Value;

            for (i = 0; i < CmdEditCopy.m_pFeatureList.Count; i++)
            {
                item = CmdEditCopy.m_pFeatureList[i];
                if (item.Shape.GeometryType == shapeType)
                {
                    feature = featureClass.CreateFeature();
                    try
                    {
                        Yutai.ArcGIS.Common.Editor.Editor.CopyRowEx(item, feature);
                        feature.Store();
                        arrayClass.Add(feature);
                    }
                    catch (Exception exception)
                    {
                        CErrorLog.writeErrorLog(this, exception, "");
                    }
                }
                else if ((item.Shape.GeometryType != esriGeometryType.esriGeometryPolygon
                    ? false
                    : shapeType == esriGeometryType.esriGeometryPolyline))
                {
                    feature = featureClass.CreateFeature();
                    try
                    {
                        IPolyline polylineClass = new Polyline() as IPolyline;
                        IPolygon  shape         = item.Shape as IPolygon;
                        for (int j = 0; j < (shape as IGeometryCollection).GeometryCount; j++)
                        {
                            ISegmentCollection geometry =
                                (shape as IGeometryCollection).Geometry[j] as ISegmentCollection;
                            IPath pathClass = new Path() as IPath;
                            (pathClass as ISegmentCollection).AddSegmentCollection(geometry);
                            (polylineClass as IGeometryCollection).AddGeometry(pathClass, ref value, ref value);
                        }
                        feature.Shape = polylineClass;
                        Yutai.ArcGIS.Common.Editor.Editor.CopyRow(item, feature);
                        feature.Store();
                        arrayClass.Add(feature);
                    }
                    catch (Exception exception1)
                    {
                        CErrorLog.writeErrorLog(this, exception1, "");
                    }
                }
                item = CmdEditCopy.m_pEnumFeature.Next();
            }
            workspace.StopEditOperation();
            _context.FocusMap.ClearSelection();
            for (i = 0; i < arrayClass.Count; i++)
            {
                _context.FocusMap.SelectFeature(Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer,
                                                arrayClass.Element[i] as IFeature);
            }
            _context.ActiveView.Refresh();
        }
Ejemplo n.º 27
0
 public void CreateFeature(IGeometry igeometry_0)
 {
     try
     {
         if (igeometry_0 != null)
         {
             IFeatureLayer  featureLayer  = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer;
             IDataset       dataset       = (IDataset)featureLayer.FeatureClass;
             IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)dataset.Workspace;
             int            index         = featureLayer.FeatureClass.FindField(featureLayer.FeatureClass.ShapeFieldName);
             IGeometryDef   geometryDef   = featureLayer.FeatureClass.Fields.get_Field(index).GeometryDef;
             if (geometryDef.HasZ)
             {
                 IZAware iZAware = (IZAware)igeometry_0;
                 iZAware.ZAware = true;
                 IZ     iZ = (IZ)igeometry_0;
                 double constantZ;
                 double num;
                 geometryDef.SpatialReference.GetZDomain(out constantZ, out num);
                 iZ.SetConstantZ(constantZ);
             }
             if (geometryDef.HasM)
             {
                 IMAware iMAware = (IMAware)igeometry_0;
                 iMAware.MAware = true;
             }
             workspaceEdit.StartEditOperation();
             IFeature feature = featureLayer.FeatureClass.CreateFeature();
             if (igeometry_0 is ITopologicalOperator)
             {
                 (igeometry_0 as ITopologicalOperator).Simplify();
             }
             feature.Shape = igeometry_0;
             try
             {
                 IRowSubtypes rowSubtypes = (IRowSubtypes)feature;
                 rowSubtypes.InitDefaultValues();
             }
             catch (Exception exception_)
             {
                 CErrorLog.writeErrorLog(this, exception_, "");
             }
             feature.Store();
             workspaceEdit.StopEditOperation();
             EditorEvent.AddFeature(featureLayer, feature);
             IActiveView activeView = (IActiveView)_context.FocusMap;
             _context.FocusMap.ClearSelection();
             _context.FocusMap.SelectFeature(featureLayer, feature);
             if (igeometry_0.GeometryType == esriGeometryType.esriGeometryPoint)
             {
                 double distance = Common.ConvertPixelsToMapUnits((IActiveView)_context.FocusMap, 30.0);
                 ITopologicalOperator topologicalOperator = (ITopologicalOperator)igeometry_0;
                 topologicalOperator.Buffer(distance);
                 activeView.Refresh();
             }
             else
             {
                 activeView.Refresh();
             }
         }
     }
     catch (COMException ex)
     {
         if (ex.ErrorCode == -2147220936)
         {
             System.Windows.Forms.MessageBox.Show("坐标值或量测值超出范围!", "创建要素",
                                                  System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
         }
     }
 }
Ejemplo n.º 28
0
 public void EndSketch()
 {
     try
     {
         IGeometry geometry = null;
         if (SketchToolAssist.Feedback is INewLineFeedback)
         {
             INewLineFeedback newLineFeedback = (INewLineFeedback)SketchToolAssist.Feedback;
             IPolyline        polyline        = newLineFeedback.Stop();
             if (polyline != null)
             {
                 IPointCollection pointCollection = (IPointCollection)polyline;
                 if (pointCollection.PointCount >= 2)
                 {
                     geometry = (IGeometry)pointCollection;
                     if (SketchShareEx.m_LastPartGeometry != null &&
                         SketchShareEx.m_LastPartGeometry is IPolyline)
                     {
                         IGeometryCollection geometryCollection =
                             SketchShareEx.m_LastPartGeometry as IGeometryCollection;
                         geometryCollection.AddGeometryCollection(polyline as IGeometryCollection);
                         geometry = (geometryCollection as IGeometry);
                         SketchShareEx.m_LastPartGeometry = null;
                     }
                 }
             }
         }
         else if (SketchToolAssist.Feedback is INewPolygonFeedback)
         {
             INewPolygonFeedback newPolygonFeedback = (INewPolygonFeedback)SketchToolAssist.Feedback;
             IPolygon            polygon            = newPolygonFeedback.Stop();
             if (polygon != null)
             {
                 IPointCollection pointCollection = (IPointCollection)polygon;
                 if (pointCollection.PointCount >= 3)
                 {
                     geometry = (IGeometry)pointCollection;
                     if (SketchShareEx.m_LastPartGeometry != null && SketchShareEx.m_LastPartGeometry is IPolygon)
                     {
                         IGeometryCollection geometryCollection =
                             SketchShareEx.m_LastPartGeometry as IGeometryCollection;
                         geometryCollection.AddGeometryCollection(polygon as IGeometryCollection);
                         geometry = (geometryCollection as IGeometry);
                         SketchShareEx.m_LastPartGeometry = null;
                     }
                 }
             }
         }
         if (geometry == null)
         {
             return;
         }
         this.CreateFeature(geometry);
     }
     catch (Exception ex2)
     {
         COMException ex = ex2 as COMException;
         if (ex.ErrorCode == -2147220936)
         {
             System.Windows.Forms.MessageBox.Show("坐标值或量测值超出范围!", "创建要素",
                                                  System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand);
         }
         CErrorLog.writeErrorLog(this, ex2, "");
     }
     _context.ActiveView.Refresh();
     SketchShareEx.m_bInUse    = false;
     SketchShareEx.LastPoint   = null;
     SketchToolAssist.Feedback = null;
     SketchShareEx.PointCount  = 0;
 }
Ejemplo n.º 29
0
        public void LoadData(IList ilist_0)
        {
            IEnumDataset      subsets;
            IDataset          j;
            string            str;
            IFeatureClass     dataset;
            IFeatureLayer     cadFeatureLayerClass;
            ITopologyLayer    topologyLayerClass;
            IEnumFeatureClass classes;
            IFeatureClass     m;
            IFeatureClass     n;
            IFeatureLayer     featureLayerClass;
            List <object>     objs = new List <object>();

            foreach (object ilist0 in ilist_0)
            {
                if (ilist0 is IGxDataset)
                {
                    if ((ilist0 as IGxDataset).Type != esriDatasetType.esriDTFeatureDataset)
                    {
                        objs.Add(ilist0);
                    }
                    else
                    {
                        IEnumGxObject children = (ilist0 as IGxObjectContainer).Children;
                        children.Reset();
                        for (IGxObject i = children.Next(); i != null; i = children.Next())
                        {
                            objs.Add(i);
                        }
                    }
                }
                else if (!(ilist0 is IDataset))
                {
                    objs.Add(ilist0);
                }
                else
                {
                    if ((ilist0 as IDataset).Type != esriDatasetType.esriDTFeatureDataset)
                    {
                        continue;
                    }
                    subsets = (ilist0 as IDataset).Subsets;
                    subsets.Reset();
                    for (j = subsets.Next(); j != null; j = subsets.Next())
                    {
                        objs.Add(j);
                    }
                }
            }
            ProcessAssist processAssist = new ProcessAssist();

            processAssist.InitProgress();
            processAssist.SetMaxValue(objs.Count);
            processAssist.SetMessage("正在加载数据,请稍候...");
            processAssist.Start();
            try
            {
                ILayer layer = null;
                IMap   map   = this.GetMap();
                this.list_0 = new List <ILayer>();
                List <string> strs      = new List <string>();
                IEnvelope     envelope  = null;
                IDataset      item      = null;
                IGxDataset    gxDataset = null;
                for (int k = 0; k < objs.Count; k++)
                {
                    string name = "";
                    if (objs[k] is IGxObject)
                    {
                        name = (objs[k] as IGxObject).Name;
                    }
                    else if (objs[k] is IDataset)
                    {
                        name = (objs[k] as IDataset).Name;
                    }
                    bool flag = true;
                    str = string.Format("加载图层[{0}],第{1}/{2}个", name, k + 1, objs.Count);
                    processAssist.Increment(1);
                    processAssist.SetMessage(str);
                    if (objs[k] is IGxLayer)
                    {
                        layer = (objs[k] as IGxLayer).Layer;
                        if (layer is IGeoDataset && !SpatialReferenctOperator.ValideFeatureClass(layer as IGeoDataset))
                        {
                            strs.Add(layer.Name);
                            flag = false;
                        }
                        this.AddLayer(map, layer, ref envelope, flag);
                    }
                    else if (!(objs[k] is IGxAGSObject))
                    {
                        if (objs[k] is IGxDataset)
                        {
                            gxDataset = objs[k] as IGxDataset;
                            item      = gxDataset.Dataset;
                        }
                        else if (ilist_0[k] is IDataset)
                        {
                            item = objs[k] as IDataset;
                        }
                        if (item != null)
                        {
                            if (item is IGeoDataset)
                            {
                                flag = SpatialReferenctOperator.ValideFeatureClass(item as IGeoDataset);
                            }
                            if (item.Type == esriDatasetType.esriDTFeatureClass)
                            {
                                dataset = (IFeatureClass)item;
                                if ((gxDataset as IGxObject).Category.IndexOf("CAD") != -1)
                                {
                                    if (dataset.FeatureType != esriFeatureType.esriFTCoverageAnnotation)
                                    {
                                        cadFeatureLayerClass = new CadFeatureLayerClass();
                                    }
                                    else
                                    {
                                        cadFeatureLayerClass = new CadAnnotationLayerClass();
                                    }
                                    cadFeatureLayerClass.FeatureClass = dataset;
                                    cadFeatureLayerClass.Name         = dataset.AliasName;
                                }
                                else if (dataset.FeatureType == esriFeatureType.esriFTAnnotation)
                                {
                                    cadFeatureLayerClass = new FDOGraphicsLayerClass()
                                    {
                                        FeatureClass = dataset,
                                        Name         = dataset.AliasName
                                    };
                                }
                                else if (dataset.FeatureType != esriFeatureType.esriFTDimension)
                                {
                                    cadFeatureLayerClass = new FeatureLayerClass()
                                    {
                                        FeatureClass = dataset,
                                        Name         = dataset.AliasName
                                    };
                                }
                                else
                                {
                                    cadFeatureLayerClass = new DimensionLayerClass()
                                    {
                                        FeatureClass = dataset,
                                        Name         = dataset.AliasName
                                    };
                                }
                                if (!flag)
                                {
                                    strs.Add(cadFeatureLayerClass.Name);
                                }
                                this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                            }
                            else if (item.Type == esriDatasetType.esriDTCadDrawing)
                            {
                                if ((gxDataset as IGxObject).Category != "CAD绘图")
                                {
                                    IEnumGxObject enumGxObject = (gxDataset as IGxObjectContainer).Children;
                                    enumGxObject.Reset();
                                    for (IGxDataset l = enumGxObject.Next() as IGxDataset; l != null; l = enumGxObject.Next() as IGxDataset)
                                    {
                                        dataset = l.Dataset as IFeatureClass;
                                        if (dataset != null)
                                        {
                                            if (dataset.FeatureType != esriFeatureType.esriFTAnnotation)
                                            {
                                                cadFeatureLayerClass = new CadFeatureLayerClass()
                                                {
                                                    FeatureClass = dataset,
                                                    Name         = dataset.AliasName
                                                };
                                            }
                                            else
                                            {
                                                cadFeatureLayerClass = new FDOGraphicsLayerClass()
                                                {
                                                    FeatureClass = dataset,
                                                    Name         = dataset.AliasName
                                                };
                                            }
                                            flag = true;
                                            if (cadFeatureLayerClass is IGeoDataset)
                                            {
                                                bool flag1 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                                flag = flag1;
                                                if (!flag1)
                                                {
                                                    strs.Add(cadFeatureLayerClass.Name);
                                                }
                                            }
                                            this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                        }
                                    }
                                }
                                else
                                {
                                    ICadLayer cadLayerClass = new CadLayerClass()
                                    {
                                        CadDrawingDataset = gxDataset.Dataset as ICadDrawingDataset,
                                        Name = gxDataset.Dataset.Name
                                    };
                                    if (!flag)
                                    {
                                        strs.Add(cadLayerClass.Name);
                                    }
                                    this.AddLayer(map, cadLayerClass, ref envelope, flag);
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTFeatureDataset)
                            {
                                subsets = item.Subsets;
                                subsets.Reset();
                                for (j = subsets.Next(); j != null; j = subsets.Next())
                                {
                                    if (j.Type == esriDatasetType.esriDTFeatureClass)
                                    {
                                        dataset = j as IFeatureClass;
                                        if (dataset.FeatureType != esriFeatureType.esriFTAnnotation)
                                        {
                                            cadFeatureLayerClass = new FeatureLayerClass()
                                            {
                                                FeatureClass = dataset,
                                                Name         = dataset.AliasName
                                            };
                                            flag = true;
                                            if (cadFeatureLayerClass is IGeoDataset)
                                            {
                                                bool flag2 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                                flag = flag2;
                                                if (!flag2)
                                                {
                                                    strs.Add(cadFeatureLayerClass.Name);
                                                }
                                            }
                                            this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                        }
                                        else
                                        {
                                            cadFeatureLayerClass = new FDOGraphicsLayerClass()
                                            {
                                                FeatureClass = dataset,
                                                Name         = dataset.AliasName
                                            };
                                            flag = true;
                                            if (cadFeatureLayerClass is IGeoDataset)
                                            {
                                                bool flag3 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                                flag = flag3;
                                                if (!flag3)
                                                {
                                                    strs.Add(cadFeatureLayerClass.Name);
                                                }
                                            }
                                            this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                        }
                                    }
                                    else if (j.Type == esriDatasetType.esriDTTopology)
                                    {
                                        topologyLayerClass = new TopologyLayerClass()
                                        {
                                            Topology = j as ITopology
                                        };
                                        (topologyLayerClass as ILayer).Name = j.Name;
                                        this.AddLayer(map, topologyLayerClass as ILayer, ref envelope, true);
                                    }
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTTopology)
                            {
                                if (MessageBox.Show(string.Concat("是否将参加拓扑-", item.Name, "-的所有要素添加到地图中"), "添加拓扑层", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                                {
                                    classes = (item as IFeatureClassContainer).Classes;
                                    classes.Reset();
                                    for (m = classes.Next(); m != null; m = classes.Next())
                                    {
                                        cadFeatureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = m,
                                            Name         = m.AliasName
                                        };
                                        flag = true;
                                        if (cadFeatureLayerClass is IGeoDataset)
                                        {
                                            bool flag4 = SpatialReferenctOperator.ValideFeatureClass(cadFeatureLayerClass as IGeoDataset);
                                            flag = flag4;
                                            if (!flag4)
                                            {
                                                strs.Add(cadFeatureLayerClass.Name);
                                            }
                                        }
                                        this.AddLayer(map, cadFeatureLayerClass, ref envelope, flag);
                                    }
                                }
                                topologyLayerClass = new TopologyLayerClass()
                                {
                                    Topology = item as ITopology
                                };
                                (topologyLayerClass as ILayer).Name = item.Name;
                                this.AddLayer(map, topologyLayerClass as ILayer, ref envelope, true);
                            }
                            else if (item.Type == esriDatasetType.esriDTTin)
                            {
                                ITinLayer tinLayerClass = new TinLayerClass()
                                {
                                    Dataset = (ITin)item,
                                    Name    = item.Name
                                };
                                flag = true;
                                if (tinLayerClass is IGeoDataset)
                                {
                                    bool flag5 = SpatialReferenctOperator.ValideFeatureClass(tinLayerClass as IGeoDataset);
                                    flag = flag5;
                                    if (!flag5)
                                    {
                                        strs.Add(tinLayerClass.Name);
                                    }
                                }
                                this.AddLayer(map, tinLayerClass, ref envelope, flag);
                            }
                            else if (item.Type == esriDatasetType.esriDTRasterCatalog)
                            {
                                IGdbRasterCatalogLayer gdbRasterCatalogLayerClass = null;
                                gdbRasterCatalogLayerClass = new GdbRasterCatalogLayerClass();
                                if (gdbRasterCatalogLayerClass.Setup((ITable)(item as IRasterCatalog)))
                                {
                                    bool flag6 = SpatialReferenctOperator.ValideFeatureClass(gdbRasterCatalogLayerClass as IGeoDataset);
                                    flag = flag6;
                                    if (!flag6)
                                    {
                                        strs.Add((gdbRasterCatalogLayerClass as ILayer).Name);
                                    }
                                    this.AddLayer(map, gdbRasterCatalogLayerClass as ILayer, ref envelope, flag);
                                }
                            }
                            else if (!(item.Type == esriDatasetType.esriDTRasterDataset ? false : item.Type != esriDatasetType.esriDTRasterBand))
                            {
                                bool flag7 = true;
                                if (!((IRasterPyramid)item).Present)
                                {
                                    if (this.m_pApp.PyramidPromptType == PyramidPromptType.AlwaysBuildNoPrompt)
                                    {
                                        ((IRasterPyramid)item).Create();
                                    }
                                    else if (this.m_pApp.PyramidPromptType == PyramidPromptType.AlwaysPrompt)
                                    {
                                        DialogResult dialogResult = BuildPyramidSet.Show();
                                        if (dialogResult == DialogResult.Yes)
                                        {
                                            ((IRasterPyramid)item).Create();
                                        }
                                        else if (dialogResult == DialogResult.Cancel)
                                        {
                                            flag7 = false;
                                        }
                                    }
                                }
                                if (flag7)
                                {
                                    IRasterLayer rasterLayerClass = new RasterLayerClass()
                                    {
                                        Cached = true
                                    };
                                    rasterLayerClass.CreateFromDataset((IRasterDataset)item);
                                    rasterLayerClass.Name = item.Name;
                                    bool flag8 = SpatialReferenctOperator.ValideFeatureClass(rasterLayerClass as IGeoDataset);
                                    flag = flag8;
                                    if (!flag8)
                                    {
                                        strs.Add(rasterLayerClass.Name);
                                    }
                                    this.AddLayer(map, rasterLayerClass, ref envelope, flag);
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTTable)
                            {
                                try
                                {
                                    IStandaloneTableCollection standaloneTableCollection = this.GetMap() as IStandaloneTableCollection;
                                    IPropertySet connectionProperties = item.Workspace.ConnectionProperties;
                                    bool         flag9 = false;
                                    int          num   = 0;
                                    while (true)
                                    {
                                        if (num < standaloneTableCollection.StandaloneTableCount)
                                        {
                                            ITable table = standaloneTableCollection.StandaloneTable[num].Table;
                                            if (!connectionProperties.IsEqual((table as IDataset).Workspace.ConnectionProperties) || !((table as IDataset).Name == item.Name))
                                            {
                                                num++;
                                            }
                                            else
                                            {
                                                flag9 = true;
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    if (!flag9)
                                    {
                                        standaloneTableCollection.AddStandaloneTable(new StandaloneTableClass()
                                        {
                                            Table = item as ITable
                                        });
                                    }
                                }
                                catch (Exception exception)
                                {
                                    CErrorLog.writeErrorLog(this, exception, "");
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTGeometricNetwork)
                            {
                                IGeometricNetwork geometricNetwork = item as IGeometricNetwork;
                                if (geometricNetwork != null)
                                {
                                    IEnumFeatureClass classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTSimpleJunction];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                    classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTComplexJunction];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                    classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTSimpleEdge];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                    classesByType = geometricNetwork.ClassesByType[esriFeatureType.esriFTComplexEdge];
                                    classesByType.Reset();
                                    for (n = classesByType.Next(); n != null; n = classesByType.Next())
                                    {
                                        featureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = n,
                                            Name         = (n as IDataset).Name
                                        };
                                        this.AddLayer(map, featureLayerClass, ref envelope, true);
                                    }
                                }
                            }
                            else if (item.Type == esriDatasetType.esriDTNetworkDataset)
                            {
                                INetworkLayer networkLayerClass = new NetworkLayerClass()
                                {
                                    NetworkDataset = item as INetworkDataset
                                };
                                this.AddLayer(map, networkLayerClass as ILayer, ref envelope, true);
                                if (MessageBox.Show(string.Concat("是否将参加网络要素集-", item.Name, "-的所有要素添加到地图中"), "添加拓扑层", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                                {
                                    classes = (item as IFeatureClassContainer).Classes;
                                    classes.Reset();
                                    for (m = classes.Next(); m != null; m = classes.Next())
                                    {
                                        cadFeatureLayerClass = new FeatureLayerClass()
                                        {
                                            FeatureClass = m,
                                            Name         = m.AliasName
                                        };
                                        this.AddLayer(map, cadFeatureLayerClass, ref envelope, true);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        IMapServerLayer mapServerLayerClass = new MapServerLayerClass();
                        mapServerLayerClass.ServerConnect((objs[k] as IGxAGSObject).AGSServerObjectName, (objs[k] as IGxAGSObject).DefaultMapName);
                        this.AddLayer(map, mapServerLayerClass as ILayer, ref envelope, false);
                    }
                }
                processAssist.End();
                bool layerCount = this.GetMap().LayerCount > 0;
                if (strs.Count > 0)
                {
                    MessageBox.Show("警告:数据范围不一致。\r\n 一个或多个添加的图层范围与关联的空间坐标系范围不一致。请检查数据问题。存在问题图层信息请查看错误日志!", "管理平台", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (string str1 in strs)
                    {
                        if (stringBuilder.Length > 0)
                        {
                            stringBuilder.Append(",");
                        }
                        stringBuilder.Append(str1);
                    }
                    CErrorLog.writeErrorLog(stringBuilder, null, "图层范围不一致!");
                }
                foreach (ILayer list0 in this.list_0)
                {
                    list0.Visible = true;
                }
                if (layerCount && envelope != null)
                {
                    IMap map1 = this.GetMap();
                    ISpatialReference spatialReference = map1.SpatialReference;
                    if ((spatialReference is IUnknownCoordinateSystem || envelope.SpatialReference is IUnknownCoordinateSystem || envelope.SpatialReference == null ? false : spatialReference != null))
                    {
                        envelope.Project(spatialReference);
                    }
                    (map1 as IActiveView).Extent = envelope;
                    (map1 as IActiveView).Refresh();
                }
                if (this.m_pApp != null)
                {
                    this.m_pApp.MapDocumentChanged();
                }
                else if (ApplicationRef.Application != null)
                {
                    ApplicationRef.Application.MapDocumentChanged();
                }
            }
            catch (Exception exception1)
            {
                str = exception1.ToString();
            }
            if (this.onLoadCompleteHand_0 != null)
            {
                this.onLoadCompleteHand_0();
            }
        }
Ejemplo n.º 30
0
        public void LoadData(IList ilist_0)
        {
            try
            {
                List <ILayer> list = new List <ILayer>();
                for (int i = 0; i < ilist_0.Count; i++)
                {
                    if (ilist_0[i] is IGxLayer)
                    {
                        list.Add((ilist_0[i] as IGxLayer).Layer);
                    }
                    else
                    {
                        IGxDataset gxDataset = ilist_0[i] as IGxDataset;
                        if (gxDataset != null)
                        {
                            IDataset dataset = gxDataset.Dataset;
                            if (dataset != null)
                            {
                                if (dataset.Type == esriDatasetType.esriDTFeatureClass)
                                {
                                    IFeatureClass featureClass = (IFeatureClass)dataset;
                                    IFeatureLayer featureLayer;
                                    if ((gxDataset as IGxObject).Category.IndexOf("CAD") != -1)
                                    {
                                        if (featureClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
                                        {
                                            featureLayer = new CadAnnotationLayer() as IFeatureLayer;
                                        }
                                        else
                                        {
                                            featureLayer = new CadFeatureLayer() as IFeatureLayer;
                                        }
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    else if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                    {
                                        featureLayer = new FDOGraphicsLayer() as IFeatureLayer;
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    else if (featureClass.FeatureType == esriFeatureType.esriFTDimension)
                                    {
                                        featureLayer = new DimensionLayer() as IFeatureLayer;
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    else
                                    {
                                        featureLayer = new FeatureLayer();
                                        featureLayer.FeatureClass = featureClass;
                                        featureLayer.Name         = featureClass.AliasName;
                                    }
                                    list.Add(featureLayer);
                                }
                                else if (dataset.Type == esriDatasetType.esriDTCadDrawing)
                                {
                                    if ((gxDataset as IGxObject).Category == "CAD绘图")
                                    {
                                        ICadLayer item = new CadLayer() as ICadLayer;
                                        item.CadDrawingDataset = gxDataset.Dataset as ICadDrawingDataset;
                                        item.Name = gxDataset.Dataset.Name;
                                        list.Add(item);
                                    }
                                    else
                                    {
                                        IEnumGxObject children = (gxDataset as IGxObjectContainer).Children;
                                        children.Reset();
                                        for (IGxDataset gxDataset2 = children.Next() as IGxDataset; gxDataset2 != null; gxDataset2 = (children.Next() as IGxDataset))
                                        {
                                            IFeatureClass featureClass = gxDataset2.Dataset as IFeatureClass;
                                            if (featureClass != null)
                                            {
                                                IFeatureLayer featureLayer;
                                                if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                                {
                                                    featureLayer = new FDOGraphicsLayer() as IFeatureLayer;
                                                    featureLayer.FeatureClass = featureClass;
                                                    featureLayer.Name         = featureClass.AliasName;
                                                }
                                                else
                                                {
                                                    featureLayer = new CadFeatureLayer() as IFeatureLayer;
                                                    featureLayer.FeatureClass = featureClass;
                                                    featureLayer.Name         = featureClass.AliasName;
                                                }
                                                list.Add(featureLayer);
                                            }
                                        }
                                    }
                                }
                                else if (dataset.Type == esriDatasetType.esriDTFeatureDataset)
                                {
                                    IEnumDataset subsets = dataset.Subsets;
                                    subsets.Reset();
                                    for (IDataset dataset2 = subsets.Next(); dataset2 != null; dataset2 = subsets.Next())
                                    {
                                        if (dataset2.Type == esriDatasetType.esriDTFeatureClass)
                                        {
                                            IFeatureClass featureClass = dataset2 as IFeatureClass;
                                            if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                                            {
                                                IFeatureLayer item = new FDOGraphicsLayer() as IFeatureLayer;
                                                item.FeatureClass = featureClass;
                                                item.Name         = featureClass.AliasName;
                                                list.Add(item);
                                            }
                                            else
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass,
                                                    Name         = featureClass.AliasName
                                                });
                                            }
                                        }
                                        else if (dataset2.Type == esriDatasetType.esriDTTopology)
                                        {
                                            ITopologyLayer topologyLayer = new TopologyLayer() as ITopologyLayer;
                                            topologyLayer.Topology         = (dataset2 as ITopology);
                                            (topologyLayer as ILayer).Name = dataset2.Name;
                                            list.Add(topologyLayer as ILayer);
                                        }
                                    }
                                }
                                else if (dataset.Type == esriDatasetType.esriDTTopology)
                                {
                                    if (System.Windows.Forms.MessageBox.Show("是否将参加拓扑-" + dataset.Name + "-的所有要素添加到地图中", "添加拓扑层", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        IEnumFeatureClass classes = (dataset as IFeatureClassContainer).Classes;
                                        classes.Reset();
                                        for (IFeatureClass featureClass2 = classes.Next(); featureClass2 != null; featureClass2 = classes.Next())
                                        {
                                            list.Add(new FeatureLayer
                                            {
                                                FeatureClass = featureClass2,
                                                Name         = featureClass2.AliasName
                                            });
                                        }
                                    }
                                    ITopologyLayer topologyLayer = new TopologyLayer() as ITopologyLayer;
                                    topologyLayer.Topology         = (dataset as ITopology);
                                    (topologyLayer as ILayer).Name = dataset.Name;
                                    list.Add(topologyLayer as ILayer);
                                }
                                else if (dataset.Type == esriDatasetType.esriDTTin)
                                {
                                    list.Add(new TinLayer
                                    {
                                        Dataset = (ITin)dataset,
                                        Name    = dataset.Name
                                    });
                                }
                                else if (dataset.Type == esriDatasetType.esriDTRasterDataset || dataset.Type == esriDatasetType.esriDTRasterBand)
                                {
                                    bool flag = true;
                                    if (!((IRasterPyramid)dataset).Present)
                                    {
                                        if (ApplicationRef.PyramidPromptType == PyramidPromptType.AlwaysBuildNoPrompt)
                                        {
                                            ((IRasterPyramid)dataset).Create();
                                        }
                                        else if (ApplicationRef.PyramidPromptType == PyramidPromptType.AlwaysPrompt)
                                        {
                                            System.Windows.Forms.DialogResult dialogResult = BuildPyramidSet.Show();
                                            if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                                            {
                                                ((IRasterPyramid)dataset).Create();
                                            }
                                            else if (dialogResult == System.Windows.Forms.DialogResult.Cancel)
                                            {
                                                flag = false;
                                            }
                                        }
                                    }
                                    if (flag)
                                    {
                                        IRasterLayer rasterLayer = new RasterLayer
                                        {
                                            Cached = true
                                        };
                                        rasterLayer.CreateFromDataset((IRasterDataset)dataset);
                                        rasterLayer.Name = dataset.Name;
                                        list.Add(rasterLayer);
                                    }
                                }
                                else
                                {
                                    if (dataset.Type == esriDatasetType.esriDTTable)
                                    {
                                        try
                                        {
                                            IRasterCatalogTable rasterCatalogTable = new RasterCatalogTable();
                                            rasterCatalogTable.Table = (ITable)dataset;
                                            rasterCatalogTable.Update();
                                            IRasterCatalogLayer rasterCatalogLayer = new RasterCatalogLayer() as IRasterCatalogLayer;
                                            rasterCatalogLayer.Create(rasterCatalogTable);
                                            rasterCatalogLayer.Name = dataset.BrowseName;
                                            list.Add(rasterCatalogLayer);
                                            goto IL_8B0;
                                        }
                                        catch (Exception ex)
                                        {
                                            try
                                            {
                                                IStandaloneTableCollection standaloneTableCollection = this.method_0() as IStandaloneTableCollection;
                                                IPropertySet connectionProperties = dataset.Workspace.ConnectionProperties;
                                                bool         flag2 = false;
                                                for (int j = 0; j < standaloneTableCollection.StandaloneTableCount; j++)
                                                {
                                                    ITable table = standaloneTableCollection.get_StandaloneTable(j).Table;
                                                    if (
                                                        connectionProperties.IsEqual(
                                                            (table as IDataset).Workspace.ConnectionProperties) &&
                                                        (table as IDataset).Name == dataset.Name)
                                                    {
                                                        flag2 = true;
                                                    }
                                                    else
                                                    {
                                                        standaloneTableCollection.AddStandaloneTable(new StandaloneTable
                                                        {
                                                            Table = dataset as ITable
                                                        });
                                                    }
                                                }
                                            }
                                            catch (Exception exception_)
                                            {
                                                CErrorLog.writeErrorLog(this, exception_, "");
                                            }

                                            goto IL_8B0;
                                        }
                                    }
                                    if (dataset.Type == esriDatasetType.esriDTGeometricNetwork)
                                    {
                                        IGeometricNetwork geometricNetwork = dataset as IGeometricNetwork;
                                        if (geometricNetwork != null)
                                        {
                                            IEnumFeatureClass enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                            enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                            enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                            enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
                                            enumFeatureClass.Reset();
                                            for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass3,
                                                    Name         = (featureClass3 as IDataset).Name
                                                });
                                            }
                                        }
                                    }
                                    else if (dataset.Type == esriDatasetType.esriDTNetworkDataset)
                                    {
                                        INetworkDataset networkDataset = dataset as INetworkDataset;
                                        INetworkLayer   item           = new NetworkLayer() as INetworkLayer;
                                        item.NetworkDataset = networkDataset;

                                        list.Add(item as ILayer);
                                        if (System.Windows.Forms.MessageBox.Show("是否将参加网络要素集-" + dataset.Name + "-的所有要素添加到地图中", "添加拓扑层", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Yes)
                                        {
                                            IEnumFeatureClass classes = (dataset as IFeatureClassContainer).Classes;
                                            classes.Reset();
                                            for (IFeatureClass featureClass2 = classes.Next(); featureClass2 != null; featureClass2 = classes.Next())
                                            {
                                                list.Add(new FeatureLayer
                                                {
                                                    FeatureClass = featureClass2,
                                                    Name         = featureClass2.AliasName
                                                });
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    IL_8B0 :;
                }
                int    num   = list.Count;
                ILayer layer = null;
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IRasterCatalogLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IRasterLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is ITinLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is ICadLayer)
                    {
                        this.method_0().AddLayer(layer);
                        (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                        list.RemoveAt(i);
                        num--;
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer featureLayer = layer as IFeatureLayer;
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass.ShapeType == esriGeometryType.esriGeometryPolygon || featureClass.ShapeType == esriGeometryType.esriGeometryEnvelope)
                        {
                            this.method_0().AddLayer(layer);
                            (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                            list.RemoveAt(i);
                            num--;
                        }
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer featureLayer = layer as IFeatureLayer;
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass.ShapeType == esriGeometryType.esriGeometryLine || featureClass.ShapeType == esriGeometryType.esriGeometryBezier3Curve || featureClass.ShapeType == esriGeometryType.esriGeometryCircularArc || featureClass.ShapeType == esriGeometryType.esriGeometryEllipticArc || featureClass.ShapeType == esriGeometryType.esriGeometryPath || featureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                        {
                            try
                            {
                                this.method_0().AddLayer(layer);
                                goto IL_B56;
                            }
                            catch
                            {
                                goto IL_B56;
                            }
                            goto IL_B4D;
IL_B56:
                            (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                            list.RemoveAt(i);
                            num--;
                        }
                    }
                    IL_B4D :;
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    if (layer is IFeatureLayer)
                    {
                        IFeatureLayer featureLayer = layer as IFeatureLayer;
                        IFeatureClass featureClass = featureLayer.FeatureClass;
                        if (featureClass.ShapeType == esriGeometryType.esriGeometryMultipoint || featureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                        {
                            this.method_0().AddLayer(layer);
                            (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                            list.RemoveAt(i);
                            num--;
                        }
                    }
                }
                for (int i = num - 1; i >= 0; i--)
                {
                    layer = list[i];
                    this.method_0().AddLayer(layer);
                    (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null);
                    list.RemoveAt(i);
                    num--;
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }