Ejemplo n.º 1
0
        public static async Task Toggle(BagisMapType mapType)
        {
            //Get map definition
            BA_Objects.MapDefinition thisMap = MapTools.LoadMapDefinition(mapType);

            // toggle layers according to map definition
            var allLayers = MapView.Active.Map.Layers.ToList();
            await QueuedTask.Run(() =>
            {
                foreach (var layer in allLayers)
                {
                    if (thisMap.LayerList.Contains(layer.Name))
                    {
                        layer.SetVisibility(true);
                    }
                    else
                    {
                        layer.SetVisibility(false);
                    }
                }
            });

            Layout layout = await MapTools.GetDefaultLayoutAsync(Constants.MAPS_DEFAULT_LAYOUT_NAME);

            await MapTools.UpdateMapElementsAsync(layout, Module1.Current.Aoi.Name.ToUpper(), thisMap);

            await MapTools.UpdateLegendAsync(layout, thisMap);

            Module1.Current.DisplayedMap = thisMap.PdfFileName;
        }
Ejemplo n.º 2
0
        public static async Task ToggleAsync(BagisMapType mapType)
        {
            //Get map definition
            BA_Objects.MapDefinition thisMap = MapTools.LoadMapDefinition(mapType);
            Layout oLayout = await MapTools.GetDefaultLayoutAsync(Constants.MAPS_DEFAULT_LAYOUT_NAME);

            if (oLayout != null)
            {
                foreach (var pane in FrameworkApplication.Panes)
                {
                    if (!(pane is ILayoutPane layoutPane))  //if not a layout view, continue to the next pane
                    {
                        continue;
                    }
                    if (layoutPane.LayoutView.Layout == oLayout) //if there is a match, activate the view
                    {
                        (layoutPane as Pane).Activate();
                    }
                }
            }

            // toggle layers according to map definition
            Module1.Current.MapFinishedLoading = false;
            var allLayers = MapView.Active.Map.Layers.ToList();
            await QueuedTask.Run(() =>
            {
                foreach (var layer in allLayers)
                {
                    if (thisMap.LayerList.Contains(layer.Name))
                    {
                        layer.SetVisibility(true);
                    }
                    else
                    {
                        layer.SetVisibility(false);
                    }
                }
            });

            await MapTools.UpdateMapElementsAsync(Module1.Current.Aoi.NwccName.ToUpper(), thisMap);

            BA_ReturnCode success = await MapTools.UpdateLegendAsync(oLayout, thisMap.LegendLayerList);

            Module1.Current.MapFinishedLoading = true;
            Module1.Current.DisplayedMap       = thisMap.PdfFileName;
        }
Ejemplo n.º 3
0
        public static BA_Objects.MapDefinition LoadMapDefinition(BagisMapType mapType)
        {
            BA_Objects.MapDefinition mapDefinition   = null;
            IList <string>           lstLayers       = new List <string>();
            IList <string>           lstLegendLayers = new List <string>();

            switch (mapType)
            {
            case BagisMapType.ELEVATION:
                lstLayers = new List <string> {
                    Constants.MAPS_AOI_BOUNDARY, Constants.MAPS_STREAMS,
                    Constants.MAPS_HILLSHADE, Constants.MAPS_ELEV_ZONE
                };
                lstLegendLayers = new List <string> {
                    Constants.MAPS_ELEV_ZONE
                };
                if (Module1.Current.AoiHasSnotel == true)
                {
                    lstLayers.Add(Constants.MAPS_SNOTEL);
                    lstLegendLayers.Add(Constants.MAPS_SNOTEL);
                }
                if (Module1.Current.AoiHasSnowCourse == true)
                {
                    lstLayers.Add(Constants.MAPS_SNOW_COURSE);
                    lstLegendLayers.Add(Constants.MAPS_SNOW_COURSE);
                }
                // @ToDo: manage elevation units better
                mapDefinition = new BA_Objects.MapDefinition("ELEVATION DISTRIBUTION",
                                                             "Elevation Units = Feet", Constants.FILE_EXPORT_MAP_ELEV_PDF);
                mapDefinition.LayerList       = lstLayers;
                mapDefinition.LegendLayerList = lstLegendLayers;
                break;

            case BagisMapType.SLOPE:
                lstLayers = new List <string> {
                    Constants.MAPS_AOI_BOUNDARY, Constants.MAPS_STREAMS,
                    Constants.MAPS_HILLSHADE, Constants.MAPS_SLOPE_ZONE
                };
                lstLegendLayers = new List <string> {
                    Constants.MAPS_SLOPE_ZONE
                };
                if (Module1.Current.AoiHasSnotel == true)
                {
                    lstLayers.Add(Constants.MAPS_SNOTEL);
                    lstLegendLayers.Add(Constants.MAPS_SNOTEL);
                }
                if (Module1.Current.AoiHasSnowCourse == true)
                {
                    lstLayers.Add(Constants.MAPS_SNOW_COURSE);
                    lstLegendLayers.Add(Constants.MAPS_SNOW_COURSE);
                }
                mapDefinition = new BA_Objects.MapDefinition("SLOPE DISTRIBUTION",
                                                             " ", Constants.FILE_EXPORT_MAP_SLOPE_PDF);
                mapDefinition.LayerList       = lstLayers;
                mapDefinition.LegendLayerList = lstLegendLayers;
                break;

            case BagisMapType.ASPECT:
                lstLayers = new List <string> {
                    Constants.MAPS_AOI_BOUNDARY, Constants.MAPS_STREAMS,
                    Constants.MAPS_HILLSHADE, Constants.MAPS_ASPECT_ZONE
                };
                lstLegendLayers = new List <string> {
                    Constants.MAPS_ASPECT_ZONE
                };
                if (Module1.Current.AoiHasSnotel == true)
                {
                    lstLayers.Add(Constants.MAPS_SNOTEL);
                    lstLegendLayers.Add(Constants.MAPS_SNOTEL);
                }
                if (Module1.Current.AoiHasSnowCourse == true)
                {
                    lstLayers.Add(Constants.MAPS_SNOW_COURSE);
                    lstLegendLayers.Add(Constants.MAPS_SNOW_COURSE);
                }
                mapDefinition = new BA_Objects.MapDefinition("ASPECT DISTRIBUTION",
                                                             " ", Constants.FILE_EXPORT_MAP_ASPECT_PDF);
                mapDefinition.LayerList       = lstLayers;
                mapDefinition.LegendLayerList = lstLegendLayers;
                break;

            case BagisMapType.SNOTEL:
                lstLayers = new List <string> {
                    Constants.MAPS_AOI_BOUNDARY, Constants.MAPS_STREAMS,
                    Constants.MAPS_HILLSHADE, Constants.MAPS_ELEV_ZONE,
                    Constants.MAPS_SNOTEL_REPRESENTED
                };
                lstLegendLayers = new List <string> {
                    Constants.MAPS_SNOTEL_REPRESENTED
                };
                if (Module1.Current.AoiHasSnotel == true)
                {
                    lstLayers.Add(Constants.MAPS_SNOTEL);
                    lstLegendLayers.Add(Constants.MAPS_SNOTEL);
                }
                mapDefinition = new BA_Objects.MapDefinition("SNOTEL SITES REPRESENTATION",
                                                             " ", Constants.FILE_EXPORT_MAP_SNOTEL_PDF);
                mapDefinition.LayerList       = lstLayers;
                mapDefinition.LegendLayerList = lstLegendLayers;
                break;
            }
            return(mapDefinition);
        }