feat(uploader): uploader window, dialogs, tray icon and screenshot mode

Single 760x560 window after the Uploader mockup: header with server,
user, connection glyph and quota; first-run connect form with LAN
servers and a TOFU fingerprint dialog; drop zone with an IFileOpenDialog
browse menu (files or folder/card); target choice; queue line,
pause/stop and MB/s limit; progress and per-file states with retry;
watch-folder chips; options, with a destructive confirmation before
"Delete after upload"; in-window settings panel. Shell_NotifyIcon tray
icon (program icon, Show/Pause/Exit menu, balloon on completion), app
bootstrap with logging, language, theme, single instance hand-over, and
--capture rendering connect/queue/settings in dark and light from a
design-time sample provider.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 10:28:03 +00:00
1 parent 42d96c962d
commit 192fc7dcb3
15 files changed
+2572 -1

No files matched your search

@@ -0,0 +1,139 @@
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using Titano.Ui.Controls;
using Titano.Uploader.Infrastructure;
namespace Titano.Uploader.Shell;
/// <summary>The uploader's single window (mockup Uploader.html).</summary>
public sealed partial class MainWindow : TitanoWindow
{
private readonly MainViewModel _vm;
private readonly UploaderSettings _settings;
public MainWindow(MainViewModel vm, UploaderSettings settings)
{
_vm = vm;
_settings = settings;
DataContext = vm;
InitializeComponent();
vm.PendingToasts.CollectionChanged += OnToastRequested;
vm.PropertyChanged += OnViewModelChanged;
PreviewKeyDown += OnPreviewKeyDown;
RestorePlacement();
}
/// <summary>Remembers size and position (also when the window only hides to the tray).</summary>
public void SavePlacement()
{
var b = RestoreBounds;
if (b.IsEmpty || b.Width < MinWidth || b.Height < MinHeight) return;
_settings.Window = new UploaderSettings.WindowPlacement { Left = b.Left, Top = b.Top, Width = b.Width, Height = b.Height };
}
protected override void OnDragOver(DragEventArgs e)
{
var accepted = CanDrop(e);
e.Effects = accepted ? DragDropEffects.Copy : DragDropEffects.None;
SetDropHighlight(accepted);
e.Handled = true;
}
protected override void OnDragLeave(DragEventArgs e) => SetDropHighlight(false);
protected override void OnDrop(DragEventArgs e)
{
SetDropHighlight(false);
if (!CanDrop(e) || e.Data.GetData(DataFormats.FileDrop) is not string[] paths) return;
e.Handled = true;
_ = EnqueueAsync(paths);
}
private async Task EnqueueAsync(IReadOnlyList<string> paths)
{
try
{
await _vm.EnqueueAsync(paths);
}
catch (Exception ex)
{
// UI boundary: a drop must never take the window down.
_vm.ReportError(ex);
}
}
private bool CanDrop(DragEventArgs e) => !_vm.IsConnectVisible && e.Data.GetDataPresent(DataFormats.FileDrop);
private void SetDropHighlight(bool on)
{
DropBorder.SetResourceReference(Shape.StrokeProperty, on ? "Brush.Accent" : "Brush.Stroke");
if (on) DropBorder.SetResourceReference(Shape.FillProperty, "Brush.AccentSubtle");
else DropBorder.Fill = Brushes.Transparent;
}
private void OnBrowseClick(object sender, RoutedEventArgs e) => OpenMenu((Button)sender);
private void OnWatchChipClick(object sender, RoutedEventArgs e) => OpenMenu((Button)sender);
/// <summary>Opens a button's menu under it on a normal click.</summary>
private static void OpenMenu(Button button)
{
if (button.ContextMenu is not { } menu) return;
menu.DataContext = button.DataContext;
menu.PlacementTarget = button;
menu.Placement = PlacementMode.Bottom;
menu.IsOpen = true;
}
private void OnSequencesDropDownOpened(object? sender, EventArgs e) => _vm.RefreshSequencesCommand.Execute(null);
private void OnPasswordChanged(object sender, RoutedEventArgs e) => _vm.Connect.Password = Password.Password;
/// <summary>DESIGN §4 inputs: Enter commits, Esc reverts; Esc also closes the settings panel.</summary>
private void OnPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.OriginalSource is TextBox box && (e.Key is Key.Enter or Key.Escape) && box.GetBindingExpression(TextBox.TextProperty) is { } binding)
{
if (e.Key == Key.Enter) binding.UpdateSource();
else binding.UpdateTarget();
if (e.Key == Key.Escape) e.Handled = true;
return;
}
if (e.Key == Key.Escape && _vm.IsSettingsOpen)
{
_vm.IsSettingsOpen = false;
e.Handled = true;
}
}
private void OnViewModelChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(MainViewModel.CurrentItem) && _vm.CurrentItem is { } item) ItemList.ScrollIntoView(item);
if (e.PropertyName == nameof(MainViewModel.IsConnectVisible) && _vm.IsConnectVisible) Password.Clear();
}
private void OnToastRequested(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action != NotifyCollectionChangedAction.Add || e.NewItems is null) return;
foreach (Toast t in e.NewItems) Toasts.Show(t);
Dispatcher.BeginInvoke(() => _vm.PendingToasts.Clear());
}
private void RestorePlacement()
{
if (_settings.Window is not { } p || p.Width < MinWidth || p.Height < MinHeight) return;
var screen = new Rect(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop, SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight);
if (!screen.IntersectsWith(new Rect(p.Left, p.Top, p.Width, p.Height))) return;
WindowStartupLocation = WindowStartupLocation.Manual;
Left = p.Left;
Top = p.Top;
Width = p.Width;
Height = p.Height;
}
}