예제 #1
0
파일: settings.cs 프로젝트: mansehr/DGP
        public void Save(MainForm form, string fileName)
        {
            MainFormSettingsValues values = form.Settings;

            using( Stream stream = new FileStream(@fileName, FileMode.Create) )
            {
                // Write to the stream
                IFormatter formatter = new BinaryFormatter();
                formatter.Serialize(stream, values);
            }
        }
예제 #2
0
파일: settings.cs 프로젝트: mansehr/DGP
        public MainFormSettingsValues Load(MainForm form, string fileName)
        {
            MainFormSettingsValues values;
            try
            {
                using( Stream stream = new FileStream(@fileName, FileMode.OpenOrCreate) )
                {
                    IFormatter formatter = new BinaryFormatter();
                    values = (MainFormSettingsValues)formatter.Deserialize(stream);
                }
            }
            catch(Exception e)
            {
                MessageBox.Show("Error: " + e.Message, "Loadsettings exception");
                values = new MainFormSettingsValues();
            }

            form.StartPosition = FormStartPosition.Manual;

            return values;
        }