Esempio n. 1
0
        public void SeparateFigures(CadFigure fig, int pointIdx)
        {
            var res = CadFigureCutter.Cut(mDB, fig, pointIdx);

            if (!res.isValid())
            {
                return;
            }

            CadOpeList opeRoot = new CadOpeList();
            CadOpe     ope;

            foreach (EditResult.Item ri in res.AddList)
            {
                CadLayer layer = mDB.GetLayer(ri.LayerID);

                ope = new CadOpeAddFigure(ri.LayerID, ri.FigureID);
                opeRoot.OpeList.Add(ope);

                layer.AddFigure(ri.Figure);
            }

            foreach (EditResult.Item ri in res.RemoveList)
            {
                CadLayer layer = mDB.GetLayer(ri.LayerID);

                ope = new CadOpeRemoveFigure(layer, ri.FigureID);
                opeRoot.OpeList.Add(ope);

                layer.RemoveFigureByID(ri.FigureID);
            }

            HistoryMan.foward(opeRoot);
        }
Esempio n. 2
0
        public void Update(bool remakeTree, bool filter, CadLayer layer)
        {
            if (filter)
            {
                CadLayerTreeItem item = new CadLayerTreeItem();
                item.AddChildren(layer, fig =>
                {
                    return(fig.HasSelectedPointInclueChild());
                });

                AttachRoot(item);
                Redraw();
            }
            else
            {
                if (remakeTree)
                {
                    CadLayerTreeItem item = new CadLayerTreeItem(layer);
                    AttachRoot(item);
                    Redraw();
                }
                else
                {
                    Redraw();
                }
            }
        }
Esempio n. 3
0
        public void FlipAndCopyWithPlane(List <CadFigure> rootFigList, Vector3d p0, Vector3d normal)
        {
            List <CadFigure> cpy = PlotterClipboard.CopyFigures(rootFigList);

            CadOpeList opeRoot = new CadOpeList();

            CadLayer layer = Controller.CurrentLayer;

            foreach (CadFigure fig in cpy)
            {
                fig.ForEachFig(f =>
                {
                    FlipWithPlane(f, p0, normal);
                    Controller.DB.AddFigure(f);
                });

                layer.AddFigure(fig);

                CadOpe ope = new CadOpeAddFigure(layer.ID, fig.ID);
                opeRoot.OpeList.Add(ope);
            }

            Controller.HistoryMan.foward(opeRoot);

            RunOnMainThread(() =>
            {
                Controller.Redraw();
                Controller.UpdateObjectTree(remakeTree: true);
            });
        }
Esempio n. 4
0
        private void ChangeLayerFigList(CadLayer layer, List <CadFigure> newFigList)
        {
            HistoryMan.foward(new CadOpeChangeFigureList(layer, layer.FigureList, newFigList));

            layer.FigureList = newFigList;

            Callback.UpdateObjectTree(true);
        }
Esempio n. 5
0
        public static MpLayer_v1001 Create(CadLayer layer)
        {
            MpLayer_v1001 ret = new MpLayer_v1001();

            ret.ID      = layer.ID;
            ret.Visible = layer.Visible;
            ret.Locked  = layer.Locked;

            ret.FigureIdList = MpUtil_v1001.FigureListToIdList(layer.FigureList);

            return(ret);
        }
Esempio n. 6
0
        public void AddChildren(CadLayer layer)
        {
            Layer = layer;

            for (int i = 0; i < Layer.FigureList.Count; i++)
            {
                CadFigure fig = Layer.FigureList[i];

                CadObjTreeItem item = new CadFigTreeItem(fig);
                Add(item);
            }
        }
Esempio n. 7
0
        public void AddLayer(string name)
        {
            CadLayer layer = mDB.NewLayer();

            layer.Name = name;

            CurrentLayer = layer;

            mDB.LayerList.Add(layer);

            UpdateLayerList();

            ItConsole.println("Layer added.  Name:" + layer.Name + " ID:" + layer.ID);
        }
