public static GISApp CreateGisApp() { try { _gisApp = GISApplications.None; if (Enum.IsDefined(typeof(GISApplications), Settings.Default.PreferredGis)) { _gisApp = (GISApplications)Settings.Default.PreferredGis; } if (_gisApp == GISApplications.None) { if (ArcGisInstalled && MapInfoInstalled) { SelectGISApp(); } else if (ArcGisInstalled) { _gisApp = GISApplications.ArcGIS; } else if (MapInfoInstalled) { _gisApp = GISApplications.MapInfo; } Settings.Default.PreferredGis = (int)_gisApp; } if (_gisApp == GISApplications.None) { throw new ArgumentException("Could not find GIS application."); } else { Settings.Default.Save(); } switch (_gisApp) { case GISApplications.ArcGIS: return(new ArcMapApp(Settings.Default.MapPath)); case GISApplications.MapInfo: return(new MapInfoApp(Settings.Default.MapPath)); default: return(null); } } catch (Exception ex) { if (!_cancelled) { MessageBox.Show(ex.Message, "HLU: Fatal Error", MessageBoxButton.OK, MessageBoxImage.Error); } return(null); } }
public ViewModelWindowSelectGIS() { _availableGISApps = Enum.GetValues(typeof(GISApplications)).Cast <GISApplications>().Where(g => g != GISApplications.None).ToArray(); if (_availableGISApps.Length > 0) { _selectedGISApp = _availableGISApps[0]; } }
public ViewModelExport(int numberSelected, string layerName, GISApplications gisApp, HluDataSet.exportsDataTable exportFormats) { _selectedNumber = numberSelected; _selectedOnly = _selectedNumber > 0; _layerName = layerName; _gisApp = gisApp; _exportFormats = exportFormats; if (_exportFormats.Count == 1) _exportID = _exportFormats[0].export_id; }
private static void _viewModelSelGIS_RequestClose(bool cancelled, GISApplications selectedGISApp) { _viewModelSelGIS.RequestClose -= _viewModelSelGIS_RequestClose; _windowSelGIS.Close(); _cancelled = cancelled; if (!_cancelled) { _gisApp = selectedGISApp; } }
public ViewModelExport(int numberSelected, string layerName, GISApplications gisApp, HluDataSet.exportsDataTable exportFormats) { _selectedNumber = numberSelected; _selectedOnly = _selectedNumber > 0; _layerName = layerName; _gisApp = gisApp; _exportFormats = exportFormats; if (_exportFormats.Count == 1) { _exportID = _exportFormats[0].export_id; } }
private static void _viewModelSelGIS_RequestClose(bool cancelled, GISApplications selectedGISApp) { _viewModelSelGIS.RequestClose -= _viewModelSelGIS_RequestClose; _windowSelGIS.Close(); _cancelled = cancelled; if (!_cancelled) _gisApp = selectedGISApp; }
public static string GetMapPath(GISApplications gisApp) { try { string mapPath = Settings.Default.MapPath; if (File.Exists(mapPath)) { FileInfo mapFile = new FileInfo(mapPath); switch (gisApp) { case GISApplications.ArcGIS: if (mapFile.Extension.ToLower() == ".mxd") return mapPath; break; case GISApplications.MapInfo: if (mapFile.Extension.ToLower() == ".wor") return mapPath; break; } } OpenFileDialog openFileDlg = new OpenFileDialog(); switch (gisApp) { case GISApplications.ArcGIS: openFileDlg.Filter = "ESRI ArcMap Documents (*.mxd)|*.mxd"; openFileDlg.Title = "Open HLU Map Document"; break; case GISApplications.MapInfo: openFileDlg.Filter = "MapInfo Workspaces (*.wor)|*.wor"; openFileDlg.Title = "Open HLU Workspace"; break; default: return null; } openFileDlg.Multiselect = false; openFileDlg.CheckPathExists = true; openFileDlg.CheckFileExists = true; openFileDlg.ValidateNames = true; openFileDlg.RestoreDirectory = false; openFileDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (openFileDlg.ShowDialog() == true) { if (File.Exists(openFileDlg.FileName)) return openFileDlg.FileName; } } catch { } return null; }
public static GISApp CreateGisApp() { try { _gisApp = GISApplications.None; if (Enum.IsDefined(typeof(GISApplications), Settings.Default.PreferredGis)) _gisApp = (GISApplications)Settings.Default.PreferredGis; if (_gisApp == GISApplications.None) { if (ArcGisInstalled && MapInfoInstalled) { SelectGISApp(); } else if (ArcGisInstalled) { _gisApp = GISApplications.ArcGIS; } else if (MapInfoInstalled) { _gisApp = GISApplications.MapInfo; } Settings.Default.PreferredGis = (int)_gisApp; } if (_gisApp == GISApplications.None) throw new ArgumentException("Could not find GIS application."); else Settings.Default.Save(); switch (_gisApp) { case GISApplications.ArcGIS: return new ArcMapApp(Settings.Default.MapPath); case GISApplications.MapInfo: return new MapInfoApp(Settings.Default.MapPath); default: return null; } } catch (Exception ex) { if (!_cancelled) MessageBox.Show(ex.Message, "HLU: Fatal Error", MessageBoxButton.OK, MessageBoxImage.Error); return null; } }
public ViewModelWindowSelectGIS() { _availableGISApps = Enum.GetValues(typeof(GISApplications)).Cast<GISApplications>().Where(g => g != GISApplications.None).ToArray(); if (_availableGISApps.Length > 0) _selectedGISApp = _availableGISApps[0]; }
public static string GetMapPath(GISApplications gisApp) { try { string mapPath = Settings.Default.MapPath; if (File.Exists(mapPath)) { FileInfo mapFile = new FileInfo(mapPath); switch (gisApp) { case GISApplications.ArcGIS: if (mapFile.Extension.ToLower() == ".mxd") { return(mapPath); } break; case GISApplications.MapInfo: if (mapFile.Extension.ToLower() == ".wor") { return(mapPath); } break; } } OpenFileDialog openFileDlg = new OpenFileDialog(); switch (gisApp) { case GISApplications.ArcGIS: openFileDlg.Filter = "ESRI ArcMap Documents (*.mxd)|*.mxd"; openFileDlg.Title = "Open HLU Map Document"; break; case GISApplications.MapInfo: openFileDlg.Filter = "MapInfo Workspaces (*.wor)|*.wor"; openFileDlg.Title = "Open HLU Workspace"; break; default: return(null); } openFileDlg.Multiselect = false; openFileDlg.CheckPathExists = true; openFileDlg.CheckFileExists = true; openFileDlg.ValidateNames = true; openFileDlg.RestoreDirectory = false; openFileDlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (openFileDlg.ShowDialog() == true) { if (File.Exists(openFileDlg.FileName)) { return(openFileDlg.FileName); } } } catch { } return(null); }