603af17e56
The repo carried two parallel UIs (WPF + WinUI) sharing Models/Services via
cross-directory Link includes. Now that WinUI is the only frontend, collapse
the structure so the WinUI project IS the repo root instead of a nested
sibling folder:
- Delete the WPF project entirely (App.xaml, MainWindow.xaml, csproj) and its
bin/obj output
- Move AmiReel.WinUI/* up to the repo root (App, MainWindow, MainPage,
DialogHelper, Assets, Package.appxmanifest, app.manifest, Properties,
.github/instructions, AGENTS.md) via git mv, preserving history
- Rename AmiReel.WinUI.csproj -> AmiReel.csproj; regenerate the solution as
AmiReel.slnx (the newer XML solution format) with a single project
- Rename namespace AmigaDB.VideoRenderer.{Models,Services} -> AmiReel.{...}
and AmiReel_WinUI -> AmiReel across all files, including the embedded
ffmpeg/ffprobe resource logical names in the csproj and ToolExtractor
- Models/ and Services/ no longer need the Link-based cross-directory
<Compile Include>; they're picked up by the SDK's default globbing now
that they live under the project directory
- Rename assets/ -> branding/ (source icon art) to avoid a case-insensitive
collision with Assets/ (packaged tile art) once both sit at repo root
- Merge the two .gitignore files into one; track the PublishProfiles pubxml
files instead of ignoring them (no secrets, and they keep publish
reproducible across machines) as branding, gitignore, etc.
- Simplify publish-win-x64.ps1 (drop the -Target Wpf/WinUI switch, there's
only one target now) and rewrite README.md to describe the single-project
layout, build/run/publish commands, and file structure
Verified: dotnet build succeeds for both AmiReel.csproj and AmiReel.slnx, and
the built exe launches and renders identically to before the move.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
117 lines
4.2 KiB
C#
117 lines
4.2 KiB
C#
using Microsoft.UI;
|
|
using Microsoft.UI.Windowing;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using System;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
using Windows.Graphics;
|
|
using Windows.UI;
|
|
using WinRT.Interop;
|
|
|
|
// To learn more about WinUI, the WinUI project structure,
|
|
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
|
|
|
namespace AmiReel;
|
|
|
|
/// <summary>
|
|
/// The application window. This hosts a Frame that displays pages. Add your
|
|
/// UI and logic to MainPage.xaml / MainPage.xaml.cs instead of here so you
|
|
/// can use Page features such as navigation events and the Loaded lifecycle.
|
|
/// </summary>
|
|
public sealed partial class MainWindow : Window
|
|
{
|
|
private bool _exitConfirmed;
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
App.MainWindowInstance = this;
|
|
|
|
ExtendsContentIntoTitleBar = true;
|
|
SetTitleBar(AppTitleBar);
|
|
|
|
string? executablePath = Environment.ProcessPath;
|
|
if (!string.IsNullOrWhiteSpace(executablePath) && File.Exists(executablePath))
|
|
AppWindow.SetIcon(executablePath);
|
|
|
|
SetDefaultSizeAndPosition();
|
|
|
|
// Navigate the root frame to the main page on startup.
|
|
RootFrame.Navigate(typeof(MainPage));
|
|
|
|
AppWindow.Closing += AppWindow_Closing;
|
|
}
|
|
|
|
private void SetDefaultSizeAndPosition()
|
|
{
|
|
const int DefaultWidth = 1280;
|
|
const int DefaultHeight = 860;
|
|
const int MinWidth = 1100;
|
|
const int MinHeight = 780;
|
|
|
|
IntPtr hwnd = WindowNative.GetWindowHandle(this);
|
|
double scale = GetDpiForWindow(hwnd) / 96.0;
|
|
int width = (int)(DefaultWidth * scale);
|
|
int height = (int)(DefaultHeight * scale);
|
|
|
|
AppWindow.Resize(new SizeInt32(width, height));
|
|
|
|
if (AppWindow.Presenter is OverlappedPresenter presenter)
|
|
{
|
|
presenter.PreferredMinimumWidth = (int)(MinWidth * scale);
|
|
presenter.PreferredMinimumHeight = (int)(MinHeight * scale);
|
|
}
|
|
|
|
DisplayArea? displayArea = DisplayArea.GetFromWindowId(Win32Interop.GetWindowIdFromWindow(hwnd), DisplayAreaFallback.Primary);
|
|
if (displayArea is not null)
|
|
{
|
|
int centerX = displayArea.WorkArea.X + (displayArea.WorkArea.Width - width) / 2;
|
|
int centerY = displayArea.WorkArea.Y + (displayArea.WorkArea.Height - height) / 2;
|
|
AppWindow.Move(new PointInt32(centerX, centerY));
|
|
}
|
|
}
|
|
|
|
[DllImport("user32.dll")]
|
|
private static extern int GetDpiForWindow(IntPtr hwnd);
|
|
|
|
public void ApplyTheme(bool isDark)
|
|
{
|
|
if (Content is FrameworkElement root)
|
|
root.RequestedTheme = isDark ? ElementTheme.Dark : ElementTheme.Light;
|
|
|
|
AppWindowTitleBar titleBar = AppWindow.TitleBar;
|
|
Color foreground = isDark ? Color.FromArgb(255, 0xF5, 0xF7, 0xFB) : Color.FromArgb(255, 0x12, 0x20, 0x33);
|
|
Color hoverBackground = isDark ? Color.FromArgb(255, 0x2E, 0x44, 0x6C) : Color.FromArgb(255, 0xD7, 0xE4, 0xF4);
|
|
|
|
titleBar.ButtonBackgroundColor = Colors.Transparent;
|
|
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
|
|
titleBar.ButtonForegroundColor = foreground;
|
|
titleBar.ButtonInactiveForegroundColor = foreground;
|
|
titleBar.ButtonHoverBackgroundColor = hoverBackground;
|
|
titleBar.ButtonHoverForegroundColor = foreground;
|
|
titleBar.ButtonPressedBackgroundColor = hoverBackground;
|
|
titleBar.ButtonPressedForegroundColor = foreground;
|
|
}
|
|
|
|
private async void AppWindow_Closing(AppWindow sender, AppWindowClosingEventArgs args)
|
|
{
|
|
if (_exitConfirmed) return;
|
|
args.Cancel = true;
|
|
|
|
FrameworkElement root = (FrameworkElement)Content;
|
|
ContentDialog dialog = DialogHelper.CreateStyled(RootFrame.XamlRoot, root.RequestedTheme);
|
|
dialog.Title = "Exit AmiReel?";
|
|
dialog.Content = "Are you sure you want to close the application?";
|
|
dialog.PrimaryButtonText = "Exit";
|
|
dialog.CloseButtonText = "Cancel";
|
|
dialog.DefaultButton = ContentDialogButton.Primary;
|
|
|
|
ContentDialogResult result = await dialog.ShowAsync();
|
|
if (result != ContentDialogResult.Primary) return;
|
|
|
|
_exitConfirmed = true;
|
|
Close();
|
|
}
|
|
}
|