95 lines
2.2 KiB
C#
95 lines
2.2 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using System.IO.Ports;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.Cameras.CameraRoi
|
|
{
|
|
public partial class CameraRoiCfgCtrl : UserControl, IComponentCfgCtrl
|
|
{
|
|
ComponentParametersDlg parent;
|
|
|
|
CameraRoiCfg config;
|
|
public IComponentCfg Config
|
|
{
|
|
get { return config as IComponentCfg; }
|
|
set
|
|
{
|
|
config = value as CameraRoiCfg;
|
|
Redraw();
|
|
}
|
|
}
|
|
|
|
public CameraRoiCfgCtrl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void IdcCameraCfgCtrl_Load(object sender, EventArgs e)
|
|
{
|
|
parent = ParentForm as ComponentParametersDlg;
|
|
if (parent == null) return;
|
|
|
|
if (parent.TbfComponents != null)
|
|
{
|
|
parentNameComboBox.Items.Add("---");
|
|
foreach (var cmpnt in parent.TbfComponents)
|
|
{
|
|
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is BenchControl.Cameras.IdcCamera.IdcCameraFactory)
|
|
{
|
|
parentNameComboBox.Items.Add(cmpnt.Name);
|
|
}
|
|
}
|
|
}
|
|
|
|
Redraw();
|
|
}
|
|
|
|
void Redraw()
|
|
{
|
|
if (config == null) return; /// Control was not loaded, settings were not changed
|
|
|
|
classNameLabel.Text = config.Factory.ClassName;
|
|
nameTextBox.Text = config.Name;
|
|
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
|
roiTextBox.Text = config.RoiNr.ToString();
|
|
}
|
|
|
|
public void Unlock()
|
|
{
|
|
nameTextBox.Enabled = true;
|
|
parentNameComboBox.Enabled = true;
|
|
roiTextBox.Enabled = true;
|
|
}
|
|
|
|
public CfgVerifyFlags VerifyCfg(ref string message)
|
|
{
|
|
CfgVerifyFlags flags = CfgVerifyFlags.None;
|
|
|
|
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
|
{
|
|
flags |= CfgVerifyFlags.Error;
|
|
message += Environment.NewLine + "Invalid 'Parent Name'";
|
|
}
|
|
|
|
int dummy;
|
|
if (!int.TryParse(roiTextBox.Text, out dummy) || dummy < 1 || dummy > 4)
|
|
{
|
|
flags |= CfgVerifyFlags.Error;
|
|
message += Environment.NewLine + "'Region of Interest' is not valid";
|
|
}
|
|
|
|
return flags;
|
|
}
|
|
|
|
public void UpdateCfg()
|
|
{
|
|
if (config == null) return; /// Control was not loaded, settings were not changed
|
|
|
|
config.Name = nameTextBox.Text;
|
|
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
|
config.RoiNr = int.Parse(roiTextBox.Text);
|
|
}
|
|
}
|
|
}
|