Esempio n. 1
0
        //public async Task<QueryResult>
        //    QueryEntitiesByID(QueryEntitiesArgs args, string layerName)
        //{
        //    QueryResult queryResult = null;

        //    // Objs field must be filled
        //    if (_localFeatureService == null || args.Objs == null)
        //        return queryResult;

        //    EngineeringLayer eLayer = _eMap.GetELayerByName(layerName);
        //    if (eLayer == null)
        //        return queryResult;

        //    string url = _localFeatureService.UrlFeatureService
        //        + "/" + eLayer.LocalLayerID;

        //    QueryTask queryTask = new QueryTask(new Uri(url));

        //    Query query = new Query("1=1");
        //    query.OutFields.Add("*");
        //    query.ReturnGeometry = true;
        //    query.OutSpatialReference = _srEMap;
        //    query.Where = QueryCondition(args.Objs);

        //    try
        //    {
        //        IsBusy = true;
        //        queryResult = await queryTask.ExecuteAsync(query);
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }
        //    IsBusy = false;
        //    return queryResult;
        //}

        //public async Task<QueryResult>
        //    QueryEntitiesByGeom(QueryEntitiesArgs args, EngineeringLayer layer)
        //{
        //    QueryResult queryResult = null;

        //    if (_localFeatureService == null || layer == null)
        //        return queryResult;

        //    string url = _localFeatureService.UrlFeatureService
        //        + "/" + layer.LocalLayerID;

        //    QueryTask queryTask = new QueryTask(new Uri(url));

        //    Query query = new Query("1=1");
        //    query.OutFields.Add("*");
        //    query.ReturnGeometry = true;
        //    query.OutSpatialReference = _srEMap;
        //    query.Geometry = args.Geometry;
        //    query.Where = args.Condition;

        //    try
        //    {
        //        IsBusy = true;
        //        queryResult = await queryTask.ExecuteAsync(query);
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }
        //    IsBusy = false;
        //    return queryResult;
        //}
        #endregion

        #region map pan functions
        public void panToObjects(IEnumerable <DGObject> objs)
        {
            if (objs == null)
            {
                return;
            }
            IGraphicCollection allGraphics = new IS3GraphicCollection();

            foreach (DGObject obj in objs)
            {
                if (obj == null || obj.parent == null)
                {
                    continue;
                }
                string         layerID = obj.parent.definition.GISLayerName;
                IGraphicsLayer layer   = _map.Layers[layerID] as IGraphicsLayer;
                if (layer == null)
                {
                    continue;
                }
                IGraphicCollection gc = layer.getGraphics(obj);
                if (gc == null)
                {
                    continue;
                }
                allGraphics.Add(gc);
            }
            panToGraphics(allGraphics);
        }
Esempio n. 2
0
        public void LabelQueryInfo(string name, string strContent, IPoint pt, IMap pMap, bool isRemoveLast)
        {
            //获取并激活Graphic标注图层
            if (pt == null)
            {
                return;
            }
            IActiveView             pActiveView             = pMap as IActiveView;
            ICompositeGraphicsLayer pCompositeGraphicsLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer;

            //WeatherLabel标记组,通过ArcMap的Layers Properties的Annotation group可以看到
            IGraphicsLayer pGraphicsLayer = pCompositeGraphicsLayer.FindLayer("WeatherLabel");

            pMap.ActiveGraphicsLayer = pGraphicsLayer as ILayer;
            pGraphicsLayer.Activate(pActiveView.ScreenDisplay);
            IGraphicsContainer pGraphicsContainer = pGraphicsLayer as IGraphicsContainer;//转换到图形容器接口

            IElementCollection pElementCollection = new ElementCollectionClass();

            AddBalloonCalloutLabel(name, strContent, pt, pElementCollection);//我们需要一个新的私有函数来实现设置标签元素背景,BalloonCallout对象

            //添加标注
            if (isRemoveLast == true)
            {
                pGraphicsContainer.DeleteAllElements();
            }

            pGraphicsContainer.AddElements(pElementCollection, 1000);

            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds);
        }
