130 lines
3.5 KiB
C#
130 lines
3.5 KiB
C#
///
|
|
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Xml.Serialization;
|
|
using Config.Entities;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.DataEntry.DataStream
|
|
{
|
|
/// <summary>
|
|
/// Holds information identifying the test bench - serializable configuration.
|
|
/// </summary>
|
|
public class EntryFormCfg : ComponentCfgBase, Generic.IChildComponentCfg, Config.Entities.IParamsProvider
|
|
{
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(EntryFormCfg) })[0];
|
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
public IComponentCfgCtrl GetControl()
|
|
{
|
|
IList<string> parents = new List<string>();
|
|
parents.Add("MefImport");
|
|
|
|
return new Configs.ParamsProvider.ComponentCfgCtrl(this, parents);
|
|
}
|
|
|
|
///
|
|
/// Serialized parameters
|
|
///
|
|
public bool ShowCycleEndForm;
|
|
|
|
/// Private parameterless constructor invoked by all other (public) constructors
|
|
EntryFormCfg() {}
|
|
|
|
public EntryFormCfg(IComponentFactory factory, string name)
|
|
: this()
|
|
{
|
|
Factory = factory;
|
|
Name = name;
|
|
ParentName = "MefImport";
|
|
InitializeAll();
|
|
}
|
|
|
|
public string ComponentName { get { return Name; } }
|
|
|
|
public void InitializeAll()
|
|
{
|
|
ShowCycleEndForm = false;
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
"Show form at the end of cycle",
|
|
};
|
|
public string ParamName(int i) { return paramNames[i]; }
|
|
public int ParamsCount() { return paramNames.Length; }
|
|
|
|
public ICollection<string> ParamValues(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
return new List<string>() { Strings.yes, Strings.no };
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public string ToString(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
return ShowCycleEndForm ? Strings.yes : Strings.no;
|
|
default:
|
|
return string.Format("{0}: ShowEndForm={1}", Name, ShowCycleEndForm);
|
|
}
|
|
}
|
|
|
|
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
ShowCycleEndForm = (strValue == Strings.yes);
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
default:
|
|
return CfgUpdateFlags.None;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string strValue, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
if (ParamValues(i).Contains(strValue)) return true;
|
|
break;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
void CopyContentTo(EntryFormCfg prms)
|
|
{
|
|
prms.ShowCycleEndForm = this.ShowCycleEndForm;
|
|
}
|
|
|
|
public Config.Entities.IParamsProvider Clone()
|
|
{
|
|
EntryFormCfg pars = new EntryFormCfg();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public bool UpdateEmbeddedDbEntity()
|
|
{
|
|
return true; /// =OK, do nothing
|
|
}
|
|
}
|
|
}
|