コード例 #1
0
        public override void Click()
        {
            IMap map = OpenMapDialog.Open();

            if (map != null)
            {
                IMapControl m = (_hook as IHookOfAgileMap).MapControl;
                m.Apply(map);
                m.ReRender();
            }
        }
コード例 #2
0
ファイル: cmdAddLayer.cs プロジェクト: configare/hispeed
        public override void Click()
        {
            IMapControl mapControl = (_hook as IHookOfAgileMap).MapControl;

            if (mapControl != null)
            {
                using (IDataSource ds = DataSourceDialog.OpenDataSource())
                {
                    if (ds == null)
                    {
                        return;
                    }
                    ILayer layer = null;
                    if (ds is IFeatureDataSource)
                    {
                        IFeatureClass fetc = new FeatureClass(ds as FeatureDataSourceBase);
                        layer = new FeatureLayer(ds.Name, fetc);
                    }
                    //else if (ds is IRasterDataSource)
                    //{
                    //    layer = new RasterLayer(ds.Name, new RasterClass((ds as IRasterDataSource).Url));
                    //}
                    if (mapControl.Map == null)
                    {
                        IMap map = new Map(new ILayer[] { layer });
                        map.Name = "新地图";
                        mapControl.Apply(map);
                    }
                    else
                    {
                        mapControl.Map.LayerContainer.Append(layer as ILayer);
                    }
                    mapControl.ReRender();
                }
            }
        }