- a card that leaves needs a new check; formatting re-lists the card and refuses one that changed since its check; files that are not photos are named in the format confirmation - an import never stays stuck in Running; Retry never resumes an older job - server imports list refused files and keep what was uploaded when stopped - the archive result matches each copy to its job's record and shows the job's own error per file - refreshing devices keeps typed titles and choices; titles lock while copying - three destination names, merge and split of sessions, camera profiles shared by the cards of a camera, photo counts and a new-card toast - disabled controls say why; keyboard focus follows the nickname field and Show plan (Esc closes it); label column fits longer languages - capture states for insertion, running, failed and a new card Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
63 lines
2.5 KiB
C#
63 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;
|
|
|
|
namespace Titano.App.Sections;
|
|
|
|
public partial class ImportView : UserControl
|
|
{
|
|
private bool _nicknameOpen;
|
|
|
|
public ImportView()
|
|
{
|
|
InitializeComponent();
|
|
DataContextChanged += OnDataContextChanged;
|
|
}
|
|
|
|
private ImportViewModel? Model => DataContext as ImportViewModel;
|
|
|
|
/// <summary>"Edit ▾" and "{ }" 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;
|
|
}
|
|
|
|
/// <summary>The "{ }" menu writes into the template field used last.</summary>
|
|
private void OnFolderTemplateFocus(object sender, KeyboardFocusChangedEventArgs e) => Model?.SetActiveTemplate(folder: true);
|
|
|
|
private void OnFileTemplateFocus(object sender, KeyboardFocusChangedEventArgs e) => Model?.SetActiveTemplate(folder: false);
|
|
|
|
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
if (e.OldValue is INotifyPropertyChanged old) old.PropertyChanged -= OnModelChanged;
|
|
if (e.NewValue is INotifyPropertyChanged model) model.PropertyChanged += OnModelChanged;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Keyboard focus follows what opens: the nickname field when it appears (a new card, Rename), and "Show plan"
|
|
/// (focus returns to its button when it closes).
|
|
/// </summary>
|
|
private void OnModelChanged(object? sender, PropertyChangedEventArgs e)
|
|
{
|
|
if (Model is not { } model) return;
|
|
if (e.PropertyName is nameof(ImportViewModel.IsNicknameOpen) or "")
|
|
{
|
|
var opened = model.IsNicknameOpen && !_nicknameOpen;
|
|
_nicknameOpen = model.IsNicknameOpen;
|
|
if (opened && IsVisible) FocusLater(NicknameBox);
|
|
}
|
|
if (e.PropertyName is nameof(ImportViewModel.IsDetailsOpen) && IsVisible)
|
|
FocusLater(model.IsDetailsOpen ? ClosePlanButton : ShowPlanButton);
|
|
}
|
|
|
|
/// <summary>After layout: an element that just became visible cannot take focus yet.</summary>
|
|
private void FocusLater(UIElement element) => Dispatcher.BeginInvoke(DispatcherPriority.Input, () => element.Focus());
|
|
}
|