First unfinished version with VirtualBenchSequences, requires DB upgrade
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace TBF.Entities
|
||||||
|
{
|
||||||
|
public class VirtualBenchSequence : IHasItemNr
|
||||||
|
{
|
||||||
|
public virtual int Id { get; protected set; }
|
||||||
|
public virtual int ItemNr { get; set; }
|
||||||
|
public virtual string Name { get; set; }
|
||||||
|
public virtual string Description { get; set; } /// Short description
|
||||||
|
public virtual IList<VirtualBenchStep> VirtualBenchSteps { get; set; }
|
||||||
|
|
||||||
|
public VirtualBenchSequence()
|
||||||
|
{
|
||||||
|
VirtualBenchSteps = new List<VirtualBenchStep>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VirtualBenchSequence(string name, int itemNr)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
ItemNr = itemNr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual VirtualBenchSequence Clone()
|
||||||
|
{
|
||||||
|
VirtualBenchSequence result = new VirtualBenchSequence();
|
||||||
|
result.Name = Name;
|
||||||
|
result.Description = Description;
|
||||||
|
foreach (var step in VirtualBenchSteps) { result.VirtualBenchSteps.Add(step.Clone()); }
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace TBF.Entities
|
||||||
|
{
|
||||||
|
public class VirtualBenchStep : IHasItemNr
|
||||||
|
{
|
||||||
|
public virtual int Id { get; protected set; }
|
||||||
|
public virtual int ItemNr { get; set; } /// Order of the preparation step
|
||||||
|
public virtual int Duration { get; set; } /// Duration in seconds
|
||||||
|
///
|
||||||
|
|
||||||
|
public virtual VirtualBenchSequence VirtualBenchSequence { get; set; }
|
||||||
|
|
||||||
|
/// ------------- Additional stuff not mapped into the database -------------
|
||||||
|
|
||||||
|
public VirtualBenchStep()
|
||||||
|
{
|
||||||
|
Duration = 5; /// sec.
|
||||||
|
}
|
||||||
|
|
||||||
|
public VirtualBenchStep(int itemNr, VirtualBenchSequence sequence)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
ItemNr = itemNr;
|
||||||
|
VirtualBenchSequence = sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual VirtualBenchStep Clone()
|
||||||
|
{
|
||||||
|
VirtualBenchStep result = new VirtualBenchStep(ItemNr, VirtualBenchSequence);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
-1
@@ -30,6 +30,8 @@
|
|||||||
{
|
{
|
||||||
this.tabNameTextBox = new System.Windows.Forms.TextBox();
|
this.tabNameTextBox = new System.Windows.Forms.TextBox();
|
||||||
this.okButton = new System.Windows.Forms.Button();
|
this.okButton = new System.Windows.Forms.Button();
|
||||||
|
this.radioButton1 = new System.Windows.Forms.RadioButton();
|
||||||
|
this.radioButton2 = new System.Windows.Forms.RadioButton();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// tabNameTextBox
|
// tabNameTextBox
|
||||||
@@ -49,12 +51,36 @@
|
|||||||
this.okButton.UseVisualStyleBackColor = true;
|
this.okButton.UseVisualStyleBackColor = true;
|
||||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||||
//
|
//
|
||||||
|
// radioButton1
|
||||||
|
//
|
||||||
|
this.radioButton1.AutoSize = true;
|
||||||
|
this.radioButton1.Checked = true;
|
||||||
|
this.radioButton1.Location = new System.Drawing.Point(37, 64);
|
||||||
|
this.radioButton1.Name = "radioButton1";
|
||||||
|
this.radioButton1.Size = new System.Drawing.Size(121, 17);
|
||||||
|
this.radioButton1.TabIndex = 3;
|
||||||
|
this.radioButton1.TabStop = true;
|
||||||
|
this.radioButton1.Text = "Transition sequence";
|
||||||
|
this.radioButton1.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// radioButton2
|
||||||
|
//
|
||||||
|
this.radioButton2.AutoSize = true;
|
||||||
|
this.radioButton2.Location = new System.Drawing.Point(37, 87);
|
||||||
|
this.radioButton2.Name = "radioButton2";
|
||||||
|
this.radioButton2.Size = new System.Drawing.Size(137, 17);
|
||||||
|
this.radioButton2.TabIndex = 4;
|
||||||
|
this.radioButton2.Text = "Virtual bench sequence";
|
||||||
|
this.radioButton2.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// TabNameDlg
|
// TabNameDlg
|
||||||
//
|
//
|
||||||
this.AcceptButton = this.okButton;
|
this.AcceptButton = this.okButton;
|
||||||
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.ClientSize = new System.Drawing.Size(316, 69);
|
this.ClientSize = new System.Drawing.Size(316, 117);
|
||||||
|
this.Controls.Add(this.radioButton2);
|
||||||
|
this.Controls.Add(this.radioButton1);
|
||||||
this.Controls.Add(this.okButton);
|
this.Controls.Add(this.okButton);
|
||||||
this.Controls.Add(this.tabNameTextBox);
|
this.Controls.Add(this.tabNameTextBox);
|
||||||
this.Name = "TabNameDlg";
|
this.Name = "TabNameDlg";
|
||||||
@@ -69,5 +95,7 @@
|
|||||||
|
|
||||||
private System.Windows.Forms.TextBox tabNameTextBox;
|
private System.Windows.Forms.TextBox tabNameTextBox;
|
||||||
private System.Windows.Forms.Button okButton;
|
private System.Windows.Forms.Button okButton;
|
||||||
|
private System.Windows.Forms.RadioButton radioButton1;
|
||||||
|
private System.Windows.Forms.RadioButton radioButton2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ namespace TBF.Forms
|
|||||||
{
|
{
|
||||||
public string TabNameLabel;
|
public string TabNameLabel;
|
||||||
public string TabName;
|
public string TabName;
|
||||||
|
public bool IsVirtualBenchSeq;
|
||||||
|
|
||||||
public TabNameDlg()
|
public TabNameDlg()
|
||||||
{
|
{
|
||||||
@@ -18,12 +19,14 @@ namespace TBF.Forms
|
|||||||
{
|
{
|
||||||
Text = TabNameLabel;
|
Text = TabNameLabel;
|
||||||
tabNameTextBox.Text = TabName;
|
tabNameTextBox.Text = TabName;
|
||||||
|
IsVirtualBenchSeq = false;
|
||||||
okButton.Text = Strings.OkBtnText;
|
okButton.Text = Strings.OkBtnText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void okButton_Click(object sender, EventArgs e)
|
private void okButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
TabName = tabNameTextBox.Text;
|
TabName = tabNameTextBox.Text;
|
||||||
|
IsVirtualBenchSeq = radioButton2.Checked;
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using FluentNHibernate.Mapping;
|
||||||
|
using TBF.Entities;
|
||||||
|
|
||||||
|
namespace TBF.Mappings
|
||||||
|
{
|
||||||
|
class VirtualBenchSequenceMap : ClassMap<VirtualBenchSequence>
|
||||||
|
{
|
||||||
|
public VirtualBenchSequenceMap()
|
||||||
|
{
|
||||||
|
Id(x => x.Id);
|
||||||
|
Map(x => x.ItemNr);
|
||||||
|
Map(x => x.Name);
|
||||||
|
Map(x => x.Description);
|
||||||
|
HasMany(x => x.VirtualBenchSteps)
|
||||||
|
.OrderBy("ItemNr")
|
||||||
|
.Cascade.All();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using FluentNHibernate.Mapping;
|
||||||
|
using TBF.Entities;
|
||||||
|
|
||||||
|
namespace TBF.Mappings
|
||||||
|
{
|
||||||
|
class VirtualBenchStepMap : ClassMap<VirtualBenchStep>
|
||||||
|
{
|
||||||
|
public VirtualBenchStepMap()
|
||||||
|
{
|
||||||
|
Id(x => x.Id);
|
||||||
|
Map(x => x.ItemNr);
|
||||||
|
Map(x => x.Duration);
|
||||||
|
|
||||||
|
References(x => x.VirtualBenchSequence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -502,6 +502,8 @@
|
|||||||
<Compile Include="Entities\IHasValves.cs" />
|
<Compile Include="Entities\IHasValves.cs" />
|
||||||
<Compile Include="Entities\TransitionSequence.cs" />
|
<Compile Include="Entities\TransitionSequence.cs" />
|
||||||
<Compile Include="Entities\TransitionStep.cs" />
|
<Compile Include="Entities\TransitionStep.cs" />
|
||||||
|
<Compile Include="Entities\VirtualBenchSequence.cs" />
|
||||||
|
<Compile Include="Entities\VirtualBenchStep.cs" />
|
||||||
<Compile Include="Forms\ClosingProgram.cs">
|
<Compile Include="Forms\ClosingProgram.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -528,6 +530,8 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Mappings\TransitionSequenceMap.cs" />
|
<Compile Include="Mappings\TransitionSequenceMap.cs" />
|
||||||
<Compile Include="Mappings\TransitionStepMap.cs" />
|
<Compile Include="Mappings\TransitionStepMap.cs" />
|
||||||
|
<Compile Include="Mappings\VirtualBenchSequenceMap.cs" />
|
||||||
|
<Compile Include="Mappings\VirtualBenchStepMap.cs" />
|
||||||
<Compile Include="Screens\PicturesTabPageCtrl.cs">
|
<Compile Include="Screens\PicturesTabPageCtrl.cs">
|
||||||
<SubType>UserControl</SubType>
|
<SubType>UserControl</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -931,6 +935,9 @@
|
|||||||
<Compile Include="UiControls\TransitionStepsCtrl.cs">
|
<Compile Include="UiControls\TransitionStepsCtrl.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="UiControls\VirtualBenchStepsCtrl.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Utils.cs" />
|
<Compile Include="Utils.cs" />
|
||||||
<EmbeddedResource Include="BenchControl\BenchId\ComponentCfgCtrl.resx">
|
<EmbeddedResource Include="BenchControl\BenchId\ComponentCfgCtrl.resx">
|
||||||
<DependentUpon>ComponentCfgCtrl.cs</DependentUpon>
|
<DependentUpon>ComponentCfgCtrl.cs</DependentUpon>
|
||||||
|
|||||||
@@ -27,15 +27,16 @@ namespace TBF
|
|||||||
public ISession Session;
|
public ISession Session;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Procedure to be updated by this dialog.
|
/// Transition sequences to be updated by this dialog.
|
||||||
/// Set by the constructor or updated by the parent after creation and before loading.
|
/// Set by the constructor or updated by the parent after creation and before loading.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<Entities.TransitionSequence> LoadedSequences;
|
public IList<Entities.TransitionSequence> TransitionSequences;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of tests to be deleted after closing this dialog
|
/// Virtual bench sequences to be updated by this dialog.
|
||||||
|
/// Set by the constructor or updated by the parent after creation and before loading.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<Entities.TransitionStep> ToBeDeletedSteps;
|
public IList<Entities.VirtualBenchSequence> VirtualBenchSequences;
|
||||||
|
|
||||||
|
|
||||||
/// Auxiliary public lists used also by user controls in tab pages
|
/// Auxiliary public lists used also by user controls in tab pages
|
||||||
@@ -44,7 +45,8 @@ namespace TBF
|
|||||||
public IList<IRegulValve> RegulValves;
|
public IList<IRegulValve> RegulValves;
|
||||||
|
|
||||||
|
|
||||||
IList<TransitionStepsCtrl> transStepsCtrls;
|
IList<TransitionStepsCtrl> transitionStepsCtrls;
|
||||||
|
IList<VirtualBenchStepsCtrl> virtualBenchStepsCtrls;
|
||||||
|
|
||||||
bool unlocked;
|
bool unlocked;
|
||||||
|
|
||||||
@@ -72,8 +74,11 @@ namespace TBF
|
|||||||
sharedButtons.RenameTabClicked += renameTabButton_Click;
|
sharedButtons.RenameTabClicked += renameTabButton_Click;
|
||||||
sharedButtons.RemoveTabClicked += removeTabButton_Click;
|
sharedButtons.RemoveTabClicked += removeTabButton_Click;
|
||||||
|
|
||||||
transStepsCtrls = new List<TransitionStepsCtrl>();
|
transitionStepsCtrls = new List<TransitionStepsCtrl>();
|
||||||
ToBeDeletedSteps = new List<Entities.TransitionStep>();
|
virtualBenchStepsCtrls = new List<VirtualBenchStepsCtrl>();
|
||||||
|
|
||||||
|
TransitionSequences = new List<TransitionSequence>();
|
||||||
|
VirtualBenchSequences = new List<VirtualBenchSequence>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Localize()
|
void Localize()
|
||||||
@@ -89,10 +94,8 @@ namespace TBF
|
|||||||
Left = (ls.TransitionsDlgLeft != 0) ? ls.TransitionsDlgLeft : 150;
|
Left = (ls.TransitionsDlgLeft != 0) ? ls.TransitionsDlgLeft : 150;
|
||||||
Top = (ls.TransitionsDlgTop != 0) ? ls.TransitionsDlgTop : 150;
|
Top = (ls.TransitionsDlgTop != 0) ? ls.TransitionsDlgTop : 150;
|
||||||
|
|
||||||
/// Load the procedures
|
/// Open the database
|
||||||
Session = FluentCommon.CreateSession(Database.Procedures);
|
Session = FluentCommon.CreateSession(Database.Procedures);
|
||||||
LoadedSequences = Session.CreateQuery("FROM TransitionSequence ORDER BY ItemNr")
|
|
||||||
.List<Entities.TransitionSequence>();
|
|
||||||
|
|
||||||
/// Prepare a list of components and a list of all valves in the test bench
|
/// Prepare a list of components and a list of all valves in the test bench
|
||||||
TbfComponents = BenchControl.TbfComponents.LoadComponentsFromDB(Session);
|
TbfComponents = BenchControl.TbfComponents.LoadComponentsFromDB(Session);
|
||||||
@@ -103,18 +106,36 @@ namespace TBF
|
|||||||
if (cmpnt is IRegulValve) RegulValves.Add(cmpnt as IRegulValve);
|
if (cmpnt is IRegulValve) RegulValves.Add(cmpnt as IRegulValve);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a tab with a TestParamsCtrl control for each used test method
|
/// Load the sequences
|
||||||
foreach (var sequence in LoadedSequences) AddTab(sequence);
|
TransitionSequences = Session.CreateQuery("FROM TransitionSequence ORDER BY ItemNr")
|
||||||
|
.List<Entities.TransitionSequence>();
|
||||||
|
|
||||||
|
VirtualBenchSequences = Session.CreateQuery("FROM VirtualBenchSequence ORDER BY ItemNr")
|
||||||
|
.List<Entities.VirtualBenchSequence>();
|
||||||
|
|
||||||
|
/// Create a tab with sequence steps for each sequence
|
||||||
|
foreach (var sequence in TransitionSequences) AddTransitionSeqTab(sequence);
|
||||||
|
foreach (var sequence in VirtualBenchSequences) AddVirtualBenchSeqTab(sequence);
|
||||||
|
|
||||||
/// Now refresh the content of the dialog
|
/// Now refresh the content of the dialog
|
||||||
RefreshAllTabs();
|
RefreshAllTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddTab(TransitionSequence sequence)
|
void AddTransitionSeqTab(TransitionSequence sequence)
|
||||||
{
|
{
|
||||||
TabPage nwTab = new TabPage(sequence.Name);
|
TabPage nwTab = new TabPage(sequence.Name);
|
||||||
TransitionStepsCtrl newCtrl = new TransitionStepsCtrl();
|
TransitionStepsCtrl newCtrl = new TransitionStepsCtrl();
|
||||||
transStepsCtrls.Add(newCtrl);
|
transitionStepsCtrls.Add(newCtrl);
|
||||||
|
nwTab.Controls.Add(newCtrl);
|
||||||
|
this.tabControl.TabPages.Add(nwTab);
|
||||||
|
newCtrl.Initialize(sequence, this, this.tabControl.TabPages[this.tabControl.TabPages.Count - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddVirtualBenchSeqTab(VirtualBenchSequence sequence)
|
||||||
|
{
|
||||||
|
TabPage nwTab = new TabPage(sequence.Name);
|
||||||
|
VirtualBenchStepsCtrl newCtrl = new VirtualBenchStepsCtrl();
|
||||||
|
virtualBenchStepsCtrls.Add(newCtrl);
|
||||||
nwTab.Controls.Add(newCtrl);
|
nwTab.Controls.Add(newCtrl);
|
||||||
this.tabControl.TabPages.Add(nwTab);
|
this.tabControl.TabPages.Add(nwTab);
|
||||||
newCtrl.Initialize(sequence, this, this.tabControl.TabPages[this.tabControl.TabPages.Count - 1]);
|
newCtrl.Initialize(sequence, this, this.tabControl.TabPages[this.tabControl.TabPages.Count - 1]);
|
||||||
@@ -122,26 +143,38 @@ namespace TBF
|
|||||||
|
|
||||||
void RefreshAllTabs()
|
void RefreshAllTabs()
|
||||||
{
|
{
|
||||||
foreach (var ctrl in transStepsCtrls) ctrl.Refresh();
|
foreach (var ctrl in transitionStepsCtrls) ctrl.Refresh();
|
||||||
|
foreach (var ctrl in virtualBenchStepsCtrls) ctrl.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Unlocked(object sender, EventArgs e)
|
private void Unlocked(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
unlocked = true;
|
unlocked = true;
|
||||||
foreach (var ctrl in transStepsCtrls) ctrl.Unlock();
|
foreach (var ctrl in transitionStepsCtrls) ctrl.Unlock();
|
||||||
|
foreach (var ctrl in virtualBenchStepsCtrls) ctrl.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void newTabButton_Click(object sender, EventArgs e)
|
private void newTabButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
int tabId = LoadedSequences.Count;
|
int tabId = TransitionSequences.Count + VirtualBenchSequences.Count;
|
||||||
Forms.TabNameDlg dlg = new Forms.TabNameDlg();
|
Forms.TabNameDlg dlg = new Forms.TabNameDlg();
|
||||||
dlg.TabNameLabel = Strings.New_transition_name;
|
dlg.TabNameLabel = Strings.New_transition_name;
|
||||||
dlg.TabName = "Tr1";
|
dlg.TabName = "Tr1";
|
||||||
dlg.ShowDialog();
|
dlg.ShowDialog();
|
||||||
|
if (dlg.IsVirtualBenchSeq)
|
||||||
|
{
|
||||||
|
VirtualBenchSequence sequence = new VirtualBenchSequence(dlg.TabName, tabId);
|
||||||
|
VirtualBenchSequences.Add(sequence);
|
||||||
|
AddVirtualBenchSeqTab(sequence);
|
||||||
|
virtualBenchStepsCtrls[tabId].Unlock();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
TransitionSequence sequence = new TransitionSequence(dlg.TabName, tabId);
|
TransitionSequence sequence = new TransitionSequence(dlg.TabName, tabId);
|
||||||
LoadedSequences.Add(sequence);
|
TransitionSequences.Add(sequence);
|
||||||
AddTab(sequence);
|
AddTransitionSeqTab(sequence);
|
||||||
transStepsCtrls[tabId].Unlock();
|
transitionStepsCtrls[tabId].Unlock();
|
||||||
|
}
|
||||||
tabControl.SelectTab(tabId);
|
tabControl.SelectTab(tabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,16 +188,15 @@ namespace TBF
|
|||||||
|
|
||||||
private void okButton_Click(object sender, EventArgs e)
|
private void okButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].OkBtnClicked();
|
if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].OkBtnClicked();
|
||||||
|
|
||||||
using (var transaction = Session.BeginTransaction())
|
using (var transaction = Session.BeginTransaction())
|
||||||
{
|
{
|
||||||
foreach (var sequence in LoadedSequences)
|
foreach (var transSeq in TransitionSequences) Session.SaveOrUpdate(transSeq);
|
||||||
{
|
foreach (var vBnchSeq in VirtualBenchSequences) Session.SaveOrUpdate(vBnchSeq);
|
||||||
Session.SaveOrUpdate(sequence);
|
|
||||||
}
|
|
||||||
try { transaction.Commit(); }
|
try { transaction.Commit(); }
|
||||||
catch { }
|
catch { log.Error("Update of sequences in the database failed"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
Program.LocalSettings.TransitionsDlgLeft = Location.X;
|
Program.LocalSettings.TransitionsDlgLeft = Location.X;
|
||||||
@@ -195,9 +227,9 @@ namespace TBF
|
|||||||
|
|
||||||
private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
|
private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (transStepsCtrls.Count > slctdTab)
|
if (transitionStepsCtrls.Count > slctdTab)
|
||||||
{
|
{
|
||||||
transStepsCtrls[slctdTab].OkBtnClicked();
|
transitionStepsCtrls[slctdTab].OkBtnClicked();
|
||||||
}
|
}
|
||||||
slctdTab = tabControl.SelectedIndex;
|
slctdTab = tabControl.SelectedIndex;
|
||||||
sharedButtons.SetEnabled(SharedButtons.Buttons.Add, true);
|
sharedButtons.SetEnabled(SharedButtons.Buttons.Add, true);
|
||||||
@@ -207,22 +239,22 @@ namespace TBF
|
|||||||
|
|
||||||
private void addButton_Click(object sender, EventArgs e)
|
private void addButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].AddOne();
|
if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].AddOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeButton_Click(object sender, EventArgs e)
|
private void removeButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].RemoveSelected();
|
if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].RemoveSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upButton_Click(object sender, EventArgs e)
|
private void upButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].MoveUpSelected();
|
if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].MoveUpSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downButton_Click(object sender, EventArgs e)
|
private void downButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (transStepsCtrls.Count > slctdTab) transStepsCtrls[slctdTab].MoveDownSelected();
|
if (transitionStepsCtrls.Count > slctdTab) transitionStepsCtrls[slctdTab].MoveDownSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateButtonStates(SharedButtons.SelectedItemPos selectedItemPos)
|
public void UpdateButtonStates(SharedButtons.SelectedItemPos selectedItemPos)
|
||||||
|
|||||||
@@ -0,0 +1,224 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using log4net;
|
||||||
|
using TBF.BenchControl;
|
||||||
|
using TBF.BenchControl.GenericDevices;
|
||||||
|
using TBF.Resources;
|
||||||
|
|
||||||
|
namespace TBF.UiControls
|
||||||
|
{
|
||||||
|
public partial class VirtualBenchStepsCtrl : BaseWithListViewEx<Entities.VirtualBenchStep>, ITabWithListViewEx
|
||||||
|
{
|
||||||
|
static readonly ILog log = LogManager.GetLogger(typeof(VirtualBenchStepsCtrl));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fixed ListViewEx columns
|
||||||
|
/// </summary>
|
||||||
|
enum Column
|
||||||
|
{
|
||||||
|
Duration,
|
||||||
|
FixedColumnsCount,
|
||||||
|
}
|
||||||
|
readonly int fixedCount = (int)Column.FixedColumnsCount;
|
||||||
|
|
||||||
|
Entities.VirtualBenchSequence sequence;
|
||||||
|
|
||||||
|
TransitionsDlg parent;
|
||||||
|
Control parentControl;
|
||||||
|
Control[] editors;
|
||||||
|
|
||||||
|
int fmPumpCount; /// Number of pumps with FM control
|
||||||
|
int regvCount; /// Number of regulating valves
|
||||||
|
int vCount; /// Number of valves
|
||||||
|
|
||||||
|
public VirtualBenchStepsCtrl()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize(Entities.VirtualBenchSequence sequence, TransitionsDlg parent, Control parentControl)
|
||||||
|
{
|
||||||
|
this.sequence = sequence;
|
||||||
|
this.parent = parent;
|
||||||
|
this.parentControl = parentControl;
|
||||||
|
Name = sequence.Name;
|
||||||
|
MyItems = sequence.VirtualBenchSteps;
|
||||||
|
|
||||||
|
SubItemClicked += new SubItemEventHandler(listViewEx_SubItemClicked);
|
||||||
|
SubItemEndEditing += new SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
||||||
|
|
||||||
|
vCount = 0;
|
||||||
|
fmPumpCount = 0;
|
||||||
|
regvCount = 0;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// ListViewEx columns
|
||||||
|
///
|
||||||
|
Columns.Add(Strings.Duration_s, 70 * parent.Dpi / PathsDlg.Dpi100pct);
|
||||||
|
//foreach (var vlv in parent.Valves)
|
||||||
|
//{
|
||||||
|
// if (vlv is BenchControl.GenericDevices.IPumpFM)
|
||||||
|
// {
|
||||||
|
// Columns.Add(vlv.Cfg.Name + " [%]", 45 * parent.Dpi / PathsDlg.Dpi100pct);
|
||||||
|
// fmPumpCount++;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//foreach (var rvlv in parent.RegulValves)
|
||||||
|
//{
|
||||||
|
// Columns.Add(rvlv.Cfg.Name + " [%]", 55 * parent.Dpi / PathsDlg.Dpi100pct);
|
||||||
|
//}
|
||||||
|
//foreach (var vlv in parent.Valves)
|
||||||
|
//{
|
||||||
|
// if (!(vlv is BenchControl.GenericDevices.IPumpFM))
|
||||||
|
// {
|
||||||
|
// Columns.Add(vlv.Cfg.Name, 40 * parent.Dpi / PathsDlg.Dpi100pct);
|
||||||
|
// vCount++;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Prepare valve combo-boxes
|
||||||
|
///
|
||||||
|
editors = new Control[fixedCount + vCount + fmPumpCount + regvCount];
|
||||||
|
|
||||||
|
editors[0] = new TextBox(); /// Duration
|
||||||
|
parent.Controls.Add(editors[0]);
|
||||||
|
|
||||||
|
//for (int i = fixedCount; i < fixedCount + fmPumpCount; i++)
|
||||||
|
//{
|
||||||
|
// ComboBox cb = new ComboBox();
|
||||||
|
// cb.Items.Add("---");
|
||||||
|
// cb.Items.Add(Strings.dflt);
|
||||||
|
// cb.Items.Add("0");
|
||||||
|
// cb.Items.Add("25");
|
||||||
|
// cb.Items.Add("50");
|
||||||
|
// cb.Items.Add("75");
|
||||||
|
// cb.Items.Add("100");
|
||||||
|
// editors[i] = cb;
|
||||||
|
// parent.Controls.Add(editors[i]);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//for (int i = fixedCount + fmPumpCount; i < fixedCount + fmPumpCount + regvCount; i++)
|
||||||
|
//{
|
||||||
|
// ComboBox cb = new ComboBox();
|
||||||
|
// cb.Items.Add("---");
|
||||||
|
// cb.Items.Add("0");
|
||||||
|
// cb.Items.Add("25");
|
||||||
|
// cb.Items.Add("50");
|
||||||
|
// cb.Items.Add("75");
|
||||||
|
// cb.Items.Add("100");
|
||||||
|
// editors[i] = cb;
|
||||||
|
// parent.Controls.Add(editors[i]);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//for (int i = fixedCount + fmPumpCount + regvCount; i < fixedCount + fmPumpCount + regvCount + vCount; i++)
|
||||||
|
//{
|
||||||
|
// ComboBox cb = new ComboBox();
|
||||||
|
// cb.Items.Add("---");
|
||||||
|
// cb.Items.Add(Strings.open);
|
||||||
|
// cb.Items.Add(Strings.close);
|
||||||
|
// editors[i] = cb;
|
||||||
|
// parent.Controls.Add(cb);
|
||||||
|
//}
|
||||||
|
|
||||||
|
base.RedrawAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void listViewEx_SubItemClicked(object sender, SubItemEventArgs e)
|
||||||
|
{
|
||||||
|
if (!Unlocked || e.SubItem >= editors.Length) return;
|
||||||
|
StartEditing(editors[e.SubItem], e.Item, e.SubItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void listViewEx_SubItemEndEditing(object sender, SubItemEndEditingEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.SubItem == (int)Column.Duration)
|
||||||
|
{
|
||||||
|
int duration;
|
||||||
|
if (!int.TryParse(e.DisplayText, out duration) || duration <= 0)
|
||||||
|
{
|
||||||
|
e.DisplayText = e.Item.Text;
|
||||||
|
e.Cancel = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else if ((e.SubItem >= fixedCount) && (e.SubItem < fixedCount + fmPumpCount))
|
||||||
|
//{
|
||||||
|
// float pct;
|
||||||
|
// if (!e.DisplayText.Equals("---") &&
|
||||||
|
// !e.DisplayText.Equals(Strings.dflt) &&
|
||||||
|
// !(Utils.TryParseUFloat(e.DisplayText, out pct) && (pct >= 0) && (pct <= 100.0f)))
|
||||||
|
// {
|
||||||
|
// e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||||
|
// e.Cancel = true;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else if ((e.SubItem >= fixedCount + fmPumpCount) && (e.SubItem < fixedCount + fmPumpCount + regvCount))
|
||||||
|
//{
|
||||||
|
// float pct;
|
||||||
|
// if (!e.DisplayText.Equals("---") &&
|
||||||
|
// !(Utils.TryParseUFloat(e.DisplayText, out pct) && (pct >= 0) && (pct <= 100.0f)))
|
||||||
|
// {
|
||||||
|
// e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||||
|
// e.Cancel = true;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else if ((e.SubItem >= fixedCount + fmPumpCount + regvCount) && (e.SubItem < fixedCount + fmPumpCount + regvCount + vCount))
|
||||||
|
//{
|
||||||
|
// if ((e.DisplayText != Strings.open) && (e.DisplayText != Strings.close) && (e.DisplayText != "---"))
|
||||||
|
// {
|
||||||
|
// e.DisplayText = e.Item.SubItems[e.SubItem].Text;
|
||||||
|
// e.Cancel = true;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawOne(object myItem)
|
||||||
|
{
|
||||||
|
Entities.VirtualBenchStep step = (Entities.VirtualBenchStep)myItem;
|
||||||
|
|
||||||
|
ListViewItem lvi = new ListViewItem(step.Duration.ToString());
|
||||||
|
|
||||||
|
/// TODO: All the rest
|
||||||
|
|
||||||
|
lvi.Tag = step;
|
||||||
|
|
||||||
|
Items.Add(lvi);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateOne(ListViewItem lvi, object myItem)
|
||||||
|
{
|
||||||
|
Entities.VirtualBenchStep step = (Entities.VirtualBenchStep)myItem;
|
||||||
|
|
||||||
|
/// Duration
|
||||||
|
try
|
||||||
|
{
|
||||||
|
step.Duration = int.Parse(lvi.Text);
|
||||||
|
if (step.Duration < 2) throw (new System.Exception());
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
lvi.Text = step.Duration.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Replace the following:
|
||||||
|
//step.PumpWithFMPcts = fmPumpsPcts;
|
||||||
|
//step.RegulValvesPct = regulValvesPct;
|
||||||
|
//step.ValvesOpen = valvesOpen;
|
||||||
|
//step.ValvesClose = valvesClose;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddOne()
|
||||||
|
{
|
||||||
|
base.AddOne(new Entities.VirtualBenchStep(MyItems.Count, sequence));
|
||||||
|
}
|
||||||
|
|
||||||
|
public new void RemoveSelected()
|
||||||
|
{
|
||||||
|
bool lastItemRemoved = base.RemoveSelected();
|
||||||
|
if (lastItemRemoved && parent != null)
|
||||||
|
{
|
||||||
|
parent.UpdateButtonStates(SharedButtons.SelectedItemPos.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user