133 lines
3.3 KiB
C#
133 lines
3.3 KiB
C#
///
|
|
/// Copyright (c) 2017 Sensus Metering Systems
|
|
///
|
|
using System;
|
|
using System.Windows.Forms;
|
|
using log4net;
|
|
using Common;
|
|
using Config.Entities;
|
|
using TBF.Rig.Generic;
|
|
using TBF.Resources;
|
|
|
|
namespace TBF.Rig.TestMethods.GrabImage
|
|
{
|
|
public partial class GrabImageCfgCtrl : UserControl, IComponentCfgCtrl
|
|
{
|
|
static readonly ILog log = LogManager.GetLogger(typeof(GrabImageCfgCtrl));
|
|
|
|
public bool ShowMore { get { return false; } }
|
|
|
|
GrabImageCfg config;
|
|
public IComponentCfg Config
|
|
{
|
|
get { return config as IComponentCfg; }
|
|
set
|
|
{
|
|
config = value as GrabImageCfg;
|
|
Redraw();
|
|
}
|
|
}
|
|
|
|
public GrabImageCfgCtrl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void GrabImageCfgCtrl_Load(object sender, EventArgs e)
|
|
{
|
|
for (ImageRotation ir = 0; ir < ImageRotation.Count; ir++)
|
|
{
|
|
imageRotationComboBox.Items.Add(ir.ToDescription());
|
|
}
|
|
|
|
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;
|
|
imageNameTextBox.Text = config.ImageFileName;
|
|
blackAndWhiteCheckBox.Checked = config.BlackAndWhite;
|
|
loResolutionCheckBox.Checked = config.LowResolution;
|
|
imageRotationComboBox.Text = config.ImageRotation.ToDescription();
|
|
}
|
|
|
|
public void Unlock()
|
|
{
|
|
nameTextBox.Enabled = true;
|
|
imageNameTextBox.Enabled = true;
|
|
blackAndWhiteCheckBox.Enabled = true;
|
|
loResolutionCheckBox.Enabled = true;
|
|
imageRotationComboBox.Enabled = true;
|
|
}
|
|
|
|
public CfgUpdateFlags VerifyCfg(ref string message)
|
|
{
|
|
for (ImageRotation ir = 0; ir < ImageRotation.Count; ir++)
|
|
{
|
|
if (imageRotationComboBox.Text == ir.ToDescription()) return CfgUpdateFlags.None;
|
|
}
|
|
|
|
message += Environment.NewLine + string.Format(Strings.Invalid_0, imageRotationLabel.Text);
|
|
return CfgUpdateFlags.Error;
|
|
}
|
|
|
|
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.AnyChange | CfgUpdateFlags.RestartRqrd);
|
|
}
|
|
|
|
if (config.ImageFileName != imageNameTextBox.Text)
|
|
{
|
|
config.ImageFileName = imageNameTextBox.Text;
|
|
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
|
}
|
|
|
|
if (config.BlackAndWhite != blackAndWhiteCheckBox.Checked)
|
|
{
|
|
config.BlackAndWhite = blackAndWhiteCheckBox.Checked;
|
|
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
|
}
|
|
|
|
if (config.LowResolution != loResolutionCheckBox.Checked)
|
|
{
|
|
config.LowResolution = loResolutionCheckBox.Checked;
|
|
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
|
}
|
|
|
|
for (ImageRotation ir = 0; ir < ImageRotation.Count; ir++)
|
|
{
|
|
if (imageRotationComboBox.Text == ir.ToDescription())
|
|
{
|
|
if (config.ImageRotation != ir)
|
|
{
|
|
config.ImageRotation = ir;
|
|
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
|
|
{
|
|
Component.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
|
|
}
|
|
|
|
return flags;
|
|
}
|
|
}
|
|
}
|