AskYesNoForm, AskYesNoOp, MessageBoxForm and MessageBoxOp fixed, bug was introduced when measuring the string length.

This commit is contained in:
Milan Hanajik 2017-03-09 14:53:29 +01:00
parent e93a817d4d
commit 56f8d64fc8
4 changed files with 7 additions and 13 deletions

View File

@ -10,19 +10,17 @@ 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()
public AskYesNoForm(string question)
{
InitializeComponent();
Localize();
questionLabel.Text = Question;
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

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Collections.Generic;
@ -29,8 +29,7 @@ namespace TBF.BenchControl.Operations
///
void OpenFormDlg(AskYesNoOp myRef)
{
myRef.modelessDlg = new AskYesNoForm();
myRef.modelessDlg.Question = this.question;
myRef.modelessDlg = new AskYesNoForm(question);
modelessDlg.Show();
}

View File

@ -10,19 +10,17 @@ namespace TBF.BenchControl.Operations
{
public partial class MessageBoxForm : Form, GenericDevices.IHasCompleted
{
public string Message;
/// Set to 'true' when the form closes
public bool Completed { get { return completed; } }
bool completed;
public MessageBoxForm()
public MessageBoxForm(string message)
{
InitializeComponent();
Localize();
messageLabel.Text = Message;
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

View File

@ -30,8 +30,7 @@ namespace TBF.BenchControl.Operations
///
void OpenFormDlg(MessageBoxOp myRef)
{
myRef.modelessDlg = new MessageBoxForm();
myRef.modelessDlg.Message = this.message;
myRef.modelessDlg = new MessageBoxForm(message);
modelessDlg.Show();
}