DataEntry.Uni.CycleBgEnForm : 1. autoSNButton --> multiPurposeButton, 2. Initial configuration : Order : Ac.HistoryLast, ver. 2.33.2138

This commit is contained in:
Milan Hanajik 2023-12-12 18:43:55 +01:00
parent e0d10bed71
commit 4bff6f33de
7 changed files with 138 additions and 83 deletions

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("2.33.2134.0")] [assembly: AssemblyVersion("2.33.2138.0")]
[assembly: AssemblyFileVersion("2.33.2134.0")] [assembly: AssemblyFileVersion("2.33.2138.0")]

View File

@ -1213,7 +1213,7 @@
<value>Objem</value> <value>Objem</value>
</data> </data>
<data name="PrintBtnText" xml:space="preserve"> <data name="PrintBtnText" xml:space="preserve">
<value>Vytisknout</value> <value>Tisknout</value>
</data> </data>
<data name="Do_you_want_to_save_changes" xml:space="preserve"> <data name="Do_you_want_to_save_changes" xml:space="preserve">
<value>Chcete uložit změny?</value> <value>Chcete uložit změny?</value>
@ -1675,7 +1675,7 @@
<value>Konfigurace testu {0} : chybí {1}</value> <value>Konfigurace testu {0} : chybí {1}</value>
</data> </data>
<data name="Print" xml:space="preserve"> <data name="Print" xml:space="preserve">
<value>Vytisknout</value> <value>Tisknout</value>
</data> </data>
<data name="Printer_selection" xml:space="preserve"> <data name="Printer_selection" xml:space="preserve">
<value>Výběr tiskárny</value> <value>Výběr tiskárny</value>

View File

