ParamValues() retval IList->ICollection, GetControl() arg. is a list of components, ver. 3.1.1598
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
///
|
||||
/// Copyright (c) 2016 Sensus Metering Systems
|
||||
///
|
||||
using TBF.BenchControl.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Configs.NameOnly
|
||||
{
|
||||
@@ -11,7 +12,7 @@ namespace TBF.BenchControl.Configs.NameOnly
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); }
|
||||
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new TestMethodCfgCtrl(); }
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
TestMethodCfg() { }
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace TBF.BenchControl.Configs.ParamsProvider
|
||||
}
|
||||
}
|
||||
|
||||
IList<string> parents;
|
||||
Control[] editors;
|
||||
CfgUpdateFlags flags;
|
||||
|
||||
@@ -47,22 +46,25 @@ namespace TBF.BenchControl.Configs.ParamsProvider
|
||||
/// </summary>
|
||||
/// <param name="paramsProvider">Parameters provider implementing IComponentCfg and IParamsProvider</param>
|
||||
/// <param name="parents">A list of parents or null, null hides parentComboBox</param>
|
||||
public ComponentCfgCtrl(IParamsProvider paramsProvider, IList<string> parents)
|
||||
public ComponentCfgCtrl(IParamsProvider paramsProvider, IEnumerable<Component> parents)
|
||||
: this()
|
||||
{
|
||||
this.paramsProvider = paramsProvider;
|
||||
this.parents = parents;
|
||||
|
||||
if (parents == null)
|
||||
{
|
||||
parentLabel.Visible = false;
|
||||
parentComboBox.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var p in parents) parentComboBox.Items.Add(p.Name);
|
||||
}
|
||||
|
||||
editors = new Control[paramsProvider.ParamsCount()];
|
||||
for (int i = 0; i < paramsProvider.ParamsCount(); i++)
|
||||
{
|
||||
IList<string> values = paramsProvider.ParamValues(i);
|
||||
ICollection<string> values = paramsProvider.ParamValues(i);
|
||||
if (values == null)
|
||||
{
|
||||
editors[i] = new TextBox();
|
||||
@@ -95,10 +97,6 @@ namespace TBF.BenchControl.Configs.ParamsProvider
|
||||
Localize();
|
||||
paramsListViewEx.Columns.Add(Strings.Parameter, 210);
|
||||
paramsListViewEx.Columns.Add(Strings.Value, 210);
|
||||
if (parents != null)
|
||||
{
|
||||
foreach (var p in parents) parentComboBox.Items.Add(p);
|
||||
}
|
||||
Redraw();
|
||||
}
|
||||
|
||||
@@ -114,7 +112,7 @@ namespace TBF.BenchControl.Configs.ParamsProvider
|
||||
componentClassTextBox.Text = Config.Factory.ClassName;
|
||||
nameTextBox.Text = Config.Name;
|
||||
|
||||
if (parents != null) parentComboBox.Text = Config.ParentName;
|
||||
if (parentComboBox.Visible) parentComboBox.Text = Config.ParentName;
|
||||
|
||||
paramsListViewEx.Items.Clear();
|
||||
for (int i = 0; i < paramsProvider.ParamsCount(); i++)
|
||||
@@ -129,18 +127,16 @@ namespace TBF.BenchControl.Configs.ParamsProvider
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
if (parents != null) parentComboBox.Enabled = true;
|
||||
parentComboBox.Enabled = true; /// It still may be invisible
|
||||
paramsListViewEx.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
if (parents == null) return CfgUpdateFlags.None;
|
||||
|
||||
/// Verify the parent
|
||||
foreach (var item in parentComboBox.Items)
|
||||
/// Verify the parent (if parent combo box is visible)
|
||||
if (!parentComboBox.Visible || parentComboBox.Items.Contains(parentComboBox.Text))
|
||||
{
|
||||
if (parentComboBox.Text == item.ToString()) return CfgUpdateFlags.None;
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
|
||||
message += Environment.NewLine + string.Format(Strings.Invalid_0, parentLabel.Text);
|
||||
@@ -159,13 +155,10 @@ namespace TBF.BenchControl.Configs.ParamsProvider
|
||||
f |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
if (parents != null)
|
||||
if (parentComboBox.Visible && Config.ParentName != parentComboBox.Text)
|
||||
{
|
||||
if (Config.ParentName != parentComboBox.Text)
|
||||
{
|
||||
Config.ParentName = parentComboBox.Text;
|
||||
f |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
Config.ParentName = parentComboBox.Text;
|
||||
f |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
return f;
|
||||
|
||||
Reference in New Issue
Block a user