2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
2017-02-28 21:04:07 +00:00
|
|
|
|
/// Copyright (c) 2013-2017 Sensus Metering Systems
|
2015-08-13 06:36:28 +00:00
|
|
|
|
/// Author: Milan Hanajík
|
2015-04-15 18:32:56 +00:00
|
|
|
|
///
|
|
|
|
|
|
using System;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-05-15 12:03:07 +00:00
|
|
|
|
using System.IO;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using log4net;
|
2018-08-30 06:04:19 +00:00
|
|
|
|
using NHibernate;
|
2015-12-04 16:17:20 +00:00
|
|
|
|
using Config.Entities;
|
2018-09-10 09:19:37 +00:00
|
|
|
|
using Results.Forms;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
using TBF.BenchControl;
|
|
|
|
|
|
using TBF.BenchControl.Generic;
|
|
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
using TBF.UiControls;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class ComponentsManagerDlg : Form, IParentOfListViewEx
|
|
|
|
|
|
{
|
|
|
|
|
|
static readonly ILog log = LogManager.GetLogger(typeof(ComponentsManagerDlg));
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// List of components (=component configuration instances)
|
|
|
|
|
|
/// </summary>
|
2015-12-04 16:17:20 +00:00
|
|
|
|
IList<Component> cmpntEntities;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2015-12-04 16:17:20 +00:00
|
|
|
|
IList<Component> toBeDeletedEntities;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2018-08-30 06:04:19 +00:00
|
|
|
|
ISession session;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
SelectComponentClassDlg selectComponentTypeDlg; /// Constructed once, the selection is kept between dialog usages
|
|
|
|
|
|
|
2015-01-02 22:42:01 +00:00
|
|
|
|
CfgUpdateFlags flags; /// Or-ed from particular Flags from ComponentParametersDlg
|
2016-11-30 13:16:51 +00:00
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// ListViewEx columns
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
enum Column
|
|
|
|
|
|
{
|
2018-09-10 09:19:37 +00:00
|
|
|
|
Number,
|
2014-07-28 07:54:35 +00:00
|
|
|
|
Name,
|
|
|
|
|
|
ClassName,
|
|
|
|
|
|
ParentName,
|
|
|
|
|
|
DebugMode,
|
|
|
|
|
|
Logging,
|
|
|
|
|
|
Parameters,
|
|
|
|
|
|
ColumnsCount,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-09-10 09:19:37 +00:00
|
|
|
|
SortOrder sortOrder = SortOrder.Ascending;
|
|
|
|
|
|
int sortColumn = -1; /// 0-based index of column to be used for sorting
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// Editors used by listViewEx
|
|
|
|
|
|
ComboBox debugCB;
|
|
|
|
|
|
ComboBox logCB;
|
|
|
|
|
|
|
|
|
|
|
|
bool unlocked;
|
|
|
|
|
|
|
|
|
|
|
|
public ComponentsManagerDlg()
|
|
|
|
|
|
{
|
2015-12-04 16:17:20 +00:00
|
|
|
|
toBeDeletedEntities = new List<Component>();
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
2015-01-02 22:42:01 +00:00
|
|
|
|
flags = CfgUpdateFlags.None;
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
selectComponentTypeDlg = new SelectComponentClassDlg();
|
|
|
|
|
|
|
|
|
|
|
|
/// SharedDlgButtons configuration
|
2018-09-24 12:15:04 +00:00
|
|
|
|
sharedButtons.RequiredGroupMembership = new Users.Grp.GID[] { Users.Grp.GID.Metrologists };
|
2017-12-08 09:34:02 +00:00
|
|
|
|
|
2017-12-20 08:14:43 +00:00
|
|
|
|
sharedButtons.OptionalButtons = SharedButtons.Buttons.Add |
|
|
|
|
|
|
SharedButtons.Buttons.Remove |
|
|
|
|
|
|
SharedButtons.Buttons.Up |
|
|
|
|
|
|
SharedButtons.Buttons.Down |
|
|
|
|
|
|
SharedButtons.Buttons.Edit |
|
|
|
|
|
|
SharedButtons.Buttons.Copy |
|
|
|
|
|
|
SharedButtons.Buttons.Export |
|
|
|
|
|
|
SharedButtons.Buttons.Import;
|
|
|
|
|
|
sharedButtons.Unlocked += Unlocked;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
sharedButtons.OKClicked += okButton_Click;
|
|
|
|
|
|
sharedButtons.CancelClicked += cancelButton_Click;
|
|
|
|
|
|
sharedButtons.AddClicked += addButton_Click;
|
|
|
|
|
|
sharedButtons.RemoveClicked += removeButton_Click;
|
2017-02-28 21:04:07 +00:00
|
|
|
|
sharedButtons.UpClicked += upButton_Click;
|
|
|
|
|
|
sharedButtons.DownClicked += downButton_Click;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
sharedButtons.EditClicked += editButton_Click;
|
2017-09-29 13:41:23 +00:00
|
|
|
|
sharedButtons.CopyClicked += copyButton_Click;
|
2017-12-20 08:14:43 +00:00
|
|
|
|
sharedButtons.ExportClicked += exportButton_Click;
|
|
|
|
|
|
sharedButtons.ImportClicked += importButton_Click;
|
2017-09-29 13:41:23 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
private void ComponentsManagerDlg_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2014-09-07 07:34:28 +00:00
|
|
|
|
TBF.LocalSettings ls = Program.LocalSettings;
|
|
|
|
|
|
Width = (ls.ComponentsDlgWidth > 0) ? ls.ComponentsDlgWidth : 850;
|
|
|
|
|
|
Height = (ls.ComponentsDlgHeight > 0) ? ls.ComponentsDlgHeight : 500;
|
|
|
|
|
|
Left = (ls.ComponentsDlgLeft != 0) ? ls.ComponentsDlgLeft : 200;
|
|
|
|
|
|
Top = (ls.ComponentsDlgTop != 0) ? ls.ComponentsDlgTop : 100;
|
|
|
|
|
|
|
|
|
|
|
|
Text = Strings.Test_Bench_Components_Configuration;
|
2018-09-13 10:49:31 +00:00
|
|
|
|
listViewEx.Columns.Add(Strings.Nr, (ls.ComponentsColumnCount > 0) ? ls.ComponentsColumnWidths[0] : 40);
|
|
|
|
|
|
listViewEx.Columns.Add(Strings.Name, (ls.ComponentsColumnCount > 1) ? ls.ComponentsColumnWidths[1] : 80);
|
|
|
|
|
|
listViewEx.Columns.Add(Strings.Type, (ls.ComponentsColumnCount > 2) ? ls.ComponentsColumnWidths[2] : 120);
|
|
|
|
|
|
listViewEx.Columns.Add(Strings.Parent, (ls.ComponentsColumnCount > 3) ? ls.ComponentsColumnWidths[3] : 55);
|
|
|
|
|
|
listViewEx.Columns.Add(Strings.Mode, (ls.ComponentsColumnCount > 4) ? ls.ComponentsColumnWidths[4] : 55);
|
|
|
|
|
|
listViewEx.Columns.Add(Strings.Logging, (ls.ComponentsColumnCount > 5) ? ls.ComponentsColumnWidths[5] : 55);
|
|
|
|
|
|
listViewEx.Columns.Add(Strings.Parameters, (ls.ComponentsColumnCount > 6) ? ls.ComponentsColumnWidths[6] : 600);
|
2018-09-10 09:19:37 +00:00
|
|
|
|
listViewEx.HeaderStyle = ColumnHeaderStyle.Clickable;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
debugCB = new ComboBox();
|
2016-11-16 21:13:48 +00:00
|
|
|
|
for (DebugMode level = 0; level < DebugMode.Count; level++) debugCB.Items.Add(level.ToDescription());
|
2014-07-28 07:54:35 +00:00
|
|
|
|
splitContainer.Panel1.Controls.Add(debugCB);
|
|
|
|
|
|
|
|
|
|
|
|
logCB = new ComboBox();
|
2016-11-16 21:13:48 +00:00
|
|
|
|
for (LogLevel level = 0; level < LogLevel.Count; level++) logCB.Items.Add(level.ToDescription());
|
2014-07-28 07:54:35 +00:00
|
|
|
|
splitContainer.Panel1.Controls.Add(logCB);
|
|
|
|
|
|
|
2016-08-19 08:43:48 +00:00
|
|
|
|
listViewEx.SubItemClicked += new Results.Forms.SubItemEventHandler(listViewEx_SubItemClicked);
|
|
|
|
|
|
listViewEx.SubItemEndEditing += new Results.Forms.SubItemEndEditingEventHandler(listViewEx_SubItemEndEditing);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
sharedButtons.DisableButtons(UiControls.SharedButtons.Buttons.Remove | UiControls.SharedButtons.Buttons.Edit);
|
|
|
|
|
|
|
2017-03-16 20:53:12 +00:00
|
|
|
|
session = Config.FluentCommon.CreateSession(Users.Entities.DBKind.Config);
|
2016-11-30 13:16:51 +00:00
|
|
|
|
cmpntEntities = session.QueryOver<Component>()
|
|
|
|
|
|
.OrderBy(x => x.ItemNr).Asc
|
|
|
|
|
|
.List<Component>();
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
RedrawAll();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-08-19 08:43:48 +00:00
|
|
|
|
void listViewEx_SubItemClicked(object sender, Results.Forms.SubItemEventArgs e)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (unlocked && e.SubItem == (int)Column.DebugMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
listViewEx.StartEditing(debugCB, e.Item, e.SubItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (unlocked && e.SubItem == (int)Column.Logging)
|
|
|
|
|
|
{
|
|
|
|
|
|
listViewEx.StartEditing(logCB, e.Item, e.SubItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-08-19 08:43:48 +00:00
|
|
|
|
void listViewEx_SubItemEndEditing(object sender, Results.Forms.SubItemEndEditingEventArgs e)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2015-12-04 16:17:20 +00:00
|
|
|
|
Component cmpnt = (Component)e.Item.Tag;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
if (e.SubItem == (int)Column.DebugMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (DebugMode level = 0; level < DebugMode.Count; level++)
|
|
|
|
|
|
{
|
2016-11-16 21:13:48 +00:00
|
|
|
|
if (debugCB.Text.Equals(level.ToDescription()))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
cmpnt.Mode = level;
|
2015-01-11 04:06:18 +00:00
|
|
|
|
flags |= CfgUpdateFlags.RestartRqrd;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
e.DisplayText = cmpnt.Mode.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (e.SubItem == (int)Column.Logging)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (LogLevel level = 0; level < LogLevel.Count; level++)
|
|
|
|
|
|
{
|
2016-11-16 21:13:48 +00:00
|
|
|
|
if (logCB.Text.Equals(level.ToDescription()))
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
cmpnt.Logging = level;
|
2015-01-11 04:06:18 +00:00
|
|
|
|
flags |= CfgUpdateFlags.RestartRqrd;
|
2015-01-07 07:00:32 +00:00
|
|
|
|
return;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
e.DisplayText = cmpnt.Logging.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Unlocked(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
unlocked = true;
|
2017-02-28 21:04:07 +00:00
|
|
|
|
|
|
|
|
|
|
if (listViewEx.SelectedItems.Count == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
int ix = listViewEx.SelectedIndices[0];
|
|
|
|
|
|
Focus();
|
|
|
|
|
|
listViewEx.Items[ix].Selected = true;
|
|
|
|
|
|
listViewEx.Items[ix].EnsureVisible();
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RedrawAll()
|
|
|
|
|
|
{
|
|
|
|
|
|
listViewEx.Items.Clear();
|
|
|
|
|
|
foreach (var cmpnt in cmpntEntities) DrawOne(cmpnt);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-12-04 16:17:20 +00:00
|
|
|
|
void DrawOne(Component cmpnt)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2018-09-10 09:19:37 +00:00
|
|
|
|
ListViewItem lvi = new ListViewItem(cmpnt.ItemNr.ToString());
|
2018-07-16 08:26:17 +00:00
|
|
|
|
lvi.Tag = cmpnt;
|
2018-09-10 09:19:37 +00:00
|
|
|
|
lvi.SubItems.Add(cmpnt.Name);
|
2018-07-16 08:26:17 +00:00
|
|
|
|
lvi.SubItems.Add(string.IsNullOrEmpty(cmpnt.ClassName) ? string.Empty : cmpnt.ClassName);
|
|
|
|
|
|
lvi.SubItems.Add(string.IsNullOrEmpty(cmpnt.ParentName) ? string.Empty : cmpnt.ParentName);
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2018-07-16 08:26:17 +00:00
|
|
|
|
IComponentCfg cmpCfg = TbfComponents.CmpntCfgFromCmpntEntity(cmpnt);
|
|
|
|
|
|
if (cmpCfg != null)
|
2017-03-18 15:46:03 +00:00
|
|
|
|
{
|
2018-07-16 08:26:17 +00:00
|
|
|
|
lvi.SubItems.Add(cmpCfg.DebugLevel.ToDescription());
|
2017-03-18 15:46:03 +00:00
|
|
|
|
lvi.SubItems.Add(cmpCfg.LogLevel.ToDescription());
|
2018-09-05 09:05:08 +00:00
|
|
|
|
lvi.SubItems.Add(cmpCfg.ToString(-1));
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-03-18 15:46:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
lvi.SubItems.Add("---");
|
|
|
|
|
|
lvi.SubItems.Add("---");
|
|
|
|
|
|
lvi.SubItems.Add("Not a component");
|
|
|
|
|
|
}
|
2018-07-16 08:26:17 +00:00
|
|
|
|
|
|
|
|
|
|
listViewEx.Items.Add(lvi);
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-11-30 13:16:51 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Save DB changes, return true when DB changes saved OK
|
|
|
|
|
|
///
|
2018-08-30 06:04:19 +00:00
|
|
|
|
bool SaveDBChanges(ISession session)
|
2016-11-30 13:16:51 +00:00
|
|
|
|
{
|
2018-08-30 06:04:19 +00:00
|
|
|
|
using (ITransaction transaction = session.BeginTransaction())
|
2016-11-30 13:16:51 +00:00
|
|
|
|
{
|
2018-08-30 06:04:19 +00:00
|
|
|
|
try
|
2016-11-30 13:16:51 +00:00
|
|
|
|
{
|
2018-08-30 06:04:19 +00:00
|
|
|
|
foreach (var cmpnt in toBeDeletedEntities) session.Delete(cmpnt);
|
|
|
|
|
|
|
|
|
|
|
|
int itemNr = 1;
|
|
|
|
|
|
foreach (var cmpnt in cmpntEntities)
|
|
|
|
|
|
{
|
|
|
|
|
|
cmpnt.ItemNr = itemNr++;
|
|
|
|
|
|
session.SaveOrUpdate(cmpnt);
|
|
|
|
|
|
}
|
2016-11-30 13:16:51 +00:00
|
|
|
|
|
2018-08-30 06:04:19 +00:00
|
|
|
|
transaction.Commit();
|
|
|
|
|
|
session.Flush();
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception exc)
|
2016-11-30 13:16:51 +00:00
|
|
|
|
{
|
2018-08-30 06:04:19 +00:00
|
|
|
|
transaction.Rollback();
|
|
|
|
|
|
log.ErrorFormat("Exception when saving components : {1}", exc.Message);
|
|
|
|
|
|
return false;
|
2016-11-30 13:16:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Save the dialog position and ListViewEx column widths
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
2014-07-28 07:54:35 +00:00
|
|
|
|
/// OK
|
2016-11-30 13:16:51 +00:00
|
|
|
|
///
|
|
|
|
|
|
private void okButton_Click(object sender, EventArgs e)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2015-01-02 22:42:01 +00:00
|
|
|
|
if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
2016-11-30 13:16:51 +00:00
|
|
|
|
SaveDBChanges(session);
|
2016-12-05 12:25:24 +00:00
|
|
|
|
flags = CfgUpdateFlags.None; /// Changes saved
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2016-11-30 13:16:51 +00:00
|
|
|
|
SaveUISettings();
|
2015-11-23 14:11:46 +00:00
|
|
|
|
|
2014-09-07 07:34:28 +00:00
|
|
|
|
DialogResult = DialogResult.OK;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
Close();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Cancel
|
|
|
|
|
|
private void cancelButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2016-11-30 13:16:51 +00:00
|
|
|
|
SaveUISettings();
|
2014-09-07 07:34:28 +00:00
|
|
|
|
|
2015-01-02 22:42:01 +00:00
|
|
|
|
if ((flags & CfgUpdateFlags.AnyChange) != 0 || (flags & CfgUpdateFlags.RestartRqrd) != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DialogResult dr = MessageBox.Show(Strings.Changes_will_be_lost_Do_you_want_to_proceed,
|
|
|
|
|
|
Strings.Warning,
|
|
|
|
|
|
MessageBoxButtons.YesNo,
|
|
|
|
|
|
MessageBoxIcon.Question);
|
|
|
|
|
|
if (dr != DialogResult.Yes) return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-12-05 12:25:24 +00:00
|
|
|
|
flags = CfgUpdateFlags.None; /// Abandoning changes confirmed
|
2016-11-30 13:16:51 +00:00
|
|
|
|
|
2014-09-07 07:34:28 +00:00
|
|
|
|
DialogResult = DialogResult.Cancel;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
Close();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Add a new component
|
|
|
|
|
|
private void addButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2017-05-15 12:03:07 +00:00
|
|
|
|
selectComponentTypeDlg.SelectedScriptName = null;
|
2016-11-30 13:16:51 +00:00
|
|
|
|
DialogResult dialogRslt = selectComponentTypeDlg.ShowDialog();
|
|
|
|
|
|
if (dialogRslt != DialogResult.OK) return;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
|
|
|
|
|
IComponentFactory factory = selectComponentTypeDlg.SlctdCmpntFactory;
|
2017-05-15 12:03:07 +00:00
|
|
|
|
IComponentCfg cfg = factory.DefaultConfig();
|
|
|
|
|
|
if (selectComponentTypeDlg.SelectedScriptName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
IComponentCfgCtrl cfgControl = cfg.GetControl();
|
|
|
|
|
|
cfgControl.Config = cfg;
|
|
|
|
|
|
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;
|
|
|
|
|
|
dialogRslt = cfgForm.ShowDialog();
|
|
|
|
|
|
if (dialogRslt != DialogResult.OK) return;
|
|
|
|
|
|
|
|
|
|
|
|
flags |= CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
AddOne(cfgForm.Config.CreateDbEntity());
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
using (TextReader reader = new StreamReader(selectComponentTypeDlg.SelectedScriptName))
|
|
|
|
|
|
{
|
|
|
|
|
|
int zeroBasedIdx = 0;
|
|
|
|
|
|
string line = reader.ReadLine();
|
|
|
|
|
|
while (line != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
line.Trim();
|
|
|
|
|
|
if (line.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] words = line.Split(new char[] { ' ', '\t' });
|
|
|
|
|
|
|
2017-05-16 11:06:48 +00:00
|
|
|
|
if (UpdateCfg(ref cfg, words, ref zeroBasedIdx))
|
2017-05-15 12:03:07 +00:00
|
|
|
|
{
|
2017-05-16 11:06:48 +00:00
|
|
|
|
flags |= CfgUpdateFlags.RestartRqrd;
|
2018-10-03 10:17:30 +00:00
|
|
|
|
cfg.ItemNr = (cmpntEntities.Count > 0) ? (cmpntEntities[cmpntEntities.Count - 1].ItemNr + 1) : 1;
|
2017-05-16 11:06:48 +00:00
|
|
|
|
AddOne(cfg.CreateDbEntity());
|
2017-05-15 12:03:07 +00:00
|
|
|
|
}
|
2017-05-16 11:06:48 +00:00
|
|
|
|
|
2017-05-15 12:03:07 +00:00
|
|
|
|
zeroBasedIdx++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
line = reader.ReadLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-12-04 16:17:20 +00:00
|
|
|
|
void AddOne(Component cmpnt)
|
2014-07-28 07:54:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
cmpntEntities.Add(cmpnt);
|
|
|
|
|
|
DrawOne(cmpnt);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Delete the component
|
|
|
|
|
|
private void removeButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (listViewEx.SelectedIndices.Count != 1) return;
|
|
|
|
|
|
int ix = listViewEx.SelectedIndices[0];
|
|
|
|
|
|
if (ix < 0) return;
|
|
|
|
|
|
|
2015-12-04 16:17:20 +00:00
|
|
|
|
Component selectedCmpnt = (Component)listViewEx.Items[ix].Tag;
|
2016-11-30 13:16:51 +00:00
|
|
|
|
if (selectedCmpnt.Id != 0) toBeDeletedEntities.Add(selectedCmpnt);
|
|
|
|
|
|
cmpntEntities.Remove(selectedCmpnt);
|
|
|
|
|
|
|
|
|
|
|
|
flags |= CfgUpdateFlags.AnyChange;
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
RedrawAll();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// DoubleClick -> Edit the component
|
|
|
|
|
|
private void listViewEx_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
editButton_Click(sender, e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-29 13:41:23 +00:00
|
|
|
|
/// Edit a component
|
2014-07-28 07:54:35 +00:00
|
|
|
|
private void editButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (listViewEx.SelectedIndices.Count != 1) return;
|
|
|
|
|
|
ListViewItem lvi = listViewEx.SelectedItems[0];
|
|
|
|
|
|
|
2015-12-04 16:17:20 +00:00
|
|
|
|
IComponentCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity((Component)lvi.Tag);
|
2017-03-18 15:46:03 +00:00
|
|
|
|
if (cfg != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
ComponentParametersDlg cfgForm = new ComponentParametersDlg();
|
|
|
|
|
|
cfgForm.TbfComponents = cmpntEntities;
|
|
|
|
|
|
cfgForm.ComponentCfgCtrl = cfg.GetControl();
|
|
|
|
|
|
cfgForm.ComponentCfgCtrl.Config = cfg;
|
|
|
|
|
|
DialogResult dr = cfgForm.ShowDialog();
|
|
|
|
|
|
if (dr != DialogResult.OK) return;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-03-18 15:46:03 +00:00
|
|
|
|
flags |= cfgForm.Flags;
|
2015-01-02 22:42:01 +00:00
|
|
|
|
|
2017-03-18 15:46:03 +00:00
|
|
|
|
sharedButtons.UnlockButtons(); /// Unlock this dialog buttons as changes were enabled
|
|
|
|
|
|
unlocked = true; /// in the ComponentParametersDlg.
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-03-18 15:46:03 +00:00
|
|
|
|
Component modified = cfgForm.Config.CreateDbEntity();
|
|
|
|
|
|
Component original = (Component)lvi.Tag;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-03-18 15:46:03 +00:00
|
|
|
|
original.Name = modified.Name;
|
|
|
|
|
|
original.ClassName = modified.ClassName;
|
|
|
|
|
|
original.ParentName = modified.ParentName;
|
|
|
|
|
|
original.Mode = modified.Mode;
|
|
|
|
|
|
original.Logging = modified.Logging;
|
|
|
|
|
|
original.Parameters = modified.Parameters;
|
2014-07-28 07:54:35 +00:00
|
|
|
|
|
2017-03-18 15:46:03 +00:00
|
|
|
|
RedrawAll();
|
|
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-29 13:41:23 +00:00
|
|
|
|
/// Copy a component
|
|
|
|
|
|
private void copyButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (listViewEx.SelectedIndices.Count != 1) return;
|
|
|
|
|
|
ListViewItem lvi = listViewEx.SelectedItems[0];
|
|
|
|
|
|
|
|
|
|
|
|
IComponentCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity((Component)lvi.Tag);
|
|
|
|
|
|
if (cfg != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
cfg.Name += Strings.New_name_copy;
|
|
|
|
|
|
if (selectComponentTypeDlg.SelectedScriptName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
IComponentCfgCtrl cfgControl = cfg.GetControl();
|
|
|
|
|
|
cfgControl.Config = cfg;
|
|
|
|
|
|
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;
|
|
|
|
|
|
if (cfgForm.ShowDialog() != DialogResult.OK) return;
|
|
|
|
|
|
|
|
|
|
|
|
flags |= CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
AddOne(cfgForm.Config.CreateDbEntity());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-20 08:14:43 +00:00
|
|
|
|
/// Export a component to a file
|
|
|
|
|
|
private void exportButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (listViewEx.SelectedIndices.Count != 1) return;
|
|
|
|
|
|
|
|
|
|
|
|
Component component = listViewEx.SelectedItems[0].Tag as Component;
|
|
|
|
|
|
if (component == null) return;
|
|
|
|
|
|
|
|
|
|
|
|
SaveFileDialog dlg = new SaveFileDialog();
|
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
component.Export(new StreamWriter(dlg.FileName, false, System.Text.Encoding.UTF8));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Import a component form a file
|
|
|
|
|
|
private void importButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
OpenFileDialog dlg = new OpenFileDialog();
|
|
|
|
|
|
if (dlg.ShowDialog() != DialogResult.OK) return;
|
|
|
|
|
|
|
|
|
|
|
|
/// Import a procedure from a file
|
|
|
|
|
|
Component newComponent = Component.Import(new StreamReader(dlg.FileName, System.Text.Encoding.UTF8));
|
|
|
|
|
|
|
|
|
|
|
|
IComponentCfg cfg = TbfComponents.CmpntCfgFromCmpntEntity(newComponent);
|
|
|
|
|
|
if (cfg != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
IComponentCfgCtrl cfgControl = cfg.GetControl();
|
|
|
|
|
|
cfgControl.Config = cfg;
|
|
|
|
|
|
cfgControl.Config.Name = cfgControl.Config.Name + " imported";
|
|
|
|
|
|
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;
|
|
|
|
|
|
if (cfgForm.ShowDialog() != DialogResult.OK) return;
|
|
|
|
|
|
|
|
|
|
|
|
flags |= CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
AddOne(cfgForm.Config.CreateDbEntity());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-28 21:04:07 +00:00
|
|
|
|
private void upButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (listViewEx.SelectedIndices.Count != 1) return;
|
|
|
|
|
|
int ix = listViewEx.SelectedIndices[0];
|
|
|
|
|
|
if (ix < 1) return;
|
|
|
|
|
|
|
|
|
|
|
|
Component item1 = (Component)(listViewEx.Items[ix - 1].Tag);
|
|
|
|
|
|
Component item2 = (Component)(listViewEx.Items[ix].Tag);
|
|
|
|
|
|
(item1 as IHasItemNr).ItemNr++;
|
|
|
|
|
|
(item2 as IHasItemNr).ItemNr--;
|
|
|
|
|
|
cmpntEntities.RemoveAt(ix);
|
|
|
|
|
|
cmpntEntities.Insert(ix - 1, item2);
|
|
|
|
|
|
|
|
|
|
|
|
flags |= CfgUpdateFlags.AnyChange;
|
|
|
|
|
|
|
|
|
|
|
|
RedrawAll();
|
|
|
|
|
|
|
|
|
|
|
|
Focus();
|
|
|
|
|
|
listViewEx.Items[ix - 1].Selected = true;
|
|
|
|
|
|
listViewEx.Items[ix - 1].EnsureVisible();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void downButton_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (listViewEx.SelectedIndices.Count != 1) return;
|
|
|
|
|
|
int ix = listViewEx.SelectedIndices[0];
|
|
|
|
|
|
if (ix >= listViewEx.Items.Count - 1) return;
|
|
|
|
|
|
|
|
|
|
|
|
Component item1 = (Component)(listViewEx.Items[ix].Tag);
|
|
|
|
|
|
Component item2 = (Component)(listViewEx.Items[ix + 1].Tag);
|
|
|
|
|
|
(item1 as IHasItemNr).ItemNr++;
|
|
|
|
|
|
(item2 as IHasItemNr).ItemNr--;
|
|
|
|
|
|
cmpntEntities.RemoveAt(ix + 1);
|
|
|
|
|
|
cmpntEntities.Insert(ix, item2);
|
|
|
|
|
|
|
|
|
|
|
|
flags |= CfgUpdateFlags.AnyChange;
|
|
|
|
|
|
|
|
|
|
|
|
RedrawAll();
|
|
|
|
|
|
|
|
|
|
|
|
Focus();
|
|
|
|
|
|
listViewEx.Items[ix + 1].Selected = true;
|
|
|
|
|
|
listViewEx.Items[ix + 1].EnsureVisible();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-07-28 07:54:35 +00:00
|
|
|
|
private void componentsListView_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (listViewEx.SelectedIndices.Count == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
sharedButtons.EnableButtons(UiControls.SharedButtons.Buttons.Remove | UiControls.SharedButtons.Buttons.Edit);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sharedButtons.DisableButtons(UiControls.SharedButtons.Buttons.Remove | UiControls.SharedButtons.Buttons.Edit);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void UpdateButtonStates(SharedButtons.SelectedItemPos selectedItemPos)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (selectedItemPos == SharedButtons.SelectedItemPos.None)
|
|
|
|
|
|
{
|
|
|
|
|
|
sharedButtons.DisableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (selectedItemPos == SharedButtons.SelectedItemPos.First)
|
|
|
|
|
|
{
|
|
|
|
|
|
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Down);
|
|
|
|
|
|
sharedButtons.DisableButtons(SharedButtons.Buttons.Up);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (selectedItemPos == SharedButtons.SelectedItemPos.Last)
|
|
|
|
|
|
{
|
|
|
|
|
|
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up);
|
|
|
|
|
|
sharedButtons.DisableButtons(SharedButtons.Buttons.Down);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (selectedItemPos == SharedButtons.SelectedItemPos.FirstAndLast)
|
|
|
|
|
|
{
|
|
|
|
|
|
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove);
|
|
|
|
|
|
sharedButtons.DisableButtons(SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sharedButtons.EnableButtons(SharedButtons.Buttons.Remove | SharedButtons.Buttons.Up | SharedButtons.Buttons.Down);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-11-30 13:16:51 +00:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-05-16 11:06:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Updates component configuration from a script file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="cfg"></param>
|
|
|
|
|
|
/// <param name="words"></param>
|
|
|
|
|
|
/// <param name="zeroBasedIdx"></param>
|
|
|
|
|
|
/// <returns>true = udated component configuration should be saved, new component should be created</returns>
|
|
|
|
|
|
bool UpdateCfg(ref IComponentCfg cfg, string[] words, ref int zeroBasedIdx)
|
|
|
|
|
|
{
|
|
|
|
|
|
string name = words[words.Length - 1]; /// The last word is the component name
|
|
|
|
|
|
cfg.Name = name.Replace("#", (zeroBasedIdx + 1).ToString());
|
|
|
|
|
|
|
|
|
|
|
|
if (cfg is BenchControl.Elde.Valve.ValveCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
int bitNr = zeroBasedIdx;
|
|
|
|
|
|
if (words.Length >= 2 && words[0].StartsWith("D") && int.TryParse(words[0].Substring(1), out bitNr))
|
|
|
|
|
|
{
|
|
|
|
|
|
zeroBasedIdx = bitNr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (name != "-")
|
|
|
|
|
|
{
|
|
|
|
|
|
(cfg as BenchControl.Elde.Valve.ValveCfg).BitPosition = bitNr;
|
|
|
|
|
|
(cfg as BenchControl.Elde.Valve.ValveCfg).Category =
|
|
|
|
|
|
name.Contains("L") ? ValveCategory.Bench :
|
|
|
|
|
|
name.Contains("I") ? ValveCategory.Output :
|
|
|
|
|
|
name.Contains("Z") ? ValveCategory.Feeding : ValveCategory.None;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (cfg is BenchControl.Elde.FlowMeter.FlowMeterCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
(cfg as IChildComponentCfg).ParentName = "CB";
|
|
|
|
|
|
(cfg as BenchControl.Elde.FlowMeter.FlowMeterCfg).Idx1 = zeroBasedIdx + 1;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (cfg is BenchControl.Elde.TempMeter.TempMeterCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
(cfg as IChildComponentCfg).ParentName = "CB";
|
|
|
|
|
|
(cfg as BenchControl.Elde.TempMeter.TempMeterCfg).Idx0 = zeroBasedIdx;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (cfg is BenchControl.Elde.PressureMeter.PressureMeterCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
(cfg as IChildComponentCfg).ParentName = "CB";
|
|
|
|
|
|
(cfg as BenchControl.Elde.PressureMeter.PressureMeterCfg).Idx0 = zeroBasedIdx;
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-05-29 11:37:04 +00:00
|
|
|
|
else if (cfg is BenchControl.Elde.RegulValve.RegulValveCfg)
|
2017-05-16 11:06:48 +00:00
|
|
|
|
{
|
|
|
|
|
|
(cfg as IChildComponentCfg).ParentName = "CB";
|
2018-05-29 11:37:04 +00:00
|
|
|
|
(cfg as BenchControl.Elde.RegulValve.RegulValveCfg).Idx1 = zeroBasedIdx + 1;
|
2017-05-16 11:06:48 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-05-29 11:37:04 +00:00
|
|
|
|
else if (cfg is BenchControl.Elde.RegisterReader.RegisterReaderCfg)
|
2017-05-16 11:06:48 +00:00
|
|
|
|
{
|
|
|
|
|
|
(cfg as IChildComponentCfg).ParentName = "CB";
|
2018-05-29 11:37:04 +00:00
|
|
|
|
(cfg as BenchControl.Elde.RegisterReader.RegisterReaderCfg).Position = zeroBasedIdx + 1;
|
2017-05-16 11:06:48 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (cfg is BenchControl.Elde.FixedStartRegisterReader.RegisterReaderCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
(cfg as IChildComponentCfg).ParentName = "CB";
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2019-01-16 13:52:20 +00:00
|
|
|
|
else if (cfg is BenchControl.RegisterReaders.KPackE.RegisterReader.RegisterReaderCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
(cfg as IChildComponentCfg).ParentName = "KPackE.Radio";
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-05-29 11:37:04 +00:00
|
|
|
|
else if (cfg is BenchControl.TestMethods.iPerlCommunication.iPerlHead.IperlHeadCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2017-05-16 11:06:48 +00:00
|
|
|
|
else if (cfg is BenchControl.WaterMeters.WaterMeter.WaterMeterCfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2018-09-10 09:19:37 +00:00
|
|
|
|
|
|
|
|
|
|
private void listViewEx_ColumnClick(object sender, ColumnClickEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Column == sortColumn)
|
|
|
|
|
|
{
|
|
|
|
|
|
sortOrder = (sortOrder == SortOrder.Ascending) ? SortOrder.Descending : SortOrder.Ascending;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
/// Clicked on another column header => set sortOrder to SortOrder.Ascending
|
|
|
|
|
|
sortColumn = e.Column;
|
|
|
|
|
|
sortOrder = SortOrder.Ascending;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sortColumn == (int)Column.Number)
|
|
|
|
|
|
{
|
|
|
|
|
|
listViewEx.ListViewItemSorter = new LviIntColumnComparer(sortColumn, sortOrder);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
listViewEx.ListViewItemSorter = new LviTextColumnComparer(sortColumn, sortOrder);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
listViewEx.SetSortIcon(sortColumn, sortOrder);
|
|
|
|
|
|
listViewEx.Sort();
|
|
|
|
|
|
}
|
2017-05-16 11:06:48 +00:00
|
|
|
|
}
|
2014-07-28 07:54:35 +00:00
|
|
|
|
}
|