Esempio n. 3
0
        //----------------------------------干扰源定位中的绘制

        // 绘制线段
        public static void DrawLine(IPoint p1, IPoint p2, int r, int g, int b)
        {
            IPolyline line     = new PolylineClass();
            object    _missing = Type.Missing;

            line.FromPoint = p1;
            line.ToPoint   = p2;

            ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();

            lineSymbol.Color = ColorUtilities.GetColor(r, g, b);
            lineSymbol.Width = 0.25;

            ILineElement lineElement = new LineElementClass();

            lineElement.Symbol = lineSymbol;

            IElement element = lineElement as IElement;

            element.Geometry = line as IGeometry;

            IGraphicsLayer       pLayer = (GISMapApplication.Instance.Scene as IBasicMap).BasicGraphicsLayer;
            IGraphicsContainer3D pGC    = pLayer as IGraphicsContainer3D;

            pGC.AddElement(element);
        }
Esempio n. 4
0
        /// <summary>
        /// 设置存储在地图上的注记的字体和大小
        /// </summary>
        /// <param name="map"></param>
        /// <param name="graphicsLayerName"></param>
        /// <param name="fontName">注记字体(此值为""、空白字符或null,则不改变注记字体)</param>
        /// <param name="size">注记大小(此值小于等于0,则不改变注记大小)</param>
        public static void SetAnnotationFontOnMap(this IMap map, string graphicsLayerName, string fontName = null, int size = 0)
        {
            IGraphicsLayer     graphicsLayer    = map.GetGraphicsLayer(graphicsLayerName);
            IGraphicsContainer graphicContainer = graphicsLayer as IGraphicsContainer;
            var txtElements = graphicContainer.GetTextElements();

            foreach (var txtElement in txtElements)
            {
                ITextSymbol txtSymbol = txtElement.Symbol;
                //注意不能使用下面这一句,直接设置txtElement.Symbol.Size = size 是无效的,原因未知
                //txtElement.Symbol.Size = size;

                if (size > 0)
                {
                    txtSymbol.Size = size;
                }

                if (!string.IsNullOrEmpty(fontName) && fontName.Trim() != string.Empty)
                {
                    System.Drawing.Font font     = new System.Drawing.Font(fontName, (float)txtSymbol.Size);
                    IFontDisp           fontDisp = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(font) as IFontDisp;
                    txtSymbol.Font = fontDisp;
                }
                txtElement.Symbol = txtSymbol;
                graphicContainer.UpdateElement(txtElement as IElement);
            }
        }
Esempio n. 5
0
        public int syncObjects()
        {
            if (_prj == null)
            {
                return(0);
            }

            int count = 0;

            foreach (Layer layer in _map.Layers)
            {
                List <DGObjects> objsList = _prj.Get2dRelatedObjs(layer.ID);
                if ((objsList == null) || (objsList.Count == 0))
                {
                    continue;
                }
                IGraphicsLayer myLayer = layer as IGraphicsLayer;
                if (myLayer == null)
                {
                    continue;
                }
                foreach (DGObjects objs in objsList)
                {
                    count += myLayer.syncObjects(objs);
                }
            }
            return(count);
        }
