/// <summary>
        /// Callback when the datacontext of the control changes
        /// </summary>
        private void LiteMapsControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            _viewModel = DataContext as LiteMapsViewModel;

            if (_viewModel != null)
            {
                SetBinding(IsExpandedProperty, new Binding(LiteNewUserMapViewModel.AddMapViewVisiblePropertyName)
                {
                    Mode = BindingMode.TwoWay, Source = _viewModel.NewMapViewModel
                });
            }
        }
예제 #2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="messenger"></param>
        public LiteNewUserMapViewModel(LiteMapsViewModel maps, Messenger messenger = null)
            : base(messenger)
        {
            this.Maps = maps;

            _addMapViewVisible = false;

            MapDefinitionViewModel = new MapDefinitionComboBoxViewModel(messenger);
            MapDefinitionViewModel.ServiceProviderGroupTypeProperties.AllowedGroupTypes = new ServiceProviderGroupType[] { ServiceProviderGroupType.Business, ServiceProviderGroupType.Analysis };
            MapDefinitionViewModel.PropertyChanged += MapDefinitionViewModel_PropertyChanged;

            // If there is a single Analysis, hide it (it will be the same name as the Analysis itself)
            MapDefinitionViewModel.DatumProperties.HideWhenSingleDatumFor = (serviceProvider, serviceProviderGroupType) => serviceProviderGroupType == ServiceProviderGroupType.Analysis;
            MapDefinitionViewModel.MapDefinitionsFilter = this.MapDefinitionFilter;

            SetCurrentCultureLabels();
            SetupCommands();
        }
        /// <summary>
        /// Converts the storage model to a MapViewModel that can be used within Lite.
        /// </summary>
        /// <param name="messenger">The messenger the ViewModel should be connected to</param>
        /// <returns>A LiteMapViewModel</returns>
        public async Task <LiteMapViewModel> ToUserMapViewModel(LiteMapsViewModel maps, Messenger messenger, EpsgCoordinateSystemReferenceCollection epsgCoordinateSystems)
        {
            LiteMapViewModel result = null;

            var layers = new List <MapLayerDefinition>();

            try
            {
                foreach (var layer in this.Layers)
                {
                    var layerDefinition = await layer.ToLayerDefinition();

                    if (layerDefinition != null)
                    {
                        layers.Add(layerDefinition);
                    }
                }

                if (layers.Count > 0)
                {
                    Envelope defaultEnvelope = DefaultEnvelope != null?DefaultEnvelope.ToEnvelope() : null;

                    var universe      = Universe.Default;
                    var mapDefinition = new MapDefinition(ExternalName, ExternalName, universe, defaultEnvelope);

                    foreach (var layer in layers)
                    {
                        mapDefinition.Layers.Add(layer);
                    }

                    result = new LiteMapViewModel(messenger, mapDefinition, true, epsgCoordinateSystems, World.Default);
                }
            }
            catch
            {
                // Defend against issues upon serializing
            }

            return(result);
        }