merge: integration branch claude/keen-knuth-uhxv8w (Archive manager and UI kit review) into the Library workstream

The Archive manager's reviewed dialogs (live status lines, one-sentence
errors, growing label columns, left-to-right paths) move into the shared
ArchiveDialogs.xaml with their styles, so the Library's Delete and the
Trash dialog use them too. Delete, Restore and Rate failures read as one
sentence through ArchiveFailures, which now knows a stale delete plan, a
newer sidecar and a sequence already back in the library
(SequenceInLibraryException). The confirmation's plan lines in the UI font
follow the reading direction; fingerprints stay left to right.

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-06 20:36:02 +00:00
commit 9f7907d903
77 files changed
+1966 -468

No files matched your search

@@ -16,13 +16,15 @@ namespace Titano.App.Archiving;
/// <summary>
/// An in-window dialog of the Archive screen: one primary action, one way out. While its action runs, the way out
/// stops it when it can be stopped, and is disabled otherwise; the close callback receives the dialog, so a late close
/// never closes another one.
/// never closes another one. A failure stays on screen as one sentence until the next attempt.
/// </summary>
public abstract class ArchiveDialogViewModel : LocalizedViewModel
{
private readonly Action<ArchiveDialogViewModel> _close;
private bool _isBusy;
private string? _busyText;
private string? _errorText;
private string? _errorToolTip;
protected ArchiveDialogViewModel(Action<ArchiveDialogViewModel> close)
{
@@ -61,11 +63,32 @@ public abstract class ArchiveDialogViewModel : LocalizedViewModel
public string? BusyText { get => _busyText; protected set => Set(ref _busyText, value); }
/// <summary>Why the last dry run or apply stopped (<see cref="ArchiveFailures.Cause"/>); null when nothing failed.</summary>
public string? ErrorText { get => _errorText; private set => Set(ref _errorText, value); }
/// <summary>The failure as the engine reported it, for the tooltip.</summary>
public string? ErrorToolTip { get => _errorToolTip; private set => Set(ref _errorToolTip, value); }
protected void Close() => _close(this);
protected void ShowError(Exception ex)
{
ErrorText = ArchiveFailures.Cause(ex);
ErrorToolTip = ex.Message;
}
protected void ClearError()
{
ErrorText = null;
ErrorToolTip = null;
}
}
/// <summary>A fact of the rebuild dialog ("Sidecars · 412").</summary>
public sealed record DialogFact(string Label, string Value);
/// <summary>A fact of the rebuild dialog ("Sidecars · 412"); a path stays left to right, a missing value says why in its tooltip.</summary>
public sealed record DialogFact(string Label, string Value, bool IsPath = false, string? Reason = null)
{
public string ToolTip => Reason ?? Value;
}
/// <summary>
/// "Rebuild index" (BRIEF §12.5): what the rebuild reads — the sidecars on disk, then a full metadata scan of folders
@@ -84,7 +107,7 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
Archive = archive;
Availability = availability;
Indexed = indexed;
_facts = Facts(null);
_facts = Facts(null, availability == ArchiveAvailability.Offline ? Loc.L("Archive.Error.Offline", Formatting.LeftToRight(archive.RootPath)) : null);
RebuildCommand = new AsyncRelayCommand(RebuildAsync, () => !IsBusy && availability == ArchiveAvailability.Online);
}
@@ -98,7 +121,10 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
public string RebuildToolTip => Availability == ArchiveAvailability.Online ? Loc.L("Tooltips.Archive.RebuildStart") : Loc.L("Archive.Blocked.NotOnline");
/// <summary>Counts sequence folders with and without a sidecar (a walk of the archive tree, off the UI thread).</summary>
/// <summary>
/// Counts sequence folders with and without a sidecar (a walk of the archive tree, off the UI thread). The counts
/// read "Counting…" only while the walk runs; an offline archive or a failed walk leaves "—" with the reason.
/// </summary>
public async Task CountAsync()
{
if (Availability == ArchiveAvailability.Offline) return;
@@ -107,11 +133,12 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
{
var root = Archive.RootPath;
var folders = await Task.Run(() => ArchiveScanner.FindSequenceFolders(new ArchivePaths(root)));
FactRows = Facts(folders);
FactRows = Facts(folders, null);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
Log.Warning("archive", "Counting sidecars failed", ex);
FactRows = Facts(null, ArchiveFailures.Cause(ex));
}
finally
{
@@ -120,19 +147,24 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
}
/// <summary>Shows counts computed elsewhere (capture).</summary>
public void ShowFolders(IReadOnlyList<SequenceFolder> folders) => FactRows = Facts(folders);
public void ShowFolders(IReadOnlyList<SequenceFolder> folders) => FactRows = Facts(folders, null);
private IReadOnlyList<DialogFact> Facts(IReadOnlyList<SequenceFolder>? folders)
/// <param name="folders">The counted folders; null while counting or when they cannot be counted.</param>
/// <param name="uncounted">Why the folders cannot be counted; null while counting.</param>
private IReadOnlyList<DialogFact> Facts(IReadOnlyList<SequenceFolder>? folders, string? uncounted)
{
var waiting = Loc.L("Archive.Rebuild.Counting");
DialogFact Count(string label, Func<SequenceFolder, bool> counted) =>
folders is not null ? new(label, Formatting.Count(folders.Count(counted)))
: uncounted is not null ? new(label, "—", Reason: uncounted)
: new(label, Loc.L("Archive.Rebuild.Counting"));
return
[
new(Loc.L("Archive.Rebuild.Archive"), Archive.Name),
new(Loc.L("Archive.Rebuild.Root"), Archive.RootPath),
new(Loc.L("Archive.Rebuild.Root"), Archive.RootPath, IsPath: true),
new(Loc.L("Archive.Rebuild.State"), Loc.L("Archive.Availability." + Availability)),
new(Loc.L("Archive.Rebuild.Indexed"), Loc.Plural("Shell.Status.Sequences", Indexed)),
new(Loc.L("Archive.Rebuild.Sidecars"), folders is null ? waiting : Formatting.Count(folders.Count(f => f.Sidecar is not null))),
new(Loc.L("Archive.Rebuild.Metadata"), folders is null ? waiting : Formatting.Count(folders.Count(f => f.Sidecar is null))),
Count(Loc.L("Archive.Rebuild.Sidecars"), f => f.Sidecar is not null),
Count(Loc.L("Archive.Rebuild.Metadata"), f => f.Sidecar is null),
];
}
@@ -163,6 +195,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
private readonly Func<int, Task> _applied;
private readonly DispatcherTimer _delay = new() { Interval = TimeSpan.FromMilliseconds(400) };
private RenamePlan? _plan;
private string? _planError;
private IReadOnlyList<RenameRow> _rows = [];
private CancellationTokenSource? _planning;
@@ -196,7 +229,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
private string? ApplyBlocker =>
IsBusy ? Loc.L("Archive.Blocked.Applying")
: Template.Error is { } error ? error
: _plan is null ? Loc.L("Archive.Blocked.Planning")
: _plan is null ? _planError ?? Loc.L("Archive.Blocked.Planning")
: _plan.Steps.Count == 0 ? Loc.L("Archive.Blocked.NoChanges")
: null;
@@ -221,14 +254,20 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
base.Dispose();
}
/// <summary>The dry run of the current template (the engine's plan; nothing changes on disk).</summary>
public async Task PlanAsync()
/// <summary>The dry run of the current template (the engine's plan; nothing changes on disk); it clears the last failure.</summary>
public Task PlanAsync()
{
ClearError();
return DryRunAsync();
}
private async Task DryRunAsync()
{
_planning?.Cancel();
_plan = null;
_planError = null;
Rows = [];
OnPropertyChanged(nameof(SummaryText));
OnPropertyChanged(nameof(ApplyToolTip));
OnPlanChanged();
if (Template.HasErrors) return;
var cts = _planning = new CancellationTokenSource();
var template = Template.Text;
@@ -240,41 +279,57 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
if (cts.IsCancellationRequested) return;
_plan = plan;
Rows = MassRename.Rows(plan, Mode);
OnPropertyChanged(nameof(SummaryText));
OnPropertyChanged(nameof(ApplyToolTip));
CommandManager.InvalidateRequerySuggested();
}
catch (OperationCanceledException) when (cts.IsCancellationRequested)
{
return;
}
catch (Exception ex) when (ex is ArgumentException or DatabaseException or FormatException)
{
Log.Warning("archive", "Rename plan failed", ex);
BusyText = ex.Message;
_planError = ArchiveFailures.Cause(ex);
ShowError(ex);
}
OnPlanChanged();
}
private void OnPlanChanged()
{
OnPropertyChanged(nameof(SummaryText));
OnPropertyChanged(nameof(ApplyToolTip));
CommandManager.InvalidateRequerySuggested();
}
private async Task ApplyAsync()
{
if (_plan is not { } plan) return;
ClearError();
IsBusy = true;
var progress = new Progress<int>(n => BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(n), Formatting.Count(plan.Steps.Count)));
// A tick posted before the apply ended must not bring its progress back.
var progress = new Progress<int>(n =>
{
if (IsBusy) BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(n), Formatting.Count(plan.Steps.Count));
});
try
{
await Task.Run(() => _archives.ApplyRenameAsync(plan, progress));
Log.Info("archive", $"{Mode} applied to {plan.Steps.Count} sequence(s)");
await _applied(plan.Steps.Count);
Close();
return;
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or StaleRenamePlanException or ArchiveOfflineException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or StaleRenamePlanException or DatabaseException)
{
Log.Warning("archive", "Rename failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
IsBusy = false;
BusyText = null;
}
// Part of the plan may have been applied, or the archive changed under it: the dry run shows what is left.
await DryRunAsync();
}
}
@@ -338,6 +393,7 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
var changes = Changes();
var run = _run = new CancellationTokenSource();
var done = 0;
ClearError();
IsBusy = true;
try
{
@@ -351,16 +407,17 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
await _applied(done);
Close();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException or ArchiveOfflineException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException)
{
Log.Warning("archive", "Retag failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
_run = null;
run.Dispose();
IsBusy = false;
BusyText = null;
}
}
}
+81 -24
View File
@@ -3,13 +3,42 @@
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
xmlns:ar="clr-namespace:Titano.App.Archiving"
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
xmlns:shell="clr-namespace:Titano.App.Shell">
<!-- In-window dialogs of the archive engine's operations, shared by the Archive manager and the Library. -->
<!-- Rows that only show text: focusable, so the arrow keys move through a long list. -->
<Style x:Key="ListBoxItem.Preview" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Padding" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="AutomationProperties.Name" Value="{Binding To}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding From}" />
</Style>
<!-- Dialog labels: a column at least 116 px wide that grows with the longest label (DESIGN §2: no fixed-width labels). -->
<Style x:Key="Text.DialogLabel" TargetType="TextBlock" BasedOn="{StaticResource Text.Label}">
<Setter Property="TextTrimming" Value="None" />
</Style>
<!-- A status line screen readers announce when it changes. -->
<Style x:Key="Text.Live" TargetType="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
<Setter Property="AutomationProperties.LiveSetting" Value="Polite" />
</Style>
<!-- A dialog's failure: one sentence in the error colour with its glyph, the engine's own text in the tooltip, announced at once. -->
<Style x:Key="Status.DialogError" TargetType="ui:StatusGlyph" BasedOn="{StaticResource {x:Type ui:StatusGlyph}}">
<Setter Property="Kind" Value="Error" />
<Setter Property="FontSize" Value="12" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Text" Value="{Binding ErrorText}" />
<Setter Property="ToolTip" Value="{Binding ErrorToolTip}" />
<Setter Property="AutomationProperties.LiveSetting" Value="Assertive" />
<Setter Property="infra:LiveRegion.Text" Value="{Binding ErrorText}" />
<Setter Property="Visibility" Value="{Binding ErrorText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
</Style>
<!-- Dialog card (DESIGN §4: Surface, Stroke, radius 12, 24 px shadow, two buttons). -->
<Style x:Key="Border.Dialog" TargetType="Border">
<Setter Property="Background" Value="{DynamicResource Brush.Surface}" />
@@ -26,21 +55,29 @@
<Border Style="{StaticResource Border.Dialog}" Width="520">
<StackPanel>
<TextBlock Text="{l:Loc Archive.Rebuild.Heading}" Style="{StaticResource Text.Title}" />
<ItemsControl ItemsSource="{Binding FactRows}" Focusable="False" Margin="0,14,0,0">
<ItemsControl ItemsSource="{Binding FactRows}" Focusable="False" Margin="0,14,0,0" Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type ar:DialogFact}">
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="Auto" MinWidth="116" SharedSizeGroup="FactLabel" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Label}" Style="{StaticResource Text.Label}" />
<TextBlock Grid.Column="1" Text="{Binding Value}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Value}" Typography.NumeralAlignment="Tabular" />
<TextBlock Text="{Binding Label}" Style="{StaticResource Text.DialogLabel}" />
<TextBlock x:Name="Value" Grid.Column="1" Text="{Binding Value}" TextTrimming="CharacterEllipsis" ToolTip="{Binding ToolTip}"
Typography.NumeralAlignment="Tabular" />
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsPath}" Value="True">
<Setter TargetName="Value" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="Value" Property="HorizontalAlignment" Value="Left" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" Visibility="{Binding BusyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}"
Visibility="{Binding BusyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,18,0,0">
<Button Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsDefault="True" IsCancel="True"
MinWidth="96" />
@@ -64,12 +101,14 @@
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Grid.Row="1" Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="Auto" MinWidth="116" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{l:Loc Archive.Rename.Template}" Style="{StaticResource Text.Label}" />
<TextBox Grid.Column="1" Style="{StaticResource TextBox.Mono}" Text="{Binding Template.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding Template}" ToolTip="{Binding Template.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Rename.Template}" />
<TextBlock Text="{l:Loc Archive.Rename.Template}" Style="{StaticResource Text.DialogLabel}" />
<!-- A naming template keeps its tokens and separators in order in every language. -->
<TextBox Grid.Column="1" Style="{StaticResource TextBox.Mono}" FlowDirection="LeftToRight"
Text="{Binding Template.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding Template}"
ToolTip="{Binding Template.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Rename.Template}" />
</Grid>
<TextBlock Grid.Row="2" Text="{Binding SummaryText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,12,0,6" Typography.NumeralAlignment="Tabular" />
<ListBox Grid.Row="3" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.Preview}" MinHeight="120"
@@ -82,19 +121,31 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding From}" Foreground="{DynamicResource Brush.TextMuted}" ToolTip="{Binding From}" />
<ui:Icon Grid.Column="1" Glyph="{StaticResource Icon.Forward}" Margin="10,0" Foreground="{DynamicResource Brush.TextFaint}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding To}" ToolTip="{Binding To}" />
<TextBlock x:Name="From" Style="{StaticResource Text.Cell}" Text="{Binding From}" Foreground="{DynamicResource Brush.TextMuted}" ToolTip="{Binding From}" />
<ui:Icon Grid.Column="1" Glyph="{StaticResource Icon.Forward}" Margin="10,0" VerticalAlignment="Center" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock x:Name="To" Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding To}" ToolTip="{Binding To}" />
</Grid>
<DataTemplate.Triggers>
<!-- Move lists folders: paths stay left to right; Rename lists titles, which read in the language's direction. -->
<DataTrigger Binding="{Binding DataContext.Mode, RelativeSource={RelativeSource AncestorType=ListBox}}" Value="Folders">
<Setter TargetName="From" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="From" Property="HorizontalAlignment" Value="Left" />
<Setter TargetName="To" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="To" Property="HorizontalAlignment" Value="Left" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DockPanel Grid.Row="4" Margin="0,16,0,0">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Archive.Rename.Apply}" Command="{Binding ApplyCommand}"
ToolTip="{Binding ApplyToolTip}" MinWidth="96" Margin="8,0,0,0" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsDefault="True"
IsCancel="True" MinWidth="96" />
<Grid Margin="0,0,12,0">
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" Typography.NumeralAlignment="Tabular" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" />
</Grid>
</DockPanel>
</Grid>
</Border>
@@ -106,17 +157,17 @@
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="Auto" MinWidth="116" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{l:Loc Archive.Retag.Add}" Style="{StaticResource Text.Label}" />
<TextBlock Text="{l:Loc Archive.Retag.Add}" Style="{StaticResource Text.DialogLabel}" />
<TextBox Grid.Column="1" Text="{Binding Add.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding Add}"
ToolTip="{Binding Add.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Retag.Add}" />
<TextBlock Grid.Row="1" Text="{l:Loc Archive.Retag.Remove}" Style="{StaticResource Text.Label}" Margin="0,10,14,0" />
<TextBlock Grid.Row="1" Text="{l:Loc Archive.Retag.Remove}" Style="{StaticResource Text.DialogLabel}" Margin="0,10,14,0" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" Text="{Binding Remove.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding Remove}" ToolTip="{Binding Remove.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Retag.Remove}" />
</Grid>
@@ -124,9 +175,12 @@
<DockPanel Margin="0,18,0,0">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Archive.Retag.Apply}" Command="{Binding ApplyCommand}"
ToolTip="{Binding ApplyToolTip}" MinWidth="96" Margin="8,0,0,0" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsDefault="True"
IsCancel="True" MinWidth="96" />
<Grid Margin="0,0,12,0">
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" Typography.NumeralAlignment="Tabular" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" />
</Grid>
</DockPanel>
</StackPanel>
</Border>
@@ -142,8 +196,8 @@
<DockPanel Margin="0,18,0,0">
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
IsDefault="True" MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"
Typography.NumeralAlignment="Tabular" Margin="0,0,12,0" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" Typography.NumeralAlignment="Tabular"
Margin="0,0,12,0" />
</DockPanel>
</StackPanel>
</Border>
@@ -188,7 +242,10 @@
<DockPanel Grid.Row="3" Margin="0,16,0,0">
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Close}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
IsDefault="True" MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<Grid Margin="0,0,12,0">
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" />
</Grid>
</DockPanel>
</Grid>
</Border>
+26
View File
@@ -0,0 +1,26 @@
using Titano.App.Infrastructure;
using Titano.Core.Archiving;
using Titano.Core.Localization;
using Titano.Data;
using Titano.Data.Archiving;
namespace Titano.App.Archiving;
/// <summary>
/// Why an Archive screen action stopped, as one localized sentence chosen by cause (BRIEF §0.2 rule 6). The
/// exception's own text, which may be technical or unlocalized, goes to the tooltip and the log only.
/// </summary>
public static class ArchiveFailures
{
public static string Cause(Exception ex) => ex switch
{
ArchiveOfflineException offline => Loc.L(offline.Availability == ArchiveAvailability.ReadOnly ? "Archive.Error.ReadOnly" : "Archive.Error.Offline",
Formatting.LeftToRight(offline.Root)),
// Already one localized sentence each.
LeaseUnavailableException or NewerFormatException or StaleRenamePlanException or StaleDeletePlanException or SequenceInLibraryException => ex.Message,
UnauthorizedAccessException => Loc.L("Archive.Failed.Access"),
DatabaseException => Loc.L("Archive.Failed.Index"),
ArgumentException => Loc.L("Archive.Failed.Gone"),
_ => Loc.L("Archive.Failed.Files"),
};
}
+32 -9
View File
@@ -23,6 +23,7 @@ public enum HealthAction
Proxies,
Analyse,
Duplicates,
MarkDuplicates,
Orphans,
}
@@ -44,7 +45,7 @@ public static class ArchiveFigures
var years = stats.ByYear.Select(y => y.Year).ToList();
var range = years.Count == 0 ? "—"
: years.Min() == years.Max() ? Year(years.Min())
: Loc.L("Archive.Tile.YearRange", Year(years.Min()), Year(years.Max()));
: Formatting.LeftToRight(Loc.L("Archive.Tile.YearRange", Year(years.Min()), Year(years.Max())));
var cameras = stats.ByCamera.Count(c => !string.IsNullOrWhiteSpace(c.Model) || !string.IsNullOrWhiteSpace(c.Make));
return
[
@@ -56,9 +57,22 @@ public static class ArchiveFigures
];
}
/// <summary>Culture month initials for the heatmap columns ("J F M …", "G F M …").</summary>
public static IReadOnlyList<string> MonthLabels() =>
[.. Loc.Culture.DateTimeFormat.AbbreviatedMonthNames.Take(12).Select(m => m.Length == 0 ? string.Empty : char.ToUpper(m[0], Loc.Culture).ToString())];
/// <summary>
/// The heatmap columns: month initials where the culture's month names start with a letter of a cased alphabet
/// ("J F M …", "G F M …"); month numbers in every other language, whose abbreviations are numbered ("1月",
/// "Tháng 1"), start alike or do not abbreviate to one letter (Thai, Arabic, Hebrew, Persian).
/// </summary>
public static IReadOnlyList<string> MonthLabels()
{
var culture = Loc.Culture;
var names = culture.DateTimeFormat.AbbreviatedMonthNames.Take(12).ToList();
return names.All(HasInitial)
? [.. names.Select(m => char.ToUpper(m[0], culture).ToString())]
: [.. Enumerable.Range(1, 12).Select(month => month.ToString("N0", culture))];
}
private static bool HasInitial(string month) =>
month.Length > 0 && char.IsLetter(month[0]) && char.ToUpperInvariant(month[0]) != char.ToLowerInvariant(month[0]) && !month.Any(char.IsDigit);
/// <summary>One row per year from the first to the last with photos, oldest first; months after <paramref name="today"/> are NaN.</summary>
public static IReadOnlyList<HeatRow> PhotosPerMonth(ArchiveStats stats, DateTime today)
@@ -125,8 +139,11 @@ public static class ArchiveFigures
_ => format.ToString().ToUpperInvariant(),
};
/// <summary>Index health (Archive.html): what needs attention, each with its fix.</summary>
public static IReadOnlyList<HealthLine> Health(ArchiveStats stats, int withoutProxies)
/// <summary>
/// Index health (Archive.html): what needs attention, each with its fix. Duplicates follow the last duplicates
/// search (<paramref name="duplicateGroups"/>, groups found by hash); before one, the copies already flagged.
/// </summary>
public static IReadOnlyList<HealthLine> Health(ArchiveStats stats, int withoutProxies, int? duplicateGroups = null)
{
var h = stats.Health;
var damaged = h.MissingFrames + h.CorruptFrames;
@@ -144,12 +161,18 @@ public static class ArchiveFigures
h.NotAnalyzed == 0
? new HealthLine(true, Loc.L("Archive.Health.AnalysedOk"), HealthAction.None)
: new HealthLine(false, Loc.Plural("Archive.Health.NotAnalysed", h.NotAnalyzed), HealthAction.Analyse),
h.DuplicateFrames == 0
? new HealthLine(true, Loc.L("Archive.Health.NoDuplicates"), HealthAction.None)
: new HealthLine(false, Loc.Plural("Archive.Health.Duplicates", h.DuplicateFrames), HealthAction.Duplicates),
Duplicates(h.DuplicateFrames, duplicateGroups),
];
}
private static HealthLine Duplicates(long flagged, int? groups) => groups switch
{
0 => new HealthLine(true, Loc.L("Archive.Health.NoDuplicates"), HealthAction.None),
{ } found => new HealthLine(false, Loc.Plural("Archive.Health.DuplicateGroups", found), HealthAction.MarkDuplicates),
null when flagged == 0 => new HealthLine(true, Loc.L("Archive.Health.NoneFlagged"), HealthAction.None),
null => new HealthLine(false, Loc.Plural("Archive.Health.Duplicates", flagged), HealthAction.Duplicates),
};
private static IReadOnlyList<BarValue> Shares(List<(string Name, long Photos)> ranked, int top, Func<int, string> restLabel, long total)
{
var bars = new List<BarValue>(top + 1);
+15 -6
View File
@@ -24,8 +24,18 @@ public sealed class ArchiveTreeRowViewModel(ArchiveTreeNode node, ArchiveAvailab
public string ToggleToolTip => Loc.L(Node.IsExpanded ? "Tooltips.Archive.Collapse" : "Tooltips.Archive.Expand");
/// <summary>The row's figures; a year also says how the keyboard opens and closes it.</summary>
public string RowToolTip => IsYear ? Loc.L("Tooltips.Archive.YearRow", Detail) : Detail;
/// <summary>
/// The full title (the tree trims it) and its figures; a year also says how the keyboard opens and closes it, with
/// the arrow keys swapped in a right-to-left layout.
/// </summary>
public string RowToolTip
{
get
{
var text = Title + " · " + Detail;
return IsYear ? Loc.L(Loc.IsRightToLeft ? "Tooltips.Archive.YearRowRtl" : "Tooltips.Archive.YearRow", text) : text;
}
}
public ICommand ToggleCommand { get; } = new RelayCommand(() => toggle(node));
@@ -42,12 +52,12 @@ public sealed class ArchiveTreeRowViewModel(ArchiveTreeNode node, ArchiveAvailab
public string AvailabilityToolTip => Loc.L("Tooltips.Archive.Availability." + availability);
}
/// <summary>A line of "Index health" with its fix.</summary>
/// <summary>A line of "Index health" with its fix: ● ok or ▲ needs attention.</summary>
public sealed class HealthLineViewModel(HealthLine line, ICommand? fix) : ObservableObject
{
public HealthLine Line { get; } = line;
public string Text => Line.Text;
public StatusKind Kind => Line.IsOk ? StatusKind.Done : StatusKind.Warning;
public bool IsOk => Line.IsOk;
public string KindToolTip => Loc.L(Line.IsOk ? "Tooltips.Archive.HealthOk" : "Tooltips.Archive.HealthWarning");
public bool HasFix => FixCommand is not null && Line.Action != HealthAction.None;
public ICommand? FixCommand { get; } = fix;
@@ -64,11 +74,10 @@ public sealed class DuplicateRowViewModel(DuplicateRow row, ICommand open, IComm
public ICommand RevealCommand { get; } = reveal;
}
/// <summary>An orphan line with its fix (index, reconcile, remove the row, scan).</summary>
/// <summary>An orphan line with its fix (index, reconcile, remove the row, scan); every kind is a ▲ warning the fix resolves.</summary>
public sealed class OrphanRowViewModel(OrphanRow row, ICommand fix) : ObservableObject
{
public OrphanRow Row { get; } = row;
public StatusKind Kind => Row.Kind is OrphanKind.MissingFiles or OrphanKind.MissingSequence ? StatusKind.Warning : StatusKind.Queued;
public string KindText => Loc.L("Archive.Orphans.Kind." + Row.Kind);
public ICommand FixCommand { get; } = fix;
public string FixText => Loc.L("Archive.Orphans.Fix." + Row.Kind);
@@ -88,7 +88,7 @@ public sealed class DeleteDialogViewModel : ArchiveDialogViewModel
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException)
{
Log.Warning("archive", "Delete dry run failed", ex);
_shell.Notify(Loc.L("Archive.Delete.Failed"), ex.Message);
_shell.Notify(Loc.L("Archive.Delete.Failed"), ArchiveFailures.Cause(ex));
return null;
}
}
@@ -124,7 +124,7 @@ public sealed class DeleteDialogViewModel : ArchiveDialogViewModel
await SequenceDeletion.RefreshAsync(_shell);
var undo = moved.Count == 0 ? null : new AsyncRelayCommand(() => SequenceDeletion.RestoreAsync(_shell, moved));
if (failure is not null)
_shell.Notify(Loc.L("Archive.Delete.Failed"), failure.Message, undo is null ? null : Loc.L("Archive.Delete.Undo"), Loc.L("Tooltips.Archive.DeleteUndo"),
_shell.Notify(Loc.L("Archive.Delete.Failed"), ArchiveFailures.Cause(failure), undo is null ? null : Loc.L("Archive.Delete.Undo"), Loc.L("Tooltips.Archive.DeleteUndo"),
undo is null ? null : () => undo.Execute(null));
else if (moved.Count > 0)
_shell.Notify(Loc.Plural("Archive.Delete.Done", moved.Count), Loc.L("Archive.Delete.Kept"), Loc.L("Archive.Delete.Undo"),
+26 -6
View File
@@ -4,6 +4,7 @@ using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Data.Archiving;
using Titano.Data.Repositories;
using Titano.Ui.Controls;
namespace Titano.App.Archiving;
@@ -30,11 +31,26 @@ public enum OrphanKind
public sealed record OrphanRow(OrphanKind Kind, string Title, string Detail, Guid? SequenceId);
/// <summary>A line of "Recent maintenance": date, operation and outcome.</summary>
public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State);
public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State)
{
/// <summary>The outcome's glyph and colour, as on the Jobs screen (paired with the word, never colour alone).</summary>
public StatusKind StateKind => State switch
{
JobState.Running => StatusKind.Running,
JobState.Queued => StatusKind.Queued,
JobState.Paused => StatusKind.Paused,
JobState.Done => StatusKind.Done,
JobState.Failed => StatusKind.Failed,
_ => StatusKind.Offline,
};
public string StateToolTip => Loc.L("Tooltips.Jobs.State." + State);
}
/// <summary>
/// The Maintenance view's reports (BRIEF §12.5): duplicates across sequences, orphans with their safe fixes, and the
/// recent archive jobs. Nothing here deletes a file; the only removal is of index rows whose sidecar is gone.
/// recent archive jobs. Nothing here deletes a file; the only removal is of index rows whose sidecar is gone. Folders
/// and paths are kept left to right inside right-to-left text (BRIEF §16).
/// </summary>
public static class MaintenanceReports
{
@@ -50,7 +66,8 @@ public static class MaintenanceReports
{
var first = g.Frames[0];
var name = first.RelativePath[(first.RelativePath.LastIndexOf('/') + 1)..];
var places = g.Frames.Select(f => Loc.L("Archive.Duplicates.Place", titles.GetValueOrDefault(f.SequenceId, f.RelativePath), f.RelativePath)).ToList();
var places = g.Frames.Select(f => Loc.L("Archive.Duplicates.Place", titles.GetValueOrDefault(f.SequenceId, f.RelativePath),
Formatting.LeftToRight(f.RelativePath))).ToList();
return new DuplicateRow(name, Loc.Plural("Archive.Duplicates.Copies", g.Frames.Count), places, first.SequenceId);
}),
];
@@ -63,16 +80,19 @@ public static class MaintenanceReports
foreach (var s in report.Sequences)
{
byFolder.TryGetValue(s.Folder, out var location);
var title = location?.Title ?? s.Folder;
var title = location?.Title ?? Formatting.LeftToRight(s.Folder);
if (s.UnindexedFiles.Count > 0)
rows.Add(new OrphanRow(OrphanKind.UnlistedFiles, title, Loc.Plural("Archive.Orphans.Unlisted", s.UnindexedFiles.Count), location?.Id));
if (s.MissingFiles.Count > 0)
rows.Add(new OrphanRow(OrphanKind.MissingFiles, title, Loc.Plural("Archive.Orphans.Missing", s.MissingFiles.Count), location?.Id));
}
foreach (var missing in report.MissingSequences)
rows.Add(new OrphanRow(OrphanKind.MissingSequence, missing.Title ?? missing.Folder, Loc.L("Archive.Orphans.NoSidecar", missing.Folder), missing.Id));
{
var folder = Formatting.LeftToRight(missing.Folder);
rows.Add(new OrphanRow(OrphanKind.MissingSequence, missing.Title ?? folder, Loc.L("Archive.Orphans.NoSidecar", folder), missing.Id));
}
foreach (var folder in report.UnindexedFolders)
rows.Add(new OrphanRow(OrphanKind.NewFolder, folder.Length == 0 ? "/" : folder, Loc.L("Archive.Orphans.NewFolder"), null));
rows.Add(new OrphanRow(OrphanKind.NewFolder, Formatting.LeftToRight(folder.Length == 0 ? "/" : folder), Loc.L("Archive.Orphans.NewFolder"), null));
return rows;
}
+4 -3
View File
@@ -1,5 +1,6 @@
using System.IO;
using Titano.App.Shell;
using Titano.Core.Archiving;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Data;
@@ -24,11 +25,11 @@ public static class SequenceDeletion
}
shell.Notify(Loc.Plural("Archive.Trash.Restored", restored));
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or InvalidOperationException or ArgumentException
or DatabaseException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or SequenceInLibraryException or NewerFormatException
or ArgumentException or DatabaseException)
{
Log.Warning("archive", "Restore from the trash failed", ex);
shell.Notify(Loc.L("Archive.Trash.Failed"), ex.Message);
shell.Notify(Loc.L("Archive.Trash.Failed"), ArchiveFailures.Cause(ex));
}
await RefreshAsync(shell);
}
+14 -7
View File
@@ -1,6 +1,7 @@
using System.IO;
using System.Windows.Input;
using Titano.App.Infrastructure;
using Titano.Core.Archiving;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Data;
@@ -15,8 +16,8 @@ public sealed class TrashRowViewModel(TrashEntry entry, ICommand restore)
public TrashEntry Entry { get; } = entry;
public string Title => Entry.Title;
/// <summary>"3,600 photos · 96.2 GB · 2026/2026-09-28 Canon EOS R5".</summary>
public string Detail => string.Join(" · ", Loc.Plural("Shell.Status.Photos", Entry.Frames), Formatting.Bytes(Entry.Bytes), Entry.Folder);
/// <summary>"3,600 photos · 96.2 GB · 2026/2026-09-28 Canon EOS R5" (the folder left to right in every language).</summary>
public string Detail => string.Join(" · ", Loc.Plural("Shell.Status.Photos", Entry.Frames), Formatting.Bytes(Entry.Bytes), Formatting.LeftToRight(Entry.Folder));
/// <summary>"Deleted 02/10/2026 18:04".</summary>
public string DeletedText => Loc.L("Archive.Trash.Deleted", Formatting.Date(Entry.DeletedAt) + " " + Formatting.TimeOfDay(Entry.DeletedAt));
@@ -69,17 +70,21 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel
/// <summary>Reads the trash of the archive (off the UI thread).</summary>
public async Task LoadAsync()
{
ClearError();
BusyText = Loc.L("Archive.Trash.Reading");
try
{
var entries = await Task.Run(() => _archives.ListTrashAsync(_archive.Id));
Rows = [.. entries.Select(e => new TrashRowViewModel(e, new AsyncRelayCommand(() => RestoreAsync(e), () => !IsBusy)))];
BusyText = null;
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException or ArgumentException)
{
Log.Warning("archive", "Reading the trash failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
BusyText = null;
}
}
@@ -89,6 +94,7 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel
private async Task RestoreAsync(TrashEntry entry)
{
ClearError();
IsBusy = true;
BusyText = Loc.L("Archive.Trash.Restoring", entry.Title);
try
@@ -99,15 +105,16 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel
BusyText = null;
await _restored();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or InvalidOperationException or DatabaseException
or ArgumentException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or SequenceInLibraryException or NewerFormatException
or DatabaseException or ArgumentException)
{
Log.Warning("archive", $"Restoring {entry.Title} failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
IsBusy = false;
BusyText = null;
}
}
}
+7 -10
View File
@@ -1,21 +1,22 @@
using System.Globalization;
using System.Windows;
using Titano.Core.Localization;
using Titano.Ui.Controls;
namespace Titano.App.Infrastructure;
/// <summary>Switches the UI language at run time without restart (BRIEF §16), mirroring right-to-left languages.</summary>
/// <summary>
/// Switches the UI language at run time without restart (BRIEF §16). A <see cref="TitanoWindow"/> takes the
/// language's direction when it is created and follows each switch, so right-to-left languages mirror windows opened
/// before and after this call alike; plain windows (the full-screen preview) take it when they load.
/// </summary>
public static class UiLanguage
{
static UiLanguage()
{
// Windows created later (the main window at start, every dialog) take the reading direction when they load.
EventManager.RegisterClassHandler(typeof(Window), FrameworkElement.LoadedEvent, new RoutedEventHandler((sender, _) => ((Window)sender).FlowDirection = Direction));
EventManager.RegisterClassHandler(typeof(Window), FrameworkElement.LoadedEvent, new RoutedEventHandler((sender, _) => ((Window)sender).FlowDirection = Bidi.UiDirection));
}
/// <summary>The reading direction of the current language.</summary>
public static FlowDirection Direction => Loc.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
/// <summary>Applies <paramref name="code"/> (or the OS language when null) and returns the culture in use.</summary>
public static CultureInfo Apply(string? code)
{
@@ -32,10 +33,6 @@ public static class UiLanguage
CultureInfo.DefaultThreadCurrentUICulture = culture;
CultureInfo.CurrentUICulture = culture;
Loc.SetCulture(culture);
if (Application.Current is { } app)
{
foreach (Window window in app.Windows) window.FlowDirection = Direction;
}
return culture;
}
}
+2 -1
View File
@@ -1,5 +1,6 @@
using System.IO;
using System.Net.Http;
using Titano.App.Archiving;
using Titano.App.Jobs;
using Titano.App.Server;
using Titano.App.Shell;
@@ -168,7 +169,7 @@ public sealed class LibraryActions(ShellViewModel shell)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException)
{
Log.Warning("library", "Rating failed", ex);
shell.Notify(Loc.L("Library.Rate.Failed"), ex.Message);
shell.Notify(Loc.L("Library.Rate.Failed"), ArchiveFailures.Cause(ex));
}
return changed;
}
+1 -2
View File
@@ -9,8 +9,7 @@
<Border Style="{StaticResource Border.Panel}" Padding="28,24" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="600">
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,22">
<!-- The mark keeps its clockwise ring and its sun on the right in every reading direction. -->
<ui:BrandMarkIcon Width="56" Height="56" ShowPlate="True" FlowDirection="LeftToRight" />
<ui:BrandMarkIcon Width="56" Height="56" ShowPlate="True" />
<StackPanel Margin="16,0,0,0" VerticalAlignment="Center">
<TextBlock Text="{l:Loc Shell.AppName}" Style="{StaticResource Text.PageTitle}" FontSize="22" />
<TextBlock Text="{Binding Version}" Style="{StaticResource Text.Secondary}" Margin="0,2,0,0" Typography.NumeralAlignment="Tabular" />
+132 -61
View File
@@ -5,12 +5,44 @@
xmlns:v="clr-namespace:Titano.Ui.Visuals;assembly=Titano.Ui"
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
xmlns:ar="clr-namespace:Titano.App.Archiving"
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
xmlns:shell="clr-namespace:Titano.App.Shell">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- The dialogs (and their styles) are shared with the Library, which runs Delete… too. -->
<ResourceDictionary Source="pack://application:,,,/Titano;component/Archive/ArchiveDialogs.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Keyboard focus drawn inside the row (DESIGN §4 ring): an outer ring would be clipped by the list's scroll viewer. -->
<Style x:Key="Focus.Inset">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Border BorderBrush="{DynamicResource Brush.Accent}" BorderThickness="2" CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--
Lists keep their panel's fill while the screen behind a dialog is disabled: the system template would paint them
white. Rows and buttons dim themselves.
-->
<Style TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
Padding="1" SnapsToDevicePixels="True">
<ScrollViewer Focusable="False" Padding="{TemplateBinding Padding}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Text.PanelHeading" TargetType="TextBlock" BasedOn="{StaticResource Text.Section}">
<Setter Property="FontSize" Value="13" />
<Setter Property="VerticalAlignment" Value="Center" />
@@ -25,6 +57,7 @@
<!-- Report rows with their own buttons: Tab reaches every button. -->
<Style x:Key="ListBoxItem.Duplicate" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Row.Title}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Row.Detail}" />
</Style>
<!-- A filter menu: its values, each checked while chosen. -->
<Style x:Key="MenuItem.Choice" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
@@ -58,10 +91,10 @@
<Button Style="{StaticResource Button.Tool}" Content="{l:Loc Archive.Toolbar.Duplicates}" Command="{Binding FindDuplicatesCommand}"
ToolTip="{Binding DuplicatesToolTip}" />
<Button Style="{StaticResource Button.Tool}" Content="{l:Loc Archive.Toolbar.Orphans}" Command="{Binding FindOrphansCommand}" ToolTip="{Binding OrphansToolTip}" />
<Button Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Adopt}">
<Button Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Adopt}" AutomationProperties.Name="{l:Loc Archive.Toolbar.AdoptMenu}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Archive.Toolbar.AdoptMenu}" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
@@ -70,10 +103,11 @@
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button x:Name="MaintenanceButton" Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Maintenance}">
<Button x:Name="MaintenanceButton" Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Maintenance}"
AutomationProperties.Name="{l:Loc Archive.Toolbar.Maintenance}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Archive.Toolbar.Maintenance}" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
@@ -94,8 +128,7 @@
<DockPanel Grid.Row="1" Margin="0,0,0,12" Visibility="{Binding HasArchive, Converter={StaticResource BoolToVisibility}}">
<v:SegmentedControl DockPanel.Dock="Left" SelectedIndex="{Binding ViewIndex}" AutomationProperties.Name="{l:Loc Archive.View.Name}">
<v:SegmentedItem Content="{l:Loc Archive.View.Overview}" ToolTip="{l:Loc Tooltips.Archive.Overview}" AutomationProperties.Name="{l:Loc Archive.View.Overview}" />
<v:SegmentedItem Content="{l:Loc Archive.View.Maintenance}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceView}"
AutomationProperties.Name="{l:Loc Archive.View.Maintenance}" />
<v:SegmentedItem Content="{l:Loc Archive.View.Health}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceView}" AutomationProperties.Name="{l:Loc Archive.View.Health}" />
</v:SegmentedControl>
<TextBlock Text="{Binding LastScanText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="14,0,0,0"
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Archive.LastScan}" />
@@ -115,6 +148,7 @@
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="MinHeight" Value="32" />
<Setter Property="Padding" Value="6,0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="ToolTip" Value="{Binding RowToolTip}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Detail}" />
@@ -160,13 +194,28 @@
</Border>
<Grid Grid.Column="2">
<!--
Chart labels in TextMuted as in Archive.html: the kit's charts draw them in TextFaint, too faint for 11 px data
labels (reported to the shared controls; remove this alias once they draw in TextMuted).
-->
<Grid.Resources>
<SolidColorBrush x:Key="Brush.TextFaint" Color="{DynamicResource Color.TextMuted}" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="14" />
<RowDefinition Height="*" />
<RowDefinition Height="14" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- One column split for both chart rows, so the gutter lines up; 14 px gaps throughout (Archive.html). -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" />
<ColumnDefinition Width="14" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Figure tiles (Archive.html). -->
<ItemsControl ItemsSource="{Binding Tiles}" Focusable="False" Margin="0,0,-10,0">
<ItemsControl Grid.ColumnSpan="3" ItemsSource="{Binding Tiles}" Focusable="False" Margin="0,0,-14,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1" />
@@ -174,7 +223,7 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type ar:ArchiveTile}">
<Border Style="{StaticResource Border.Panel}" Padding="14,8" Margin="0,0,10,0" ToolTip="{Binding Caption}">
<Border Style="{StaticResource Border.Panel}" Padding="14,8" Margin="0,0,14,0" ToolTip="{Binding Caption}">
<StackPanel>
<!-- A narrow tile (the window at its minimum width) shrinks the figure rather than cutting it. -->
<Viewbox StretchDirection="DownOnly" HorizontalAlignment="Left">
@@ -187,49 +236,59 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid Grid.Row="1" Margin="0,12,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" />
<ColumnDefinition Width="12" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Months}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:HeatmapStrip Rows="{Binding MonthRows}" ColumnLabels="{Binding MonthLabels}" ValueFormatter="{Binding CountFormatter}" MaxCellSize="18"
ToolTip="{l:Loc Tooltips.Archive.Months}" AutomationProperties.Name="{l:Loc Archive.Chart.Months}" />
<Border Grid.Row="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<!-- The colour scale sits in the header, at the end of the title (Archive.html). -->
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" FlowDirection="LeftToRight" VerticalAlignment="Center"
Visibility="{Binding HasMonthScale, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding MonthScaleLow}" Style="{StaticResource Text.Chip}" Typography.NumeralAlignment="Tabular" />
<Grid Width="60" Height="8" Margin="6,0">
<Border CornerRadius="2" Background="{DynamicResource Brush.Accent}" Opacity="0.08" />
<Border CornerRadius="2" Background="{DynamicResource Brush.Accent}">
<Border.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="Transparent" Offset="0" />
<GradientStop Color="Black" Offset="1" />
</LinearGradientBrush>
</Border.OpacityMask>
</Border>
</Grid>
<TextBlock Text="{Binding MonthScaleHigh}" Style="{StaticResource Text.Chip}" Typography.NumeralAlignment="Tabular" />
</StackPanel>
<TextBlock Text="{l:Loc Archive.Chart.Months}" Style="{StaticResource Text.PanelHeading}" />
</DockPanel>
</Border>
<Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Storage}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding StorageBars}" MinimumOpacity="0.55" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Storage}"
AutomationProperties.Name="{l:Loc Archive.Chart.Storage}" />
</DockPanel>
</Border>
</Grid>
<Grid Grid.Row="2" Margin="0,12,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="12" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Cameras}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding CameraBars}" BrushKey="Brush.Sun" MinimumOpacity="0.45" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Cameras}"
AutomationProperties.Name="{l:Loc Archive.Chart.Cameras}" />
</DockPanel>
</Border>
<Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Formats}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding FormatBars}" MinimumOpacity="0.35" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Formats}"
AutomationProperties.Name="{l:Loc Archive.Chart.Formats}" />
</DockPanel>
</Border>
</Grid>
<v:HeatmapStrip Rows="{Binding MonthRows}" ColumnLabels="{Binding MonthLabels}" ValueFormatter="{Binding CountFormatter}" MaxCellSize="32" ShowScale="False"
ToolTip="{l:Loc Tooltips.Archive.Months}" AutomationProperties.Name="{l:Loc Archive.Chart.Months}"
AutomationProperties.HelpText="{Binding MonthsDescription}">
<!-- Months still to come in the Stroke tone: the kit fills them with Card, the panel's own colour in the light theme. -->
<v:HeatmapStrip.Resources>
<SolidColorBrush x:Key="Brush.Card" Color="{DynamicResource Color.Stroke}" />
</v:HeatmapStrip.Resources>
</v:HeatmapStrip>
</DockPanel>
</Border>
<Border Grid.Row="2" Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Storage}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding StorageBars}" MinimumOpacity="0.55" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Storage}"
AutomationProperties.Name="{l:Loc Archive.Chart.Storage}" AutomationProperties.HelpText="{Binding StorageDescription}" />
</DockPanel>
</Border>
<Border Grid.Row="4" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Cameras}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding CameraBars}" BrushKey="Brush.Sun" MinimumOpacity="0.45" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Cameras}"
AutomationProperties.Name="{l:Loc Archive.Chart.Cameras}" AutomationProperties.HelpText="{Binding CamerasDescription}" />
</DockPanel>
</Border>
<Border Grid.Row="4" Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Formats}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding FormatBars}" MinimumOpacity="0.35" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Formats}"
AutomationProperties.Name="{l:Loc Archive.Chart.Formats}" AutomationProperties.HelpText="{Binding FormatsDescription}" />
</DockPanel>
</Border>
</Grid>
</Grid>
@@ -250,12 +309,21 @@
<TextBlock Text="{l:Loc Archive.Health.Title}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<ItemsControl ItemsSource="{Binding Health}" Focusable="False">
<ItemsControl.ItemTemplate>
<!-- Archive.html: a 14 px glyph in the state's colour (● ok, ▲ needs attention), the text in the normal colour. -->
<DataTemplate DataType="{x:Type ar:HealthLineViewModel}">
<DockPanel Height="32">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="8,0,0,0" Content="{Binding FixText}" Command="{Binding FixCommand}"
ToolTip="{Binding FixToolTip}" Visibility="{Binding HasFix, Converter={StaticResource BoolToVisibility}}" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" FontSize="13" VerticalAlignment="Center" ToolTip="{Binding KindToolTip}" />
<ui:Icon x:Name="Glyph" DockPanel.Dock="Left" Glyph="{StaticResource Icon.Warning}" Size="14" Margin="0,0,10,0" VerticalAlignment="Center"
Foreground="{DynamicResource Brush.Warning}" />
<TextBlock Text="{Binding Text}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding KindToolTip}" />
</DockPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsOk}" Value="True">
<Setter TargetName="Glyph" Property="Glyph" Value="{StaticResource Icon.SuccessCircle}" />
<Setter TargetName="Glyph" Property="Foreground" Value="{DynamicResource Brush.Success}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -281,7 +349,9 @@
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding DateText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<TextBlock Grid.Column="1" Text="{Binding Text}" Margin="12,0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text}" />
<TextBlock Grid.Column="2" Text="{Binding StateText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<!-- The outcome in its state's colour and glyph (Archive.html: accent while running, green when done). -->
<ui:StatusGlyph Grid.Column="2" Kind="{Binding StateKind}" Text="{Binding StateText}" FontSize="12" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" ToolTip="{Binding StateToolTip}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
@@ -300,12 +370,13 @@
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="8,0,0,0" Content="{l:Loc Archive.Duplicates.Mark}"
Command="{Binding MarkDuplicatesCommand}" ToolTip="{Binding MarkDuplicatesToolTip}" />
<!-- Cancel only in the card whose search runs; the other card's Find waits, its tooltip says why. -->
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Run}" Command="{Binding FindDuplicatesCommand}"
ToolTip="{Binding DuplicatesToolTip}" Visibility="{Binding IsSearching, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
ToolTip="{Binding DuplicatesToolTip}" Visibility="{Binding IsFindingDuplicates, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Cancel}" Command="{Binding CancelSearchCommand}"
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsSearching, Converter={StaticResource BoolToVisibility}}" />
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsFindingDuplicates, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{l:Loc Archive.Duplicates.Title}" Style="{StaticResource Text.PanelHeading}" />
<TextBlock Text="{Binding DuplicatesText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" VerticalAlignment="Center" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding DuplicatesText}" infra:LiveRegion.Text="{Binding DuplicatesText}" Margin="10,0,0,0" />
</DockPanel>
<ListBox ItemsSource="{Binding Duplicates}" ItemContainerStyle="{StaticResource ListBoxItem.Duplicate}" AutomationProperties.Name="{l:Loc Archive.Duplicates.Title}"
KeyboardNavigation.TabNavigation="Continue">
@@ -333,11 +404,11 @@
<DockPanel>
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Run}" Command="{Binding FindOrphansCommand}"
ToolTip="{Binding OrphansToolTip}" Visibility="{Binding IsSearching, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
ToolTip="{Binding OrphansToolTip}" Visibility="{Binding IsFindingOrphans, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Cancel}" Command="{Binding CancelSearchCommand}"
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsSearching, Converter={StaticResource BoolToVisibility}}" />
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsFindingOrphans, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{l:Loc Archive.Orphans.Title}" Style="{StaticResource Text.PanelHeading}" />
<TextBlock Text="{Binding OrphansText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" VerticalAlignment="Center" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding OrphansText}" infra:LiveRegion.Text="{Binding OrphansText}" Margin="10,0,0,0" />
</DockPanel>
<ListBox ItemsSource="{Binding Orphans}" ItemContainerStyle="{StaticResource ListBoxItem.Duplicate}" AutomationProperties.Name="{l:Loc Archive.Orphans.Title}"
KeyboardNavigation.TabNavigation="Continue">
@@ -347,7 +418,7 @@
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Content="{Binding FixText}" Command="{Binding FixCommand}" ToolTip="{Binding FixToolTip}" />
<StackPanel VerticalAlignment="Center">
<TextBlock Text="{Binding Row.Title}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" ToolTip="{Binding Row.Title}" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Row.Detail}" FontSize="12" ToolTip="{Binding KindText}" />
<ui:StatusGlyph Kind="Warning" Text="{Binding Row.Detail}" FontSize="12" ToolTip="{Binding KindText}" />
</StackPanel>
</DockPanel>
</DataTemplate>
@@ -370,10 +441,10 @@
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="{l:Loc Archive.Set.Label}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Margin="0,0,10,8" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" BorderBrush="{DynamicResource Brush.Accent}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Set}"
AutomationProperties.Name="{l:Loc Archive.Set.Filter}">
AutomationProperties.Name="{Binding SetFilterName}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding SetText}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" MaxWidth="260" TextTrimming="CharacterEllipsis" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
+36 -12
View File
@@ -3,6 +3,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Titano.App.Archiving;
@@ -12,6 +13,7 @@ public partial class ArchiveView : UserControl
{
private bool _restoring;
private string? _focusKey;
private IInputElement? _beforeDialog;
public ArchiveView()
{
@@ -79,26 +81,48 @@ public partial class ArchiveView : UserControl
});
}
/// <summary>On a year: Right opens it, Left closes it, Enter toggles it.</summary>
private void OnTreeKeyDown(object sender, KeyEventArgs e)
{
if (Model is not { } model || Keyboard.FocusedElement is not ListBoxItem { DataContext: ArchiveTreeRowViewModel row } || !row.HasChildren || row.IsArchive) return;
var toggle = e.Key switch
{
Key.Right => !row.IsExpanded,
Key.Left => row.IsExpanded,
Key.Enter => true,
_ => false,
};
if (!toggle) return;
if (!Toggles(e.Key, Tree.FlowDirection, row.IsExpanded)) return;
model.Toggle(row);
e.Handled = true;
}
/// <summary>A dialog that opens takes the keyboard: its first field or button.</summary>
/// <summary>
/// Whether <paramref name="key"/> opens or closes a year: the arrow towards the indented side opens it (Right, or
/// Left in a right-to-left layout, as a tree view does), the other arrow closes it, Enter toggles it.
/// </summary>
internal static bool Toggles(Key key, FlowDirection direction, bool isExpanded)
{
var (open, close) = direction == FlowDirection.RightToLeft ? (Key.Left, Key.Right) : (Key.Right, Key.Left);
return key == open ? !isExpanded
: key == close ? isExpanded
: key == Key.Enter;
}
/// <summary>
/// A dialog that opens takes the keyboard (its first field or button); when it closes, the keyboard goes back to the
/// control that opened it, or to the tree when that control can no longer take it.
/// </summary>
private void OnModelChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != nameof(ArchiveViewModel.Dialog) || Model?.Dialog is null || !IsVisible) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
if (e.PropertyName != nameof(ArchiveViewModel.Dialog) || Model is not { } model) return;
if (model.Dialog is not null)
{
if (!IsVisible) return;
// Raised before the screen behind the dialog is disabled: the control that opened it still has the keyboard.
_beforeDialog ??= Keyboard.FocusedElement is Visual focused && IsAncestorOf(focused) ? Keyboard.FocusedElement : null;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
return;
}
var back = _beforeDialog;
_beforeDialog = null;
if (!IsVisible) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () =>
{
if (back is UIElement { IsVisible: true, IsEnabled: true, Focusable: true } element && element.Focus()) return;
Tree.Focus();
});
}
}
+59 -18
View File
@@ -47,6 +47,7 @@ public sealed class ArchiveViewModel : SectionViewModel
private Core.Model.Archive? _archive;
private ArchiveAvailability _availability = ArchiveAvailability.Offline;
private ArchiveStats? _stats;
private int _withoutProxies;
private ArchiveTree? _tree;
private int _viewIndex;
private bool _loaded;
@@ -129,7 +130,7 @@ public sealed class ArchiveViewModel : SectionViewModel
public bool HasArchive => _archive is not null;
public string ArchiveToolTip => _archive is null ? Loc.L("Tooltips.Archive.Pick") : Loc.L("Tooltips.Archive.PickRoot", _archive.RootPath);
public string ArchiveToolTip => _archive is null ? Loc.L("Tooltips.Archive.Pick") : Loc.L("Tooltips.Archive.PickRoot", Formatting.LeftToRight(_archive.RootPath));
/// <summary>0 = overview (tree and figures), 1 = maintenance.</summary>
public int ViewIndex
@@ -171,7 +172,7 @@ public sealed class ArchiveViewModel : SectionViewModel
public ICommand VerifyCommand { get; }
public ICommand AdoptCommand { get; }
/// <summary>"Adopt folder ▾ › Copy into the layout": the Import screen copies the folder into the archive with its templates.</summary>
/// <summary>"Adopt folder ▾ › Copy into archive": the Import screen copies the folder into the archive with its templates.</summary>
public ICommand CopyFolderCommand { get; }
public ICommand BackupCommand { get; }
@@ -195,6 +196,20 @@ public sealed class ArchiveViewModel : SectionViewModel
public IReadOnlyList<ChartItem> CameraBars { get => _cameras; private set => Set(ref _cameras, value); }
public IReadOnlyList<ChartItem> FormatBars { get => _formats; private set => Set(ref _formats, value); }
/// <summary>The heatmap's scale in the card header (Archive.html: "0 ▭ 21,000"); hidden without photos.</summary>
public bool HasMonthScale => MonthScaleMax > 0;
public string MonthScaleLow => Formatting.Count(0);
public string MonthScaleHigh => Formatting.Count((long)MonthScaleMax);
private double MonthScaleMax => _months.SelectMany(r => r.Values).Where(double.IsFinite).DefaultIfEmpty(0).Max();
/// <summary>What each chart shows, value by value, for screen readers (the charts themselves are images).</summary>
public string MonthsDescription => Describe(_months.SelectMany(r => r.Values.Select((photos, month) => photos > 0 ? r.ToolTips?[month] : null)));
public string StorageDescription => Describe(_storage.Select(b => b.ToolTip));
public string CamerasDescription => Describe(_cameras.Select(b => b.ToolTip));
public string FormatsDescription => Describe(_formats.Select(b => b.ToolTip));
/// <summary>Photos per month in the culture's digits.</summary>
public Func<double, string> CountFormatter { get; } = v => Formatting.Count((long)v);
@@ -212,6 +227,9 @@ public sealed class ArchiveViewModel : SectionViewModel
}
}
/// <summary>The set button's accessible name: what it is and the set it shows.</summary>
public string SetFilterName => Loc.L("Archive.Set.Filter") + " · " + SetText;
/// <summary>Camera, status and tag on top of the tree selection.</summary>
public ArchiveSetFilter Filter
{
@@ -286,7 +304,9 @@ public sealed class ArchiveViewModel : SectionViewModel
get => _duplicates;
private set
{
if (Set(ref _duplicates, value)) OnPropertyChanged(nameof(DuplicatesText));
if (!Set(ref _duplicates, value)) return;
OnPropertyChanged(nameof(DuplicatesText));
ShowHealth();
}
}
@@ -299,8 +319,11 @@ public sealed class ArchiveViewModel : SectionViewModel
}
}
/// <summary>A duplicates or orphans search runs; it can be cancelled.</summary>
public bool IsSearching => _search is not null;
/// <summary>The duplicates search runs: its card offers Cancel; the other card's Find waits for it.</summary>
public bool IsFindingDuplicates => _findingDuplicates;
/// <summary>The orphans search runs: its card offers Cancel; the other card's Find waits for it.</summary>
public bool IsFindingOrphans => _findingOrphans;
/// <summary>"3 groups", "None found", or empty before the first search.</summary>
public string DuplicatesText => _findingDuplicates ? Loc.L("Archive.Find.Searching")
@@ -428,19 +451,28 @@ public sealed class ArchiveViewModel : SectionViewModel
private void ShowFigures(ArchiveStats stats, int withoutProxies)
{
_withoutProxies = withoutProxies;
Tiles = ArchiveFigures.Tiles(stats);
MonthRows = [.. ArchiveFigures.PhotosPerMonth(stats, DateTime.Today).Select(r => new ChartRow(r.Label, r.Values, r.ToolTips))];
StorageBars = Bars(ArchiveFigures.StorageByYear(stats));
CameraBars = Bars(ArchiveFigures.ByCamera(stats));
FormatBars = Bars(ArchiveFigures.ByFormat(stats));
ShowHealth();
}
/// <summary>The health lines of the last figures; the duplicates line follows the last duplicates search.</summary>
private void ShowHealth()
{
if (_stats is not { } stats) return;
Health =
[
.. ArchiveFigures.Health(stats, withoutProxies).Select(line => new HealthLineViewModel(line, line.Action switch
.. ArchiveFigures.Health(stats, _withoutProxies, _duplicates?.Count).Select(line => new HealthLineViewModel(line, line.Action switch
{
HealthAction.Verify => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.Verified, ids => ArchiveJobs.Verify(_archive!, ids))),
HealthAction.Proxies => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.ProxiesBuilt, ids => ArchiveJobs.Proxies(ids, CountLabel(ids)))),
HealthAction.Analyse => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.AnalyzedLight, ids => ProcessingJobs.LightAnalysis(ids, CountLabel(ids)))),
HealthAction.Duplicates => FindDuplicatesCommand,
HealthAction.MarkDuplicates => MarkDuplicatesCommand,
HealthAction.Orphans => FindOrphansCommand,
_ => null,
})),
@@ -450,6 +482,8 @@ public sealed class ArchiveViewModel : SectionViewModel
private static IReadOnlyList<ChartItem> Bars(IReadOnlyList<BarValue> values) =>
[.. values.Select(v => new ChartItem(v.Label, v.Value, v.ValueText, v.ToolTip))];
private static string Describe(IEnumerable<string?> values) => string.Join(Environment.NewLine, values.Where(v => !string.IsNullOrEmpty(v)));
/// <summary>A reloaded tree keeps the open years and the selection (nodes that still exist).</summary>
private void ShowTree(ArchiveTree tree)
{
@@ -498,6 +532,7 @@ public sealed class ArchiveViewModel : SectionViewModel
private void OnSetChanged()
{
OnPropertyChanged(nameof(SetText));
OnPropertyChanged(nameof(SetFilterName));
OnPropertyChanged(nameof(CameraChoices));
OnPropertyChanged(nameof(StatusChoices));
OnPropertyChanged(nameof(TagChoices));
@@ -714,13 +749,13 @@ public sealed class ArchiveViewModel : SectionViewModel
try
{
var path = await db.BackupAsync(Services.Environment.BackupDirectory);
Shell.Notify(Loc.L("Settings.Advanced.BackupDone"), Path.GetFileName(path), Loc.L("Library.Export.Show"), Loc.L("Tooltips.Library.ShowExport"),
() => ShellActions.Reveal(path));
Shell.Notify(Loc.L("Settings.Advanced.BackupDone"), Formatting.LeftToRight(Path.GetFileName(path)), Loc.L("Library.Export.Show"),
Loc.L("Tooltips.Library.ShowExport"), () => ShellActions.Reveal(path));
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException or NotSupportedException)
{
Log.Warning("archive", "Database backup failed", ex);
Shell.Notify(Loc.L("Archive.Backup.Failed"), ex.Message);
NotifyFailure("Archive.Backup.Failed", ex, BackupCommand);
}
}
@@ -737,13 +772,14 @@ public sealed class ArchiveViewModel : SectionViewModel
Services.SaveSettings();
_archive = archive;
await Services.QueueScanAsync(archive, full: false);
Shell.Notify(Loc.L("Archive.Relink.Done", archive.Name), archive.RootPath);
Shell.Notify(Loc.L("Archive.Relink.Done", archive.Name), Formatting.LeftToRight(archive.RootPath));
await LoadAsync();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException)
{
Log.Warning("archive", $"Relinking {folder} failed", ex);
Shell.Notify(Loc.L("Archive.Relink.Failed"), ex.Message);
// Retry asks for the folder again: the same one once its drive is back, or the right one.
NotifyFailure("Archive.Relink.Failed", ex, RelinkCommand);
}
}
@@ -777,7 +813,8 @@ public sealed class ArchiveViewModel : SectionViewModel
}
catch (DatabaseException ex)
{
Shell.ReportError(ex);
Log.Warning("archive", "Duplicates search failed", ex);
NotifyFailure("Archive.Duplicates.Failed", ex, FindDuplicatesCommand);
}
finally
{
@@ -803,10 +840,10 @@ public sealed class ArchiveViewModel : SectionViewModel
catch (OperationCanceledException) when (search.IsCancellationRequested)
{
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArchiveOfflineException or DatabaseException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException)
{
Log.Warning("archive", "Orphan search failed", ex);
Shell.Notify(Loc.L("Archive.Orphans.Failed"), ex.Message);
NotifyFailure("Archive.Orphans.Failed", ex, FindOrphansCommand);
}
finally
{
@@ -831,7 +868,8 @@ public sealed class ArchiveViewModel : SectionViewModel
private void OnSearchChanged()
{
OnPropertyChanged(nameof(IsSearching));
OnPropertyChanged(nameof(IsFindingDuplicates));
OnPropertyChanged(nameof(IsFindingOrphans));
OnPropertyChanged(nameof(DuplicatesText));
OnPropertyChanged(nameof(OrphansText));
OnPropertyChanged(nameof(DuplicatesToolTip));
@@ -888,11 +926,14 @@ public sealed class ArchiveViewModel : SectionViewModel
Orphans = Orphans?.Where(o => o.Row != row).ToList();
await LoadAsync();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArchiveOfflineException or DatabaseException
or ArgumentException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException or ArgumentException)
{
Log.Warning("archive", $"Fixing {row.Title} failed", ex);
Shell.Notify(Loc.L("Archive.Orphans.FixFailed"), ex.Message);
NotifyFailure("Archive.Orphans.FixFailed", ex, new AsyncRelayCommand(() => FixAsync(row)));
}
}
/// <summary>An action stopped: what stopped, why in one sentence, and Retry to run it again (BRIEF §0.2 rule 6).</summary>
private void NotifyFailure(string titleKey, Exception ex, ICommand retry) =>
Shell.Notify(Loc.L(titleKey), ArchiveFailures.Cause(ex), Loc.L("Archive.Failed.Retry"), Loc.L("Tooltips.Archive.Retry"), () => retry.Execute(null));
}
+1 -4
View File
@@ -102,10 +102,7 @@
</Style.Triggers>
</Style>
<!--
Up to four digits (gap ≤ 1440). The kit's text box applies its padding twice (reported to the shared controls),
so the side padding is halved here: four digits fit before and after that fix.
-->
<!-- Up to four digits (gap ≤ 1440) in 56 px: half the usual side padding. -->
<Style x:Key="TextBox.Small" TargetType="TextBox" BasedOn="{StaticResource TextBox.Number}">
<Setter Property="Width" Value="56" />
<Setter Property="Height" Value="30" />
+1 -1
View File
@@ -262,7 +262,7 @@ public sealed class JobsViewModel : SectionViewModel
private void UpdateShell()
{
if (_model.Current is { } current)
Shell.SetJob(JobText.Bar(current), current.Fraction ?? 0, indeterminate: current.Fraction is null);
Shell.SetJob(JobText.Bar(current), current.Fraction ?? 0, indeterminate: current.Fraction is null, name: JobText.Name(current.Job));
else
Shell.SetJob(null, 0);
// The rail badge, the status strip and the Running chip count the same jobs: running or paused (Jobs.html).
+1 -1
View File
@@ -55,7 +55,7 @@
<DockPanel LastChildFill="True">
<ComboBox DockPanel.Dock="Right" VerticalAlignment="Top" MinWidth="120" ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage}"
DisplayMemberPath="Name" ToolTip="{l:Loc Tooltips.Welcome.Language}" AutomationProperties.Name="{l:Loc Settings.General.Language}" />
<ui:BrandMarkIcon Width="56" Height="56" ShowPlate="True" FlowDirection="LeftToRight" />
<ui:BrandMarkIcon Width="56" Height="56" ShowPlate="True" />
<StackPanel Margin="16,0,16,0" VerticalAlignment="Center">
<TextBlock Text="{l:Loc Shell.Welcome.Title}" FontSize="20" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" />
<TextBlock Text="{l:Loc Shell.Welcome.Question}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,4,0,0" TextTrimming="CharacterEllipsis" />
+5 -19
View File
@@ -43,8 +43,9 @@
<Setter Property="TextAlignment" Value="Right" />
</Style>
<!-- Log tail: monospaced, muted. -->
<!-- Log tail: monospaced, muted, left to right in every language (paths, times, codes). -->
<Style x:Key="Text.Log" TargetType="TextBlock">
<Setter Property="FlowDirection" Value="LeftToRight" />
<Setter Property="FontFamily" Value="{StaticResource Font.Mono}" />
<Setter Property="FontSize" Value="12" />
<Setter Property="LineHeight" Value="18" />
@@ -89,7 +90,7 @@
<!-- Section list entry of Settings: 34 px, active = Card fill + 3 px accent edge (Settings.html). -->
<Style x:Key="ListBoxItem.Section" TargetType="ListBoxItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
<Setter Property="Height" Value="34" />
<Setter Property="Margin" Value="0,0,0,2" />
@@ -145,21 +146,6 @@
<Setter Property="Margin" Value="0,0,6,0" />
</Style>
<!-- "Auto · 8" pill (DESIGN §4 Auto/manual): accent outline, 24 px, 11 px text. -->
<Style x:Key="Button.AutoPill" TargetType="Button" BasedOn="{StaticResource Button.Base}">
<Setter Property="Height" Value="24" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="Padding" Value="8,0" />
<Setter Property="FontSize" Value="11" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}" />
<Setter Property="ui:ControlState.CornerRadius" Value="12" />
<Setter Property="ui:ControlState.HoverBackground" Value="{DynamicResource Brush.AccentSubtle}" />
<Setter Property="ui:ControlState.HoverBorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="ui:ControlState.PressedBackground" Value="{DynamicResource Brush.AccentSubtle}" />
</Style>
<!-- Toolbar dropdown (Library filters): accent border while a filter is active (bind Tag to the active flag). -->
<Style x:Key="ComboBox.Filter" TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="MinWidth" Value="88" />
@@ -213,8 +199,8 @@
<Setter Property="VerticalContentAlignment" Value="Top" />
</Style>
<!-- Path and template fields in Settings (360 px, DESIGN mockup). -->
<Style x:Key="TextBox.Setting" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<!-- Path, address and template fields in Settings (360 px, DESIGN mockup), left to right in every language. -->
<Style x:Key="TextBox.Setting" TargetType="TextBox" BasedOn="{StaticResource TextBox.Path}">
<Setter Property="Width" Value="360" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
+7 -4
View File
@@ -5,14 +5,17 @@
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
Title="{l:Loc Shell.AppName}"
IsDialog="True" ResizeMode="NoResize" SizeToContent="Height" Width="460"
WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
<!-- DESIGN §4 dialog: two buttons, safe action left and default, the action on the right. -->
WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
AutomationProperties.Name="{Binding Heading}" AutomationProperties.HelpText="{Binding Message}">
<!-- DESIGN §4 dialog: two buttons, safe action left and default, the action on the right. Screen readers hear the
heading and the message as the dialog opens on the safe button. -->
<StackPanel Margin="24,18,24,20">
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" TextWrapping="Wrap" TextTrimming="None" />
<TextBlock Text="{Binding Message}" Margin="0,8,0,0" Foreground="{DynamicResource Brush.TextMuted}" TextWrapping="Wrap" TextTrimming="None" LineHeight="18" />
<Border Style="{StaticResource Border.Card}" Margin="0,16,0,0" Padding="12,10" ToolTip="{Binding DetailToolTip}"
Visibility="{Binding Detail, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<TextBlock x:Name="DetailText" Text="{Binding Detail}" FontFamily="{StaticResource Font.Mono}" FontSize="{StaticResource Size.Secondary}" TextWrapping="Wrap" TextTrimming="None" LineHeight="18" />
<TextBlock x:Name="DetailText" Text="{Binding Detail}" FontFamily="{StaticResource Font.Mono}" FontSize="{StaticResource Size.Secondary}" TextWrapping="Wrap" TextTrimming="None" LineHeight="18"
FlowDirection="LeftToRight" />
</Border>
<StackPanel x:Name="Typing" Margin="0,16,0,0" Visibility="Collapsed">
<TextBlock Text="{Binding TypedPrompt}" Foreground="{DynamicResource Brush.TextMuted}" TextWrapping="Wrap" />
@@ -20,7 +23,7 @@
AutomationProperties.Name="{Binding TypedPrompt}" TextChanged="OnTyped" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,24,0,0">
<Button Content="{Binding SafeText}" ToolTip="{Binding SafeToolTip}" IsDefault="True" IsCancel="True" MinWidth="96" Click="OnSafe" />
<Button x:Name="Safe" Content="{Binding SafeText}" ToolTip="{Binding SafeToolTip}" IsDefault="True" IsCancel="True" MinWidth="96" Click="OnSafe" />
<Button x:Name="Action" Content="{Binding ActionText}" ToolTip="{Binding ActionToolTip}" MinWidth="96" Margin="8,0,0,0" Click="OnAction" />
</StackPanel>
</StackPanel>
+11 -2
View File
@@ -12,8 +12,17 @@ public sealed partial class ConfirmDialog : TitanoWindow
DataContext = request;
InitializeComponent();
Action.SetResourceReference(StyleProperty, request.IsDestructive ? "Button.Destructive" : "Button.Primary");
if (!request.IsDetailMonospaced) DetailText.SetResourceReference(FontFamilyProperty, "Font.Ui");
if (request.TypedConfirmation is null) return;
if (!request.IsDetailMonospaced)
{
// Names and sentences follow the reading direction; only fingerprints stay left to right.
DetailText.SetResourceReference(FontFamilyProperty, "Font.Ui");
DetailText.ClearValue(FlowDirectionProperty);
}
if (request.TypedConfirmation is null)
{
Loaded += (_, _) => Safe.Focus();
return;
}
Typing.Visibility = Visibility.Visible;
Loaded += (_, _) => Typed.Focus();
EnableAction(false);
+37
View File
@@ -0,0 +1,37 @@
using System.Reflection;
using Titano.Core.Archiving;
using Titano.Core.Import;
using Titano.Core.Localization;
using Titano.Core.Render;
using Titano.Data.Archiving;
using Titano.Data.Sync;
using Titano.Protocol.Client;
namespace Titano.App.Shell;
/// <summary>
/// The sentence an error toast shows (BRIEF §0.2: one sentence saying what happened plus one action). Only failures
/// that carry a catalog sentence say what happened; anything else (framework and OS messages, often technical
/// English) reads "Something went wrong." and stays in the log.
/// </summary>
public static class ErrorText
{
public static string For(Exception ex) => Describe(Unwrap(ex)) ?? Loc.L("Errors.Unexpected");
private static string? Describe(Exception ex) => ex switch
{
LeaseUnavailableException or ArchiveOfflineException or NewerFormatException or ImportSourceUnavailableException
or CopyVerificationException or StaleRenamePlanException or SyncConflictChangedException => ex.Message,
// The server words its errors in the client's language (Accept-Language).
TitanoApiException api when !string.IsNullOrWhiteSpace(api.Error.Message) => api.Error.Message,
RenderException render => Loc.Get(render.ReasonKey, Loc.Culture) is null ? null : Loc.L(render.ReasonKey, [.. render.Args]),
_ => null,
};
/// <summary>Awaited tasks and reflection wrap the real failure in one layer or more.</summary>
private static Exception Unwrap(Exception ex)
{
while (ex is AggregateException { InnerExceptions.Count: 1 } or TargetInvocationException && ex.InnerException is { } inner) ex = inner;
return ex;
}
}
+2 -2
View File
@@ -5,11 +5,11 @@
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
Title="{l:Loc Shell.AppName}"
IsDialog="True" ResizeMode="NoResize" SizeToContent="Height" Width="440"
WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
WindowStartupLocation="CenterOwner" ShowInTaskbar="False" AutomationProperties.Name="{l:Loc Server.Login.Title}">
<!-- BRIEF §12.7 login modal: the server is already identified and its certificate trusted. -->
<StackPanel Margin="24,18,24,20">
<TextBlock Text="{l:Loc Server.Login.Title}" Style="{StaticResource Text.Title}" />
<TextBlock x:Name="ServerText" Margin="0,4,0,0" Style="{StaticResource Text.Secondary}" />
<TextBlock x:Name="ServerText" Margin="0,4,0,0" Style="{StaticResource Text.Secondary}" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
<Grid Margin="0,18,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="92" />
+8 -1
View File
@@ -1,4 +1,6 @@
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using Titano.Ui.Controls;
namespace Titano.App.Shell;
@@ -6,7 +8,8 @@ namespace Titano.App.Shell;
/// <summary>
/// The login form (BRIEF §12.7). It calls back the connection with the credentials and stays open with the
/// error sentence until the sign-in succeeds or the user cancels. The password never leaves the PasswordBox
/// except for that call.
/// except for that call. A failed sign-in is announced to screen readers and marks the password box (error border,
/// sentence as its help text) until the next attempt.
/// </summary>
public sealed partial class LoginDialog : TitanoWindow
{
@@ -40,6 +43,7 @@ public sealed partial class LoginDialog : TitanoWindow
{
SignIn.IsEnabled = false;
Error.Visibility = Visibility.Collapsed;
Field.SetError(Password, null);
try
{
var error = await _signIn(User.Text, Password.Password);
@@ -50,8 +54,11 @@ public sealed partial class LoginDialog : TitanoWindow
}
Error.Text = error;
Error.Visibility = Visibility.Visible;
Field.SetError(Password, error);
Password.Clear();
Password.Focus();
UIElementAutomationPeer.CreatePeerForElement(this)?.RaiseNotificationEvent(
AutomationNotificationKind.ActionCompleted, AutomationNotificationProcessing.ImportantMostRecent, error, "Titano.SignIn");
}
finally
{
+38 -15
View File
@@ -4,6 +4,7 @@
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
xmlns:shell="clr-namespace:Titano.App.Shell"
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
xmlns:s="clr-namespace:Titano.App.Sections"
Title="{Binding WindowTitle}"
Width="1440" Height="900" MinWidth="1200" MinHeight="760"
@@ -14,8 +15,24 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Navigation rail: full names, collapsible to icons (BRIEF §12.1). -->
<Border x:Name="Rail" Background="{DynamicResource Brush.Chrome}" Width="128" ui:NavRail.IsCollapsed="{Binding IsRailCollapsed}">
<!-- Navigation rail: full names, collapsible to icons (BRIEF §12.1). Expanded it is at least 128 px and grows with
the longest label of the language (up to 200 px); collapsed it is 48 px of icons. While the first-run dialog is
open the shell behind it takes no input. The buttons of both lists form one group (GroupName); their check
binds one way, the section the shell navigates to (a GroupName spans every window not yet on screen). -->
<Border x:Name="Rail" Background="{DynamicResource Brush.Chrome}" ui:NavRail.IsCollapsed="{Binding IsRailCollapsed}"
IsEnabled="{Binding IsShellEnabled}">
<Border.Style>
<Style TargetType="Border">
<Setter Property="MinWidth" Value="128" />
<Setter Property="MaxWidth" Value="200" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsRailCollapsed}" Value="True">
<Setter Property="MinWidth" Value="0" />
<Setter Property="Width" Value="48" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<DockPanel Margin="8,8,8,8" LastChildFill="False">
<Button DockPanel.Dock="Top" Style="{StaticResource Button.IconSubtle}" HorizontalAlignment="Left" Margin="0,0,0,6"
ui:ButtonIcon.Glyph="{StaticResource Icon.Menu}" Command="{Binding ToggleRailCommand}"
@@ -24,7 +41,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type shell:SectionViewModel}">
<ui:NavRailButton GroupName="Rail" Glyph="{Binding Glyph}" Content="{Binding Label}" Badge="{Binding Badge}"
IsChecked="{Binding IsSelected}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
IsChecked="{Binding IsSelected, Mode=OneWay}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
Command="{Binding DataContext.NavigateCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
@@ -33,7 +50,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type shell:SectionViewModel}">
<ui:NavRailButton GroupName="Rail" Glyph="{Binding Glyph}" Content="{Binding Label}" Badge="{Binding Badge}"
IsChecked="{Binding IsSelected}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
IsChecked="{Binding IsSelected, Mode=OneWay}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
Command="{Binding DataContext.NavigateCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
@@ -41,17 +58,19 @@
</DockPanel>
</Border>
<Grid Grid.Column="1">
<Grid Grid.Column="1" IsEnabled="{Binding IsShellEnabled}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Job bar (DESIGN §4): current job, progress, time left, pause; "Ready" when idle, hidden when idle in the editor. -->
<ui:JobBar Text="{Binding JobText}" Progress="{Binding JobProgress}" IsActive="{Binding IsJobActive}" IsIndeterminate="{Binding IsJobIndeterminate}"
StopCommand="{Binding StopJobCommand}" StopToolTip="{l:Loc Tooltips.Shell.PauseJob}" ActionGlyph="{StaticResource Icon.Pause}"
Visibility="{Binding IsJobBarVisible, Converter={StaticResource BoolToVisibility}}" />
<!-- Job bar (DESIGN §4): current job, progress, time left, pause; "Ready" when idle, hidden when idle in the editor.
Screen readers hear which job starts and when the queue empties, not its progress ticks. -->
<ui:JobBar x:Name="JobBar" Text="{Binding JobText}" Progress="{Binding JobProgress}" IsActive="{Binding IsJobActive}" IsIndeterminate="{Binding IsJobIndeterminate}"
StopCommand="{Binding StopJobCommand}" StopToolTip="{l:Loc Tooltips.Shell.PauseJob}" StopName="{l:Loc Shell.JobBar.Pause}" ActionGlyph="{StaticResource Icon.Pause}"
Visibility="{Binding IsJobBarVisible, Converter={StaticResource BoolToVisibility}}"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding JobAnnouncement}" />
<ContentControl Grid.Row="1" Content="{Binding Current}" Focusable="False" />
@@ -61,18 +80,22 @@
<TextBlock Text="{Binding SequencesText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock Text="{Binding PhotosText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock Text="{Binding StorageText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock x:Name="Connection" Text="{Binding ConnectionText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock x:Name="Connection" Text="{Binding ConnectionText}" Margin="0,0,18,0" VerticalAlignment="Center"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding ConnectionText}" />
<TextBlock Text="{Binding JobsText}" VerticalAlignment="Center" />
</StackPanel>
</Border>
<ui:ToastHost x:Name="Toasts" Grid.Row="0" Grid.RowSpan="3" />
</Grid>
<!-- First run (Welcome.html): the shell dimmed behind one dialog. -->
<Grid Grid.ColumnSpan="2" Visibility="{Binding IsWelcomeOpen, Converter={StaticResource BoolToVisibility}}">
<!-- First run (Welcome.html): the shell dimmed behind one dialog that keeps the keyboard. -->
<Grid x:Name="WelcomeOverlay" Grid.ColumnSpan="2" Visibility="{Binding IsWelcomeOpen, Converter={StaticResource BoolToVisibility}}"
KeyboardNavigation.TabNavigation="Cycle" KeyboardNavigation.ControlTabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Contained">
<Border Background="{DynamicResource Brush.Scrim}" />
<s:WelcomeView DataContext="{Binding Welcome}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,114,0,0" />
<s:WelcomeView DataContext="{Binding Welcome}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,114,0,0"
AutomationProperties.Name="{l:Loc Shell.Welcome.Title}" />
</Grid>
<!-- Above the first-run dialog too, so a card inserted meanwhile can still be acted on (Welcome.html). -->
<ui:ToastHost x:Name="Toasts" Grid.ColumnSpan="2" />
</Grid>
</ui:TitanoWindow>
+37 -4
View File
@@ -1,5 +1,9 @@
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Titano.App.Infrastructure;
using Titano.Ui.Controls;
@@ -14,21 +18,50 @@ public partial class MainWindow : TitanoWindow
_shell = shell;
DataContext = shell;
InitializeComponent();
Rail.Width = shell.IsRailCollapsed ? 48 : 128;
UpdateConnection();
shell.PropertyChanged += (_, e) =>
{
if (e.PropertyName is nameof(ShellViewModel.IsRailCollapsed) or "")
Rail.Width = shell.IsRailCollapsed ? 48 : 128;
if (e.PropertyName is nameof(ShellViewModel.IsConnected) or "") UpdateConnection();
if (e.PropertyName is nameof(ShellViewModel.IsWelcomeOpen) or "") FocusWelcome();
};
shell.PendingToasts.CollectionChanged += OnToastRequested;
Loaded += (_, _) => FocusWelcome();
RestorePlacement();
Closing += (_, _) => SavePlacement();
}
/// <summary>F6 moves the keyboard to the newest notification (as in Windows apps), Esc there dismisses it.</summary>
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (!e.Handled && e.Key == Key.F6 && Keyboard.Modifiers == ModifierKeys.None) e.Handled = Toasts.FocusNewest();
}
private void UpdateConnection() =>
Connection.SetResourceReference(System.Windows.Controls.TextBlock.ForegroundProperty, _shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
Connection.SetResourceReference(TextBlock.ForegroundProperty, _shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
/// <summary>The first-run dialog takes the keyboard on its chosen option once it is on screen.</summary>
private void FocusWelcome()
{
if (!_shell.IsWelcomeOpen) return;
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () =>
{
if (!_shell.IsWelcomeOpen || !IsLoaded) return;
if (FindChecked(WelcomeOverlay) is { } choice) choice.Focus();
else WelcomeOverlay.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
});
}
private static RadioButton? FindChecked(DependencyObject root)
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
{
var child = VisualTreeHelper.GetChild(root, i);
if (child is RadioButton { IsChecked: true } radio) return radio;
if (FindChecked(child) is { } nested) return nested;
}
return null;
}
private void OnToastRequested(object? sender, NotifyCollectionChangedEventArgs e)
{
+45 -1
View File
@@ -7,6 +7,7 @@ using Titano.App.Archiving;
using Titano.App.DesignTime;
using Titano.App.Editor;
using Titano.App.Import;
using Titano.App.Infrastructure;
using Titano.App.Library;
using Titano.App.Server;
using Titano.App.Settings;
@@ -18,7 +19,9 @@ namespace Titano.App.Shell;
/// <summary>
/// <c>Titano.exe --capture &lt;dir&gt;</c>: renders every client screen at 1440×900 in the dark and light themes to
/// <c>&lt;screen&gt;-&lt;theme&gt;.png</c> from <see cref="SampleData"/> (first run on an empty index, then a populated
/// one, then the sync table with transfers, a conflict and its confirmation), for visual review and phase reports (BRIEF §20.2), then exits.
/// one, then the sync table with transfers, a conflict and its confirmation), plus the Library, the editor's Exposure
/// tab and the import plan in Arabic (<c>*-rtl-dark.png</c>, right to left), for visual review and phase reports
/// (BRIEF §20.2), then exits.
/// </summary>
public static class ScreenCapture
{
@@ -82,6 +85,9 @@ public static class ScreenCapture
written += await SaveAsync(window, directory, "library-list", theme, waitForThumbnails: shell);
shell.Library.LayoutIndex = 0;
shell.Library.ClearSelectionCommand.Execute(null);
shell.IsRailCollapsed = true;
written += await SaveAsync(window, directory, "library-rail-collapsed", theme, waitForThumbnails: shell);
shell.IsRailCollapsed = false;
written += await CaptureLibraryScenesAsync(window, shell, directory, theme);
shell.Navigate(SectionKey.Jobs);
@@ -241,6 +247,8 @@ public static class ScreenCapture
foreach (var toast in window.Toasts.Toasts.ToList()) window.Toasts.Dismiss(toast);
}
written += await CaptureRightToLeftAsync(window, shell, editor, directory);
// Last, as it stays: an analysis of the sequence running (settings disabled, viewing tools live).
await sample.MarkAnalysingAsync(id);
await editor.AttachJobsAsync();
@@ -252,6 +260,41 @@ public static class ScreenCapture
return written;
}
/// <summary>
/// The Library, the editor's Exposure tab and the import plan in Arabic, dark: the layout mirrors while photos,
/// charts, the filmstrip and templates stay left to right. English is restored whatever happens.
/// </summary>
private static async Task<int> CaptureRightToLeftAsync(MainWindow window, ShellViewModel shell, EditorViewModel editor, string directory)
{
var written = 0;
var frame = editor.CurrentIndex;
ThemeManager.Apply(AppTheme.Dark);
UiLanguage.Apply("ar");
try
{
DismissToasts(window);
shell.Navigate(SectionKey.Library);
written += await SaveAsync(window, directory, "library-rtl", AppTheme.Dark, waitForThumbnails: shell);
shell.Navigate(SectionKey.Sequence);
editor.SelectedTab = editor.Exposure;
editor.IsCompare = true;
editor.CurrentIndex = 45;
written += await SaveEditorAsync(window, editor, directory, "sequence-exposure-rtl", AppTheme.Dark);
await ImportScenes.ShowAsync(shell, "plan");
DismissToasts(window);
written += await SaveAsync(window, directory, "import-plan-rtl", AppTheme.Dark);
}
finally
{
UiLanguage.Apply("en");
}
shell.Navigate(SectionKey.Sequence);
editor.CurrentIndex = frame;
return written;
}
private static async Task<int> SaveEditorAsync(Window window, EditorViewModel editor, string directory, string screen, AppTheme theme)
{
await Settle(window);
@@ -306,6 +349,7 @@ public static class ScreenCapture
return false;
}
var bitmap = new RenderTargetBitmap(width, height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32);
// A right-to-left window's content already renders mirrored, as on screen.
bitmap.Render(root);
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
+26 -8
View File
@@ -16,6 +16,7 @@ public sealed class ShellViewModel : LocalizedViewModel
private SectionViewModel _current;
private bool _isRailCollapsed;
private string? _jobText;
private string? _jobName;
private double _jobProgress;
private bool _jobActive;
private bool _jobIndeterminate;
@@ -85,12 +86,17 @@ public sealed class ShellViewModel : LocalizedViewModel
get => _welcome;
private set
{
if (Set(ref _welcome, value)) OnPropertyChanged(nameof(IsWelcomeOpen));
if (!Set(ref _welcome, value)) return;
OnPropertyChanged(nameof(IsWelcomeOpen));
OnPropertyChanged(nameof(IsShellEnabled));
}
}
public bool IsWelcomeOpen => _welcome is not null;
/// <summary>The rail and the sections take input only while no first-run dialog covers them.</summary>
public bool IsShellEnabled => _welcome is null;
public SectionViewModel Current
{
get => _current;
@@ -105,7 +111,7 @@ public sealed class ShellViewModel : LocalizedViewModel
}
}
public string WindowTitle => Current == Library ? "Titano" : "Titano — " + Current.Title;
public string WindowTitle => Current == Library ? Loc.L("Shell.AppName") : Loc.L("Shell.WindowTitle", Loc.L("Shell.AppName"), Current.Title);
public bool IsRailCollapsed
{
@@ -160,7 +166,7 @@ public sealed class ShellViewModel : LocalizedViewModel
// ---- Job bar ----
public string JobText => _jobActive && _jobText is not null
? _jobText
: _queuedCount > 0 ? Loc.L("Shell.JobBar.Ready", _queuedCount) : Loc.L("Shell.JobBar.Idle");
: _queuedCount > 0 ? Loc.Plural("Shell.JobBar.Ready", _queuedCount) : Loc.L("Shell.JobBar.Idle");
public double JobProgress { get => _jobProgress; private set => Set(ref _jobProgress, value); }
public bool IsJobActive
@@ -179,14 +185,25 @@ public sealed class ShellViewModel : LocalizedViewModel
/// <summary>Pauses the job the bar shows.</summary>
public ICommand? StopJobCommand => Jobs.PauseCurrentCommand;
/// <summary>Updates the global job bar (and the taskbar progress through the window).</summary>
public void SetJob(string? text, double progress, bool indeterminate = false)
/// <summary>
/// What screen readers hear from the job bar: the job when one starts, the idle line when the last one ends; not its
/// progress, speed or time left, which change every second.
/// </summary>
public string JobAnnouncement => _jobActive && _jobName is not null ? _jobName : JobText;
/// <summary>
/// Updates the global job bar (and the taskbar progress through the window). <paramref name="name"/> says which job
/// it is without its progress ("Render: Harbour sunset"); null reads <paramref name="text"/>.
/// </summary>
public void SetJob(string? text, double progress, bool indeterminate = false, string? name = null)
{
_jobText = text;
_jobName = text is null ? null : name ?? text;
IsJobActive = text is not null;
JobProgress = progress;
IsJobIndeterminate = indeterminate;
OnPropertyChanged(nameof(JobText));
OnPropertyChanged(nameof(JobAnnouncement));
}
// ---- Status strip ----
@@ -222,6 +239,7 @@ public sealed class ShellViewModel : LocalizedViewModel
_queuedCount = queued;
OnPropertyChanged(nameof(JobsText));
OnPropertyChanged(nameof(JobText));
OnPropertyChanged(nameof(JobAnnouncement));
}
public void Navigate(SectionKey key)
@@ -250,14 +268,14 @@ public sealed class ShellViewModel : LocalizedViewModel
ActionCommand = action is null ? null : new RelayCommand(action),
});
/// <summary>Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6).</summary>
/// <summary>Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6); the details go to the log.</summary>
public void ReportError(Exception ex)
{
Log.Error("ui", "Operation failed", ex);
ShowToast(new Toast
{
Title = Loc.L("Errors.Unexpected"),
Message = ex.Message,
Title = ErrorText.For(ex),
IsError = true,
ActionText = Loc.L("Common.OpenLogs"),
ActionToolTip = Loc.L("Tooltips.Common.OpenLogs"),
ActionCommand = new RelayCommand(() => ShellActions.Reveal(Services.Environment.LogDirectory)),
+8 -2
View File
@@ -60,6 +60,12 @@ public sealed class StaleDeletePlanException(Guid sequenceId) : InvalidOperation
public Guid SequenceId { get; } = sequenceId;
}
/// <summary>A trash entry cannot come back: the index already holds its sequence (restored before, or scanned again); nothing moved.</summary>
public sealed class SequenceInLibraryException(Guid sequenceId, string title) : InvalidOperationException(Loc.L("Archive.Error.InLibrary", title))
{
public Guid SequenceId { get; } = sequenceId;
}
/// <summary>
/// Deleting sequences without erasing anything (BRIEF §0.2 rule 8, §12.2, §12.5): <see cref="PlanAsync"/> is the dry
/// run; <see cref="DeleteAsync"/> moves each sequence folder whole — originals, proxies, exports and its sidecars — into
@@ -188,7 +194,7 @@ public sealed class SequenceTrash
/// sequence's id, as a scan would adopt it, with the title, tags, rating and notes the record kept. Returns the
/// restored row. When it cannot be indexed, the folder goes back into the trash with its record.
/// </summary>
/// <exception cref="InvalidOperationException">The index already holds that sequence.</exception>
/// <exception cref="SequenceInLibraryException">The index already holds that sequence.</exception>
/// <exception cref="DirectoryNotFoundException">The entry is not in the trash.</exception>
public async Task<Sequence> RestoreAsync(Archive archive, string name, CancellationToken cancellationToken = default)
{
@@ -203,7 +209,7 @@ public sealed class SequenceTrash
throw new DirectoryNotFoundException($"{name} is not in the trash of {archive.Name}.");
var id = record.Sequence.Id;
if (await _db.Sequences.GetAsync(id, cancellationToken).ConfigureAwait(false) is not null)
throw new InvalidOperationException(Loc.L("Archive.Error.InLibrary", record.Sequence.DisplayTitle));
throw new SequenceInLibraryException(id, record.Sequence.DisplayTitle);
var locations = (await _db.Sequences.ListLocationsAsync(archive.Id, cancellationToken).ConfigureAwait(false)).Select(l => l.Folder)
.ToHashSet(StringComparer.OrdinalIgnoreCase);
+4 -1
View File
@@ -37,7 +37,10 @@ public static class ProcessingJobs
ArgumentNullException.ThrowIfNull(sequence);
ArgumentNullException.ThrowIfNull(export);
var parameters = Parameters(export, sourceWidth, sourceHeight, project?.ToJson(), useProxies);
return new ArchiveJobRequest(JobKind.Render, [sequence.Id], $"{sequence.DisplayTitle} → {parameters.PresetName}",
// The label is stored as written, in the language of the moment like the preset name: its arrow points from the
// sequence to the preset in that language's reading direction.
var label = Loc.L(Loc.IsRightToLeft ? "Jobs.Target.RenderRtl" : "Jobs.Target.Render", sequence.DisplayTitle, parameters.PresetName);
return new ArchiveJobRequest(JobKind.Render, [sequence.Id], label,
JsonSerializer.Serialize(parameters, ProtocolJson.Default.RenderJobParameters), JobPriority.User);
}
+1 -2
View File
@@ -18,8 +18,7 @@
<DockPanel>
<ComboBox DockPanel.Dock="Right" MinWidth="180" VerticalAlignment="Center" ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage}"
DisplayMemberPath="Name" IsEnabled="{Binding IsOptions}" ToolTip="{l:Loc Tooltips.Setup.Language}" AutomationProperties.Name="{l:Loc Setup.Field.Language}" />
<!-- The mark is artwork: its off-centre sun must not flip in right-to-left languages. -->
<ui:BrandMarkIcon ShowPlate="True" Width="40" Height="40" Margin="0,0,14,0" VerticalAlignment="Center" FlowDirection="LeftToRight" />
<ui:BrandMarkIcon ShowPlate="True" Width="40" Height="40" Margin="0,0,14,0" VerticalAlignment="Center" />
<StackPanel VerticalAlignment="Center">
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.PageTitle}" />
<TextBlock Text="{Binding SubHeading}" Style="{StaticResource Text.Secondary}" />
@@ -26,8 +26,6 @@ internal sealed partial class SetupWindow : TitanoWindow
_shownStage = model.Stage;
DataContext = model;
InitializeComponent();
ApplyFlowDirection();
Loc.CultureChanged += OnCultureChanged;
// Ahead of the chrome's own Close binding, which is always enabled.
CommandBindings.Insert(0, new CommandBinding(SystemCommands.CloseWindowCommand, null, OnCanClose));
model.PickFolder = initial => FolderPicker.Pick(new WindowInteropHelper(this).Handle, Loc.L("Setup.Field.Folder"), initial);
@@ -46,12 +44,6 @@ internal sealed partial class SetupWindow : TitanoWindow
base.OnClosing(e);
}
protected override void OnClosed(EventArgs e)
{
Loc.CultureChanged -= OnCultureChanged;
base.OnClosed(e);
}
private void OnCanClose(object sender, CanExecuteRoutedEventArgs e)
{
if (!_model.IsWorking) return;
@@ -97,8 +89,4 @@ internal sealed partial class SetupWindow : TitanoWindow
var buttons = Footer.Children.OfType<Button>().Where(b => b.IsVisible).ToList();
(buttons.FirstOrDefault(b => b.IsDefault) ?? buttons.FirstOrDefault())?.Focus();
}
private void OnCultureChanged(object? sender, EventArgs e) => ApplyFlowDirection();
private void ApplyFlowDirection() => FlowDirection = Loc.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
}
+33 -4
View File
@@ -1,14 +1,17 @@
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using Titano.Core.Localization;
namespace Titano.Ui.Controls;
/// <summary>
/// Advisor-aware slider (BRIEF §10.4, DESIGN §4): in Auto the track is accent with an "Auto · value" pill whose
/// tooltip carries the advisor's reason; touching the slider switches to manual (sun track, value shown, reset
/// button returns to Auto). When not applicable the value reads "n/a" with the reason in the tooltip.
/// button returns to Auto). When not applicable the value reads "n/a" with the reason in the tooltip. Screen readers
/// see a group named after <see cref="Header"/> holding the named slider, the Auto pill and the reset button.
/// </summary>
[TemplatePart(Name = PartSlider, Type = typeof(Slider))]
public class AutoSlider : Control
@@ -47,6 +50,14 @@ public class AutoSlider : Control
public AutoSlider()
{
CommandBindings.Add(new CommandBinding(ResetCommand, (_, _) => ResetToAuto()));
// The pill and the value follow a language switch; the static event is held only while the slider is shown.
Loaded += (_, _) =>
{
Loc.CultureChanged -= OnCultureChanged;
Loc.CultureChanged += OnCultureChanged;
UpdateTexts();
};
Unloaded += (_, _) => Loc.CultureChanged -= OnCultureChanged;
UpdateTexts();
}
@@ -67,7 +78,7 @@ public class AutoSlider : Control
/// <summary>Formatted current value (read by the template).</summary>
public string DisplayValue { get => (string)GetValue(DisplayValueProperty); private set => SetValue(DisplayValueProperty, value); }
/// <summary>"Auto · 41" pill text; the "Auto" word comes from the catalog (Common.Auto).</summary>
/// <summary>"Auto · 41" pill text (Common.AutoValue).</summary>
public string AutoText { get => (string)GetValue(AutoTextProperty); private set => SetValue(AutoTextProperty, value); }
/// <summary>Tooltip of the slider track: what moving it does.</summary>
@@ -131,12 +142,30 @@ public class AutoSlider : Control
s.UpdateTexts();
}
protected override AutomationPeer OnCreateAutomationPeer() => new AutoSliderAutomationPeer(this);
private static void OnFormatChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((AutoSlider)d).UpdateTexts();
private void OnCultureChanged(object? sender, EventArgs e) => UpdateTexts();
private void UpdateTexts()
{
var culture = Core.Localization.Loc.Culture;
var culture = Loc.Culture;
DisplayValue = Value.ToString(ValueFormat, culture);
AutoText = Core.Localization.Loc.L("Common.Auto") + " · " + AutoValue.ToString(ValueFormat, culture);
AutoText = Loc.L("Common.AutoValue", AutoValue.ToString(ValueFormat, culture));
}
}
/// <summary>A named group around the slider, the Auto pill and the reset button.</summary>
public sealed class AutoSliderAutomationPeer(AutoSlider owner) : FrameworkElementAutomationPeer(owner)
{
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Group;
protected override string GetClassNameCore() => nameof(AutoSlider);
protected override string GetNameCore()
{
var name = base.GetNameCore();
return string.IsNullOrEmpty(name) ? ((AutoSlider)Owner).Header ?? string.Empty : name;
}
}
+30
View File
@@ -0,0 +1,30 @@
using System.Windows;
namespace Titano.Ui.Controls;
/// <summary>
/// Right-to-left rules of the kit (BRIEF §16, DESIGN §5). Windows take their direction from the UI language, so
/// layout mirrors by itself; an <see cref="Icon"/> mirrors with it only when its glyph is directional
/// (<see cref="IconData.IsDirectional"/>). <see cref="IsDirectionalProperty"/> overrides that per subtree, e.g. a
/// play triangle used as a "next" arrow (true) or a chevron that points along a left-to-right time axis (false).
/// Media, charts, numbers, paths and templates are left-to-right islands: set <c>FlowDirection="LeftToRight"</c>
/// on the smallest element that holds them, and a directional icon inside an island keeps its drawn orientation.
/// </summary>
public static class Bidi
{
/// <summary>Inherited override of <see cref="IconData.IsDirectional"/>; null keeps each glyph's own flag.</summary>
public static readonly DependencyProperty IsDirectionalProperty = DependencyProperty.RegisterAttached(
"IsDirectional", typeof(bool?), typeof(Bidi), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits, OnIsDirectionalChanged));
public static bool? GetIsDirectional(DependencyObject d) => (bool?)d.GetValue(IsDirectionalProperty);
public static void SetIsDirectional(DependencyObject d, bool? value) => d.SetValue(IsDirectionalProperty, value);
/// <summary>The flow direction of the current UI language.</summary>
public static FlowDirection UiDirection => Core.Localization.Loc.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
private static void OnIsDirectionalChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is Icon icon) icon.UpdateDirection();
}
}
+4 -1
View File
@@ -4,7 +4,7 @@ using Titano.Core.Branding;
namespace Titano.Ui.Controls;
/// <summary>The Titano mark drawn as vectors from <see cref="BrandMark"/> geometry (plate optional).</summary>
/// <summary>The Titano mark drawn as vectors from <see cref="BrandMark"/> geometry (plate optional); it never mirrors.</summary>
public sealed class BrandMarkIcon : FrameworkElement
{
public static readonly DependencyProperty ShowPlateProperty = DependencyProperty.Register(
@@ -14,6 +14,9 @@ public sealed class BrandMarkIcon : FrameworkElement
private static readonly Brush Sun = Frozen(new SolidColorBrush(Color.FromRgb(BrandMark.Sun.R, BrandMark.Sun.G, BrandMark.Sun.B)));
private static readonly Brush Plate = Frozen(new SolidColorBrush(Color.FromRgb(BrandMark.Plate.R, BrandMark.Plate.G, BrandMark.Plate.B)));
// A logo keeps its orientation in right-to-left layouts: the sun stays north-east, the ticks clockwise.
public BrandMarkIcon() => FlowDirection = FlowDirection.LeftToRight;
public bool ShowPlate
{
get => (bool)GetValue(ShowPlateProperty);
+23 -1
View File
@@ -2,7 +2,10 @@ using System.Windows;
namespace Titano.Ui.Controls;
/// <summary>Attached field helpers: placeholder text and an inline leading icon for text inputs.</summary>
/// <summary>
/// Attached field helpers: placeholder text and an inline leading icon for text inputs, and the error of an input that
/// has no validating binding (a password box): the error border, with the message as help text for screen readers.
/// </summary>
public static class Field
{
public static readonly DependencyProperty PlaceholderProperty = DependencyProperty.RegisterAttached(
@@ -11,6 +14,16 @@ public static class Field
public static readonly DependencyProperty GlyphProperty = DependencyProperty.RegisterAttached(
"Glyph", typeof(IconData), typeof(Field), new FrameworkPropertyMetadata(null));
/// <summary>One sentence saying what is wrong with the value; null when it is fine.</summary>
public static readonly DependencyProperty ErrorProperty = DependencyProperty.RegisterAttached(
"Error", typeof(string), typeof(Field), new FrameworkPropertyMetadata(null, OnErrorChanged));
private static readonly DependencyPropertyKey HasErrorKey = DependencyProperty.RegisterAttachedReadOnly(
"HasError", typeof(bool), typeof(Field), new FrameworkPropertyMetadata(false));
/// <summary>True while <see cref="ErrorProperty"/> holds a message; the input templates trigger on it.</summary>
public static readonly DependencyProperty HasErrorProperty = HasErrorKey.DependencyProperty;
public static string? GetPlaceholder(DependencyObject d) => (string?)d.GetValue(PlaceholderProperty);
public static void SetPlaceholder(DependencyObject d, string? value) => d.SetValue(PlaceholderProperty, value);
@@ -18,6 +31,15 @@ public static class Field
public static IconData? GetGlyph(DependencyObject d) => (IconData?)d.GetValue(GlyphProperty);
public static void SetGlyph(DependencyObject d, IconData? value) => d.SetValue(GlyphProperty, value);
public static string? GetError(DependencyObject d) => (string?)d.GetValue(ErrorProperty);
public static void SetError(DependencyObject d, string? value) => d.SetValue(ErrorProperty, value);
public static bool GetHasError(DependencyObject d) => (bool)d.GetValue(HasErrorProperty);
private static void OnErrorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) =>
d.SetValue(HasErrorKey, !string.IsNullOrEmpty((string?)e.NewValue));
}
/// <summary>Attached glyph for buttons: renders an <see cref="IconData"/> before (or instead of) the content.</summary>
+18 -2
View File
@@ -4,12 +4,16 @@ using System.Windows.Media;
namespace Titano.Ui.Controls;
/// <summary>Renders an <see cref="IconData"/> on the 16-unit grid, scaled to the element size, in the inherited foreground.</summary>
/// <summary>
/// Renders an <see cref="IconData"/> on the 16-unit grid, scaled to the element size, in the inherited foreground,
/// centred in its slot. Only directional glyphs follow a right-to-left layout (<see cref="Bidi"/>); the others keep
/// their drawn orientation.
/// </summary>
public sealed class Icon : FrameworkElement
{
public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register(
nameof(Glyph), typeof(IconData), typeof(Icon),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, (d, _) => ((Icon)d).UpdateDirection()));
public static readonly DependencyProperty ForegroundProperty = TextElement.ForegroundProperty.AddOwner(
typeof(Icon), new FrameworkPropertyMetadata(Brushes.Gray, FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsRender));
@@ -26,8 +30,13 @@ public sealed class Icon : FrameworkElement
{
SnapsToDevicePixelsProperty.OverrideMetadata(typeof(Icon), new FrameworkPropertyMetadata(true));
FocusableProperty.OverrideMetadata(typeof(Icon), new FrameworkPropertyMetadata(false));
// The glyph is drawn from the top-left of the element: a stretched slot would pull it off centre.
HorizontalAlignmentProperty.OverrideMetadata(typeof(Icon), new FrameworkPropertyMetadata(HorizontalAlignment.Center));
VerticalAlignmentProperty.OverrideMetadata(typeof(Icon), new FrameworkPropertyMetadata(VerticalAlignment.Center));
}
public Icon() => UpdateDirection();
public IconData? Glyph
{
get => (IconData?)GetValue(GlyphProperty);
@@ -56,6 +65,13 @@ public sealed class Icon : FrameworkElement
protected override Size MeasureOverride(Size availableSize) => new(Size, Size);
/// <summary>A directional glyph inherits the layout direction (and mirrors with it); any other glyph is pinned left-to-right.</summary>
internal void UpdateDirection()
{
if (Bidi.GetIsDirectional(this) ?? Glyph?.IsDirectional ?? false) ClearValue(FlowDirectionProperty);
else SetValue(FlowDirectionProperty, FlowDirection.LeftToRight);
}
protected override void OnRender(DrawingContext dc)
{
var glyph = Glyph;
+6
View File
@@ -22,6 +22,12 @@ public sealed class IconData
set => _fill = Freeze(value);
}
/// <summary>
/// The glyph points along the reading direction (back/forward arrows, chevrons, start-aligned lines), so it
/// mirrors in right-to-left layouts (DESIGN §5); every other glyph keeps its drawn orientation.
/// </summary>
public bool IsDirectional { get; set; }
private static Geometry? Freeze(Geometry? g)
{
if (g is { CanFreeze: true, IsFrozen: false }) g.Freeze();
+26 -1
View File
@@ -1,10 +1,15 @@
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Input;
namespace Titano.Ui.Controls;
/// <summary>40-px strip under the title bar: current job, progress, time left and a stop (or pause) button (DESIGN §4).</summary>
/// <summary>
/// 40-px strip under the title bar: current job, progress, time left and a stop (or pause) button (DESIGN §4). Screen
/// readers see a status bar; its name is <c>AutomationProperties.Name</c> (the owner keeps it to the job's state, so
/// it can be a live region that does not speak every progress tick), else <see cref="Text"/>.
/// </summary>
public class JobBar : Control
{
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(nameof(Text), typeof(string), typeof(JobBar));
@@ -13,6 +18,7 @@ public class JobBar : Control
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(nameof(IsActive), typeof(bool), typeof(JobBar));
public static readonly DependencyProperty StopCommandProperty = DependencyProperty.Register(nameof(StopCommand), typeof(ICommand), typeof(JobBar));
public static readonly DependencyProperty StopToolTipProperty = DependencyProperty.Register(nameof(StopToolTip), typeof(object), typeof(JobBar));
public static readonly DependencyProperty StopNameProperty = DependencyProperty.Register(nameof(StopName), typeof(string), typeof(JobBar));
public static readonly DependencyProperty ActionGlyphProperty = DependencyProperty.Register(nameof(ActionGlyph), typeof(IconData), typeof(JobBar));
static JobBar()
@@ -33,6 +39,25 @@ public class JobBar : Control
public ICommand? StopCommand { get => (ICommand?)GetValue(StopCommandProperty); set => SetValue(StopCommandProperty, value); }
public object? StopToolTip { get => GetValue(StopToolTipProperty); set => SetValue(StopToolTipProperty, value); }
/// <summary>Short accessible name of the stop (or pause) button; the tooltip sentence becomes its help text.</summary>
public string? StopName { get => (string?)GetValue(StopNameProperty); set => SetValue(StopNameProperty, value); }
/// <summary>Glyph of the action button: stop by default; the client shows pause (DESIGN §4 job bar).</summary>
public IconData? ActionGlyph { get => (IconData?)GetValue(ActionGlyphProperty); set => SetValue(ActionGlyphProperty, value); }
protected override AutomationPeer OnCreateAutomationPeer() => new JobBarAutomationPeer(this);
}
/// <summary>The job bar seen by UI Automation: a status bar holding the progress bar and the pause button.</summary>
public sealed class JobBarAutomationPeer(JobBar owner) : FrameworkElementAutomationPeer(owner)
{
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.StatusBar;
protected override string GetClassNameCore() => nameof(JobBar);
protected override string GetNameCore()
{
var name = base.GetNameCore();
return string.IsNullOrEmpty(name) ? ((JobBar)Owner).Text ?? string.Empty : name;
}
}
+14 -1
View File
@@ -4,6 +4,7 @@ using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Shell;
using Titano.Core.Localization;
using Titano.Ui.Interop;
using Titano.Ui.Theming;
@@ -12,7 +13,8 @@ namespace Titano.Ui.Controls;
/// <summary>
/// Window with Titano's custom chrome: 34-px title bar in the Chrome colour, brand mark, title, optional
/// title-bar content and drawn caption buttons. The maximise button answers HTMAXBUTTON so Windows 11
/// snap layouts appear on hover.
/// snap layouts appear on hover. The window lays out in the direction of the UI language from its creation on and
/// follows every language switch while it is shown (BRIEF §16).
/// </summary>
[TemplatePart(Name = PartMaximize, Type = typeof(Button))]
public class TitanoWindow : Window
@@ -54,6 +56,7 @@ public class TitanoWindow : Window
CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, (_, _) => ToggleMaximize()));
UseLayoutRounding = true;
TextOptions.SetTextFormattingMode(this, TextFormattingMode.Display);
FlowDirection = Bidi.UiDirection;
}
/// <summary>Extra content placed in the title bar between the title and the caption buttons.</summary>
@@ -88,8 +91,18 @@ public class TitanoWindow : Window
base.OnSourceInitialized(e);
ThemeManager.ApplyChrome(this);
if (PresentationSource.FromVisual(this) is HwndSource source) source.AddHook(WndProc);
// Subscribed only while shown: the static event must not keep a closed (or never shown) window alive.
Loc.CultureChanged += OnCultureChanged;
}
protected override void OnClosed(EventArgs e)
{
Loc.CultureChanged -= OnCultureChanged;
base.OnClosed(e);
}
private void OnCultureChanged(object? sender, EventArgs e) => Dispatcher.Invoke(() => FlowDirection = Bidi.UiDirection);
private void ToggleMaximize()
{
if (WindowState == WindowState.Maximized) SystemCommands.RestoreWindow(this);
+83 -14
View File
@@ -1,6 +1,9 @@
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Threading;
using Titano.Ui.Mvvm;
@@ -16,12 +19,21 @@ public sealed class Toast : ObservableObject
public ICommand? ActionCommand { get; init; }
public string? ActionToolTip { get; init; }
public TimeSpan Lifetime { get; init; } = TimeSpan.FromSeconds(8);
/// <summary>Something failed: screen readers say it at once, ahead of other notices (assertive, not polite).</summary>
public bool IsError { get; init; }
}
/// <summary>Bottom-right stack of <see cref="Toast"/>s with auto-dismiss.</summary>
/// <summary>
/// Bottom-right stack of <see cref="Toast"/>s with auto-dismiss. Screen readers hear each toast as it appears; the
/// timers pause while the pointer or the keyboard focus is on a toast; <see cref="FocusNewest"/> brings the keyboard
/// to the newest one, Esc dismisses the focused one and focus then returns where it came from; running a toast's
/// action closes it.
/// </summary>
public class ToastHost : ItemsControl
{
private readonly Dictionary<Toast, DispatcherTimer> _timers = [];
private IInputElement? _returnFocus;
static ToastHost()
{
@@ -35,12 +47,15 @@ public class ToastHost : ItemsControl
{
if (e.Parameter is Toast t) Dismiss(t);
}));
AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(OnButtonClick));
}
public static RoutedCommand DismissCommand { get; } = new(nameof(DismissCommand), typeof(ToastHost));
public ObservableCollection<Toast> Toasts { get; } = [];
private bool IsHeld => IsMouseOver || IsKeyboardFocusWithin;
public void Show(Toast toast)
{
Toasts.Add(toast);
@@ -48,32 +63,86 @@ public class ToastHost : ItemsControl
var timer = new DispatcherTimer { Interval = toast.Lifetime };
timer.Tick += (_, _) => Dismiss(toast);
_timers[toast] = timer;
timer.Start();
}
/// <summary>Pauses or resumes the dismissal timer (hover pauses).</summary>
public void SetPaused(Toast toast, bool paused)
{
if (!_timers.TryGetValue(toast, out var timer)) return;
if (paused) timer.Stop();
else timer.Start();
timer.IsEnabled = !IsHeld;
Announce(toast);
}
public void Dismiss(Toast toast)
{
if (_timers.Remove(toast, out var timer)) timer.Stop();
var hadFocus = IsKeyboardFocusWithin;
Toasts.Remove(toast);
if (hadFocus && !IsKeyboardFocusWithin && _returnFocus is UIElement { IsVisible: true } previous) previous.Focus();
}
protected override void OnPreviewMouseMove(MouseEventArgs e)
/// <summary>Moves the keyboard to the newest toast's first control; false when no toast is shown.</summary>
public bool FocusNewest()
{
base.OnPreviewMouseMove(e);
foreach (var t in Toasts.ToList()) SetPaused(t, true);
if (Toasts.Count == 0) return false;
UpdateLayout();
return ItemContainerGenerator.ContainerFromIndex(Toasts.Count - 1) is UIElement container
&& container.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
}
protected override void OnPreviewGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnPreviewGotKeyboardFocus(e);
if (e.OldFocus is not DependencyObject old || !IsAncestorOf(old)) _returnFocus = e.OldFocus;
}
protected override void OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
{
base.OnIsKeyboardFocusWithinChanged(e);
UpdateTimers();
}
protected override void OnMouseEnter(MouseEventArgs e)
{
base.OnMouseEnter(e);
UpdateTimers();
}
protected override void OnMouseLeave(MouseEventArgs e)
{
base.OnMouseLeave(e);
foreach (var t in Toasts.ToList()) SetPaused(t, false);
UpdateTimers();
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.Handled || e.Key != Key.Escape || (e.OriginalSource as FrameworkElement)?.DataContext is not Toast toast) return;
Dismiss(toast);
e.Handled = true;
}
/// <summary>Hovering or focusing any toast holds them all; leaving restarts their full lifetime.</summary>
private void UpdateTimers()
{
var held = IsHeld;
foreach (var timer in _timers.Values)
{
timer.Stop();
if (!held) timer.Start();
}
}
/// <summary>The action executes right after its Click event; the toast closes once it has run.</summary>
private void OnButtonClick(object sender, RoutedEventArgs e)
{
if (e.OriginalSource is ButtonBase { DataContext: Toast toast, Command: { } command } && ReferenceEquals(command, toast.ActionCommand))
Dispatcher.BeginInvoke(() => Dismiss(toast));
}
/// <summary>
/// A UI Automation notification rather than a live region: a toast is a new element, not a text that changes, and
/// the host's peer is always in the tree. Notices queue (polite); errors interrupt (assertive).
/// </summary>
private void Announce(Toast toast)
{
var text = string.IsNullOrEmpty(toast.Message) ? toast.Title : toast.Title + " " + toast.Message;
UIElementAutomationPeer.CreatePeerForElement(this)?.RaiseNotificationEvent(
AutomationNotificationKind.Other, toast.IsError ? AutomationNotificationProcessing.ImportantAll : AutomationNotificationProcessing.All,
text, "Titano.Toast");
}
}
+8 -8
View File
@@ -6,7 +6,7 @@
<ui:IconData x:Key="Icon.ActualSize" Stroke="M3.0 2.5 H13.0 A1.5 1.5 0 0 1 14.5 4.0 V12.0 A1.5 1.5 0 0 1 13.0 13.5 H3.0 A1.5 1.5 0 0 1 1.5 12.0 V4.0 A1.5 1.5 0 0 1 3.0 2.5 Z M5 6 L6 5.5 V10.5 M9.5 6 L10.5 5.5 V10.5 M8 7 V7.1 M8 9.5 V9.6" />
<ui:IconData x:Key="Icon.Analyse" Stroke="M1.5 8.5 H4.5 L6.5 3.5 L9.5 12.5 L11.5 8.5 H14.5" />
<ui:IconData x:Key="Icon.Archive" Stroke="M2 4.5 H14 V13.5 H2 Z M2 2 H14 V4.5 H2 Z M6 8 H10" />
<ui:IconData x:Key="Icon.Back" Stroke="M13 8 H3 M7 4 L3 8 L7 12" />
<ui:IconData x:Key="Icon.Back" Stroke="M13 8 H3 M7 4 L3 8 L7 12" IsDirectional="True" />
<ui:IconData x:Key="Icon.Calendar" Stroke="M3.0 3 H13.0 A1.5 1.5 0 0 1 14.5 4.5 V13.0 A1.5 1.5 0 0 1 13.0 14.5 H3.0 A1.5 1.5 0 0 1 1.5 13.0 V4.5 A1.5 1.5 0 0 1 3.0 3 Z M1.5 6.5 H14.5 M5 1.5 V4 M11 1.5 V4" />
<ui:IconData x:Key="Icon.Camera" Stroke="M1.5 5 A1 1 0 0 1 2.5 4 H4.5 L6 2.5 H10 L11.5 4 H13.5 A1 1 0 0 1 14.5 5 V12.5 A1 1 0 0 1 13.5 13.5 H2.5 A1 1 0 0 1 1.5 12.5 Z M5.2 8.5 A2.8 2.8 0 1 0 10.8 8.5 A2.8 2.8 0 1 0 5.2 8.5 Z" />
<ui:IconData x:Key="Icon.Cancel" Stroke="M1.5 8 A6.5 6.5 0 1 0 14.5 8 A6.5 6.5 0 1 0 1.5 8 Z M5.8 5.8 L10.2 10.2 M10.2 5.8 L5.8 10.2" />
@@ -14,8 +14,8 @@
<ui:IconData x:Key="Icon.Chart" Stroke="M2 2 V14 H14 M4.5 10.5 L7.5 7 L9.5 9 L13.5 4" />
<ui:IconData x:Key="Icon.Check" Stroke="M3 8.5 L6.5 12 L13 4.5" />
<ui:IconData x:Key="Icon.ChevronDown" Stroke="M4 6 L8 10 L12 6" />
<ui:IconData x:Key="Icon.ChevronLeft" Stroke="M10 4 L6 8 L10 12" />
<ui:IconData x:Key="Icon.ChevronRight" Stroke="M6 4 L10 8 L6 12" />
<ui:IconData x:Key="Icon.ChevronLeft" Stroke="M10 4 L6 8 L10 12" IsDirectional="True" />
<ui:IconData x:Key="Icon.ChevronRight" Stroke="M6 4 L10 8 L6 12" IsDirectional="True" />
<ui:IconData x:Key="Icon.ChevronUp" Stroke="M4 10 L8 6 L12 10" />
<ui:IconData x:Key="Icon.Clipboard" Stroke="M4.0 2.5 H12.0 A1.5 1.5 0 0 1 13.5 4.0 V13.0 A1.5 1.5 0 0 1 12.0 14.5 H4.0 A1.5 1.5 0 0 1 2.5 13.0 V4.0 A1.5 1.5 0 0 1 4.0 2.5 Z M6.3 1.5 H9.7 A0.8 0.8 0 0 1 10.5 2.3 V3.2 A0.8 0.8 0 0 1 9.7 4.0 H6.3 A0.8 0.8 0 0 1 5.5 3.2 V2.3 A0.8 0.8 0 0 1 6.3 1.5 Z" />
<ui:IconData x:Key="Icon.Clock" Stroke="M1.5 8 A6.5 6.5 0 1 0 14.5 8 A6.5 6.5 0 1 0 1.5 8 Z M8 4.5 V8 L10.5 9.5" />
@@ -35,13 +35,13 @@
<ui:IconData x:Key="Icon.Exclude" Stroke="M1.5 8 A6.5 6.5 0 1 0 14.5 8 A6.5 6.5 0 1 0 1.5 8 Z M3.4 12.6 L12.6 3.4" />
<ui:IconData x:Key="Icon.Export" Stroke="M8 10 V1.8 M4.8 5 L8 1.8 L11.2 5 M5 7.5 H3 A1 1 0 0 0 2 8.5 V13.5 A1 1 0 0 0 3 14.5 H13 A1 1 0 0 0 14 13.5 V8.5 A1 1 0 0 0 13 7.5 H11" />
<ui:IconData x:Key="Icon.Exposure" Stroke="M1.5 8 A6.5 6.5 0 1 0 14.5 8 A6.5 6.5 0 1 0 1.5 8 Z M3.4 12.6 L12.6 3.4 M4.5 6 H7 M5.75 4.75 V7.25 M9 10 H11.5" />
<ui:IconData x:Key="Icon.ExternalLink" Stroke="M9.5 2 H14 V6.5 M14 2 L7.5 8.5 M12 9.5 V13 A1 1 0 0 1 11 14 H3 A1 1 0 0 1 2 13 V5 A1 1 0 0 1 3 4 H6.5" />
<ui:IconData x:Key="Icon.ExternalLink" Stroke="M9.5 2 H14 V6.5 M14 2 L7.5 8.5 M12 9.5 V13 A1 1 0 0 1 11 14 H3 A1 1 0 0 1 2 13 V5 A1 1 0 0 1 3 4 H6.5" IsDirectional="True" />
<ui:IconData x:Key="Icon.Eye" Stroke="M1.5 8 C3.5 4 12.5 4 14.5 8 C12.5 12 3.5 12 1.5 8 Z M5.8 8 A2.2 2.2 0 1 0 10.2 8 A2.2 2.2 0 1 0 5.8 8 Z" />
<ui:IconData x:Key="Icon.Filmstrip" Stroke="M3.0 2.5 H13.0 A1.5 1.5 0 0 1 14.5 4.0 V12.0 A1.5 1.5 0 0 1 13.0 13.5 H3.0 A1.5 1.5 0 0 1 1.5 12.0 V4.0 A1.5 1.5 0 0 1 3.0 2.5 Z M4.5 2.5 V13.5 M11.5 2.5 V13.5 M1.5 6 H4.5 M1.5 10 H4.5 M11.5 6 H14.5 M11.5 10 H14.5" />
<ui:IconData x:Key="Icon.Filter" Stroke="M1.5 2.5 H14.5 L9.5 8.5 V13.5 L6.5 12 V8.5 Z" />
<ui:IconData x:Key="Icon.Folder" Stroke="M1.5 4 A1 1 0 0 1 2.5 3 H6 L7.5 4.5 H13.5 A1 1 0 0 1 14.5 5.5 V12.5 A1 1 0 0 1 13.5 13.5 H2.5 A1 1 0 0 1 1.5 12.5 Z" />
<ui:IconData x:Key="Icon.FolderOpen" Stroke="M1.5 12.5 V4 A1 1 0 0 1 2.5 3 H6 L7.5 4.5 H12.5 V6.5 M1.5 12.5 L3.5 7 H14.5 L12.5 13.5 H2.5 A1 1 0 0 1 1.5 12.5 Z" />
<ui:IconData x:Key="Icon.Forward" Stroke="M3 8 H13 M9 4 L13 8 L9 12" />
<ui:IconData x:Key="Icon.Forward" Stroke="M3 8 H13 M9 4 L13 8 L9 12" IsDirectional="True" />
<ui:IconData x:Key="Icon.Fullscreen" Stroke="M2 6 V2 H6 M10 2 H14 V6 M14 10 V14 H10 M6 14 H2 V10" />
<ui:IconData x:Key="Icon.Gpu" Stroke="M5.0 3.5 H11.0 A1.5 1.5 0 0 1 12.5 5.0 V11.0 A1.5 1.5 0 0 1 11.0 12.5 H5.0 A1.5 1.5 0 0 1 3.5 11.0 V5.0 A1.5 1.5 0 0 1 5.0 3.5 Z M6.5 6 H9.5 A0.5 0.5 0 0 1 10 6.5 V9.5 A0.5 0.5 0 0 1 9.5 10 H6.5 A0.5 0.5 0 0 1 6 9.5 V6.5 A0.5 0.5 0 0 1 6.5 6 Z M6 1.5 V3.5 M10 1.5 V3.5 M6 12.5 V14.5 M10 12.5 V14.5 M1.5 6 H3.5 M1.5 10 H3.5 M12.5 6 H14.5 M12.5 10 H14.5" />
<ui:IconData x:Key="Icon.Grip" Fill="M5 4 A1 1 0 1 0 7 4 A1 1 0 1 0 5 4 ZM9 4 A1 1 0 1 0 11 4 A1 1 0 1 0 9 4 ZM5 8 A1 1 0 1 0 7 8 A1 1 0 1 0 5 8 ZM9 8 A1 1 0 1 0 11 8 A1 1 0 1 0 9 8 ZM5 12 A1 1 0 1 0 7 12 A1 1 0 1 0 5 12 ZM9 12 A1 1 0 1 0 11 12 A1 1 0 1 0 9 12 Z" />
@@ -50,14 +50,14 @@
<ui:IconData x:Key="Icon.Image" Stroke="M3.0 2.5 H13.0 A1.5 1.5 0 0 1 14.5 4.0 V12.0 A1.5 1.5 0 0 1 13.0 13.5 H3.0 A1.5 1.5 0 0 1 1.5 12.0 V4.0 A1.5 1.5 0 0 1 3.0 2.5 Z M1.5 11 L5.5 7 L9 10.5 L11 8.5 L14.5 12" Fill="M9.600000000000001 5.6 A1.2 1.2 0 1 0 12.0 5.6 A1.2 1.2 0 1 0 9.600000000000001 5.6 Z" />
<ui:IconData x:Key="Icon.Import" Stroke="M8 2V10 M4.5 6.5 L8 10 L11.5 6.5 M2.5 13.5 H13.5" />
<ui:IconData x:Key="Icon.Info" Stroke="M1.5 8 A6.5 6.5 0 1 0 14.5 8 A6.5 6.5 0 1 0 1.5 8 Z M8 7 V11 M8 4.8 V5.2" />
<ui:IconData x:Key="Icon.Jobs" Stroke="M3 8 H13 M3 4 H13 M3 12 H9" />
<ui:IconData x:Key="Icon.Jobs" Stroke="M3 8 H13 M3 4 H13 M3 12 H9" IsDirectional="True" />
<ui:IconData x:Key="Icon.Key" Stroke="M2 10.5 A3 3 0 1 0 8 10.5 A3 3 0 1 0 2 10.5 Z M7.2 8.3 L13.5 2 M11.5 4 L13 5.5 M9.8 5.7 L11 6.9" />
<ui:IconData x:Key="Icon.Keyframe" Stroke="M8 2 L13 8 L8 14 L3 8 Z" />
<ui:IconData x:Key="Icon.Layers" Stroke="M8 1.8 L14.5 5.2 L8 8.6 L1.5 5.2 Z M1.5 8.2 L8 11.6 L14.5 8.2 M1.5 11 L8 14.4 L14.5 11" />
<ui:IconData x:Key="Icon.Library" Stroke="M2.5 1.5 H6.0 A1 1 0 0 1 7.0 2.5 V6.0 A1 1 0 0 1 6.0 7.0 H2.5 A1 1 0 0 1 1.5 6.0 V2.5 A1 1 0 0 1 2.5 1.5 ZM10 1.5 H13.5 A1 1 0 0 1 14.5 2.5 V6.0 A1 1 0 0 1 13.5 7.0 H10 A1 1 0 0 1 9 6.0 V2.5 A1 1 0 0 1 10 1.5 ZM2.5 9 H6.0 A1 1 0 0 1 7.0 10 V13.5 A1 1 0 0 1 6.0 14.5 H2.5 A1 1 0 0 1 1.5 13.5 V10 A1 1 0 0 1 2.5 9 ZM10 9 H13.5 A1 1 0 0 1 14.5 10 V13.5 A1 1 0 0 1 13.5 14.5 H10 A1 1 0 0 1 9 13.5 V10 A1 1 0 0 1 10 9 Z" />
<ui:IconData x:Key="Icon.Link" Stroke="M6.8 9.2 L9.2 6.8 M7.5 4.5 L9 3 A2.8 2.8 0 0 1 13 7 L11.5 8.5 M8.5 11.5 L7 13 A2.8 2.8 0 0 1 3 9 L4.5 7.5" />
<ui:IconData x:Key="Icon.Lock" Stroke="M4.5 7 H11.5 A1.5 1.5 0 0 1 13 8.5 V13.0 A1.5 1.5 0 0 1 11.5 14.5 H4.5 A1.5 1.5 0 0 1 3 13.0 V8.5 A1.5 1.5 0 0 1 4.5 7 Z M5.5 7 V5 A2.5 2.5 0 0 1 10.5 5 V7" />
<ui:IconData x:Key="Icon.Logs" Stroke="M3.5 1.5 H9.5 L12.5 4.5 V14.5 H3.5 Z M5.5 7 H10.5 M5.5 9.5 H10.5 M5.5 12 H8.5" />
<ui:IconData x:Key="Icon.Logs" Stroke="M3.5 1.5 H9.5 L12.5 4.5 V14.5 H3.5 Z M5.5 7 H10.5 M5.5 9.5 H10.5 M5.5 12 H8.5" IsDirectional="True" />
<ui:IconData x:Key="Icon.Menu" Stroke="M2.5 4 H13.5 M2.5 8 H13.5 M2.5 12 H13.5" />
<ui:IconData x:Key="Icon.Minus" Stroke="M3 8 H13" />
<ui:IconData x:Key="Icon.Moon" Stroke="M9.5 1.8 A6.5 6.5 0 1 0 14.2 11.2 A5.5 5.5 0 0 1 9.5 1.8 Z" />
@@ -99,7 +99,7 @@
<ui:IconData x:Key="Icon.Vectors" Stroke="M2.5 12.5 L7 8 M7 8 H4.5 M7 8 V10.5 M9 7 L13.5 2.5 M13.5 2.5 H11 M13.5 2.5 V5" />
<ui:IconData x:Key="Icon.Verify" Stroke="M8 1.5 L13.5 3.5 V7.5 C13.5 11 11 13.3 8 14.5 C5 13.3 2.5 11 2.5 7.5 V3.5 Z M5.5 8 L7.3 9.8 L10.6 6.3" />
<ui:IconData x:Key="Icon.ViewGrid" Stroke="M2.5 1.5 H6.0 A1 1 0 0 1 7.0 2.5 V6.0 A1 1 0 0 1 6.0 7.0 H2.5 A1 1 0 0 1 1.5 6.0 V2.5 A1 1 0 0 1 2.5 1.5 ZM10 1.5 H13.5 A1 1 0 0 1 14.5 2.5 V6.0 A1 1 0 0 1 13.5 7.0 H10 A1 1 0 0 1 9 6.0 V2.5 A1 1 0 0 1 10 1.5 ZM2.5 9 H6.0 A1 1 0 0 1 7.0 10 V13.5 A1 1 0 0 1 6.0 14.5 H2.5 A1 1 0 0 1 1.5 13.5 V10 A1 1 0 0 1 2.5 9 ZM10 9 H13.5 A1 1 0 0 1 14.5 10 V13.5 A1 1 0 0 1 13.5 14.5 H10 A1 1 0 0 1 9 13.5 V10 A1 1 0 0 1 10 9 Z" />
<ui:IconData x:Key="Icon.ViewList" Stroke="M5.5 4 H13.5 M5.5 8 H13.5 M5.5 12 H13.5 M2.5 4 H2.6 M2.5 8 H2.6 M2.5 12 H2.6" />
<ui:IconData x:Key="Icon.ViewList" Stroke="M5.5 4 H13.5 M5.5 8 H13.5 M5.5 12 H13.5 M2.5 4 H2.6 M2.5 8 H2.6 M2.5 12 H2.6" IsDirectional="True" />
<ui:IconData x:Key="Icon.ViewTimeline" Stroke="M2 13.5 H14 M3.5 11 V8 M6 11 V5 M8.5 11 V7 M11 11 V3.5 M13.5 11 V9" />
<ui:IconData x:Key="Icon.Warning" Stroke="M8 1.8 L14.8 13.8 H1.2 Z M8 6.2 V9.6 M8 11.7 V11.8" />
<ui:IconData x:Key="Icon.Window" Stroke="M3.0 2.5 H13.0 A1.5 1.5 0 0 1 14.5 4.0 V12.0 A1.5 1.5 0 0 1 13.0 13.5 H3.0 A1.5 1.5 0 0 1 1.5 12.0 V4.0 A1.5 1.5 0 0 1 3.0 2.5 Z M1.5 5.5 H14.5" />
+111 -41
View File
@@ -25,6 +25,17 @@
</Setter>
</Style>
<!-- Focus inside the bounds, for list rows and table rows whose neighbours or scroll viewport would hide an outer ring. -->
<Style x:Key="Focus.Inset">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Border BorderBrush="{DynamicResource Brush.Accent}" BorderThickness="2" CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DropShadowEffect x:Key="Shadow.Popup" BlurRadius="24" ShadowDepth="6" Direction="270" Opacity="0.45" Color="Black" />
<DropShadowEffect x:Key="Shadow.ToolTip" BlurRadius="14" ShadowDepth="4" Direction="270" Opacity="0.4" Color="Black" />
@@ -212,24 +223,26 @@
<Setter Property="SelectionOpacity" Value="0.35" />
<Setter Property="Template">
<Setter.Value>
<!-- The text box hands its Padding to the content host itself, so the template applies it nowhere else: the
placeholder takes it as its own padding (plus the 2 px the text view adds) and the leading icon sits at its
left edge; with an icon, text and placeholder start 8 px after it. -->
<ControlTemplate TargetType="TextBox">
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True">
<Grid Margin="{TemplateBinding Padding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ui:Icon x:Name="Glyph" Glyph="{TemplateBinding ui:Field.Glyph}" Foreground="{DynamicResource Brush.TextFaint}" Margin="0,0,8,0" VerticalAlignment="Center" />
<TextBlock x:Name="Placeholder" Grid.Column="1" Text="{TemplateBinding ui:Field.Placeholder}" Foreground="{DynamicResource Brush.TextFaint}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" IsHitTestVisible="False" TextTrimming="CharacterEllipsis" Margin="2,0,0,0" />
<ScrollViewer x:Name="PART_ContentHost" Grid.Column="1" Focusable="False" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
<Grid>
<ui:Icon x:Name="Glyph" Glyph="{TemplateBinding ui:Field.Glyph}" Foreground="{DynamicResource Brush.TextFaint}" HorizontalAlignment="Left"
Margin="{TemplateBinding Padding}" />
<TextBlock x:Name="Placeholder" Text="{TemplateBinding ui:Field.Placeholder}" Foreground="{DynamicResource Brush.TextFaint}" Padding="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Visibility="Collapsed" IsHitTestVisible="False" TextTrimming="CharacterEllipsis" Margin="24,0,0,0" />
<ScrollViewer x:Name="PART_ContentHost" Focusable="False" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="22,0,0,0"
HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="ui:Field.Glyph" Value="{x:Null}">
<Setter TargetName="Glyph" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Placeholder" Property="Margin" Value="2,0,0,0" />
<Setter TargetName="PART_ContentHost" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="Text" Value="">
<Setter TargetName="Placeholder" Property="Visibility" Value="Visible" />
@@ -256,8 +269,14 @@
</Setter>
</Style>
<!-- Naming templates ({year}/{date}_{n:0000}) and paths keep their characters in order in right-to-left languages. -->
<Style x:Key="TextBox.Mono" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="FontFamily" Value="{StaticResource Font.Mono}" />
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style>
<Style x:Key="TextBox.Path" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style>
<Style TargetType="PasswordBox" BasedOn="{StaticResource Input.Base}">
@@ -265,10 +284,11 @@
<Setter Property="SelectionBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="Template">
<Setter.Value>
<!-- As for TextBox, the password box hands its Padding to the content host itself. -->
<ControlTemplate TargetType="PasswordBox">
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost" Margin="{TemplateBinding Padding}" VerticalAlignment="Center" Focusable="False"
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center" Focusable="False"
HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" />
</Border>
<ControlTemplate.Triggers>
@@ -278,6 +298,11 @@
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
</Trigger>
<!-- A password has no binding to validate: the owner sets ui:Field.Error (DESIGN §4 error state, as TextBox). -->
<Trigger Property="ui:Field.HasError" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Brush.Error}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding (ui:Field.Error), RelativeSource={RelativeSource Self}}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" />
</Trigger>
@@ -295,7 +320,7 @@
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border Background="Transparent">
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Size="14" HorizontalAlignment="Right" Margin="0,0,10,0"
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Size="14" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"
Foreground="{DynamicResource Brush.TextMuted}" />
</Border>
</ControlTemplate>
@@ -737,7 +762,7 @@
</Style>
<Style TargetType="ListBoxItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
<Setter Property="MinHeight" Value="36" />
<Setter Property="Padding" Value="10,0" />
@@ -800,7 +825,7 @@
</Style>
<Style TargetType="ListViewItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
<Setter Property="Height" Value="{StaticResource Height.Row}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
@@ -1050,11 +1075,11 @@
<DockPanel LastChildFill="True">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
<Button x:Name="Minimize" Style="{StaticResource Caption.Button}" ui:ButtonIcon.Glyph="{StaticResource Icon.Caption.Minimize}"
Command="{x:Static SystemCommands.MinimizeWindowCommand}" AutomationProperties.Name="Minimize" ToolTip="{l:Loc Tooltips.Window.Minimize}" />
Command="{x:Static SystemCommands.MinimizeWindowCommand}" AutomationProperties.Name="{l:Loc Tooltips.Window.Minimize}" ToolTip="{l:Loc Tooltips.Window.Minimize}" />
<Button x:Name="PART_Maximize" Style="{StaticResource Caption.Button}" ui:ButtonIcon.Glyph="{StaticResource Icon.Caption.Maximize}"
Command="{x:Static SystemCommands.MaximizeWindowCommand}" AutomationProperties.Name="Maximize" ToolTip="{l:Loc Tooltips.Window.Maximize}" />
Command="{x:Static SystemCommands.MaximizeWindowCommand}" AutomationProperties.Name="{l:Loc Tooltips.Window.Maximize}" ToolTip="{l:Loc Tooltips.Window.Maximize}" />
<Button x:Name="Close" Style="{StaticResource Caption.Close}" ui:ButtonIcon.Glyph="{StaticResource Icon.Caption.Close}"
Command="{x:Static SystemCommands.CloseWindowCommand}" AutomationProperties.Name="Close" ToolTip="{l:Loc Tooltips.Window.Close}" />
Command="{x:Static SystemCommands.CloseWindowCommand}" AutomationProperties.Name="{l:Loc Tooltips.Window.Close}" ToolTip="{l:Loc Tooltips.Window.Close}" />
</StackPanel>
<ui:BrandMarkIcon Width="16" Height="16" Margin="12,0,10,0" VerticalAlignment="Center" />
<TextBlock Text="{TemplateBinding Title}" Foreground="{DynamicResource Brush.TextMuted}" FontSize="{StaticResource Size.Secondary}"
@@ -1072,6 +1097,7 @@
<Setter TargetName="Root" Property="Padding" Value="{x:Static SystemParameters.WindowResizeBorderThickness}" />
<Setter TargetName="PART_Maximize" Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Caption.Restore}" />
<Setter TargetName="PART_Maximize" Property="ToolTip" Value="{l:Loc Tooltips.Window.Restore}" />
<Setter TargetName="PART_Maximize" Property="AutomationProperties.Name" Value="{l:Loc Tooltips.Window.Restore}" />
</Trigger>
<Trigger Property="IsMaximizeHovered" Value="True">
<Setter TargetName="PART_Maximize" Property="Background" Value="{DynamicResource Brush.Card}" />
@@ -1106,7 +1132,7 @@
<Border x:Name="Bd" Background="Transparent" CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True">
<Grid>
<Border x:Name="Edge" Width="3" HorizontalAlignment="Left" CornerRadius="1.5" Margin="0,8" Background="{DynamicResource Brush.Accent}" Visibility="Hidden" />
<Grid Margin="10,0,8,0">
<Grid x:Name="Row" Margin="10,0,8,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
@@ -1116,8 +1142,9 @@
<TextBlock x:Name="Label" Grid.Column="1" Margin="10,0,0,0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis">
<ContentPresenter RecognizesAccessKey="True" />
</TextBlock>
<Border x:Name="Badge" Grid.Column="2" MinWidth="18" Height="16" CornerRadius="8" Padding="5,0" Background="{DynamicResource Brush.Accent}" VerticalAlignment="Center">
<TextBlock Text="{Binding Badge, RelativeSource={RelativeSource TemplatedParent}}" FontSize="10" FontWeight="SemiBold" Foreground="{DynamicResource Brush.OnAccent}" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Border x:Name="Badge" Grid.Column="2" MinWidth="18" Height="16" CornerRadius="8" Padding="5,0" Margin="6,0,0,0" Background="{DynamicResource Brush.Accent}" VerticalAlignment="Center">
<TextBlock Text="{Binding Badge, RelativeSource={RelativeSource TemplatedParent}}" FontSize="{StaticResource Size.Chip}" FontWeight="SemiBold" Foreground="{DynamicResource Brush.OnAccent}"
HorizontalAlignment="Center" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
</Border>
</Grid>
</Grid>
@@ -1126,12 +1153,15 @@
<Trigger Property="Badge" Value="0">
<Setter TargetName="Badge" Property="Visibility" Value="Collapsed" />
</Trigger>
<!-- 32 px button: the 16 px icon centred; the badge hangs off the icon's top-right corner (the negative margin
keeps it from widening the icon column) and covers only that corner. -->
<Trigger Property="ui:NavRail.IsCollapsed" Value="True">
<Setter TargetName="Label" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Badge" Property="HorizontalAlignment" Value="Right" />
<Setter TargetName="Badge" Property="VerticalAlignment" Value="Top" />
<Setter TargetName="Badge" Property="Margin" Value="-14,4,0,0" />
<Setter TargetName="Row" Property="Margin" Value="8,0" />
<Setter TargetName="Badge" Property="Grid.Column" Value="0" />
<Setter TargetName="Badge" Property="HorizontalAlignment" Value="Left" />
<Setter TargetName="Badge" Property="VerticalAlignment" Value="Top" />
<Setter TargetName="Badge" Property="Margin" Value="8,2,-24,0" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.Card}" />
@@ -1149,6 +1179,21 @@
</Style>
<!-- ===================== AutoSlider (advisor Auto / manual) ===================== -->
<!-- "Auto · 8" pill (DESIGN §4 Auto/manual): accent outline, 24 px, 11 px text; its tooltip gives the advisor's reason. -->
<Style x:Key="Button.AutoPill" TargetType="Button" BasedOn="{StaticResource Button.Base}">
<Setter Property="Height" Value="24" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="Padding" Value="8,0" />
<Setter Property="FontSize" Value="{StaticResource Size.Chip}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}" />
<Setter Property="ui:ControlState.CornerRadius" Value="12" />
<Setter Property="ui:ControlState.HoverBackground" Value="{DynamicResource Brush.AccentSubtle}" />
<Setter Property="ui:ControlState.HoverBorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="ui:ControlState.PressedBackground" Value="{DynamicResource Brush.AccentSubtle}" />
</Style>
<Style x:Key="Pill.Auto" TargetType="Border">
<Setter Property="Height" Value="22" />
<Setter Property="Padding" Value="8,0" />
@@ -1172,32 +1217,40 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{TemplateBinding Header}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<Border x:Name="AutoPill" Grid.Column="1" Style="{StaticResource Pill.Auto}" ToolTip="{TemplateBinding AutoReason}" ToolTipService.ShowOnDisabled="True">
<TextBlock Text="{TemplateBinding AutoText}" FontSize="{StaticResource Size.Chip}" Foreground="{DynamicResource Brush.Accent}" VerticalAlignment="Center" />
</Border>
<Button x:Name="AutoPill" Grid.Column="1" Style="{StaticResource Button.AutoPill}" Content="{TemplateBinding AutoText}" ToolTip="{TemplateBinding AutoReason}"
AutomationProperties.Name="{Binding AutoText, RelativeSource={RelativeSource TemplatedParent}}"
AutomationProperties.HelpText="{Binding AutoReason, RelativeSource={RelativeSource TemplatedParent}}" />
<StackPanel x:Name="Manual" Grid.Column="1" Orientation="Horizontal" Visibility="Collapsed">
<TextBlock Text="{TemplateBinding DisplayValue}" VerticalAlignment="Center" Style="{StaticResource Text.Number}" />
<Button Style="{StaticResource Button.IconSubtle}" Width="26" Height="26" Margin="6,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.Reset}"
Command="{x:Static ui:AutoSlider.ResetCommand}" ToolTip="{l:Loc Tooltips.Common.ResetToAuto}" />
Command="{x:Static ui:AutoSlider.ResetCommand}" ToolTip="{l:Loc Tooltips.Common.ResetToAuto}" AutomationProperties.Name="{l:Loc Common.ResetToAuto}" />
</StackPanel>
<TextBlock x:Name="NotApplicable" Grid.Column="1" Text="{l:Loc Common.NotApplicable}" Foreground="{DynamicResource Brush.TextFaint}"
ToolTip="{TemplateBinding NotApplicableReason}" Visibility="Collapsed" VerticalAlignment="Center" />
</Grid>
<!-- The slider carries the setting's name; its status says Auto (with the advisor's reason) or not applicable. -->
<Slider x:Name="PART_Slider" Margin="0,6,0,0" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}"
SmallChange="{TemplateBinding SmallChange}" LargeChange="{TemplateBinding SmallChange}" TickFrequency="{TemplateBinding TickFrequency}"
IsSnapToTickEnabled="{TemplateBinding IsSnapToTickEnabled}" ToolTip="{TemplateBinding SliderToolTip}" />
IsSnapToTickEnabled="{TemplateBinding IsSnapToTickEnabled}" ToolTip="{TemplateBinding SliderToolTip}"
AutomationProperties.Name="{Binding Header, RelativeSource={RelativeSource TemplatedParent}}"
AutomationProperties.ItemStatus="{Binding AutoText, RelativeSource={RelativeSource TemplatedParent}}"
AutomationProperties.HelpText="{Binding AutoReason, RelativeSource={RelativeSource TemplatedParent}}" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsAuto" Value="False">
<Setter TargetName="AutoPill" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Manual" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_Slider" Property="ui:ControlState.Accent" Value="{DynamicResource Brush.Sun}" />
<Setter TargetName="PART_Slider" Property="AutomationProperties.ItemStatus" Value="" />
<Setter TargetName="PART_Slider" Property="AutomationProperties.HelpText" Value="" />
</Trigger>
<Trigger Property="IsApplicable" Value="False">
<Setter TargetName="AutoPill" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Manual" Property="Visibility" Value="Collapsed" />
<Setter TargetName="NotApplicable" Property="Visibility" Value="Visible" />
<Setter TargetName="PART_Slider" Property="IsEnabled" Value="False" />
<Setter TargetName="PART_Slider" Property="AutomationProperties.ItemStatus" Value="{l:Loc Common.NotApplicable}" />
<Setter TargetName="PART_Slider" Property="AutomationProperties.HelpText" Value="{Binding NotApplicableReason, RelativeSource={RelativeSource TemplatedParent}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -1221,7 +1274,7 @@
<ContentPresenter VerticalAlignment="Center" Margin="0,0,4,0" />
<Button x:Name="Remove" Style="{StaticResource Button.IconSubtle}" Width="18" Height="18" MinWidth="18" ui:ControlState.CornerRadius="9"
ui:ButtonIcon.Glyph="{StaticResource Icon.Close}" Command="{TemplateBinding RemoveCommand}" CommandParameter="{TemplateBinding RemoveCommandParameter}"
ToolTip="{TemplateBinding RemoveToolTip}" />
ToolTip="{TemplateBinding RemoveToolTip}" AutomationProperties.Name="{l:Loc Common.Remove}" />
</StackPanel>
</Border>
<ControlTemplate.Triggers>
@@ -1314,19 +1367,19 @@
<Setter.Value>
<ControlTemplate TargetType="ui:JobBar">
<Border Background="{DynamicResource Brush.Surface}" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="20,0,12,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="120" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ProgressBar x:Name="Bar" VerticalAlignment="Center" Maximum="1" Value="{TemplateBinding Progress}" IsIndeterminate="{TemplateBinding IsIndeterminate}" />
<TextBlock Grid.Column="1" Text="{TemplateBinding Text}" Margin="12,0,12,0" VerticalAlignment="Center" FontSize="{StaticResource Size.Body}"
Typography.NumeralAlignment="Tabular" TextTrimming="CharacterEllipsis" MaxWidth="640" />
<Button x:Name="Stop" Grid.Column="2" Style="{StaticResource Button.Icon}" Width="28" Height="28" MinWidth="28"
<!-- The text takes what it needs and trims only once the bar is down to 120 px: the spacer reserves those
120 px before the text is measured, and the bar reaches back over it. -->
<DockPanel>
<Button x:Name="Stop" DockPanel.Dock="Right" Style="{StaticResource Button.Icon}" Width="28" Height="28" MinWidth="28"
ui:ButtonIcon.Glyph="{TemplateBinding ActionGlyph}" Command="{TemplateBinding StopCommand}" ToolTip="{TemplateBinding StopToolTip}"
AutomationProperties.Name="{Binding StopToolTip, RelativeSource={RelativeSource TemplatedParent}}" />
</Grid>
AutomationProperties.Name="{Binding StopName, RelativeSource={RelativeSource TemplatedParent}}"
AutomationProperties.HelpText="{Binding StopToolTip, RelativeSource={RelativeSource TemplatedParent}}" />
<FrameworkElement DockPanel.Dock="Left" Width="120" />
<TextBlock DockPanel.Dock="Right" Text="{TemplateBinding Text}" Margin="12,0,12,0" VerticalAlignment="Center" FontSize="{StaticResource Size.Body}"
Typography.NumeralAlignment="Tabular" TextTrimming="CharacterEllipsis" />
<ProgressBar x:Name="Bar" Margin="-120,0,0,0" VerticalAlignment="Center" Maximum="1" Value="{TemplateBinding Progress}" IsIndeterminate="{TemplateBinding IsIndeterminate}"
AutomationProperties.Name="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" />
</DockPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsActive" Value="False">
@@ -1364,6 +1417,22 @@
<Setter Property="VerticalAlignment" Value="Bottom" />
<Setter Property="Margin" Value="0,0,20,44" />
<Setter Property="Focusable" Value="False" />
<!-- The host keys its own style, so no theme template applies: without this one nothing would draw. -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ui:ToastHost">
<ItemsPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ContentPresenter">
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Message}" />
</Style>
</Setter.Value>
</Setter>
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate DataType="{x:Type ui:Toast}">
@@ -1384,7 +1453,8 @@
<Button Grid.Column="1" Style="{StaticResource Button.Primary}" Margin="12,0,0,0" Content="{Binding ActionText}" Command="{Binding ActionCommand}"
ToolTip="{Binding ActionToolTip}" Visibility="{Binding ActionCommand, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<Button Grid.Column="2" Style="{StaticResource Button.IconSubtle}" Margin="4,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.Close}"
Command="{x:Static ui:ToastHost.DismissCommand}" CommandParameter="{Binding}" ToolTip="{l:Loc Tooltips.Common.Dismiss}" />
Command="{x:Static ui:ToastHost.DismissCommand}" CommandParameter="{Binding}" ToolTip="{l:Loc Tooltips.Common.DismissToast}"
AutomationProperties.Name="{l:Loc Tooltips.Common.Dismiss}" />
</Grid>
</Grid>
</Border>
+15 -8
View File
@@ -1,7 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Titano.Ui.Controls"
xmlns:v="clr-namespace:Titano.Ui.Visuals">
xmlns:v="clr-namespace:Titano.Ui.Visuals"
xmlns:l="clr-namespace:Titano.Ui.Localization">
<!--
Styles of the high-performance visuals (Titano.Ui.Visuals), merged by Controls.xaml. Brushes and the shared
button templates of Controls.xaml are DynamicResource (they live in the parent dictionary); sizes, radii and
@@ -76,14 +77,17 @@
CornerRadius="{StaticResource Radius.Card}">
<StackPanel>
<v:AspectRatioDecorator>
<Grid x:Name="PART_Thumbnail" Background="Transparent">
<!-- The photo and the scrub position are a left-to-right island (time runs left to right, as in the
filmstrip); the check box, badge and quick actions follow the layout direction. -->
<Grid Background="Transparent">
<Border CornerRadius="7,7,0,0" Background="{DynamicResource Brush.Preview}" />
<Border CornerRadius="7,7,0,0">
<Border x:Name="PART_Thumbnail" CornerRadius="7,7,0,0" FlowDirection="LeftToRight">
<Border.Background>
<ImageBrush ImageSource="{Binding DisplayedThumbnail, RelativeSource={RelativeSource TemplatedParent}}" Stretch="UniformToFill" />
</Border.Background>
</Border>
<Border x:Name="ScrubTrack" Height="2" VerticalAlignment="Bottom" Background="{DynamicResource Brush.Accent}" RenderTransformOrigin="0,0.5" Visibility="Collapsed">
<Border x:Name="ScrubTrack" Height="2" VerticalAlignment="Bottom" Background="{DynamicResource Brush.Accent}" RenderTransformOrigin="0,0.5" Visibility="Collapsed"
FlowDirection="LeftToRight">
<Border.RenderTransform>
<ScaleTransform ScaleX="{Binding ScrubPosition, RelativeSource={RelativeSource TemplatedParent}}" />
</Border.RenderTransform>
@@ -151,13 +155,14 @@
</Style>
<!-- ===================== Preview viewport (BRIEF §12.3) ===================== -->
<!-- The image surface (a drawn visual, always left to right) and the numeric shot data stay left to right; the tool
row follows the layout direction. -->
<Style TargetType="v:PreviewViewport">
<Setter Property="Background" Value="{DynamicResource Brush.Preview}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
<Setter Property="FontFamily" Value="{StaticResource Font.Ui}" />
<Setter Property="FontSize" Value="{StaticResource Size.Secondary}" />
<Setter Property="FlowDirection" Value="LeftToRight" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource Focus.Ring}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="v:PreviewViewport">
@@ -165,7 +170,7 @@
<Grid>
<v:PreviewSurface x:Name="PART_Surface" CornerRadius="8" />
<ContentPresenter x:Name="PART_Tools" Content="{TemplateBinding ToolsContent}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="12" />
<Grid x:Name="PART_Info" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="12" IsHitTestVisible="False">
<Grid x:Name="PART_Info" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="12" IsHitTestVisible="False" FlowDirection="LeftToRight">
<Border Background="{DynamicResource Brush.Chrome}" Opacity="0.85" CornerRadius="{StaticResource Radius.Control}" />
<TextBlock Text="{TemplateBinding InfoText}" Margin="10,6" Typography.NumeralAlignment="Tabular" TextTrimming="CharacterEllipsis" />
</Grid>
@@ -275,6 +280,7 @@
<Style TargetType="v:SplitButton">
<Setter Property="Height" Value="{StaticResource Height.Control}" />
<Setter Property="DropDownName" Value="{l:Loc Common.MoreChoices}" />
<Setter Property="FontFamily" Value="{StaticResource Font.Ui}" />
<Setter Property="FontSize" Value="{StaticResource Size.Body}" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
@@ -287,7 +293,8 @@
CommandTarget="{TemplateBinding CommandTarget}" />
<ToggleButton x:Name="Arrow" Style="{DynamicResource Button.Base}" Height="{TemplateBinding Height}" Width="28" MinWidth="28" Padding="0" Margin="-1,0,0,0"
ClickMode="Press" ui:ControlState.CornerRadius="0,6,6,0" ui:ButtonIcon.Glyph="{DynamicResource Icon.ChevronDown}"
IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" ToolTip="{TemplateBinding DropDownToolTip}" />
IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" ToolTip="{TemplateBinding DropDownToolTip}"
AutomationProperties.Name="{Binding DropDownName, RelativeSource={RelativeSource TemplatedParent}}" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsPrimary" Value="True">
+11 -8
View File
@@ -85,6 +85,9 @@ public sealed class BarChart : DrawingElement
remove => RemoveHandler(ItemActivatedEvent, value);
}
protected internal override string? AutomationDescription =>
Items is { Count: > 0 } items ? string.Join(Environment.NewLine, items.Select(ReadoutText)) : null;
protected override Size MeasureOverride(Size availableSize)
{
var count = Items?.Count ?? 0;
@@ -166,10 +169,10 @@ public sealed class BarChart : DrawingElement
double labelWidth = 0, valueWidth = 0;
for (var i = 0; i < items.Count; i++)
{
labels[i] = CreateText(items[i].Label, LabelSize, faint);
labels[i] = CreateLabel(items[i].Label, LabelSize, faint);
labelWidth = Math.Max(labelWidth, labels[i].Width);
if (!ShowValues) continue;
values[i] = CreateText(items[i].ValueText ?? Format(items[i].Value), LabelSize, text);
values[i] = CreateLabel(items[i].ValueText ?? Format(items[i].Value), LabelSize, text);
valueWidth = Math.Max(valueWidth, values[i]!.Width);
}
var gridHeight = ShowGrid ? 16 : 0;
@@ -184,7 +187,7 @@ public sealed class BarChart : DrawingElement
{
var item = items[i];
var cy = _area.Top + _pitch * (i + 0.5);
dc.DrawText(labels[i], new Point(left - 8 - labels[i].Width, cy - labels[i].Height / 2));
DrawTextAt(dc, labels[i], new Point(left - 8 - labels[i].Width, cy - labels[i].Height / 2));
var length = _area.Width * Math.Clamp(item.Value / max, 0, 1);
if (length > 0)
{
@@ -192,7 +195,7 @@ public sealed class BarChart : DrawingElement
dc.DrawRoundedRectangle(GetBrush(item.BrushKey ?? BrushKey), null, new Rect(left, cy - thickness / 2, length, thickness), 2, 2);
dc.Pop();
}
if (values[i] is { } value) dc.DrawText(value, new Point(left + length + 6, cy - value.Height / 2));
if (values[i] is { } value) DrawTextAt(dc, value, new Point(left + length + 6, cy - value.Height / 2));
}
}
@@ -228,13 +231,13 @@ public sealed class BarChart : DrawingElement
}
if (ShowValues && _pitch >= 24)
{
var value = CreateText(item.ValueText ?? Format(item.Value), LabelSize, text);
if (value.Width <= _pitch) dc.DrawText(value, new Point(cx - value.Width / 2, _area.Bottom - height - value.Height - 2));
var value = CreateLabel(item.ValueText ?? Format(item.Value), LabelSize, text);
if (value.Width <= _pitch) DrawTextAt(dc, value, new Point(cx - value.Width / 2, _area.Bottom - height - value.Height - 2));
}
var label = CreateText(item.Label, LabelSize, faint);
var label = CreateLabel(item.Label, LabelSize, faint);
var x = cx - label.Width / 2;
if (x < lastLabelRight + 6) continue;
dc.DrawText(label, new Point(x, _area.Bottom + 4));
DrawTextAt(dc, label, new Point(x, _area.Bottom + 4));
lastLabelRight = x + label.Width;
}
}
+100 -8
View File
@@ -1,5 +1,8 @@
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Input;
using System.Windows.Media;
using Titano.Core.Localization;
@@ -23,6 +26,8 @@ public enum CurveEditMode
/// sampling <see cref="Evaluator"/> once per device-pixel column, so the engine's Fritsch–Carlson spline is what
/// the user sees. Grid, optional identity diagonal and a playhead are drawn; hovering or dragging a point reads
/// out its coordinates. <see cref="EditCompletedEvent"/> fires after each add, delete, nudge or finished drag.
/// Keyboard alone: focus selects the first point, PageUp/PageDown step through the points, Insert or Enter adds one
/// at the playhead, and the readout follows the selected point; screen readers hear the selected point as the value.
/// </summary>
public sealed class CurveEditor : DrawingElement
{
@@ -37,7 +42,8 @@ public sealed class CurveEditor : DrawingElement
public static readonly DependencyProperty SelectedIndexProperty = DependencyProperty.Register(
nameof(SelectedIndex), typeof(int), typeof(CurveEditor),
new FrameworkPropertyMetadata(-1, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.AffectsRender, null, CoerceSelectedIndex));
new FrameworkPropertyMetadata(-1, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.AffectsRender,
(d, _) => ((CurveEditor)d).AnnounceSelection(), CoerceSelectedIndex));
public static readonly DependencyProperty PlayheadPositionProperty = DependencyProperty.Register(
nameof(PlayheadPosition), typeof(double), typeof(CurveEditor), new PropertyMetadata(double.NaN, (d, _) => ((CurveEditor)d).RenderOverlay()));
@@ -70,6 +76,7 @@ public sealed class CurveEditor : DrawingElement
private int _hover = -1;
private bool _dragging;
private bool _moved;
private string _announced = string.Empty;
static CurveEditor()
{
@@ -138,8 +145,15 @@ public sealed class CurveEditor : DrawingElement
_hover = -1;
CoerceValue(SelectedIndexProperty);
base.OnDataChanged();
AnnounceSelection();
}
protected internal override string? AutomationDescription => SelectionText;
/// <summary>"Point 2 of 4: x → y" for the selected point; empty without a selection.</summary>
internal string SelectionText =>
SelectedIndex >= 0 && SelectedIndex < _count ? Loc.L("Common.CurvePoint", SelectedIndex + 1, _count, ReadoutText(SelectedIndex)) : string.Empty;
protected override void OnRender(DrawingContext dc)
{
DrawHitArea(dc);
@@ -211,7 +225,7 @@ public sealed class CurveEditor : DrawingElement
if (_dragging && SelectedIndex >= 0)
{
_moved |= Move(SelectedIndex, ToX(p.X), ToY(p.Y));
Readout.Show(ReadoutText(SelectedIndex), p);
Readout.Show(ReadoutText(SelectedIndex), p, FlowDirection.LeftToRight);
return;
}
var hover = HitTest(p);
@@ -220,7 +234,7 @@ public sealed class CurveEditor : DrawingElement
_hover = hover;
InvalidateVisual();
}
Readout.Show(hover >= 0 ? ReadoutText(hover) : null, p);
Readout.Show(hover >= 0 ? ReadoutText(hover) : null, p, FlowDirection.LeftToRight);
}
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
@@ -256,11 +270,42 @@ public sealed class CurveEditor : DrawingElement
e.Handled = true;
}
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnGotKeyboardFocus(e);
// Tabbing in selects a point so the arrows have something to move; a click selects what it hits instead.
if (SelectedIndex < 0 && _count > 0 && InputManager.Current.MostRecentInputDevice is KeyboardDevice)
SetCurrentValue(SelectedIndexProperty, 0);
ShowSelectionReadout();
}
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnLostKeyboardFocus(e);
if (!_dragging) Readout.Hide();
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.Handled) return;
if (e.Key is (Key.PageUp or Key.PageDown) && _count > 0)
{
var next = SelectedIndex < 0 ? 0 : SelectedIndex + (e.Key == Key.PageDown ? 1 : -1);
SetCurrentValue(SelectedIndexProperty, Math.Clamp(next, 0, _count - 1));
ShowSelectionReadout();
e.Handled = true;
return;
}
if (e.Key is (Key.Insert or Key.Enter) && IsEditable)
{
AddFromKeyboard();
ShowSelectionReadout();
e.Handled = true;
return;
}
var index = SelectedIndex;
if (e.Handled || index < 0 || index >= _count || !IsEditable) return;
if (index < 0 || index >= _count || !IsEditable) return;
var step = (Keyboard.Modifiers & ModifierKeys.Shift) != 0 ? 0.1 : 0.01;
var changed = e.Key switch
{
@@ -273,9 +318,12 @@ public sealed class CurveEditor : DrawingElement
};
if (changed is null) return;
e.Handled = true;
ShowSelectionReadout();
if (changed.Value) RaiseEvent(new RoutedEventArgs(EditCompletedEvent));
}
protected override AutomationPeer OnCreateAutomationPeer() => new CurveEditorAutomationPeer(this);
private static object CoerceSelectedIndex(DependencyObject d, object value)
{
var index = (int)value;
@@ -341,18 +389,45 @@ public sealed class CurveEditor : DrawingElement
return true;
}
private void Add(Point at)
private void Add(Point at) => AddAt(ToX(at.X), ToY(at.Y));
/// <summary>A new point on the curve as it is drawn now, at the playhead or in the gap after the selection.</summary>
private void AddFromKeyboard()
{
var xs = _xs.AsSpan(0, _count);
var x = CurveMath.KeyboardInsertionX(xs, SelectedIndex, PlayheadPosition, MinimumGap, PinEnds);
AddAt(x, Evaluator?.Invoke(x) ?? CurveMath.Interpolate(xs, _ys.AsSpan(0, _count), x));
}
private void AddAt(double x, double y)
{
if (Points is not { IsReadOnly: false } points) return;
var x = ToX(at.X);
var index = CurveMath.InsertionIndex(_xs.AsSpan(0, _count), x, MinimumGap, PinEnds);
if (index < 0) return;
points.Insert(index, new Point(x, CurveMath.ConstrainY(ToY(at.Y))));
points.Insert(index, new Point(x, CurveMath.ConstrainY(y)));
AfterEdit(points);
SetCurrentValue(SelectedIndexProperty, index);
RaiseEvent(new RoutedEventArgs(EditCompletedEvent));
}
/// <summary>Tells screen readers about a new selection or a moved point (the peer's value).</summary>
private void AnnounceSelection()
{
var text = SelectionText;
if (text == _announced) return;
var previous = _announced;
_announced = text;
UIElementAutomationPeer.FromElement(this)?.RaisePropertyChangedEvent(ValuePatternIdentifiers.ValueProperty, previous, text);
}
/// <summary>The coordinate readout next to the selected point, for keyboard edits.</summary>
private void ShowSelectionReadout()
{
var index = SelectedIndex;
if (!IsKeyboardFocused || index < 0 || index >= _count || _plot.Width < 1) return;
Readout.Show(ReadoutText(index), new Point(X(_xs[index]), Y(_ys[index])), FlowDirection.LeftToRight);
}
private bool Remove(int index)
{
if (Points is not { IsReadOnly: false } points || !CurveMath.CanRemove(_count, index, PinEnds)) return false;
@@ -372,8 +447,25 @@ public sealed class CurveEditor : DrawingElement
{
var x = XLabelFormatter ?? DefaultFormat;
var y = YLabelFormatter ?? DefaultFormat;
return x(_xs[index]) + " → " + y(_ys[index]);
return Loc.L("Common.CurveReadout", x(_xs[index]), y(_ys[index]));
}
private static string DefaultFormat(double value) => value.ToString("0.###", Loc.Culture);
}
/// <summary>The curve editor seen by UI Automation: its value reads the selected point ("Point 2 of 4: 0:12 → 0:30").</summary>
public sealed class CurveEditorAutomationPeer(CurveEditor owner) : DrawingElementAutomationPeer(owner), IValueProvider
{
public string Value => ((CurveEditor)Owner).SelectionText;
public bool IsReadOnly => true;
public void SetValue(string value) => throw new InvalidOperationException("The curve is edited with the arrow keys, not by text.");
public override object? GetPattern(PatternInterface patternInterface) =>
patternInterface == PatternInterface.Value ? this : base.GetPattern(patternInterface);
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Custom;
protected override string GetLocalizedControlTypeCore() => Loc.L("Common.Curve");
}
+28
View File
@@ -51,6 +51,34 @@ public static class CurveMath
return index;
}
/// <summary>
/// X of a point added from the keyboard: the playhead when a point fits there, otherwise the middle of the gap
/// after point <paramref name="selected"/> (before it for the last point; 0.5 on an empty curve).
/// </summary>
public static double KeyboardInsertionX(ReadOnlySpan<double> xs, int selected, double playhead, double minGap, bool pinEnds)
{
if (double.IsFinite(playhead) && InsertionIndex(xs, playhead, minGap, pinEnds) >= 0) return playhead;
if (xs.Length == 0) return 0.5;
if (xs.Length == 1) return xs[0] < 0.5 ? (xs[0] + 1) / 2 : xs[0] / 2;
var i = Math.Clamp(selected, 0, xs.Length - 2);
return (xs[i] + xs[i + 1]) / 2;
}
/// <summary>Y at <paramref name="x"/> on the straight segments through the points, flat beyond the ends; the identity without points.</summary>
public static double Interpolate(ReadOnlySpan<double> xs, ReadOnlySpan<double> ys, double x)
{
var n = Math.Min(xs.Length, ys.Length);
if (n == 0) return x;
if (x <= xs[0]) return ys[0];
for (var i = 1; i < n; i++)
{
if (x > xs[i]) continue;
var span = xs[i] - xs[i - 1];
return span > 0 ? ys[i - 1] + (x - xs[i - 1]) / span * (ys[i] - ys[i - 1]) : ys[i];
}
return ys[n - 1];
}
/// <summary>Whether point <paramref name="index"/> may be deleted: two points always remain and pinned ends stay.</summary>
public static bool CanRemove(int count, int index, bool pinEnds) =>
count > 2 && index >= 0 && index < count && (!pinEnds || (index > 0 && index < count - 1));
+62 -20
View File
@@ -1,8 +1,10 @@
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Media;
using Titano.Core.Localization;
using Titano.Ui.Controls;
namespace Titano.Ui.Visuals;
@@ -10,7 +12,9 @@ namespace Titano.Ui.Visuals;
/// Base of the retained-mode visuals. Brushes are looked up by theme resource key and re-resolved when the token
/// dictionary is swapped (frozen pens are cached per theme); text is laid out with the UI font at the element's
/// DPI; an optional overlay layer (playhead, hover) is redrawn without re-rendering the static content drawn in
/// <see cref="UIElement.OnRender"/>. Time axes and images never mirror, so the element is always left-to-right.
/// <see cref="UIElement.OnRender"/>. Time axes and images never mirror, so the element is always left-to-right;
/// words (categories, legends, summaries) still read in the UI language's direction (<see cref="CreateLabel"/>) and
/// legends start on its side. Screen readers see a named image (<see cref="DrawingElementAutomationPeer"/>).
/// </summary>
public abstract class DrawingElement : FrameworkElement
{
@@ -91,13 +95,29 @@ public abstract class DrawingElement : FrameworkElement
/// <summary>Pen covering whole device pixels, for gridlines and edges drawn at <see cref="PixelGrid.SnapLine"/> positions.</summary>
protected Pen GetHairline(string key, LineDash dash = LineDash.Solid) => GetPen(key, PixelGrid.SnapThickness(1, PixelScale), dash);
/// <summary>Single-line text in the UI font, laid out for this element's DPI and text formatting mode.</summary>
protected FormattedText CreateText(string text, double emSize, Brush brush, bool semiBold = false)
{
var typeface = semiBold ? _semiBold ??= CreateTypeface(FontWeights.SemiBold) : _regular ??= CreateTypeface(FontWeights.Normal);
return new FormattedText(text, Loc.Culture, FlowDirection.LeftToRight, typeface, emSize, brush, null,
TextOptions.GetTextFormattingMode(this), VisualTreeHelper.GetDpi(this).PixelsPerDip);
}
/// <summary>
/// Text a screen reader hears for the visual when no AutomationProperties.Name is set (its summary, its values);
/// null leaves the image unnamed.
/// </summary>
protected internal virtual string? AutomationDescription => null;
/// <summary>Single-line left-to-right text in the UI font (numbers, ticks, times), laid out for this element's DPI and text formatting mode.</summary>
protected FormattedText CreateText(string text, double emSize, Brush brush, bool semiBold = false) =>
Format(text, emSize, brush, semiBold, FlowDirection.LeftToRight);
/// <summary>
/// Single-line words (category, legend, summary) in the reading order of the UI language, so right-to-left text
/// mixed with numbers or Latin units keeps its order. Place it with <see cref="DrawTextAt"/>.
/// </summary>
protected FormattedText CreateLabel(string text, double emSize, Brush brush, bool semiBold = false) =>
Format(text, emSize, brush, semiBold, Bidi.UiDirection);
/// <summary>Draws <paramref name="text"/> with its top-left corner at <paramref name="topLeft"/>; right-to-left text is laid out leftwards from its origin.</summary>
protected static void DrawTextAt(DrawingContext dc, FormattedText text, Point topLeft) =>
dc.DrawText(text, text.FlowDirection == FlowDirection.RightToLeft ? new Point(topLeft.X + text.Width, topLeft.Y) : topLeft);
/// <summary>Position of a <paramref name="width"/>-wide box laid out from the left within [0, <paramref name="extent"/>], mirrored in a right-to-left UI.</summary>
protected static double FromStart(double x, double width, double extent) => Loc.IsRightToLeft ? extent - x - width : x;
/// <summary>Redraws the overlay layer; call after any change that only affects playhead or hover state.</summary>
protected void RenderOverlay()
@@ -165,25 +185,24 @@ public abstract class DrawingElement : FrameworkElement
}
/// <summary>
/// Draws legend entries left to right from <paramref name="origin"/> (swatch, 6 px, text in the entry colour,
/// 16 px between entries) and stops before <paramref name="maxRight"/>. Returns the right edge reached.
/// Draws legend entries in reading order from the start side of [<paramref name="left"/>, <paramref name="right"/>]
/// (swatch, 6 px, text in the entry colour, 16 px between entries); entries that do not fit are left out.
/// </summary>
protected double DrawLegend(DrawingContext dc, IReadOnlyList<ChartLegendItem> items, Point origin, double maxRight, double emSize)
protected void DrawLegend(DrawingContext dc, IReadOnlyList<ChartLegendItem> items, double left, double right, double top, double emSize)
{
var x = origin.X;
var offset = 0.0;
for (var i = 0; i < items.Count; i++)
{
var item = items[i];
var brush = GetBrush(item.BrushKey);
var text = CreateText(item.Text, emSize, brush);
var text = CreateLabel(item.Text, emSize, GetBrush(item.BrushKey));
var width = 16 + 6 + text.Width;
if (x + width > maxRight) break;
var cy = origin.Y + text.Height / 2;
DrawSwatch(dc, item.Swatch, item.BrushKey, new Rect(x, cy - 5, 16, 10));
dc.DrawText(text, new Point(x + 22, origin.Y));
x += width + 16;
if (left + offset + width > right) break;
var cy = top + text.Height / 2;
var extent = right - left;
DrawSwatch(dc, item.Swatch, item.BrushKey, new Rect(left + FromStart(offset, 16, extent), cy - 5, 16, 10));
DrawTextAt(dc, text, new Point(left + FromStart(offset + 22, text.Width, extent), top));
offset += width + 16;
}
return x;
}
/// <summary>Draws a legend swatch centred in <paramref name="box"/>.</summary>
@@ -235,8 +254,31 @@ public abstract class DrawingElement : FrameworkElement
element.OnThemeChanged();
}
protected override AutomationPeer OnCreateAutomationPeer() => new DrawingElementAutomationPeer(this);
private FormattedText Format(string text, double emSize, Brush brush, bool semiBold, FlowDirection direction)
{
var typeface = semiBold ? _semiBold ??= CreateTypeface(FontWeights.SemiBold) : _regular ??= CreateTypeface(FontWeights.Normal);
return new FormattedText(text, Loc.Culture, direction, typeface, emSize, brush, null,
TextOptions.GetTextFormattingMode(this), VisualTreeHelper.GetDpi(this).PixelsPerDip);
}
private Typeface CreateTypeface(FontWeight weight) =>
new(TryFindResource("Font.Ui") as FontFamily ?? SystemFonts.MessageFontFamily, FontStyles.Normal, weight, FontStretches.Normal);
private void OnWatchedCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) => OnDataChanged();
}
/// <summary>A chart seen by UI Automation: an image named by AutomationProperties.Name or, failing that, by its description.</summary>
public class DrawingElementAutomationPeer(DrawingElement owner) : FrameworkElementAutomationPeer(owner)
{
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Image;
protected override string GetClassNameCore() => Owner.GetType().Name;
protected override string GetNameCore()
{
var name = base.GetNameCore();
return string.IsNullOrEmpty(name) ? ((DrawingElement)Owner).AutomationDescription ?? string.Empty : name;
}
}
+47 -4
View File
@@ -1,5 +1,8 @@
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Input;
using System.Windows.Media;
using Titano.Core.Diagnostics;
@@ -11,7 +14,8 @@ namespace Titano.Ui.Visuals;
/// (exposure steps ▼ in Sun/Warning, keyframes ◆ in Accent). The cell holding <see cref="CurrentIndex"/> is outlined
/// in Accent and an accent ▼ marks the exact frame. Click or drag seeks, the wheel and arrow keys step one frame
/// (PageUp/PageDown one cell, Home/End the ends). Thumbnails load asynchronously from <see cref="Source"/> into an
/// LRU cache; cells show a placeholder until their image arrives. Hovering a marker reads out its label.
/// LRU cache; cells show a placeholder until their image arrives. Hovering a marker reads out its label. Screen
/// readers see a slider over the frame index.
/// </summary>
public sealed class Filmstrip : DrawingElement
{
@@ -77,7 +81,10 @@ public sealed class Filmstrip : DrawingElement
/// <summary>Decoded thumbnails kept in memory.</summary>
public int CacheCapacity { get => (int)GetValue(CacheCapacityProperty); set => SetValue(CacheCapacityProperty, value); }
private int FrameCount => Source?.Count ?? 0;
internal int FrameCount => Source?.Count ?? 0;
/// <summary>Frames per thumbnail cell: the PageUp/PageDown step.</summary>
internal int CellFrames => Math.Max(1, FrameCount / Math.Max(1, _strip.CellCount));
protected override Size MeasureOverride(Size availableSize) => new(0, MarkerRow + 3 + CellHeight);
@@ -188,7 +195,7 @@ public sealed class Filmstrip : DrawingElement
base.OnKeyDown(e);
var count = FrameCount;
if (count == 0) return;
var cellFrames = Math.Max(1, count / Math.Max(1, _strip.CellCount));
var cellFrames = CellFrames;
int? target = e.Key switch
{
Key.Left => CurrentIndex - 1,
@@ -212,7 +219,14 @@ public sealed class Filmstrip : DrawingElement
strip.InvalidateVisual();
}
private static void OnCurrentIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((Filmstrip)d).RenderOverlay();
protected override AutomationPeer OnCreateAutomationPeer() => new FilmstripAutomationPeer(this);
private static void OnCurrentIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var strip = (Filmstrip)d;
strip.RenderOverlay();
UIElementAutomationPeer.FromElement(strip)?.RaisePropertyChangedEvent(RangeValuePatternIdentifiers.ValueProperty, (double)(int)e.OldValue, (double)(int)e.NewValue);
}
private static object CoerceCurrentIndex(DependencyObject d, object value)
{
@@ -347,3 +361,32 @@ public sealed class Filmstrip : DrawingElement
private readonly record struct CachedFrame(ImageSource Image, int PixelWidth);
}
/// <summary>The filmstrip seen by UI Automation: a slider whose value is the current frame (0-based).</summary>
public sealed class FilmstripAutomationPeer(Filmstrip owner) : DrawingElementAutomationPeer(owner), IRangeValueProvider
{
private Filmstrip Strip => (Filmstrip)Owner;
public double Value => Strip.CurrentIndex;
public double Minimum => 0;
public double Maximum => Math.Max(0, Strip.FrameCount - 1);
public double SmallChange => 1;
public double LargeChange => Strip.CellFrames;
public bool IsReadOnly => !IsEnabled();
public void SetValue(double value)
{
if (!IsEnabled()) throw new ElementNotEnabledException();
Strip.SetCurrentValue(Filmstrip.CurrentIndexProperty, (int)Math.Round(value));
}
public override object? GetPattern(PatternInterface patternInterface) =>
patternInterface == PatternInterface.RangeValue ? this : base.GetPattern(patternInterface);
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Slider;
}
+5 -5
View File
@@ -114,9 +114,9 @@ public sealed class HeatmapStrip : DrawingElement
{
for (var c = 0; c < columns.Count; c++)
{
var label = CreateText(columns[c], LabelSize, faint);
var label = CreateLabel(columns[c], LabelSize, faint);
var (x, _) = _grid.CellOrigin(0, c);
dc.DrawText(label, new Point(x + (_grid.CellSize - label.Width) / 2, 0));
DrawTextAt(dc, label, new Point(x + (_grid.CellSize - label.Width) / 2, 0));
}
}
@@ -126,9 +126,9 @@ public sealed class HeatmapStrip : DrawingElement
for (var r = 0; r < rows.Count; r++)
{
var row = rows[r];
var label = CreateText(row.Label, LabelSize, faint);
var label = CreateLabel(row.Label, LabelSize, faint);
var (_, y) = _grid.CellOrigin(r, 0);
dc.DrawText(label, new Point(_grid.Left - 8 - label.Width, y + (_grid.CellSize - label.Height) / 2));
DrawTextAt(dc, label, new Point(_grid.Left - 8 - label.Width, y + (_grid.CellSize - label.Height) / 2));
for (var c = 0; c < _grid.Columns; c++)
{
var (x, _) = _grid.CellOrigin(r, c);
@@ -192,7 +192,7 @@ public sealed class HeatmapStrip : DrawingElement
var faint = Brushes.Transparent;
var labelWidth = 0.0;
if (Rows is { } rows)
for (var r = 0; r < rows.Count; r++) labelWidth = Math.Max(labelWidth, CreateText(rows[r].Label, LabelSize, faint).Width);
for (var r = 0; r < rows.Count; r++) labelWidth = Math.Max(labelWidth, CreateLabel(rows[r].Label, LabelSize, faint).Width);
var left = Math.Ceiling(labelWidth) + 8;
var top = ColumnLabels is { Count: > 0 } ? LabelHeight() + 4 : 0;
var cell = CellGridLayout.FitCellSize(width - left, height - top, RowCount, ColumnCount, CellGap, MaxCellSize);
+25 -10
View File
@@ -1,36 +1,51 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using Titano.Ui.Controls;
namespace Titano.Ui.Visuals;
/// <summary>
/// A tooltip (same style as every other) that opens at once and follows the mouse to read out the value under
/// the cursor. While it shows, the owner's own tooltip (which describes the action) is suppressed.
/// the cursor. While it shows, the owner's own tooltip (which describes the action) is suppressed. The text reads in
/// the UI language's direction unless the caller pins a numeric readout left to right.
/// </summary>
public sealed class HoverReadout(FrameworkElement owner)
{
private ToolTip? _tip;
private TextBlock? _text;
private object? _savedEnabled;
public bool IsOpen => _tip?.IsOpen == true;
/// <summary>Shows <paramref name="text"/> next to <paramref name="position"/> (owner coordinates); empty text hides the readout.</summary>
public void Show(string? text, Point position)
/// <summary>
/// Shows <paramref name="text"/> next to <paramref name="position"/> (owner coordinates); empty text hides the
/// readout. <paramref name="direction"/> defaults to the UI language's.
/// </summary>
public void Show(string? text, Point position, FlowDirection? direction = null)
{
if (string.IsNullOrEmpty(text))
{
Hide();
return;
}
_tip ??= new ToolTip
if (_tip is null)
{
Placement = PlacementMode.Relative,
PlacementTarget = owner,
IsHitTestVisible = false,
Focusable = false,
};
if (!Equals(_tip.Content, text)) _tip.Content = text;
// The tip keeps the owner's direction so its placement offsets stay the owner's; only the text inside reads
// right to left. The content is explicit, so the tooltip style's text settings are repeated here.
_text = new TextBlock { TextWrapping = TextWrapping.Wrap, LineHeight = 16 };
_tip = new ToolTip
{
Placement = PlacementMode.Relative,
PlacementTarget = owner,
IsHitTestVisible = false,
Focusable = false,
FlowDirection = owner.FlowDirection,
Content = _text,
};
}
_text!.FlowDirection = direction ?? Bidi.UiDirection;
if (_text.Text != text) _text.Text = text;
// Below-right of the cursor so the popup never sits under the mouse (which would end the hover).
_tip.HorizontalOffset = position.X + 12;
_tip.VerticalOffset = position.Y + 18;
+4
View File
@@ -1,4 +1,5 @@
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Media;
namespace Titano.Ui.Visuals;
@@ -50,6 +51,9 @@ public sealed class PreviewSurface : DrawingElement
protected override Visual GetVisualChild(int index) => _layers[index];
/// <summary>The viewport is the image screen readers see; the surface adds nothing to it.</summary>
protected override AutomationPeer OnCreateAutomationPeer() => null!;
/// <summary>Redraws both images over the image rectangle [0, size].</summary>
internal void SetImages(ImageSource? corrected, ImageSource? original, Size imageSize)
{
+26 -1
View File
@@ -1,8 +1,10 @@
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Titano.Core.Localization;
namespace Titano.Ui.Visuals;
@@ -39,7 +41,8 @@ public readonly record struct MotionVector(float X, float Y, float Dx, float Dy)
/// polyline) and a crop mask (normalised <see cref="CropRect"/>; dims or hides what the output loses). Tools go
/// bottom-left (<see cref="ToolsContent"/>), the shot data pill bottom-right (<see cref="InfoText"/>). Images and
/// overlays are retained visuals under one shared transform, so panning re-renders nothing. Double-click toggles
/// Fit and 1:1; Ctrl+0 fits, Ctrl+1 shows 1:1.
/// Fit and 1:1; Ctrl+0 fits, Ctrl+1 shows 1:1. Screen readers see an image (named by AutomationProperties.Name)
/// whose status is the zoom and whose help text is the shot data, holding the tools.
/// </summary>
[TemplatePart(Name = PartSurface, Type = typeof(FrameworkElement))]
[TemplatePart(Name = PartTools, Type = typeof(FrameworkElement))]
@@ -298,6 +301,8 @@ public class PreviewViewport : Control
ApplyZoomMode();
}
protected override AutomationPeer OnCreateAutomationPeer() => new PreviewViewportAutomationPeer(this);
private static object CoerceUnit(DependencyObject d, object value) => double.IsNaN((double)value) ? 0.5 : Math.Clamp((double)value, 0, 1);
private static object CoerceZoom(DependencyObject d, object value) =>
@@ -411,3 +416,23 @@ public class PreviewViewport : Control
return !_imageSize.IsEmpty && (_imageSize.Width * _view.Scale > view.Width + 0.5 || _imageSize.Height * _view.Scale > view.Height + 0.5);
}
}
/// <summary>The preview seen by UI Automation: an image whose status gives the zoom ("50 %") and whose help text is the shot data.</summary>
public sealed class PreviewViewportAutomationPeer(PreviewViewport owner) : FrameworkElementAutomationPeer(owner)
{
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Image;
protected override string GetClassNameCore() => nameof(PreviewViewport);
protected override string GetItemStatusCore()
{
var viewport = (PreviewViewport)Owner;
return viewport.ImageSize.IsEmpty ? string.Empty : Loc.L("Common.Percent", Math.Round(viewport.Zoom * 100));
}
protected override string GetHelpTextCore()
{
var help = base.GetHelpTextCore();
return string.IsNullOrEmpty(help) ? ((PreviewViewport)Owner).InfoText ?? string.Empty : help;
}
}
+10 -7
View File
@@ -86,7 +86,7 @@ public sealed class SeriesChart : DrawingElement
/// <summary>Explicit legend entries; null lists the titled series.</summary>
public IReadOnlyList<ChartLegendItem>? Legend { get => (IReadOnlyList<ChartLegendItem>?)GetValue(LegendProperty); set => SetValue(LegendProperty, value); }
/// <summary>Right-aligned text of the legend row (e.g. "flicker −67 % · max step 0.21 EV").</summary>
/// <summary>Text closing the legend row, at its end side (e.g. "flicker −67 % · max step 0.21 EV").</summary>
public string? Summary { get => (string?)GetValue(SummaryProperty); set => SetValue(SummaryProperty, value); }
public bool ShowLegend { get => (bool)GetValue(ShowLegendProperty); set => SetValue(ShowLegendProperty, value); }
@@ -114,6 +114,8 @@ public sealed class SeriesChart : DrawingElement
/// <summary>Formatting of frame indices (readout header and, when set, X axis labels).</summary>
public Func<double, string>? XLabelFormatter { get => (Func<double, string>?)GetValue(XLabelFormatterProperty); set => SetValue(XLabelFormatterProperty, value); }
protected internal override string? AutomationDescription => Summary;
protected override Size MeasureOverride(Size availableSize) => new(0, 160);
protected override void OnDataChanged()
@@ -290,15 +292,16 @@ public sealed class SeriesChart : DrawingElement
{
var items = Legend ?? AutoLegend();
if (items.Count == 0 && string.IsNullOrEmpty(Summary)) return 0;
var right = width;
double left = 0, right = width;
if (!string.IsNullOrEmpty(Summary))
{
var summary = CreateText(Summary, LabelSize, GetBrush("Brush.TextMuted"));
right -= summary.Width;
dc.DrawText(summary, new Point(right, 0));
right -= 16;
var summary = CreateLabel(Summary, LabelSize, GetBrush("Brush.TextMuted"));
var x = FromStart(width - summary.Width, summary.Width, width);
DrawTextAt(dc, summary, new Point(x, 0));
if (Loc.IsRightToLeft) left = summary.Width + 16;
else right = x - 16;
}
DrawLegend(dc, items, new Point(0, 0), right, LabelSize);
DrawLegend(dc, items, left, right, 0, LabelSize);
return LegendHeight;
}
+55 -1
View File
@@ -1,5 +1,8 @@
using System.Collections;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
@@ -12,7 +15,9 @@ namespace Titano.Ui.Visuals;
/// The main part executes <see cref="Command"/>; choosing a menu entry sets <see cref="SelectedItem"/> (checked in
/// the menu) — bind <see cref="CommandParameter"/> to it to act on the chosen preset. The control's ToolTip
/// describes the main action, <see cref="DropDownToolTip"/> the ▾ part. F4 or Alt+Down opens the menu.
/// <see cref="IsPrimary"/> gives the accent look of the screen's primary button.
/// <see cref="IsPrimary"/> gives the accent look of the screen's primary button. Screen readers see a split button
/// (named by AutomationProperties.Name or the content) that invokes and expands, holding the two parts;
/// <see cref="DropDownName"/> names the ▾ part.
/// </summary>
public class SplitButton : Control
{
@@ -25,6 +30,7 @@ public class SplitButton : Control
public static readonly DependencyProperty ItemContainerStyleProperty = DependencyProperty.Register(nameof(ItemContainerStyle), typeof(Style), typeof(SplitButton));
public static readonly DependencyProperty DisplayMemberPathProperty = DependencyProperty.Register(nameof(DisplayMemberPath), typeof(string), typeof(SplitButton));
public static readonly DependencyProperty DropDownToolTipProperty = DependencyProperty.Register(nameof(DropDownToolTip), typeof(object), typeof(SplitButton));
public static readonly DependencyProperty DropDownNameProperty = DependencyProperty.Register(nameof(DropDownName), typeof(string), typeof(SplitButton));
public static readonly DependencyProperty IsPrimaryProperty = DependencyProperty.Register(nameof(IsPrimary), typeof(bool), typeof(SplitButton));
public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register(
@@ -69,6 +75,9 @@ public class SplitButton : Control
/// <summary>Tooltip of the ▾ part.</summary>
public object? DropDownToolTip { get => GetValue(DropDownToolTipProperty); set => SetValue(DropDownToolTipProperty, value); }
/// <summary>Accessible name of the ▾ part (default "More choices").</summary>
public string? DropDownName { get => (string?)GetValue(DropDownNameProperty); set => SetValue(DropDownNameProperty, value); }
/// <summary>Accent fill (the one primary action of a screen).</summary>
public bool IsPrimary { get => (bool)GetValue(IsPrimaryProperty); set => SetValue(IsPrimaryProperty, value); }
@@ -84,11 +93,25 @@ public class SplitButton : Control
}
}
protected override AutomationPeer OnCreateAutomationPeer() => new SplitButtonAutomationPeer(this);
/// <summary>Runs the main action, as a click on the main part does.</summary>
internal void Invoke()
{
if (Command is { } command && command.CanExecute(CommandParameter)) command.Execute(CommandParameter);
}
private static void OnIsDropDownOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var button = (SplitButton)d;
if ((bool)e.NewValue) button.EnsureMenu().IsOpen = true;
else if (button._menu is { IsOpen: true } menu) menu.IsOpen = false;
if (UIElementAutomationPeer.FromElement(button) is { } peer)
{
peer.RaisePropertyChangedEvent(ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty,
(bool)e.OldValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed,
(bool)e.NewValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed);
}
}
private ContextMenu EnsureMenu()
@@ -124,3 +147,34 @@ public class SplitButton : Control
container.IsChecked = Equals(_menu.Items[i], SelectedItem);
}
}
/// <summary>UI Automation view of a <see cref="SplitButton"/>: Invoke runs the main action, ExpandCollapse opens the choices.</summary>
public sealed class SplitButtonAutomationPeer(SplitButton owner) : FrameworkElementAutomationPeer(owner), IInvokeProvider, IExpandCollapseProvider
{
private SplitButton Button => (SplitButton)Owner;
public ExpandCollapseState ExpandCollapseState => Button.IsDropDownOpen ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed;
public override object? GetPattern(PatternInterface patternInterface) =>
patternInterface is PatternInterface.Invoke or PatternInterface.ExpandCollapse ? this : base.GetPattern(patternInterface);
public void Invoke()
{
if (!IsEnabled()) throw new ElementNotEnabledException();
Button.Invoke();
}
public void Expand() => Button.SetCurrentValue(SplitButton.IsDropDownOpenProperty, true);
public void Collapse() => Button.SetCurrentValue(SplitButton.IsDropDownOpenProperty, false);
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.SplitButton;
protected override string GetClassNameCore() => nameof(SplitButton);
protected override string GetNameCore()
{
var name = base.GetNameCore();
return string.IsNullOrEmpty(name) ? Button.Content as string ?? string.Empty : name;
}
}
+13 -7
View File
@@ -62,6 +62,9 @@ public sealed class StackedBar : DrawingElement
remove => RemoveHandler(ItemActivatedEvent, value);
}
protected internal override string? AutomationDescription =>
Items is { Count: > 0 } items ? string.Join(Environment.NewLine, Enumerable.Range(0, items.Count).Select(ReadoutText)) : null;
protected override Size MeasureOverride(Size availableSize)
{
if (Items is not { Count: > 0 } items) return new Size(0, 0);
@@ -147,7 +150,10 @@ public sealed class StackedBar : DrawingElement
private string Share(double share) => ShareFormatter?.Invoke(share) ?? share.ToString("P0", Loc.Culture);
/// <summary>Flows legend entries into lines of the given width; draws them when <paramref name="dc"/> is set. Returns the line count.</summary>
/// <summary>
/// Flows legend entries into lines of the given width from the reading direction's side (the bar itself never
/// mirrors); draws them when <paramref name="dc"/> is set. Returns the line count.
/// </summary>
private int LayoutLegend(IReadOnlyList<ChartItem> items, double width, DrawingContext? dc)
{
var total = Total(items);
@@ -158,8 +164,8 @@ public sealed class StackedBar : DrawingElement
var top = BarHeight + LegendGap;
for (var i = 0; i < items.Count; i++)
{
var label = CreateText(items[i].Label, LabelSize, muted);
var value = CreateText(items[i].ValueText ?? Share(total > 0 ? Math.Max(0, items[i].Value) / total : 0), LabelSize, text);
var label = CreateLabel(items[i].Label, LabelSize, muted);
var value = CreateLabel(items[i].ValueText ?? Share(total > 0 ? Math.Max(0, items[i].Value) / total : 0), LabelSize, text);
var entryWidth = 8 + 6 + label.Width + 4 + value.Width;
if (x > 0 && double.IsFinite(width) && x + entryWidth > width)
{
@@ -171,11 +177,11 @@ public sealed class StackedBar : DrawingElement
var y = top + line * LegendLine;
var cy = y + label.Height / 2;
dc.PushOpacity(OpacityOf(i, items));
dc.DrawRoundedRectangle(GetBrush(items[i].BrushKey ?? BrushKey), null, new Rect(x, cy - 4, 8, 8), 2, 2);
dc.DrawRoundedRectangle(GetBrush(items[i].BrushKey ?? BrushKey), null, new Rect(FromStart(x, 8, width), cy - 4, 8, 8), 2, 2);
dc.Pop();
dc.DrawText(label, new Point(x + 14, y));
dc.DrawText(value, new Point(x + 14 + label.Width + 4, y));
_entries.Add(new Rect(x, y, entryWidth, LegendLine));
DrawTextAt(dc, label, new Point(FromStart(x + 14, label.Width, width), y));
DrawTextAt(dc, value, new Point(FromStart(x + 14 + label.Width + 4, value.Width, width), y));
_entries.Add(new Rect(FromStart(x, entryWidth, width), y, entryWidth, LegendLine));
}
x += entryWidth + EntryGap;
}
+4 -4
View File
@@ -132,8 +132,8 @@ public sealed class TimelineBands : DrawingElement
var top = b * BandHeight;
var baseline = top + BandHeight - captionHeight - 8;
var barSpace = baseline - top - 8;
var title = CreateText(band.Label, 13, text, semiBold: true);
dc.DrawText(title, new Point(0, top + (BandHeight - title.Height) / 2));
var title = CreateLabel(band.Label, 13, text, semiBold: true);
DrawTextAt(dc, title, new Point(0, top + (BandHeight - title.Height) / 2));
for (var s = 0; s < slots; s++)
{
var cx = LabelColumn + pitch * (s + 0.5);
@@ -145,8 +145,8 @@ public sealed class TimelineBands : DrawingElement
}
if (SlotLabels is { } labels && s < labels.Count)
{
var caption = CreateText(labels[s], LabelSize, faint);
dc.DrawText(caption, new Point(cx - caption.Width / 2, baseline + 4));
var caption = CreateLabel(labels[s], LabelSize, faint);
DrawTextAt(dc, caption, new Point(cx - caption.Width / 2, baseline + 4));
}
if (b == CurrentBand && s == CurrentSlot)
dc.DrawRoundedRectangle(null, GetPen("Brush.Accent", 1.5), new Rect(cx - pitch / 2 + 2, top + 4, pitch - 4, BandHeight - 8), 4, 4);
@@ -29,7 +29,6 @@ public sealed partial class ConfirmDialog : TitanoWindow
{
DataContext = request;
InitializeComponent();
WindowDirection.Follow(this);
Action.SetResourceReference(StyleProperty, request.IsDestructive ? "Button.Destructive" : "Button.Primary");
// The keyboard starts on the safe default, as in Windows dialogs.
Loaded += (_, _) => Safe.Focus();
+3 -10
View File
@@ -136,8 +136,7 @@
<!-- First run / signed out: connect form. -->
<Grid Grid.Row="1" Visibility="{Binding IsConnectVisible, Converter={StaticResource BoolToVisibility}}">
<StackPanel DataContext="{Binding Connect}" Width="440" HorizontalAlignment="Center" VerticalAlignment="Center">
<!-- The mark is artwork: its off-centre sun must not flip in right-to-left languages. -->
<ui:BrandMarkIcon Width="48" Height="48" HorizontalAlignment="Center" FlowDirection="LeftToRight" />
<ui:BrandMarkIcon Width="48" Height="48" HorizontalAlignment="Center" />
<TextBlock Text="{l:Loc Uploader.Connect.Title}" Style="{StaticResource Text.Title}" HorizontalAlignment="Center" Margin="0,14,0,20" />
<Grid>
<Grid.ColumnDefinitions>
@@ -188,15 +187,9 @@
ToolTip="{l:Loc Tooltips.Uploader.User}" AutomationProperties.Name="{l:Loc Uploader.Connect.User}" />
<TextBlock Grid.Row="3" Text="{l:Loc Uploader.Connect.Password}" Style="{StaticResource Text.Label}" Margin="0,12,12,0" />
<!-- A wrong password: the kit's error border (DESIGN §4); the message is the tooltip. -->
<PasswordBox x:Name="Password" Grid.Row="3" Grid.Column="1" Margin="0,12,0,0" PasswordChanged="OnPasswordChanged"
ToolTip="{Binding PasswordToolTip}" AutomationProperties.Name="{l:Loc Uploader.Connect.Password}" />
<!--
A wrong password: the Error border (DESIGN §4), drawn over the box because the password box has no binding
to validate and its template paints the focus border over its own; the message is the tooltip.
-->
<Border x:Name="PasswordErrorRing" Grid.Row="3" Grid.Column="1" Margin="0,12,0,0" BorderBrush="{DynamicResource Brush.Error}" BorderThickness="1"
CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True" IsHitTestVisible="False"
Visibility="{Binding PasswordError, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
ToolTip="{Binding PasswordToolTip}" AutomationProperties.Name="{l:Loc Uploader.Connect.Password}" ui:Field.Error="{Binding PasswordError}" />
<Border Grid.Row="4" Grid.Column="1" Margin="0,12,0,0" Padding="10,6,6,6" CornerRadius="{StaticResource Radius.Control}" Background="{DynamicResource Brush.ErrorSubtle}"
Visibility="{Binding ErrorText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
@@ -32,7 +32,6 @@ public sealed partial class MainWindow : TitanoWindow
_connectShown = vm.IsConnectVisible;
DataContext = vm;
InitializeComponent();
WindowDirection.Follow(this);
vm.PendingToasts.CollectionChanged += OnToastRequested;
vm.PropertyChanged += OnViewModelChanged;
vm.Connect.PropertyChanged += OnConnectChanged;
@@ -1,22 +0,0 @@
using System.Windows;
using Titano.Core.Localization;
namespace Titano.Uploader.Shell;
/// <summary>
/// Mirrors a window for right-to-left languages (BRIEF §16: ar, he, fa, ur) and follows later language switches.
/// Windows do not inherit <see cref="FrameworkElement.FlowDirection"/> from their owner, so every window calls this.
/// </summary>
public static class WindowDirection
{
public static void Follow(Window window)
{
Apply(window);
void OnCultureChanged(object? sender, EventArgs e) => window.Dispatcher.Invoke(() => Apply(window));
Loc.CultureChanged += OnCultureChanged;
window.Closed += (_, _) => Loc.CultureChanged -= OnCultureChanged;
}
private static void Apply(Window window) =>
window.FlowDirection = Loc.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
}