1
0
Fork 0

fix(ui): resolve pack URI assembly prefixes, crash-proof dynamic resource brush lookups, and add MainWindow visual tree test
Some checks failed
Forgejo Release / build-and-release (push) Has been cancelled

This commit is contained in:
Yun Chan 2026-09-03 12:30:21 +09:00
parent c00c55f9e6
commit 41c8a8a94b
4 changed files with 44 additions and 17 deletions

View file

@ -4,7 +4,7 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
Title="FormatShift Utility"
Icon="pack://application:,,,/Assets/app-icon.png"
Icon="pack://application:,,,/Everything2Everything;component/Assets/app-icon.png"
Width="1280" Height="960"
MinWidth="1080" MinHeight="640"
ExtendsContentIntoTitleBar="True"
@ -75,7 +75,7 @@
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Image Width="22" Height="22"
RenderOptions.BitmapScalingMode="HighQuality"
Source="pack://application:,,,/Assets/logo-mark.png"/>
Source="pack://application:,,,/Everything2Everything;component/Assets/logo-mark.png"/>
<TextBlock Margin="9,0,0,0" FontSize="14" FontWeight="SemiBold"
Foreground="{StaticResource FsTextPrimary}"
FontFamily="{StaticResource FsFontSans}">
@ -211,7 +211,7 @@
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Image Width="15" Height="15" VerticalAlignment="Center" Margin="0,0,6,0"
RenderOptions.BitmapScalingMode="HighQuality"
Source="pack://application:,,,/Assets/glyph-ai.png"/>
Source="pack://application:,,,/Everything2Everything;component/Assets/glyph-ai.png"/>
<TextBlock Text="AI 작업" Style="{StaticResource FsLabelStyle}" VerticalAlignment="Center"/>
</StackPanel>
<ComboBox x:Name="AiTaskCombo" Margin="0,8,0,0"
@ -611,7 +611,7 @@
<Image Width="128" Height="128"
HorizontalAlignment="Center"
RenderOptions.BitmapScalingMode="HighQuality"
Source="pack://application:,,,/Assets/illus-empty.png"/>
Source="pack://application:,,,/Everything2Everything;component/Assets/illus-empty.png"/>
<TextBlock Margin="0,16,0,0" FontSize="16" FontWeight="SemiBold"
Foreground="{StaticResource FsTextPrimary}"
HorizontalAlignment="Center"

View file

@ -710,29 +710,33 @@ public partial class MainWindow : Wpf.Ui.Controls.FluentWindow
var entries = HistoryStorage.Load();
if (entries.Count == 0)
{
// 첫 실행: 데모 데이터로 시각적 가이드 제공
SeedDemoHistory();
UpdatePastResultsVisibility();
return;
}
// 가장 오래된 것부터 추가 (Insert(0)이 누적)
foreach (var e in entries.OrderBy(e => e.Timestamp))
AddToHistoryGroups(e);
UpdatePastResultsVisibility();
}
private Brush SafeBrush(string key) =>
(TryFindResource(key) as Brush) ?? (Application.Current?.TryFindResource(key) as Brush) ?? new SolidColorBrush(Color.FromRgb(0x10, 0xB9, 0x81));
private void SeedDemoHistory()
{
var today = FormatDateLabel(DateOnly.FromDateTime(DateTime.Today));
var todayGroup = new DateGroup(today);
todayGroup.Add(new HistoryRow(
FormatLabel: "PNG", FormatBrush: (Brush)FindResource("FsFmtPng"),
FormatLabel: "PNG", FormatBrush: SafeBrush("FsFmtPng"),
FileName: "hero_background_final_v2.png",
MetaLine: "08:42:12 • 3200x1800",
SizeText: "14.2 MB",
SavingsText: "↓ 1.1 MB",
SourcePath: "<demo>"));
todayGroup.Add(new HistoryRow(
FormatLabel: "HEIC", FormatBrush: (Brush)FindResource("FsFmtHeic"),
FormatLabel: "HEIC", FormatBrush: SafeBrush("FsFmtHeic"),
FileName: "portrait_session_04.heic",
MetaLine: "08:35:45 • 4032x3024",
SizeText: "6.8 MB",
@ -744,14 +748,14 @@ public partial class MainWindow : Wpf.Ui.Controls.FluentWindow
var yesterday = FormatDateLabel(DateOnly.FromDateTime(DateTime.Today.AddDays(-1)));
var yGroup = new DateGroup(yesterday);
yGroup.Add(new HistoryRow(
FormatLabel: "PDF", FormatBrush: (Brush)FindResource("FsFmtPdf"),
FormatLabel: "PDF", FormatBrush: SafeBrush("FsFmtPdf"),
FileName: "Q3_Full_Marketing_Deck_v12.pdf",
MetaLine: "17:22:10 • 124 Pages",
SizeText: "245.4 MB",
SavingsText: "↓ 12.8 MB",
SourcePath: "<demo>"));
yGroup.Add(new HistoryRow(
FormatLabel: "PNG", FormatBrush: (Brush)FindResource("FsFmtPng"),
todayGroup.Add(new HistoryRow(
FormatLabel: "PNG", FormatBrush: SafeBrush("FsFmtPng"),
FileName: "asset_bundle_archive_raw.png",
MetaLine: "16:45:33 • 8000x8000",
SizeText: "82.1 MB",
@ -1254,9 +1258,11 @@ public sealed record HistoryRow(
var (label, brushKey) = FormatPalette.For(ext);
var saved = e.SavingsBytes;
var arrow = saved >= 0 ? "↓" : "↑";
var brush = (Application.Current?.TryFindResource(brushKey) as Brush)
?? new SolidColorBrush(Color.FromRgb(0x10, 0xB9, 0x81));
return new HistoryRow(
FormatLabel: label,
FormatBrush: (Brush)Application.Current.FindResource(brushKey),
FormatBrush: brush,
FileName: Path.GetFileName(e.SourcePath),
MetaLine: $"{e.Timestamp:HH:mm:ss} • {e.OutputCount} output(s)",
SizeText: MainWindow.HumanizeBytes(e.SourceSizeBytes),

View file

@ -53,6 +53,28 @@ public class DesignAuditVisualTreeTests
}
}
[Fact]
public void MainWindow_MeasureAndArrange_HasValidLayoutBounds()
{
RunOnSta(() =>
{
var engine = Everything2EverythingBootstrap.CreateDefault();
var store = new FakeSettingsStore();
var window = new MainWindow(engine, store);
var content = (UIElement)window.Content;
content.Measure(new Size(1200, 800));
content.Arrange(new Rect(0, 0, 1200, 800));
Assert.False(double.IsNaN(content.DesiredSize.Width));
Assert.False(double.IsNaN(content.DesiredSize.Height));
Assert.True(content.DesiredSize.Width > 0);
Assert.True(content.DesiredSize.Height > 0);
var buttons = FindLogicalChildren<ButtonBase>(window).ToList();
Assert.NotEmpty(buttons);
});
}
[Fact]
public void DiagnoseWindow_MeasureAndArrange_HasValidLayoutBounds()
{