diff --git a/VsProject/PropagationRemasteredBeta/Human.cs b/VsProject/PropagationRemasteredBeta/Human.cs index 317662f..a695a77 100644 --- a/VsProject/PropagationRemasteredBeta/Human.cs +++ b/VsProject/PropagationRemasteredBeta/Human.cs @@ -222,14 +222,6 @@ namespace PropagationRemasteredBeta } } } - - - - - - - - } foreach (Point p in peopleToCheckLocations) diff --git a/VsProject/PropagationRemasteredBeta/MainVue.Designer.cs b/VsProject/PropagationRemasteredBeta/MainVue.Designer.cs index 0b83149..3bc557d 100644 --- a/VsProject/PropagationRemasteredBeta/MainVue.Designer.cs +++ b/VsProject/PropagationRemasteredBeta/MainVue.Designer.cs @@ -31,35 +31,42 @@ namespace PropagationRemasteredBeta { this.lblTitle = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.label11 = new System.Windows.Forms.Label(); + this.btnRandomName = new System.Windows.Forms.Button(); + this.label10 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.tbxSimulationName = new System.Windows.Forms.TextBox(); this.chkbxSaveFiles = new System.Windows.Forms.CheckBox(); this.tbxSaveFilePath = new System.Windows.Forms.TextBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.label1 = new System.Windows.Forms.Label(); - this.nupPopulationSize = new System.Windows.Forms.NumericUpDown(); - this.label2 = new System.Windows.Forms.Label(); - this.lblPopulationSizePrediction = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.nupInfectiosity = new System.Windows.Forms.NumericUpDown(); - this.nupMortality = new System.Windows.Forms.NumericUpDown(); - this.label4 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.btnRandomizeStats = new System.Windows.Forms.Button(); + this.nupCureTime = new System.Windows.Forms.NumericUpDown(); + this.label8 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.comboModes = new System.Windows.Forms.ComboBox(); this.nupImmunes = new System.Windows.Forms.NumericUpDown(); this.label5 = new System.Windows.Forms.Label(); this.nupInfecteds = new System.Windows.Forms.NumericUpDown(); this.label6 = new System.Windows.Forms.Label(); - this.comboModes = new System.Windows.Forms.ComboBox(); - this.label7 = new System.Windows.Forms.Label(); - this.nupCureTime = new System.Windows.Forms.NumericUpDown(); - this.label8 = new System.Windows.Forms.Label(); + this.nupMortality = new System.Windows.Forms.NumericUpDown(); + this.label4 = new System.Windows.Forms.Label(); + this.nupInfectiosity = new System.Windows.Forms.NumericUpDown(); + this.label3 = new System.Windows.Forms.Label(); + this.lblPopulationSizePrediction = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.nupPopulationSize = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); this.btnRunSimulation = new System.Windows.Forms.Button(); this.btnOpenSimViewer = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nupPopulationSize)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.nupInfectiosity)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.nupMortality)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nupCureTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nupImmunes)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nupInfecteds)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.nupCureTime)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nupMortality)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nupInfectiosity)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nupPopulationSize)).BeginInit(); this.SuspendLayout(); // // lblTitle @@ -74,22 +81,73 @@ namespace PropagationRemasteredBeta // // groupBox1 // + this.groupBox1.Controls.Add(this.label11); + this.groupBox1.Controls.Add(this.btnRandomName); + this.groupBox1.Controls.Add(this.label10); + this.groupBox1.Controls.Add(this.label9); + this.groupBox1.Controls.Add(this.tbxSimulationName); this.groupBox1.Controls.Add(this.chkbxSaveFiles); this.groupBox1.Controls.Add(this.tbxSaveFilePath); this.groupBox1.Font = new System.Drawing.Font("Verdana", 12F); - this.groupBox1.Location = new System.Drawing.Point(15, 66); + this.groupBox1.Location = new System.Drawing.Point(12, 66); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(534, 108); + this.groupBox1.Size = new System.Drawing.Size(534, 196); this.groupBox1.TabIndex = 6; this.groupBox1.TabStop = false; this.groupBox1.Text = "General Settings"; // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("Verdana", 10F); + this.label11.Location = new System.Drawing.Point(381, 25); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(104, 20); + this.label11.TabIndex = 19; + this.label11.Text = "Randomize"; + // + // btnRandomName + // + this.btnRandomName.Enabled = false; + this.btnRandomName.Location = new System.Drawing.Point(491, 16); + this.btnRandomName.Name = "btnRandomName"; + this.btnRandomName.Size = new System.Drawing.Size(34, 34); + this.btnRandomName.TabIndex = 18; + this.btnRandomName.UseVisualStyleBackColor = true; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(6, 125); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(179, 25); + this.label10.TabIndex = 17; + this.label10.Text = "Saves Location :"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(6, 28); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(86, 25); + this.label9.TabIndex = 16; + this.label9.Text = "Name :"; + // + // tbxSimulationName + // + this.tbxSimulationName.Font = new System.Drawing.Font("Verdana", 12F); + this.tbxSimulationName.Location = new System.Drawing.Point(11, 56); + this.tbxSimulationName.Name = "tbxSimulationName"; + this.tbxSimulationName.Size = new System.Drawing.Size(514, 32); + this.tbxSimulationName.TabIndex = 7; + this.tbxSimulationName.Text = "Covid34"; + // // chkbxSaveFiles // this.chkbxSaveFiles.AutoSize = true; this.chkbxSaveFiles.Checked = true; this.chkbxSaveFiles.CheckState = System.Windows.Forms.CheckState.Checked; - this.chkbxSaveFiles.Location = new System.Drawing.Point(14, 69); + this.chkbxSaveFiles.Location = new System.Drawing.Point(11, 93); this.chkbxSaveFiles.Name = "chkbxSaveFiles"; this.chkbxSaveFiles.Size = new System.Drawing.Size(236, 29); this.chkbxSaveFiles.TabIndex = 6; @@ -99,14 +157,16 @@ namespace PropagationRemasteredBeta // tbxSaveFilePath // this.tbxSaveFilePath.Font = new System.Drawing.Font("Verdana", 12F); - this.tbxSaveFilePath.Location = new System.Drawing.Point(14, 31); + this.tbxSaveFilePath.Location = new System.Drawing.Point(11, 153); this.tbxSaveFilePath.Name = "tbxSaveFilePath"; this.tbxSaveFilePath.Size = new System.Drawing.Size(514, 32); this.tbxSaveFilePath.TabIndex = 5; - this.tbxSaveFilePath.Text = "./Saves/"; + this.tbxSaveFilePath.Text = "Saves"; // // groupBox2 // + this.groupBox2.Controls.Add(this.label12); + this.groupBox2.Controls.Add(this.btnRandomizeStats); this.groupBox2.Controls.Add(this.nupCureTime); this.groupBox2.Controls.Add(this.label8); this.groupBox2.Controls.Add(this.label7); @@ -124,98 +184,72 @@ namespace PropagationRemasteredBeta this.groupBox2.Controls.Add(this.nupPopulationSize); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Font = new System.Drawing.Font("Verdana", 12F); - this.groupBox2.Location = new System.Drawing.Point(15, 180); + this.groupBox2.Location = new System.Drawing.Point(12, 268); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(534, 342); this.groupBox2.TabIndex = 7; this.groupBox2.TabStop = false; this.groupBox2.Text = "Simulation Settings"; // - // label1 + // label12 // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(9, 41); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(71, 25); - this.label1.TabIndex = 0; - this.label1.Text = "Size :"; + this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("Verdana", 10F); + this.label12.Location = new System.Drawing.Point(381, 28); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(104, 20); + this.label12.TabIndex = 21; + this.label12.Text = "Randomize"; // - // nupPopulationSize + // btnRandomizeStats // - this.nupPopulationSize.Location = new System.Drawing.Point(14, 69); - this.nupPopulationSize.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); - this.nupPopulationSize.Name = "nupPopulationSize"; - this.nupPopulationSize.Size = new System.Drawing.Size(514, 32); - this.nupPopulationSize.TabIndex = 1; - this.nupPopulationSize.Value = new decimal(new int[] { - 400, - 0, - 0, - 0}); + this.btnRandomizeStats.Location = new System.Drawing.Point(491, 19); + this.btnRandomizeStats.Name = "btnRandomizeStats"; + this.btnRandomizeStats.Size = new System.Drawing.Size(34, 34); + this.btnRandomizeStats.TabIndex = 20; + this.btnRandomizeStats.UseVisualStyleBackColor = true; + this.btnRandomizeStats.Click += new System.EventHandler(this.btnRandomizeStats_Click); // - // label2 + // nupCureTime // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(9, 104); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(245, 25); - this.label2.TabIndex = 2; - this.label2.Text = "Simulated individuals :"; - // - // lblPopulationSizePrediction - // - this.lblPopulationSizePrediction.AutoSize = true; - this.lblPopulationSizePrediction.Location = new System.Drawing.Point(260, 104); - this.lblPopulationSizePrediction.Name = "lblPopulationSizePrediction"; - this.lblPopulationSizePrediction.Size = new System.Drawing.Size(95, 25); - this.lblPopulationSizePrediction.TabIndex = 3; - this.lblPopulationSizePrediction.Text = "160\'000"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(9, 143); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(187, 25); - this.label3.TabIndex = 4; - this.label3.Text = "Infectiosity (%) :"; - // - // nupInfectiosity - // - this.nupInfectiosity.Location = new System.Drawing.Point(14, 171); - this.nupInfectiosity.Name = "nupInfectiosity"; - this.nupInfectiosity.Size = new System.Drawing.Size(236, 32); - this.nupInfectiosity.TabIndex = 5; - this.nupInfectiosity.Value = new decimal(new int[] { - 20, - 0, - 0, - 0}); - // - // nupMortality - // - this.nupMortality.Location = new System.Drawing.Point(292, 171); - this.nupMortality.Name = "nupMortality"; - this.nupMortality.Size = new System.Drawing.Size(236, 32); - this.nupMortality.TabIndex = 7; - this.nupMortality.Value = new decimal(new int[] { + this.nupCureTime.Location = new System.Drawing.Point(14, 297); + this.nupCureTime.Name = "nupCureTime"; + this.nupCureTime.Size = new System.Drawing.Size(236, 32); + this.nupCureTime.TabIndex = 15; + this.nupCureTime.Value = new decimal(new int[] { 10, 0, 0, 0}); // - // label4 + // label8 // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(287, 143); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(158, 25); - this.label4.TabIndex = 6; - this.label4.Text = "Mortality (%):"; + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(9, 269); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(128, 25); + this.label8.TabIndex = 14; + this.label8.Text = "Cure time :"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(287, 269); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(81, 25); + this.label7.TabIndex = 13; + this.label7.Text = "Mode :"; + // + // comboModes + // + this.comboModes.FormattingEnabled = true; + this.comboModes.Items.AddRange(new object[] { + "Classic", + "One for all"}); + this.comboModes.Location = new System.Drawing.Point(292, 297); + this.comboModes.Name = "comboModes"; + this.comboModes.Size = new System.Drawing.Size(236, 33); + this.comboModes.TabIndex = 12; // // nupImmunes // @@ -259,51 +293,97 @@ namespace PropagationRemasteredBeta this.label6.TabIndex = 8; this.label6.Text = "Infecteds (%) :"; // - // comboModes + // nupMortality // - this.comboModes.FormattingEnabled = true; - this.comboModes.Items.AddRange(new object[] { - "Classic", - "One for all"}); - this.comboModes.Location = new System.Drawing.Point(292, 297); - this.comboModes.Name = "comboModes"; - this.comboModes.Size = new System.Drawing.Size(236, 33); - this.comboModes.TabIndex = 12; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(287, 269); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(81, 25); - this.label7.TabIndex = 13; - this.label7.Text = "Mode :"; - // - // nupCureTime - // - this.nupCureTime.Location = new System.Drawing.Point(14, 297); - this.nupCureTime.Name = "nupCureTime"; - this.nupCureTime.Size = new System.Drawing.Size(236, 32); - this.nupCureTime.TabIndex = 15; - this.nupCureTime.Value = new decimal(new int[] { + this.nupMortality.Location = new System.Drawing.Point(292, 171); + this.nupMortality.Name = "nupMortality"; + this.nupMortality.Size = new System.Drawing.Size(236, 32); + this.nupMortality.TabIndex = 7; + this.nupMortality.Value = new decimal(new int[] { 10, 0, 0, 0}); // - // label8 + // label4 // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(9, 269); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(128, 25); - this.label8.TabIndex = 14; - this.label8.Text = "Cure time :"; + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(287, 143); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(158, 25); + this.label4.TabIndex = 6; + this.label4.Text = "Mortality (%):"; + // + // nupInfectiosity + // + this.nupInfectiosity.Location = new System.Drawing.Point(14, 171); + this.nupInfectiosity.Name = "nupInfectiosity"; + this.nupInfectiosity.Size = new System.Drawing.Size(236, 32); + this.nupInfectiosity.TabIndex = 5; + this.nupInfectiosity.Value = new decimal(new int[] { + 20, + 0, + 0, + 0}); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(9, 143); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(187, 25); + this.label3.TabIndex = 4; + this.label3.Text = "Infectiosity (%) :"; + // + // lblPopulationSizePrediction + // + this.lblPopulationSizePrediction.AutoSize = true; + this.lblPopulationSizePrediction.Location = new System.Drawing.Point(260, 104); + this.lblPopulationSizePrediction.Name = "lblPopulationSizePrediction"; + this.lblPopulationSizePrediction.Size = new System.Drawing.Size(95, 25); + this.lblPopulationSizePrediction.TabIndex = 3; + this.lblPopulationSizePrediction.Text = "160\'000"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(9, 104); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(245, 25); + this.label2.TabIndex = 2; + this.label2.Text = "Simulated individuals :"; + // + // nupPopulationSize + // + this.nupPopulationSize.Location = new System.Drawing.Point(14, 69); + this.nupPopulationSize.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.nupPopulationSize.Name = "nupPopulationSize"; + this.nupPopulationSize.Size = new System.Drawing.Size(514, 32); + this.nupPopulationSize.TabIndex = 1; + this.nupPopulationSize.Value = new decimal(new int[] { + 400, + 0, + 0, + 0}); + this.nupPopulationSize.ValueChanged += new System.EventHandler(this.nupPopulationSize_ValueChanged); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(9, 41); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(71, 25); + this.label1.TabIndex = 0; + this.label1.Text = "Size :"; // // btnRunSimulation // this.btnRunSimulation.Font = new System.Drawing.Font("Verdana", 12F); - this.btnRunSimulation.Location = new System.Drawing.Point(15, 528); + this.btnRunSimulation.Location = new System.Drawing.Point(12, 616); this.btnRunSimulation.Name = "btnRunSimulation"; this.btnRunSimulation.Size = new System.Drawing.Size(534, 83); this.btnRunSimulation.TabIndex = 8; @@ -314,18 +394,19 @@ namespace PropagationRemasteredBeta // btnOpenSimViewer // this.btnOpenSimViewer.Font = new System.Drawing.Font("Verdana", 12F); - this.btnOpenSimViewer.Location = new System.Drawing.Point(15, 617); + this.btnOpenSimViewer.Location = new System.Drawing.Point(12, 705); this.btnOpenSimViewer.Name = "btnOpenSimViewer"; this.btnOpenSimViewer.Size = new System.Drawing.Size(534, 83); this.btnOpenSimViewer.TabIndex = 9; this.btnOpenSimViewer.Text = "Open SimViewer"; this.btnOpenSimViewer.UseVisualStyleBackColor = true; + this.btnOpenSimViewer.Click += new System.EventHandler(this.btnOpenSimViewer_Click); // // MainVue // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(558, 710); + this.ClientSize = new System.Drawing.Size(558, 798); this.Controls.Add(this.btnOpenSimViewer); this.Controls.Add(this.btnRunSimulation); this.Controls.Add(this.groupBox2); @@ -333,18 +414,19 @@ namespace PropagationRemasteredBeta this.Controls.Add(this.lblTitle); this.Font = new System.Drawing.Font("Verdana", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Name = "MainVue"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "MainVue"; this.Load += new System.EventHandler(this.MainVue_Load); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nupPopulationSize)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.nupInfectiosity)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.nupMortality)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nupCureTime)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nupImmunes)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nupInfecteds)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.nupCureTime)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nupMortality)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nupInfectiosity)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nupPopulationSize)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -375,5 +457,12 @@ namespace PropagationRemasteredBeta private System.Windows.Forms.Label label8; private System.Windows.Forms.Button btnRunSimulation; private System.Windows.Forms.Button btnOpenSimViewer; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.TextBox tbxSimulationName; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Button btnRandomName; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.Button btnRandomizeStats; } } \ No newline at end of file diff --git a/VsProject/PropagationRemasteredBeta/MainVue.cs b/VsProject/PropagationRemasteredBeta/MainVue.cs index af3a198..6354fc3 100644 --- a/VsProject/PropagationRemasteredBeta/MainVue.cs +++ b/VsProject/PropagationRemasteredBeta/MainVue.cs @@ -18,6 +18,9 @@ namespace PropagationRemasteredBeta public int deathRate; public int infectionRate; public int cureTime; + public bool needToSave; + public string savesLocation; + public string simulationName; public MainVue() { InitializeComponent(); @@ -30,17 +33,48 @@ namespace PropagationRemasteredBeta private void btnRunSimulation_Click(object sender, EventArgs e) { - terrainSize = new Size(Convert.ToInt32(nupPopulationSize.Value),Convert.ToInt32(nupPopulationSize.Value)); + terrainSize = new Size(Convert.ToInt32(nupPopulationSize.Value), Convert.ToInt32(nupPopulationSize.Value)); infectedProportion = Convert.ToInt32(nupInfecteds.Value); resistantProportion = Convert.ToInt32(nupImmunes.Value); deathRate = Convert.ToInt32(nupMortality.Value); infectionRate = Convert.ToInt32(nupInfectiosity.Value); cureTime = Convert.ToInt32(nupCureTime.Value); + needToSave = chkbxSaveFiles.Checked; + simulationName = tbxSimulationName.Text; + savesLocation = tbxSaveFilePath.Text; - SimulationVue sm = new SimulationVue(terrainSize,infectedProportion,resistantProportion,deathRate,infectionRate,cureTime); + SimulationVue sm = new SimulationVue(terrainSize, infectedProportion, resistantProportion, deathRate, infectionRate, cureTime, needToSave, savesLocation, simulationName); sm.Closed += (s, args) => this.Show(); sm.Show(); this.Hide(); } + private void nupPopulationSize_ValueChanged(object sender, EventArgs e) + { + decimal value = nupPopulationSize.Value; + lblPopulationSizePrediction.Text = (value * value).ToString(); + } + private void Refresh() + { + nupInfecteds.Value = infectedProportion; + nupImmunes.Value = resistantProportion; + nupMortality.Value = deathRate; + nupInfectiosity.Value = infectionRate; + nupCureTime.Value = cureTime; + } + private void btnRandomizeStats_Click(object sender, EventArgs e) + { + Random rnd = new Random(); + infectedProportion = rnd.Next(0, 80); + resistantProportion = rnd.Next(0, 80); + deathRate = rnd.Next(0, 80); + infectionRate = rnd.Next(0, 80); + cureTime = rnd.Next(0, 80); + + Refresh(); + } + private void btnOpenSimViewer_Click(object sender, EventArgs e) + { + + } } } diff --git a/VsProject/PropagationRemasteredBeta/SimulationVue.Designer.cs b/VsProject/PropagationRemasteredBeta/SimulationVue.Designer.cs index 1285fd5..5687812 100644 --- a/VsProject/PropagationRemasteredBeta/SimulationVue.Designer.cs +++ b/VsProject/PropagationRemasteredBeta/SimulationVue.Designer.cs @@ -50,6 +50,7 @@ this.lblInfected = new System.Windows.Forms.Label(); this.btnStartOneForAll = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); + this.lblSimulationName = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pbxTerrain)).BeginInit(); this.SuspendLayout(); // @@ -66,7 +67,7 @@ // // pbxTerrain // - this.pbxTerrain.Location = new System.Drawing.Point(16, 15); + this.pbxTerrain.Location = new System.Drawing.Point(16, 59); this.pbxTerrain.Margin = new System.Windows.Forms.Padding(4); this.pbxTerrain.Name = "pbxTerrain"; this.pbxTerrain.Size = new System.Drawing.Size(1067, 985); @@ -81,7 +82,7 @@ this.label4.Location = new System.Drawing.Point(1091, 108); this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(55, 17); + this.label4.Size = new System.Drawing.Size(53, 16); this.label4.TabIndex = 6; this.label4.Text = "Frames"; // @@ -96,7 +97,7 @@ this.label1.Location = new System.Drawing.Point(1091, 15); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(103, 17); + this.label1.Size = new System.Drawing.Size(100, 16); this.label1.TabIndex = 2; this.label1.Text = "Memory Usage"; // @@ -106,7 +107,7 @@ this.lblMemory.Location = new System.Drawing.Point(1091, 31); this.lblMemory.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblMemory.Name = "lblMemory"; - this.lblMemory.Size = new System.Drawing.Size(36, 17); + this.lblMemory.Size = new System.Drawing.Size(35, 16); this.lblMemory.TabIndex = 3; this.lblMemory.Text = "NaN"; // @@ -116,7 +117,7 @@ this.label3.Location = new System.Drawing.Point(1091, 59); this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(110, 17); + this.label3.Size = new System.Drawing.Size(106, 16); this.label3.TabIndex = 4; this.label3.Text = "Drawed Elemets"; // @@ -126,7 +127,7 @@ this.lblelementsCounter.Location = new System.Drawing.Point(1091, 75); this.lblelementsCounter.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblelementsCounter.Name = "lblelementsCounter"; - this.lblelementsCounter.Size = new System.Drawing.Size(36, 17); + this.lblelementsCounter.Size = new System.Drawing.Size(35, 16); this.lblelementsCounter.TabIndex = 5; this.lblelementsCounter.Text = "NaN"; // @@ -136,7 +137,7 @@ this.lblFrameCount.Location = new System.Drawing.Point(1091, 124); this.lblFrameCount.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblFrameCount.Name = "lblFrameCount"; - this.lblFrameCount.Size = new System.Drawing.Size(36, 17); + this.lblFrameCount.Size = new System.Drawing.Size(35, 16); this.lblFrameCount.TabIndex = 7; this.lblFrameCount.Text = "NaN"; // @@ -146,7 +147,7 @@ this.label5.Location = new System.Drawing.Point(1091, 151); this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(115, 17); + this.label5.Size = new System.Drawing.Size(107, 16); this.label5.TabIndex = 8; this.label5.Text = "Total Time (ms) :"; // @@ -156,7 +157,7 @@ this.lblTotalTime.Location = new System.Drawing.Point(1091, 167); this.lblTotalTime.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblTotalTime.Name = "lblTotalTime"; - this.lblTotalTime.Size = new System.Drawing.Size(36, 17); + this.lblTotalTime.Size = new System.Drawing.Size(35, 16); this.lblTotalTime.TabIndex = 9; this.lblTotalTime.Text = "NaN"; // @@ -166,7 +167,7 @@ this.lbl6.Location = new System.Drawing.Point(1091, 326); this.lbl6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbl6.Name = "lbl6"; - this.lbl6.Size = new System.Drawing.Size(57, 17); + this.lbl6.Size = new System.Drawing.Size(54, 16); this.lbl6.TabIndex = 10; this.lbl6.Text = "Deads :"; // @@ -176,7 +177,7 @@ this.lblDeaths.Location = new System.Drawing.Point(1091, 342); this.lblDeaths.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblDeaths.Name = "lblDeaths"; - this.lblDeaths.Size = new System.Drawing.Size(36, 17); + this.lblDeaths.Size = new System.Drawing.Size(35, 16); this.lblDeaths.TabIndex = 11; this.lblDeaths.Text = "NaN"; // @@ -186,7 +187,7 @@ this.lbl5.Location = new System.Drawing.Point(1091, 282); this.lbl5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbl5.Name = "lbl5"; - this.lbl5.Size = new System.Drawing.Size(51, 17); + this.lbl5.Size = new System.Drawing.Size(47, 16); this.lbl5.TabIndex = 12; this.lbl5.Text = "Sains :"; // @@ -196,7 +197,7 @@ this.lblSain.Location = new System.Drawing.Point(1091, 298); this.lblSain.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblSain.Name = "lblSain"; - this.lblSain.Size = new System.Drawing.Size(36, 17); + this.lblSain.Size = new System.Drawing.Size(35, 16); this.lblSain.TabIndex = 13; this.lblSain.Text = "NaN"; // @@ -206,7 +207,7 @@ this.lbl4.Location = new System.Drawing.Point(1091, 239); this.lbl4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lbl4.Name = "lbl4"; - this.lbl4.Size = new System.Drawing.Size(72, 17); + this.lbl4.Size = new System.Drawing.Size(67, 16); this.lbl4.TabIndex = 14; this.lbl4.Text = "Immunes :"; // @@ -216,7 +217,7 @@ this.lblImmunes.Location = new System.Drawing.Point(1091, 255); this.lblImmunes.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblImmunes.Name = "lblImmunes"; - this.lblImmunes.Size = new System.Drawing.Size(36, 17); + this.lblImmunes.Size = new System.Drawing.Size(35, 16); this.lblImmunes.TabIndex = 15; this.lblImmunes.Text = "NaN"; // @@ -226,7 +227,7 @@ this.label12.Location = new System.Drawing.Point(1091, 196); this.label12.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(73, 17); + this.label12.Size = new System.Drawing.Size(67, 16); this.label12.TabIndex = 16; this.label12.Text = "Infecteds :"; // @@ -236,7 +237,7 @@ this.lblInfected.Location = new System.Drawing.Point(1091, 212); this.lblInfected.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.lblInfected.Name = "lblInfected"; - this.lblInfected.Size = new System.Drawing.Size(36, 17); + this.lblInfected.Size = new System.Drawing.Size(35, 16); this.lblInfected.TabIndex = 17; this.lblInfected.Text = "NaN"; // @@ -262,11 +263,22 @@ this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click_1); // + // lblSimulationName + // + this.lblSimulationName.AutoSize = true; + this.lblSimulationName.Font = new System.Drawing.Font("Verdana", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblSimulationName.Location = new System.Drawing.Point(12, 13); + this.lblSimulationName.Name = "lblSimulationName"; + this.lblSimulationName.Size = new System.Drawing.Size(261, 34); + this.lblSimulationName.TabIndex = 20; + this.lblSimulationName.Text = "Simulation Name"; + // // SimulationVue // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1239, 1002); + this.ClientSize = new System.Drawing.Size(1239, 1052); + this.Controls.Add(this.lblSimulationName); this.Controls.Add(this.button1); this.Controls.Add(this.btnStartOneForAll); this.Controls.Add(this.lblInfected); @@ -289,7 +301,9 @@ this.Controls.Add(this.btnStartNormal); this.Margin = new System.Windows.Forms.Padding(4); this.Name = "SimulationVue"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Simulation"; + this.Load += new System.EventHandler(this.SimulationVue_Load); this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); ((System.ComponentModel.ISupportInitialize)(this.pbxTerrain)).EndInit(); this.ResumeLayout(false); @@ -320,6 +334,7 @@ private System.Windows.Forms.Label lblInfected; private System.Windows.Forms.Button btnStartOneForAll; private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label lblSimulationName; } } diff --git a/VsProject/PropagationRemasteredBeta/SimulationVue.cs b/VsProject/PropagationRemasteredBeta/SimulationVue.cs index c3de594..cb06807 100644 --- a/VsProject/PropagationRemasteredBeta/SimulationVue.cs +++ b/VsProject/PropagationRemasteredBeta/SimulationVue.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.IO; namespace PropagationRemasteredBeta { @@ -26,8 +27,11 @@ namespace PropagationRemasteredBeta public int deathRate; public int infectionRate; public int cureTime; + public bool needToSave; + public string savesLocation; + public string simulationName; - public SimulationVue(Size terrainSize, int infectedProportion, int resistantProportion, int deathRate, int infectionRate, int cureTime) + public SimulationVue(Size terrainSize, int infectedProportion, int resistantProportion, int deathRate, int infectionRate, int cureTime, bool needToSave, string savesLocation, string simulationName) { InitializeComponent(); this.terrainSize = terrainSize; @@ -36,9 +40,12 @@ namespace PropagationRemasteredBeta this.deathRate = deathRate; this.infectionRate = infectionRate; this.cureTime = cureTime; + this.needToSave = needToSave; + this.savesLocation = savesLocation; + this.simulationName = simulationName; frameCount = 0; - BufferImage = new Bitmap(terrainSize.Width,terrainSize.Height); + BufferImage = new Bitmap(terrainSize.Width, terrainSize.Height); stopwatch = new Stopwatch(); totalTime = 0; } @@ -66,7 +73,7 @@ namespace PropagationRemasteredBeta btnStartNormal.Text = "Stop"; btnStartOneForAll.Text = "Stop"; tmrTick.Start(); - t = new Terrain(terrainSize,infectedProportion,resistantProportion,deathRate,infectionRate,cureTime); + t = new Terrain(terrainSize, infectedProportion, resistantProportion, deathRate, infectionRate, cureTime); frameCount = 0; switch (mode) @@ -78,24 +85,12 @@ namespace PropagationRemasteredBeta t.GenerateOneForAll(); break; } - + } } private void Form1_Paint(object sender, PaintEventArgs e) { - if (started) - { - /* - BufferImage = t.Display(); - pbxTerrain.Image = BufferImage; - stopwatch.Stop(); - totalTime = stopwatch.ElapsedMilliseconds; - frameCount++; - lblFrameCount.Text = frameCount.ToString(); - lblTotalTime.Text = totalTime.ToString(); - */ - } } private void tmrTick_Tick(object sender, EventArgs e) @@ -128,7 +123,10 @@ namespace PropagationRemasteredBeta BufferImage = t.Display(); tmrTick.Start(); - + if (needToSave) + { + Save(BufferImage, frameCount); + } pbxTerrain.Image = BufferImage; stopwatch.Stop(); totalTime = stopwatch.ElapsedMilliseconds; @@ -145,7 +143,20 @@ namespace PropagationRemasteredBeta //lblSain.Text = t.SainCount[t.SainCount.Count() - 1].ToString(); //lblDeaths.Text = t.DeadCount[t.DeadCount.Count() - 1].ToString(); } - + private void Save(Bitmap imageToSave, int frameNumber) + { + string path = "./" + savesLocation + "/" + simulationName + "/"; + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + //only save if the directory has been created successfully + imageToSave.Save(path + simulationName + "_" + frameNumber + ".png", System.Drawing.Imaging.ImageFormat.Png); + } + /// + /// Code found on Stack Overflow, dont quote me on it + /// + /// private double GetMemoryUsage() { var memory = 0.0; @@ -173,5 +184,10 @@ namespace PropagationRemasteredBeta { this.Close(); } + + private void SimulationVue_Load(object sender, EventArgs e) + { + lblSimulationName.Text = simulationName; + } } } diff --git a/VsProject/PropagationRemasteredBeta/Terrain.cs b/VsProject/PropagationRemasteredBeta/Terrain.cs index 5c15a40..ad59c05 100644 --- a/VsProject/PropagationRemasteredBeta/Terrain.cs +++ b/VsProject/PropagationRemasteredBeta/Terrain.cs @@ -197,10 +197,11 @@ namespace PropagationRemasteredBeta }); }); + //Parallel.ForEach(PeopleToCheck, target => foreach (Human target in PeopleToCheck) { - Population[target.Position.X,target.Position.Y] = target.CheckInfection(InfectionRate,Rnd); - } + Population[target.Position.X, target.Position.Y] = target.CheckInfection(InfectionRate, Rnd); + }//); foreach (Human target in InfectedsToCheck) { Population[target.Position.X, target.Position.Y] = target.CheckDeath(DeathRate,CureTime,Rnd);