diff --git a/TestBenchFramework/Forms/TabNameDlg.cs b/TestBenchFramework/Forms/TabNameDlg.cs
index 7127ff037..925fc118c 100644
--- a/TestBenchFramework/Forms/TabNameDlg.cs
+++ b/TestBenchFramework/Forms/TabNameDlg.cs
@@ -22,6 +22,22 @@ namespace TBF.Forms
IsVirtualBenchSeq = false;
}
+ public TabNameDlg(bool nameOnly)
+ {
+ InitializeComponent();
+
+ TabNameLabel = string.Empty;
+ TabName = string.Empty;
+ IsVirtualBenchSeq = false;
+
+ if (nameOnly == true)
+ {
+ radioButton1.Visible = false;
+ radioButton2.Visible = false;
+ Height -= 50;
+ }
+ }
+
private void TabNameDlg_Load(object sender, EventArgs e)
{
Text = TabNameLabel;
diff --git a/TestBenchFramework/MainWnd.cs b/TestBenchFramework/MainWnd.cs
index dd9753279..51287db69 100644
--- a/TestBenchFramework/MainWnd.cs
+++ b/TestBenchFramework/MainWnd.cs
@@ -360,7 +360,7 @@ namespace TBF
private void benchComponentsTSMItem_Click(object s, EventArgs e) { new ComponentsManagerDlg().ShowDialog(); }
private void benchPathsTSMItem_Click(object s, EventArgs e) { new PathsDlg().ShowDialog(); }
- private void benchTransitionsTSMItem_Click(object s, EventArgs e) { new TransitionsDlg().ShowDialog(); }
+ private void benchTransitionsTSMItem_Click(object s, EventArgs e) { Cursor = Cursors.WaitCursor; new TransitionsDlg().ShowDialog(); Cursor = Cursors.Default; }
private void benchMetrologyTSMItem_Click(object s, EventArgs e) { new MetrologyDlg().ShowDialog(); }
private void proceduresTSMItem_Click(object s, EventArgs e) { new ProceduresDlg().ShowDialog(); }
private void localSettingsTSMItem_Click(object s, EventArgs e) { new PreferencesDlg().ShowDialog(); }
diff --git a/TestBenchFramework/Resources/Strings.Designer.cs b/TestBenchFramework/Resources/Strings.Designer.cs
index ecb66501d..986363575 100644
--- a/TestBenchFramework/Resources/Strings.Designer.cs
+++ b/TestBenchFramework/Resources/Strings.Designer.cs
@@ -987,6 +987,15 @@ namespace TBF.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Do you really want to delete sequence '{0}' ?.
+ ///
+ internal static string Do_you_really_want_to_delete_sequence_0 {
+ get {
+ return ResourceManager.GetString("Do_you_really_want_to_delete_sequence_0", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Do you want to copy this value to all cells below this cell?.
///
diff --git a/TestBenchFramework/Resources/Strings.resx b/TestBenchFramework/Resources/Strings.resx
index 96a52c9d7..05b98b196 100644
--- a/TestBenchFramework/Resources/Strings.resx
+++ b/TestBenchFramework/Resources/Strings.resx
@@ -1591,4 +1591,7 @@
Evaluate volume
+
+ Do you really want to delete sequence '{0}' ?
+
\ No newline at end of file
diff --git a/TestBenchFramework/TransitionsDlg.cs b/TestBenchFramework/TransitionsDlg.cs
index 8a15216e2..447b53162 100644
--- a/TestBenchFramework/TransitionsDlg.cs
+++ b/TestBenchFramework/TransitionsDlg.cs
@@ -33,12 +33,14 @@ namespace TBF
/// Set by the constructor or updated by the parent after creation and before loading.
///
public IList TransitionSequences;
+ public IList RemovedTransitionSequences;
///
/// Virtual bench sequences to be updated by this dialog.
/// Set by the constructor or updated by the parent after creation and before loading.
///
public IList VirtualBenchSequences;
+ public IList RemovedVirtualBenchSequences;
/// Auxiliary public lists used also by user controls in tab pages
@@ -75,27 +77,8 @@ namespace TBF
seqStepsCtrls = new List();
- TransitionSequences = new List();
- VirtualBenchSequences = new List();
- }
-
- void Localize()
- {
- Text = Strings.Transitions;
- }
-
- private void TransitionsDlg_Load(object sender, EventArgs e)
- {
- Localize();
-
- TBF.LocalSettings ls = Program.LocalSettings;
- Width = (ls.TransitionsDlgWidth > 0) ? ls.TransitionsDlgWidth : 1050;
- Height = (ls.TransitionsDlgHeight > 0) ? ls.TransitionsDlgHeight : 360;
- Left = (ls.TransitionsDlgLeft != 0) ? ls.TransitionsDlgLeft : 150;
- Top = (ls.TransitionsDlgTop != 0) ? ls.TransitionsDlgTop : 150;
-
/// Open the database
- Session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config);
+ Session = Config.FluentCommon.CreateSession(Config.Entities.DBKind.Config);
/// Prepare a list of components and a list of all valves in the test bench
TbfComponents = BenchControl.TbfComponents.LoadComponentsFromDB(Session);
@@ -104,69 +87,66 @@ namespace TBF
foreach (var cmpnt in TbfComponents)
{
if ((cmpnt is IRegulValve) && !(cmpnt is BenchControl.Elde.RegulValveTandem.RegulValveTandem))
- {
- RegulValves.Add(cmpnt as IRegulValve);
- }
+ {
+ RegulValves.Add(cmpnt as IRegulValve);
+ }
}
/// Load the sequences
- TransitionSequences = Session.CreateQuery("FROM TransitionSequence ORDER BY ItemNr")
- .List();
-
- VirtualBenchSequences = Session.CreateQuery("FROM VirtualBenchSequence ORDER BY ItemNr")
- .List();
-
- /// Create a tab with sequence steps for each sequence ordered by ItemNr.
/// Note: Each sequence (in both sequences together) has a unique ItemNr (0 .. N-1)
- for (int i = 0; i < TransitionSequences.Count + VirtualBenchSequences.Count; i++)
- {
- bool skip = false;
- foreach (var transSeq in TransitionSequences)
- {
- if (transSeq.ItemNr == i)
- {
- AddTransitionSeqTab(transSeq);
- skip = true;
- continue;
- }
- }
- if (skip) continue;
- foreach (var vBenchSeq in VirtualBenchSequences)
- {
- if (vBenchSeq.ItemNr == i)
- {
- AddVirtualBenchSeqTab(vBenchSeq);
- continue;
- }
- }
- }
+ TransitionSequences = Session.QueryOver().OrderBy(x => x.ItemNr).Asc.List();
+ VirtualBenchSequences = Session.QueryOver().OrderBy(x => x.ItemNr).Asc.List();
+
+ RemovedTransitionSequences = new List();
+ RemovedVirtualBenchSequences = new List();
+
+ /// Create a tab with sequence steps for each sequence ordered by ItemNr.
+ foreach (var transSeq in TransitionSequences) AddTransitionSeqTab(transSeq);
+ foreach (var vBenchSeq in VirtualBenchSequences) AddVirtualBenchSeqTab(vBenchSeq);
+ }
+
+ void AddTransitionSeqTab(TransitionSequence sequence)
+ {
+ TabPage nwTab = new TabPage(sequence.Name);
+ nwTab.Tag = sequence;
+ TransitionStepsCtrl newCtrl = new TransitionStepsCtrl();
+ seqStepsCtrls.Add(newCtrl);
+ nwTab.Controls.Add(newCtrl);
+ tabControl.TabPages.Add(nwTab);
+ newCtrl.Initialize(sequence, this, tabControl.TabPages[tabControl.TabPages.Count - 1]);
+ newCtrl.SelectedIndexChanged += new System.EventHandler(SelectedIndexChanged);
+ }
+
+ void AddVirtualBenchSeqTab(VirtualBenchSequence sequence)
+ {
+ TabPage nwTab = new TabPage(sequence.Name);
+ nwTab.Tag = sequence;
+ VirtualBenchStepsCtrl newCtrl = new VirtualBenchStepsCtrl();
+ seqStepsCtrls.Add(newCtrl);
+ nwTab.Controls.Add(newCtrl);
+ tabControl.TabPages.Add(nwTab);
+ newCtrl.Initialize(sequence, this, tabControl.TabPages[tabControl.TabPages.Count - 1]);
+ newCtrl.SelectedIndexChanged += new System.EventHandler(SelectedIndexChanged);
+ }
+
+ private void TransitionsDlg_Load(object sender, EventArgs e)
+ {
+ Localize();
+
+ TBF.LocalSettings ls = Program.LocalSettings;
+ Width = (ls.TransitionsDlgWidth > 0) ? ls.TransitionsDlgWidth : 1050;
+ Height = (ls.TransitionsDlgHeight > 0) ? ls.TransitionsDlgHeight : 360;
+ Left = (ls.TransitionsDlgLeft != 0) ? ls.TransitionsDlgLeft : 150;
+ Top = (ls.TransitionsDlgTop != 0) ? ls.TransitionsDlgTop : 150;
/// Now refresh the content of the dialog
RefreshAllTabs();
}
- void AddTransitionSeqTab(TransitionSequence sequence)
- {
- TabPage nwTab = new TabPage(sequence.Name);
- TransitionStepsCtrl newCtrl = new TransitionStepsCtrl();
- seqStepsCtrls.Add(newCtrl);
- nwTab.Controls.Add(newCtrl);
- this.tabControl.TabPages.Add(nwTab);
- newCtrl.Initialize(sequence, this, this.tabControl.TabPages[this.tabControl.TabPages.Count - 1]);
- newCtrl.SelectedIndexChanged += new System.EventHandler(this.SelectedIndexChanged);
-
- }
-
- void AddVirtualBenchSeqTab(VirtualBenchSequence sequence)
+ void Localize()
{
- TabPage nwTab = new TabPage(sequence.Name);
- VirtualBenchStepsCtrl newCtrl = new VirtualBenchStepsCtrl();
- seqStepsCtrls.Add(newCtrl);
- nwTab.Controls.Add(newCtrl);
- this.tabControl.TabPages.Add(nwTab);
- newCtrl.Initialize(sequence, this, this.tabControl.TabPages[this.tabControl.TabPages.Count - 1]);
- newCtrl.SelectedIndexChanged += new System.EventHandler(this.SelectedIndexChanged);
- }
+ Text = Strings.Transitions;
+ }
void RefreshAllTabs()
{
@@ -229,10 +209,66 @@ namespace TBF
private void renameTabButton_Click(object sender, EventArgs e)
{
+ TabPage tabPage = tabControl.SelectedTab;
+ TransitionSequence transitionSeq = tabPage.Tag as TransitionSequence;
+ VirtualBenchSequence virtualBenchSeq = tabPage.Tag as VirtualBenchSequence;
+
+ Forms.TabNameDlg dlg = new Forms.TabNameDlg(true);
+ dlg.TabNameLabel = Strings.New_transition_name;
+
+ if (dlg.ShowDialog() == DialogResult.OK)
+ {
+ bool nameUsed = false;
+ foreach (var seq in TransitionSequences) if (seq != transitionSeq && seq.Name == dlg.TabName) nameUsed = true;
+ foreach (var seq in VirtualBenchSequences) if (seq != virtualBenchSeq && seq.Name == dlg.TabName) nameUsed = true;
+
+ if (nameUsed)
+ {
+ MessageBox.Show(Strings.Please_choose_another_transition_sequence_name,
+ Strings.Warning,
+ MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
+ }
+ else
+ {
+ if (transitionSeq != null)
+ {
+ transitionSeq.Name = dlg.TabName;
+ tabPage.Text = dlg.TabName;
+ }
+ else if (virtualBenchSeq != null)
+ {
+ virtualBenchSeq.Name = dlg.TabName;
+ tabPage.Text = dlg.TabName;
+ }
+ }
+ }
}
private void removeTabButton_Click(object sender, EventArgs e)
{
+ TabPage tabPage = tabControl.SelectedTab;
+ TransitionSequence transitionSeq = tabPage.Tag as TransitionSequence;
+ VirtualBenchSequence virtualBenchSeq = tabPage.Tag as VirtualBenchSequence;
+
+ if (DialogResult.Yes == MessageBox.Show(string.Format(Strings.Do_you_really_want_to_delete_sequence_0, tabPage.Text),
+ Strings.Warning,
+ MessageBoxButtons.YesNo,
+ MessageBoxIcon.Question))
+ {
+ if (transitionSeq != null)
+ {
+ RemovedTransitionSequences.Add(transitionSeq);
+ TransitionSequences.Remove(transitionSeq);
+ tabControl.TabPages.Remove(tabPage);
+ }
+ else if (virtualBenchSeq != null)
+ {
+ RemovedVirtualBenchSequences.Add(virtualBenchSeq);
+ VirtualBenchSequences.Remove(virtualBenchSeq);
+ tabControl.TabPages.Remove(tabPage);
+ }
+ }
}
private void okButton_Click(object sender, EventArgs e)
@@ -243,10 +279,29 @@ namespace TBF
{
try
{
- foreach (var transSeq in TransitionSequences)
- Session.SaveOrUpdate(transSeq);
- foreach (var vBnchSeq in VirtualBenchSequences)
- Session.SaveOrUpdate(vBnchSeq);
+ foreach (var transSeq in RemovedTransitionSequences)
+ {
+ foreach (var step in transSeq.TransitionSteps) Session.Delete(step);
+ Session.Delete(transSeq);
+ }
+ foreach (var vBnchSeq in RemovedVirtualBenchSequences)
+ {
+ foreach (var step in vBnchSeq.VirtualBenchSteps) Session.Delete(step);
+ Session.Delete(vBnchSeq);
+ }
+
+ int itemNr = 0;
+ foreach (var transSeq in TransitionSequences)
+ {
+ transSeq.ItemNr = itemNr++;
+ Session.SaveOrUpdate(transSeq);
+ }
+ itemNr = 0;
+ foreach (var vBnchSeq in VirtualBenchSequences)
+ {
+ vBnchSeq.ItemNr = itemNr++;
+ Session.SaveOrUpdate(vBnchSeq);
+ }
transaction.Commit();
}