Esempio n. 1
0
        /// <summary>
        /// Deserializes and optionally decrypts settings, using specified location
        /// </summary>
        protected virtual void LoadSettings(string directory)
        {
            try
             {
            Settings = (WorldWindSettings)SettingsBase.LoadFromPath(Settings, directory);

            // decrypt encoded user credentials
            DataProtector dp = new DataProtector(DataProtector.Store.USE_USER_STORE);

            if (Settings.ProxyUsername.Length > 0) Settings.ProxyUsername = dp.TransparentDecrypt(Settings.ProxyUsername);
            if (Settings.ProxyPassword.Length > 0) Settings.ProxyPassword = dp.TransparentDecrypt(Settings.ProxyPassword);
             }
             catch (Exception caught)
             {
            Log.Write(caught);
             }
        }
Esempio n. 2
0
		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
		}
Esempio n. 3
0
        /// <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();
        }
Esempio n. 4
0
		/// <summary>
		/// Deserializes and optionally decrypts settings
		/// </summary>
		private static void LoadSettings()
		{
			try
			{
				Settings = (WorldWindSettings) SettingsBase.Load(Settings, SettingsBase.LocationType.User);

				if(!File.Exists(Settings.FileName))
				{
					Settings.PluginsLoadedOnStartup.Add("ShapeFileInfoTool");
					//Settings.PluginsLoadedOnStartup.Add("OverviewFormLoader");
					//Settings.PluginsLoadedOnStartup.Add("Atmosphere");
                    Settings.PluginsLoadedOnStartup.Add("SkyGradient");
                    Settings.PluginsLoadedOnStartup.Add("BmngLoader");
                    //Settings.PluginsLoadedOnStartup.Add("Compass");
					//Settings.PluginsLoadedOnStartup.Add("ExternalLayerManagerLoader");
					Settings.PluginsLoadedOnStartup.Add("MeasureTool");
					//Settings.PluginsLoadedOnStartup.Add("MovieRecorder");
					Settings.PluginsLoadedOnStartup.Add("NRLWeatherLoader");
					Settings.PluginsLoadedOnStartup.Add("ShapeFileLoader");
					Settings.PluginsLoadedOnStartup.Add("Stars3D");
					Settings.PluginsLoadedOnStartup.Add("GlobalClouds");
					Settings.PluginsLoadedOnStartup.Add("PlaceFinderLoader");
					Settings.PluginsLoadedOnStartup.Add("LightController");

					Settings.PluginsLoadedOnStartup.Add("Earthquake_2.0.2.1");
					Settings.PluginsLoadedOnStartup.Add("Historical_Earthquake_2.0.2.2");
					Settings.PluginsLoadedOnStartup.Add("KMLImporter");
					//Settings.PluginsLoadedOnStartup.Add("doublezoom");
					//Settings.PluginsLoadedOnStartup.Add("PlanetaryRings");
                    Settings.PluginsLoadedOnStartup.Add("TimeController");
                    //Settings.PluginsLoadedOnStartup.Add("WavingFlags");
                    Settings.PluginsLoadedOnStartup.Add("ScaleBarLegend");
                    Settings.PluginsLoadedOnStartup.Add("Compass3D");
                    Settings.PluginsLoadedOnStartup.Add("AnaglyphStereo");
                    Settings.PluginsLoadedOnStartup.Add("GlobeIcon");

				}
				// decrypt encoded user credentials
				DataProtector dp = new DataProtector(DataProtector.Store.USE_USER_STORE);

				if(Settings.ProxyUsername.Length > 0) Settings.ProxyUsername = dp.TransparentDecrypt(Settings.ProxyUsername);
				if(Settings.ProxyPassword.Length > 0) Settings.ProxyPassword = dp.TransparentDecrypt(Settings.ProxyPassword);
			}
			catch(Exception caught)
			{
				Log.Write(caught);
			}
		}