Esempio n. 8
0
        public CadLayer Restore(Dictionary <uint, CadFigure> dic)
        {
            CadLayer ret = new CadLayer();

            ret.ID         = ID;
            ret.Visible    = Visible;
            ret.Locked     = Locked;
            ret.FigureList = new List <CadFigure>();

            for (int i = 0; i < FigureIdList.Count; i++)
            {
                ret.AddFigure(dic[FigureIdList[i]]);
            }

            return(ret);
        }
Esempio n. 9
0
        public CadObjectDB Restore()
        {
            CadObjectDB ret = new CadObjectDB();

            ret.LayerIdProvider.Counter = LayerIdCount;
            ret.FigIdProvider.Counter   = FigureIdCount;

            // Figure map
            List <CadFigure> figList = MpUtil_v1001.FigureListFromMp_v1001(FigureList);

            var dic = new Dictionary <uint, CadFigure>();

            for (int i = 0; i < figList.Count; i++)
            {
                CadFigure fig = figList[i];

                dic.Add(fig.ID, fig);
                FigureList[i].TempFigure = fig;
            }

            ret.FigureMap = dic;


            // Child list
            for (int i = 0; i < figList.Count; i++)
            {
                MpFigure_v1001 mpfig = FigureList[i];
                SetFigChild(mpfig, dic);
            }


            // Layer map
            ret.LayerList = MpUtil_v1001.LayerListFromMp(LayerList, dic);

            ret.LayerMap = new Dictionary <uint, CadLayer>();

            for (int i = 0; i < ret.LayerList.Count; i++)
            {
                CadLayer layer = ret.LayerList[i];

                ret.LayerMap.Add(layer.ID, layer);
            }

            ret.CurrentLayerID = CurrentLayerID;

            return(ret);
        }
Esempio n. 10
0
        public void AddChildren(CadLayer layer, Func <CadFigure, bool> filterFunc)
        {
            Layer = layer;

            for (int i = 0; i < Layer.FigureList.Count; i++)
            {
                CadFigure fig = Layer.FigureList[i];

                if (!filterFunc(fig))
                {
                    continue;
                }

                CadObjTreeItem item = new CadFigTreeItem(fig);
                Add(item);
            }
        }
Esempio n. 11
0
        public void ClearLayer(uint layerID)
        {
            if (layerID == 0)
            {
                layerID = CurrentLayer.ID;
            }

            CadLayer layer = mDB.GetLayer(layerID);

            if (layer == null)
            {
                return;
            }

            CadOpeList opeList = layer.Clear();

            HistoryMan.foward(opeList);
        }
Esempio n. 12
0
        public void CutSegment(MarkSegment ms)
        {
            if (!ms.Valid)
            {
                return;
            }

            if (!ms.CrossPoint.IsValid())
            {
                return;
            }

            var res = CadSegmentCutter.CutSegment(mDB, ms, ms.CrossPoint);

            if (!res.isValid())
            {
                return;
            }

            CadOpeList opeRoot = new CadOpeList();
            CadOpe     ope;

            foreach (EditResult.Item ri in res.AddList)
            {
                CadLayer layer = mDB.GetLayer(ri.LayerID);

                ope = new CadOpeAddFigure(ri.LayerID, ri.FigureID);
                opeRoot.OpeList.Add(ope);

                layer.AddFigure(ri.Figure);
            }

            foreach (EditResult.Item ri in res.RemoveList)
            {
                CadLayer layer = mDB.GetLayer(ri.LayerID);

                ope = new CadOpeRemoveFigure(layer, ri.FigureID);
                opeRoot.OpeList.Add(ope);

                layer.RemoveFigureByID(ri.FigureID);
            }

            HistoryMan.foward(opeRoot);
        }
Esempio n. 13
0
        public void RemoveLayer(uint id)
        {
            if (mDB.LayerList.Count == 1)
            {
                return;
            }

            CadLayer layer = mDB.GetLayer(id);

            if (layer == null)
            {
                return;
            }

            int index = mDB.LayerIndex(id);

            int nextCurrentIdx = -1;

            if (CurrentLayer.ID == id)
            {
                nextCurrentIdx = mDB.LayerIndex(CurrentLayer.ID);
            }

            CadOpeRemoveLayer ope = new CadOpeRemoveLayer(layer, index);

            HistoryMan.foward(ope);

            mDB.RemoveLayer(id);

            if (nextCurrentIdx >= 0)
            {
                if (nextCurrentIdx > mDB.LayerList.Count - 1)
                {
                    nextCurrentIdx = mDB.LayerList.Count - 1;
                }

                CurrentLayer = mDB.LayerList[nextCurrentIdx];
            }

            UpdateLayerList();
            ItConsole.println("Layer removed.  Name:" + layer.Name + " ID:" + layer.ID);
        }
