protected override void OnClosing(CancelEventArgs e) { e.Cancel = true; this.Visible = false; if (this.curSelectedDataSet == null) { return; } this.currentImageList.Clear(); this.currentAnimatingImages.Clear(); if (this.imageLayer != null) { m_WorldWindow.CurrentWorld.RenderableObjects.Remove(this.imageLayer.Name); this.imageLayer.Dispose(); this.imageLayer = null; } if (this.buttonLoad.Text == "Cancel") { this.buttonLoad.Text = "Load"; } m_WorldWindow.Focus(); base.OnClosing(e); }
public MainForm() { //配置 Application.DoEvents(); InitializeComponent(); InitSkinGallery(); //设置global Global.worldWindow = worldWindow; long CacheUpperLimit = (long)Global.Settings.CacheSizeMegaBytes * 1024L * 1024L; long CacheLowerLimit = (long)Global.Settings.CacheSizeMegaBytes * 768L * 1024L; //75% of upper limit //Set up the cache worldWindow.Cache = new Cache( Global.Settings.CachePath, CacheLowerLimit, CacheUpperLimit, Global.Settings.CacheCleanupInterval, Global.Settings.TotalRunTime); MFW3D.Net.WebDownload.Log404Errors = World.Settings.Log404Errors; DirectoryInfo worldsXmlDir = new DirectoryInfo(Global.Settings.ConfigPath); if (!worldsXmlDir.Exists) { throw new ApplicationException( string.Format(CultureInfo.CurrentCulture, "World Wind configuration directory '{0}' could not be found.", worldsXmlDir.FullName)); } FileInfo[] worldXmlDescriptorFiles = worldsXmlDir.GetFiles("*.xml"); int worldIndex = 0; foreach (FileInfo worldXmlDescriptorFile in worldXmlDescriptorFiles) { try { Log.Write(Log.Levels.Debug + 1, "CONF", "checking world " + worldXmlDescriptorFile.FullName + " ..."); string worldXmlSchema = null; string layerSetSchema = null; if (Global.Settings.ValidateXML) { worldXmlSchema = Global.Settings.ConfigPath + "\\WorldXmlDescriptor.xsd"; layerSetSchema = Global.Settings.ConfigPath + "\\Earth\\LayerSet.xsd"; } World w = MFW3D.ConfigurationLoader.Load( worldXmlDescriptorFile.FullName, worldWindow.Cache, worldXmlSchema, layerSetSchema); if (!availableWorldList.Contains(w.Name)) { this.availableWorldList.Add(w.Name, worldXmlDescriptorFile.FullName); } w.Dispose(); worldIndex++; } catch (Exception caught) { Log.Write(caught); } } Log.Write(Log.Levels.Debug, "CONF", "loading startup world..."); OpenStartupWorld(); worldWindow.Render(); WorldWindow.Focus(); Rectangle screenBounds = Screen.GetBounds(this); }