//public static void CheckIsProjectExist(Uri uri, ProjectManager projectMananger) //{ // if (uri != null && !projectMananger.ProjectExists(uri)) // { // throw new FileNotFoundException("Project file not exists.", "uri"); // } //} /// <summary> /// Checks the is project exist. /// </summary> /// <param name="uri">The URI.</param> /// <param name="projectPluginManager">The project plugin manager.</param> /// <exception cref="System.IO.FileNotFoundException">Project file not exists.;uri</exception> public static void CheckIsProjectExist(Uri uri, ProjectPluginManager projectPluginManager) { if (uri != null && !projectPluginManager.ProjectExists(uri) && uri.AbsolutePath != "blank" && !uri.Scheme.ToLower().Contains("backup")) { throw new FileNotFoundException("Project file not exists.", "uri"); } }
/// <summary> /// Checks the are same projects opened. /// </summary> /// <param name="uri">The URI.</param> /// <param name="projectPluginManager">The project plugin manager.</param> /// <exception cref="System.ArgumentException">This project is already open.;uri</exception> public static void CheckAreSameProjectsOpened(Uri uri, ProjectPluginManager projectPluginManager) { if (projectPluginManager.IsLoaded && projectPluginManager.ProjectUri != null && uri != null && projectPluginManager.ProjectUri.AbsolutePath.Equals(uri.AbsolutePath, StringComparison.OrdinalIgnoreCase) && !projectPluginManager.ProjectUri.AbsolutePath.Equals("blank", StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException(GisEditor.LanguageManager.GetStringResource("GisEditorUserControlAlreadyOpenMessage"), "uri"); } }
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(); } } } } } }