#1751 - text should always be readable. Allow for user-resizing when it's not the case.

This commit is contained in:
rmcrackan
2026-04-20 09:48:13 -04:00
parent f2ef616203
commit 4a30acf0eb
4 changed files with 58 additions and 26 deletions

View File

@@ -2,13 +2,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="650" d:DesignHeight="500"
Width="650" Height="500"
mc:Ignorable="d" d:DesignWidth="720" d:DesignHeight="640"
Width="720" Height="640"
MinWidth="600" MinHeight="560"
CanResize="True"
WindowStartupLocation="CenterOwner"
x:Class="LibationAvalonia.Dialogs.Login.LoginExternalDialog"
Title="Audible Login External">
<Grid RowDefinitions="Auto,Auto,*,Auto,*" ColumnDefinitions="*" Margin="5">
<Grid RowDefinitions="Auto,Auto,2*,Auto,*" ColumnDefinitions="*" Margin="5">
<StackPanel
Grid.Row="0"
@@ -33,7 +35,8 @@
Grid.Row="2"
Grid.Column="0"
RowDefinitions="Auto,*,Auto"
ColumnDefinitions="*,Auto">
ColumnDefinitions="*,Auto"
MinHeight="160">
<TextBlock
Grid.Row="0"
@@ -45,6 +48,7 @@
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
MinHeight="160"
IsReadOnly="True"
TextWrapping="Wrap"
Text="{Binding ExternalLoginUrl}" />
@@ -67,8 +71,7 @@
<StackPanel
Grid.Row="3"
Orientation="Vertical"
VerticalAlignment="Bottom">
Orientation="Vertical">
<TextBlock
TextWrapping="Wrap"
@@ -90,12 +93,15 @@
Grid.Row="4"
Grid.Column="0"
Margin="0,5,0,5"
RowDefinitions="*,Auto">
RowDefinitions="*,Auto"
MinHeight="120">
<TextBox
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
MinHeight="100"
AcceptsReturn="True"
TextWrapping="Wrap"
Text="{Binding ResponseUrl, Mode=TwoWay}" />

View File

