Upgrade wizard for Output.FileWriters.Enhanced components. Test items from local settings are used.

This commit is contained in:
Milan Hanajik
2016-08-01 13:46:21 +02:00
parent 68c6111377
commit 63abe74aed
8 changed files with 139 additions and 36 deletions
@@ -1,4 +1,5 @@
using System.Windows.Forms; using System.Windows.Forms;
using TBF.Resources;
namespace TBF.BenchControl.Output.FileWriters.Enhanced namespace TBF.BenchControl.Output.FileWriters.Enhanced
{ {
@@ -15,9 +16,10 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
InitializeComponent(); InitializeComponent();
} }
public HeaderFooterDlg(string text) public HeaderFooterDlg(bool isHeader, string text)
: this() : this()
{ {
Text = isHeader ? Strings.Header : Strings.Footer;
textBox.Text = text; textBox.Text = text;
} }
} }
@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using log4net; using log4net;
using TBF.BenchControl.Generic; using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.Output.FileWriters.Enhanced namespace TBF.BenchControl.Output.FileWriters.Enhanced
{ {
@@ -36,7 +37,8 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
public WriterCfgCtrl() public WriterCfgCtrl()
{ {
InitializeComponent(); InitializeComponent();
} Localize();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e) private void WriterCfgCtrl_Load(object sender, EventArgs e)
{ {
@@ -58,6 +60,24 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
Redraw(); Redraw();
} }
void Localize()
{
nameLabel.Text = Strings.Name;
destinationLabel.Text = "Destination";
destination2Label.Text = "Destination" + " 2";
yearFoldersLabel.Text = "Year folders";
monthFoldersLabel.Text = "Month folders";
dayFoldersLabel.Text = "Day folders";
fileNameFmtLabel.Text = "File name format";
separatorLabel.Text = "Separator";
eliminateSpacesCheckBox.Text = "No spaces";
headerButton.Text = Strings.Header;
commonItemsButton.Text = "Common items";
testItemsButton.Text = "Test items";
footerButton.Text = Strings.Footer;
upgradeWizardButton.Text = "Upgrade wizard";
}
public void Closing() public void Closing()
{ {
} }
@@ -74,7 +94,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
dayFoldersComboBox.Text = config.DayFolders.ToString(); dayFoldersComboBox.Text = config.DayFolders.ToString();
fileNameFmtTextBox.Text = config.FileNameFormat; fileNameFmtTextBox.Text = config.FileNameFormat;
separatorComboBox.Text = config.Separator.ToString(); separatorComboBox.Text = config.Separator.ToString();
goodOnlyCheckBox.Checked = config.EliminateSpaces; eliminateSpacesCheckBox.Checked = config.EliminateSpaces;
} }
public void Unlock() public void Unlock()
@@ -89,7 +109,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
dayFoldersComboBox.Enabled = true; dayFoldersComboBox.Enabled = true;
fileNameFmtTextBox.Enabled = true; fileNameFmtTextBox.Enabled = true;
separatorComboBox.Enabled = true; separatorComboBox.Enabled = true;
goodOnlyCheckBox.Enabled = true; eliminateSpacesCheckBox.Enabled = true;
headerButton.Enabled = true; headerButton.Enabled = true;
commonItemsButton.Enabled = true; commonItemsButton.Enabled = true;
testItemsButton.Enabled = true; testItemsButton.Enabled = true;
@@ -194,9 +214,9 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
} }
} }
if (config.EliminateSpaces != goodOnlyCheckBox.Checked) if (config.EliminateSpaces != eliminateSpacesCheckBox.Checked)
{ {
config.EliminateSpaces = goodOnlyCheckBox.Checked; config.EliminateSpaces = eliminateSpacesCheckBox.Checked;
flags = CfgUpdateFlags.RestartRqrd; flags = CfgUpdateFlags.RestartRqrd;
} }
@@ -234,7 +254,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
private void headerButton_Click(object sender, EventArgs e) private void headerButton_Click(object sender, EventArgs e)
{ {
HeaderFooterDlg dlg = new HeaderFooterDlg(header.Replace("~", "\r\n")); HeaderFooterDlg dlg = new HeaderFooterDlg(true, header.Replace("~", "\r\n"));
if (dlg.ShowDialog() == DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
header = dlg.EditedText.Replace("\r\n", "~"); header = dlg.EditedText.Replace("\r\n", "~");
@@ -271,11 +291,41 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
private void footerButton_Click(object sender, EventArgs e) private void footerButton_Click(object sender, EventArgs e)
{ {
HeaderFooterDlg dlg = new HeaderFooterDlg(footer.Replace("~", "\r\n")); HeaderFooterDlg dlg = new HeaderFooterDlg(false, footer.Replace("~", "\r\n"));
if (dlg.ShowDialog() == DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)
{ {
footer = dlg.EditedText.Replace("\r\n", "~"); footer = dlg.EditedText.Replace("\r\n", "~");
} }
} }
private void upgradeWizardButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show("This wizzard will overwrite curent settings." + Environment.NewLine +
"Do you want to continue?",
"Confirmation",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
///
/// Use legacy common items (English)
///
commonItems = new string[] {
"3~Batch number:~~None~~~0~",
"72~Date and time:~~None~{0:yyyy.MM.dd HH:mm}~~0~",
"2~Procedure:~~None~~~0~",
"66~User:~~None~~~0~",
"26~Ambient temperature:~~C~{0} °C~F1~0~",
"27~Ambient pressure:~~mBar~{0} mbar~F0~0~",
"28~Ambient humidity:~~Pct~{0} %~F0~0~",
};
commonItemsButton_Click(this, null);
///
/// Use legacy test inems from local settings
///
testItems = config.Factory.ClassName.Contains("Compound") ? Program.LocalSettings.RsltItems_Disk_CombinedWM
: Program.LocalSettings.RsltItems_Disk_SingleWM;
testItemsButton_Click(this, null);
}
}
} }
} }
@@ -51,10 +51,11 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
this.destination2Label = new System.Windows.Forms.Label(); this.destination2Label = new System.Windows.Forms.Label();
this.fileNameFmtTextBox = new System.Windows.Forms.TextBox(); this.fileNameFmtTextBox = new System.Windows.Forms.TextBox();
this.fileNameFmtLabel = new System.Windows.Forms.Label(); this.fileNameFmtLabel = new System.Windows.Forms.Label();
this.goodOnlyCheckBox = new System.Windows.Forms.CheckBox(); this.eliminateSpacesCheckBox = new System.Windows.Forms.CheckBox();
this.headerButton = new System.Windows.Forms.Button(); this.headerButton = new System.Windows.Forms.Button();
this.footerButton = new System.Windows.Forms.Button(); this.footerButton = new System.Windows.Forms.Button();
this.commonItemsButton = new System.Windows.Forms.Button(); this.commonItemsButton = new System.Windows.Forms.Button();
this.upgradeWizardButton = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// nameTextBox // nameTextBox
@@ -103,7 +104,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// destinationButton // destinationButton
// //
this.destinationButton.Enabled = false; this.destinationButton.Enabled = false;
this.destinationButton.Location = new System.Drawing.Point(259, 56); this.destinationButton.Location = new System.Drawing.Point(269, 52);
this.destinationButton.Name = "destinationButton"; this.destinationButton.Name = "destinationButton";
this.destinationButton.Size = new System.Drawing.Size(30, 20); this.destinationButton.Size = new System.Drawing.Size(30, 20);
this.destinationButton.TabIndex = 5; this.destinationButton.TabIndex = 5;
@@ -129,14 +130,14 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
this.separatorComboBox.Size = new System.Drawing.Size(146, 21); this.separatorComboBox.Size = new System.Drawing.Size(146, 21);
this.separatorComboBox.TabIndex = 18; this.separatorComboBox.TabIndex = 18;
// //
// selectItemsButton // testItemsButton
// //
this.testItemsButton.Enabled = false; this.testItemsButton.Enabled = false;
this.testItemsButton.Location = new System.Drawing.Point(200, 204); this.testItemsButton.Location = new System.Drawing.Point(108, 278);
this.testItemsButton.Name = "selectItemsButton"; this.testItemsButton.Name = "testItemsButton";
this.testItemsButton.Size = new System.Drawing.Size(40, 23); this.testItemsButton.Size = new System.Drawing.Size(146, 23);
this.testItemsButton.TabIndex = 22; this.testItemsButton.TabIndex = 22;
this.testItemsButton.Text = "Items"; this.testItemsButton.Text = "Test items";
this.testItemsButton.UseVisualStyleBackColor = true; this.testItemsButton.UseVisualStyleBackColor = true;
this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click); this.testItemsButton.Click += new System.EventHandler(this.testItemsButton_Click);
// //
@@ -197,7 +198,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// destination2Button // destination2Button
// //
this.destination2Button.Enabled = false; this.destination2Button.Enabled = false;
this.destination2Button.Location = new System.Drawing.Point(259, 79); this.destination2Button.Location = new System.Drawing.Point(269, 73);
this.destination2Button.Name = "destination2Button"; this.destination2Button.Name = "destination2Button";
this.destination2Button.Size = new System.Drawing.Size(30, 20); this.destination2Button.Size = new System.Drawing.Size(30, 20);
this.destination2Button.TabIndex = 8; this.destination2Button.TabIndex = 8;
@@ -238,22 +239,22 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
this.fileNameFmtLabel.TabIndex = 15; this.fileNameFmtLabel.TabIndex = 15;
this.fileNameFmtLabel.Text = "File name format"; this.fileNameFmtLabel.Text = "File name format";
// //
// goodOnlyCheckBox // eliminateSpacesCheckBox
// //
this.goodOnlyCheckBox.AutoSize = true; this.eliminateSpacesCheckBox.AutoSize = true;
this.goodOnlyCheckBox.Location = new System.Drawing.Point(6, 208); this.eliminateSpacesCheckBox.Location = new System.Drawing.Point(108, 208);
this.goodOnlyCheckBox.Name = "goodOnlyCheckBox"; this.eliminateSpacesCheckBox.Name = "eliminateSpacesCheckBox";
this.goodOnlyCheckBox.Size = new System.Drawing.Size(77, 17); this.eliminateSpacesCheckBox.Size = new System.Drawing.Size(77, 17);
this.goodOnlyCheckBox.TabIndex = 19; this.eliminateSpacesCheckBox.TabIndex = 19;
this.goodOnlyCheckBox.Text = "No spaces"; this.eliminateSpacesCheckBox.Text = "No spaces";
this.goodOnlyCheckBox.UseVisualStyleBackColor = true; this.eliminateSpacesCheckBox.UseVisualStyleBackColor = true;
// //
// headerButton // headerButton
// //
this.headerButton.Enabled = false; this.headerButton.Enabled = false;
this.headerButton.Location = new System.Drawing.Point(90, 204); this.headerButton.Location = new System.Drawing.Point(108, 228);
this.headerButton.Name = "headerButton"; this.headerButton.Name = "headerButton";
this.headerButton.Size = new System.Drawing.Size(51, 23); this.headerButton.Size = new System.Drawing.Size(146, 23);
this.headerButton.TabIndex = 20; this.headerButton.TabIndex = 20;
this.headerButton.Text = "Header"; this.headerButton.Text = "Header";
this.headerButton.UseVisualStyleBackColor = true; this.headerButton.UseVisualStyleBackColor = true;
@@ -262,33 +263,44 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
// footerButton // footerButton
// //
this.footerButton.Enabled = false; this.footerButton.Enabled = false;
this.footerButton.Location = new System.Drawing.Point(241, 204); this.footerButton.Location = new System.Drawing.Point(108, 303);
this.footerButton.Name = "footerButton"; this.footerButton.Name = "footerButton";
this.footerButton.Size = new System.Drawing.Size(51, 23); this.footerButton.Size = new System.Drawing.Size(146, 23);
this.footerButton.TabIndex = 23; this.footerButton.TabIndex = 23;
this.footerButton.Text = "Footer"; this.footerButton.Text = "Footer";
this.footerButton.UseVisualStyleBackColor = true; this.footerButton.UseVisualStyleBackColor = true;
this.footerButton.Click += new System.EventHandler(this.footerButton_Click); this.footerButton.Click += new System.EventHandler(this.footerButton_Click);
// //
// commonButton // commonItemsButton
// //
this.commonItemsButton.Enabled = false; this.commonItemsButton.Enabled = false;
this.commonItemsButton.Location = new System.Drawing.Point(142, 204); this.commonItemsButton.Location = new System.Drawing.Point(108, 253);
this.commonItemsButton.Name = "commonButton"; this.commonItemsButton.Name = "commonItemsButton";
this.commonItemsButton.Size = new System.Drawing.Size(57, 23); this.commonItemsButton.Size = new System.Drawing.Size(146, 23);
this.commonItemsButton.TabIndex = 21; this.commonItemsButton.TabIndex = 21;
this.commonItemsButton.Text = "Common"; this.commonItemsButton.Text = "Common items";
this.commonItemsButton.UseVisualStyleBackColor = true; this.commonItemsButton.UseVisualStyleBackColor = true;
this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click); this.commonItemsButton.Click += new System.EventHandler(this.commonItemsButton_Click);
// //
// upgradeWizardButton
//
this.upgradeWizardButton.Location = new System.Drawing.Point(269, 253);
this.upgradeWizardButton.Name = "upgradeWizardButton";
this.upgradeWizardButton.Size = new System.Drawing.Size(80, 48);
this.upgradeWizardButton.TabIndex = 24;
this.upgradeWizardButton.Text = "Upgrade wizard";
this.upgradeWizardButton.UseVisualStyleBackColor = true;
this.upgradeWizardButton.Click += new System.EventHandler(this.upgradeWizardButton_Click);
//
// WriterCfgCtrl // WriterCfgCtrl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.upgradeWizardButton);
this.Controls.Add(this.commonItemsButton); this.Controls.Add(this.commonItemsButton);
this.Controls.Add(this.footerButton); this.Controls.Add(this.footerButton);
this.Controls.Add(this.headerButton); this.Controls.Add(this.headerButton);
this.Controls.Add(this.goodOnlyCheckBox); this.Controls.Add(this.eliminateSpacesCheckBox);
this.Controls.Add(this.fileNameFmtTextBox); this.Controls.Add(this.fileNameFmtTextBox);
this.Controls.Add(this.fileNameFmtLabel); this.Controls.Add(this.fileNameFmtLabel);
this.Controls.Add(this.destination2Button); this.Controls.Add(this.destination2Button);
@@ -310,7 +322,7 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
this.Controls.Add(this.nameLabel); this.Controls.Add(this.nameLabel);
this.Controls.Add(this.classNameLabel); this.Controls.Add(this.classNameLabel);
this.Name = "WriterCfgCtrl"; this.Name = "WriterCfgCtrl";
this.Size = new System.Drawing.Size(300, 230); this.Size = new System.Drawing.Size(400, 350);
this.Load += new System.EventHandler(this.WriterCfgCtrl_Load); this.Load += new System.EventHandler(this.WriterCfgCtrl_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -339,9 +351,10 @@ namespace TBF.BenchControl.Output.FileWriters.Enhanced
private System.Windows.Forms.Label destination2Label; private System.Windows.Forms.Label destination2Label;
private System.Windows.Forms.TextBox fileNameFmtTextBox; private System.Windows.Forms.TextBox fileNameFmtTextBox;
private System.Windows.Forms.Label fileNameFmtLabel; private System.Windows.Forms.Label fileNameFmtLabel;
private System.Windows.Forms.CheckBox goodOnlyCheckBox; private System.Windows.Forms.CheckBox eliminateSpacesCheckBox;
private System.Windows.Forms.Button headerButton; private System.Windows.Forms.Button headerButton;
private System.Windows.Forms.Button footerButton; private System.Windows.Forms.Button footerButton;
private System.Windows.Forms.Button commonItemsButton; private System.Windows.Forms.Button commonItemsButton;
private System.Windows.Forms.Button upgradeWizardButton;
} }
} }
+2
View File
@@ -194,6 +194,8 @@ namespace TBF
public string[] RsltItems_Screen_CombinedWM; public string[] RsltItems_Screen_CombinedWM;
public string[] RsltItems_Printer_SingleWM; public string[] RsltItems_Printer_SingleWM;
public string[] RsltItems_Printer_CombinedWM; public string[] RsltItems_Printer_CombinedWM;
public string[] RsltItems_Disk_SingleWM; /// Legacy, can optionally be used to initialize file writer settings
public string[] RsltItems_Disk_CombinedWM; /// Legacy, can optionally be used to initialize file writer settings
[XmlArrayAttribute("RsltsClmnWidths")] [XmlArrayAttribute("RsltsClmnWidths")]
public int[] RsltsClmnWidths; public int[] RsltsClmnWidths;
+18
View File
@@ -1374,6 +1374,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Footer.
/// </summary>
internal static string Footer {
get {
return ResourceManager.GetString("Footer", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to General. /// Looks up a localized string similar to General.
/// </summary> /// </summary>
@@ -1419,6 +1428,15 @@ namespace TBF.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Header.
/// </summary>
internal static string Header {
get {
return ResourceManager.GetString("Header", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Heat meter. /// Looks up a localized string similar to Heat meter.
/// </summary> /// </summary>
@@ -1269,4 +1269,10 @@
<data name="Another_instance_is_running" xml:space="preserve"> <data name="Another_instance_is_running" xml:space="preserve">
<value>Další instance programu Test Bench Framework je spuštěna. Uzavřete jí prosím s použitím 'Správce úloh'.</value> <value>Další instance programu Test Bench Framework je spuštěna. Uzavřete jí prosím s použitím 'Správce úloh'.</value>
</data> </data>
<data name="Footer" xml:space="preserve">
<value>Zápatí</value>
</data>
<data name="Header" xml:space="preserve">
<value>Hlavička</value>
</data>
</root> </root>
@@ -1344,4 +1344,10 @@
<data name="Another_instance_is_running" xml:space="preserve"> <data name="Another_instance_is_running" xml:space="preserve">
<value>Ein weiteres Test Bench Framework Programm-Instanz ausgeführt wird. Bitte schließen Sie es dem Taskmanager.</value> <value>Ein weiteres Test Bench Framework Programm-Instanz ausgeführt wird. Bitte schließen Sie es dem Taskmanager.</value>
</data> </data>
<data name="Footer" xml:space="preserve">
<value>Fußzeile</value>
</data>
<data name="Header" xml:space="preserve">
<value>Kopfzeile</value>
</data>
</root> </root>
@@ -1513,4 +1513,10 @@
<data name="Another_instance_is_running" xml:space="preserve"> <data name="Another_instance_is_running" xml:space="preserve">
<value>Another instance of Test Bench Framework program is running. Please, close it using Task Manager.</value> <value>Another instance of Test Bench Framework program is running. Please, close it using Task Manager.</value>
</data> </data>
<data name="Footer" xml:space="preserve">
<value>Footer</value>
</data>
<data name="Header" xml:space="preserve">
<value>Header</value>
</data>
</root> </root>