Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #12358 [HDPI] The "document" text in the “Generating Previews” dialog is truncated at >200% DPI #12363

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void Run()
private void ThreadUnsafeUpdateLabel()
{
// "page {0} of {1}"
_dialog!._cancellingTextBox.Text = string.Format(
_dialog!._messageLabel.Text = string.Format(
SR.PrintControllerWithStatusDialog_NowPrinting,
_parent._pageNumber,
_parent._document?.DocumentName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Drawing;

namespace System.Windows.Forms;

public partial class PrintControllerWithStatusDialog
{
private partial class FocusableLabel : LinkLabel
LeafShi1 marked this conversation as resolved.
Show resolved Hide resolved
{
public FocusableLabel()
{
LinkBehavior = LinkBehavior.NeverUnderline;
ActiveLinkColor = SystemColors.ControlText;
LinkColor = SystemColors.ControlText;
VisitedLinkColor = SystemColors.ControlText;
}

protected override void WndProc(ref Message msg)
{
switch (msg.MsgInternal)
{
case PInvokeCore.WM_SETCURSOR:
break;
default:
base.WndProc(ref msg);
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Drawing;
using Windows.Win32.System.Variant;
using Windows.Win32.UI.Accessibility;

namespace System.Windows.Forms;

public partial class PrintControllerWithStatusDialog
{
private partial class StatusDialog : Form
{
internal TextBox _cancellingTextBox;
internal Label _messageLabel;
Epica3055 marked this conversation as resolved.
Show resolved Hide resolved
private Button _cancelButton;
private TableLayoutPanel? _tableLayoutPanel;
private readonly BackgroundThread _backgroundThread;
Expand All @@ -24,7 +22,7 @@ internal StatusDialog(BackgroundThread backgroundThread, string dialogTitle)
MinimumSize = Size;
}

[MemberNotNull(nameof(_cancellingTextBox))]
[MemberNotNull(nameof(_messageLabel))]
[MemberNotNull(nameof(_cancelButton))]
private void InitializeComponent()
{
Expand All @@ -34,20 +32,16 @@ private void InitializeComponent()
RightToLeft = RightToLeft.Yes;
}

_cancellingTextBox = new TextBox()
_messageLabel = new FocusableLabel()
{
AutoSize = true,
Location = new Point(8, 16),
BorderStyle = BorderStyle.None,
ReadOnly = true,
TextAlign = HorizontalAlignment.Center,
TextAlign = ContentAlignment.MiddleCenter,
Size = new Size(240, 64),
TabIndex = 1,
Anchor = AnchorStyles.None
};

_cancellingTextBox.TextChanged += OnCancellingTextBoxTextChanged;

_cancelButton = new Button()
{
AutoSize = true,
Expand All @@ -73,7 +67,7 @@ private void InitializeComponent()
_tableLayoutPanel.ColumnStyles.Add(new(SizeType.Percent, 100F));
_tableLayoutPanel.RowStyles.Add(new(SizeType.Percent, 50F));
_tableLayoutPanel.RowStyles.Add(new(SizeType.Percent, 50F));
_tableLayoutPanel.Controls.Add(_cancellingTextBox, 0, 0);
_tableLayoutPanel.Controls.Add(_messageLabel, 0, 0);
_tableLayoutPanel.Controls.Add(_cancelButton, 0, 1);

AutoScaleDimensions = new Size(6, 13);
Expand All @@ -91,22 +85,10 @@ private void InitializeComponent()
private void CancelClick(object? sender, EventArgs e)
{
_cancelButton.Enabled = false;
_cancellingTextBox.Text = SR.PrintControllerWithStatusDialog_Canceling;
_messageLabel.Text = SR.PrintControllerWithStatusDialog_Canceling;
_backgroundThread._canceled = true;
}

protected override AccessibleObject CreateAccessibilityInstance() => new StatusDialogAccessibility(this);

private void OnCancellingTextBoxTextChanged(object? sender, EventArgs e)
{
if (!_cancellingTextBox.IsAccessibilityObjectCreated)
{
return;
}

using var textVariant = (VARIANT)_cancellingTextBox.Text;
_cancellingTextBox.AccessibilityObject?.RaiseAutomationEvent(UIA_EVENT_ID.UIA_Text_TextChangedEventId);
LeafShi1 marked this conversation as resolved.
Show resolved Hide resolved
_cancellingTextBox.AccessibilityObject?.RaiseAutomationPropertyChangedEvent(UIA_PROPERTY_ID.UIA_NamePropertyId, textVariant, textVariant);
}
}
}