diff --git a/TestBenchFramework/BenchControl/Operations/AskYesNoForm.Designer.cs b/TestBenchFramework/BenchControl/Operations/AskYesNoForm.Designer.cs index 5ad4bf2d6..61b456f6e 100644 --- a/TestBenchFramework/BenchControl/Operations/AskYesNoForm.Designer.cs +++ b/TestBenchFramework/BenchControl/Operations/AskYesNoForm.Designer.cs @@ -82,7 +82,6 @@ namespace TBF.BenchControl.Operations this.Name = "AskYesNoForm"; this.Text = "Question"; this.TopMost = true; - this.Load += new System.EventHandler(this.AskYesNoForm_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/TestBenchFramework/BenchControl/Operations/AskYesNoForm.cs b/TestBenchFramework/BenchControl/Operations/AskYesNoForm.cs index 7f3e3ecba..0d0efbcc9 100644 --- a/TestBenchFramework/BenchControl/Operations/AskYesNoForm.cs +++ b/TestBenchFramework/BenchControl/Operations/AskYesNoForm.cs @@ -1,7 +1,8 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// using System; +using System.Drawing; using System.Windows.Forms; using TBF.Resources; @@ -10,20 +11,36 @@ namespace TBF.BenchControl.Operations public partial class AskYesNoForm : Form { public string Question; + + /// One of the following two variables set to 'true' when the form closes public bool CompletedYes; public bool CompletedNo; + public AskYesNoForm() { InitializeComponent(); + + Localize(); + questionLabel.Text = Question; + + float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(questionLabel.Text, questionLabel.Font).Width; + int rqrdFormWidth = (int)textWidth + 80; /// Form width calculated from the text width + + if (rqrdFormWidth > Width) + { + int shift = (rqrdFormWidth - Width) / 2; + Width = rqrdFormWidth; + yesButton.Left += shift; + noButton.Left += shift; + } } - private void AskYesNoForm_Load(object sender, EventArgs e) + void Localize() { - Text = Strings.Question; - questionLabel.Text = Question; yesButton.Text = Strings.YesBtn; noButton.Text = Strings.NoBtn; + Text = Strings.Question; } private void yesButton_Click(object sender, EventArgs e) diff --git a/TestBenchFramework/BenchControl/Operations/MessageBoxForm.Designer.cs b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.Designer.cs index 003307505..b02388b73 100644 --- a/TestBenchFramework/BenchControl/Operations/MessageBoxForm.Designer.cs +++ b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.Designer.cs @@ -68,7 +68,6 @@ namespace TBF.BenchControl.Operations this.Name = "MessageBoxForm"; this.Text = "Message"; this.TopMost = true; - this.Load += new System.EventHandler(this.MessageBoxForm_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs index b3296a761..cb64b5166 100644 --- a/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs +++ b/TestBenchFramework/BenchControl/Operations/MessageBoxForm.cs @@ -1,7 +1,8 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// using System; +using System.Drawing; using System.Windows.Forms; using TBF.Resources; @@ -11,22 +12,36 @@ namespace TBF.BenchControl.Operations { public string Message; - /// Is set to 'true' when the form closes + /// Set to 'true' when the form closes public bool Completed { get { return completed; } } bool completed; + public MessageBoxForm() { InitializeComponent(); + + Localize(); + messageLabel.Text = Message; + + float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(messageLabel.Text, messageLabel.Font).Width; + int rqrdFormWidth = (int)textWidth + 80; /// Form width calculated from the text width + + if (rqrdFormWidth > Width) + { + int shift = (rqrdFormWidth - Width) / 2; + Width = rqrdFormWidth; + okButton.Left += shift; + } + completed = false; StartForceCloseHandler(); } - private void MessageBoxForm_Load(object sender, EventArgs e) + void Localize() { Text = Strings.Message; - messageLabel.Text = Message; - okButton.Text = Strings.OkBtnText; + okButton.Text = Strings.OkBtnText; } private void okButton_Click(object sender, EventArgs e)