tbf/TBF/BenchControl/TestMethods/Endurance/TestMethodCfgCtrl.cs
2018-06-18 14:44:52 +02:00

86 lines
1.7 KiB
C#

///
/// Copyright (c) 2016 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using Config.Entities;
using TBF.BenchControl.Generic;
using TBF.Resources;
namespace TBF.BenchControl.TestMethods.Endurance
{
public partial class TestMethodCfgCtrl : UserControl, IComponentCfgCtrl
{
public bool ShowMore { get { return false; } }
string cycle;
TestMethodCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as TestMethodCfg;
Redraw();
}
}
public TestMethodCfgCtrl()
{
InitializeComponent();
}
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
{
enduranceCycleButton.Text = Strings.Endurance_cycle;
cycle = config.Cycle;
Redraw();
}
public void Closing()
{
}
void Redraw()
{
if (config == null) return; /// Control was not loaded, settings were not changed
classNameLabel.Text = config.Factory.ClassName;
nameTextBox.Text = config.Name;
}
public void Unlock()
{
nameTextBox.Enabled = true;
enduranceCycleButton.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
return flags;
}
public CfgUpdateFlags UpdateCfg()
{
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
config.Name = nameTextBox.Text;
config.Cycle = cycle;
return flags;
}
private void enduranceCycleButton_Click(object sender, EventArgs e)
{
CycleDlg dlg = new CycleDlg(CycleStep.StringToCycle(cycle));
if (dlg.ShowDialog() == DialogResult.OK)
{
cycle = CycleStep.CycleToString(dlg.EnduranceCycle);
}
}
}
}