From 19552565e61d4f6fc4c668060e64c0fd7fc30cd6 Mon Sep 17 00:00:00 2001 From: Maksim_Bartoshyk Date: Tue, 4 Jun 2024 19:12:12 +0300 Subject: [PATCH 1/5] feature (nuclide-def): allow to create nuclide definitions from isotope database --- .gitignore | 3 + BecquerelMonitor/NucBase/DecayRad.cs | 26 + BecquerelMonitor/NucBase/NucBase.Designer.cs | 69 ++- BecquerelMonitor/NucBase/NucBase.cs | 167 +++++-- BecquerelMonitor/NucBase/NucBase.resx | 451 ++++++------------ BecquerelMonitor/NucBase/NucBase.ru.resx | 6 + BecquerelMonitor/NucBase/NucBaseFramework.cs | 2 + BecquerelMonitor/NuclideDefinition.cs | 2 +- .../Properties/Resources.Designer.cs | 18 + BecquerelMonitor/Properties/Resources.resx | 6 + BecquerelMonitor/Properties/Resources.ru.resx | 6 + 11 files changed, 399 insertions(+), 357 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c01ad0d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vs +bin/ +obj/ \ No newline at end of file diff --git a/BecquerelMonitor/NucBase/DecayRad.cs b/BecquerelMonitor/NucBase/DecayRad.cs index f2245f3..5cbf5e9 100644 --- a/BecquerelMonitor/NucBase/DecayRad.cs +++ b/BecquerelMonitor/NucBase/DecayRad.cs @@ -106,11 +106,37 @@ public string Name } } + public double HalfLife + { + get + { + return this.halfLife; + } + set + { + this.halfLife = value; + } + } + + public string HalfLifeUnit + { + get + { + return this.halfLifeUnit; + } + set + { + this.halfLifeUnit = value; + } + } + string name; double energy; double intensity; string decay_line; string xray_type; int dectype; + double halfLife; + string halfLifeUnit; } } diff --git a/BecquerelMonitor/NucBase/NucBase.Designer.cs b/BecquerelMonitor/NucBase/NucBase.Designer.cs index 73d9de4..bbb8902 100644 --- a/BecquerelMonitor/NucBase/NucBase.Designer.cs +++ b/BecquerelMonitor/NucBase/NucBase.Designer.cs @@ -1,4 +1,6 @@ -namespace BecquerelMonitor.NucBase +using System.Windows.Forms.VisualStyles; + +namespace BecquerelMonitor.NucBase { partial class NucBase { @@ -46,6 +48,7 @@ private void InitializeComponent() this.IsotopeTextBox = new System.Windows.Forms.TextBox(); this.SearchButton = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); + this.buttonImportDef = new System.Windows.Forms.Button(); this.label7 = new System.Windows.Forms.Label(); this.DaughtersDataGridView = new System.Windows.Forms.DataGridView(); this.NameColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -57,6 +60,8 @@ private void InitializeComponent() this.TypeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.PercentColum = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.IsotopeAbundance = new System.Windows.Forms.Label(); + this.abundanceLbl = new System.Windows.Forms.Label(); this.IsotopeSpecActivity = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label(); this.IsotopeHLLabel = new System.Windows.Forms.Label(); @@ -68,15 +73,15 @@ private void InitializeComponent() this.IsotopeNameLabel = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.ResultDataGridView = new System.Windows.Forms.DataGridView(); + this.CheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.NameColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.EnTypeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.EnergyColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.IntensityColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.XRayTypeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.DecaModeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.HalfLifeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.abundanceLbl = new System.Windows.Forms.Label(); - this.IsotopeAbundance = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.DaughtersDataGridView)).BeginInit(); @@ -199,6 +204,7 @@ private void InitializeComponent() // panel1 // resources.ApplyResources(this.panel1, "panel1"); + this.panel1.Controls.Add(this.buttonImportDef); this.panel1.Controls.Add(this.label7); this.panel1.Controls.Add(this.DaughtersDataGridView); this.panel1.Controls.Add(this.label6); @@ -207,6 +213,13 @@ private void InitializeComponent() this.panel1.Controls.Add(this.ResultDataGridView); this.panel1.Name = "panel1"; // + // buttonImportDef + // + resources.ApplyResources(this.buttonImportDef, "buttonImportDef"); + this.buttonImportDef.Name = "buttonImportDef"; + this.buttonImportDef.UseVisualStyleBackColor = true; + this.buttonImportDef.Click += new System.EventHandler(this.buttonImportDef_Click); + // // label7 // resources.ApplyResources(this.label7, "label7"); @@ -309,6 +322,16 @@ private void InitializeComponent() this.groupBox2.Name = "groupBox2"; this.groupBox2.TabStop = false; // + // IsotopeAbundance + // + resources.ApplyResources(this.IsotopeAbundance, "IsotopeAbundance"); + this.IsotopeAbundance.Name = "IsotopeAbundance"; + // + // abundanceLbl + // + resources.ApplyResources(this.abundanceLbl, "abundanceLbl"); + this.abundanceLbl.Name = "abundanceLbl"; + // // IsotopeSpecActivity // resources.ApplyResources(this.IsotopeSpecActivity, "IsotopeSpecActivity"); @@ -367,20 +390,29 @@ private void InitializeComponent() this.ResultDataGridView.BackgroundColor = System.Drawing.SystemColors.Window; this.ResultDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.ResultDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.CheckBoxColumn, this.NameColumn2, this.EnTypeColumn, this.EnergyColumn, this.IntensityColumn, this.XRayTypeColumn, - this.DecaModeColumn}); + this.DecaModeColumn, + this.HalfLifeColumn}); resources.ApplyResources(this.ResultDataGridView, "ResultDataGridView"); this.ResultDataGridView.Name = "ResultDataGridView"; - this.ResultDataGridView.ReadOnly = true; this.ResultDataGridView.RowHeadersVisible = false; this.ResultDataGridView.ShowEditingIcon = false; this.ResultDataGridView.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.ResultDataGridView_CellClick); this.ResultDataGridView.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.ResultDataGridView_CellEnter); // + // CheckBoxColumn + // + this.CheckBoxColumn.FalseValue = false; + resources.ApplyResources(this.CheckBoxColumn, "CheckBoxColumn"); + this.CheckBoxColumn.Name = "CheckBoxColumn"; + this.CheckBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.False; + this.CheckBoxColumn.TrueValue = true; + // // NameColumn2 // resources.ApplyResources(this.NameColumn2, "NameColumn2"); @@ -421,15 +453,11 @@ private void InitializeComponent() this.DecaModeColumn.Name = "DecaModeColumn"; this.DecaModeColumn.ReadOnly = true; // - // abundanceLbl + // HalfLifeColumn // - resources.ApplyResources(this.abundanceLbl, "abundanceLbl"); - this.abundanceLbl.Name = "abundanceLbl"; - // - // IsotopeAbundance - // - resources.ApplyResources(this.IsotopeAbundance, "IsotopeAbundance"); - this.IsotopeAbundance.Name = "IsotopeAbundance"; + resources.ApplyResources(this.HalfLifeColumn, "HalfLifeColumn"); + this.HalfLifeColumn.Name = "HalfLifeColumn"; + this.HalfLifeColumn.ReadOnly = true; // // NucBase // @@ -482,12 +510,6 @@ private void InitializeComponent() private System.Windows.Forms.TextBox IntencityTextBox; private System.Windows.Forms.CheckBox IncludeDecayChainCheckBox; private System.Windows.Forms.Label label8; - private System.Windows.Forms.DataGridViewTextBoxColumn NameColumn2; - private System.Windows.Forms.DataGridViewTextBoxColumn EnTypeColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn EnergyColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn IntensityColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn XRayTypeColumn; - private System.Windows.Forms.DataGridViewTextBoxColumn DecaModeColumn; private System.Windows.Forms.ComboBox HalfLifeUOMComboBox; private System.Windows.Forms.TextBox HalfLifeTextBox; private System.Windows.Forms.Label label12; @@ -502,5 +524,14 @@ private void InitializeComponent() private System.Windows.Forms.Label label13; private System.Windows.Forms.Label abundanceLbl; private System.Windows.Forms.Label IsotopeAbundance; + private System.Windows.Forms.Button buttonImportDef; + private System.Windows.Forms.DataGridViewCheckBoxColumn CheckBoxColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn NameColumn2; + private System.Windows.Forms.DataGridViewTextBoxColumn EnTypeColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn EnergyColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn IntensityColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn XRayTypeColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn DecaModeColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn HalfLifeColumn; } } \ No newline at end of file diff --git a/BecquerelMonitor/NucBase/NucBase.cs b/BecquerelMonitor/NucBase/NucBase.cs index 08f0a12..a65eebc 100644 --- a/BecquerelMonitor/NucBase/NucBase.cs +++ b/BecquerelMonitor/NucBase/NucBase.cs @@ -8,11 +8,18 @@ using BecquerelMonitor; using System.ComponentModel; using System.Diagnostics; +using System.Linq; namespace BecquerelMonitor.NucBase { public partial class NucBase : Form { + private const int CheckedColumnIdx = 0; + private const int NameColumnIdx = 1; + private const int EnergyColumnIdx = 3; + private const int IntencityColumnIdx = 4; + private const int HalfLifeColumnIdx = 7; + public NucBase(Form mainForm) { InitializeComponent(); @@ -59,41 +66,9 @@ private void DoSearch() double half_life = -1; if (this.HalfLifeUOMComboBox.Text.Length > 0 && this.HalfLifeTextBox.Text.Length > 0) { - double coeff; - switch (this.HalfLifeUOMComboBox.Text) - { - case "s": - coeff = 1; - break; - case "m": - coeff = 60; - break; - case "h": - coeff = 3600; - break; - case "d": - coeff = 86400; - break; - case "Y": - coeff = 31536000; - break; - case "ms": - coeff = 1.0 / 1000.0; - break; - case "us": - coeff = 1.0 / 1000000.0; - break; - case "ns": - coeff = 1.0 / 1000000000.0; - break; - default: - coeff = 1.0; - break; - } - half_life = coeff * Convert.ToDouble(this.HalfLifeTextBox.Text); + half_life = ConvertHalfLifeToSeconds(Convert.ToDouble(this.HalfLifeTextBox.Text), this.HalfLifeUOMComboBox.Text); } - NucBaseFramework fw = new NucBaseFramework(); if (!incDecayChain) @@ -104,7 +79,7 @@ private void DoSearch() this.ResultDataGridView.Rows.Clear(); foreach (DecayRad decrad in decayRads) { - this.ResultDataGridView.Rows.Add(decrad.Name, decrad.DecayLine, decrad.Energy, decrad.Intensity, decrad.XrayType, decrad.DecayTypeString); + AddRow(decrad); } RestoreSorting(); } @@ -123,7 +98,7 @@ private void DoSearch() { foreach (DecayRad decrad in decayRads) { - this.ResultDataGridView.Rows.Add(decrad.Name, decrad.DecayLine, decrad.Energy, decrad.Intensity, decrad.XrayType, decrad.DecayTypeString); + AddRow(decrad); Trace.WriteLine($"{this.ResultDataGridView.Rows.Count} rows added"); } } @@ -132,7 +107,6 @@ private void DoSearch() } } - if (this.IsotopeTextBox.Text.Length == 0) { return; @@ -161,6 +135,52 @@ private void DoSearch() } } + private double ConvertHalfLifeToSeconds(double value, string unit) + { + double coeff; + + switch (unit) + { + case "s": + coeff = 1; + break; + case "m": + coeff = 60; + break; + case "h": + coeff = 3600; + break; + case "d": + coeff = 86400; + break; + case "Y": + coeff = 31536000; + break; + case "ms": + coeff = 1.0 / 1000.0; + break; + case "us": + coeff = 1.0 / 1000000.0; + break; + case "ns": + coeff = 1.0 / 1000000000.0; + break; + default: + coeff = 1.0; + break; + } + + return coeff * value; + } + + private void AddRow(DecayRad decrad) + { + // TODO: use data binding? + bool isGamma = decrad.DecayLine == "G"; + string hl = decrad.HalfLife.ToString() + "(" + decrad.HalfLifeUnit + ")"; + this.ResultDataGridView.Rows.Add(isGamma, decrad.Name, decrad.DecayLine, decrad.Energy, decrad.Intensity, decrad.XrayType, decrad.DecayTypeString, hl); + } + public void CallSearch(decimal energy) { double delta = 10; @@ -181,9 +201,14 @@ private void ResultDataGridView_CellClick(object sender, DataGridViewCellEventAr { if (e.RowIndex == -1) { + if (e.ColumnIndex == CheckedColumnIdx) + { + ToggleSelection(); + } + return; } - string isotope = this.ResultDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString(); + string isotope = this.ResultDataGridView.Rows[e.RowIndex].Cells[NameColumnIdx].Value.ToString(); NucBaseFramework fw = new NucBaseFramework(); Nuclide nuc = fw.getNuclude(isotope); this.IsotopeNameLabel.Text = isotope; @@ -206,6 +231,19 @@ private void ResultDataGridView_CellClick(object sender, DataGridViewCellEventAr } } + private void ToggleSelection() + { + var checkCol = this.ResultDataGridView.Columns[CheckedColumnIdx]; + checkCol.HeaderText = checkCol.HeaderText == "X" + ? "" + : "X"; + + foreach (DataGridViewRow row in this.ResultDataGridView.Rows) + { + row.Cells[CheckedColumnIdx].Value = checkCol.HeaderText == "X"; + } + } + private void IsotopeTextBox_TextChanged(object sender, EventArgs e) { if (this.IsotopeTextBox.Text.Length == 0) @@ -277,7 +315,7 @@ private void ResultDataGridView_CellEnter(object sender, DataGridViewCellEventAr { return; } - string isotope = this.ResultDataGridView.Rows[e.RowIndex].Cells[0].Value.ToString(); + string isotope = this.ResultDataGridView.Rows[e.RowIndex].Cells[NameColumnIdx].Value.ToString(); if (isotope != null) { NucBaseFramework fw = new NucBaseFramework(); @@ -308,5 +346,58 @@ private void IsotopeTextBox_Enter(object sender, EventArgs e) int DisplayTime = 10000; this.toolTip1.Show(Resources.NucBase_IsotopeTextBoxTooltip1, this.IsotopeTextBox, 0, -23, DisplayTime); } + + private void buttonImportDef_Click(object sender, EventArgs e) + { + try + { + int updatedCount = 0; + int createdCount = 0; + NuclideDefinitionManager defManager = NuclideDefinitionManager.GetInstance(); + foreach (DataGridViewRow row in this.ResultDataGridView.Rows) + { + if ((bool)row.Cells[CheckedColumnIdx].Value == true) + { + string name = (string)row.Cells[NameColumnIdx].Value; + double energy = (double)row.Cells[EnergyColumnIdx].Value; + double intencity = (double)row.Cells[IntencityColumnIdx].Value; + double halfLife = Convert.ToDouble(((string)row.Cells[HalfLifeColumnIdx].Value).Split('(')[0]); + string halfLifeUnit = ((string)row.Cells[HalfLifeColumnIdx].Value).Split('(')[1].Substring(0, 1); + double halfLifeYears = ConvertHalfLifeToSeconds(halfLife, halfLifeUnit) / 31536000; + + NuclideDefinition existingDef = defManager.NuclideDefinitions.FirstOrDefault(def => def.Name == name && def.Energy == energy); + if (existingDef != null) + { + existingDef.Intencity = intencity; + existingDef.HalfLife = halfLifeYears; + updatedCount++; + } + else + { + defManager.NuclideDefinitions.Add(new NuclideDefinition() + { + Name = name, + Energy = energy, + Intencity = intencity, + HalfLife = halfLifeYears, + Visible = true, + NuclideColor = new SerializableColor(System.Drawing.Color.Green) + }); + createdCount++; + } + } + } + + if (updatedCount > 0 || createdCount > 0) + { + defManager.SaveDefinitionFile(); + MessageBox.Show(string.Format(Resources.NuclideDefImportSuccess, createdCount, updatedCount)); + } + } + catch (Exception ex) + { + MessageBox.Show(string.Format(Resources.NuclideDefImportError, ex.Message + ex.StackTrace)); + } + } } } diff --git a/BecquerelMonitor/NucBase/NucBase.resx b/BecquerelMonitor/NucBase/NucBase.resx index 28238d3..c84c32d 100644 --- a/BecquerelMonitor/NucBase/NucBase.resx +++ b/BecquerelMonitor/NucBase/NucBase.resx @@ -117,200 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - HalfLifeUOMComboBox - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 0 - - - HalfLifeTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 1 - - - label12 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 2 - - - label11 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 3 - - - HighEnrgTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 4 - - - label10 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 5 - - - LowEnrgTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 6 - - - label9 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 7 - - - IntencityTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 8 - - - IncludeDecayChainCheckBox - - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 9 - - - label8 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 10 - - - label1 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 11 - - - IsotopeTextBox - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 12 - - - SearchButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - groupBox1 - - - 13 - - - - 0, 0 - - - 974, 54 - - - - 0 - - - Search Isotope - - - groupBox1 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - ns @@ -335,12 +141,14 @@ Y + 482, 19 68, 21 + 13 @@ -696,9 +504,57 @@ 13 + + 0, 0 + + + 974, 54 + + + 0 + + + Search Isotope + + + groupBox1 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + Top, Bottom, Left, Right + + 8, 386 + + + 434, 23 + + + 6 + + + Import selected items to nuclide definition list + + + buttonImportDef + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel1 + + + 0 + True @@ -724,17 +580,32 @@ panel1 - 0 + 1 True + + Name + True + + Type + + + 60 + True + + % + + + 140 + 724, 111 @@ -757,7 +628,7 @@ panel1 - 1 + 2 True @@ -784,17 +655,32 @@ panel1 - 2 + 3 True + + Name + True + + Type + + + 60 + True + + % + + + 140 + 448, 111 @@ -817,7 +703,7 @@ panel1 - 3 + 4 True @@ -1147,26 +1033,77 @@ panel1 - 4 + 5 + + + X + + + 24 True + + Name + + + 50 + True + + Type + + + 50 + True + + Energy, keV + + + 60 + True + + Intensity, % + + + 60 + True + + X-Ray + + + 50 + True + + Decay + + + 50 + + + True + + + Half-Life + + + 80 + 8, 0 @@ -1189,13 +1126,13 @@ panel1 - 5 + 6 0, 60 - 976, 387 + 976, 418 1 @@ -1212,102 +1149,6 @@ 0 - - True - - - Name - - - True - - - Type - - - 60 - - - True - - - % - - - 140 - - - True - - - Name - - - True - - - Type - - - 60 - - - True - - - % - - - 140 - - - True - - - Name - - - True - - - Type - - - 50 - - - True - - - Energy, keV - - - True - - - Intensity, % - - - 70 - - - True - - - X-Ray - - - 50 - - - True - - - Decay - - - 50 - 17, 17 @@ -1321,10 +1162,10 @@ True - 988, 450 + 988, 481 - 1004, 489 + 1004, 520 1004, 489 @@ -1371,6 +1212,12 @@ System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + CheckBoxColumn + + + System.Windows.Forms.DataGridViewCheckBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + NameColumn2 @@ -1407,6 +1254,12 @@ System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + HalfLifeColumn + + + System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + toolTip1 diff --git a/BecquerelMonitor/NucBase/NucBase.ru.resx b/BecquerelMonitor/NucBase/NucBase.ru.resx index 5a41c24..e951f2e 100644 --- a/BecquerelMonitor/NucBase/NucBase.ru.resx +++ b/BecquerelMonitor/NucBase/NucBase.ru.resx @@ -237,4 +237,10 @@ База изотопов + + Период полураспада + + + Импортировать выбранные элементы в список изотопов + \ No newline at end of file diff --git a/BecquerelMonitor/NucBase/NucBaseFramework.cs b/BecquerelMonitor/NucBase/NucBaseFramework.cs index fbb2173..bed9943 100644 --- a/BecquerelMonitor/NucBase/NucBaseFramework.cs +++ b/BecquerelMonitor/NucBase/NucBaseFramework.cs @@ -115,6 +115,8 @@ public List getDecayRad(string nucname, double intensity = 0.0, double decrad.DecayLine = reader.GetString(3); decrad.XrayType = reader.GetString(4); decrad.DecayType = Convert.ToInt32(reader.GetString(5)); + decrad.HalfLife = Convert.ToDouble(reader.GetString(6)); + decrad.HalfLifeUnit = Convert.ToString(reader.GetString(7)); decayRads.Add(decrad); } } catch (Exception ex) diff --git a/BecquerelMonitor/NuclideDefinition.cs b/BecquerelMonitor/NuclideDefinition.cs index 843e6e8..5aafa5e 100644 --- a/BecquerelMonitor/NuclideDefinition.cs +++ b/BecquerelMonitor/NuclideDefinition.cs @@ -105,7 +105,7 @@ public int CompareTo(object obj) // Token: 0x060010AF RID: 4271 RVA: 0x0005AF14 File Offset: 0x00059114 public override string ToString() { - return this.name; + return $"{this.name} ({this.energy})"; } public bool Visible diff --git a/BecquerelMonitor/Properties/Resources.Designer.cs b/BecquerelMonitor/Properties/Resources.Designer.cs index 0d908f8..47c42c2 100644 --- a/BecquerelMonitor/Properties/Resources.Designer.cs +++ b/BecquerelMonitor/Properties/Resources.Designer.cs @@ -2124,6 +2124,24 @@ internal static string NucBase_X_Ray { } } + /// + /// Looks up a localized string similar to Import failed - {0}. + /// + internal static string NuclideDefImportError { + get { + return ResourceManager.GetString("NuclideDefImportError", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Import successful. Added - {0} item(s), updated - {1} item(s).. + /// + internal static string NuclideDefImportSuccess { + get { + return ResourceManager.GetString("NuclideDefImportSuccess", resourceCulture); + } + } + /// /// Looks up a localized string similar to Open Spectrum File. /// diff --git a/BecquerelMonitor/Properties/Resources.resx b/BecquerelMonitor/Properties/Resources.resx index 38cd87e..f6400e2 100644 --- a/BecquerelMonitor/Properties/Resources.resx +++ b/BecquerelMonitor/Properties/Resources.resx @@ -41963,4 +41963,10 @@ see peak in spectrum now). Selected Region (normalized by eff.) + + Import failed - {0} + + + Import successful. Added - {0} item(s), updated - {1} item(s). + \ No newline at end of file diff --git a/BecquerelMonitor/Properties/Resources.ru.resx b/BecquerelMonitor/Properties/Resources.ru.resx index 29ea645..c567311 100644 --- a/BecquerelMonitor/Properties/Resources.ru.resx +++ b/BecquerelMonitor/Properties/Resources.ru.resx @@ -656,6 +656,12 @@ http://xptable.sourceforge.net/ Пример: AM-241, AM241, 241AM. Изомер: PA234m1, 234PAm1, PA-234m1 + + Ошибка импорта - {0} + + + Импорт завершен. Добавлено - {0}, обновлено - {1}. + Открыть файл спектра From d3aa4484d34d170e462b39cc72ed477ee2046fab Mon Sep 17 00:00:00 2001 From: Am6er Date: Tue, 4 Jun 2024 21:06:17 +0300 Subject: [PATCH 2/5] - add parent if "decay chain checked" - fix checkbox mass toggle didn't refresh edited cell - export button disabled if no data to add --- BecquerelMonitor/NucBase/NucBase.cs | 20 +++++++++++++++++++- BecquerelMonitor/NucBase/NucBase.resx | 3 +++ BecquerelMonitor/NuclideDefinition.cs | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/BecquerelMonitor/NucBase/NucBase.cs b/BecquerelMonitor/NucBase/NucBase.cs index a65eebc..2f96e9f 100644 --- a/BecquerelMonitor/NucBase/NucBase.cs +++ b/BecquerelMonitor/NucBase/NucBase.cs @@ -19,6 +19,7 @@ public partial class NucBase : Form private const int EnergyColumnIdx = 3; private const int IntencityColumnIdx = 4; private const int HalfLifeColumnIdx = 7; + private string SearchedIsotope; public NucBase(Form mainForm) { @@ -47,6 +48,7 @@ private void DoSearch() string isotope_number = Regex.Match(isotope, @"\d+").Value; string isotope_name = Regex.Match(isotope, @"[a-zA-Z]+").Value; isotope = isotope_number + isotope_name + isomer; + this.SearchedIsotope = isotope; bool incDecayChain = this.IncludeDecayChainCheckBox.Checked; double lowEnergy = 0.0; if (this.LowEnrgTextBox.Text.Length != 0) @@ -133,6 +135,14 @@ private void DoSearch() this.DaughtersDataGridView.Rows.Add(daughter.NucName, daughter.DecayTypeString, daughter.DecayPercent); } } + + if (ResultDataGridView.Rows.Count > 0) + { + buttonImportDef.Enabled = true; + } else + { + buttonImportDef.Enabled = false; + } } private double ConvertHalfLifeToSeconds(double value, string unit) @@ -233,6 +243,7 @@ private void ResultDataGridView_CellClick(object sender, DataGridViewCellEventAr private void ToggleSelection() { + this.ResultDataGridView.SuspendLayout(); var checkCol = this.ResultDataGridView.Columns[CheckedColumnIdx]; checkCol.HeaderText = checkCol.HeaderText == "X" ? "" @@ -242,6 +253,8 @@ private void ToggleSelection() { row.Cells[CheckedColumnIdx].Value = checkCol.HeaderText == "X"; } + this.ResultDataGridView.RefreshEdit(); + this.ResultDataGridView.ResumeLayout(); } private void IsotopeTextBox_TextChanged(object sender, EventArgs e) @@ -365,7 +378,12 @@ private void buttonImportDef_Click(object sender, EventArgs e) string halfLifeUnit = ((string)row.Cells[HalfLifeColumnIdx].Value).Split('(')[1].Substring(0, 1); double halfLifeYears = ConvertHalfLifeToSeconds(halfLife, halfLifeUnit) / 31536000; - NuclideDefinition existingDef = defManager.NuclideDefinitions.FirstOrDefault(def => def.Name == name && def.Energy == energy); + if (IncludeDecayChainCheckBox.Checked && this.SearchedIsotope != name) + { + name += " (" + this.SearchedIsotope + ")"; + } + + NuclideDefinition existingDef = defManager.NuclideDefinitions.FirstOrDefault(def => def.Energy == energy); if (existingDef != null) { existingDef.Intencity = intencity; diff --git a/BecquerelMonitor/NucBase/NucBase.resx b/BecquerelMonitor/NucBase/NucBase.resx index c84c32d..17f74a8 100644 --- a/BecquerelMonitor/NucBase/NucBase.resx +++ b/BecquerelMonitor/NucBase/NucBase.resx @@ -531,6 +531,9 @@ Top, Bottom, Left, Right + + False + 8, 386 diff --git a/BecquerelMonitor/NuclideDefinition.cs b/BecquerelMonitor/NuclideDefinition.cs index 5aafa5e..580a3e6 100644 --- a/BecquerelMonitor/NuclideDefinition.cs +++ b/BecquerelMonitor/NuclideDefinition.cs @@ -105,7 +105,7 @@ public int CompareTo(object obj) // Token: 0x060010AF RID: 4271 RVA: 0x0005AF14 File Offset: 0x00059114 public override string ToString() { - return $"{this.name} ({this.energy})"; + return $"{this.name} - {this.energy}"; } public bool Visible From a951b85dd81216583a9c7009f84df4fe12bfab2f Mon Sep 17 00:00:00 2001 From: Maksim_Bartoshyk Date: Wed, 5 Jun 2024 22:50:14 +0300 Subject: [PATCH 3/5] feat (nuclide definition): introduce import options - option to overwrite existing records with exact the same energy - option to add main isotope name to decay products - isotope name format selector --- BecquerelMonitor/NucBase/NucBase.Designer.cs | 42 ++++++ BecquerelMonitor/NucBase/NucBase.cs | 69 +++++++-- BecquerelMonitor/NucBase/NucBase.resx | 145 +++++++++++++++++-- BecquerelMonitor/NucBase/NucBase.ru.resx | 9 ++ BecquerelMonitor/ROIConfigForm.Designer.cs | 1 + 5 files changed, 242 insertions(+), 24 deletions(-) diff --git a/BecquerelMonitor/NucBase/NucBase.Designer.cs b/BecquerelMonitor/NucBase/NucBase.Designer.cs index bbb8902..7941530 100644 --- a/BecquerelMonitor/NucBase/NucBase.Designer.cs +++ b/BecquerelMonitor/NucBase/NucBase.Designer.cs @@ -48,6 +48,10 @@ private void InitializeComponent() this.IsotopeTextBox = new System.Windows.Forms.TextBox(); this.SearchButton = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); + this.comboBoxNameFormat = new System.Windows.Forms.ComboBox(); + this.labelNameFormat = new System.Windows.Forms.Label(); + this.checkBoxAppendRootName = new System.Windows.Forms.CheckBox(); + this.checkBoxOverwriteDef = new System.Windows.Forms.CheckBox(); this.buttonImportDef = new System.Windows.Forms.Button(); this.label7 = new System.Windows.Forms.Label(); this.DaughtersDataGridView = new System.Windows.Forms.DataGridView(); @@ -175,6 +179,7 @@ private void InitializeComponent() resources.ApplyResources(this.IncludeDecayChainCheckBox, "IncludeDecayChainCheckBox"); this.IncludeDecayChainCheckBox.Name = "IncludeDecayChainCheckBox"; this.IncludeDecayChainCheckBox.UseVisualStyleBackColor = true; + this.IncludeDecayChainCheckBox.CheckedChanged += new System.EventHandler(this.IncludeDecayChainCheckBox_CheckedChanged); // // label8 // @@ -204,6 +209,10 @@ private void InitializeComponent() // panel1 // resources.ApplyResources(this.panel1, "panel1"); + this.panel1.Controls.Add(this.comboBoxNameFormat); + this.panel1.Controls.Add(this.labelNameFormat); + this.panel1.Controls.Add(this.checkBoxAppendRootName); + this.panel1.Controls.Add(this.checkBoxOverwriteDef); this.panel1.Controls.Add(this.buttonImportDef); this.panel1.Controls.Add(this.label7); this.panel1.Controls.Add(this.DaughtersDataGridView); @@ -213,6 +222,35 @@ private void InitializeComponent() this.panel1.Controls.Add(this.ResultDataGridView); this.panel1.Name = "panel1"; // + // comboBoxNameFormat + // + resources.ApplyResources(this.comboBoxNameFormat, "comboBoxNameFormat"); + this.comboBoxNameFormat.FormattingEnabled = true; + this.comboBoxNameFormat.Items.AddRange(new object[] { + resources.GetString("comboBoxNameFormat.Items"), + resources.GetString("comboBoxNameFormat.Items1"), + resources.GetString("comboBoxNameFormat.Items2")}); + this.comboBoxNameFormat.Name = "comboBoxNameFormat"; + // + // labelNameFormat + // + resources.ApplyResources(this.labelNameFormat, "labelNameFormat"); + this.labelNameFormat.Name = "labelNameFormat"; + // + // checkBoxAppendRootName + // + resources.ApplyResources(this.checkBoxAppendRootName, "checkBoxAppendRootName"); + this.checkBoxAppendRootName.Checked = true; + this.checkBoxAppendRootName.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxAppendRootName.Name = "checkBoxAppendRootName"; + this.checkBoxAppendRootName.UseVisualStyleBackColor = true; + // + // checkBoxOverwriteDef + // + resources.ApplyResources(this.checkBoxOverwriteDef, "checkBoxOverwriteDef"); + this.checkBoxOverwriteDef.Name = "checkBoxOverwriteDef"; + this.checkBoxOverwriteDef.UseVisualStyleBackColor = true; + // // buttonImportDef // resources.ApplyResources(this.buttonImportDef, "buttonImportDef"); @@ -533,5 +571,9 @@ private void InitializeComponent() private System.Windows.Forms.DataGridViewTextBoxColumn XRayTypeColumn; private System.Windows.Forms.DataGridViewTextBoxColumn DecaModeColumn; private System.Windows.Forms.DataGridViewTextBoxColumn HalfLifeColumn; + private System.Windows.Forms.Label labelNameFormat; + private System.Windows.Forms.CheckBox checkBoxAppendRootName; + private System.Windows.Forms.CheckBox checkBoxOverwriteDef; + private System.Windows.Forms.ComboBox comboBoxNameFormat; } } \ No newline at end of file diff --git a/BecquerelMonitor/NucBase/NucBase.cs b/BecquerelMonitor/NucBase/NucBase.cs index 2f96e9f..5df89e8 100644 --- a/BecquerelMonitor/NucBase/NucBase.cs +++ b/BecquerelMonitor/NucBase/NucBase.cs @@ -27,6 +27,7 @@ public NucBase(Form mainForm) this.mainForm = mainForm; this.Icon = Resources.becqmoni; this.IncludeDecayChainCheckBox.Enabled = false; + this.comboBoxNameFormat.SelectedIndex = 1; } private void SearchButton_Click(object sender, EventArgs e) @@ -136,13 +137,19 @@ private void DoSearch() } } - if (ResultDataGridView.Rows.Count > 0) - { - buttonImportDef.Enabled = true; - } else - { - buttonImportDef.Enabled = false; - } + UpdateNuclideDefinitionControlsState(); + } + + private void UpdateNuclideDefinitionControlsState() + { + bool hasRows = this.ResultDataGridView.Rows.Count > 0; + + buttonImportDef.Enabled = hasRows; + checkBoxOverwriteDef.Enabled = hasRows; + checkBoxAppendRootName.Enabled = IncludeDecayChainCheckBox.Checked; + checkBoxAppendRootName.Checked = IncludeDecayChainCheckBox.Checked; + comboBoxNameFormat.Enabled = hasRows; + labelNameFormat.Enabled = hasRows; } private double ConvertHalfLifeToSeconds(double value, string unit) @@ -244,7 +251,7 @@ private void ResultDataGridView_CellClick(object sender, DataGridViewCellEventAr private void ToggleSelection() { this.ResultDataGridView.SuspendLayout(); - var checkCol = this.ResultDataGridView.Columns[CheckedColumnIdx]; + DataGridViewColumn checkCol = this.ResultDataGridView.Columns[CheckedColumnIdx]; checkCol.HeaderText = checkCol.HeaderText == "X" ? "" : "X"; @@ -371,26 +378,28 @@ private void buttonImportDef_Click(object sender, EventArgs e) { if ((bool)row.Cells[CheckedColumnIdx].Value == true) { - string name = (string)row.Cells[NameColumnIdx].Value; + string name = FormatIsotopeName((string)row.Cells[NameColumnIdx].Value); double energy = (double)row.Cells[EnergyColumnIdx].Value; double intencity = (double)row.Cells[IntencityColumnIdx].Value; double halfLife = Convert.ToDouble(((string)row.Cells[HalfLifeColumnIdx].Value).Split('(')[0]); string halfLifeUnit = ((string)row.Cells[HalfLifeColumnIdx].Value).Split('(')[1].Substring(0, 1); double halfLifeYears = ConvertHalfLifeToSeconds(halfLife, halfLifeUnit) / 31536000; - if (IncludeDecayChainCheckBox.Checked && this.SearchedIsotope != name) + if (IncludeDecayChainCheckBox.Checked && checkBoxAppendRootName.Checked && this.SearchedIsotope != name) { - name += " (" + this.SearchedIsotope + ")"; + name += " (" + FormatIsotopeName(this.SearchedIsotope) + ")"; } NuclideDefinition existingDef = defManager.NuclideDefinitions.FirstOrDefault(def => def.Energy == energy); - if (existingDef != null) + if (existingDef != null && checkBoxOverwriteDef.Checked) { + existingDef.Name = name; existingDef.Intencity = intencity; existingDef.HalfLife = halfLifeYears; updatedCount++; } - else + + if (existingDef == null) { defManager.NuclideDefinitions.Add(new NuclideDefinition() { @@ -417,5 +426,39 @@ private void buttonImportDef_Click(object sender, EventArgs e) MessageBox.Show(string.Format(Resources.NuclideDefImportError, ex.Message + ex.StackTrace)); } } + + private string FormatIsotopeName(string nameFromDb) + { + Regex nameFormat = new Regex("^([0-9]+){1}([A-Z]+){1}(m[0-9]+)?$"); + Match match = nameFormat.Match(nameFromDb); + if (!match.Success) + { + return nameFromDb; + } + + string mass = match.Groups[1].Value; + string isotope = match.Groups[2].Value; + string isotopeLower = $"{isotope.Substring(0, 1)}{isotope.Substring(1).ToLower()}"; + string isomer = match.Groups.Count > 3 + ? match.Groups[3].Value + : string.Empty; + + switch (comboBoxNameFormat.SelectedIndex) + { + case 0: // 137CS, 234PAm1 + return $"{mass}{isotope}{isomer}"; + case 1: // Cs137, Pa234m1 + return $"{isotopeLower}{mass}{isomer}"; + case 2: // Cs-137, Pa-234m1 + return $"{isotopeLower}-{mass}{isomer}"; + default: // Cs137, Pa234m1 + return $"{isotopeLower}{mass}{isomer}"; + } + } + + private void IncludeDecayChainCheckBox_CheckedChanged(object sender, EventArgs e) + { + UpdateNuclideDefinitionControlsState(); + } } } diff --git a/BecquerelMonitor/NucBase/NucBase.resx b/BecquerelMonitor/NucBase/NucBase.resx index 17f74a8..acc10cc 100644 --- a/BecquerelMonitor/NucBase/NucBase.resx +++ b/BecquerelMonitor/NucBase/NucBase.resx @@ -531,6 +531,129 @@ Top, Bottom, Left, Right + + False + + + 137CS, 234PAm1 + + + Cs137, Pa234m1 + + + Cs-137, Pa-234m1 + + + 325, 434 + + + 117, 21 + + + 10 + + + comboBoxNameFormat + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel1 + + + 0 + + + True + + + False + + + 322, 416 + + + 112, 13 + + + 9 + + + Definition name format + + + labelNameFormat + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel1 + + + 1 + + + True + + + False + + + 8, 438 + + + 303, 17 + + + 8 + + + Append main isotope to decay product, ex. Pb214 (Ra226) + + + checkBoxAppendRootName + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel1 + + + 2 + + + True + + + False + + + 8, 415 + + + 224, 17 + + + 7 + + + Overwrite definitions with the same energy + + + checkBoxOverwriteDef + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel1 + + + 3 + False @@ -556,7 +679,7 @@ panel1 - 0 + 4 True @@ -583,7 +706,7 @@ panel1 - 1 + 5 True @@ -631,7 +754,7 @@ panel1 - 2 + 6 True @@ -658,7 +781,7 @@ panel1 - 3 + 7 True @@ -706,7 +829,7 @@ panel1 - 4 + 8 True @@ -1036,7 +1159,7 @@ panel1 - 5 + 9 X @@ -1129,13 +1252,13 @@ panel1 - 6 + 10 0, 60 - 976, 418 + 976, 458 1 @@ -1165,13 +1288,13 @@ True - 988, 481 + 988, 521 - 1004, 520 + 1004, 560 - 1004, 489 + 1004, 560 CenterParent diff --git a/BecquerelMonitor/NucBase/NucBase.ru.resx b/BecquerelMonitor/NucBase/NucBase.ru.resx index e951f2e..ed88aab 100644 --- a/BecquerelMonitor/NucBase/NucBase.ru.resx +++ b/BecquerelMonitor/NucBase/NucBase.ru.resx @@ -243,4 +243,13 @@ Импортировать выбранные элементы в список изотопов + + Добавлять имя основного изотопа к дочернему - Pb214 (Ra226) + + + Заменять записи при совпадении энергии + + + Формат имени изотопа + \ No newline at end of file diff --git a/BecquerelMonitor/ROIConfigForm.Designer.cs b/BecquerelMonitor/ROIConfigForm.Designer.cs index f1554ac..04b9c9f 100644 --- a/BecquerelMonitor/ROIConfigForm.Designer.cs +++ b/BecquerelMonitor/ROIConfigForm.Designer.cs @@ -323,6 +323,7 @@ void InitializeComponent() this.comboBox2.DropDownStyle = global::System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox2.FormattingEnabled = true; this.comboBox2.Name = "comboBox2"; + this.comboBox2.DropDownWidth = 200; this.comboBox2.SelectedIndexChanged += new global::System.EventHandler(this.comboBox2_SelectedIndexChanged); resources.ApplyResources(this.label21, "label21"); this.label21.Name = "label21"; From 0b71b5997631e68c02db224ba1a4f2301851b4e7 Mon Sep 17 00:00:00 2001 From: Maksim_Bartoshyk Date: Wed, 5 Jun 2024 22:55:51 +0300 Subject: [PATCH 4/5] fix (nuclide definition): fix main isotope name check --- BecquerelMonitor/NucBase/NucBase.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/BecquerelMonitor/NucBase/NucBase.cs b/BecquerelMonitor/NucBase/NucBase.cs index 5df89e8..13189d9 100644 --- a/BecquerelMonitor/NucBase/NucBase.cs +++ b/BecquerelMonitor/NucBase/NucBase.cs @@ -378,7 +378,8 @@ private void buttonImportDef_Click(object sender, EventArgs e) { if ((bool)row.Cells[CheckedColumnIdx].Value == true) { - string name = FormatIsotopeName((string)row.Cells[NameColumnIdx].Value); + string name = (string)row.Cells[NameColumnIdx].Value; + string formattedName = FormatIsotopeName(name); double energy = (double)row.Cells[EnergyColumnIdx].Value; double intencity = (double)row.Cells[IntencityColumnIdx].Value; double halfLife = Convert.ToDouble(((string)row.Cells[HalfLifeColumnIdx].Value).Split('(')[0]); @@ -387,13 +388,13 @@ private void buttonImportDef_Click(object sender, EventArgs e) if (IncludeDecayChainCheckBox.Checked && checkBoxAppendRootName.Checked && this.SearchedIsotope != name) { - name += " (" + FormatIsotopeName(this.SearchedIsotope) + ")"; + formattedName += " (" + FormatIsotopeName(this.SearchedIsotope) + ")"; } NuclideDefinition existingDef = defManager.NuclideDefinitions.FirstOrDefault(def => def.Energy == energy); if (existingDef != null && checkBoxOverwriteDef.Checked) { - existingDef.Name = name; + existingDef.Name = formattedName; existingDef.Intencity = intencity; existingDef.HalfLife = halfLifeYears; updatedCount++; @@ -403,7 +404,7 @@ private void buttonImportDef_Click(object sender, EventArgs e) { defManager.NuclideDefinitions.Add(new NuclideDefinition() { - Name = name, + Name = formattedName, Energy = energy, Intencity = intencity, HalfLife = halfLifeYears, From 0f2ae5881509315835d3cf42c021cf1f2489a6d4 Mon Sep 17 00:00:00 2001 From: Maksim_Bartoshyk Date: Wed, 5 Jun 2024 23:04:01 +0300 Subject: [PATCH 5/5] fix (isotope base): restrict user input in isotope format combobox --- BecquerelMonitor/NucBase/NucBase.Designer.cs | 1 + BecquerelMonitor/NucBase/NucBase.resx | 609 +++++++++++++++---- 2 files changed, 481 insertions(+), 129 deletions(-) diff --git a/BecquerelMonitor/NucBase/NucBase.Designer.cs b/BecquerelMonitor/NucBase/NucBase.Designer.cs index 7941530..b75594a 100644 --- a/BecquerelMonitor/NucBase/NucBase.Designer.cs +++ b/BecquerelMonitor/NucBase/NucBase.Designer.cs @@ -224,6 +224,7 @@ private void InitializeComponent() // // comboBoxNameFormat // + this.comboBoxNameFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; resources.ApplyResources(this.comboBoxNameFormat, "comboBoxNameFormat"); this.comboBoxNameFormat.FormattingEnabled = true; this.comboBoxNameFormat.Items.AddRange(new object[] { diff --git a/BecquerelMonitor/NucBase/NucBase.resx b/BecquerelMonitor/NucBase/NucBase.resx index acc10cc..aed0c88 100644 --- a/BecquerelMonitor/NucBase/NucBase.resx +++ b/BecquerelMonitor/NucBase/NucBase.resx @@ -117,6 +117,200 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + HalfLifeUOMComboBox + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 0 + + + HalfLifeTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 1 + + + label12 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 2 + + + label11 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 3 + + + HighEnrgTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 4 + + + label10 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 5 + + + LowEnrgTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 6 + + + label9 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 7 + + + IntencityTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 8 + + + IncludeDecayChainCheckBox + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 9 + + + label8 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 10 + + + label1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 11 + + + IsotopeTextBox + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 12 + + + SearchButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 13 + + + + 0, 0 + + + 974, 54 + + + + 0 + + + Search Isotope + + + groupBox1 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + ns @@ -141,14 +335,12 @@ Y - 482, 19 68, 21 - 13 @@ -504,30 +696,6 @@ 13 - - 0, 0 - - - 974, 54 - - - 0 - - - Search Isotope - - - groupBox1 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - Top, Bottom, Left, Right @@ -711,27 +879,12 @@ True - - Name - True - - Type - - - 60 - True - - % - - - 140 - 724, 111 @@ -786,27 +939,12 @@ True - - Name - True - - Type - - - 60 - True - - % - - - 140 - 448, 111 @@ -831,11 +969,293 @@ 8 - - True + + IsotopeAbundance - - 394, 20 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 0 + + + abundanceLbl + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 1 + + + IsotopeSpecActivity + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 2 + + + label13 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 3 + + + IsotopeHLLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 4 + + + label5 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 5 + + + IsotopeNLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 6 + + + label4 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 7 + + + IsotopeZLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 8 + + + label3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 9 + + + IsotopeNameLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 10 + + + label2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox2 + + + 11 + + + 448, 3 + + + 516, 76 + + + 1 + + + Isotope Info + + + groupBox2 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel1 + + + 9 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + 8, 0 + + + Vertical + + + 434, 378 + + + 0 + + + ResultDataGridView + + + System.Windows.Forms.DataGridView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel1 + + + 10 + + + 0, 60 + + + 976, 458 + + + 1 + + + panel1 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + Name + + + True + + + Type + + + 60 + + + True + + + % + + + 140 + + + True + + + Name + + + True + + + Type + + + 60 + + + True + + + % + + + 140 + + + True + + + 394, 20 0, 13 @@ -1137,30 +1557,6 @@ 11 - - 448, 3 - - - 516, 76 - - - 1 - - - Isotope Info - - - groupBox2 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 9 - X @@ -1230,51 +1626,6 @@ 80 - - 8, 0 - - - Vertical - - - 434, 378 - - - 0 - - - ResultDataGridView - - - System.Windows.Forms.DataGridView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - panel1 - - - 10 - - - 0, 60 - - - 976, 458 - - - 1 - - - panel1 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - 17, 17