Esempio n. 6
0
 public bool DeleteAllElements(IGraphicsLayer pGraphicsLayer)
 {
     try
     {
         if ((pGraphicsLayer != null) && (pGraphicsLayer is IGraphicsContainer))
         {
             IGraphicsContainer container = pGraphicsLayer as IGraphicsContainer;
             try
             {
                 container.DeleteAllElements();
             }
             catch (Exception)
             {
             }
         }
         else
         {
             return(false);
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "DeleteAllElements", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
        private void WireGraphicsEvents()
        {
            try
            {
                if (m_naWindowEventSource == null)
                {
                    return;
                }

                if (m_graphicsEventSource != null)
                {
                    UnWireGraphicsEvents();
                }

                IMap           activeMap     = ActiveMap;
                IGraphicsLayer graphicsLayer = null;
                if (activeMap != null)
                {
                    graphicsLayer = activeMap.BasicGraphicsLayer;
                }

                if (graphicsLayer != null)
                {
                    m_graphicsEventSource = (IGraphicsContainer)graphicsLayer;
                }

                if (m_graphicsEventSource == null)
                {
                    return;
                }

                UpdateGraphicsEIDArrayParameterValues();

                //Create an instance of the delegate, add it to AllElementsDeleted event
                m_AllGraphicsDeleted = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_AllElementsDeletedEventHandler(OnAllGraphicsDeleted);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).AllElementsDeleted += m_AllGraphicsDeleted;

                //Create an instance of the delegate, add it to ElementAdded event
                m_GraphicAdded = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementAddedEventHandler(OnGraphicAdded);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementAdded += m_GraphicAdded;

                //Create an instance of the delegate, add it to ElementDeleted event
                m_GraphicDeleted = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementDeletedEventHandler(OnGraphicDeleted);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementDeleted += m_GraphicDeleted;

                //Create an instance of the delegate, add it to ElementsAdded event
                m_GraphicsAdded = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementsAddedEventHandler(OnGraphicsAdded);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementsAdded += m_GraphicsAdded;

                //Create an instance of the delegate, add it to ElementUpdated event
                m_GraphicUpdated = new ESRI.ArcGIS.Carto.IGraphicsContainerEvents_ElementUpdatedEventHandler(OnGraphicUpdated);
                ((ESRI.ArcGIS.Carto.IGraphicsContainerEvents_Event)(m_graphicsEventSource)).ElementUpdated += m_GraphicUpdated;
            }
            catch (Exception ex)
            {
                string msg = SubsetHelperUI.GetFullExceptionMessage(ex);
                MessageBox.Show(msg, "Wire Graphics Events");
            }
        }
Esempio n. 8
0
        private void frm3DSpacedistance_FormClosing(object sender, FormClosingEventArgs e)
        {
            IGraphicsLayer       player = m_pCurrentSceneControl.Scene.BasicGraphicsLayer;
            IGraphicsContainer3D pgraphiccontainer3d = (IGraphicsContainer3D)player;

            pgraphiccontainer3d.DeleteAllElements();
            m_pCurrentSceneControl.SceneGraph.RefreshViewers();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pgraphiccontainer3d);
            Dispose();
        }
Esempio n. 9
0
 public void highlightAll(bool on = true)
 {
     foreach (Layer layer in _map.Layers)
     {
         IGraphicsLayer gLayer = layer as IGraphicsLayer;
         if (gLayer == null)
         {
             continue;
         }
         gLayer.highlightAll(on);
     }
 }
        private void DeleteRealTimeGraphicsLayer()
        {
            if (_graphicsLayer == null)
            {
                return;
            }
            //Only delete from the focus map (active data frame)
            var gLayers = (ICompositeGraphicsLayer)MxDocument.FocusMap.BasicGraphicsLayer;

            gLayers.DeleteLayer(Defaults.GraphicsLayerName);
            _graphicsLayer = null;
        }
Esempio n. 11
0
        void revLabels_RemoveLabelsEvent()
        {
            IMap                    pMap                    = axMapControl1.Map;
            IActiveView             pActiveView             = pMap as IActiveView;
            ICompositeGraphicsLayer pCompositeGraphicsLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer;
            IGraphicsLayer          pGraphicsLayer          = pCompositeGraphicsLayer.FindLayer("WeatherLabel");

            IGraphicsContainer pGraphicsContainer = pGraphicsLayer as IGraphicsContainer;

            pGraphicsContainer.DeleteAllElements();
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds);
        }
Esempio n. 12
0
        public void highlightObjects(IEnumerable <DGObject> objs,
                                     string layerID, bool on = true)
        {
            if (objs == null)
            {
                return;
            }
            IGraphicsLayer gLayer = _map.Layers[layerID] as IGraphicsLayer;

            if (gLayer == null)
            {
                return;
            }
            gLayer.highlightObject(objs, on);
        }
Esempio n. 13
0
        public void highlightObject(DGObject obj, bool on = true)
        {
            if (obj == null || obj.parent == null)
            {
                return;
            }
            string         layerID = obj.parent.definition.GISLayerName;
            IGraphicsLayer gLayer  = _map.Layers[layerID] as IGraphicsLayer;

            if (gLayer == null)
            {
                return;
            }
            gLayer.highlightObject(obj, on);
        }
Esempio n. 14
0
        public void panToSelected()
        {
            IGraphicCollection allGraphics = new IS3GraphicCollection();

            foreach (Layer layer in _map.Layers)
            {
                IGraphicsLayer gLayer = layer as IGraphicsLayer;
                if (gLayer == null)
                {
                    continue;
                }
                allGraphics.Add(gLayer.selectedGraphics);
            }
            panToGraphics(allGraphics);
        }
