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); } }
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; }
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); }
private void MainForm_Load(object sender, System.EventArgs e) { MainFormSettings mainFormSettings = new MainFormSettings(); this._settings = mainFormSettings.Load(this, "Settings.dgp"); this.Location = Settings.desktopLocation; this.Size = Settings.size; //logginDialog = new LogginDialog();//Settings.logginDialog; //Automatisk loggin //Loggin(); }