@@ -16,6 +16,7 @@ public partial class LoginExternalDialog : DialogWindow
public LoginExternalDialog() : base(saveAndRestorePosition: false)
{
InitializeComponent();
CanResize = true;
if (Design.IsDesignMode)
{

View File

@@ -44,7 +44,7 @@ namespace LibationWinForms.Dialogs.Login
// submitBtn
//
this.submitBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.submitBtn.Location = new System.Drawing.Point(665, 458);
this.submitBtn.Location = new System.Drawing.Point(665, 575);
this.submitBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.submitBtn.Name = "submitBtn";
this.submitBtn.Size = new System.Drawing.Size(88, 27);
@@ -76,7 +76,7 @@ namespace LibationWinForms.Dialogs.Login
// loginUrlLbl
//
this.loginUrlLbl.AutoSize = true;
this.loginUrlLbl.Location = new System.Drawing.Point(14, 61);
this.loginUrlLbl.Location = new System.Drawing.Point(14, 55);
this.loginUrlLbl.Name = "loginUrlLbl";
this.loginUrlLbl.Size = new System.Drawing.Size(180, 15);
this.loginUrlLbl.TabIndex = 2;
@@ -84,21 +84,20 @@ namespace LibationWinForms.Dialogs.Login
//
// loginUrlTb
//
this.loginUrlTb.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
this.loginUrlTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.loginUrlTb.Location = new System.Drawing.Point(14, 79);
this.loginUrlTb.Location = new System.Drawing.Point(14, 73);
this.loginUrlTb.Multiline = true;
this.loginUrlTb.Name = "loginUrlTb";
this.loginUrlTb.ReadOnly = true;
this.loginUrlTb.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.loginUrlTb.Size = new System.Drawing.Size(739, 117);
this.loginUrlTb.Size = new System.Drawing.Size(739, 200);
this.loginUrlTb.TabIndex = 3;
//
// copyBtn
//
this.copyBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.copyBtn.Location = new System.Drawing.Point(14, 202);
this.copyBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
this.copyBtn.Location = new System.Drawing.Point(14, 281);
this.copyBtn.Name = "copyBtn";
this.copyBtn.Size = new System.Drawing.Size(165, 23);
this.copyBtn.TabIndex = 4;
@@ -108,8 +107,8 @@ namespace LibationWinForms.Dialogs.Login
//
// launchBrowserBtn
//
this.launchBrowserBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.launchBrowserBtn.Location = new System.Drawing.Point(589, 202);
this.launchBrowserBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.launchBrowserBtn.Location = new System.Drawing.Point(589, 281);
this.launchBrowserBtn.Name = "launchBrowserBtn";
this.launchBrowserBtn.Size = new System.Drawing.Size(165, 23);
this.launchBrowserBtn.TabIndex = 5;
@@ -119,9 +118,9 @@ namespace LibationWinForms.Dialogs.Login
//
// instructionsLbl
//
this.instructionsLbl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.instructionsLbl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
this.instructionsLbl.AutoSize = true;
this.instructionsLbl.Location = new System.Drawing.Point(14, 261);
this.instructionsLbl.Location = new System.Drawing.Point(14, 338);
this.instructionsLbl.Name = "instructionsLbl";
this.instructionsLbl.Size = new System.Drawing.Size(436, 90);
this.instructionsLbl.TabIndex = 7;
@@ -129,20 +128,21 @@ namespace LibationWinForms.Dialogs.Login
//
// responseUrlTb
//
this.responseUrlTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.responseUrlTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.responseUrlTb.Location = new System.Drawing.Point(14, 354);
this.responseUrlTb.Location = new System.Drawing.Point(14, 450);
this.responseUrlTb.Multiline = true;
this.responseUrlTb.Name = "responseUrlTb";
this.responseUrlTb.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.responseUrlTb.Size = new System.Drawing.Size(739, 98);
this.responseUrlTb.Size = new System.Drawing.Size(739, 120);
this.responseUrlTb.TabIndex = 8;
//
// tldrLbl
//
this.tldrLbl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
this.tldrLbl.AutoSize = true;
this.tldrLbl.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.tldrLbl.Location = new System.Drawing.Point(14, 237);
this.tldrLbl.Location = new System.Drawing.Point(14, 315);
this.tldrLbl.Name = "tldrLbl";
this.tldrLbl.Size = new System.Drawing.Size(421, 15);
this.tldrLbl.TabIndex = 6;
@@ -153,7 +153,7 @@ namespace LibationWinForms.Dialogs.Login
this.AcceptButton = this.submitBtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(766, 498);
this.ClientSize = new System.Drawing.Size(766, 620);
this.Controls.Add(this.tldrLbl);
this.Controls.Add(this.responseUrlTb);
this.Controls.Add(this.instructionsLbl);
@@ -164,9 +164,10 @@ namespace LibationWinForms.Dialogs.Login
this.Controls.Add(this.usernameLbl);
this.Controls.Add(this.localeLbl);
this.Controls.Add(this.submitBtn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.MaximizeBox = false;
this.MaximizeBox = true;
this.MinimumSize = new System.Drawing.Size(640, 520);
this.MinimizeBox = false;
this.Name = "LoginExternalDialog";
this.ShowIcon = false;

View File

@@ -18,6 +18,30 @@ public partial class LoginExternalDialog : Form
this.usernameLbl.Text = string.Format(this.usernameLbl.Text, account.AccountId);
this.loginUrlTb.Text = loginUrl;
SizeChanged += (_, _) => AdjustInstructionAndResponseLayout();
Shown += (_, _) => AdjustInstructionAndResponseLayout();
instructionsLbl.SizeChanged += (_, _) => AdjustInstructionAndResponseLayout();
AdjustInstructionAndResponseLayout();
}
private void AdjustInstructionAndResponseLayout()
{
const int margin = 14;
const int gap = 8;
tldrLbl.Left = margin;
tldrLbl.Top = copyBtn.Bottom + gap;
instructionsLbl.Left = margin;
instructionsLbl.Top = tldrLbl.Bottom + gap;
instructionsLbl.Width = ClientSize.Width - 2 * margin;
instructionsLbl.MaximumSize = new System.Drawing.Size(ClientSize.Width - 2 * margin, 0);
var responseTop = instructionsLbl.Bottom + gap;
var responseBottom = submitBtn.Top - gap;
var h = System.Math.Max(1, responseBottom - responseTop);
responseUrlTb.SetBounds(margin, responseTop, ClientSize.Width - 2 * margin, h);
}
private void copyBtn_Click(object sender, EventArgs e) => Clipboard.SetText(this.loginUrlTb.Text);