Beispiel #1
0
        private void AddFolderToMap()
        {
            var folder = GetSelectedItem <IFolderItem>();

            if (folder != null)
            {
                _layerService.BeginBatch();

                try
                {
                    foreach (var item in folder.SubItems)
                    {
                        var file = item as IFileItem;
                        if (file != null)
                        {
                            _layerService.AddLayersFromFilename(file.Filename);
                        }
                    }
                }
                finally
                {
                    _layerService.EndBatch();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Restores the state of application by populating application _context after project file was deserialized.
        /// </summary>
        public bool Restore(XmlProject project)
        {
            _context.Map.Lock();
            _context.Legend.Lock();

            RestoreTmsProvider(project.Map.TileProviderId);

            try
            {
                _layerService.BeginBatch();

                RestoreMapProjection(project);

                RestorePlugins(project);

                int selectedLayerHandle;
                if (!RestoreLayers(project, out selectedLayerHandle))
                {
                    return(false);
                }

                RestoreGroups(project);

                RestoreExtents(project);

                RestoreLocator(project);

                if (selectedLayerHandle != -1)
                {
                    _context.Legend.SelectedLayerHandle = selectedLayerHandle;
                }

                return(true);
            }
            finally
            {
                _layerService.EndBatch();
                _context.Map.Unlock();
                _context.Legend.Unlock();
                _context.Legend.Redraw(LegendRedraw.LegendAndMap);
            }
        }
Beispiel #3
0
        public override bool ViewOkClicked()
        {
            View.StartWait();

            var layers = View.Layers.Where(l => l.Selected).ToList();

            if (layers.Count == 0)
            {
                MessageService.Current.Info("No layers are selected.");
                return(false);
            }

            _syncContext = SynchronizationContext.Current;

            _layerService.BeginBatch();

            Task.Factory.StartNew(() =>
            {
                foreach (var info in layers)
                {
                    var layer = new VectorLayer();
                    if (layer.Open(info.Layer.ConnectionString, info.Layer.Name))
                    {
                        var data = layer.Data;
                        AddLayerToMap(layer);
                    }
                }
            })
            .ContinueWith(t =>
            {
                _layerService.EndBatch();

                View.StopWait();

                ReturnValue = true;
                View.Close();
            }, TaskScheduler.FromCurrentSynchronizationContext());

            return(false);
        }
        /// <summary>
        /// Restores the state of application by populating application _context after project file was deserialized.
        /// </summary>
        public bool Restore(MapWin4Project project, string filename)
        {
            if (project == null)
            {
                return(false);
            }

            _context.Map.Lock();
            _context.Legend.Lock();

            string path = Path.GetDirectoryName(filename);

            try
            {
                _layerService.BeginBatch();

                RestoreMapProjection(project, filename);

                RestoreLayers(project, path);

                RestoreGroups(project);

                MapLayerToGroups(project);

                RestoreExtents(project);

                RestoreLocator(project);

                return(true);
            }
            finally
            {
                _layerService.EndBatch();
                _context.Map.Unlock();
                _context.Legend.Unlock();
                _context.Legend.Redraw(LegendRedraw.LegendAndMap);
            }
        }