@ -6,9 +6,9 @@ using Common;
namespace TBF.Rig.DataEntry namespace TBF.Rig.DataEntry
{ {
/// /// <summary>
/// Ac = Action /// Action of a DataEntry field
/// /// </summary>
public enum Ac public enum Ac
{ {
[Description("Clear")] Clear, /// Clear when the form is open, save on OK [Description("Clear")] Clear, /// Clear when the form is open, save on OK
@ -19,9 +19,9 @@ namespace TBF.Rig.DataEntry
Count, Count,
} }
/// /// <summary>
/// Ct = Content /// Content of a DataEntry field
/// /// </summary>
public enum Ct public enum Ct
{ {
[Description("None")] None, [Description("None")] None,
@ -48,6 +48,16 @@ namespace TBF.Rig.DataEntry
Count Count
} }
/// <summary>
/// Function of the multi purpose button
/// </summary>
public enum MultiPurposeBtnFunction
{
None,
AutoSN,
PrintLabelsOnOff,
}
/// ///
/// Identifies image instance /// Identifies image instance
/// ///

View File

@ -50,6 +50,9 @@ namespace TBF.Rig.DataEntry.Uni
readonly ComboBox[,] comboBoxes; /// Combo boxes for values in columns readonly ComboBox[,] comboBoxes; /// Combo boxes for values in columns
readonly CheckBox[] checkBoxes; /// Check boxes for water meter enable/disable readonly CheckBox[] checkBoxes; /// Check boxes for water meter enable/disable
readonly MultiPurposeBtnFunction multiPurposeButtonFn;
bool multiPurposeButtonFlag;
readonly LocalSettings ls; readonly LocalSettings ls;
bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data bool isHandlersEnabled; /// Initially false, set to true after ComboBoxes are filled with data
@ -124,13 +127,29 @@ namespace TBF.Rig.DataEntry.Uni
comboBoxes = new ComboBox[colItems.Count, wmsCount]; comboBoxes = new ComboBox[colItems.Count, wmsCount];
checkBoxes = new CheckBox[wmsCount]; checkBoxes = new CheckBox[wmsCount];
/// Make Auto s/n button visible if there is either Ct.SerialNr or Ct.SerialNrAux column ///
/// Determine the multi purpose button function
///
multiPurposeButton.Visible = false;
multiPurposeButtonFn = MultiPurposeBtnFunction.None;
int buttonsWidth = 350; int buttonsWidth = 350;
for (int k = 0; k < colItems.Count; k++) for (int k = 0; k < colItems.Count; k++)
{ {
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly) if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{ {
autoSNButton.Visible = true; multiPurposeButton.Visible = true;
multiPurposeButton.Text = "Auto s/n";
multiPurposeButtonFn = MultiPurposeBtnFunction.AutoSN;
buttonsWidth += 147;
break;
}
if (colItems[k].Content == Ct.PrintLabel)
{
multiPurposeButton.Visible = true;
multiPurposeButton.Text = string.Format("{0} ({1}/{2})", Strings.Print, Strings.yes, Strings.no);
multiPurposeButtonFn = MultiPurposeBtnFunction.PrintLabelsOnOff;
multiPurposeButtonFlag = false;
buttonsWidth += 147; buttonsWidth += 147;
break; break;
} }
@ -518,7 +537,7 @@ namespace TBF.Rig.DataEntry.Uni
case Ac.Set: case Ac.Set:
for (int i = 0; i < wmsCount; i++) for (int i = 0; i < wmsCount; i++)
{ {
comboBoxes[k, i].Text = Strings.yes; comboBoxes[k, i].Text = (WaterMeters[i] != null && !WaterMeters[i].Disabled) ? Strings.yes : Strings.no;
} }
break; break;
} }
@ -648,63 +667,68 @@ namespace TBF.Rig.DataEntry.Uni
InitializeBoxes(); InitializeBoxes();
} }
private void autoSNButton_Click(object sender, EventArgs e) private void multiPurposeButton_Click(object sender, EventArgs e)
{ {
/// if (multiPurposeButtonFn == MultiPurposeBtnFunction.None) return;
/// Find the 1st enabled water meter
///
int firstIx;
for (firstIx = 0; firstIx < wmsCount; firstIx++)
{
if (checkBoxes[firstIx].Checked) break;
}
if (firstIx == wmsCount)
{
return; /// There is not any enabled water meter
}
char[] digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; if (multiPurposeButtonFn == MultiPurposeBtnFunction.AutoSN)
///
/// Find a column with serial numbers
///
for (int k = 0; k < colItems.Count; k++)
{ {
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly) ///
/// Find the 1st enabled water meter
///
int firstIx;
for (firstIx = 0; firstIx < wmsCount; firstIx++)
{ {
/// if (checkBoxes[firstIx].Checked) break;
/// Column with serial numbers found => perform an auto s/n assignment }
/// if (firstIx == wmsCount)
string firstSN = comboBoxes[k, firstIx].Text; {
return; /// There is not any enabled water meter
}
int firstSnNr; char[] digits = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
int startIx = firstSN.IndexOfAny(digits);
if (startIx >= 0) ///
/// Find a column with serial numbers
///
for (int k = 0; k < colItems.Count; k++)
{
if ((colItems[k].Content == Ct.SerialNr || colItems[k].Content == Ct.SerialNrAux) && colItems[k].Action != Ac.LoadReadOnly)
{ {
int lastDigitPosPlus1 = startIx + 1; ///
var listOfDigits = new List<char>(digits); /// Column with serial numbers found => perform an auto s/n assignment
while (lastDigitPosPlus1 < firstSN.Length && listOfDigits.Contains(firstSN[lastDigitPosPlus1])) ///
{ string firstSN = comboBoxes[k, firstIx].Text;
lastDigitPosPlus1++;
}
int digitsCount = lastDigitPosPlus1 - startIx;
if (int.TryParse(firstSN.Substring(startIx, digitsCount), out firstSnNr) && firstSnNr >= 0) int firstSnNr;
int startIx = firstSN.IndexOfAny(digits);
if (startIx >= 0)
{ {
for (int ix = firstIx + 1; ix < wmsCount; ix++) int lastDigitPosPlus1 = startIx + 1;
var listOfDigits = new List<char>(digits);
while (lastDigitPosPlus1 < firstSN.Length && listOfDigits.Contains(firstSN[lastDigitPosPlus1]))
{ {
if (checkBoxes[ix].Checked) lastDigitPosPlus1++;
}
int digitsCount = lastDigitPosPlus1 - startIx;
if (int.TryParse(firstSN.Substring(startIx, digitsCount), out firstSnNr) && firstSnNr >= 0)
{
for (int ix = firstIx + 1; ix < wmsCount; ix++)
{ {
firstSnNr++; if (checkBoxes[ix].Checked)
string newSN = firstSnNr.ToString();
int len = newSN.Length;
if (len <= digitsCount)
{ {
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx + digitsCount - len) + newSN + firstSN.Substring(startIx + digitsCount); firstSnNr++;
} string newSN = firstSnNr.ToString();
else int len = newSN.Length;
{ if (len <= digitsCount)
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx) + newSN + firstSN.Substring(startIx + digitsCount); ; {
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx + digitsCount - len) + newSN + firstSN.Substring(startIx + digitsCount);
}
else
{
comboBoxes[k, ix].Text = firstSN.Substring(0, startIx) + newSN + firstSN.Substring(startIx + digitsCount); ;
}
} }
} }
} }
@ -712,6 +736,27 @@ namespace TBF.Rig.DataEntry.Uni
} }
} }
} }
if (multiPurposeButtonFn == MultiPurposeBtnFunction.PrintLabelsOnOff)
{
///
/// Find a column with Ct.PrintLabel
///
for (int k = 0; k < colItems.Count; k++)
{
if (colItems[k].Content == Ct.PrintLabel)
{
for (int ix = 0; ix < wmsCount; ix++)
{
if (WaterMeters[ix] != null && !WaterMeters[ix].Disabled)
{
comboBoxes[k, ix].Text = multiPurposeButtonFlag ? Strings.yes : Strings.no;
}
}
}
}
multiPurposeButtonFlag = !multiPurposeButtonFlag;
}
} }
private void comboBox_SelectedIndexChanged(object sndr, EventArgs e) private void comboBox_SelectedIndexChanged(object sndr, EventArgs e)

