/// /// Copyright (c) 2013-2015 Sensus Metering Systems /// using System; using System.Windows.Forms; using log4net; using TBF.Resources; #pragma warning disable 162 /// Disables 'Unreachable code detected' warning namespace TBF.BenchControl.DataEntry.Munich { public partial class CycleBeginningForm : Form, GenericDevices.IHasCompleted { private static readonly ILog log = LogManager.GetLogger(typeof(CycleBeginningForm)); // To be retrieved after the form closes public string[] MainSNText; public string[] AuxSNText; // Set to 'true' when the form closes public bool Completed { get { return completed; } } bool completed; public CycleBeginningForm() { InitializeComponent(); ControlBox = false; MainSNText = new string[Config.Data.CompoundWMsCount]; AuxSNText = new string[Config.Data.CompoundWMsCount]; completed = false; StartForceCloseHandler(); } private void CycleBeginningForm_Load(object sender, EventArgs e) { Localize(); if (Config.Data.CompoundWMsCount < 2) { groupBox2.Visible = groupBox3.Visible = false; Height = 200; } else if (Config.Data.CompoundWMsCount < 3) { groupBox3.Visible = false; Height = 355; } } void Localize() { Text = Strings.Data; okButton.Text = Strings.OkBtnText; groupBox1.Text = string.Format(Strings.Water_Meter_nr, 1); mainSN1Label.Text = Strings.Main_WM_SerialNr; auxSN1Label.Text = Strings.Aux_WM_SerialNr; groupBox2.Text = string.Format(Strings.Water_Meter_nr, 2); mainSN2Label.Text = Strings.Main_WM_SerialNr; auxSN2Label.Text = Strings.Aux_WM_SerialNr; groupBox3.Text = string.Format(Strings.Water_Meter_nr, 3); mainSN3Label.Text = Strings.Main_WM_SerialNr; auxSN3Label.Text = Strings.Aux_WM_SerialNr; } private void okButton_Click(object sender, EventArgs e) { MainSNText[0] = mainSN1TextBox.Text; AuxSNText[0] = auxSN1TextBox.Text; if (Config.Data.CompoundWMsCount >= 2) { MainSNText[1] = mainSN2TextBox.Text; AuxSNText[1] = auxSN2TextBox.Text; } if (Config.Data.CompoundWMsCount >= 3) { MainSNText[2] = mainSN3TextBox.Text; AuxSNText[2] = auxSN3TextBox.Text; } completed = true; Close(); } #region Forced close handling public void StartForceCloseHandler() { UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args) { if (InvokeRequired) { Invoke(new EventHandler(OnForceClose), sender, args); } else OnForceClose(sender, args); }; } void OnForceClose(object sender, EventArgs args) { DialogResult = DialogResult.Cancel; Close(); } #endregion } }