优化显示

This commit is contained in:
ww-rm
2025-03-25 11:24:37 +08:00
parent da329723bc
commit adfcfdb1de
3 changed files with 55 additions and 8 deletions

View File

@@ -73,6 +73,7 @@
propertyGrid_ExportArgs.Dock = DockStyle.Fill; propertyGrid_ExportArgs.Dock = DockStyle.Fill;
propertyGrid_ExportArgs.Location = new Point(3, 3); propertyGrid_ExportArgs.Location = new Point(3, 3);
propertyGrid_ExportArgs.Name = "propertyGrid_ExportArgs"; propertyGrid_ExportArgs.Name = "propertyGrid_ExportArgs";
propertyGrid_ExportArgs.PropertySort = PropertySort.Categorized;
propertyGrid_ExportArgs.Size = new Size(604, 594); propertyGrid_ExportArgs.Size = new Size(604, 594);
propertyGrid_ExportArgs.TabIndex = 1; propertyGrid_ExportArgs.TabIndex = 1;
propertyGrid_ExportArgs.ToolbarVisible = false; propertyGrid_ExportArgs.ToolbarVisible = false;

View File

@@ -1,12 +1,15 @@
using SpineViewer.Exporter; using SpineViewer.Exporter;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Drawing.Design; using System.Drawing.Design;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
@@ -18,10 +21,52 @@ namespace SpineViewer.Dialogs
/// <summary> /// <summary>
/// 要绑定的导出参数 /// 要绑定的导出参数
/// </summary> /// </summary>
public required ExportArgs ExportArgs public required ExportArgs ExportArgs
{ {
get => propertyGrid_ExportArgs.SelectedObject as ExportArgs; get => propertyGrid_ExportArgs.SelectedObject as ExportArgs;
init => propertyGrid_ExportArgs.SelectedObject = value; init
{
propertyGrid_ExportArgs.SelectedObject = value;
#region XXX:
var categories = propertyGrid_ExportArgs.SelectedGridItem?.Parent?.Parent?.GridItems;
if (categories is null) return;
foreach (var category in categories)
{
// 查找 "导出" 分组
if (category == null) continue;
PropertyInfo? labelProp = category.GetType().GetProperty("Label", BindingFlags.Instance | BindingFlags.Public);
if (labelProp == null) continue;
string? label = labelProp.GetValue(category) as string;
if (label != "导出") continue;
// 获取该分组下的所有属性项
PropertyInfo? gridItemsProp = category.GetType().GetProperty("GridItems", BindingFlags.Instance | BindingFlags.Public);
if (gridItemsProp == null) continue;
var gridItemsObj = gridItemsProp.GetValue(category);
if (gridItemsObj is not IEnumerable gridItems) continue;
foreach (object item in gridItems)
{
if (item == null) continue;
PropertyInfo? propDescProp = item.GetType().GetProperty("PropertyDescriptor", BindingFlags.Instance | BindingFlags.Public);
if (propDescProp == null) continue;
var propDesc = propDescProp.GetValue(item) as PropertyDescriptor;
if (propDesc == null) continue;
if (propDesc.Name == "OutputDir")
{
if (item is GridItem gridItem)
propertyGrid_ExportArgs.SelectedGridItem = gridItem; // 找到后,将此项设为选中项
else
propertyGrid_ExportArgs.SelectedGridItem = (GridItem)item; // 如果转换失败,则尝试直接赋值
}
return; // 设置成功后退出
}
}
#endregion
}
} }
public ExportDialog() public ExportDialog()

View File

@@ -22,7 +22,7 @@ namespace SpineViewer.Exporter
public string? OutputDir { get; set; } = null; public string? OutputDir { get; set; } = null;
/// <summary> /// <summary>
/// 逐个导出 /// 导出单个
/// </summary> /// </summary>
[Category("导出"), DisplayName("导出单个"), Description("是否将模型在同一个画面上导出单个文件,否则逐个导出模型")] [Category("导出"), DisplayName("导出单个"), Description("是否将模型在同一个画面上导出单个文件,否则逐个导出模型")]
public bool ExportSingle { get; set; } = false; public bool ExportSingle { get; set; } = false;
@@ -32,20 +32,21 @@ namespace SpineViewer.Exporter
/// </summary> /// </summary>
[ReadOnly(true)] [ReadOnly(true)]
[TypeConverter(typeof(SizeConverter))] [TypeConverter(typeof(SizeConverter))]
[Category("导出"), DisplayName("分辨率"), Description("画面的宽高像素大小")] [Category("导出"), DisplayName("分辨率"), Description("画面的宽高像素大小,请在预览画面参数面板进行调整")]
public required Size Resolution { get; init; } public required Size Resolution { get; init; }
/// <summary> /// <summary>
/// 渲染视窗 /// 渲染视窗
/// </summary> /// </summary>
[Browsable(false)] [ReadOnly(true)]
[Category("导出"), DisplayName("视图"), Description("画面的视图参数,请在预览画面参数面板进行调整")]
public required SFML.Graphics.View View { get; init; } public required SFML.Graphics.View View { get; init; }
/// <summary> /// <summary>
/// 是否仅渲染选中 /// 是否仅渲染选中
/// </summary> /// </summary>
[ReadOnly(true)] [ReadOnly(true)]
[Category("导出"), DisplayName("仅渲染选中"), Description("是否仅导出选中的模型")] [Category("导出"), DisplayName("仅渲染选中"), Description("是否仅导出选中的模型,请在预览画面参数面板进行调整")]
public required bool RenderSelectedOnly { get; init; } public required bool RenderSelectedOnly { get; init; }
/// <summary> /// <summary>