Ejemplo n.º 1
0
        /// <summary>
        /// Setup the datacontext for this control
        /// </summary>
        private void SetupDataContext()
        {
            _viewModel = DataContext as LiteMapViewModel;

            if (_viewModel != null)
            {
                SetBinding(IsExpandedProperty, new Binding(LiteMapViewModel.IsExpandedPropertyName)
                {
                    Mode = BindingMode.TwoWay
                });
            }

            UpdateVisualState(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="messenger"></param>
        public LiteNewMapLayerViewModel(LiteMapViewModel mapToAddTo, Messenger messenger = null)
            : base(messenger)
        {
            this.CurrentMap = mapToAddTo;

            MapLayerDefinitionViewModel = new MapLayerDefinitionComboBoxViewModel(messenger);
            MapLayerDefinitionViewModel.ServiceProviderGroupTypeProperties.AllowedGroupTypes = new ServiceProviderGroupType[] { ServiceProviderGroupType.Business, ServiceProviderGroupType.Analysis, ServiceProviderGroupType.AddIn };
            MapLayerDefinitionViewModel.PropertyChanged += MapLayerDefinitionViewModel_PropertyChanged;

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

            SetCurrentCultureLabels();

            SetupCommands();

            // Set the visibility of the AddMapLayer possibility for easy binding
            this.AddMapLayerVisibility = CurrentMap.MapType == LiteMapType.User ? Visibility.Visible : Visibility.Collapsed;
        }
        /// <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);
        }
        /// <summary>
        /// Constructs the storage model for the specified model
        /// </summary>
        /// <param name="model"></param>
        public LiteUserMapStorageModel(LiteMapViewModel model)
        {
            ProjectName  = TransactionContext.ActiveContext.ProjectName;
            ExternalName = model.ExternalName;

            if (model.DefaultEnvelope != null)
            {
                DefaultEnvelope = new XYEnvelopeDto(model.DefaultEnvelope);
            }

            var layers = new List <LiteUserMapLayerStorageModel>();

            foreach (var layer in model.Layers)
            {
                if (layer.LayerDefinition != null)
                {
                    layers.Add(new LiteUserMapLayerStorageModel(layer.LayerDefinition, layer.IsOn));
                }
            }

            this.Layers = layers.ToArray();
        }