!改善界面的高分辨率屏幕适配

This commit is contained in:
WMJ
2025-08-25 20:35:29 +08:00
parent dbd3f9c035
commit 7280aebbd8
13 changed files with 80 additions and 68 deletions
+14 -4
View File
@@ -155,16 +155,26 @@ namespace PDFPatcher.Common
}
}
public static ToolStrip ScaleIcons(this ToolStrip toolStrip, int size) {
size = (int)(toolStrip.GetDpiScale() * size);
return toolStrip.ScaleIcons(new Size(size, size));
public static ToolStrip ScaleElements(this ToolStrip toolStrip, float scale = 0) {
if (scale <= 0) {
scale = toolStrip.GetDpiScale();
}
var iconSize = (int)(scale * 16);
var splitButtonWidth = (int)(11 * scale);
return toolStrip.DpiAwareScale(new Size(iconSize, iconSize), splitButtonWidth);
}
public static ToolStrip ScaleIcons(this ToolStrip toolStrip, Size size) {
public static ToolStrip DpiAwareScale(this ToolStrip toolStrip, Size size, int splitButtonWidth) {
toolStrip.SuspendLayout();
toolStrip.AutoSize = false;
toolStrip.ImageScalingSize = size;
toolStrip.ResumeLayout();
toolStrip.AutoSize = true;
foreach (var item in toolStrip.Items) {
if (item is ToolStripSplitButton sb) {
sb.DropDownButtonWidth = splitButtonWidth;
}
}
return toolStrip;
}
@@ -46,7 +46,7 @@ namespace PDFPatcher.Functions
}
void OnLoad() {
_MainToolbar.ScaleIcons(16);
_MainToolbar.ScaleElements();
_FilterBox.ScaleColumnWidths();
}
+1 -1
View File
@@ -27,7 +27,7 @@ namespace PDFPatcher.Functions
public string DocumentPath => _SourceFileControl.Text;
void OnLoad() {
_FilterToolbar.ScaleIcons(16);
_FilterToolbar.ScaleElements();
_LevelAdjustmentBox.ScaleColumnWidths();
AppContext.MainForm.SetTooltip(_SourceFileControl.FileList, "需要识别标题为书签的 PDF 源文件路径");
AppContext.MainForm.SetTooltip(_BookmarkControl.FileList, "指定识别书签后生成的信息文件或简易文本书签文件路径");
+1 -1
View File
@@ -57,7 +57,7 @@ namespace PDFPatcher.Functions
}
void OnLoad() {
_MainToolbar.ScaleIcons(16);
_MainToolbar.ScaleElements();
_ObjectDetailBox.ScaleColumnWidths();
_ObjectDetailBox.EmptyListMsg = "请使用“打开”按钮加载需要检查结构的 PDF 文件,或从资源管理器拖放文件到本列表框";
+1 -1
View File
@@ -26,7 +26,7 @@ namespace PDFPatcher.Functions
void OnLoad() {
MinimumSize = Size;
_Toolbar.ScaleIcons(16);
_Toolbar.ScaleElements();
_ConditionColumn.AsTyped<EditModel.AutoBookmarkSettings>(c => c.AspectGetter = o => $"字体为{o.FontName} 尺寸为{o.FontSize}{o.MatchPattern?.ToString() ?? String.Empty}");
_LevelColumn.CellEditUseWholeCell = true;
+7 -8
View File
@@ -48,14 +48,13 @@ namespace PDFPatcher.Functions
ListRecentFiles = _OpenButton_DropDownOpening;
RecentFileItemClicked = _OpenButton_DropDownItemClicked;
var s = this.GetDpiScale();
var size = new Size((int)(s * 16), (int)(s * 16));
_BookmarkToolbar.ScaleIcons(size);
_ViewerToolbar.ScaleIcons(size);
_EditMenu.ScaleIcons(size);
_RecentFileMenu.ScaleIcons(size);
_SelectionMenu.ScaleIcons(size);
_UndoMenu.ScaleIcons(size);
_ViewerMenu.ScaleIcons(size);
_BookmarkToolbar.ScaleElements(s);
_ViewerToolbar.ScaleElements(s);
_EditMenu.ScaleElements(s);
_RecentFileMenu.ScaleElements(s);
_SelectionMenu.ScaleElements(s);
_UndoMenu.ScaleElements(s);
_ViewerMenu.ScaleElements(s);
_BookmarkBox.ScaleColumnWidths(s);
_ViewerToolbar.Left = _BookmarkToolbar.Right;
_MainPanel.SplitterDistance = (int)(_MainPanel.SplitterDistance * FormHelper.GetDpiScale(this));
+1 -1
View File
@@ -26,7 +26,7 @@ namespace PDFPatcher.Functions
}
void OnLoad() {
_MainToolbar.ScaleIcons(16);
_MainToolbar.ScaleElements();
_ItemList.ListViewItemSorter = new ListViewItemComparer(0);
AppContext.MainForm.SetTooltip(_BookmarkControl.FileList, "需要导出或导入的信息文件路径");
+6 -5
View File
@@ -30,11 +30,12 @@ namespace PDFPatcher.Functions
}
void OnLoad() {
_MainToolbar.ScaleIcons(16);
_FileMenu.ScaleIcons(16);
_ItemListMenu.ScaleIcons(16);
_RecentFileMenu.ScaleIcons(16);
_RecentFolderMenu.ScaleIcons(16);
var s = this.GetDpiScale();
_MainToolbar.ScaleElements(s);
_FileMenu.ScaleElements(s);
_ItemListMenu.ScaleElements(s);
_RecentFileMenu.ScaleElements(s);
_RecentFolderMenu.ScaleElements(s);
_ItemList.ScaleColumnWidths();
_BookmarkColorButton.SelectedColorChanged += (s, e) => RefreshBookmarkColor();
+4 -3
View File
@@ -167,7 +167,8 @@
// _RefreshInfoMenu
//
this._RefreshInfoMenu.Name = "_RefreshInfoMenu";
this._RefreshInfoMenu.Size = new System.Drawing.Size(181, 26);
this._RefreshInfoMenu.OwnerItem = _RefreshInfo;
this._RefreshInfoMenu.Size = new System.Drawing.Size(61, 4);
//
// _MainToolbar
//
@@ -217,6 +218,7 @@
_InvertSelection,
_SelectNone});
this._SelectionMenu.Name = "_SelectionMenu";
this._SelectionMenu.OwnerItem = this._SelectionMenuItem;
this._SelectionMenu.Size = new System.Drawing.Size(125, 70);
this._SelectionMenu.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this._MainToolbar_ItemClicked);
//
@@ -417,7 +419,7 @@
this._ConfigButton.Image = global::PDFPatcher.Properties.Resources.PdfOptions;
this._ConfigButton.Location = new System.Drawing.Point(253, 297);
this._ConfigButton.Name = "_ConfigButton";
this._ConfigButton.Size = new System.Drawing.Size(181, 23);
this._ConfigButton.Size = new System.Drawing.Size(181, 29);
this._ConfigButton.TabIndex = 11;
this._ConfigButton.Text = "设置 P&DF 文件的修改方式";
this._ConfigButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
@@ -454,7 +456,6 @@
this.Controls.Add(this._TargetPdfFile);
this.Controls.Add(this._ItemActionsContainerBox);
this.Controls.Add(this._AutoClearListBox);
this.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Name = "PatcherControl";
this.Size = new System.Drawing.Size(575, 342);
this._SortMenu.ResumeLayout(false);
+7 -6
View File
@@ -28,12 +28,13 @@ namespace PDFPatcher.Functions
}
void OnLoad() {
_MainToolbar.ScaleIcons(16);
_ItemListMenu.ScaleIcons(16);
_RecentFileMenu.ScaleIcons(16);
_RefreshInfoMenu.ScaleIcons(16);
_SelectionMenu.ScaleIcons(16);
_SortMenu.ScaleIcons(16);
var s = this.GetDpiScale();
_MainToolbar.ScaleElements(s);
_ItemListMenu.ScaleElements(s);
_RecentFileMenu.ScaleElements(s);
_RefreshInfoMenu.ScaleElements(s);
_SelectionMenu.ScaleElements(s);
_SortMenu.ScaleElements(s);
AppContext.MainForm.SetTooltip(_ConfigButton, "点击此处设置 PDF 文件的修改方式选项");
AppContext.MainForm.SetTooltip(_ActionsBox, "双击项目编辑操作选项;右键点击项目弹出上下文菜单");
+29 -28
View File
@@ -25,36 +25,37 @@
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent () {
this._OptionsBox = new PDFPatcher.Functions.PatcherOptionsControl();
this.SuspendLayout();
//
// _OptionsBox
//
this._OptionsBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this._OptionsBox = new PDFPatcher.Functions.PatcherOptionsControl();
this.SuspendLayout();
//
// _OptionsBox
//
this._OptionsBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this._OptionsBox.ForEditor = false;
this._OptionsBox.Location = new System.Drawing.Point(12, 15);
this._OptionsBox.Name = "_OptionsBox";
this._OptionsBox.Options = null;
this._OptionsBox.Size = new System.Drawing.Size(452, 321);
this._OptionsBox.TabIndex = 0;
//
// PatcherOptionForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(476, 348);
this.Controls.Add(this._OptionsBox);
this.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(482, 374);
this.Name = "PatcherOptionForm";
this.ShowInTaskbar = false;
this.Text = "PDF 文档选项";
this.ResumeLayout(false);
this._OptionsBox.ForEditor = false;
this._OptionsBox.Location = new System.Drawing.Point(18, 22);
this._OptionsBox.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
this._OptionsBox.Name = "_OptionsBox";
this._OptionsBox.Options = null;
this._OptionsBox.Size = new System.Drawing.Size(678, 482);
this._OptionsBox.TabIndex = 0;
//
// PatcherOptionForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(714, 522);
this.Controls.Add(this._OptionsBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(712, 533);
this.Name = "PatcherOptionForm";
this.ShowInTaskbar = false;
this.Text = "PDF 文档选项";
this.ResumeLayout(false);
}
+6 -7
View File
@@ -26,13 +26,12 @@ namespace PDFPatcher.Functions
}
void OnLoad() {
var s = (int)(this.GetDpiScale() * 16);
var size = new System.Drawing.Size(s, s);
_MainToolbar.ScaleIcons(size);
_SortMenu.ScaleIcons(size);
_ItemListMenu.ScaleIcons(size);
_RecentFileMenu.ScaleIcons(size);
_RefreshInfoMenu.ScaleIcons(size);
var s = this.GetDpiScale();
_MainToolbar.ScaleElements(s);
_SortMenu.ScaleElements(s);
_ItemListMenu.ScaleElements(s);
_RecentFileMenu.ScaleElements(s);
_RefreshInfoMenu.ScaleElements(s);
_ItemList.ListViewItemSorter = new ListViewItemComparer(0);
+2 -2
View File
@@ -224,7 +224,7 @@ namespace PDFPatcher
// ignore loading exception
firstLoad = true;
}
_MainMenu.ScaleIcons(16);
_MainMenu.ScaleElements();
Text = Constants.AppName + " [" + Application.ProductVersion + "]";
MinimumSize = Size;
AllowDrop = true;
@@ -423,7 +423,7 @@ namespace PDFPatcher
}
void ScaleToolbar() {
_GeneralToolbar.ScaleIcons(16);
_GeneralToolbar.ScaleElements();
}
Control GetActiveFunctionControl() {