Esempio n. 15
0
        //在view中加载图形,和同步图形
        void SyncToView()
        {
            IView view = InputCB.SelectedItem as IView;

            //为图形赋值“Name”属性,以便图形和数据关联
            foreach (int monID in _MonGraphics.Keys)
            {
                MonPoint           mp = _allMons[monID] as MonPoint;
                IGraphicCollection gc = _MonGraphics[monID];
                foreach (IGraphic g in gc)
                {
                    g.Attributes["Name"] = mp.name;
                }
            }

            //将图形添加到view中
            string         layerID = "DemoLayer";                 //图层ID
            IGraphicsLayer gLayer  = getDemoLayer(view, layerID); //获取图层函数

            foreach (int id in _MonGraphics.Keys)
            {
                IGraphicCollection gc = _MonGraphics[id];
                gLayer.addGraphics(gc);
            }

            //使数据与图形关联
            List <DGObject> sls = _allMons.merge();

            gLayer.syncObjects(sls);

            //计算新建图形范围,并在地图中显示该范围
            IEnvelope ext = null;

            foreach (IGraphicCollection gc in _MonGraphics.Values)
            {
                IEnvelope itemExt = GraphicsUtil.GetGraphicsEnvelope(gc);
                if (ext == null)
                {
                    ext = itemExt;
                }
                else
                {
                    ext = ext.Union(itemExt);
                }
            }
            _mainFrame.activeView = view;
            view.zoomTo(ext);
        }
Esempio n. 16
0
        protected virtual void DefaultDrawingELayerToXml(XElement root)
        {
            IGraphicsLayer     gLayer = DefaultDrawingELayer.GraphicsLayer;
            IGraphicCollection gc     = IS3Runtime.GraphicEngine.NewGraphicCollection();

            foreach (IGraphic g in gLayer.Graphics)
            {
                gc.Add(g);
            }

            XElement parent = new XElement("DefaultDrawingELayer");
            XElement node   = GraphicsSerializer.GraphicsToXml(gc);

            parent.Add(node);
            root.Add(parent);
        }
Esempio n. 17
0
        //获取新建图层
        IGraphicsLayer getDemoLayer(IView view, string layerID)
        {
            IGraphicsLayer gLayer = view.getLayer(layerID);

            if (gLayer == null)
            {
                gLayer = Runtime.graphicEngine.newGraphicsLayer(
                    layerID, layerID);
                var sym_fill = GraphicsUtil.GetDefaultFillSymbol();
                var renderer = Runtime.graphicEngine.newSimpleRenderer(sym_fill);
                gLayer.setRenderer(renderer);
                gLayer.Opacity = 0.9;
                view.addLayer(gLayer);
            }
            return(gLayer);
        }
Esempio n. 18
0
        public async void selectByRect()
        {
            if (Globals.isThreadUnsafe())
            {
                Globals.application.Dispatcher.Invoke(new Action(() =>
                {
                    selectByRect();
                }));
                return;
            }

            Geometry geom = await _mapView.Editor.RequestShapeAsync(DrawShape.Rectangle);

            if (_srEMap != null)
            {
                geom = GeometryEngine.Project(geom, _srEMap);
            }
            IGeometry rect = IS3GeometryEngine.fromGeometry(geom);

            ObjSelectionChangedEventArgs args = new ObjSelectionChangedEventArgs();

            args.addedObjs = new Dictionary <string, IEnumerable <DGObject> >();

            foreach (Layer layer in _map.Layers)
            {
                IGraphicsLayer gLayer = layer as IGraphicsLayer;
                if (!isLayerSelectable(gLayer))
                {
                    continue;
                }
                List <DGObject> objs = gLayer.selectObjectsByRect(rect);
                if (objs.Count > 0)
                {
                    //old
                    // args.addedObjs.Add(gLayer.ID, objs);
                    args.addedObjs.Add(objs.FirstOrDefault().parent.definition.Name, objs);
                }
            }

            if (objSelectionChangedTrigger != null)
            {
                objSelectionChangedTrigger(this, args);
            }
        }
