feat(app): Import and Archive manager screens with capture scenes and resources
Import (cards and folders): the card pool with remembered profiles and the nickname field for new cards, the form (destination, scan, sessions, names with live preview and tokens, duplicates, after-import choices), the plan panel with editable session titles, Show plan, the archive import job or the folder/server run with progress, the verification result and the after-import actions (dry run, delete, format through the Windows dialog, eject, open in Library), card-insertion toasts, automatic import into the archive and resume after re-insertion. Deep analysis after import is queued with ProcessingJobs at background priority. Archive manager: archive picker, tree with availability, figure tiles and charts, mass operations on the selected set, scan/rebuild (dialog)/verify/ duplicates/orphans/adopt/maintenance as jobs, and the maintenance view with index health, recent runs and the duplicate and orphan reports with safe fixes. --capture renders import-<state> and archive-<view> from a simulated card and sample reports; en and it resources for both screens. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
31 files changed
+4531
-28
No files matched your search
@@ -3,6 +3,7 @@ using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using Titano.App.About;
|
||||
using Titano.App.Import;
|
||||
using Titano.App.Jobs;
|
||||
using Titano.App.Library;
|
||||
using Titano.App.Server;
|
||||
@@ -86,6 +87,9 @@ public sealed class AppServices : IAsyncDisposable
|
||||
|
||||
public IEncoderInventory Encoders { get; set; }
|
||||
|
||||
/// <summary>Card detection, eject and format (BRIEF §13); started with the index, replaced by a fake in capture.</summary>
|
||||
public IDeviceMonitor Devices { get; set; } = new WindowsDeviceMonitor();
|
||||
|
||||
/// <summary>Latest public release (GitHub Releases API of the releases repository, BRIEF §18).</summary>
|
||||
public Func<CancellationToken, Task<ReleaseInfo?>> CheckForUpdateAsync { get; set; }
|
||||
|
||||
@@ -155,6 +159,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
}
|
||||
await StartJobsAsync(Database, startEngine: true, ct);
|
||||
Thumbnails = new ThumbnailService(Database, Settings.ThumbnailMemoryItems);
|
||||
Devices.Start();
|
||||
if (Settings.LastArchivePath is { Length: > 0 } root) _polling = PollAsync(root, _stopping.Token);
|
||||
}
|
||||
|
||||
@@ -177,6 +182,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
(Jobs as IDisposable)?.Dispose();
|
||||
if (Engine is not null) await Engine.DisposeAsync();
|
||||
Thumbnails?.Dispose();
|
||||
Devices.Dispose();
|
||||
Server.Dispose();
|
||||
if (Database is not null) await Database.DisposeAsync();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,12 @@ public sealed record ConfirmRequest
|
||||
|
||||
/// <summary>Warning-outlined action (never a primary) for data-destroying choices.</summary>
|
||||
public bool IsDestructive { get; init; }
|
||||
|
||||
/// <summary>Text the user must type before the action enables (formatting a card: its name); null asks no typing.</summary>
|
||||
public string? TypedConfirmation { get; init; }
|
||||
|
||||
/// <summary>Label of the typing field ("Type the card name to confirm").</summary>
|
||||
public string? TypedPrompt { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>Modal questions and OS pickers the view models ask for (BRIEF §12.1: modals only for confirmations and login).</summary>
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using Titano.App.Import;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Windows.Devices;
|
||||
|
||||
namespace Titano.App.Infrastructure;
|
||||
|
||||
/// <summary>
|
||||
/// Card detection on this PC (BRIEF §13): <see cref="RemovableVolumeWatcher"/> (WM_DEVICECHANGE plus a 3-second poll),
|
||||
/// safe removal through <see cref="VolumeEjector"/> and formatting only through the Windows format dialog
|
||||
/// (<see cref="FormatDialog"/>, BRIEF §8.6).
|
||||
/// </summary>
|
||||
public sealed class WindowsDeviceMonitor : IDeviceMonitor
|
||||
{
|
||||
private RemovableVolumeWatcher? _watcher;
|
||||
|
||||
public event Action<CardDevice>? Arrived;
|
||||
|
||||
public event Action<CardDevice>? Removed;
|
||||
|
||||
public IReadOnlyList<CardDevice> Devices => _watcher is { } watcher ? [.. watcher.Volumes.Select(Map)] : [];
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (_watcher is not null) return;
|
||||
var watcher = new RemovableVolumeWatcher();
|
||||
watcher.VolumeArrived += (_, e) => Arrived?.Invoke(Map(e.Volume));
|
||||
watcher.VolumeRemoved += (_, e) => Removed?.Invoke(Map(e.Volume));
|
||||
try
|
||||
{
|
||||
watcher.Start();
|
||||
_watcher = watcher;
|
||||
}
|
||||
catch (Win32Exception ex)
|
||||
{
|
||||
// Without the watcher cards are still listed by "Folder…"; nothing else depends on it.
|
||||
Log.Warning("devices", "Card detection is unavailable", ex);
|
||||
watcher.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public EjectOutcome Eject(CardDevice device) => VolumeEjector.Eject(device.Root[0]) switch
|
||||
{
|
||||
EjectResult.Ejected => EjectOutcome.Ejected,
|
||||
EjectResult.InUse => EjectOutcome.InUse,
|
||||
_ => EjectOutcome.Failed,
|
||||
};
|
||||
|
||||
public FormatOutcome Format(CardDevice device)
|
||||
{
|
||||
var owner = Application.Current?.MainWindow is { } window ? new WindowInteropHelper(window).Handle : 0;
|
||||
try
|
||||
{
|
||||
return FormatDialog.Show(owner, device.Root[0]) switch
|
||||
{
|
||||
FormatDialogResult.Formatted => FormatOutcome.Formatted,
|
||||
FormatDialogResult.Cancelled => FormatOutcome.Cancelled,
|
||||
_ => FormatOutcome.Failed,
|
||||
};
|
||||
}
|
||||
catch (Exception ex) when (ex is ArgumentException or InvalidOperationException)
|
||||
{
|
||||
Log.Warning("devices", $"The format dialog cannot open for {device.Root}", ex);
|
||||
return FormatOutcome.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose() => _watcher?.Dispose();
|
||||
|
||||
private static CardDevice Map(VolumeInfo v) =>
|
||||
new(v.RootPath, v.Label, v.SerialNumber, v.TotalBytes, v.FreeBytes, v.DriveType == VolumeDriveType.Removable, v.HasDcim);
|
||||
}
|
||||
Reference in new issue
Block a user