Refactoring : TestBenchFramework --> TBF ver. 2.18.789
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
///
|
||||
/// Copyright (c) 2017 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Output.FileWriters.ImageArchiver
|
||||
{
|
||||
public partial class ArchiverCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
static readonly ILog log = LogManager.GetLogger(typeof(ArchiverCfgCtrl));
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
public bool Compound;
|
||||
|
||||
ArchiverCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as ArchiverCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
string[] selectedItems;
|
||||
|
||||
public ArchiverCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void WriterCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
for (YearFolders s = 0; s < YearFolders.Count; s++) yearFoldersComboBox.Items.Add(s.ToString());
|
||||
for (MonthFolders s = 0; s < MonthFolders.Count; s++) monthFoldersComboBox.Items.Add(s.ToString());
|
||||
for (DayFolders s = 0; s < DayFolders.Count; s++) dayFoldersComboBox.Items.Add(s.ToString());
|
||||
|
||||
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;
|
||||
destinationTextBox.Text = config.DestinationPath;
|
||||
destination2TextBox.Text = config.DestinationPath2;
|
||||
yearFoldersComboBox.Text = config.YearFolders.ToString();
|
||||
monthFoldersComboBox.Text = config.MonthFolders.ToString();
|
||||
dayFoldersComboBox.Text = config.DayFolders.ToString();
|
||||
archiveFmtTextBox.Text = config.ArchiveFormat;
|
||||
goodOnlyCheckBox.Checked = config.SaveGoodOnly;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
destinationTextBox.Enabled = true;
|
||||
destinationButton.Enabled = true;
|
||||
destination2TextBox.Enabled = true;
|
||||
destination2Button.Enabled = true;
|
||||
yearFoldersComboBox.Enabled = true;
|
||||
monthFoldersComboBox.Enabled = true;
|
||||
dayFoldersComboBox.Enabled = true;
|
||||
archiveFmtTextBox.Enabled = true;
|
||||
goodOnlyCheckBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
if (!yearFoldersComboBox.Items.Contains(yearFoldersComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid year folders selection";
|
||||
}
|
||||
|
||||
if (!monthFoldersComboBox.Items.Contains(monthFoldersComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid month folders selection";
|
||||
}
|
||||
|
||||
if (!dayFoldersComboBox.Items.Contains(dayFoldersComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid day folder selection";
|
||||
}
|
||||
|
||||
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.AnyChange | CfgUpdateFlags.RestartRqrd);
|
||||
}
|
||||
|
||||
if (config.DestinationPath != destinationTextBox.Text)
|
||||
{
|
||||
config.DestinationPath = destinationTextBox.Text;
|
||||
if (!config.DestinationPath.EndsWith("\\")) config.DestinationPath += "\\";
|
||||
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
||||
}
|
||||
|
||||
if (config.DestinationPath2 != destination2TextBox.Text)
|
||||
{
|
||||
config.DestinationPath2 = destination2TextBox.Text;
|
||||
if (!config.DestinationPath2.EndsWith("\\")) config.DestinationPath2 += "\\";
|
||||
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
||||
}
|
||||
|
||||
for (YearFolders i = 0; i < YearFolders.Count; i++)
|
||||
{
|
||||
if (i.ToString().Equals(yearFoldersComboBox.Text) && (config.YearFolders != i))
|
||||
{
|
||||
config.YearFolders = i;
|
||||
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (MonthFolders i = 0; i < MonthFolders.Count; i++)
|
||||
{
|
||||
if (i.ToString().Equals(monthFoldersComboBox.Text) && (config.MonthFolders != i))
|
||||
{
|
||||
config.MonthFolders = i;
|
||||
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (DayFolders i = 0; i < DayFolders.Count; i++)
|
||||
{
|
||||
if (i.ToString().Equals(dayFoldersComboBox.Text) && (config.DayFolders != i))
|
||||
{
|
||||
config.DayFolders = i;
|
||||
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (config.ArchiveFormat != archiveFmtTextBox.Text)
|
||||
{
|
||||
config.ArchiveFormat = archiveFmtTextBox.Text;
|
||||
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
||||
}
|
||||
|
||||
if (config.SaveGoodOnly != goodOnlyCheckBox.Checked)
|
||||
{
|
||||
config.SaveGoodOnly = goodOnlyCheckBox.Checked;
|
||||
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.InvokeCfgChange);
|
||||
}
|
||||
|
||||
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
|
||||
{
|
||||
Archiver.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
private void destinationButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user