Esempio n. 19
0
        private void OnActiveViewEventsSelectionChanged()
        {
            m_CompoLyr = this.axMapControl1.Map.ActiveGraphicsLayer as ICompositeLayer;

            for (int i = 0; i < m_CompoLyr.Count; i++)
            {
                IGraphicsLayer m_GraphicsLyr = (IGraphicsLayer)m_CompoLyr.Layer[i];

                IGraphicsContainerSelect m_GConatinerSelect = m_GraphicsLyr as IGraphicsContainerSelect;

                if (m_GConatinerSelect.ElementSelectionCount != 1)
                {
                    //MessageBox.Show("Select only one graphic element");
                }

                else
                {
                    IElement m_Element = (IElement)m_GConatinerSelect.SelectedElements.Next();

                    if (m_Element is ITextElement)
                    {
                        if (this.m_Form_LabelEdit == null)
                        {
                            m_Form_LabelEdit = new Form_LabelEdit();
                            m_Form_LabelEdit.m_ActiveView  = this.axMapControl1.ActiveView;
                            m_Form_LabelEdit.m_TextElement = (ITextElement)m_Element;

                            m_Form_LabelEdit.Show();
                        }

                        else
                        {
                            m_Form_LabelEdit = new Form_LabelEdit();
                            m_Form_LabelEdit.m_ActiveView  = this.axMapControl1.ActiveView;
                            m_Form_LabelEdit.m_TextElement = (ITextElement)m_Element;

                            m_Form_LabelEdit.Show();
                        }
                    }
                }

                this.axMapControl1.ActiveView.Refresh();
            }
        }
Esempio n. 20
0
        private void AddSelectedElementByGraphicsSubLayer(string SubLayerName, IElement element)
        {
            IGraphicsLayer     sublayer = FindOrCreateGraphicsSubLayer(SubLayerName);
            IGraphicsContainer gc       = sublayer as IGraphicsContainer;

            gc.DeleteAllElements();
            gc.AddElement(element, 0);
            if (element.Geometry.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                IEnvelope pEnvelope = new EnvelopeClass();
                pEnvelope.XMin      = ((ESRI.ArcGIS.Geometry.IPoint)element.Geometry).X - 0.2;
                pEnvelope.XMax      = ((ESRI.ArcGIS.Geometry.IPoint)element.Geometry).X + 0.2;
                pEnvelope.YMin      = ((ESRI.ArcGIS.Geometry.IPoint)element.Geometry).Y - 0.2;
                pEnvelope.YMax      = ((ESRI.ArcGIS.Geometry.IPoint)element.Geometry).Y + 0.2;
                axMapControl.Extent = pEnvelope;
            }
            // axMapControl.FlashShape(element.Geometry);
            //axMapControl.Map.SelectByShape(element.Geometry, null, false);
        }
Esempio n. 21
0
        public int syncObjects(string layerID, List <DGObject> objs)
        {
            if (_prj == null)
            {
                return(0);
            }
            int count = 0;

            if (_map.Layers[layerID] != null)
            {
                IGraphicsLayer layer = _map.Layers[layerID] as IGraphicsLayer;
                if (layer != null)
                {
                    count += layer.syncObjects(objs);
                }
            }

            return(count);
        }
