public static WindowSettings GetRoamingConfiguration(out SysConfig config)
		{
			// Define the custom section to add to the
			// configuration file.
			string sectionName = "windowSettings";
			WindowSettings currentSection = null;

			// Get the roaming configuration 
			// that applies to the current user.
			SysConfig roamingConfig =
				ConfigurationManager.OpenExeConfiguration(
				 ConfigurationUserLevel.PerUserRoamingAndLocal);

			// Map the roaming configuration file. This
			// enables the application to access 
			// the configuration file using the
			// System.Configuration.Configuration class
			ExeConfigurationFileMap configFileMap =
				new ExeConfigurationFileMap();
			configFileMap.ExeConfigFilename =
				roamingConfig.FilePath;

			// Get the mapped configuration file.
			config =
				ConfigurationManager.OpenMappedExeConfiguration(
					configFileMap, ConfigurationUserLevel.None);

			try
			{
				currentSection =
						 (WindowSettings)config.GetSection(
							 sectionName);

				// Synchronize the application configuration
				// if needed. The following two steps seem
				// to solve some out of synch issues 
				// between roaming and default
				// configuration.
				//config.Save(ConfigurationSaveMode.Full);

				// Force a reload of the changed section, 
				// if needed. This makes the new values available 
				// for reading.
				//ConfigurationManager.RefreshSection(sectionName);

				if (currentSection == null)
				{
					// Create a custom configuration section.
					currentSection = new WindowSettings();

					// Define where in the configuration file 
					// hierarchy the associated 
					// configuration section can be declared.
					// The following assignment assures that 
					// the configuration information can be 
					// defined in the user.config file in the 
					// roaming user directory. 
					currentSection.SectionInformation.AllowExeDefinition =
						ConfigurationAllowExeDefinition.MachineToLocalUser;

					// Allow the configuration section to be 
					// overridden by lower-level configuration files.
					// This means that lower-level files can contain
					// the section (use the same name) and assign 
					// different values to it as done by the
					// function GetApplicationConfiguration() in this
					// example.
					currentSection.SectionInformation.AllowOverride =
						true;
					// Add configuration information to 
					// the configuration file.
					config.Sections.Add(sectionName, currentSection);

					currentSection.StartupDirectory = new StringConfigElement();
					currentSection.ImageViewFullScreen = new BoolConfigElement();
					currentSection.MainViewFullScreen = new BoolConfigElement();

					currentSection.ImageViewHeight = new IntConfigElement() { Value = 800 };
					currentSection.ImageViewWidth = new IntConfigElement() { Value = 800 };
					currentSection.MainViewHeight = new IntConfigElement() { Value = 800 };
					currentSection.MainViewWidth = new IntConfigElement() { Value = 800 };

				}
				config.Save(ConfigurationSaveMode.Modified);
				// Force a reload of the changed section. This 
				// makes the new values available for reading.
				ConfigurationManager.RefreshSection(
					sectionName);

				return currentSection;
			}
			catch (ConfigurationErrorsException e)
			{
				System.Diagnostics.Debug.WriteLine("[Exception error: {0}]",
						e.ToString());
			}
			catch (Exception e)
			{
				System.Diagnostics.Debug.WriteLine("[Exception error: {0}]",
						e.ToString());
			}
			return null;
		}
        public static WindowSettings GetRoamingConfiguration(out SysConfig config)
        {
            // Define the custom section to add to the
            // configuration file.
            string         sectionName    = "windowSettings";
            WindowSettings currentSection = null;

            // Get the roaming configuration
            // that applies to the current user.
            SysConfig roamingConfig =
                ConfigurationManager.OpenExeConfiguration(
                    ConfigurationUserLevel.PerUserRoamingAndLocal);

            // Map the roaming configuration file. This
            // enables the application to access
            // the configuration file using the
            // System.Configuration.Configuration class
            ExeConfigurationFileMap configFileMap =
                new ExeConfigurationFileMap();

            configFileMap.ExeConfigFilename =
                roamingConfig.FilePath;

            // Get the mapped configuration file.
            config =
                ConfigurationManager.OpenMappedExeConfiguration(
                    configFileMap, ConfigurationUserLevel.None);

            try
            {
                currentSection =
                    (WindowSettings)config.GetSection(
                        sectionName);

                // Synchronize the application configuration
                // if needed. The following two steps seem
                // to solve some out of synch issues
                // between roaming and default
                // configuration.
                //config.Save(ConfigurationSaveMode.Full);

                // Force a reload of the changed section,
                // if needed. This makes the new values available
                // for reading.
                //ConfigurationManager.RefreshSection(sectionName);

                if (currentSection == null)
                {
                    // Create a custom configuration section.
                    currentSection = new WindowSettings();

                    // Define where in the configuration file
                    // hierarchy the associated
                    // configuration section can be declared.
                    // The following assignment assures that
                    // the configuration information can be
                    // defined in the user.config file in the
                    // roaming user directory.
                    currentSection.SectionInformation.AllowExeDefinition =
                        ConfigurationAllowExeDefinition.MachineToLocalUser;

                    // Allow the configuration section to be
                    // overridden by lower-level configuration files.
                    // This means that lower-level files can contain
                    // the section (use the same name) and assign
                    // different values to it as done by the
                    // function GetApplicationConfiguration() in this
                    // example.
                    currentSection.SectionInformation.AllowOverride =
                        true;
                    // Add configuration information to
                    // the configuration file.
                    config.Sections.Add(sectionName, currentSection);

                    currentSection.StartupDirectory    = new StringConfigElement();
                    currentSection.ImageViewFullScreen = new BoolConfigElement();
                    currentSection.MainViewFullScreen  = new BoolConfigElement();

                    currentSection.ImageViewHeight = new IntConfigElement()
                    {
                        Value = 800
                    };
                    currentSection.ImageViewWidth = new IntConfigElement()
                    {
                        Value = 800
                    };
                    currentSection.MainViewHeight = new IntConfigElement()
                    {
                        Value = 800
                    };
                    currentSection.MainViewWidth = new IntConfigElement()
                    {
                        Value = 800
                    };
                }
                config.Save(ConfigurationSaveMode.Modified);
                // Force a reload of the changed section. This
                // makes the new values available for reading.
                ConfigurationManager.RefreshSection(
                    sectionName);

                return(currentSection);
            }
            catch (ConfigurationErrorsException e)
            {
                System.Diagnostics.Debug.WriteLine("[Exception error: {0}]",
                                                   e.ToString());
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("[Exception error: {0}]",
                                                   e.ToString());
            }
            return(null);
        }
		public Configuration()
		{
			ConfigSettings = GetRoamingConfiguration(out  Config);
		}
 public Configuration()
 {
     ConfigSettings = GetRoamingConfiguration(out Config);
 }