private void ProjectManager_Opened(object sender, OpenedProjectManagerEventArgs e)
        {
            ProjectPluginManager projectManager = sender as ProjectPluginManager;

            if (projectManager != null)
            {
                var maps          = projectManager.GetDeserializedMaps();
                var mapsWithBings = maps.Select(m => new { Map = m, BingOverlays = m.Overlays.OfType <BingMapsOverlay>().ToList() })
                                    .Where(o => o.BingOverlays.Count > 0).ToList();

                var hasKey        = !String.IsNullOrEmpty(BingMapsKey);
                var needAskForKey = false;
                foreach (var mapWithBings in mapsWithBings)
                {
                    foreach (var bing in mapWithBings.BingOverlays)
                    {
                        if (hasKey)
                        {
                            bing.ApplicationId = BingMapsKey;
                        }
                        else if (mapWithBings.Map.Overlays.Contains(bing))
                        {
                            needAskForKey = true;
                            mapWithBings.Map.Overlays.Remove(bing);
                        }
                    }
                }

                if (needAskForKey && mapsWithBings.Count > 0)
                {
                    BingMapsConfigWindow configWindow = new BingMapsConfigWindow();
                    if (configWindow.ShowDialog().GetValueOrDefault())
                    {
                        foreach (var mapWithBings in mapsWithBings)
                        {
                            foreach (var bing in mapWithBings.BingOverlays)
                            {
                                if (!mapWithBings.Map.Overlays.Contains(bing))
                                {
                                    bing.ApplicationId = BingMapsKey;
                                    mapWithBings.Map.Overlays.Insert(0, bing);
                                }
                            }

                            if (mapWithBings.Map.ActualWidth != 0 || mapWithBings.Map.ActualHeight != 0)
                            {
                                mapWithBings.Map.Refresh();
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public static BingMapsOverlay AddBingMapsOverlay(GisEditorWpfMap map)
        {
            BingMapsConfigWindow configWindow = new BingMapsConfigWindow();
            BingMapsOverlay      bingOverlay  = null;

            if (!string.IsNullOrEmpty(configWindow.BingMapsKey))
            {
                if (((BingMapsConfigViewModel)configWindow.DataContext).Validate())
                {
                    bingOverlay = AddBingMapOverlayToMap(map, configWindow, bingOverlay);
                }
            }
            else
            {
                if (configWindow.ShowDialog().GetValueOrDefault())
                {
                    bingOverlay = AddBingMapOverlayToMap(map, configWindow, bingOverlay);
                }
            }
            return(bingOverlay);
        }
        private void ShowProperties()
        {
            BingMapsConfigWindow configWindow = new BingMapsConfigWindow();

            configWindow.ShowDialog();
        }