Exemplo n.º 1
0
 protected internal void OnLayerAdded()
 {
     if (LayerAdded != null)
     {
         LayerAdded.Invoke(this, EventArgs.Empty);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Fires the LayerAdded event.
        /// </summary>
        /// <param name="sender">The layer that was added.</param>
        /// <param name="e">LayerEventArgs.</param>
        protected virtual void OnLayerAdded(object sender, LayerEventArgs e)
        {
            if (EventsSuspended)
            {
                return;
            }

            LayerAdded?.Invoke(sender, e);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a layer to the game state.
        /// </summary>
        /// <param name="key">used to reference the added layer in other game objects</param>
        /// <param name="sortIndex">
        /// sort position in reference to the default 0, layers are drawn from lowest to highest
        /// </param>
        public Layer Add(string key, int sortIndex)
        {
            var layer = new Layer(key, sortIndex);

            _layers.Add(layer);
            _layers.Sort((a, b) => a.SortIndex.CompareTo(b.SortIndex));
            LayerAdded?.Invoke(this, new LayerAddedEvent(layer));
            return(layer);
        }
        public BendyLayer GetOrCreateLayer(string id)
        {
            BendyLayer res;

            if (!_layers.TryGetValue(id, out res))
            {
                var fixedId = id.ToUpperInvariant();
                _layers.Add(id, res = new BendyLayer(this, fixedId));
                LayerAdded?.Invoke(fixedId, res);
            }

            return(res);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 初始化地图及其图层/表格控制、鹰眼图、导航工具的组合控件
        /// </summary>
        public MapViewer()
        {
            InitializeComponent();
            MxdLaoder               = new MapDocLoader(axMapControlMainMap, axPageLayoutControl);
            _measureTool            = new MeasureTools(axMapControlMainMap);
            measureResultLabel.Text = "";
            _layer2FieldsMenuItems  = new Dictionary <string, ToolStripMenuItem[]>();
            LayerRemoved            = (obj, evt) =>
            {
                if (_attributeForm != null && !_attributeForm.IsDisposed && _attributeForm.FeatLayer != null)
                {
                    _attributeForm.Clear();
                }
            };
            MapActiveViewEvents = axMapControlMainMap.Map as IActiveViewEvents_Event;
            //向map/PageLayout中添加数据,包括图层、表格等都会触发ItemAdded事件
            MapActiveViewEvents.ItemAdded += (item) =>
            {
                if (item is ILayer layer)
                {
                    LayerAdded?.Invoke(layer, new EventArgs());
                    GoToMapView();
                    GotoLayerToc();
                }
                else if (item is ITable table)
                {
                    this.tableListBox1.AddTable(table);
                    GoToMapView();
                    GotoTableListBox();
                }
            };

            _toolBarMenu = new ToolbarMenuClass();//工具栏菜单类
            _toolBarMenu.AddItem(new ControlsMapViewMenuClass(), 0, 0, false, esriCommandStyles.esriCommandStyleMenuBar);
            _toolBarMenu.AddItem(new ControlsMapPanToolClass(), 0, 0, false, esriCommandStyles.esriCommandStyleMenuBar);
            _toolBarMenu.AddItem(new ControlsMapZoomOutToolClass(), 0, 0, false, esriCommandStyles.esriCommandStyleMenuBar);
            _toolBarMenu.AddItem(new ControlsMapZoomInToolClass(), 0, 0, false, esriCommandStyles.esriCommandStyleMenuBar);
            _toolBarMenu.SetHook(axMapControlMainMap.Object);
        }
        private async Task AddLayerAsync(Layer layer)
        {
            FeatureLayer         featureLayer    = layer as FeatureLayer;
            GlobeSpotter         globeSpotter    = GlobeSpotter.Current;
            CycloMediaGroupLayer cycloGrouplayer = globeSpotter?.CycloMediaGroupLayer;

            if ((featureLayer != null) && (cycloGrouplayer != null) && (!cycloGrouplayer.IsKnownName(featureLayer.Name)))
            {
                if (!this.Aggregate(false, (current, vecLayer) => (vecLayer.Layer == layer) || current))
                {
                    var  vectorLayer = new VectorLayer(featureLayer, this);
                    bool initialized = await vectorLayer.InitializeEventsAsync();

                    if (initialized)
                    {
                        Add(vectorLayer);
                        vectorLayer.PropertyChanged += OnVectorLayerPropertyChanged;
                        LayerAdded?.Invoke(vectorLayer);
                    }
                }
            }
        }
Exemplo n.º 7
0
        private async Task AddLayerAsync(Layer layer)
        {
            FeatureLayer         featureLayer    = layer as FeatureLayer;
            ModuleStreetSmart    streetSmart     = ModuleStreetSmart.Current;
            CycloMediaGroupLayer cycloGrouplayer = streetSmart?.CycloMediaGroupLayer;

            if (featureLayer != null && cycloGrouplayer != null && !cycloGrouplayer.IsKnownName(featureLayer.Name))
            {
                if (!this.Aggregate(false, (current, vecLayer) => vecLayer.Layer == layer || current))
                {
                    var  vectorLayer = new VectorLayer(featureLayer, this);
                    bool initialized = await vectorLayer.InitializeEventsAsync();

                    if (initialized)
                    {
                        Add(vectorLayer);
                        vectorLayer.PropertyChanged += OnVectorLayerPropertyChanged;
                        LayerAdded?.Invoke(vectorLayer);
                    }
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Simply echo this event out to members above this group that might be listening to it.
 /// </summary>
 /// <param name="sender">Sender that raised the event.</param>
 /// <param name="e">The event args.</param>
 protected virtual void OnLayerAdded(object sender, LayerEventArgs e)
 {
     LayerAdded?.Invoke(sender, e);
 }
Exemplo n.º 9
0
 private void OnLayerAdded(ILayer layer)
 {
     LayerAdded?.Invoke(layer);
 }
Exemplo n.º 10
0
        /// <summary>
        /// 添加图层
        /// </summary>
        /// <param name="layer">图层</param>
        public void AddLayer(Layer layer)
        {
            //计算投影
            if (layer.GeoType == typeof(PointD))
            {
                PointD sPoint;
                foreach (DataRow mRow in layer.Records.Rows)
                {
                    sPoint = mRow.Field <PointD>(1);
                    if (sPoint != null)
                    {
                        mRow[2] = _PrjSystem.ToProjCo(sPoint);
                    }
                }
            }
            else if (layer.GeoType == typeof(MultiPolyLine))
            {
                MultiPolyLine sMultiPolyLine;
                foreach (DataRow mRow in layer.Records.Rows)
                {
                    sMultiPolyLine = mRow.Field <MultiPolyLine>(1);
                    if (sMultiPolyLine != null)
                    {
                        mRow[2] = _PrjSystem.ToProjCo(sMultiPolyLine);
                    }
                }
            }
            else if (layer.GeoType == typeof(MultiPolygon))
            {
                MultiPolygon sMultiPolygon;
                foreach (DataRow mRow in layer.Records.Rows)
                {
                    sMultiPolygon = mRow.Field <MultiPolygon>(1);
                    if (sMultiPolygon != null)
                    {
                        mRow[2] = _PrjSystem.ToProjCo(sMultiPolygon);
                    }
                }
            }

            Geometry sGeo;

            foreach (DataRow mRow in layer.Records.Rows)
            {
                if (!Convert.IsDBNull(mRow[2]))
                {
                    sGeo    = (Geometry)mRow[2];
                    mRow[3] = LayerTools.GetCenterPoint(sGeo);
                }
            }
            if (layer.MBR == null)
            {
                layer.MBR = LayerTools.GetLayerGeoMBR(layer);
            }

            layer.PRJMBR = _PrjSystem.ToProjCo(layer.MBR);
            layer.Records.AcceptChanges(); //保存更改
            layer.GenerateIndex();         //计算地理索引

            //将地图数据锁住,不允许修改
            layer.ReadOnly = true;


            layer.VisiblityChanged += Layer_VisiblityChanged;
            layer.SymbolChanged    += Layer_SymbolChanged;
            layer.RecordsChanged   += Layer_RecordsChanged;

            _Layers.Insert(0, layer);
            if (_DataSet.Tables.Contains(layer.Name))
            {
                layer.Name += "_";
            }
            _DataSet.Tables.Add(layer.Records);
            _TreeNode.Nodes.Insert(0, layer.Node);

            LayerAdded?.Invoke(this, layer);    //通知外部已经添加了图层
            MapPerformaceChanged?.Invoke(this); //重绘一级地图
        }
Exemplo n.º 11
0
 private void btAdd_Click(object Sender, System.EventArgs E)
 {
     LayerAdded?.Invoke();
 }