Esempio n. 22
0
 public bool AddGraphicsLayer(IBasicMap pBasicMap, IGroupLayer pParentLayer, string sLayerName)
 {
     try
     {
         if (sLayerName == null)
         {
             sLayerName = "";
         }
         if (pBasicMap == null)
         {
             return(false);
         }
         if (string.IsNullOrEmpty(sLayerName))
         {
             sLayerName = "<新建图像图层>";
         }
         IGraphicsLayer layer = null;
         if (this.FindGraphicsLayer(pBasicMap, sLayerName) == null)
         {
             layer = new CompositeGraphicsLayerClass();
             ILayer layer2 = null;
             layer2      = layer as ILayer;
             layer2.Name = sLayerName;
             pBasicMap.AddLayer(layer as ILayer);
             IMapLayers layers = pBasicMap as IMapLayers;
             if (pParentLayer == null)
             {
                 layers.MoveLayer(layer2, 0);
             }
             else if (pBasicMap is IMap)
             {
                 layers.MoveLayerEx(pParentLayer, pParentLayer, layer2, 0);
             }
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.LayerFun", "AddGraphicsLayer", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Esempio n. 23
0
        public void ShowCoordinatesOnMap(AxGlobeControl axGlobeControl)
        {
            try
            {
                ITextSymbol pTextSymbol = new TextSymbolClass();
                //pTextSymbol.Font = new Font("Consolas", 10, FontStyle.Regular);    //设置字体
                pTextSymbol.Size = 12;          //字体大小
                pTextSymbol.Color = BaseGISTools.TransColorToAEColor(Color.White);    //字体颜色

                myTextElement = new TextElementClass(); ;
                myTextElement.Symbol = pTextSymbol; //设置样式
                myTextElement.Text = "这是现实的信息 \n 这是第二行 \n 这是第三行";

                graphicsLayer = axGlobeControl.GlobeDisplay.Scene.BasicGraphicsLayer;
                graphicsContain3D = (IGraphicsContainer3D)graphicsLayer;
                graphicsContain3D.AddElement(myTextElement as IElement);
                axGlobeControl.GlobeDisplay.RefreshViewers();
            }
            catch { }
        }
Esempio n. 24
0
        public int syncObjects()
        {
            if (_prj == null)
            {
                return(0);
            }

            int count = 0;

            foreach (string defID in _prj.objsDefIndex.Keys)
            {
                DGObjects      objs  = _prj.objsDefIndex[defID];
                IGraphicsLayer layer = _map.Layers[objs.definition.GISLayerName] as IGraphicsLayer;
                if (layer == null)
                {
                    continue;
                }
                count += layer.syncObjects(objs);
            }
            return(count);
        }
Esempio n. 25
0
        public async Task <IGraphicsLayer> addGdbLayer(LayerDef eLayer,
                                                       string dbFile, int start = 0, int maxFeatures = 0)
        {
            if (dbFile == null)
            {
                dbFile = _eMap.LocalGeoDbFileName;
            }

            string filePath = _prj.projDef.LocalFilePath + "\\" + dbFile;

            if (File.Exists(filePath))
            {
                Geodatabase gdb = await Geodatabase.OpenAsync(filePath);

                IGraphicsLayer gLayer = await addGeodatabaseLayer(
                    eLayer, gdb, start, maxFeatures);

                return(gLayer);
            }
            return(null);
        }
Esempio n. 26
0
        public void ShowCoordinatesOnMap(AxGlobeControl axGlobeControl)
        {
            try
            {
                ITextSymbol pTextSymbol = new TextSymbolClass();
                //pTextSymbol.Font = new Font("Consolas", 10, FontStyle.Regular);    //设置字体
                pTextSymbol.Size  = 12;                                            //字体大小
                pTextSymbol.Color = BaseGISTools.TransColorToAEColor(Color.White); //字体颜色


                myTextElement        = new TextElementClass();;
                myTextElement.Symbol = pTextSymbol; //设置样式
                myTextElement.Text   = "这是现实的信息 \n 这是第二行 \n 这是第三行";


                graphicsLayer     = axGlobeControl.GlobeDisplay.Scene.BasicGraphicsLayer;
                graphicsContain3D = (IGraphicsContainer3D)graphicsLayer;
                graphicsContain3D.AddElement(myTextElement as IElement);
                axGlobeControl.GlobeDisplay.RefreshViewers();
            }
            catch { }
        }
Esempio n. 27
0
        protected virtual void DefaultDrawingELayerFromXml(XElement root)
        {
            XElement parent = root.Descendants().First();

            if (parent.Name != "DefaultDrawingELayer")
            {
                return;
            }

            XElement           node     = parent.Descendants().First();
            IGraphicCollection graphics =
                GraphicsSerializer.GraphicsFromXml(node);

            if (graphics == null)
            {
                return;
            }

            IGraphicsLayer gLayer = DefaultDrawingELayer.GraphicsLayer;

            _view.AddGraphics(gLayer, graphics);
        }
Esempio n. 28
0
        private IGraphicsLayer FindOrCreateGraphicsSubLayer(string SubLayerName)
        {
            IMap                    Map1 = axMapControl.Map;
            IGraphicsLayer          gl   = Map1.BasicGraphicsLayer;
            ICompositeGraphicsLayer cgl  = gl as ICompositeGraphicsLayer;
            IGraphicsLayer          sublayer;

            try
            {
                sublayer = cgl.FindLayer(SubLayerName);
                if (sublayer == null)
                {
                    sublayer = cgl.AddLayer(SubLayerName, null);
                }
            }
            catch (Exception ex)
            {
                sublayer = cgl.AddLayer(SubLayerName, null);
            }

            return(sublayer);
        }
Esempio n. 29
0
        public int syncObjects()
        {
            if (_prj == null)
            {
                return(0);
            }

            int count = 0;

            foreach (string layerID in _prj.objsLayerIndex.Keys)
            {
                DGObjects      objs  = _prj.objsLayerIndex[layerID];
                IGraphicsLayer layer = _map.Layers[layerID] as IGraphicsLayer;
                if (layer == null)
                {
                    continue;
                }
                count += layer.syncObjects(objs);
            }

            return(count);
        }
Esempio n. 30
0
 public IGraphicsLayer FindGraphicsLayer(IBasicMap pBasicMap, string sLayerName)
 {
     try
     {
         if (pBasicMap == null)
         {
             return(null);
         }
         if (pBasicMap.LayerCount <= 0)
         {
             return(null);
         }
         if (string.IsNullOrEmpty(sLayerName))
         {
             return(null);
         }
         ICompositeGraphicsLayer basicGraphicsLayer = null;
         basicGraphicsLayer = pBasicMap.BasicGraphicsLayer as ICompositeGraphicsLayer;
         IGraphicsLayer layer2 = null;
         try
         {
             layer2 = basicGraphicsLayer.FindLayer(sLayerName);
         }
         catch (Exception)
         {
             return(pBasicMap.BasicGraphicsLayer);
         }
         if (layer2 == null)
         {
             return(null);
         }
         return(layer2);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.LayerFun", "FindGraphicsLayer", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(null);
     }
 }
Esempio n. 31
0
 public bool CopyGraphicsLayerElements(IActiveView pSourceActiveView, IGraphicsLayer pTargetGLayer, bool bSelect, bool bPreserve)
 {
     try
     {
         if (pSourceActiveView == null)
         {
             return(false);
         }
         if (pTargetGLayer == null)
         {
             return(false);
         }
         if (!(pSourceActiveView is IGraphicsContainer))
         {
             return(false);
         }
         IGraphicsContainer container = null;
         container = pSourceActiveView as IGraphicsContainer;
         container.Reset();
         container.LocateElementsByEnvelope(pSourceActiveView.FullExtent).Reset();
         IElement element2 = null;
         IElement pElement = null;
         for (element2 = container.Next(); element2 != null; element2 = container.Next())
         {
             pElement = GISFunFactory.SystemFun.CloneObejct(element2 as IClone) as IElement;
             if (!this.AddElement(pTargetGLayer, pElement, bSelect, bPreserve))
             {
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "CopyGraphicsLayerElements", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Esempio n. 32
0
 public void addLayer(IGraphicsLayer layer)
 {
     _map.Layers.Add(layer as IS3GraphicsLayer);
 }
Esempio n. 33
0
        public bool isLayerSelectable(IGraphicsLayer gLayer)
        {
            if (gLayer == null)
                return false;
            if (gLayer.IsVisible == false)
                return false;

            if (_selectableLayerIDs.Count == 0)
                return true;
            else if (_selectableLayerIDs.Contains(gLayer.ID))
                return true;
            else
                return false;
        }
Esempio n. 34
0
 /// <summary>
 /// Adds a graphical element to this scene.
 /// </summary>
 /// <param name="layer">Element inheriting from IGraphicsLayer.</param>
 public void Add(IGraphicsLayer layer)
 {
     layer.Initialize(Device);
     Layers.Add(layer);
 }
Esempio n. 35
0
        public static List<Tuple<IGraphic, string>> GetPolylines(IGraphicsLayer gLayer)
        {
            if (gLayer == null)
                return null;

            List<Tuple<IGraphic, string>> result = new List<Tuple<IGraphic, string>>();
            int i = 1;
            foreach (IGraphic g in gLayer.graphics)
            {
                IGeometry geom = g.Geometry;
                if (geom == null)
                    continue;
                if (geom.GeometryType == GeometryType.Polyline)
                {
                    Tuple<IGraphic, string> turple = new Tuple<IGraphic, string>(
                        g, "Polyline#" + i.ToString());
                    i++;
                    result.Add(turple);
                }
            }
            return result;
        }
Esempio n. 36
0
 public void addLayer(IGraphicsLayer layer){}