internal MainForm(string strView, string strGeoTiff, string strGeotiffName, bool bGeotiffTmp, string strKMLFile, string strKMLName, bool blKMLTmp, string strLastView, Dapple.Extract.Options.Client.ClientType eClientType, RemoteInterface oMRI, GeographicBoundingBox oAoi, string strAoiCoordinateSystem, string strMapFileName) { if (String.Compare(Path.GetExtension(strView), ViewExt, true) == 0 && File.Exists(strView)) this.openView = strView; m_strOpenGeoTiffFile = strGeoTiff; m_strOpenGeoTiffName = strGeotiffName; m_blOpenGeoTiffTmp = bGeotiffTmp; m_strOpenKMLFile = strKMLFile; m_strOpenKMLName = strKMLName; m_blOpenKMLTmp = blKMLTmp; this.lastView = strLastView; s_oMontajRemoteInterface = oMRI; // Establish the version number string used for user display, // such as the Splash and Help->About screens. // To change the Application.ProductVersion make the // changes in \WorldWind\AssemblyInfo.cs // For alpha/beta versions, include " alphaN" or " betaN" // at the end of the format string. Version ver = new Version(Application.ProductVersion); Release = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build); if (ver.Build % 2 != 0) Release += " (BETA)"; // Name the main thread. System.Threading.Thread.CurrentThread.Name = ThreadNames.EventDispatch; // Copy/Update any configuration files and other files if needed now CurrentSettingsDirectory = Path.Combine(UserPath, "Config"); Directory.CreateDirectory(CurrentSettingsDirectory); Settings.CachePath = Path.Combine(UserPath, "Cache"); Directory.CreateDirectory(Settings.CachePath); this.metaviewerDir = Path.Combine(UserPath, "Metadata"); Directory.CreateDirectory(this.metaviewerDir); string[] cfgFiles = Directory.GetFiles(Path.Combine(DirectoryPath, "Config"), "*.xml"); foreach (string strCfgFile in cfgFiles) { string strUserCfg = Path.Combine(CurrentSettingsDirectory, Path.GetFileName(strCfgFile)); if (!File.Exists(strUserCfg)) File.Copy(strCfgFile, strUserCfg); } string[] metaFiles = Directory.GetFiles(Path.Combine(Path.Combine(DirectoryPath, "Data"), "MetaViewer"), "*.*"); foreach (string strMetaFile in metaFiles) { string strUserMeta = Path.Combine(this.metaviewerDir, Path.GetFileName(strMetaFile)); File.Copy(strMetaFile, strUserMeta, true); } // --- Set up a new user's favorites list and home view --- /*if (!File.Exists(Path.Combine(CurrentSettingsDirectory, "user.dapple_serverlist"))) { File.Copy(Path.Combine(Path.Combine(DirectoryPath, "Data"), "default.dapple_serverlist"), Path.Combine(CurrentSettingsDirectory, "user.dapple_serverlist")); }*/ HomeView.CreateDefault(); InitSettings(); if (Settings.NewCachePath.Length > 0) { try { // We want to make sure the new cache path is writable Directory.CreateDirectory(Settings.NewCachePath); if (Directory.Exists(Settings.CachePath)) Utility.FileSystem.DeleteFolderGUI(this, Settings.CachePath, "Deleting Existing Cache"); Settings.CachePath = Settings.NewCachePath; } catch { } Settings.NewCachePath = ""; } if (Settings.ConfigurationWizardAtStartup) { Wizard frm = new Wizard(Settings); frm.ShowDialog(this); Settings.ConfigurationWizardAtStartup = false; } if (Settings.ConfigurationWizardAtStartup) { // If the settings file doesn't exist, then we are using the // default settings, and the default is to show the Configuration // Wizard at startup. We only want that to happen the first time // World Wind is started, so change the setting to false(the user // can change it to true if they want). if (!File.Exists(Settings.FileName)) { Settings.ConfigurationWizardAtStartup = false; } ConfigurationWizard.Wizard wizard = new ConfigurationWizard.Wizard(Settings); wizard.TopMost = true; wizard.ShowInTaskbar = true; wizard.ShowDialog(); // TODO: should settings be saved now, in case of program crashes, // and so that XML file on disk matches in-memory settings? } //#if !DEBUG using (this.splashScreen = new Splash()) { this.splashScreen.Owner = this; this.splashScreen.Show(); Application.DoEvents(); //#endif // --- setup the list of images used for the different datatypes --- s_oImageList.ColorDepth = ColorDepth.Depth32Bit; s_oImageList.ImageSize = new Size(16, 16); s_oImageList.TransparentColor = Color.Transparent; s_oImageList.Images.Add(EnabledServerIconKey, Resources.enserver); s_oImageList.Images.Add(DisabledServerIconKey, Resources.disserver); s_oImageList.Images.Add(OfflineServerIconKey, Resources.offline); s_oImageList.Images.Add(DapIconKey, Resources.dap); s_oImageList.Images.Add(DapDatabaseIconKey, Resources.dap_database); s_oImageList.Images.Add(DapDocumentIconKey, Resources.dap_document); s_oImageList.Images.Add(DapGridIconKey, Resources.dap_grid); s_oImageList.Images.Add(DapMapIconKey, Resources.dap_map); s_oImageList.Images.Add(DapPictureIconKey, Resources.dap_picture); s_oImageList.Images.Add(DapPointIconKey, Resources.dap_point); s_oImageList.Images.Add(DapSpfIconKey, Resources.dap_spf); s_oImageList.Images.Add(DapVoxelIconKey, Resources.dap_voxel); s_oImageList.Images.Add(FolderIconKey, Resources.folder); s_oImageList.Images.Add(DapArcGisIconKey, global::Dapple.Properties.Resources.dap_arcgis); s_oImageList.Images.Add(KmlIconKey, Resources.kml); s_oImageList.Images.Add(ErrorIconKey, global::Dapple.Properties.Resources.error); s_oImageList.Images.Add(LayerIconKey, global::Dapple.Properties.Resources.layer); s_oImageList.Images.Add(LiveMapsIconKey, global::Dapple.Properties.Resources.live); s_oImageList.Images.Add(TileIconKey, global::Dapple.Properties.Resources.tile); s_oImageList.Images.Add(GeorefImageIconKey, global::Dapple.Properties.Resources.georef_image); s_oImageList.Images.Add(WmsIconKey, Resources.wms); s_oImageList.Images.Add(ArcImsIconKey, global::Dapple.Properties.Resources.arcims); s_oImageList.Images.Add(BlueMarbleIconKey, Dapple.Properties.Resources.blue_marble); s_oImageList.Images.Add(DesktopCatalogerIconKey, Dapple.Properties.Resources.dcat); c_oWorldWindow = new WorldWindow(); #if !DEBUG Utility.AbortUtility.ProgramAborting += new MethodInvoker(c_oWorldWindow.KillD3DAndWorkerThread); #endif c_oWorldWindow.AllowDrop = true; c_oWorldWindow.DragOver += new DragEventHandler(c_oWorldWindow_DragOver); c_oWorldWindow.DragDrop += new DragEventHandler(c_oWorldWindow_DragDrop); c_oWorldWindow.Resize += new EventHandler(c_oWorldWindow_Resize); InitializeComponent(); this.SuspendLayout(); c_oLayerList.ImageList = s_oImageList; /*#if DEBUG // --- Make the server tree HOOGE --- this.splitContainerMain.SplitterDistance = 400; this.splitContainerLeftMain.SplitterDistance = 400; #endif*/ this.Icon = new System.Drawing.Icon(@"app.ico"); DappleToolStripRenderer oTSR = new DappleToolStripRenderer(); c_tsSearch.Renderer = oTSR; c_tsLayers.Renderer = oTSR; c_tsOverview.Renderer = oTSR; c_tsMetadata.Renderer = oTSR; c_tsNavigation.Renderer = new BorderlessToolStripRenderer(); // set Upper and Lower limits for Cache size control, in bytes long CacheUpperLimit = (long)Settings.CacheSizeGigaBytes * 1024L * 1024L * 1024L; long CacheLowerLimit = (long)Settings.CacheSizeGigaBytes * 768L * 1024L * 1024L; //75% of upper limit try { Directory.CreateDirectory(Settings.CachePath); } catch { // We get here when people used a cache drive that since dissappeared (e.g. USB flash) // Revert to default cache directory in this case Settings.CachePath = Path.Combine(UserPath, "Cache"); Directory.CreateDirectory(Settings.CachePath); } //Set up the cache c_oWorldWindow.Cache = new Cache( Settings.CachePath, CacheLowerLimit, CacheUpperLimit, Settings.CacheCleanupInterval, Settings.TotalRunTime); #region Plugin + World Init. WorldWind.Terrain.TerrainTileService terrainTileService = new WorldWind.Terrain.TerrainTileService("http://worldwind25.arc.nasa.gov/wwelevation/wwelevation.aspx", "srtm30pluszip", 20, 150, "bil", 12, Path.Combine(Settings.CachePath, "Earth\\TerrainAccessor\\SRTM"), TimeSpan.FromMinutes(30), "Int16"); WorldWind.Terrain.TerrainAccessor terrainAccessor = new WorldWind.Terrain.NltTerrainAccessor("SRTM", -180, -90, 180, 90, terrainTileService, null); WorldWind.World world = new WorldWind.World("Earth", new Point3d(0, 0, 0), Quaternion4d.RotationYawPitchRoll(0, 0, 0), (float)6378137, System.IO.Path.Combine(c_oWorldWindow.Cache.CacheDirectory, "Earth"), terrainAccessor); c_oWorldWindow.CurrentWorld = world; c_oWorldWindow.DrawArgs.WorldCamera.CameraChanged += new EventHandler(c_oWorldWindow_CameraChanged); string strPluginsDir = Path.Combine(DirectoryPath, "Plugins"); this.scalebarPlugin = new NASA.Plugins.ScaleBarLegend(); this.scalebarPlugin.PluginLoad(this, strPluginsDir); this.scalebarPlugin.IsVisible = World.Settings.ShowScaleBar; this.starsPlugin = new Stars3D.Plugin.Stars3D(); this.starsPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "Stars3D")); this.compassPlugin = new Murris.Plugins.Compass(); this.compassPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "Compass")); String szGlobalCloudsCacheDir = Path.Combine(Settings.CachePath, @"Plugins\GlobalClouds"); Directory.CreateDirectory(szGlobalCloudsCacheDir); String szGlobalCloudsPluginDir = Path.Combine(CurrentSettingsDirectory, @"Plugins\GlobalClouds"); Directory.CreateDirectory(szGlobalCloudsPluginDir); if (!File.Exists(Path.Combine(szGlobalCloudsPluginDir, Murris.Plugins.GlobalCloudsLayer.serverListFileName))) { File.Copy(Path.Combine(Path.Combine(strPluginsDir, "GlobalClouds"), Murris.Plugins.GlobalCloudsLayer.serverListFileName), Path.Combine(szGlobalCloudsPluginDir, Murris.Plugins.GlobalCloudsLayer.serverListFileName)); } this.cloudsPlugin = new Murris.Plugins.GlobalClouds(szGlobalCloudsCacheDir); this.cloudsPlugin.PluginLoad(this, szGlobalCloudsPluginDir); this.skyPlugin = new Murris.Plugins.SkyGradient(); this.skyPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "SkyGradient")); this.threeDConnPlugin = new ThreeDconnexion.Plugin.TDxWWInput(); this.threeDConnPlugin.PluginLoad(this, Path.Combine(strPluginsDir, "3DConnexion")); ThreadPool.QueueUserWorkItem(LoadPlacenames); c_scWorldMetadata.Panel1.Controls.Add(c_oWorldWindow); c_oWorldWindow.Dock = DockStyle.Fill; #endregion float[] verticalExaggerationMultipliers = { 0.0f, 1.0f, 1.5f, 2.0f, 3.0f, 5.0f, 7.0f, 10.0f }; foreach (float multiplier in verticalExaggerationMultipliers) { ToolStripMenuItem curItem = new ToolStripMenuItem(multiplier.ToString("f1", System.Threading.Thread.CurrentThread.CurrentCulture) + "x", null, new EventHandler(menuItemVerticalExaggerationChange)); c_miVertExaggeration.DropDownItems.Add(curItem); curItem.CheckOnClick = true; if (Math.Abs(multiplier - World.Settings.VerticalExaggeration) < 0.1f) curItem.Checked = true; } this.c_miShowCompass.Checked = World.Settings.ShowCompass; this.c_miShowDLProgress.Checked = World.Settings.ShowDownloadIndicator; this.c_miShowCrosshair.Checked = World.Settings.ShowCrosshairs; this.c_miShowInfoOverlay.Checked = World.Settings.ShowPosition; this.c_miShowGridlines.Checked = World.Settings.ShowLatLonLines; this.c_miShowGlobalClouds.Checked = World.Settings.ShowClouds; if (World.Settings.EnableSunShading) { if (!World.Settings.SunSynchedWithTime) this.c_miSunshadingEnabled.Checked = true; else this.c_miSunshadingSync.Checked = true; } else this.c_miSunshadingDisabled.Checked = true; this.c_miShowAtmoScatter.Checked = World.Settings.EnableAtmosphericScattering; this.c_miAskLastViewAtStartup.Checked = Settings.AskLastViewAtStartup; if (!Settings.AskLastViewAtStartup) this.c_miOpenLastViewAtStartup.Checked = Settings.LastViewAtStartup; #region OverviewPanel // Fix: earlier versions of Dapple set the DataPath as an absolute reference, so if Dapple was uninstalled, OMapple could not find // the file for the overview control. To fix this, switch the variable to a relative reference if the absolute one doesn't resolve. // Dapple will still work; the relative reference will be from whatever directory Dapple is being run. if (!Directory.Exists(Settings.DataPath)) Settings.DataPath = "Data"; #endregion c_oWorldWindow.MouseEnter += new EventHandler(this.c_oWorldWindow_MouseEnter); c_oWorldWindow.MouseLeave += new EventHandler(this.c_oWorldWindow_MouseLeave); c_oOverview.AOISelected += new Overview.AOISelectedDelegate(c_oOverview_AOISelected); #region Search view setup this.c_oServerList = new ServerList(); m_oModel = new DappleModel(c_oLayerList); m_oModel.SelectedNodeChanged += new EventHandler(m_oModel_SelectedNodeChanged); c_oLayerList.Attach(m_oModel); NewServerTree.View.ServerTree newServerTree = new NewServerTree.View.ServerTree(); newServerTree.Attach(m_oModel); c_oServerList.Attach(m_oModel); c_oLayerList.LayerSelectionChanged += new EventHandler(c_oLayerList_LayerSelectionChanged); m_oMetadataDisplay = new MetadataDisplayThread(this); m_oMetadataDisplay.AddBuilder(null); c_oServerList.LayerList = c_oLayerList; c_oLayerList.GoTo += new LayerList.GoToHandler(this.GoTo); c_oLayerList.ViewMetadata += new ViewMetadataHandler(m_oMetadataDisplay.AddBuilder); c_oServerList.ViewMetadata += new ViewMetadataHandler(m_oMetadataDisplay.AddBuilder); c_oServerList.LayerSelectionChanged += new EventHandler(c_oServerList_LayerSelectionChanged); this.cServerViewsTab = new JanaTab(); this.cServerViewsTab.SetImage(0, Resources.tab_tree); this.cServerViewsTab.SetImage(1, Resources.tab_list); this.cServerViewsTab.SetToolTip(0, "Server tree view"); this.cServerViewsTab.SetToolTip(1, "Server list view"); this.cServerViewsTab.SetNameAndText(0, "TreeView"); this.cServerViewsTab.SetNameAndText(1, "ListView"); this.cServerViewsTab.SetPage(0, newServerTree); this.cServerViewsTab.SetPage(1, this.c_oServerList); cServerViewsTab.PageChanged += new JanaTab.PageChangedDelegate(ServerPageChanged); c_oDappleSearch = new DappleSearchList(); c_oDappleSearch.LayerSelectionChanged += new EventHandler(c_oDappleSearch_LayerSelectionChanged); c_oDappleSearch.Attach(m_oModel, c_oLayerList); c_tcSearchViews.TabPages[0].Controls.Add(cServerViewsTab); cServerViewsTab.Dock = DockStyle.Fill; c_tcSearchViews.TabPages[1].Controls.Add(c_oDappleSearch); c_oDappleSearch.Dock = DockStyle.Fill; c_oLayerList.SetBaseLayer(new BlueMarbleBuilder()); this.ResumeLayout(false); #endregion this.PerformLayout(); while (!this.splashScreen.IsDone) System.Threading.Thread.Sleep(50); // Force initial render to avoid showing random contents of frame buffer to user. c_oWorldWindow.Render(); WorldWindow.Focus(); #region OM Forked Process configuration if (IsRunningAsDapClient) { c_oLayerList.OMFeaturesEnabled = true; this.MinimizeBox = false; if (oAoi != null && !string.IsNullOrEmpty(strAoiCoordinateSystem)) { s_oOMMapExtentNative = oAoi; s_strAoiCoordinateSystem = strAoiCoordinateSystem; s_strOpenMapFileName = strMapFileName; s_oOMMapExtentWGS84 = s_oOMMapExtentNative.Clone() as GeographicBoundingBox; s_oMontajRemoteInterface.ProjectBoundingRectangle(strAoiCoordinateSystem, ref s_oOMMapExtentWGS84.West, ref s_oOMMapExtentWGS84.South, ref s_oOMMapExtentWGS84.East, ref s_oOMMapExtentWGS84.North, Dapple.Extract.Resolution.WGS_84); } s_eClientType = eClientType; c_miLastView.Enabled = false; c_miLastView.Visible = false; c_miDappleHelp.Visible = false; c_miDappleHelp.Enabled = false; toolStripSeparator10.Visible = false; c_miOpenImage.Visible = false; c_miOpenImage.Enabled = false; c_miOpenKeyhole.Visible = false; c_miOpenKeyhole.Enabled = false; // Hide and disable the file menu c_miFile.Visible = false; c_miFile.Enabled = false; c_miOpenSavedView.Visible = false; c_miOpenSavedView.Enabled = false; c_miOpenHomeView.Visible = false; c_miOpenHomeView.Enabled = false; c_miSetHomeView.Visible = false; c_miSetHomeView.Enabled = false; c_miSaveView.Visible = false; c_miSaveView.Enabled = false; c_miSendViewTo.Visible = false; c_miSendViewTo.Enabled = false; c_miOpenKeyhole.Visible = false; c_miOpenKeyhole.Enabled = false; // Show the OM help menu c_miGetDatahelp.Enabled = true; c_miGetDatahelp.Visible = true; // Don't let the user check for updates. EVER. c_miCheckForUpdates.Visible = false; c_miCheckForUpdates.Enabled = false; } else { c_miExtractLayers.Visible = false; c_miExtractLayers.Enabled = false; } #endregion loadCountryList(); populateAoiComboBox(); LoadMRUList(); CenterNavigationToolStrip(); //#if !DEBUG c_tbSearchKeywords.Text = NO_SEARCH; } //#endif }
static void Main(string[] args) { #if !DEBUG Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); #endif WorldWindow.VideoMemoryExhausted += ReportVideoMemoryExhaustion; #if !DEBUG bool aborting = false; #endif #if DEBUG System.Text.StringBuilder oTemp = new System.Text.StringBuilder(); foreach (String arg in args) { oTemp.Append(arg); oTemp.Append(Environment.NewLine); } if (!System.Diagnostics.Debugger.IsAttached) { ShowMessageBox( "Dapple is being invoked with the following command-line parameters:" + Environment.NewLine + oTemp.ToString() + Environment.NewLine + Environment.NewLine + "Attach debugger if desired, then press OK to continue.", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Information); } #endif MontajRemote.RemoteInterface oRemoteInterface = null; IpcChannel oClientChannel = null; // Command line parsing CommandLineArguments cmdl = new CommandLineArguments(args); try { bool blSelectPersonalDAP = false; bool bAbort = false; string strView = "", strGeoTiff = "", strGeoTiffName = "", strLastView = "", strMapFileName = string.Empty; bool bGeotiffTmp = false; String strKMLFile = String.Empty, strKMLName = String.Empty; bool blKMLTmp = false; GeographicBoundingBox oAoi = null; string strAoiCoordinateSystem = string.Empty; Dapple.Extract.Options.Client.ClientType eClientType = Dapple.Extract.Options.Client.ClientType.None; if (cmdl["h"] != null) { PrintUsage(); return; } SetDCAvailability(cmdl); if (cmdl["callerprocid"] != null) { g_iCallerProcID = Int32.Parse(cmdl["callerprocid"], CultureInfo.InvariantCulture); } if (cmdl[0] != null) { if (String.Compare(cmdl[0], "ABORT") == 0 && cmdl[1] != null) { bAbort = true; } else { strView = Path.GetFullPath(cmdl[0]); if (String.Compare(Path.GetExtension(strView), MainForm.ViewExt, true) != 0 || !File.Exists(strView)) { PrintUsage(); return; } } } if (cmdl["geotiff"] != null) { strGeoTiff = Path.GetFullPath(cmdl["geotiff"]); if (!(String.Compare(Path.GetExtension(strGeoTiff), ".tiff", true) == 0 || String.Compare(Path.GetExtension(strGeoTiff), ".tif", true) == 0) || !File.Exists(strGeoTiff)) { PrintUsage(); return; } } #if !DEBUG if (cmdl["noaborttool"] != null) { g_blTestingMode = true; } #endif if (cmdl["personaldap"] != null) { blSelectPersonalDAP = true; } if (cmdl["geotifftmp"] != null) { string strGeoTiffTmpVar = cmdl["geotifftmp"]; int iIndex = strGeoTiffTmpVar.IndexOf(":"); if (iIndex == -1) { PrintUsage(); return; } strGeoTiff = Path.GetFullPath(strGeoTiffTmpVar.Substring(iIndex + 1)); strGeoTiffName = strGeoTiffTmpVar.Substring(0, iIndex); bGeotiffTmp = true; if (strGeoTiffName.Length == 0 || !(String.Compare(Path.GetExtension(strGeoTiff), ".tiff", true) == 0 || String.Compare(Path.GetExtension(strGeoTiff), ".tif", true) == 0) || !File.Exists(strGeoTiff)) { PrintUsage(); return; } } if (cmdl["kmltmp"] != null) { string strKMLTmpVar = cmdl["kmltmp"]; int iIndex = strKMLTmpVar.IndexOf(":"); if (iIndex == -1) { PrintUsage(); return; } strKMLFile = Path.GetFullPath(strKMLTmpVar.Substring(iIndex + 1)); strKMLName = strKMLTmpVar.Substring(0, iIndex); blKMLTmp = true; if (strKMLName.Length == 0 || !(String.Compare(Path.GetExtension(strKMLFile), ".kmz", true) == 0 || String.Compare(Path.GetExtension(strKMLFile), ".kml", true) == 0) || !File.Exists(strKMLFile)) { PrintUsage(); return; } } if (cmdl["exitview"] != null) { strLastView = Path.GetFullPath(cmdl["exitview"]); } if (cmdl["montajport"] != null) { int iMontajPort = int.Parse(cmdl["montajport"], NumberStyles.Any, CultureInfo.InvariantCulture); if (cmdl["dummyserver"] != null) { oClientChannel = new IpcChannel(String.Format(CultureInfo.InvariantCulture, "localhost:{0}", iMontajPort)); ChannelServices.RegisterChannel(oClientChannel, true); RemotingConfiguration.RegisterWellKnownServiceType(typeof(MontajRemote.RemoteInterface), "MontajRemote", System.Runtime.Remoting.WellKnownObjectMode.Singleton); } else { oClientChannel = new IpcChannel(); ChannelServices.RegisterChannel(oClientChannel, true); } oRemoteInterface = (MontajRemote.RemoteInterface)Activator.GetObject(typeof(MontajRemote.RemoteInterface), String.Format(CultureInfo.InvariantCulture, "ipc://localhost:{0}/MontajRemote", iMontajPort)); } if (cmdl["aoi"] != null) { String[] strValues = cmdl["aoi"].Split(new char[] { ',' }); if (strValues.Length != 4) { ShowMessageBox( "The -aoi command line argument has incorrect number of components.", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error); return; } double dMinX = 180, dMinY = 90, dMaxX = -180, dMaxY = -90; bool bAoiArgument = double.TryParse(strValues[0], out dMinX); if (bAoiArgument) { bAoiArgument = double.TryParse(strValues[1], out dMinY); } if (bAoiArgument) { bAoiArgument = double.TryParse(strValues[2], out dMaxX); } if (bAoiArgument) { bAoiArgument = double.TryParse(strValues[3], out dMaxY); } if (bAoiArgument) { oAoi = new GeographicBoundingBox(dMaxY, dMinY, dMinX, dMaxX); } else { ShowMessageBox( "The -aoi command line argument has incorrectly-formatted component(s).", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error); return; } if (oAoi.North < oAoi.South || oAoi.East < oAoi.West) { ShowMessageBox( "The -aoi command line argument specifies an incorrect bounding box.", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error); return; } if (cmdl["aoi_cs"] != null) { strAoiCoordinateSystem = cmdl["aoi_cs"]; } if (string.IsNullOrEmpty(strAoiCoordinateSystem)) { ShowMessageBox( "The -aoi_cs command line parameter must be present when using -aoi parameter.", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error); return; } if (cmdl["filename_map"] != null) { strMapFileName = cmdl["filename_map"]; } } if (cmdl["client"] != null) { try { eClientType = (Dapple.Extract.Options.Client.ClientType)Enum.Parse(eClientType.GetType(), cmdl["client"], true); } catch { ShowMessageBox( "The -client command line is invalid.", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error); return; } } // From now on in own path please and free the console Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath)); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (bAbort) { string strErrors = File.ReadAllText(args[1]); #if !DEBUG aborting = true; #endif ErrorDisplay errorDialog = new ErrorDisplay(); errorDialog.errorMessages(strErrors); Application.Run(errorDialog); } else { if (GetSystemMetrics(SM_REMOTESESSION) != 0) { ShowMessageBox( "Dapple cannot be run over a remote connection.", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error); return; } Process instance = RunningInstance(); if (instance == null) { try { MainForm oForm = new MainForm(strView, strGeoTiff, strGeoTiffName, bGeotiffTmp, strKMLFile, strKMLName, blKMLTmp, strLastView, eClientType, oRemoteInterface, oAoi, strAoiCoordinateSystem, strMapFileName); oForm.SetSelectPersonalDAPOnStartup(blSelectPersonalDAP); Application.Run(oForm); } catch (Microsoft.DirectX.DirectXException) { if (g_blTestingMode == true) { throw; } else { ShowMessageBox( "Dapple was unable to locate a compatible graphics adapter. Make sure you are running the latest version of DirectX.", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error); return; } } catch (System.Runtime.Remoting.RemotingException) { if (g_blTestingMode == true) { throw; } else { ShowMessageBox( "Dapple has experienced an error attempting to connect to " + EnumUtils.GetDescription(eClientType) + ". Restarting the application or your computer may fix this problem.", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error); } } catch (System.ComponentModel.Win32Exception) { if (g_blTestingMode == true) { throw; } else { ShowMessageBox( "Dapple has encountered an internal Win32 error during startup." + Environment.NewLine + "If this error persists, and you have a Logitech webcam installed, you may be able to resolve the error" + Environment.NewLine + "by disabling the 'Process Monitor' and 'LvSrvLauncher' services on your computer.", "Dapple Startup", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1, MessageBoxIcon.Error); } } } else { HandleRunningInstance(instance); if (strView.Length > 0 || strGeoTiff.Length > 0 || (strKMLName.Length > 0 && strKMLFile.Length > 0)) { try { using (Segment s = new Segment("Dapple.OpenView", SharedMemoryCreationFlag.Create, 10000)) { string[] strData = new string[8]; strData[0] = strView; strData[1] = strGeoTiff; strData[2] = strGeoTiffName; strData[3] = bGeotiffTmp ? "YES" : "NO"; strData[4] = strLastView; strData[5] = blKMLTmp ? "YES" : "NO"; strData[6] = strKMLName; strData[7] = strKMLFile; s.SetData(strData); SendMessage(instance.MainWindowHandle, MainForm.OpenViewMessage, IntPtr.Zero, IntPtr.Zero); } } catch { } } } } } #if !DEBUG catch (Exception caught) { if (g_blTestingMode) { throw; } else { if (!aborting) { Utility.AbortUtility.Abort(caught, Thread.CurrentThread); } } } #endif finally { if (oRemoteInterface != null) { try { oRemoteInterface.EndConnection(); } catch (System.Runtime.Remoting.RemotingException) { } // Ignore these, they most likely mean that OM was closed before Dapple was. } if (oClientChannel != null) { try { ChannelServices.UnregisterChannel(oClientChannel); } catch (System.Runtime.Remoting.RemotingException) { } // Ignore these, they most likely mean that OM was closed before Dapple was. } } }