The Library gets a third layout (year bands of photos per month over the card grid; a month narrows to its year and scrolls to it), saved views stored as app-scope settings rows, hover quick actions on cards and rows (open, analyse, render the sequence's preset, sync), the full mass actions bar (analyse, proxies, verify, tags, rating, move, upload, download, delete into the trash, CSV) with each button's reason when it cannot run, and, while signed in, the server's sequences without a local copy as remote cards filterable by origin. Delete shows the engine's dry run behind a typed confirmation and offers Undo; the Archive manager gets Delete… and a Trash dialog that restores sequences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
66 lines
2.5 KiB
C#
66 lines
2.5 KiB
C#
using System.ComponentModel;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls.Primitives;
|
|
using System.Windows.Input;
|
|
using System.Windows.Threading;
|
|
using Titano.App.Library;
|
|
using Titano.Ui.Visuals;
|
|
|
|
namespace Titano.App.Sections;
|
|
|
|
public partial class LibraryView : UserControl
|
|
{
|
|
public LibraryView()
|
|
{
|
|
InitializeComponent();
|
|
DataContextChanged += OnDataContextChanged;
|
|
}
|
|
|
|
private LibraryViewModel? Model => DataContext as LibraryViewModel;
|
|
|
|
/// <summary>Loads the next page when the grid or the list scrolls within two screens of its end.</summary>
|
|
private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
|
|
{
|
|
if (Model is not { } vm || e.ExtentHeight <= 0) return;
|
|
if (e.VerticalOffset + e.ViewportHeight >= e.ExtentHeight - 2 * Math.Max(e.ViewportHeight, 200)) _ = vm.LoadMoreAsync();
|
|
}
|
|
|
|
/// <summary>A month of the timeline: the Library narrows to its year and the grid scrolls to it.</summary>
|
|
private void OnSlotActivated(object sender, ChartItemEventArgs e) => Model?.ShowMonth(e.Row, e.Column);
|
|
|
|
/// <summary>"Saved views" and "Rate ▾" open their menu under themselves.</summary>
|
|
private void OnOpenMenu(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender is not Button { ContextMenu: { } menu } button) return;
|
|
menu.DataContext = DataContext;
|
|
menu.PlacementTarget = button;
|
|
menu.Placement = PlacementMode.Bottom;
|
|
menu.IsOpen = true;
|
|
}
|
|
|
|
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
if (e.OldValue is LibraryViewModel old)
|
|
{
|
|
old.ScrollRequested -= OnScrollRequested;
|
|
old.PropertyChanged -= OnModelChanged;
|
|
}
|
|
if (e.NewValue is LibraryViewModel model)
|
|
{
|
|
model.ScrollRequested += OnScrollRequested;
|
|
model.PropertyChanged += OnModelChanged;
|
|
}
|
|
}
|
|
|
|
private void OnScrollRequested(SequenceItem item) =>
|
|
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () => CardGrid.ScrollIntoView(item));
|
|
|
|
/// <summary>A dialog that opens takes the keyboard: its first field or button.</summary>
|
|
private void OnModelChanged(object? sender, PropertyChangedEventArgs e)
|
|
{
|
|
if (e.PropertyName != nameof(LibraryViewModel.Dialog) || Model?.Dialog is null || !IsVisible) return;
|
|
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
|
|
}
|
|
}
|