feat(app): library, jobs, settings, server, welcome and about screens
Local-mode composition root (SQLite index, one JobEngine fed by a single handler registration list), keyset-paged library with thumbnail cache and hover scrub, live job list with throttled updates and the shell job bar, settings with live template validation and encoder self-test, server connection with trust-on-first-use and DPAPI token, first-run welcome, About with update check, and --capture screenshots with synthetic data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
94 files changed
+10130
-374
No files matched your search
@@ -0,0 +1,192 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Titano.App.Interop;
|
||||
|
||||
/// <summary>A filter of the Open dialog: display name and patterns such as <c>*.jpg;*.cr2</c>.</summary>
|
||||
public readonly record struct FileFilter(string Name, string Patterns);
|
||||
|
||||
/// <summary>
|
||||
/// The shell's Open dialog through <c>IFileOpenDialog</c> COM (no WinForms): one or several files, or one folder
|
||||
/// (which also picks a card root such as <c>E:\</c>). Same wrapper as the uploader's (kept per program so neither
|
||||
/// depends on the other).
|
||||
/// </summary>
|
||||
public static class FileDialogs
|
||||
{
|
||||
private const uint FosPickFolders = 0x20;
|
||||
private const uint FosForceFileSystem = 0x40;
|
||||
private const uint FosAllowMultiSelect = 0x200;
|
||||
private const uint FosPathMustExist = 0x800;
|
||||
private const uint FosFileMustExist = 0x1000;
|
||||
private const uint SigdnFileSysPath = 0x80058000;
|
||||
private const int ErrorCancelled = unchecked((int)0x800704C7);
|
||||
|
||||
/// <summary>Selected files; empty when cancelled.</summary>
|
||||
public static IReadOnlyList<string> PickFiles(IntPtr owner, string title, IReadOnlyList<FileFilter> filters) =>
|
||||
Show(owner, title, FosAllowMultiSelect | FosFileMustExist, filters);
|
||||
|
||||
/// <summary>One selected file; null when cancelled.</summary>
|
||||
public static string? PickFile(IntPtr owner, string title, IReadOnlyList<FileFilter> filters) =>
|
||||
Show(owner, title, FosFileMustExist, filters).FirstOrDefault();
|
||||
|
||||
/// <summary>Selected folder; null when cancelled.</summary>
|
||||
public static string? PickFolder(IntPtr owner, string title) => Show(owner, title, FosPickFolders, []).FirstOrDefault();
|
||||
|
||||
private static List<string> Show(IntPtr owner, string title, uint options, IReadOnlyList<FileFilter> filters)
|
||||
{
|
||||
var dialog = (IFileOpenDialog)new FileOpenDialogClass();
|
||||
try
|
||||
{
|
||||
dialog.GetOptions(out var current);
|
||||
dialog.SetOptions(current | options | FosForceFileSystem | FosPathMustExist);
|
||||
dialog.SetTitle(title);
|
||||
if (filters.Count > 0)
|
||||
{
|
||||
var specs = filters.Select(f => new FilterSpec { Name = f.Name, Spec = f.Patterns }).ToArray();
|
||||
dialog.SetFileTypes((uint)specs.Length, specs);
|
||||
dialog.SetFileTypeIndex(1);
|
||||
}
|
||||
var hr = dialog.Show(owner);
|
||||
if (hr == ErrorCancelled) return [];
|
||||
Marshal.ThrowExceptionForHR(hr);
|
||||
|
||||
dialog.GetResults(out var items);
|
||||
try
|
||||
{
|
||||
items.GetCount(out var count);
|
||||
var paths = new List<string>((int)count);
|
||||
for (uint i = 0; i < count; i++)
|
||||
{
|
||||
items.GetItemAt(i, out var item);
|
||||
try
|
||||
{
|
||||
item.GetDisplayName(SigdnFileSysPath, out var path);
|
||||
paths.Add(path);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.ReleaseComObject(item);
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.ReleaseComObject(items);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.ReleaseComObject(dialog);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
private struct FilterSpec
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string Name;
|
||||
|
||||
[MarshalAs(UnmanagedType.LPWStr)]
|
||||
public string Spec;
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
[Guid("DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7")]
|
||||
private class FileOpenDialogClass;
|
||||
|
||||
// Classic COM interop does not inherit vtables: IModalWindow and IFileDialog members are repeated in order.
|
||||
[ComImport]
|
||||
[Guid("d57c7288-d4ad-4768-be02-9d969532d960")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IFileOpenDialog
|
||||
{
|
||||
[PreserveSig]
|
||||
int Show(IntPtr owner);
|
||||
|
||||
void SetFileTypes(uint count, [In, MarshalAs(UnmanagedType.LPArray)] FilterSpec[] filters);
|
||||
|
||||
void SetFileTypeIndex(uint index);
|
||||
|
||||
void GetFileTypeIndex(out uint index);
|
||||
|
||||
void Advise(IntPtr events, out uint cookie);
|
||||
|
||||
void Unadvise(uint cookie);
|
||||
|
||||
void SetOptions(uint options);
|
||||
|
||||
void GetOptions(out uint options);
|
||||
|
||||
void SetDefaultFolder(IShellItem item);
|
||||
|
||||
void SetFolder(IShellItem item);
|
||||
|
||||
void GetFolder(out IShellItem item);
|
||||
|
||||
void GetCurrentSelection(out IShellItem item);
|
||||
|
||||
void SetFileName([MarshalAs(UnmanagedType.LPWStr)] string name);
|
||||
|
||||
void GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string name);
|
||||
|
||||
void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string title);
|
||||
|
||||
void SetOkButtonLabel([MarshalAs(UnmanagedType.LPWStr)] string text);
|
||||
|
||||
void SetFileNameLabel([MarshalAs(UnmanagedType.LPWStr)] string label);
|
||||
|
||||
void GetResult(out IShellItem item);
|
||||
|
||||
void AddPlace(IShellItem item, int placement);
|
||||
|
||||
void SetDefaultExtension([MarshalAs(UnmanagedType.LPWStr)] string extension);
|
||||
|
||||
void Close(int hr);
|
||||
|
||||
void SetClientGuid(ref Guid guid);
|
||||
|
||||
void ClearClientData();
|
||||
|
||||
void SetFilter(IntPtr filter);
|
||||
|
||||
void GetResults(out IShellItemArray items);
|
||||
|
||||
void GetSelectedItems(out IShellItemArray items);
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IShellItem
|
||||
{
|
||||
void BindToHandler(IntPtr bindContext, ref Guid handler, ref Guid iid, out IntPtr result);
|
||||
|
||||
void GetParent(out IShellItem parent);
|
||||
|
||||
void GetDisplayName(uint form, [MarshalAs(UnmanagedType.LPWStr)] out string name);
|
||||
|
||||
void GetAttributes(uint mask, out uint attributes);
|
||||
|
||||
void Compare(IShellItem other, uint hint, out int order);
|
||||
}
|
||||
|
||||
[ComImport]
|
||||
[Guid("b63ea76d-1f85-456f-a19c-48159efa858b")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IShellItemArray
|
||||
{
|
||||
void BindToHandler(IntPtr bindContext, ref Guid handler, ref Guid iid, out IntPtr result);
|
||||
|
||||
void GetPropertyStore(int flags, ref Guid iid, out IntPtr store);
|
||||
|
||||
void GetPropertyDescriptionList(IntPtr keyType, ref Guid iid, out IntPtr list);
|
||||
|
||||
void GetAttributes(int flags, uint mask, out uint attributes);
|
||||
|
||||
void GetCount(out uint count);
|
||||
|
||||
void GetItemAt(uint index, out IShellItem item);
|
||||
|
||||
void EnumItems(out IntPtr items);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user