/// <summary> /// Inizializes the form. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Spread_Load(object sender, EventArgs e) { try { this.Location = Program.INIGUI.Read(this.Name, "Location", this.Location); this.Size = Program.INIGUI.Read(this.Name, "Size", this.Size); this.INICoViD = Program.INICoViD.Read(new CoViD.INI()); this.legend1.IsSusceptible = false; this.legend1.IsImmune = false; Initialize(); // ToDo: remove this and fix the bug that clears the // diagrams the first time a tab become active tabControl1.SelectedIndex = 4; tabControl1.SelectedIndex = 3; tabControl1.SelectedIndex = 2; tabControl1.SelectedIndex = 1; tabControl1.SelectedIndex = 0; } catch (System.Exception se) { se.Show(); } }
/// <summary> /// Writes the settings for the CoViD simulation. /// </summary> /// <param name="profile">The class Profile extended by this extension method.</param> /// <param name="settings">The set of values to store in the INI file.</param> public static void Write(this Vi.Tools.Profile profile, CoViD.INI settings) { profile.Write("Settings", "Radius", settings.Radius); profile.Write("Settings", "People", settings.People); profile.Write("Settings", "Steps", settings.Steps); profile.Write("Settings", "Ticks", settings.Ticks); profile.Write("Settings", "Isolation", settings.Isolation); }
/// <summary> /// Reads the settings for the CoViD simulation. /// </summary> /// <param name="profile">The class Profile extended by this extension method.</param> /// <param name="default">The default values to return it is not possible read the INI (for any reason).</param> /// <returns>The values in the INI files. Default if any issue raises.</returns> public static CoViD.INI Read(this Vi.Tools.Profile profile, CoViD.INI @default) { @default.Radius = profile.Read("Settings", "Radius", string.Empty).ToDecimal(@default.Radius); @default.People = profile.Read("Settings", "People", @default.People); @default.Steps = profile.Read("Settings", "Steps", string.Empty).ToByte(@default.Steps); @default.Ticks = profile.Read("Settings", "Ticks", @default.Ticks); @default.Isolation = profile.Read("Settings", "Isolation", string.Empty).ToPercentage(@default.Isolation); return(@default); }
private void Settings_Load(object sender, EventArgs e) { this.Location = Program.INIGUI.Read(this.Name, "Location", this.Location); this.Size = Program.INIGUI.Read(this.Name, "Size", this.Size); this.INI = Program.INICoViD.Read(new CoViD.INI()); this.udPeople.Value = this.INI.People; this.udRadius.Value = this.INI.Radius; this.udIsolation.Value = this.INI.Isolation; this.udSteps.Value = this.INI.Steps; this.udTicks.Value = this.INI.Ticks; }
private void Settings_FormClosing(object sender, FormClosingEventArgs e) { Program.INIGUI.Write(this.Name, "Location", this.Location); Program.INIGUI.Write(this.Name, "Size", this.Size); var ini = new CoViD.INI(udRadius, udPeople, udSteps, udTicks, udIsolation); if (ini != this.INI) { DialogResult result = MessageBox.Show("Settings are changed. Saving the changes will clear all the diagrams and restart the elaboration.\nWant you save changes?", "Data changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); var data = result.IsYes() ? ini : INI; Program.INICoViD.Write(data); } }
// // // e: // /// <summary> /// Opens the form Settings stopping the process if running. When closed /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">An object that contains no event data.</param> private void tsbSettings_Click(object sender, EventArgs e) { try { var isRunning = this.isRunning; tsbPause_Click(null, null); var frmSettings = new CoViD.GUI.Forms.Settings(); frmSettings.ShowDialog(); var iniCovid = Program.INICoViD.Read(new CoViD.INI()); if (isRunning) { if (iniCovid == this.INICoViD) { tsbPlay_Click(null, null); } else { this.INICoViD = iniCovid; Initialize(); tsbNew_Click(null, null); } } else { if (iniCovid != this.INICoViD) { this.INICoViD = iniCovid; Initialize(); } } } catch (System.Exception se) { se.Show(); } }
/// <summary> /// compare this instance with the provided instance of The INI class. /// </summary> /// <param name="ini">The other INI object to compare with this.</param> /// <returns>True if both the parameters are not null and each filed in the left parameter is ugual to the same field in the right parameter. False otherwise.</returns> public bool Equals(CoViD.INI ini) { return(this == ini); }