// ------------------------------------------------------------------

        #region Public Methods

        public bool Load()
        {
            XmlSerializer serializer = null;
            FileStream    fileStream = null;
            bool          fileExists = false;

            try
            {
                // Create an XmlSerializer for the SystemConfiguration type.
                serializer = new XmlSerializer(typeof(SystemConfiguration));
                FileInfo fi = new FileInfo(_AppConfigFolder + ConfigurationFileName + ConfigurationFileExtension);
                // If the config file exists, open it.
                if (fi.Exists)
                {
                    fileStream = fi.OpenRead();
                    // Create a new instance of the SystemConfiguration by deserializing the config file.
                    SystemConfiguration appSettings = (SystemConfiguration)serializer.Deserialize(fileStream);
                    // Assign property values to this instance of the SystemConfiguration class.
                    _WindowLocation          = appSettings.WindowLocation;
                    _WindowSize              = appSettings.WindowSize;
                    _AppWIndowState          = appSettings.AppWIndowState;
                    _ShowSystemResourceUsage = appSettings.ShowSystemResourceUsage;
                    _Channels  = appSettings.Channels;
                    fileExists = true;
                }
                else
                {
                    // Create default config.
                    _WindowLocation          = new Point(0, 0);
                    _WindowSize              = new Size(800, 600);
                    _AppSettingsChanged      = true;
                    _ShowSystemResourceUsage = false;
                    _Channels  = new Collection <EmulatorChannel>();
                    fileExists = Save();
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (fileStream != null)
                {
                    fileStream.Close();
                }
            }
            return(fileExists);
        }
Exemplo n.º 2
0
 public FormSettings(SystemConfiguration config)
 {
     InitializeComponent();
     _Config = config;
 }