tbf/TestBenchFramework/BenchControl/ResultsWriters/Basic/WriterCfgCtrl.cs
Milan Hanajik 1d8156e4d7 Version 1.5.100: - serious bug in SensusOracle database configuration control fixed, etc.
- bug in ResultsWriter.Basic configuration control fixed
- FlyingStartMassCollection minor fixes
- iPerlCommunication activity "Q2 corrected from ..." implemented
- iPerl communication timeout increased to 1800 ms
- more comments in EntitiesTestResults
2015-08-25 17:03:36 +02:00

139 lines
3.5 KiB
C#

///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
using System;
using System.Windows.Forms;
using log4net;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.ResultsWriters.Basic
{
public partial class WriterCfgCtrl : UserControl, IComponentCfgCtrl
{
static readonly ILog log = LogManager.GetLogger(typeof(WriterCfgCtrl));
public bool ShowMore { get { return false; } }
WriterCfg config;
public IComponentCfg Config
{
get { return config as IComponentCfg; }
set
{
config = value as WriterCfg;
Redraw();
}
}
public WriterCfgCtrl()
{
InitializeComponent();
}
private void WriterCfgCtrl_Load(object sender, EventArgs e)
{
for (int i = 0; i < (int)Separator.Count; i++)
{
separatorComboBox.Items.Add(((Separator)i).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;
yearFoldersCheckBox.Checked = config.YearFolders;
monthFoldersCheckBox.Checked = config.MonthFolders;
dayFoldersCheckBox.Checked = config.DayFolders;
separatorComboBox.Text = config.Separator.ToString();
eliminateSpacesCheckBox.Checked = config.EliminateSpaces;
}
public void Unlock()
{
nameTextBox.Enabled = true;
destinationTextBox.Enabled = true;
destinationButton.Enabled = true;
yearFoldersCheckBox.Enabled = true;
monthFoldersCheckBox.Enabled = true;
dayFoldersCheckBox.Enabled = true;
separatorComboBox.Enabled = true;
eliminateSpacesCheckBox.Enabled = true;
}
public CfgUpdateFlags VerifyCfg(ref string message)
{
CfgUpdateFlags flags = CfgUpdateFlags.None;
if (!separatorComboBox.Items.Contains(separatorComboBox.Text))
{
flags |= CfgUpdateFlags.Error;
message += Environment.NewLine + "Invalid separator";
}
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; }
if (config.DestinationPath != destinationTextBox.Text)
{
config.DestinationPath = destinationTextBox.Text;
if (!config.DestinationPath.EndsWith("\\")) config.DestinationPath += "\\";
flags = CfgUpdateFlags.RestartRqrd;
}
if (yearFoldersCheckBox.Checked != config.YearFolders)
{
config.YearFolders = yearFoldersCheckBox.Checked;
flags = CfgUpdateFlags.RestartRqrd;
}
if (monthFoldersCheckBox.Checked != config.MonthFolders)
{
config.MonthFolders = monthFoldersCheckBox.Checked;
flags = CfgUpdateFlags.RestartRqrd;
}
if (dayFoldersCheckBox.Checked != config.DayFolders)
{
config.DayFolders = dayFoldersCheckBox.Checked;
flags = CfgUpdateFlags.RestartRqrd;
}
for (int i = 0; i < (int)Separator.Count; i++)
{
if (((Separator)i).ToString().Equals(separatorComboBox.Text) && (config.Separator != (Separator)i))
{
config.Separator = (Separator)i;
flags = CfgUpdateFlags.RestartRqrd;
break;
}
}
if (eliminateSpacesCheckBox.Checked != config.EliminateSpaces)
{
config.EliminateSpaces = eliminateSpacesCheckBox.Checked;
flags = CfgUpdateFlags.RestartRqrd;
}
return flags;
}
private void destinationButton_Click(object sender, EventArgs e)
{
}
}
}