View File

@ -34,7 +34,7 @@ namespace TBF.Rig.DataEntry.Uni
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleBgEnForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CycleBgEnForm));
this.okButton = new System.Windows.Forms.Button(); this.okButton = new System.Windows.Forms.Button();
this.clearButton = new System.Windows.Forms.Button(); this.clearButton = new System.Windows.Forms.Button();
this.autoSNButton = new System.Windows.Forms.Button(); this.multiPurposeButton = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// okButton // okButton
@ -53,20 +53,20 @@ namespace TBF.Rig.DataEntry.Uni
this.clearButton.UseVisualStyleBackColor = true; this.clearButton.UseVisualStyleBackColor = true;
this.clearButton.Click += new System.EventHandler(this.clearButton_Click); this.clearButton.Click += new System.EventHandler(this.clearButton_Click);
// //
// autoSNButton // multiPurposeButton
// //
resources.ApplyResources(this.autoSNButton, "autoSNButton"); resources.ApplyResources(this.multiPurposeButton, "multiPurposeButton");
this.autoSNButton.ForeColor = System.Drawing.Color.Black; this.multiPurposeButton.ForeColor = System.Drawing.Color.Black;
this.autoSNButton.Name = "autoSNButton"; this.multiPurposeButton.Name = "multiPurposeButton";
this.autoSNButton.UseVisualStyleBackColor = true; this.multiPurposeButton.UseVisualStyleBackColor = true;
this.autoSNButton.Click += new System.EventHandler(this.autoSNButton_Click); this.multiPurposeButton.Click += new System.EventHandler(this.multiPurposeButton_Click);
// //
// CycleBgEnForm // CycleBgEnForm
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.DarkGray; this.BackColor = System.Drawing.Color.DarkGray;
this.Controls.Add(this.autoSNButton); this.Controls.Add(this.multiPurposeButton);
this.Controls.Add(this.clearButton); this.Controls.Add(this.clearButton);
this.Controls.Add(this.okButton); this.Controls.Add(this.okButton);
this.ForeColor = System.Drawing.Color.Black; this.ForeColor = System.Drawing.Color.Black;
@ -81,6 +81,6 @@ namespace TBF.Rig.DataEntry.Uni
private System.Windows.Forms.Button okButton; private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Button clearButton; private System.Windows.Forms.Button clearButton;
private System.Windows.Forms.Button autoSNButton; private System.Windows.Forms.Button multiPurposeButton;
} }
} }

