/// <summary> /// Run at shutdown to save settings /// </summary> protected void FinalizeSettings() { // Save World settings World.Settings.Save(); // Encrypt encoded user credentials before saving program settings DataProtector dp = new DataProtector(DataProtector.Store.USE_USER_STORE); Settings.ProxyUsername = dp.TransparentEncrypt(Settings.ProxyUsername); Settings.ProxyPassword = dp.TransparentEncrypt(Settings.ProxyPassword); // Save program settings Settings.Save(); }
static void Main(string[] args) { try { // 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("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision); // If World Wind is already running, pass any commandline // arguments from this instance, and quit. IntPtr handle = GetWWHandle(); if (!System.IntPtr.Zero.Equals(handle)) { if(args.Length>0) NativeMethods.SendArgs( handle, string.Join("\n",args) ); return; } // abort if 50 bindings problem present and user opts to go to the download page if(BindingsCheck.FiftyBindingsWarning()) return; // Name the main thread System.Threading.Thread.CurrentThread.Name = "Main Thread"; // ParseArgs may set values that are used elsewhere, // such as startFullScreen and CurrentSettingsDirectory. ParseArgs(args); if(CurrentSettingsDirectory == null) { // load program settings from default directory LoadSettings(); World.LoadSettings(); } else { LoadSettings(CurrentSettingsDirectory); World.LoadSettings(CurrentSettingsDirectory); } Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); MainApplication app = new MainApplication(); Application.Idle += new EventHandler(app.WorldWindow.OnApplicationIdle); Application.Run(app); // Save World settings World.Settings.Save(); // Encrypt encoded user credentials before saving program settings DataProtector dp = new DataProtector(DataProtector.Store.USE_USER_STORE); Settings.ProxyUsername = dp.TransparentEncrypt(Settings.ProxyUsername); Settings.ProxyPassword = dp.TransparentEncrypt(Settings.ProxyPassword); // Save program settings Settings.Save(); } catch (NullReferenceException) { // HACK } // uncomment this if you want easy debugging ;) //#if !DEBUG catch (Exception caught) { Exception e; string errorMessages; try { // log the error Log.Write(caught); } catch { // ignore errors while trying to write the error to the log } finally { e = caught; errorMessages = "The following error(s) occurred:"; do { errorMessages += "\r\n" + e.Message; e = e.InnerException; } while( e != null ); Abort(errorMessages); } } //#endif }