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,171 @@
using System.ComponentModel;
using System.Globalization;
using System.Runtime.CompilerServices;
using Titano.Protocol;
using Titano.Uploader.Infrastructure;
using Titano.Uploader.Server;
using Titano.Uploader.Shell;
using Titano.Uploader.Uploads;
using Titano.Uploader.Watching;
namespace Titano.Uploader.DesignTime;
/// <summary>
/// Sample content for <c>--capture</c> screenshots ONLY: a fake signed-in session, a running queue of 4,812 files
/// and two watch folders. Nothing here touches the network, the registry or the user's data files.
/// </summary>
public sealed class SampleData
{
private const int FileCount = 4_812;
private const long FileSize = 20_000_000;
private readonly SampleSession _session = new();
private readonly UploadQueue _queue = new();
private MainViewModel? _vm;
public UploaderSettings Settings { get; } = new()
{
ServerUrl = "https://nas.local:8443/",
Username = "alberto",
BandwidthLimit = 50,
MinimizeToTray = true,
WatchFolders =
[
new UploaderSettings.WatchFolderSettings { Path = @"D:\Cam\Roof", IntervalSeconds = 60 },
new UploaderSettings.WatchFolderSettings { Path = @"\\garage-pi\cam", IntervalSeconds = 300 },
],
};
/// <summary>A view model over in-memory sample services; settings changes are discarded.</summary>
public MainViewModel CreateViewModel()
{
var memory = new ProcessedFileMemory();
_session.BandwidthLimit = Settings.BandwidthLimit;
_vm = new MainViewModel(new UploaderServices(
Settings, () => { }, _session, _queue, new SampleEngine(_queue), new SampleStartup(), new UploaderDialogs(),
new WatchFolderService(memory, _queue.ContainsPath), memory, string.Empty));
foreach (var w in _vm.WatchFolders) w.IsAvailable = true;
return _vm;
}
/// <summary>First run: no server yet, one server found on the LAN.</summary>
public void ShowConnect()
{
_session.SetState(ConnectionState.NotConfigured);
_vm!.Connect.Address = string.Empty;
_vm.Connect.Username = string.Empty;
_vm.Connect.Discovered.Clear();
_vm.Connect.Discovered.Add(new DiscoveredServer("Studio NAS", "https://192.168.1.20:8443"));
}
/// <summary>Signed in, a card being uploaded at 38 MB/s.</summary>
public void ShowQueue()
{
_session.SetState(ConnectionState.Connected);
if (_queue.Items.Count == 0) FillQueue();
_vm!.Sequences.Clear();
_vm.Sequences.Add(new SequenceOption(Guid.Empty, "Harbour sunset"));
_vm.SelectedSequence = _vm.Sequences[0];
_vm.RefreshQueue();
}
private void FillQueue()
{
var batch = new UploadBatch { Id = Guid.CreateVersion7(), Mode = UploadTargetMode.Sessions };
var start = new DateTime(2026, 9, 28, 15, 22, 0);
_queue.Add(batch, Enumerable.Range(0, FileCount).Select(i =>
{
var shot = start.AddSeconds(i * 5);
var name = shot.ToString("yyyy-MM-dd_HH-mm-ss", CultureInfo.InvariantCulture) + "_" + (i + 1).ToString("0000", CultureInfo.InvariantCulture) + ".CR2";
return new QueueEntry(@"E:\DCIM\100CANON\" + name, FileSize, shot.ToUniversalTime(), shot, "1a2b3c4d-20260928-152200", null);
}));
for (var i = 0; i < 2_201; i++) _queue.Items[i].State = i % 200 == 7 ? UploadItemState.Skipped : UploadItemState.Verified;
_queue.Items[1_640].Retries = 1;
_queue.Items[2_201].State = UploadItemState.Uploading;
_queue.Items[2_201].BytesSent = FileSize * 46 / 100;
_queue.Items[2_202].State = UploadItemState.Hashing;
_queue.Fail(_queue.Items[2_203], UploadFailure.FileUnreadable, null, DateTime.UtcNow);
}
private sealed class SampleSession : IServerSession
{
private ConnectionState _state = ConnectionState.Connected;
public event PropertyChangedEventHandler? PropertyChanged;
public event EventHandler<ServerProblem>? SessionEnded
{
add { }
remove { }
}
public ConnectionState State => _state;
public string? Address => "https://nas.local:8443/";
public string? Username => "alberto";
public long QuotaBytes => 5_000_000_000_000;
public long UsedBytes => 3_100_000_000_000;
public int BandwidthLimit { get; set; }
public void SetState(ConnectionState state)
{
_state = state;
Raise(nameof(State));
}
public Task<(SignInResult Result, string? Fingerprint)> SignInAsync(string address, string username, string password, CancellationToken ct) =>
Task.FromResult<(SignInResult, string?)>((SignInResult.Failed, null));
public void Trust(string fingerprint)
{
}
public Task SignOutAsync() => Task.CompletedTask;
public Task RefreshAsync() => Task.CompletedTask;
public Task<IReadOnlyList<SequenceDto>> ListSequencesAsync(CancellationToken ct) => Task.FromResult<IReadOnlyList<SequenceDto>>([]);
private void Raise([CallerMemberName] string? name = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
private sealed class SampleEngine(UploadQueue queue) : IUploadEngine
{
public event PropertyChangedEventHandler? PropertyChanged
{
add { }
remove { }
}
public event EventHandler? Drained
{
add { }
remove { }
}
public EngineStatus Status => queue.IsPaused ? EngineStatus.Paused : EngineStatus.Running;
public double BytesPerSecond => 38_000_000;
public void Pump()
{
}
public void Pause() => queue.IsPaused = true;
public void Resume() => queue.IsPaused = false;
public void StopAndClear()
{
}
public void Retry(UploadItem item)
{
}
}
private sealed class SampleStartup : IStartupRegistration
{
public bool IsEnabled { get; private set; } = true;
public void SetEnabled(bool enabled) => IsEnabled = enabled;
}
}