diff --git a/TestBenchFramework/ComponentsManagerDlg.Designer.cs b/TestBenchFramework/ComponentsManagerDlg.Designer.cs
index 06b46ae11..89c048d4c 100644
--- a/TestBenchFramework/ComponentsManagerDlg.Designer.cs
+++ b/TestBenchFramework/ComponentsManagerDlg.Designer.cs
@@ -33,7 +33,7 @@ namespace TBF
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ComponentsManagerDlg));
this.splitContainer = new System.Windows.Forms.SplitContainer();
- this.listViewEx = new Results.Forms.ListViewEx();
+ this.listViewEx = new Results.Forms.ListViewEx();
this.sharedButtons = new TBF.UiControls.SharedButtons();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
@@ -80,6 +80,7 @@ namespace TBF
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer);
this.Name = "ComponentsManagerDlg";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ComponentsManagerDlg_FormClosing);
this.Load += new System.EventHandler(this.ComponentsManagerDlg_Load);
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
diff --git a/TestBenchFramework/ComponentsManagerDlg.cs b/TestBenchFramework/ComponentsManagerDlg.cs
index ecf05a390..1b71a4498 100644
--- a/TestBenchFramework/ComponentsManagerDlg.cs
+++ b/TestBenchFramework/ComponentsManagerDlg.cs
@@ -30,7 +30,7 @@ namespace TBF
SelectComponentClassDlg selectComponentTypeDlg; /// Constructed once, the selection is kept between dialog usages
CfgUpdateFlags flags; /// Or-ed from particular Flags from ComponentParametersDlg
-
+
///
/// ListViewEx columns
///
@@ -108,9 +108,9 @@ namespace TBF
sharedButtons.DisableButtons(UiControls.SharedButtons.Buttons.Remove | UiControls.SharedButtons.Buttons.Edit);
session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config);
- cmpntEntities = session
- .CreateQuery("FROM Component ORDER BY ItemNr")
- .List();
+ cmpntEntities = session.QueryOver()
+ .OrderBy(x => x.ItemNr).Asc
+ .List();
RedrawAll();
}
@@ -189,34 +189,65 @@ namespace TBF
}
}
+ ///
+ /// Save DB changes, return true when DB changes saved OK
+ ///
+ bool SaveDBChanges(NHibernate.ISession ses)
+ {
+ try
+ {
+ foreach (var cmpnt in toBeDeletedEntities)
+ {
+ Config.FluentCommon.DeleteFromDb(ses, cmpnt);
+ }
+
+ int itemNr = 1;
+ foreach (var cmpnt in cmpntEntities)
+ {
+ cmpnt.ItemNr = itemNr++;
+ Config.FluentCommon.SaveToDb(ses, cmpnt);
+ }
+ ses.Flush();
+
+ return true;
+ }
+ catch (Exception exc)
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// Save the dialog position and ListViewEx column widths
+ ///
+ void SaveUISettings()
+ {
+ Program.LocalSettings.ComponentsDlgLeft = Location.X;
+ Program.LocalSettings.ComponentsDlgTop = Location.Y;
+ Program.LocalSettings.ComponentsDlgWidth = Size.Width;
+ Program.LocalSettings.ComponentsDlgHeight = Size.Height;
+ Program.LocalSettings.Save();
+
+ /// Update the column widths
+ Program.LocalSettings.ComponentsColumnWidths = new int[(int)Column.ColumnsCount];
+ for (int i = 0; i < (int)Column.ColumnsCount; i++)
+ {
+ Program.LocalSettings.ComponentsColumnWidths[i] = listViewEx.Columns[i].Width;
+ }
+ Program.LocalSettings.Save();
+ }
+
+ ///
/// OK
- private void okButton_Click(object sender, EventArgs e)
+ ///
+ private void okButton_Click(object sender, EventArgs e)
{
if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0)
{
- foreach (var cmpnt in toBeDeletedEntities)
- {
- Config.FluentCommon.DeleteFromDb(session, cmpnt);
- }
- foreach (var cmpnt in cmpntEntities)
- {
- Config.FluentCommon.SaveToDb(session, cmpnt);
- }
-
- Program.LocalSettings.ComponentsDlgLeft = Location.X;
- Program.LocalSettings.ComponentsDlgTop = Location.Y;
- Program.LocalSettings.ComponentsDlgWidth = Size.Width;
- Program.LocalSettings.ComponentsDlgHeight = Size.Height;
- Program.LocalSettings.Save();
+ SaveDBChanges(session);
}
- /// Update the column widths
- Program.LocalSettings.ComponentsColumnWidths = new int[(int)Column.ColumnsCount];
- for (int i = 0; i < (int)Column.ColumnsCount; i++)
- {
- Program.LocalSettings.ComponentsColumnWidths[i] = listViewEx.Columns[i].Width;
- }
- Program.LocalSettings.Save();
+ SaveUISettings();
DialogResult = DialogResult.OK;
Close();
@@ -226,11 +257,7 @@ namespace TBF
/// Cancel
private void cancelButton_Click(object sender, EventArgs e)
{
- Program.LocalSettings.ComponentsDlgLeft = Location.X;
- Program.LocalSettings.ComponentsDlgTop = Location.Y;
- Program.LocalSettings.ComponentsDlgWidth = Size.Width;
- Program.LocalSettings.ComponentsDlgHeight = Size.Height;
- Program.LocalSettings.Save();
+ SaveUISettings();
if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0)
{
@@ -241,6 +268,8 @@ namespace TBF
if (dr != DialogResult.Yes) return;
}
+ flags = CfgUpdateFlags.None; /// Already confirmed abandoning changes
+
DialogResult = DialogResult.Cancel;
Close();
return;
@@ -249,21 +278,21 @@ namespace TBF
/// Add a new component
private void addButton_Click(object sender, EventArgs e)
{
- DialogResult dr = selectComponentTypeDlg.ShowDialog();
- if (dr != DialogResult.OK) return;
+ DialogResult dialogRslt = selectComponentTypeDlg.ShowDialog();
+ if (dialogRslt != DialogResult.OK) return;
IComponentFactory factory = selectComponentTypeDlg.SlctdCmpntFactory;
IComponentCfg cfg = factory.DefaultConfig();
IComponentCfgCtrl cfgControl = cfg.GetControl();
cfgControl.Config = cfg;
- cfgControl.Config.ItemNr = listViewEx.Items.Count;
+ cfgControl.Config.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1;
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
cfgForm.TbfComponents = cmpntEntities;
cfgForm.ComponentCfgCtrl = cfgControl;
cfgForm.UnlockAfterStart = true;
- dr = cfgForm.ShowDialog();
- if (dr != DialogResult.OK) return;
+ dialogRslt = cfgForm.ShowDialog();
+ if (dialogRslt != DialogResult.OK) return;
flags |= CfgUpdateFlags.RestartRqrd;
AddOne(cfgForm.Config.CreateDbEntity());
@@ -283,8 +312,11 @@ namespace TBF
if (ix < 0) return;
Component selectedCmpnt = (Component)listViewEx.Items[ix].Tag;
- if (selectedCmpnt.Id != 0) toBeDeletedEntities.Add(selectedCmpnt);
- listViewEx.Items.RemoveAt(ix);
+ if (selectedCmpnt.Id != 0) toBeDeletedEntities.Add(selectedCmpnt);
+ cmpntEntities.Remove(selectedCmpnt);
+
+ flags |= CfgUpdateFlags.AnyChange;
+
RedrawAll();
}
@@ -364,5 +396,22 @@ namespace TBF
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
}
}
+
+ private void ComponentsManagerDlg_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ SaveUISettings();
+
+ if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0)
+ {
+ DialogResult dr = MessageBox.Show(Strings.Do_you_want_to_save_changes,
+ Strings.Warning,
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Question);
+ if (dr == DialogResult.Yes)
+ {
+ SaveDBChanges(session);
+ }
+ }
+ }
}
}
diff --git a/TestBenchFramework/ComponentsManagerDlg.resx b/TestBenchFramework/ComponentsManagerDlg.resx
index 982aa26ca..dddcf84b2 100644
--- a/TestBenchFramework/ComponentsManagerDlg.resx
+++ b/TestBenchFramework/ComponentsManagerDlg.resx
@@ -145,7 +145,7 @@
listViewEx
- TBF.UiControls.ListViewEx, TBF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+ Results.Forms.ListViewEx, Results, Version=2.12.394.0, Culture=neutral, PublicKeyToken=null
splitContainer.Panel1
@@ -178,7 +178,7 @@
sharedButtons
- TBF.UiControls.SharedButtons, TBF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+ TBF.UiControls.SharedButtons, TBF, Version=2.12.395.1, Culture=neutral, PublicKeyToken=null
splitContainer.Panel2
diff --git a/TestBenchFramework/Properties/AssemblyInfo.cs b/TestBenchFramework/Properties/AssemblyInfo.cs
index f887d22bc..af60f7c7f 100644
--- a/TestBenchFramework/Properties/AssemblyInfo.cs
+++ b/TestBenchFramework/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
-[assembly: AssemblyVersion("2.12.395.1")]
-[assembly: AssemblyFileVersion("2.12.395.1")]
+[assembly: AssemblyVersion("2.12.396.1")]
+[assembly: AssemblyFileVersion("2.12.396.1")]
diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs
index f04a2e10e..d2a55058c 100644
--- a/TestBenchFramework/Resources/Strings.Designer.cs
+++ b/TestBenchFramework/Resources/Strings.Designer.cs
@@ -1032,6 +1032,15 @@ namespace TBF.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Do you want to save changes?.
+ ///
+ internal static string Do_you_want_to_save_changes {
+ get {
+ return ResourceManager.GetString("Do_you_want_to_save_changes", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Do you want to save the procedure?.
///
diff --git a/TestBenchFramework/Resources/Strings.cs.resx b/TestBenchFramework/Resources/Strings.cs.resx
index 837b16002..99a05571b 100644
--- a/TestBenchFramework/Resources/Strings.cs.resx
+++ b/TestBenchFramework/Resources/Strings.cs.resx
@@ -1281,4 +1281,7 @@
Vytisknout
+
+ Chcete uložit změny?
+
\ No newline at end of file
diff --git a/TestBenchFramework/Resources/Strings.de.resx b/TestBenchFramework/Resources/Strings.de.resx
index 6ee54fbc1..38591f049 100644
--- a/TestBenchFramework/Resources/Strings.de.resx
+++ b/TestBenchFramework/Resources/Strings.de.resx
@@ -1371,4 +1371,7 @@
Pumpe starten
+
+ Wollen sie die Änderungen speichern?
+
\ No newline at end of file
diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx
index f0ce8145e..8f4a994f8 100644
--- a/TestBenchFramework/Resources/Strings.resx
+++ b/TestBenchFramework/Resources/Strings.resx
@@ -1591,4 +1591,7 @@
Show
+
+ Do you want to save changes?
+
\ No newline at end of file