private void CollectLayers(ILayerCollection ll, List <Layer> res) { if (ll.Layers != null) { foreach (var l in ll.Layers) { res.Add(l); CollectLayers(l, res); } } }
private void Configure() { Layers = new LayerCollection(MapFrame, this); StateLocked = false; IsDragable = true; IsExpanded = true; ContextMenuItems = new List <SymbologyMenuItem> { new SymbologyMenuItem("Remove Group", RemoveClick), new SymbologyMenuItem("Zoom to Group", (sender, args) => ZoomToGroup()), new SymbologyMenuItem("Create new Group", CreateGroupClick) }; }
public static IList <ILayer> AddLayers(IMap map, ILayerCollection layerCollection) { var layers = new List <ILayer>(); OpenFileDialog dg = new OpenFileDialog() { Filter = "*.img,*.shp|*.img;*.shp", Multiselect = true }; if (dg.ShowDialog(Window.GetWindow(map as DependencyObject)).HasValue) { foreach (var fileName in dg.FileNames) { var layer = layerCollection.AddLayer(fileName); if (layer != null) { layers.Add(layer); } } } return(layers); }
/// <summary> /// 添加图层组工具 /// </summary> /// <param name="commandFactory"></param> /// <param name="layers"></param> /// <returns></returns> public static IBaseCommand GetAddGroupCommand(this ICommandFactory commandFactory, ILayerCollection layers) { IBaseCommand command = null; if (commandFactory != null && layers != null) { string name = "addGroup"; command = commandFactory.Commands?.FirstOrDefault(x => x.Name == name); if (command == null) { command = new BaseCommand() { Header = "添加分组", Name = name, ExecuteCommand = (obj) => layers.AddGroup(), Icon = ResourcesHelper.GetBitmapImage("Group16.png"), LargeIcon = ResourcesHelper.GetBitmapImage("Group32.png"), ToolTip = "添加分组" }; commandFactory.Commands.Add(command); } } return(command); }
/// <summary> /// 添加图层工具 /// </summary> /// <param name="commandFactory"></param> /// <param name="map"></param> /// <param name="layerCollection"></param> /// <returns></returns> public static IBaseCommand GetAddLayersCommand(this ICommandFactory commandFactory, IMap map, ILayerCollection layerCollection) { IBaseCommand command = null; if (commandFactory != null && map != null) { string name = "addLayers"; command = commandFactory.Commands?.FirstOrDefault(x => x.Name == name); if (command == null) { command = new BaseCommand() { Header = "添加", Name = name, ExecuteCommand = (obj) => AddLayers(map, layerCollection), Icon = ResourcesHelper.GetBitmapImage("Add16.png"), LargeIcon = ResourcesHelper.GetBitmapImage("Add32.png"), ToolTip = "添加图层" }; commandFactory.Commands.Add(command); } } return(command); }