View File

@ -183,40 +183,40 @@
<data name="&gt;&gt;clearButton.ZOrder" xml:space="preserve"> <data name="&gt;&gt;clearButton.ZOrder" xml:space="preserve">
<value>1</value> <value>1</value>
</data> </data>
<data name="autoSNButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms"> <data name="multiPurposeButton.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value> <value>Top, Right</value>
</data> </data>
<data name="autoSNButton.Font" type="System.Drawing.Font, System.Drawing"> <data name="multiPurposeButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Verdana, 14.25pt</value> <value>Verdana, 14.25pt</value>
</data> </data>
<data name="autoSNButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms"> <data name="multiPurposeButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="autoSNButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="multiPurposeButton.Location" type="System.Drawing.Point, System.Drawing">
<value>648, 26</value> <value>648, 26</value>
</data> </data>
<data name="autoSNButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="multiPurposeButton.Size" type="System.Drawing.Size, System.Drawing">
<value>112, 63</value> <value>112, 63</value>
</data> </data>
<data name="autoSNButton.TabIndex" type="System.Int32, mscorlib"> <data name="multiPurposeButton.TabIndex" type="System.Int32, mscorlib">
<value>9</value> <value>9</value>
</data> </data>
<data name="autoSNButton.Text" xml:space="preserve"> <data name="multiPurposeButton.Text" xml:space="preserve">
<value>Auto s/n</value> <value>Multi purpose</value>
</data> </data>
<data name="autoSNButton.Visible" type="System.Boolean, mscorlib"> <data name="multiPurposeButton.Visible" type="System.Boolean, mscorlib">
<value>False</value> <value>False</value>
</data> </data>
<data name="&gt;&gt;autoSNButton.Name" xml:space="preserve"> <data name="&gt;&gt;multiPurposeButton.Name" xml:space="preserve">
<value>autoSNButton</value> <value>multiPurposeButton</value>
</data> </data>
<data name="&gt;&gt;autoSNButton.Type" xml:space="preserve"> <data name="&gt;&gt;multiPurposeButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;autoSNButton.Parent" xml:space="preserve"> <data name="&gt;&gt;multiPurposeButton.Parent" xml:space="preserve">
<value>$this</value> <value>$this</value>
</data> </data>
<data name="&gt;&gt;autoSNButton.ZOrder" xml:space="preserve"> <data name="&gt;&gt;multiPurposeButton.ZOrder" xml:space="preserve">
<value>0</value> <value>0</value>
</data> </data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -347,7 +347,7 @@ namespace TBF.Rig.DataEntry.Uni
BgItemContent = new Ct[1] { Ct.BatchAndWmOrder }; BgItemContent = new Ct[1] { Ct.BatchAndWmOrder };
BgItemCaption = new string[1] { "Order nr." }; BgItemCaption = new string[1] { "Order nr." };
BgItemAction = new Ac[1] { Ac.Clear }; BgItemAction = new Ac[1] { Ac.HistoryLast };
BgItemWidth = new int[1] { 200 }; BgItemWidth = new int[1] { 200 };
BgColumnContent = new Ct[1] { Ct.SerialNr }; BgColumnContent = new Ct[1] { Ct.SerialNr };