Skip to content

Commit

Permalink
Fixes binary question form not sizing correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
FalcoGer committed Sep 19, 2023
1 parent 0e0a535 commit c6dcb73
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 21 additions & 4 deletions CoordinateConverter/DCS/Tools/FormAskBinaryQuestion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,28 @@ public FormAskBinaryQuestion(string question, string yesButtonText = "Yes", stri
btn_Affirm.Text = yesButtonText;
btn_Deny.Text = noButtonText;

// Form will auto size to fit everything.
Rectangle screenRectangle = RectangleToScreen(ClientRectangle);
int titleHeight = screenRectangle.Top - Top;
int borderWidth = screenRectangle.Left - Left;

// Adjust positions, button X positions will be set by means of the anchor
btn_Affirm.Location = new Point(btn_Affirm.Location.X, lbl_QuestionText.Bottom + 4);
btn_Deny.Location = new Point(btn_Deny.Location.X, lbl_QuestionText.Bottom + 4);
const int MARGIN = 13;

lbl_QuestionText.Location = new Point(MARGIN, MARGIN);

int widthRequiredForButtons = btn_Deny.Width + MARGIN + btn_Affirm.Width;
int width = Math.Max(widthRequiredForButtons, lbl_QuestionText.Width) + (MARGIN * 2) + (borderWidth * 2);
int height = borderWidth + titleHeight + lbl_QuestionText.Top + lbl_QuestionText.Height + MARGIN + Math.Max(btn_Affirm.Height, btn_Deny.Height) + MARGIN;

Size = new Size(width, height);

// Left button
btn_Deny.Location = new Point(MARGIN, lbl_QuestionText.Location.Y + lbl_QuestionText.Height + MARGIN);
// btn_Deny.Location = new Point(btn_Deny.Location.X, lbl_QuestionText.Location.Y + lbl_QuestionText.Height + MARGIN);
// Right button
btn_Affirm.Location = new Point(btn_Deny.Location.X + btn_Deny.Width + MARGIN, btn_Deny.Location.Y);
// btn_Affirm.Location = new Point(btn_Affirm.Location.X, btn_Deny.Location.Y);


}

private void Btn_Deny_Click(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion CoordinateConverter/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace CoordinateConverter
/// <seealso cref="Form" />
public partial class MainForm : Form
{
private readonly GitHub.Version VERSION = new GitHub.Version(0, 5, 0);
private readonly GitHub.Version VERSION = new GitHub.Version(0, 5, 1);

private readonly Color ERROR_COLOR = Color.Pink;
private readonly Color DCS_ERROR_COLOR = Color.Yellow;
Expand Down

0 comments on commit c6dcb73

Please sign in to comment.