106 lines
2.3 KiB
C#
106 lines
2.3 KiB
C#
///
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using Config.Entities;
|
|
using TBF.BenchControl.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.BenchControl.Various.ErrorFlags
|
|
{
|
|
public partial class ErrorsCfgCtrl : UserControl, IComponentCfgCtrl
|
|
{
|
|
static readonly ILog log = LogManager.GetLogger(typeof(ErrorsCfgCtrl));
|
|
|
|
ComponentParametersDlg parent;
|
|
|
|
public bool ShowMore { get { return false; } }
|
|
|
|
ErrorsCfg config;
|
|
public IComponentCfg Config
|
|
{
|
|
get { return config as IComponentCfg; }
|
|
set
|
|
{
|
|
config = value as ErrorsCfg;
|
|
Redraw();
|
|
}
|
|
}
|
|
|
|
public ErrorsCfgCtrl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void PumpCfgCtrl_Load(object sender, EventArgs e)
|
|
{
|
|
parent = ParentForm as ComponentParametersDlg;
|
|
if (parent == null) return;
|
|
|
|
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;
|
|
}
|
|
|
|
public CfgUpdateFlags VerifyCfg(ref string message)
|
|
{
|
|
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
|
|
|
return flags;
|
|
}
|
|
|
|
public CfgUpdateFlags UpdateCfg()
|
|
{
|
|
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
|
|
|
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
|
|
|
if (config.Name != nameTextBox.Text)
|
|
{
|
|
config.Name = nameTextBox.Text;
|
|
flags |= (CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
|
}
|
|
|
|
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
|
|
{
|
|
Errors.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, Config));
|
|
}
|
|
|
|
return flags;
|
|
}
|
|
|
|
#region Configuration Change Handling
|
|
|
|
public static void OnCmdResponse(object sender, CmdResponseArgs args)
|
|
{
|
|
if (CmdResponseHandler == null) return;
|
|
try { CmdResponseHandler(sender, args); }
|
|
catch (Exception e) { log.Error("CmdResponseHandler(...) failed", e); }
|
|
}
|
|
|
|
public static event EventHandler<CmdResponseArgs> CmdResponseHandler;
|
|
|
|
public void StartResponseHandler() { }
|
|
public void StopResponseHandler() { }
|
|
|
|
#endregion Configuration Change Handling
|
|
}
|
|
}
|