Esempio n. 14
0
        private void test009()
        {
            DrawContext dc = Controller.DC;

            CadObjectDB db = Controller.DB;

            Stopwatch sw = new Stopwatch();

            sw.Start();

            int i        = 0;
            int layerCnt = db.LayerList.Count;

            for (; i < layerCnt; i++)
            {
                CadLayer layer = db.LayerList[i];

                int j      = 0;
                int figCnt = layer.FigureList.Count;

                for (; j < figCnt; j++)
                {
                    CadFigure fig = layer.FigureList[j];

                    int k    = 0;
                    int pcnt = fig.PointList.Count;

                    for (; k < pcnt; k++)
                    {
                        CadVertex p  = fig.PointList[k];
                        CadVertex sp = dc.WorldPointToDevPoint(p);
                    }
                }
            }

            sw.Stop();
            DOut.pl(sw.ElapsedMilliseconds.ToString() + " milli sec");
        }
Esempio n. 15
0
 public CadLayerTreeItem(CadLayer layer)
 {
     AddChildren(layer);
 }
Esempio n. 16
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();
            }
        }
Esempio n. 17
0
        public static void AddDataset(IBasicMap ibasicMap_0, IDataset idataset_0, string string_0)
        {
            if (string_0 == null)
            {
                string_0 = "";
            }
            switch (idataset_0.Type)
            {
            case esriDatasetType.esriDTFeatureDataset:
            {
                IEnumDataset subsets = idataset_0.Subsets;
                subsets.Reset();
                for (IDataset dataset2 = subsets.Next(); dataset2 != null; dataset2 = subsets.Next())
                {
                    AddDataset(ibasicMap_0, dataset2, string_0);
                }
                break;
            }

            case esriDatasetType.esriDTFeatureClass:
            {
                IFeatureLayer layer;
                IFeatureClass class2 = (IFeatureClass)idataset_0;
                if (class2.FeatureType != esriFeatureType.esriFTAnnotation)
                {
                    if (class2.FeatureType == esriFeatureType.esriFTDimension)
                    {
                        IFeatureLayer dimensionLayer = new DimensionLayer() as IFeatureLayer;
                        dimensionLayer.FeatureClass = class2;
                        dimensionLayer.Name         = string_0 + class2.AliasName;
                        layer = dimensionLayer as IFeatureLayer;
                        ibasicMap_0.AddLayer(layer);
                    }
                    else
                    {
                        layer = new FeatureLayer
                        {
                            FeatureClass = class2,
                            Name         = string_0 + class2.AliasName
                        };
                        ibasicMap_0.AddLayer(layer);
                    }
                    break;
                }
                layer = new FDOGraphicsLayer() as IFeatureLayer;
                try
                {
                    layer.FeatureClass = class2;
                    layer.Name         = string_0 + class2.AliasName;
                    ibasicMap_0.AddLayer(layer);
                }
                catch (Exception exception)
                {
                    exception.ToString();
                }
                break;
            }

            case esriDatasetType.esriDTGeometricNetwork:
            {
                IGeometricNetwork network = idataset_0 as IGeometricNetwork;
                if (network != null)
                {
                    IFeatureLayer     layer7;
                    IEnumFeatureClass class3 = network.get_ClassesByType(esriFeatureType.esriFTSimpleJunction);
                    class3.Reset();
                    IFeatureClass class4 = class3.Next();
                    while (class4 != null)
                    {
                        layer7 = new FeatureLayer
                        {
                            FeatureClass = class4,
                            Name         = string_0 + (class4 as IDataset).Name
                        };
                        ibasicMap_0.AddLayer(layer7);
                        class4 = class3.Next();
                    }
                    class3 = network.get_ClassesByType(esriFeatureType.esriFTComplexJunction);
                    class3.Reset();
                    for (class4 = class3.Next(); class4 != null; class4 = class3.Next())
                    {
                        layer7 = new FeatureLayer
                        {
                            FeatureClass = class4,
                            Name         = string_0 + (class4 as IDataset).Name
                        };
                        ibasicMap_0.AddLayer(layer7);
                    }
                    class3 = network.get_ClassesByType(esriFeatureType.esriFTSimpleEdge);
                    class3.Reset();
                    for (class4 = class3.Next(); class4 != null; class4 = class3.Next())
                    {
                        layer7 = new FeatureLayer
                        {
                            FeatureClass = class4,
                            Name         = string_0 + (class4 as IDataset).Name
                        };
                        ibasicMap_0.AddLayer(layer7);
                    }
                    class3 = network.get_ClassesByType(esriFeatureType.esriFTComplexEdge);
                    class3.Reset();
                    for (class4 = class3.Next(); class4 != null; class4 = class3.Next())
                    {
                        layer7 = new FeatureLayer
                        {
                            FeatureClass = class4,
                            Name         = string_0 + (class4 as IDataset).Name
                        };
                        ibasicMap_0.AddLayer(layer7);
                    }
                }
                break;
            }

            case esriDatasetType.esriDTTopology:
            {
                ITopologyLayer layer = new TopologyLayer() as ITopologyLayer;
                layer.Topology = idataset_0 as ITopology;
                ITopologyLayer layer3 = layer as ITopologyLayer;
                (layer3 as ILayer).Name = string_0 + idataset_0.Name;
                ibasicMap_0.AddLayer(layer3 as ILayer);
                break;
            }

            case esriDatasetType.esriDTTable:
                try
                {
                    IRasterCatalogTable pCatalog = new RasterCatalogTable
                    {
                        Table = (ITable)idataset_0
                    };
                    pCatalog.Update();
                    IRasterCatalogLayer pLayer = new RasterCatalogLayer() as IRasterCatalogLayer;
                    pLayer.Create(pCatalog);
                    pLayer.Name = string_0 + idataset_0.BrowseName;
                    ibasicMap_0.AddLayer(pLayer);
                }
                catch
                {
                    try
                    {
                        IStandaloneTableCollection tables = ibasicMap_0 as IStandaloneTableCollection;
                        IPropertySet connectionProperties = idataset_0.Workspace.ConnectionProperties;
                        bool         flag = false;
                        for (int i = 0; i < tables.StandaloneTableCount; i++)
                        {
                            ITable table = tables.get_StandaloneTable(i).Table;
                            if (connectionProperties.IsEqual((table as IDataset).Workspace.ConnectionProperties) &&
                                ((table as IDataset).Name == idataset_0.Name))
                            {
                                goto Label_03E1;
                            }
                        }
                        goto Label_03E4;
Label_03E1:
                        flag = true;
Label_03E4:
                        if (!flag)
                        {
                            IStandaloneTable table3 = new StandaloneTable
                            {
                                Table = idataset_0 as ITable
                            };
                            tables.AddStandaloneTable(table3);
                        }
                    }
                    catch (Exception exception2)
                    {
                        CErrorLog.writeErrorLog(null, exception2, "");
                    }
                }
                break;

            case esriDatasetType.esriDTRasterDataset:
            case esriDatasetType.esriDTRasterBand:
            {
                IRasterLayer layer5 = new RasterLayer();
                layer5.CreateFromDataset((IRasterDataset)idataset_0);
                layer5.Name = string_0 + idataset_0.Name;
                ibasicMap_0.AddLayer(layer5);
                break;
            }

            case esriDatasetType.esriDTTin:
            {
                ITinLayer layer4 = new TinLayer
                {
                    Dataset = (ITin)idataset_0,
                    Name    = string_0 + idataset_0.Name
                };
                ibasicMap_0.AddLayer(layer4);
                break;
            }

            case esriDatasetType.esriDTCadDrawing:
            {
                ICadLayer layer2 = new CadLayer() as ICadLayer;
                layer2.CadDrawingDataset = idataset_0 as ICadDrawingDataset;
                layer2.Name = idataset_0.Name;
                ibasicMap_0.AddLayer(layer2);
                break;
            }
            }
        }