refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s

The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout and the system SQLite. The release cross-compiles the Windows
  programs, checks their icon, version and DPI manifest, packs installers
  and zips, publishes the Gitea release and pushes the server image
  (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows
  runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow; the
  throw-away server runs without durability) and pe-check.
- Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR,
  3 on the shared runner; the weekly performance gates keep theirs).

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-23 12:45:18 +02:00
1 parent c99842cc86
commit f2b58522b9
1801 files changed
+11804 -10676

No files matched your search

+82
View File
@@ -0,0 +1,82 @@
<UserControl x:Class="Chronos.App.Sections.AboutView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:infra="clr-namespace:Chronos.App.Infrastructure">
<!-- BRIEF §12.9 (no mockup): built from the kit — panel, label column, one primary action. -->
<Grid Margin="20,16,20,20">
<Border Style="{StaticResource Border.Panel}" Padding="28,24" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="600">
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,22">
<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" />
</StackPanel>
</StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="140" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="Auto" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<TextBlock Style="{StaticResource Text.Label}" Text="{l:Loc About.Build}" />
<TextBlock Grid.Column="1" Text="{Binding Build}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<TextBlock Grid.Row="1" Style="{StaticResource Text.Label}" Text="{l:Loc About.Runtime}" />
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Runtime}" VerticalAlignment="Center" />
<TextBlock Grid.Row="2" Style="{StaticResource Text.Label}" Text="{l:Loc About.System}" />
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding OperatingSystem}" ToolTip="{Binding OperatingSystem}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Row="3" Style="{StaticResource Text.Label}" Text="{l:Loc About.Licence}" />
<Button Grid.Row="3" Grid.Column="1" Style="{StaticResource Button.Link}" FontSize="13" HorizontalAlignment="Left" VerticalAlignment="Center"
Content="{l:Loc About.LicenceLink}" Command="{Binding OpenLicenceCommand}" ToolTip="{l:Loc Tooltips.About.Licence}" />
<TextBlock Grid.Row="4" Style="{StaticResource Text.Label}" Text="{l:Loc About.ThirdParty}" />
<TextBlock Grid.Row="4" Grid.Column="1" Text="{l:Loc About.ThirdPartyNone}" VerticalAlignment="Center" ToolTip="{l:Loc Tooltips.About.ThirdParty}" />
<TextBlock Grid.Row="5" Style="{StaticResource Text.Label}" Text="{l:Loc About.Data}" />
<!-- A path reads left to right in every language and shows whole in its tooltip when cut. -->
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding DataFolder}" ToolTip="{Binding DataFolder}" VerticalAlignment="Center" HorizontalAlignment="Left"
TextTrimming="CharacterEllipsis" FlowDirection="LeftToRight" />
<TextBlock Grid.Row="6" Style="{StaticResource Text.Label}" Text="{l:Loc About.Translation}" Height="28"
Visibility="{Binding IsTranslated, Converter={StaticResource BoolToVisibility}}" />
<StackPanel Grid.Row="6" Grid.Column="1" Orientation="Horizontal" Height="28" Visibility="{Binding IsTranslated, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{l:Loc About.MachineTranslated}" VerticalAlignment="Center" />
<Button Style="{StaticResource Button.Link}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center" Content="{l:Loc About.Review}"
Command="{Binding ReviewTranslationCommand}" ToolTip="{l:Loc Tooltips.About.Review}" />
</StackPanel>
<TextBlock Grid.Row="7" Style="{StaticResource Text.Label}" Text="{l:Loc About.Updates}" />
<StackPanel Grid.Row="7" Grid.Column="1" Orientation="Horizontal">
<ui:StatusGlyph Kind="{Binding UpdateKind}" Text="{Binding UpdateText}" FontSize="13" VerticalAlignment="Center"
Visibility="{Binding HasUpdateText, Converter={StaticResource BoolToVisibility}}"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding UpdateAnnouncement}" />
<Button Style="{StaticResource Button.Link}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center" Content="{l:Loc About.Update.Download}"
Command="{Binding DownloadCommand}" ToolTip="{Binding DownloadToolTip}"
Visibility="{Binding IsUpdateAvailable, Converter={StaticResource BoolToVisibility}}" />
<Button Style="{StaticResource Button.Link}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center" Content="{l:Loc About.Update.Cancel}"
Command="{Binding CancelDownloadCommand}" ToolTip="{l:Loc Tooltips.About.CancelDownload}"
Visibility="{Binding IsDownloading, Converter={StaticResource BoolToVisibility}}" />
<Button Style="{StaticResource Button.Link}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center" Content="{l:Loc About.Update.ShowFile}"
Command="{Binding ShowPackageCommand}" ToolTip="{Binding ShowPackageToolTip}"
Visibility="{Binding IsPackageReady, Converter={StaticResource BoolToVisibility}}" />
</StackPanel>
</Grid>
<WrapPanel Margin="0,22,0,0">
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc About.Update.Check}" Command="{Binding CheckCommand}" ToolTip="{l:Loc Tooltips.About.Check}" Margin="0,0,8,8" />
<Button Content="{l:Loc About.Releases}" Command="{Binding OpenReleasesCommand}" ToolTip="{l:Loc Tooltips.About.Releases}" ui:ButtonIcon.Glyph="{StaticResource Icon.ExternalLink}" Margin="0,0,8,8" />
<Button Content="{l:Loc About.Diagnostics}" Command="{Binding DiagnosticsCommand}" ToolTip="{l:Loc Tooltips.About.Diagnostics}" ui:ButtonIcon.Glyph="{StaticResource Icon.Export}" Margin="0,0,8,8" />
<Button Content="{l:Loc About.OpenData}" Command="{Binding OpenDataFolderCommand}" ToolTip="{l:Loc Tooltips.About.OpenData}" ui:ButtonIcon.Glyph="{StaticResource Icon.FolderOpen}" Margin="0,0,8,8" />
</WrapPanel>
</StackPanel>
</Border>
</Grid>
</UserControl>
@@ -0,0 +1,8 @@
using System.Windows.Controls;
namespace Chronos.App.Sections;
public partial class AboutView : UserControl
{
public AboutView() => InitializeComponent();
}
+153
View File
@@ -0,0 +1,153 @@
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Input;
using Chronos.App.About;
using Chronos.App.Infrastructure;
using Chronos.App.Shell;
using Chronos.Core.Localization;
using Chronos.Ui.Controls;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Sections;
/// <summary>
/// About (BRIEF §12.9): version and build, licence link, third-party notice (none), translation notice,
/// diagnostics bundle and the update notice of <see cref="UpdateFlow"/> (BRIEF §18), which Settings › Updates shows too.
/// </summary>
public sealed class AboutViewModel : SectionViewModel
{
private readonly UpdateFlow _update;
public AboutViewModel(ShellViewModel shell)
: base(SectionKey.About, "Icon.About")
{
Shell = shell;
var environment = shell.Services.Environment;
_update = new UpdateFlow(new UpdateHost(UpdateCheck.RunningVersion(Version), environment.IsCapture, environment.IsPortable,
ct => Shell.Services.CheckForUpdateAsync(ct), (release, progress, ct) => Shell.Services.DownloadUpdateAsync(release, progress, ct),
ShellActions.OpenUrl, ShellActions.Reveal)
{ RunningIsPrerelease = UpdateCheck.IsPrerelease(Version) });
_update.Changed += RaiseUpdate;
ShowPackageCommand = new RelayCommand(() =>
{
if (_update.PackagePath is { } path) ShellActions.Reveal(path);
}, () => _update.PackagePath is not null);
CancelDownloadCommand = new RelayCommand(_update.CancelDownload, () => IsDownloading);
OpenReleasesCommand = new RelayCommand(() => ShellActions.OpenUrl(ProductLinks.Releases));
OpenLicenceCommand = new RelayCommand(() => ShellActions.OpenUrl(ProductLinks.Licence));
ReviewTranslationCommand = new RelayCommand(() => ShellActions.OpenUrl(ProductLinks.Issues));
OpenDataFolderCommand = new RelayCommand(() => ShellActions.Reveal(DataFolder));
DiagnosticsCommand = new AsyncRelayCommand(DiagnosticsAsync);
}
public ShellViewModel Shell { get; }
public string Version => AppServices.VersionText;
/// <summary>File version and processor architecture.</summary>
public string Build =>
(typeof(App).Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version ?? Version) + Loc.Separator + RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
public string Runtime => RuntimeInformation.FrameworkDescription;
public string OperatingSystem => RuntimeInformation.OSDescription;
public string DataFolder => Shell.Services.Environment.DataDirectory;
/// <summary>Every language but English is machine-translated and open to review (BRIEF §16).</summary>
public bool IsTranslated => !Loc.Culture.TwoLetterISOLanguageName.Equals("en", StringComparison.OrdinalIgnoreCase);
public ICommand CheckCommand => _update.Check;
public ICommand DownloadCommand => _update.Download;
public ICommand ShowPackageCommand { get; }
public ICommand CancelDownloadCommand { get; }
public ICommand OpenReleasesCommand { get; }
public ICommand OpenLicenceCommand { get; }
public ICommand ReviewTranslationCommand { get; }
public ICommand OpenDataFolderCommand { get; }
public ICommand DiagnosticsCommand { get; }
/// <summary>"Up to date", "Chronos 0.2.0 available", …; null before the first check.</summary>
public string? UpdateText => _update.State switch
{
UpdateState.Checking => Loc.L("About.Update.Checking"),
UpdateState.UpToDate => Loc.L("About.Update.Current"),
UpdateState.Available when _update.Release is { } r => Loc.L("About.Update.Available", UpdateCheck.Display(r.Version)),
UpdateState.Failed => Loc.L("About.Update.Failed"),
UpdateState.Downloading => Loc.L("About.Update.Downloading", _update.Downloaded),
UpdateState.Downloaded when _update.Release is { } r => Loc.L("About.Update.Ready", UpdateCheck.Display(r.Version)),
UpdateState.DownloadFailed => Loc.L("About.Update.DownloadFailed"),
UpdateState.NotVerified => Loc.L("About.Update.NotVerified"),
_ => null,
};
/// <summary>What screen readers announce: each new state, not each percent of a download.</summary>
public string? UpdateAnnouncement => _update.State == UpdateState.Downloading ? Loc.L("About.Update.InProgress") : UpdateText;
public StatusKind UpdateKind => _update.State switch
{
UpdateState.Checking or UpdateState.Downloading => StatusKind.Running,
UpdateState.UpToDate or UpdateState.Downloaded => StatusKind.Done,
UpdateState.Available => StatusKind.Warning,
_ => StatusKind.Error,
};
public bool HasUpdateText => UpdateText is not null;
/// <summary>Download is offered: a newer release exists and no verified package is waiting (a failed download can be retried).</summary>
public bool IsUpdateAvailable => _update.IsDownloadOffered;
/// <summary>The verified setup or portable zip is in the temporary folder.</summary>
public bool IsPackageReady => _update.State == UpdateState.Downloaded;
public bool IsDownloading => _update.State == UpdateState.Downloading;
/// <summary>What Download does here: fetch and verify the setup or the portable zip (with its size), or open the release page.</summary>
public string DownloadToolTip => _update.Package is { } package
? Loc.L(_update.IsPortable ? "Tooltips.About.DownloadPortable" : "Tooltips.About.Download", Formatting.Bytes(package.Size))
: Loc.L("Tooltips.About.DownloadPage");
public string ShowPackageToolTip => Loc.L(_update.IsPortable ? "Tooltips.About.ShowPortable" : "Tooltips.About.ShowSetup");
/// <summary>Starts the update check on start when allowed (opt-out, BRIEF §18); never in a capture run.</summary>
public void Attach() => _ = NotifyAsync();
/// <summary>Sets a result without the network (capture, tests).</summary>
internal void SetResult(ReleaseInfo? release, bool failed = false) => _update.SetResult(release, failed);
private async Task NotifyAsync()
{
if (await _update.CheckOnStartAsync(Shell.Services.Settings.CheckForUpdates) is not { } newer) return;
Shell.Notify(Loc.L("About.Update.Available", UpdateCheck.Display(newer.Version)), actionText: Loc.L("About.Update.Download"),
actionToolTip: DownloadToolTip, action: () => DownloadCommand.Execute(null));
}
private async Task DiagnosticsAsync()
{
var folder = Shell.Services.Dialogs.PickFolder(Loc.L("Settings.Advanced.DiagnosticsTitle"));
if (folder is null) return;
try
{
var path = await DiagnosticsBundle.CreateAsync(Shell.Services, folder);
Shell.Notify(Loc.L("Settings.Advanced.DiagnosticsDone"), 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 Chronos.Data.DatabaseException)
{
Shell.ReportError(ex);
}
}
private void RaiseUpdate()
{
OnPropertyChanged(nameof(UpdateText));
OnPropertyChanged(nameof(UpdateAnnouncement));
OnPropertyChanged(nameof(UpdateKind));
OnPropertyChanged(nameof(HasUpdateText));
OnPropertyChanged(nameof(IsUpdateAvailable));
OnPropertyChanged(nameof(IsPackageReady));
OnPropertyChanged(nameof(IsDownloading));
OnPropertyChanged(nameof(DownloadToolTip));
CommandManager.InvalidateRequerySuggested();
}
}
+448
View File
@@ -0,0 +1,448 @@
<UserControl x:Class="Chronos.App.Sections.ArchiveView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:v="clr-namespace:Chronos.Ui.Visuals;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:ar="clr-namespace:Chronos.App.Archiving"
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
xmlns:shell="clr-namespace:Chronos.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:,,,/Chronos;component/Archive/ArchiveDialogs.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="Text.PanelHeading" TargetType="TextBlock" BasedOn="{StaticResource Text.Section}">
<Setter Property="FontSize" Value="13" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style x:Key="Button.Bar" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="0,0,8,0" />
</Style>
<Style x:Key="Button.Tool" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Margin" Value="0,0,8,8" />
</Style>
<!-- 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}}">
<Setter Property="Header" Value="{Binding Label}" />
<Setter Property="IsChecked" Value="{Binding IsChecked, Mode=OneWay}" />
<Setter Property="Command" Value="{Binding Command}" />
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Archive.FilterChoice}" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid Margin="20,16" IsEnabled="{Binding IsContentEnabled}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- ===================== Toolbar (Archive.html: one row) ===================== -->
<DockPanel Margin="0,0,0,4">
<ComboBox DockPanel.Dock="Left" Width="220" VerticalAlignment="Top" ItemsSource="{Binding Archives}" SelectedItem="{Binding SelectedArchive}" DisplayMemberPath="Name"
ToolTip="{Binding ArchiveToolTip}" AutomationProperties.Name="{l:Loc Archive.Toolbar.Archive}" Margin="0,0,8,8" />
<Border DockPanel.Dock="Left" Width="1" Height="22" Background="{DynamicResource Brush.Stroke}" Margin="4,5,12,0" VerticalAlignment="Top" />
<WrapPanel>
<Button Style="{StaticResource Button.Tool}" Content="{l:Loc Archive.Toolbar.Scan}" Command="{Binding ScanCommand}" ToolTip="{Binding ScanToolTip}" />
<Button Style="{StaticResource Button.Tool}" Content="{l:Loc Archive.Toolbar.Rebuild}" Command="{Binding RebuildCommand}" ToolTip="{l:Loc Tooltips.Archive.Rebuild}" />
<Button Style="{StaticResource Button.Tool}" Content="{l:Loc Archive.Toolbar.Verify}" Command="{Binding VerifyCommand}" ToolTip="{Binding VerifyToolTip}" />
<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}" 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" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="{l:Loc Archive.Adopt.InPlace}" Command="{Binding AdoptCommand}" ToolTip="{l:Loc Tooltips.Archive.AdoptInPlace}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Archive.Adopt.Copy}" Command="{Binding CopyFolderCommand}" ToolTip="{l:Loc Tooltips.Archive.AdoptCopy}" ToolTipService.ShowOnDisabled="True" />
</ContextMenu>
</Button.ContextMenu>
</Button>
<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" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="{l:Loc Archive.Maintenance.Run}" Command="{Binding MaintenanceCommand}" ToolTip="{Binding MaintenanceRunToolTip}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Archive.Maintenance.DryRun}" Command="{Binding MaintenanceDryRunCommand}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceDryRun}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Archive.Maintenance.Proxies}" Command="{Binding RebuildProxiesCommand}" ToolTip="{Binding RebuildProxiesToolTip}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Archive.Maintenance.Backup}" Command="{Binding BackupCommand}" ToolTip="{l:Loc Tooltips.Archive.Backup}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Archive.Maintenance.Restore}" Command="{Binding RestoreCommand}" ToolTip="{l:Loc Tooltips.Archive.Restore}" />
<MenuItem Header="{l:Loc Archive.Maintenance.Trash}" Command="{Binding TrashCommand}" ToolTip="{l:Loc Tooltips.Archive.Trash}" ToolTipService.ShowOnDisabled="True" />
<Separator />
<MenuItem Header="{l:Loc Archive.Maintenance.Relink}" Command="{Binding RelinkCommand}" ToolTip="{l:Loc Tooltips.Archive.Relink}" ToolTipService.ShowOnDisabled="True" />
</ContextMenu>
</Button.ContextMenu>
</Button>
</WrapPanel>
</DockPanel>
<!-- Overview or maintenance, and when the archive was last scanned. -->
<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.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}" />
</DockPanel>
<!-- ===================== Overview: tree, figures, charts ===================== -->
<Grid Grid.Row="2" Visibility="{Binding IsOverview, Converter={StaticResource BoolToVisibility}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*" MinWidth="200" MaxWidth="320" />
<ColumnDefinition Width="14" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="6,8">
<ListBox x:Name="Tree" ItemsSource="{Binding TreeRows}" SelectionMode="Extended" SelectionChanged="OnTreeSelectionChanged" PreviewKeyDown="OnTreeKeyDown"
AutomationProperties.Name="{l:Loc Archive.Tree.Name}">
<ListBox.ItemContainerStyle>
<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}" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type ar:ArchiveTreeRowViewModel}">
<!-- Measured in order: the toggle's slot, an archive's state, the title, then a year's figures, which give way first (the row's
tooltip has them whole), so a year keeps its label at the minimum window. -->
<DockPanel Margin="{Binding IndentMargin}">
<Border DockPanel.Dock="Left" Width="24">
<Button x:Name="Toggle" Style="{StaticResource Button.IconSubtle}" Width="22" Height="22" MinWidth="22" HorizontalAlignment="Left"
ui:ButtonIcon.Glyph="{StaticResource Icon.ChevronRight}" Command="{Binding ToggleCommand}" ToolTip="{Binding ToggleToolTip}"
AutomationProperties.Name="{Binding ToggleName}" Visibility="Hidden" Focusable="False" />
</Border>
<ui:StatusGlyph x:Name="State" DockPanel.Dock="Right" Kind="{Binding AvailabilityKind}" Text="{Binding AvailabilityText}" VerticalAlignment="Center"
Margin="8,0,0,0" ToolTip="{Binding AvailabilityToolTip}" Visibility="Collapsed" />
<TextBlock x:Name="Title" DockPanel.Dock="Left" Text="{Binding Title}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />
<TextBlock x:Name="Detail" Text="{Binding Detail}" Style="{StaticResource Text.Secondary}" VerticalAlignment="Center" Margin="8,0,0,0"
TextTrimming="CharacterEllipsis" TextAlignment="Right" Visibility="Collapsed" Typography.NumeralAlignment="Tabular" />
</DockPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding HasChildren}" Value="True">
<Setter TargetName="Toggle" Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding IsExpanded}" Value="True">
<Setter TargetName="Toggle" Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.ChevronDown}" />
</DataTrigger>
<DataTrigger Binding="{Binding IsArchive}" Value="True">
<Setter TargetName="Title" Property="FontWeight" Value="SemiBold" />
<Setter TargetName="State" Property="Visibility" Value="Visible" />
<Setter TargetName="Toggle" Property="Visibility" Value="Collapsed" />
</DataTrigger>
<DataTrigger Binding="{Binding IsYear}" Value="True">
<Setter TargetName="Title" Property="FontWeight" Value="SemiBold" />
<Setter TargetName="Detail" Property="Visibility" Value="Visible" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
<Grid Grid.Column="2">
<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 Grid.ColumnSpan="3" ItemsSource="{Binding Tiles}" Focusable="False" Margin="0,0,-14,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type ar:ArchiveTile}">
<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">
<TextBlock Text="{Binding Value}" FontSize="24" FontWeight="SemiBold" Typography.NumeralAlignment="Tabular" />
</Viewbox>
<TextBlock Text="{Binding Caption}" Style="{StaticResource Text.Secondary}" TextWrapping="Wrap" />
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<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>
<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}" />
</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>
<!-- ===================== Maintenance: health, recent runs, duplicates, orphans ===================== -->
<Grid Grid.Row="2" Visibility="{Binding IsMaintenance, Converter={StaticResource BoolToVisibility}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="14" />
<ColumnDefinition Width="1.1*" />
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="16,12">
<StackPanel>
<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: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>
</StackPanel>
</Border>
<Border Grid.Row="1" Style="{StaticResource Border.Panel}" Padding="16,12" Margin="0,14,0,0">
<DockPanel>
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Recent.History}" Command="{Binding HistoryCommand}"
ToolTip="{l:Loc Tooltips.Archive.History}" />
<TextBlock Text="{l:Loc Archive.Recent.Title}" Style="{StaticResource Text.PanelHeading}" />
</DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Recent.Empty}" Foreground="{DynamicResource Brush.TextMuted}"
Visibility="{Binding HasRecent, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<ItemsControl ItemsSource="{Binding Recent}" Focusable="False">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type ar:MaintenanceRow}">
<Grid Height="28">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="90" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</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}" />
<!-- 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>
</ItemsControl>
</DockPanel>
</Border>
</Grid>
<Grid Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="16,12">
<DockPanel>
<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 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 IsFindingDuplicates, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{l:Loc Archive.Duplicates.Title}" Style="{StaticResource Text.PanelHeading}" />
<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">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type ar:DuplicateRowViewModel}">
<DockPanel Height="44">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Content="{l:Loc Archive.Duplicates.Folder}" Command="{Binding RevealCommand}"
ToolTip="{l:Loc Tooltips.Archive.DuplicateFolder}" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Content="{l:Loc Archive.Duplicates.Open}" Command="{Binding OpenCommand}"
ToolTip="{l:Loc Tooltips.Archive.DuplicateOpen}" />
<StackPanel VerticalAlignment="Center">
<TextBlock TextTrimming="CharacterEllipsis">
<Run Text="{Binding Row.Title, Mode=OneWay}" FontWeight="SemiBold" />
<Run Text="{Binding Row.Detail, Mode=OneWay}" Foreground="{DynamicResource Brush.TextMuted}" />
</TextBlock>
<TextBlock Text="{Binding Places}" Style="{StaticResource Text.Secondary}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Places}" />
</StackPanel>
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</Border>
<Border Grid.Row="1" Style="{StaticResource Border.Panel}" Padding="16,12" Margin="0,14,0,0">
<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 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 IsFindingOrphans, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{l:Loc Archive.Orphans.Title}" Style="{StaticResource Text.PanelHeading}" />
<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">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type ar:OrphanRowViewModel}">
<DockPanel Height="44">
<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="Warning" Text="{Binding Row.Detail}" FontSize="12" ToolTip="{Binding KindText}" />
</StackPanel>
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</Border>
</Grid>
</Grid>
<!-- ===================== Mass operations on the selected, filtered set; Delete… apart at the far right (Archive.html) ===================== -->
<Border Grid.Row="3" Style="{StaticResource Border.Panel}" Padding="14,8,6,0" Margin="0,14,0,0" MinHeight="48"
Visibility="{Binding IsOverview, Converter={StaticResource BoolToVisibility}}">
<!-- Delete… last in the tab order too. -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<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="{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" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="{l:Loc Library.Filter.Camera}" ItemsSource="{Binding CameraChoices}" ItemContainerStyle="{StaticResource MenuItem.Choice}"
ToolTip="{l:Loc Tooltips.Archive.FilterCamera}" />
<MenuItem Header="{l:Loc Library.Filter.Status}" ItemsSource="{Binding StatusChoices}" ItemContainerStyle="{StaticResource MenuItem.Choice}"
ToolTip="{l:Loc Tooltips.Archive.FilterStatus}" />
<MenuItem Header="{l:Loc Library.Filter.Tags}" ItemsSource="{Binding TagChoices}" ItemContainerStyle="{StaticResource MenuItem.Choice}"
ToolTip="{l:Loc Tooltips.Archive.FilterTag}" />
<Separator />
<MenuItem Header="{l:Loc Archive.Set.ClearFilter}" Command="{Binding ClearFilterCommand}" ToolTip="{l:Loc Tooltips.Archive.ClearFilter}" ToolTipService.ShowOnDisabled="True" />
</ContextMenu>
</Button.ContextMenu>
</Button>
<Border Width="1" Height="22" Background="{DynamicResource Brush.Stroke}" Margin="4,0,12,8" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Analyse}" Command="{Binding AnalyseSetCommand}" ToolTip="{Binding AnalyseSetToolTip}" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Proxies}" Command="{Binding ProxiesSetCommand}" ToolTip="{Binding ProxiesSetToolTip}" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Thumbnails}" Command="{Binding ThumbnailsSetCommand}"
ToolTip="{Binding ThumbnailsSetToolTip}" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Verify}" Command="{Binding VerifySetCommand}" ToolTip="{Binding VerifySetToolTip}" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Rename}" Command="{Binding RenameSetCommand}" ToolTip="{Binding RenameSetToolTip}" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Move}" Command="{Binding MoveSetCommand}" ToolTip="{Binding MoveSetToolTip}" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Retag}" Command="{Binding RetagSetCommand}" ToolTip="{Binding RetagSetToolTip}" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Export}" Command="{Binding ExportSetCommand}" ToolTip="{Binding ExportSetToolTip}" />
</WrapPanel>
<Button Grid.Column="1" Style="{StaticResource Button.Destructive}" Height="30" Margin="8,0,8,8" VerticalAlignment="Top" Content="{l:Loc Archive.Set.Delete}"
Command="{Binding DeleteSetCommand}" ToolTip="{Binding DeleteSetToolTip}" />
</Grid>
</Border>
<ui:EmptyState Grid.Row="2" Message="{l:Loc Archive.Empty}" Visibility="{Binding IsEmpty, Converter={StaticResource BoolToVisibility}}">
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Archive.Toolbar.Adopt}" Command="{Binding AdoptCommand}" ToolTip="{l:Loc Tooltips.Archive.Adopt}" />
</ui:EmptyState>
</Grid>
<!-- In-window dialogs (rebuild, rename, retag, trash) over a scrim; the keyboard stays inside the dialog. -->
<Grid Visibility="{Binding IsDialogOpen, Converter={StaticResource BoolToVisibility}}" KeyboardNavigation.TabNavigation="Cycle"
KeyboardNavigation.ControlTabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Contained">
<Border Background="{DynamicResource Brush.Scrim}" />
<ContentPresenter x:Name="DialogHost" Content="{Binding Dialog}" Margin="20" />
</Grid>
</Grid>
</UserControl>
@@ -0,0 +1,128 @@
using System.ComponentModel;
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 Chronos.App.Archiving;
namespace Chronos.App.Sections;
public partial class ArchiveView : UserControl
{
private bool _restoring;
private string? _focusKey;
private IInputElement? _beforeDialog;
public ArchiveView()
{
InitializeComponent();
DataContextChanged += OnDataContextChanged;
Tree.GotKeyboardFocus += (_, e) =>
{
if (e.NewFocus is ListBoxItem { DataContext: ArchiveTreeRowViewModel row }) _focusKey = row.Node.Key;
};
}
private ArchiveViewModel? Model => DataContext as ArchiveViewModel;
/// <summary>"Adopt folder ▾", "Maintenance ▾" and the set filter open their menu under themselves.</summary>
private void OnOpenMenu(object sender, RoutedEventArgs e)
{
if (sender is not Button { ContextMenu: { } menu } button) return;
menu.DataContext = DataContext;
menu.PlacementTarget = button;
menu.Placement = PlacementMode.Bottom;
menu.IsOpen = true;
}
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.OldValue is ArchiveViewModel old)
{
old.RowsRebuilt -= RestoreSelection;
old.PropertyChanged -= OnModelChanged;
}
if (e.NewValue is ArchiveViewModel model)
{
model.RowsRebuilt += RestoreSelection;
model.PropertyChanged += OnModelChanged;
}
}
/// <summary>The selected tree rows are the set the mass operations act on.</summary>
private void OnTreeSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!_restoring) Model?.SetSelection(Tree.SelectedItems.OfType<ArchiveTreeRowViewModel>());
}
/// <summary>The rows were rebuilt (a reload, a year opened or closed): the list shows the same selection and keeps the keyboard where it was.</summary>
private void RestoreSelection()
{
if (Model is not { } model) return;
// The rebuild removed the focused row's container; the keyboard goes back to the row with the same key.
var refocus = Tree.IsKeyboardFocusWithin || Keyboard.FocusedElement is null ? _focusKey : null;
_restoring = true;
try
{
Tree.SelectedItems.Clear();
foreach (var row in model.TreeRows.Where(model.IsSelectedRow)) Tree.SelectedItems.Add(row);
}
finally
{
_restoring = false;
}
if (refocus is null || model.TreeRows.FirstOrDefault(r => r.Node.Key == refocus) is not { } again) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () =>
{
Tree.ScrollIntoView(again);
(Tree.ItemContainerGenerator.ContainerFromItem(again) as ListBoxItem)?.Focus();
});
}
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;
if (!Toggles(e.Key, Tree.FlowDirection, row.IsExpanded)) return;
model.Toggle(row);
e.Handled = true;
}
/// <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 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();
});
}
}
File diff suppressed because it is too large. Load diff
+723
View File
@@ -0,0 +1,723 @@
<UserControl x:Class="Chronos.App.Sections.ImportView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:imp="clr-namespace:Chronos.App.Import"
xmlns:shell="clr-namespace:Chronos.App.Shell">
<UserControl.InputBindings>
<KeyBinding Key="Enter" Modifiers="Control" Command="{Binding StartCommand}" />
</UserControl.InputBindings>
<UserControl.Resources>
<!-- Keyboard focus drawn inside the element: an outer ring would be clipped by the scroll viewer around lists. -->
<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>
<!-- Devices list entry (Import.html): 54 px, Surface fill, Stroke border; selected = accent border; disabled while copying. -->
<Style x:Key="ListBoxItem.Device" TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="Height" Value="54" />
<Setter Property="Margin" Value="0,0,0,8" />
<Setter Property="Padding" Value="12,0" />
<Setter Property="Background" Value="{DynamicResource Brush.Surface}" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="ToolTip" Value="{Binding ToolTip}" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding ToolTip}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Bd" Background="{DynamicResource Brush.Surface}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Stroke}"
CornerRadius="{StaticResource Radius.Control}" Padding="{TemplateBinding Padding}">
<ContentPresenter VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.Card}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.Card}" />
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="ToolTip" Value="{l:Loc Import.Blocked.Copying}" />
</Trigger>
</Style.Triggers>
</Style>
<!-- One form line: a label column at least 116 px wide, as wide as the longest label of the form, then the controls (Import.html grid). -->
<Style x:Key="Import.Row" TargetType="HeaderedContentControl">
<Setter Property="Focusable" Value="False" />
<Setter Property="Margin" Value="0,0,0,10" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="HeaderedContentControl">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="116" SharedSizeGroup="ImportLabel" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{TemplateBinding Header}" Style="{StaticResource Text.Label}" TextTrimming="None" VerticalAlignment="Top" Margin="0,6,12,0" />
<ContentPresenter Grid.Column="1" VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Import.Choice" TargetType="FrameworkElement">
<Setter Property="Margin" Value="0,4,18,4" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style TargetType="RadioButton" BasedOn="{StaticResource {x:Type RadioButton}}">
<Setter Property="Margin" Value="0,4,18,4" />
</Style>
<Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
<Setter Property="Margin" Value="0,4,18,4" />
</Style>
<!-- Unit words beside a field ("gap … min"): dimmed with the field they belong to. -->
<Style x:Key="Text.Unit" TargetType="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" />
</Trigger>
</Style.Triggers>
</Style>
<!-- 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" />
<Setter Property="Padding" Value="4,0" />
<Setter Property="Margin" Value="6,0" />
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style>
<!-- File paths and name templates stay left to right in every language (BRIEF §16). -->
<Style x:Key="TextBox.NameTemplate" TargetType="TextBox" BasedOn="{StaticResource TextBox.Mono}">
<Setter Property="Height" Value="30" />
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style>
<!-- The folder path is in use only with the Folder destination (Import.html: faint text otherwise). -->
<Style x:Key="TextBox.FolderPath" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="Width" Value="190" />
<Setter Property="Height" Value="30" />
<Setter Property="FlowDirection" Value="LeftToRight" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsFolderDestination}" Value="False">
<Setter Property="Foreground" Value="{DynamicResource Brush.TextFaint}" />
</DataTrigger>
</Style.Triggers>
</Style>
<!-- A path or file name in a cell: left to right, at the start of the cell in either direction. -->
<Style x:Key="Text.CellPath" TargetType="TextBlock" BasedOn="{StaticResource Text.Cell}">
<Setter Property="FlowDirection" Value="LeftToRight" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<!-- Sizes carry the language's unit ("18,6 كيلوبايت"): they read in its direction, at the end of the cell like their header. -->
<Style x:Key="Text.HeaderEnd" TargetType="TextBlock" BasedOn="{StaticResource Text.Header}">
<Setter Property="TextAlignment" Value="Right" />
</Style>
<!-- Row actions (DESIGN §4 tables): revealed on the row it acts on, still in the tab order. -->
<Style x:Key="Button.RowAction" TargetType="Button" BasedOn="{StaticResource Button.Row}">
<Setter Property="Opacity" Value="0" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
<Setter Property="Opacity" Value="1" />
</DataTrigger>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
<Setter Property="Opacity" Value="1" />
</DataTrigger>
<DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
<Setter Property="Opacity" Value="1" />
</DataTrigger>
</Style.Triggers>
</Style>
<!-- Session table rows (36 px). -->
<Style x:Key="Session.Grid" TargetType="Grid">
<Setter Property="Height" Value="36" />
</Style>
<Style x:Key="ListBoxItem.Session" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Row.TimeText}" />
</Style>
<!-- Show plan and failure rows: focusable, so the arrow keys move through a long list. -->
<Style x:Key="ListBoxItem.PlanRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Padding" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Source}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Destination}" />
</Style>
<Style x:Key="ListBoxItem.Failure" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Padding" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="AutomationProperties.Name" Value="{Binding}" />
</Style>
<!-- "Folder…" (Import.html): transparent, 1 px dashed Stroke border. -->
<Style x:Key="Button.Dashed" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Rectangle x:Name="Edge" Fill="Transparent" Stroke="{DynamicResource Brush.Stroke}" StrokeThickness="1" StrokeDashArray="4 3" RadiusX="6" RadiusY="6" />
<ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="Center" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Edge" Property="Fill" Value="{DynamicResource Brush.Card}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid Margin="20,16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.36*" MinWidth="220" MaxWidth="300" />
<ColumnDefinition Width="16" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- ===================== Devices (declared top to bottom: the tab order follows) ===================== -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<DockPanel Height="32" Margin="0,0,0,8">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Icon}" ui:ButtonIcon.Glyph="{StaticResource Icon.Refresh}" Command="{Binding RefreshCommand}"
ToolTip="{l:Loc Tooltips.Import.Refresh}" AutomationProperties.Name="{l:Loc Import.Devices.Refresh}" />
<TextBlock Text="{l:Loc Import.Devices.Title}" Style="{StaticResource Text.Section}" VerticalAlignment="Center" />
</DockPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" Focusable="False" IsEnabled="{Binding CanChangeSource}">
<StackPanel>
<ListBox ItemsSource="{Binding Sources}" SelectedItem="{Binding SelectedSource}" ItemContainerStyle="{StaticResource ListBoxItem.Device}"
AutomationProperties.Name="{l:Loc Import.Devices.Title}">
<!-- The surrounding ScrollViewer scrolls the list and "Folder…" together (Import.html: Folder… follows the cards). -->
<ListBox.Template>
<ControlTemplate TargetType="ListBox">
<ItemsPresenter />
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type imp:ImportSource}">
<Grid x:Name="Root">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:Icon x:Name="Glyph" Glyph="{StaticResource Icon.Card}" Size="18" Margin="0,0,10,0" VerticalAlignment="Center" />
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="{Binding Title}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" />
<TextBlock Text="{Binding Subtitle}" Style="{StaticResource Text.Secondary}" TextTrimming="CharacterEllipsis" Margin="0,2,0,0" />
</StackPanel>
<ui:StatusGlyph x:Name="State" Grid.Column="2" Kind="Online" Margin="8,0,0,0" VerticalAlignment="Center" />
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Kind}" Value="Drive">
<Setter TargetName="Glyph" Property="Glyph" Value="{StaticResource Icon.Drive}" />
<Setter TargetName="State" Property="Kind" Value="Offline" />
<Setter TargetName="Root" Property="TextElement.Foreground" Value="{DynamicResource Brush.TextMuted}" />
</DataTrigger>
<DataTrigger Binding="{Binding Kind}" Value="Folder">
<Setter TargetName="Glyph" Property="Glyph" Value="{StaticResource Icon.Folder}" />
<Setter TargetName="State" Property="Visibility" Value="Collapsed" />
</DataTrigger>
<DataTrigger Binding="{Binding IsKnown}" Value="False">
<Setter TargetName="State" Property="Kind" Value="Offline" />
</DataTrigger>
<DataTrigger Binding="{Binding IsInserted}" Value="False">
<Setter TargetName="Root" Property="Opacity" Value="0.6" />
<Setter TargetName="State" Property="Kind" Value="Offline" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button x:Name="FolderSourceButton" Style="{StaticResource Button.Dashed}" Height="44" HorizontalContentAlignment="Left" Command="{Binding PickFolderCommand}"
ToolTip="{Binding FolderSourceToolTip}" AutomationProperties.Name="{l:Loc Import.Devices.Folder}">
<StackPanel Orientation="Horizontal">
<ui:Icon Glyph="{StaticResource Icon.Folder}" Margin="0,0,10,0" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock Text="{l:Loc Import.Devices.Folder}" Foreground="{DynamicResource Brush.TextMuted}" />
</StackPanel>
</Button>
</StackPanel>
</ScrollViewer>
<CheckBox Grid.Row="2" Margin="0,8,0,0" IsChecked="{Binding AutoImport}" IsEnabled="{Binding CanAutoImport}" ToolTip="{Binding AutoImportToolTip}"
VerticalContentAlignment="Top" AutomationProperties.Name="{l:Loc Import.Devices.Auto}">
<TextBlock Text="{l:Loc Import.Devices.Auto}" TextWrapping="Wrap" Foreground="{DynamicResource Brush.TextMuted}" />
</CheckBox>
</Grid>
<!-- ===================== Profile, form and plan ===================== -->
<Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="20,16">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Profile header: nickname (or its field for a new card), identity, Edit ▾ (declared in reading order for Tab). -->
<Grid Margin="0,0,0,14" MinHeight="32">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding SourceTitle}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" MaxWidth="320" TextTrimming="CharacterEllipsis"
Visibility="{Binding IsNicknameOpen, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<TextBox x:Name="NicknameBox" Width="240" Text="{Binding Nickname.Text, UpdateSourceTrigger=PropertyChanged}" shell:EditBehavior.Field="{Binding Nickname}"
ui:Field.Placeholder="{l:Loc Import.Profile.Nickname}" ToolTip="{Binding Nickname.ToolTip}" AutomationProperties.Name="{l:Loc Import.Profile.Nickname}"
Visibility="{Binding IsNicknameOpen, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Grid.Column="1" Text="{Binding IdentityText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Margin="12,0,12,0"
TextTrimming="CharacterEllipsis" ToolTip="{Binding IdentityText}" />
<Button x:Name="EditButton" Grid.Column="2" Click="OnOpenMenu" IsEnabled="{Binding CanEditProfile}" ToolTip="{Binding EditToolTip}"
AutomationProperties.Name="{l:Loc Import.Profile.Edit}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Import.Profile.Edit}" VerticalAlignment="Center" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="{l:Loc Import.Profile.Rename}" Command="{Binding RenameCommand}" ToolTip="{l:Loc Tooltips.Import.Rename}" />
<MenuItem Header="{l:Loc Import.Profile.Camera}" Command="{Binding FollowCameraCommand}" IsCheckable="False" IsChecked="{Binding FollowsCamera, Mode=OneWay}"
ToolTip="{Binding FollowCameraToolTip}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Import.Profile.CopyFrom}" ItemsSource="{Binding OtherCards}" ToolTip="{l:Loc Tooltips.Import.CopyFrom}">
<MenuItem.ItemContainerStyle>
<Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header" Value="{Binding Name}" />
<Setter Property="Command" Value="{Binding Command}" />
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Import.CopyFrom}" />
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
<Separator />
<MenuItem Header="{l:Loc Import.Profile.Forget}" Command="{Binding ForgetCommand}" ToolTip="{l:Loc Tooltips.Import.Forget}" />
</ContextMenu>
</Button.ContextMenu>
</Button>
</Grid>
<!-- The form (Import.html grid). -->
<StackPanel Grid.Row="1" IsEnabled="{Binding IsFormEnabled}" Grid.IsSharedSizeScope="True">
<HeaderedContentControl Style="{StaticResource Import.Row}" Header="{l:Loc Import.Label.Destination}">
<WrapPanel>
<RadioButton Content="{l:Loc Import.Destination.Archive}" IsChecked="{Binding IsArchiveDestination}"
IsEnabled="{Binding CanUseArchive}" ToolTip="{Binding ArchiveToolTip}" />
<RadioButton Content="{l:Loc Import.Destination.Folder}" IsChecked="{Binding IsFolderDestination}"
ToolTip="{l:Loc Tooltips.Import.FolderDestination}" Margin="0,4,8,4" />
<TextBox x:Name="FolderPathBox" Style="{StaticResource TextBox.FolderPath}"
Text="{Binding FolderPath.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding FolderPath}"
ToolTip="{Binding FolderPath.ToolTip}" AutomationProperties.Name="{l:Loc Import.Destination.FolderPlaceholder}"
ui:Field.Placeholder="{l:Loc Import.Destination.FolderPlaceholder}" />
<Button Style="{StaticResource Button.Icon}" Width="30" MinWidth="30" Height="30" Margin="6,0,18,0" Content="…" Command="{Binding ChooseDestinationCommand}"
ToolTip="{l:Loc Tooltips.Import.ChooseFolder}" AutomationProperties.Name="{l:Loc Import.Destination.Choose}" />
<RadioButton IsChecked="{Binding IsServerDestination}" IsEnabled="{Binding CanUseServer}" ToolTip="{Binding ServerToolTip}"
AutomationProperties.Name="{Binding ServerChoiceName}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Import.Destination.Server}" />
<ui:Icon Glyph="{StaticResource Icon.Server}" Margin="10,0,6,0" Foreground="{DynamicResource Brush.Accent}" />
<TextBlock Text="{Binding ServerName}" Foreground="{DynamicResource Brush.Accent}" />
</StackPanel>
</RadioButton>
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Import.Row}" Header="{l:Loc Import.Label.Scan}">
<WrapPanel>
<CheckBox Content="{l:Loc Import.Scan.Subfolders}" IsChecked="{Binding IncludeSubfolders}" ToolTip="{l:Loc Tooltips.Import.Subfolders}" />
<CheckBox Content="{l:Loc Import.Scan.Sessions}" IsChecked="{Binding SplitSessions}" ToolTip="{l:Loc Tooltips.Import.Sessions}" />
<StackPanel Orientation="Horizontal" Style="{StaticResource Import.Choice}" IsEnabled="{Binding SplitSessions}">
<TextBlock Text="{l:Loc Import.Scan.Gap}" Style="{StaticResource Text.Unit}" />
<TextBox x:Name="GapBox" Style="{StaticResource TextBox.Small}" Text="{Binding GapMinutes.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding GapMinutes}" ToolTip="{Binding GapMinutes.ToolTip}" AutomationProperties.Name="{l:Loc Import.Scan.GapName}" />
<TextBlock Text="{l:Loc Import.Scan.Minutes}" Style="{StaticResource Text.Unit}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Style="{StaticResource Import.Choice}">
<TextBlock Text="{l:Loc Import.Scan.Minimum}" Style="{StaticResource Text.Unit}" />
<TextBox Style="{StaticResource TextBox.Small}" Text="{Binding MinimumFrames.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding MinimumFrames}" ToolTip="{Binding MinimumFrames.ToolTip}" AutomationProperties.Name="{l:Loc Import.Scan.MinimumName}" />
<TextBlock Text="{l:Loc Import.Scan.Frames}" Style="{StaticResource Text.Unit}" />
</StackPanel>
<CheckBox Content="{l:Loc Import.Scan.Verify}" IsChecked="{Binding VerifyCopies}" ToolTip="{l:Loc Tooltips.Import.Verify}" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Import.Row}" Header="{l:Loc Import.Label.Names}">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="140" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" MinWidth="140" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Style="{StaticResource TextBox.NameTemplate}" Text="{Binding FolderTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding FolderTemplate}" ToolTip="{Binding FolderTemplate.ToolTip}" GotKeyboardFocus="OnFolderTemplateFocus"
AutomationProperties.Name="{l:Loc Import.Names.Folder}" />
<TextBlock Grid.Column="1" Text="/" Style="{StaticResource Text.Unit}" Foreground="{DynamicResource Brush.TextFaint}" Margin="10,0" />
<TextBox Grid.Column="2" Style="{StaticResource TextBox.NameTemplate}"
Text="{Binding FileTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding FileTemplate}"
ToolTip="{Binding FileTemplate.ToolTip}" GotKeyboardFocus="OnFileTemplateFocus" AutomationProperties.Name="{l:Loc Import.Names.File}" />
<Button x:Name="TokensButton" Grid.Column="3" Style="{StaticResource Button.Icon}" Width="30" MinWidth="30" Height="30" Margin="10,0,0,0" Content="{}{ }"
Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Import.Tokens}" AutomationProperties.Name="{l:Loc Import.Names.Tokens}">
<Button.ContextMenu>
<ContextMenu ItemsSource="{Binding Tokens}" MaxHeight="420">
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header" Value="{Binding Text}" />
<Setter Property="ToolTip" Value="{Binding ToolTip}" />
<Setter Property="Command" Value="{Binding DataContext.InsertTokenCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}" />
<Setter Property="CommandParameter" Value="{Binding}" />
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
</Button.ContextMenu>
</Button>
</Grid>
<TextBlock Text="{Binding NamePreview}" Style="{StaticResource Text.Secondary}" Foreground="{DynamicResource Brush.TextFaint}" Margin="0,6,0,0"
TextTrimming="CharacterEllipsis" ToolTip="{Binding NamePreview}" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
</StackPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Import.Row}" Header="{l:Loc Import.Label.Duplicates}">
<WrapPanel>
<RadioButton Content="{l:Loc Import.Duplicates.Skip}" IsChecked="{Binding SkipDuplicates}" ToolTip="{l:Loc Tooltips.Import.Skip}" />
<RadioButton Content="{l:Loc Import.Duplicates.Again}" IsChecked="{Binding ImportDuplicatesAgain}" ToolTip="{l:Loc Tooltips.Import.Again}" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Import.Row}" Header="{l:Loc Import.Label.After}" Margin="0">
<WrapPanel>
<RadioButton Content="{l:Loc Import.After.Keep}" IsChecked="{Binding KeepCard}" ToolTip="{l:Loc Tooltips.Import.Keep}" />
<RadioButton Content="{l:Loc Import.After.Delete}" IsChecked="{Binding DeleteImported}" IsEnabled="{Binding CardActionsApply}"
ToolTip="{Binding DeleteChoiceToolTip}" />
<RadioButton Content="{l:Loc Import.After.Format}" IsChecked="{Binding FormatCard}" IsEnabled="{Binding CardActionsApply}"
ToolTip="{Binding FormatChoiceToolTip}" />
<Border Width="1" Height="20" Background="{DynamicResource Brush.Stroke}" Margin="0,0,18,0" VerticalAlignment="Center" />
<CheckBox Content="{l:Loc Import.After.Eject}" IsChecked="{Binding Eject}" ToolTip="{l:Loc Tooltips.Import.EjectChoice}" />
<CheckBox Content="{l:Loc Import.After.Deep}" IsChecked="{Binding DeepAnalysis}" IsEnabled="{Binding IsArchiveDestination}" ToolTip="{Binding DeepToolTip}" />
</WrapPanel>
</HeaderedContentControl>
</StackPanel>
<!-- ===================== Plan panel ===================== -->
<Border Grid.Row="2" Style="{StaticResource Border.Card}" Padding="16,14" Margin="0,14,0,0" IsEnabled="{Binding IsPlanPanelEnabled}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<DockPanel Margin="0,0,0,10">
<TextBlock DockPanel.Dock="Left" Text="{l:Loc Import.Plan.Title}" Style="{StaticResource Text.Section}" VerticalAlignment="Center" />
<TextBlock DockPanel.Dock="Right" Text="{Binding SpaceText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="12,0,0,0" VerticalAlignment="Center"
ToolTip="{l:Loc Tooltips.Import.Space}" Visibility="{Binding IsSpaceShort, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<ui:StatusGlyph DockPanel.Dock="Right" Kind="Warning" Text="{Binding SpaceText}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center"
ToolTip="{l:Loc Tooltips.Import.Space}" Visibility="{Binding IsSpaceShort, Converter={StaticResource BoolToVisibility}}" />
<TextBlock DockPanel.Dock="Right" Text="{Binding ImportedBeforeText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="12,0,0,0" VerticalAlignment="Center"
ToolTip="{l:Loc Tooltips.Import.ImportedBefore}" />
<ui:StatusGlyph DockPanel.Dock="Right" Kind="{Binding DuplicatesKind}" Text="{Binding DuplicatesText}" FontSize="13" Margin="12,0,0,0" VerticalAlignment="Center"
ToolTip="{l:Loc Tooltips.Import.Duplicates}" Visibility="{Binding HasPlan, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{Binding TotalsText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="12,0,0,0" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" TextTrimming="CharacterEllipsis" ToolTip="{Binding TotalsText}" />
</DockPanel>
<!-- No source, reading the card, or the reason no plan can be made: one sentence and one action. -->
<StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" MaxWidth="420"
Visibility="{Binding ShowsStatus, Converter={StaticResource BoolToVisibility}}">
<TextBlock x:Name="StatusLine" Text="{Binding StatusText, NotifyOnTargetUpdated=True}" ToolTip="{Binding StatusDetail}" Foreground="{DynamicResource Brush.TextMuted}"
TextAlignment="Center" TextWrapping="Wrap" AutomationProperties.LiveSetting="Polite" />
<ProgressBar IsIndeterminate="{Binding IsBusyPlanning}" Width="240" Margin="0,12,0,0" AutomationProperties.LabeledBy="{Binding ElementName=StatusLine}"
Visibility="{Binding IsBusyPlanning, Converter={StaticResource BoolToVisibility}}" />
<Button x:Name="StatusActionButton" Content="{Binding StatusActionText}" Command="{Binding StatusActionCommand}" ToolTip="{Binding StatusActionToolTip}"
HorizontalAlignment="Center" Margin="0,12,0,0" Visibility="{Binding HasStatusAction, Converter={StaticResource BoolToVisibility}}" />
</StackPanel>
<!-- Sessions of the plan with editable titles. -->
<Grid Grid.Row="1" Visibility="{Binding HasPlan, Converter={StaticResource BoolToVisibility}}" Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- The right margin is the list's scroll bar (always shown, 10 px), so header and cells line up. -->
<Grid TextElement.FontSize="12" Margin="0,0,10,4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="110" SharedSizeGroup="SessionTime" />
<ColumnDefinition Width="0.85*" MinWidth="70" />
<ColumnDefinition Width="Auto" MinWidth="56" SharedSizeGroup="SessionSize" />
<ColumnDefinition Width="0.9*" MinWidth="48" />
<ColumnDefinition Width="1.6*" MinWidth="140" />
<ColumnDefinition Width="Auto" SharedSizeGroup="SessionAction" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Session}" ToolTip="{l:Loc Import.Session.Column.Session}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Frames}" Margin="10,0,0,0" ToolTip="{l:Loc Import.Session.Column.Frames}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.HeaderEnd}" Text="{l:Loc Import.Session.Column.Size}" Margin="10,0,0,0" ToolTip="{l:Loc Import.Session.Column.Size}" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Camera}" Margin="10,0,0,0" ToolTip="{l:Loc Import.Session.Column.Camera}" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Sequence}" Margin="10,0,0,0" ToolTip="{l:Loc Import.Session.Column.Sequence}" />
</Grid>
<ListBox x:Name="SessionRows" Grid.Row="1" ItemsSource="{Binding Sessions}" ItemContainerStyle="{StaticResource ListBoxItem.Session}"
AutomationProperties.Name="{l:Loc Import.Plan.Title}" KeyboardNavigation.TabNavigation="Continue" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type imp:ImportSessionRowViewModel}">
<Grid Style="{StaticResource Session.Grid}" TextElement.FontSize="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="110" SharedSizeGroup="SessionTime" />
<ColumnDefinition Width="0.85*" MinWidth="70" />
<ColumnDefinition Width="Auto" MinWidth="56" SharedSizeGroup="SessionSize" />
<ColumnDefinition Width="0.9*" MinWidth="48" />
<ColumnDefinition Width="1.6*" MinWidth="140" />
<ColumnDefinition Width="Auto" SharedSizeGroup="SessionAction" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Row.TimeText}" ToolTip="{Binding Row.TimeText}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Row.FramesText}" Margin="10,0,0,0" ToolTip="{Binding Row.FramesText}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.CellNumber}" Text="{Binding Row.SizeText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Cell}" Text="{Binding Row.CameraText}" Margin="10,0,0,0" ToolTip="{Binding Row.CameraText}" />
<DockPanel Grid.Column="4" Margin="10,0,0,0">
<TextBlock x:Name="Target" DockPanel.Dock="Right" Text="{l:Loc Import.Session.NewShort}" Foreground="{DynamicResource Brush.Accent}"
VerticalAlignment="Center" Margin="8,0,0,0" ToolTip="{Binding Row.TargetText}" />
<TextBox Height="26" Padding="8,0" Text="{Binding Title.Text, UpdateSourceTrigger=PropertyChanged}" shell:EditBehavior.Field="{Binding Title}"
IsEnabled="{Binding IsEditable}" ui:Field.Placeholder="{Binding Placeholder}" ToolTip="{Binding TitleToolTip}" ToolTipService.ShowOnDisabled="True"
AutomationProperties.Name="{Binding TitleName}" />
</DockPanel>
<Button x:Name="Merge" Grid.Column="5" Style="{StaticResource Button.RowAction}" Margin="8,0,0,0" Content="{l:Loc Import.Session.Merge}"
Command="{Binding MergeCommand}" ToolTip="{Binding MergeToolTip}" AutomationProperties.Name="{Binding MergeName}"
AutomationProperties.HelpText="{Binding MergeToolTip}" Visibility="{Binding HasMerge, Converter={StaticResource BoolToVisibility}}" />
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Row.IsNew}" Value="False">
<Setter TargetName="Target" Property="Text" Value="{l:Loc Import.Session.AddsShort}" />
<Setter TargetName="Target" Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
</DataTrigger>
<!-- While copying the plan is fixed: no row action to reveal. -->
<DataTrigger Binding="{Binding IsEditable}" Value="False">
<Setter TargetName="Merge" Property="Visibility" Value="Hidden" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<!-- The verification result and the after-import actions. -->
<Grid Grid.Row="1" Grid.RowSpan="2" DataContext="{Binding Result}" Visibility="{Binding DataContext.IsDone, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource BoolToVisibility}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- The glyph colours the result; the text beside it is what screen readers announce. The figures move under it when the card is too
narrow for both (Romanian at 1200 px). -->
<WrapPanel>
<ui:StatusGlyph x:Name="ResultGlyph" Kind="{Binding ResultKind}" VerticalAlignment="Center" />
<TextBlock Text="{Binding ResultText, NotifyOnTargetUpdated=True}" Foreground="{Binding Foreground, ElementName=ResultGlyph}" FontSize="16" FontWeight="SemiBold"
VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Import.Result}" AutomationProperties.LiveSetting="Polite" />
<TextBlock Text="{Binding DetailText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="14,0,0,0" VerticalAlignment="Center" />
</WrapPanel>
<ListBox Grid.Row="1" ItemsSource="{Binding Failures}" Margin="0,8,0,0" ItemContainerStyle="{StaticResource ListBoxItem.Failure}"
Visibility="{Binding HasFailures, Converter={StaticResource BoolToVisibility}}" AutomationProperties.Name="{l:Loc Import.Result.FailuresName}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Style="{StaticResource Text.Cell}" Foreground="{DynamicResource Brush.Error}" Height="28" Padding="0,6,0,0" ToolTip="{Binding}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="2" Margin="0,10,0,0" Visibility="{Binding OffersCheck, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding EraseText}" Typography.NumeralAlignment="Tabular" />
<TextBlock Text="{Binding BusyText, NotifyOnTargetUpdated=True}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,4,0,0"
AutomationProperties.LiveSetting="Polite" Visibility="{Binding BusyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<ItemsControl ItemsSource="{Binding KeptReasons}" Focusable="False" MaxHeight="80" Margin="0,4,0,0">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ui:StatusGlyph Kind="Warning" Text="{Binding}" FontSize="12" ToolTip="{l:Loc Tooltips.Import.Kept}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
<WrapPanel Grid.Row="3" Margin="0,12,0,0">
<Button Content="{l:Loc Import.Result.Check}" Command="{Binding CheckCommand}" ToolTip="{Binding CheckToolTip}" Margin="0,0,8,0"
Visibility="{Binding OffersCheck, Converter={StaticResource BoolToVisibility}}" />
<Button Style="{StaticResource Button.Destructive}" Content="{Binding DeleteText}" Command="{Binding DeleteCommand}" ToolTip="{Binding DeleteToolTip}"
Margin="0,0,8,0" Visibility="{Binding OffersDelete, Converter={StaticResource BoolToVisibility}}" />
<Button Style="{StaticResource Button.Destructive}" Content="{l:Loc Import.Result.Format}" Command="{Binding FormatCommand}" ToolTip="{Binding FormatToolTip}"
Margin="0,0,8,0" Visibility="{Binding OffersFormat, Converter={StaticResource BoolToVisibility}}" />
<Button Command="{Binding EjectCommand}" ToolTip="{Binding EjectToolTip}" Margin="0,0,8,0" AutomationProperties.Name="{l:Loc Import.Result.Eject}">
<StackPanel Orientation="Horizontal">
<ui:Icon Glyph="{StaticResource Icon.Eject}" Margin="0,0,6,0" />
<TextBlock Text="{l:Loc Import.Result.Eject}" />
</StackPanel>
</Button>
<Button Content="{l:Loc Import.Result.Library}" Command="{Binding OpenLibraryCommand}" ToolTip="{l:Loc Tooltips.Import.Library}" Margin="0,0,8,0" />
<Button x:Name="NewImportButton" Content="{l:Loc Import.Result.New}" Command="{Binding DataContext.NewImportCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
ToolTip="{l:Loc Tooltips.Import.New}" />
</WrapPanel>
</Grid>
<!-- The import failed or was cancelled: what happened in one sentence (its full text in the tooltip), and Retry. -->
<StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" MaxWidth="520" Visibility="{Binding IsFailed, Converter={StaticResource BoolToVisibility}}">
<DockPanel>
<ui:Icon DockPanel.Dock="Left" Glyph="{StaticResource Icon.Cross}" Size="12" Foreground="{DynamicResource Brush.Error}" VerticalAlignment="Top" Margin="0,3,6,0" />
<TextBlock x:Name="FailureLine" Text="{Binding ErrorText, NotifyOnTargetUpdated=True}" Foreground="{DynamicResource Brush.Error}" TextWrapping="Wrap"
TextTrimming="CharacterEllipsis" LineHeight="18" LineStackingStrategy="BlockLineHeight" MaxHeight="54" ToolTip="{Binding FailureToolTip}"
AutomationProperties.LiveSetting="Assertive" />
</DockPanel>
<Button x:Name="RetryButton" Content="{l:Loc Import.Failed.Retry}" Command="{Binding RetryCommand}" ToolTip="{l:Loc Tooltips.Import.Retry}"
HorizontalAlignment="Center" Margin="0,12,0,0" />
</StackPanel>
<!-- Footer: Show plan and Import, or the progress while copying. -->
<DockPanel Grid.Row="2" Margin="0,10,0,0" Visibility="{Binding HasPlan, Converter={StaticResource BoolToVisibility}}">
<Button x:Name="ShowPlanButton" DockPanel.Dock="Left" Content="{l:Loc Import.Plan.Show}" Command="{Binding ShowPlanCommand}" ToolTip="{l:Loc Tooltips.Import.ShowPlan}"
Visibility="{Binding IsRunning, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Height="36" Padding="22,0" Content="{Binding StartText}" Command="{Binding StartCommand}"
ToolTip="{Binding StartToolTip}" Visibility="{Binding IsRunning, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button x:Name="CancelButton" DockPanel.Dock="Right" Content="{l:Loc Import.Progress.Cancel}" Command="{Binding CancelCommand}" ToolTip="{l:Loc Tooltips.Import.Cancel}" Margin="12,0,0,0"
Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibility}}" />
<Grid Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibility}}" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ProgressBar Maximum="1" Value="{Binding Progress, Mode=OneWay}" VerticalAlignment="Center" AutomationProperties.LabeledBy="{Binding ElementName=ProgressLine}" />
<TextBlock x:Name="ProgressLine" Grid.Column="1" Text="{Binding ProgressText, NotifyOnTargetUpdated=True}" Foreground="{DynamicResource Brush.TextMuted}" Margin="12,0,0,0"
Typography.NumeralAlignment="Tabular" AutomationProperties.LiveSetting="Polite" />
</Grid>
</DockPanel>
</Grid>
</Border>
<!-- ===================== Show plan ===================== -->
<Border Grid.RowSpan="3" Style="{StaticResource Border.Panel}" Background="{DynamicResource Brush.Surface}" Padding="0" Margin="-8"
Visibility="{Binding IsDetailsOpen, Converter={StaticResource BoolToVisibility}}" KeyboardNavigation.TabNavigation="Cycle"
KeyboardNavigation.ControlTabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Contained">
<Border.InputBindings>
<KeyBinding Key="Escape" Command="{Binding CloseDetailsCommand}" />
</Border.InputBindings>
<Grid DataContext="{Binding Details}" Margin="16,12" Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<DockPanel>
<Button x:Name="ClosePlanButton" DockPanel.Dock="Right" Style="{StaticResource Button.IconSubtle}" ui:ButtonIcon.Glyph="{StaticResource Icon.Close}"
Command="{Binding DataContext.CloseDetailsCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" ToolTip="{l:Loc Tooltips.Import.ClosePlan}"
AutomationProperties.Name="{l:Loc Import.Details.Close}" />
<TextBlock Text="{l:Loc Import.Details.Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" />
<TextBlock Text="{Binding TotalsText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="14,0,0,0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"
Typography.NumeralAlignment="Tabular" ToolTip="{Binding TotalsText}" />
</DockPanel>
<ItemsControl Grid.Row="1" ItemsSource="{Binding Conflicts}" Focusable="False" Margin="0,8,0,0" MaxHeight="96">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ui:StatusGlyph Kind="Warning" Text="{Binding}" FontSize="12" Margin="0,2" ToolTip="{l:Loc Tooltips.Import.Conflict}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!-- The right margin is the list's scroll bar (always shown, 10 px), so header and cells line up. -->
<Grid Grid.Row="2" Margin="0,10,10,4" TextElement.FontSize="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" MinWidth="120" />
<ColumnDefinition Width="1.8*" MinWidth="180" />
<ColumnDefinition Width="*" MinWidth="110" />
<ColumnDefinition Width="Auto" MinWidth="64" SharedSizeGroup="PlanSize" />
<ColumnDefinition Width="Auto" SharedSizeGroup="PlanAction" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Import.Details.Column.Source}" ToolTip="{l:Loc Import.Details.Column.Source}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Details.Column.Destination}" Margin="10,0,0,0" ToolTip="{l:Loc Import.Details.Column.Destination}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Details.Column.Action}" Margin="10,0,0,0" ToolTip="{l:Loc Import.Details.Column.Action}" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.HeaderEnd}" Text="{l:Loc Import.Session.Column.Size}" Margin="10,0,0,0" ToolTip="{l:Loc Import.Session.Column.Size}" />
</Grid>
<ListBox x:Name="PlanRows" Grid.Row="3" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.PlanRow}" AutomationProperties.Name="{l:Loc Import.Details.Title}"
KeyboardNavigation.TabNavigation="Continue" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.ItemTemplate>
<!-- A file: its name on the card, its new name, what happens, its size. A session: its heading over two columns, its folder below. -->
<DataTemplate DataType="{x:Type imp:PlanDetailRow}">
<Grid x:Name="Row" Height="36" TextElement.FontSize="12">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" MinWidth="120" />
<ColumnDefinition Width="1.8*" MinWidth="180" />
<ColumnDefinition Width="*" MinWidth="110" />
<ColumnDefinition Width="Auto" MinWidth="64" SharedSizeGroup="PlanSize" />
<ColumnDefinition Width="Auto" SharedSizeGroup="PlanAction" />
</Grid.ColumnDefinitions>
<TextBlock x:Name="Source" Style="{StaticResource Text.Cell}" Text="{Binding SourceText}" ToolTip="{Binding Source}" />
<TextBlock x:Name="Destination" Grid.Column="1" Style="{StaticResource Text.CellPath}" Text="{Binding DestinationText}" Margin="10,0,0,0"
ToolTip="{Binding Destination}" />
<TextBlock x:Name="Action" Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding ActionText}" Margin="10,0,0,0" ToolTip="{Binding ActionText}" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.CellNumber}" Text="{Binding SizeText}" Margin="10,0,0,0" />
<Button x:Name="Split" Grid.Column="4" Style="{StaticResource Button.RowAction}" Margin="10,0,4,0" Content="{l:Loc Import.Details.Split}"
Command="{Binding DataContext.SplitCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Import.Split}" AutomationProperties.Name="{Binding SplitName}" Visibility="Hidden" />
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding CanSplit}" Value="True">
<Setter TargetName="Split" Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding Kind}" Value="File">
<Setter TargetName="Source" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="Source" Property="HorizontalAlignment" Value="Left" />
</DataTrigger>
<DataTrigger Binding="{Binding Kind}" Value="Session">
<Setter TargetName="Row" Property="Height" Value="50" />
<Setter TargetName="Source" Property="FontWeight" Value="SemiBold" />
<Setter TargetName="Source" Property="Grid.ColumnSpan" Value="2" />
<Setter TargetName="Destination" Property="Grid.Row" Value="1" />
<Setter TargetName="Destination" Property="Grid.Column" Value="0" />
<Setter TargetName="Destination" Property="Grid.ColumnSpan" Value="4" />
<Setter TargetName="Destination" Property="Margin" Value="0,2,0,8" />
<Setter TargetName="Destination" Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
</DataTrigger>
<DataTrigger Binding="{Binding IsSkipped}" Value="True">
<Setter TargetName="Row" Property="Opacity" Value="0.6" />
<Setter TargetName="Action" Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
</Grid>
</Border>
</Grid>
</UserControl>
+127
View File
@@ -0,0 +1,127 @@
using System.ComponentModel;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Threading;
namespace Chronos.App.Sections;
public partial class ImportView : UserControl
{
/// <summary>A polite text that keeps changing (copy progress) is announced at most this often.</summary>
private static readonly TimeSpan PoliteInterval = TimeSpan.FromSeconds(3);
private readonly Dictionary<UIElement, DateTime> _announced = [];
private readonly HashSet<UIElement> _pending = [];
private bool _nicknameOpen;
private bool _restoreFocus;
public ImportView()
{
InitializeComponent();
DataContextChanged += OnDataContextChanged;
AddHandler(Binding.TargetUpdatedEvent, new EventHandler<DataTransferEventArgs>(OnTargetUpdated));
}
private ImportViewModel? Model => DataContext as ImportViewModel;
/// <summary>"Edit ▾" and "{ }" open their menu under themselves.</summary>
private void OnOpenMenu(object sender, RoutedEventArgs e)
{
if (sender is not Button { ContextMenu: { } menu } button) return;
menu.DataContext = DataContext;
menu.PlacementTarget = button;
menu.Placement = PlacementMode.Bottom;
menu.IsOpen = true;
}
/// <summary>The "{ }" menu writes into the template field used last.</summary>
private void OnFolderTemplateFocus(object sender, KeyboardFocusChangedEventArgs e) => Model?.SetActiveTemplate(folder: true);
private void OnFileTemplateFocus(object sender, KeyboardFocusChangedEventArgs e) => Model?.SetActiveTemplate(folder: false);
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.OldValue is INotifyPropertyChanged old) old.PropertyChanged -= OnModelChanged;
if (e.NewValue is INotifyPropertyChanged model) model.PropertyChanged += OnModelChanged;
}
/// <summary>
/// Keyboard focus follows what opens: the nickname field when it appears (a new card, Rename), and "Show plan"
/// (focus returns to its button when it closes). A change of phase that hides the focused button (Import, Retry,
/// New import, the status action, "Split here" closing the plan) moves focus to what replaced it, once the card
/// is planned again.
/// </summary>
private void OnModelChanged(object? sender, PropertyChangedEventArgs e)
{
if (Model is not { } model) return;
if (e.PropertyName is nameof(ImportViewModel.IsNicknameOpen) or "")
{
var opened = model.IsNicknameOpen && !_nicknameOpen;
_nicknameOpen = model.IsNicknameOpen;
if (opened && IsVisible) FocusLater(NicknameBox);
}
if (e.PropertyName is nameof(ImportViewModel.IsDetailsOpen) && IsVisible)
{
if (model.IsDetailsOpen) FocusLater(ClosePlanButton);
else _restoreFocus = true;
}
if (e.PropertyName is nameof(ImportViewModel.IsDetailsOpen) or "" && IsVisible) Dispatcher.BeginInvoke(DispatcherPriority.Input, RestoreFocus);
}
private void RestoreFocus()
{
if (Model is not { } model || model.IsBusyPlanning) return;
var lost = Keyboard.FocusedElement is UIElement { IsVisible: false } focused && IsAncestorOf(focused);
if (!_restoreFocus && !lost) return;
_restoreFocus = false;
UIElement? target = model.IsRunning ? CancelButton
: model.IsDone ? NewImportButton
: model.IsFailed ? RetryButton
: model.HasPlan ? ShowPlanButton
: model.HasStatusAction ? StatusActionButton
: null;
target?.Focus();
}
/// <summary>After layout: an element that just became visible cannot take focus yet.</summary>
private void FocusLater(UIElement element) => Dispatcher.BeginInvoke(DispatcherPriority.Input, () => element.Focus());
/// <summary>
/// Live texts (AutomationProperties.LiveSetting in XAML, their binding with NotifyOnTargetUpdated) tell screen
/// readers that they changed: planning status, copy progress, the result and the failure. WPF raises nothing by itself.
/// </summary>
private void OnTargetUpdated(object? sender, DataTransferEventArgs e)
{
if (e.TargetObject is not UIElement element || AutomationProperties.GetLiveSetting(element) is var setting && setting == AutomationLiveSetting.Off) return;
if (AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged)) Announce(element, setting);
}
/// <summary>Polite texts at most every <see cref="PoliteInterval"/>, ending with their latest value; assertive ones at once.</summary>
private void Announce(UIElement element, AutomationLiveSetting setting)
{
var wait = setting == AutomationLiveSetting.Polite && _announced.TryGetValue(element, out var last) ? last + PoliteInterval - DateTime.UtcNow : TimeSpan.Zero;
if (wait > TimeSpan.Zero)
{
if (_pending.Add(element)) _ = AnnounceLaterAsync(element, setting, wait);
return;
}
_announced[element] = DateTime.UtcNow;
// After the bindings of the same change: a text that is being hidden is not announced.
Dispatcher.BeginInvoke(DispatcherPriority.Background, () =>
{
if (element.IsVisible) UIElementAutomationPeer.CreatePeerForElement(element)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
});
}
private async Task AnnounceLaterAsync(UIElement element, AutomationLiveSetting setting, TimeSpan wait)
{
await Task.Delay(wait);
_pending.Remove(element);
Announce(element, setting);
}
}
File diff suppressed because it is too large. Load diff
+230
View File
@@ -0,0 +1,230 @@
<UserControl x:Class="Chronos.App.Sections.JobsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:s="clr-namespace:Chronos.App.Sections"
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
xmlns:j="clr-namespace:Chronos.App.Jobs">
<UserControl.Resources>
<Style x:Key="Text.Muted" TargetType="TextBlock" BasedOn="{StaticResource Text.Cell}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsDimmed}" Value="True">
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
</DataTrigger>
</Style.Triggers>
</Style>
<!-- Numbers stay right-aligned in both reading directions (DESIGN §4 tables). -->
<Style x:Key="Text.MutedNumber" TargetType="TextBlock" BasedOn="{StaticResource Text.Muted}">
<Setter Property="TextAlignment" Value="Right" />
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style>
<!-- Speeds and times left carry the language's unit ("2 د"): they read in its direction, at the end of the cell like their header. -->
<Style x:Key="Text.MutedEnd" TargetType="TextBlock" BasedOn="{StaticResource Text.Muted}">
<Setter Property="TextAlignment" Value="Right" />
</Style>
<Style x:Key="Text.HeaderEnd" TargetType="TextBlock" BasedOn="{StaticResource Text.Header}">
<Setter Property="TextAlignment" Value="Right" />
</Style>
<Style x:Key="ProgressBar.Job" TargetType="ProgressBar" BasedOn="{StaticResource {x:Type ProgressBar}}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsDone}" Value="True">
<Setter Property="Foreground" Value="{DynamicResource Brush.Success}" />
</DataTrigger>
<DataTrigger Binding="{Binding IsFailed}" Value="True">
<Setter Property="Foreground" Value="{DynamicResource Brush.Error}" />
</DataTrigger>
</Style.Triggers>
</Style>
<ItemsPanelTemplate x:Key="Panel.Row">
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
<ItemsPanelTemplate x:Key="Panel.Wrap">
<WrapPanel />
</ItemsPanelTemplate>
<!-- Filter chip (Jobs.html, aria-pressed): one of a group, so screen readers hear which filter is on. -->
<Style x:Key="RadioButton.Chip" TargetType="RadioButton" BasedOn="{StaticResource Button.Base}">
<Setter Property="Height" Value="30" />
<Setter Property="Padding" Value="12,0" />
<Setter Property="Typography.NumeralAlignment" Value="Tabular" />
<Setter Property="ui:ControlState.CornerRadius" Value="15" />
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}" />
<Setter Property="ui:ControlState.HoverBorderBrush" Value="{DynamicResource Brush.Accent}" />
</Trigger>
</Style.Triggers>
</Style>
<!-- A row reads as its job and state; Tab goes to its buttons. -->
<Style x:Key="ListBoxItem.Job" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding AccessibleName}" />
<Setter Property="AutomationProperties.ItemStatus" Value="{Binding StateText}" />
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Toolbar in visual (and Tab) order: state chips · search, then workers, Pause all, Clear done. The search moves under
the chips before anything is cut (+40 % text at 1200 px). -->
<Grid Margin="20,12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<WrapPanel VerticalAlignment="Center">
<ItemsControl ItemsSource="{Binding Chips}" ItemsPanel="{StaticResource Panel.Wrap}" Focusable="False" VerticalAlignment="Center">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type s:JobFilterChip}">
<RadioButton Style="{StaticResource RadioButton.Chip}" GroupName="JobFilters" Content="{Binding Text}" IsChecked="{Binding IsSelected, Mode=OneWay}"
Command="{Binding SelectCommand}" ToolTip="{Binding ToolTip}" Margin="0,1,8,1" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<StackPanel Orientation="Horizontal" Margin="0,1,0,1">
<Border Width="1" Height="22" Background="{DynamicResource Brush.Stroke}" Margin="6,0,14,0" VerticalAlignment="Center" />
<TextBox Width="240" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Search}"
ui:Field.Placeholder="{l:Loc Jobs.Search}" ToolTip="{l:Loc Tooltips.Jobs.Search}" AutomationProperties.Name="{l:Loc Jobs.Search}" />
</StackPanel>
</WrapPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="12,0,0,0" Visibility="{Binding HasEngine, Converter={StaticResource BoolToVisibility}}">
<Border Style="{StaticResource Pill.Auto}" Margin="0,0,10,0" VerticalAlignment="Center" ToolTip="{l:Loc Tooltips.Jobs.PriorityQueue}"
Visibility="{Binding IsPriorityQueueOn, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{l:Loc Jobs.PriorityQueue}" FontSize="{StaticResource Size.Chip}" Foreground="{DynamicResource Brush.Accent}" VerticalAlignment="Center" />
</Border>
<TextBlock Text="{Binding ParallelismText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Jobs.Parallelism}" />
</StackPanel>
<Button Grid.Column="2" Content="{l:Loc Jobs.PauseAll}" Command="{Binding PauseAllCommand}" ToolTip="{l:Loc Tooltips.Jobs.PauseAll}" Margin="12,0,0,0" VerticalAlignment="Center" />
<Button Grid.Column="3" Content="{l:Loc Jobs.ClearDone}" Command="{Binding ClearDoneCommand}" ToolTip="{l:Loc Tooltips.Jobs.ClearDone}" Margin="8,0,0,0" VerticalAlignment="Center" />
</Grid>
<Border Grid.Row="1" Style="{StaticResource Border.Panel}" Margin="20,0,20,12" Visibility="{Binding HasRows, Converter={StaticResource BoolToVisibility}}">
<!-- Header and rows share their columns (Jobs.html grid-template-columns): the same 14 px padding, the actions column sized
by its widest row in every row, and the list's scroll-bar gutter always kept (10 px), mirrored on the header's right. -->
<Grid Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Header -->
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="14,8,24,8">
<Grid>
<!-- Kind, Where and State share the width with Target and Progress (Target, whose name is in its tooltip, gives way first), so the actions keep
their room at 1200 px beside the 200 px rail in every language; a cut kind, place, state or header shows whole in its tooltip. On wide
windows Kind, Where and State stop growing and Target takes the rest (Jobs.html). -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="28" />
<ColumnDefinition Width="0.7*" MinWidth="90" MaxWidth="140" />
<ColumnDefinition Width="1.6*" MinWidth="84" />
<ColumnDefinition Width="*" MinWidth="104" MaxWidth="240" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="0.6*" MinWidth="80" MaxWidth="140" />
<ColumnDefinition Width="0.7*" MinWidth="116" MaxWidth="170" />
<ColumnDefinition Width="Auto" MinWidth="150" SharedSizeGroup="JobActions" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Column.Kind}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.Kind}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Column.Target}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.Target}" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Column.Progress}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.Progress}" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.HeaderEnd}" Text="{l:Loc Jobs.Column.Speed}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.Speed}" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.HeaderEnd}" Text="{l:Loc Jobs.Column.Left}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.Left}" />
<TextBlock Grid.Column="6" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Column.Where}" Margin="16,0,0,0" ToolTip="{l:Loc Jobs.Column.Where}" />
<TextBlock Grid.Column="7" Style="{StaticResource Text.Header}" Text="{l:Loc Jobs.Column.State}" Margin="10,0,0,0" ToolTip="{l:Loc Jobs.Column.State}" />
</Grid>
</Border>
<!-- Rows: queue order, then the history; expandable log tail. Tab walks every row button (the rows take no focus). -->
<ListBox x:Name="JobList" Grid.Row="1" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.Job}"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.ScrollChanged="OnScrollChanged"
KeyboardNavigation.TabNavigation="Continue" AutomationProperties.Name="{l:Loc Shell.Nav.Jobs}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type j:JobRowViewModel}">
<StackPanel>
<Border x:Name="Row" Height="38" Background="Transparent" Padding="14,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="28" />
<ColumnDefinition Width="0.7*" MinWidth="90" MaxWidth="140" />
<ColumnDefinition Width="1.6*" MinWidth="84" />
<ColumnDefinition Width="*" MinWidth="104" MaxWidth="240" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="0.6*" MinWidth="80" MaxWidth="140" />
<ColumnDefinition Width="0.7*" MinWidth="116" MaxWidth="170" />
<ColumnDefinition Width="Auto" MinWidth="150" SharedSizeGroup="JobActions" />
</Grid.ColumnDefinitions>
<Button x:Name="Toggle" Style="{StaticResource Button.IconSubtle}" Width="22" Height="22" MinWidth="22" HorizontalAlignment="Left"
ui:ButtonIcon.Glyph="{StaticResource Icon.ChevronRight}" Command="{Binding ToggleLogCommand}"
ToolTip="{Binding ToggleToolTip}" AutomationProperties.Name="{Binding ToggleName}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Muted}" Text="{Binding Kind}" Margin="10,0,0,0" ToolTip="{Binding Kind}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding Target}" Margin="10,0,0,0" ToolTip="{Binding Target}" />
<Grid Grid.Column="3" Margin="10,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="44" />
</Grid.ColumnDefinitions>
<ProgressBar Style="{StaticResource ProgressBar.Job}" Maximum="1" Value="{Binding Progress, Mode=OneWay}" VerticalAlignment="Center"
AutomationProperties.Name="{Binding AccessibleName}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.MutedNumber}" Text="{Binding PercentText}" />
</Grid>
<TextBlock Grid.Column="4" Style="{StaticResource Text.MutedEnd}" Text="{Binding SpeedText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.MutedEnd}" Text="{Binding LeftText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="6" Style="{StaticResource Text.Muted}" Text="{Binding WhereText}" Margin="16,0,0,0" ToolTip="{Binding WhereText}" />
<!-- A new state is announced with its job; progress ticks are not. -->
<ui:StatusGlyph Grid.Column="7" Kind="{Binding StateKind}" Text="{Binding StateText}" ToolTip="{Binding StateToolTip}"
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding StateAnnouncement}" />
<ItemsControl Grid.Column="8" ItemsSource="{Binding Actions}" ItemsPanel="{StaticResource Panel.Row}" Focusable="False"
VerticalAlignment="Center" Margin="10,0,0,0">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type j:JobAction}">
<Button Style="{StaticResource Button.Row}" Content="{Binding Text}" Command="{Binding Command}" ToolTip="{Binding ToolTip}"
AutomationProperties.Name="{Binding AccessibleName}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Border>
<!-- The log keeps its left-to-right lines (times, paths, numbers) in every language. -->
<Border x:Name="Log" Background="{DynamicResource Brush.Bg}" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,0"
Padding="52,10,14,12" Visibility="Collapsed">
<TextBlock Style="{StaticResource Text.Log}" Text="{Binding LogText}" FlowDirection="LeftToRight" />
</Border>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsExpanded}" Value="True">
<Setter TargetName="Log" Property="Visibility" Value="Visible" />
<Setter TargetName="Row" Property="Background" Value="{DynamicResource Brush.Card}" />
<Setter TargetName="Toggle" Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.ChevronDown}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- Footer -->
<Border Grid.Row="2" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,0" Padding="14,8">
<DockPanel LastChildFill="False" TextElement.FontSize="12">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Link}" Content="{l:Loc Jobs.RenderingSettings}" Command="{Binding RenderingSettingsCommand}"
ToolTip="{l:Loc Tooltips.Jobs.RenderingSettings}" />
<TextBlock Text="{Binding HistoryText}" Foreground="{DynamicResource Brush.TextMuted}" ToolTip="{l:Loc Tooltips.Jobs.History}" />
</DockPanel>
</Border>
</Grid>
</Border>
<ui:EmptyState Grid.Row="1" Message="{l:Loc Jobs.Empty}" Visibility="{Binding IsEmpty, Converter={StaticResource BoolToVisibility}}">
<Button Content="{l:Loc Shell.Nav.Import}" Command="{Binding ImportCommand}" ToolTip="{l:Loc Tooltips.Jobs.Import}" />
</ui:EmptyState>
</Grid>
</UserControl>
+15
View File
@@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace Chronos.App.Sections;
public partial class JobsView : UserControl
{
public JobsView() => InitializeComponent();
/// <summary>Loads older history when the list scrolls near its end.</summary>
private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (DataContext is not JobsViewModel vm || e.ExtentHeight <= 0) return;
if (e.VerticalOffset + e.ViewportHeight >= e.ExtentHeight - Math.Max(e.ViewportHeight, 200)) _ = vm.LoadMoreAsync();
}
}
+545
View File
@@ -0,0 +1,545 @@
using System.Collections.ObjectModel;
using System.IO;
using System.Windows.Input;
using Chronos.App.Infrastructure;
using Chronos.App.Jobs;
using Chronos.App.Library;
using Chronos.App.Settings;
using Chronos.App.Shell;
using Chronos.Core.Diagnostics;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Data;
using Chronos.Data.Jobs;
using Chronos.Ui.Controls;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Sections;
/// <summary>A filter chip of the Jobs toolbar ("Running · 4").</summary>
public sealed class JobFilterChip(JobFilter filter, Action<JobFilter> select) : ObservableObject
{
private int _count;
private bool _isSelected;
public JobFilter Filter { get; } = filter;
public string Text => Loc.L("Jobs.Filter." + Filter, Formatting.Count(_count));
public string ToolTip => Loc.L("Tooltips.Jobs.Filter." + Filter);
public ICommand SelectCommand { get; } = new RelayCommand(() => select(filter));
public bool IsSelected
{
get => _isSelected;
set => Set(ref _isSelected, value);
}
public int Count
{
get => _count;
set
{
if (Set(ref _count, value)) OnPropertyChanged(nameof(Text));
}
}
internal void Refresh() => OnAllPropertiesChanged();
}
/// <summary>
/// Jobs (BRIEF §12.6, Jobs.html): queue and history with live progress from the engine (batched to about 10
/// updates a second), filters, queue order, an expandable log tail per job, and the row actions. Also feeds the
/// shell's job bar, the status strip and the rail badge (running jobs, and failures not seen on this screen yet), and
/// raises the toast of a long operation that ends (<see cref="JobNotices"/>), whichever screen started it.
/// </summary>
public sealed class JobsViewModel : SectionViewModel
{
private static readonly TimeSpan FlushInterval = TimeSpan.FromMilliseconds(100);
private const int PageSize = 200;
private readonly JobListModel _model = new();
private readonly JobUpdateBuffer _buffer = new();
private readonly Dictionary<Guid, JobRowViewModel> _rows = [];
private readonly HashSet<Guid> _unseenFailures = [];
private readonly JobEndings _endings = new();
/// <summary>Finished renders whose toast was taken (<see cref="ClaimRenderToast"/>).</summary>
private readonly HashSet<Guid> _renderToasts = [];
private readonly JobActions _actions;
private CoalescingThrottle? _throttle;
private IJobQueue? _queue;
private JobFilter _filter = JobFilter.All;
private string _searchText = string.Empty;
private string? _cursor;
private bool _hasMore;
private bool _loading;
private bool _hasLoaded;
public JobsViewModel(ShellViewModel shell)
: base(SectionKey.Jobs, "Icon.Jobs")
{
Shell = shell;
_actions = new JobActions(this);
Chips = [.. Enum.GetValues<JobFilter>().Select(f => new JobFilterChip(f, SelectFilter) { IsSelected = f == JobFilter.All })];
PauseCurrentCommand = new AsyncRelayCommand(PauseCurrentAsync, () => _model.Current is not null);
PauseAllCommand = new AsyncRelayCommand(PauseAllAsync, () => _model.RunningCount > 0);
ClearDoneCommand = new RelayCommand(ClearDone, () => _model.CountOf(JobFilter.Done, ClearedAt) + _model.CountOf(JobFilter.Failed, ClearedAt) > 0);
RenderingSettingsCommand = new RelayCommand(() =>
{
Shell.Settings.Page = SettingsPage.Rendering;
Shell.Navigate(SectionKey.Settings);
});
LoadMoreCommand = new RelayCommand(() => _ = LoadMoreAsync());
ImportCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Import));
}
public ShellViewModel Shell { get; }
/// <summary>Rows in display order for the current filter and search.</summary>
public ObservableCollection<JobRowViewModel> Rows { get; } = [];
public IReadOnlyList<JobFilterChip> Chips { get; }
public ICommand PauseCurrentCommand { get; }
public ICommand PauseAllCommand { get; }
public ICommand ClearDoneCommand { get; }
public ICommand RenderingSettingsCommand { get; }
public ICommand LoadMoreCommand { get; }
/// <summary>The empty state's one action: jobs start with an import.</summary>
public ICommand ImportCommand { get; }
public JobFilter Filter
{
get => _filter;
set
{
if (!Set(ref _filter, value)) return;
foreach (var chip in Chips) chip.IsSelected = chip.Filter == value;
SyncRows();
}
}
public string SearchText
{
get => _searchText;
set
{
if (Set(ref _searchText, value ?? string.Empty)) SyncRows();
}
}
/// <summary>"8 photos at once": what the running job of this PC processes together (Settings › Rendering › Parallelism).</summary>
public string ParallelismText => Loc.Plural("Jobs.Parallelism", Shell.Services.Parallelism);
/// <summary>The engine of this PC runs jobs (it runs none before it starts).</summary>
public bool HasEngine => _queue is { IsRunning: true };
/// <summary>The priority queue of Settings › Rendering is on: higher jobs pause the running one.</summary>
public bool IsPriorityQueueOn => HasEngine && Shell.Services.Settings.PriorityQueue;
/// <summary>"History keeps 90 days".</summary>
public string HistoryText => Loc.Plural("Jobs.History", (long)new JobEngineOptions().HistoryRetention.TotalDays);
public bool IsEmpty => _hasLoaded && Rows.Count == 0;
public bool HasRows => Rows.Count > 0;
internal IJobQueue? Queue => _queue;
internal JobListModel Model => _model;
private DateTimeOffset? ClearedAt => Shell.Services.Settings.JobsClearedAt;
/// <summary>Subscribes to the engine and loads the first page of jobs.</summary>
public void Attach()
{
_queue = Shell.Services.Jobs;
if (_queue is null)
{
_hasLoaded = true;
RaiseState();
return;
}
_throttle = new CoalescingThrottle(FlushInterval, SynchronizationContext.Current, Flush);
_queue.JobChanged += OnJobChanged;
_queue.Progress += OnProgress;
_ = LoadMoreAsync();
}
public override void Dispose()
{
if (_queue is not null)
{
_queue.JobChanged -= OnJobChanged;
_queue.Progress -= OnProgress;
}
_throttle?.Dispose();
base.Dispose();
}
/// <summary>The UI language changed: the rows, the filter chips and the job bar say it again in the new language.</summary>
protected override void OnLanguageChanged()
{
foreach (var row in _rows.Values) row.Refresh();
foreach (var chip in Chips) chip.Refresh();
UpdateShell();
base.OnLanguageChanged();
}
/// <summary>Reads the job list again from the first page (after jobs were written outside the engine).</summary>
public Task ReloadAsync()
{
_cursor = null;
_hasMore = true;
_hasLoaded = false;
return LoadMoreAsync();
}
/// <summary>Next page of the history (newest first); the view calls it when the list scrolls near its end.</summary>
public async Task LoadMoreAsync()
{
if (_queue is null || _loading || (_hasLoaded && !_hasMore)) return;
_loading = true;
try
{
var stamp = _model.Stamp;
var page = await _queue.ListAsync(_cursor, PageSize);
foreach (var job in page.Items) _model.ApplyLoaded(job, stamp);
_cursor = page.NextCursor;
_hasMore = page.NextCursor is not null;
}
catch (DatabaseException ex)
{
Log.Warning("jobs", "Job list unavailable", ex);
_hasMore = false;
}
finally
{
_loading = false;
_hasLoaded = true;
}
Flush();
}
/// <summary>Applies everything buffered since the last flush (UI thread).</summary>
internal void Flush()
{
var (jobs, progress) = _buffer.Drain();
foreach (var job in jobs)
{
var before = _model[job.Id]?.State;
_model.Apply(job);
Follow(before, job);
}
foreach (var p in progress) _model.Apply(p);
foreach (var ending in _endings.Take(_model.IsBusy)) Shell.ShowToast(ToastFor(ending));
SyncRows();
UpdateShell();
}
/// <summary>Failures seen on this screen no longer count on the rail.</summary>
protected override void OnActivated()
{
if (_unseenFailures.Count == 0) return;
_unseenFailures.Clear();
UpdateShell();
}
/// <summary>
/// A change the engine reported (these are live, never pages read again): a failure counts on the rail until this
/// screen is opened, and a long operation that ends is announced at the end of the flush (<see cref="JobEndings"/>).
/// </summary>
private void Follow(JobState? before, Job job)
{
if (job.State != JobState.Failed) _unseenFailures.Remove(job.Id);
else if (before != JobState.Failed && !IsSelected) _unseenFailures.Add(job.Id);
var notice = JobNotices.For(before, job);
// A flush can take the end before the editor that follows the render has seen it: the editor says it, with its output.
if (notice == JobNotice.Done && job.Kind == JobKind.Render
&& (Shell.Sequence.Editor?.FollowsRender(job.Id) == true || !ClaimRenderToast(job.Id))) return;
_endings.Add(notice, job);
}
/// <summary>
/// Takes the toast of a finished render, which is said once (UI thread): true for the first caller only, which then
/// raises it. The editor of the render's sequence takes it when it sees the render end, and says it with the output
/// file even when the sequence cannot be read again or the editor closed meanwhile; a render the editor did not
/// follow is said here.
/// </summary>
internal bool ClaimRenderToast(Guid jobId) => _renderToasts.Add(jobId);
/// <summary>
/// The toast of a job that ended, with one action (BRIEF §12.1, §0.2 rule 6). Several endings at once (a batch
/// finished, or failed together) say how many and lead to this screen. Clicking the Windows notification of a
/// toast opens what it names; a retry waits until the user has seen why the job failed.
/// </summary>
private Toast ToastFor(JobEnding ending)
{
var job = ending.Jobs[0];
var failed = ending.Notice == JobNotice.Failed;
if (ending.Jobs.Count > 1)
{
return new Toast
{
Title = Loc.Plural(failed ? "Shell.Job.FailedPlural" : "Shell.Job.DonePlural", ending.Jobs.Count),
Message = ending.Jobs.All(j => j.Kind == job.Kind) ? JobText.Kind(job.Kind) : null,
ActionText = Loc.L("Shell.Nav.Jobs"),
ActionToolTip = Loc.L("Tooltips.Nav.Jobs"),
ActionCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Jobs)),
IsError = failed,
RunsFromNotification = true,
};
}
if (!failed)
{
return new Toast
{
Title = Loc.L("Shell.Job.Done"),
Message = JobText.Name(job),
ActionText = Loc.L("Jobs.Action.Open"),
ActionToolTip = Loc.L("Tooltips.Jobs.Open"),
ActionCommand = new AsyncRelayCommand(() => OpenTargetAsync(job)),
RunsFromNotification = true,
};
}
return job.Kind == JobKind.Import
// The Import screen resumes an import with its plan and card; it holds the retry.
? new Toast
{
Title = Loc.L("Shell.Job.Failed"),
Message = JobText.Name(job),
ActionText = Loc.L("Shell.Nav.Import"),
ActionToolTip = Loc.L("Tooltips.Nav.Import"),
ActionCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Import)),
IsError = true,
RunsFromNotification = true,
}
: new Toast
{
Title = Loc.L("Shell.Job.Failed"),
Message = JobText.Name(job),
ActionText = Loc.L("Jobs.Action.Retry"),
ActionToolTip = Loc.L("Tooltips.Jobs.Retry"),
ActionCommand = new AsyncRelayCommand(() => _queue?.ResumeAsync(job.Id) ?? Task.CompletedTask),
IsError = true,
};
}
/// <summary>A job changed state (any thread; tests feed it too): buffered until the next flush.</summary>
internal void OnJobChanged(Job job)
{
_buffer.Post(job);
_throttle?.Signal();
}
private void OnProgress(JobProgressInfo progress)
{
_buffer.Post(progress);
_throttle?.Signal();
}
private void SelectFilter(JobFilter filter) => Filter = filter;
/// <summary>Brings <see cref="Rows"/> to the model's order with moves (rows keep their expanded log).</summary>
private void SyncRows()
{
_model.PriorityQueue = Shell.Services.PriorityQueue;
var ordered = _model.Ordered(_filter, _searchText, ClearedAt);
var wanted = new HashSet<Guid>(ordered.Select(e => e.Id));
for (var i = Rows.Count - 1; i >= 0; i--)
{
if (!wanted.Contains(Rows[i].Id)) Rows.RemoveAt(i);
}
for (var i = 0; i < ordered.Count; i++)
{
var entry = ordered[i];
var position = entry.State == JobState.Queued ? _model.QueuePosition(entry.Id) : 0;
if (!_rows.TryGetValue(entry.Id, out var row))
{
row = new JobRowViewModel(entry, position, _actions);
_rows[entry.Id] = row;
}
else
{
row.Update(entry, position);
}
if (i < Rows.Count && ReferenceEquals(Rows[i], row)) continue;
var existing = Rows.IndexOf(row);
if (existing >= 0) Rows.Move(existing, i);
else Rows.Insert(i, row);
}
foreach (var chip in Chips) chip.Count = _model.CountOf(chip.Filter, ClearedAt);
RaiseState();
}
private void UpdateShell()
{
if (_model.Current is { } current)
Shell.SetJob(JobText.Bar(current), current.Fraction ?? 0, indeterminate: current.Fraction is null, name: JobText.Name(current.Job));
else
Shell.SetJob(null, 0);
// The status strip and the Running chip count the same jobs: running or paused (Jobs.html). The rail badge adds the
// failures not seen here yet, which also turn the taskbar button red while no job runs.
var active = _model.CountOf(JobFilter.Running);
Shell.SetJobCount(active, _model.QueuedCount);
Shell.SetUnseenFailures(_unseenFailures.Count);
Badge = active + _unseenFailures.Count;
OnPropertyChanged(nameof(ParallelismText));
OnPropertyChanged(nameof(HasEngine));
OnPropertyChanged(nameof(IsPriorityQueueOn));
CommandManager.InvalidateRequerySuggested();
}
private void RaiseState()
{
OnPropertyChanged(nameof(IsEmpty));
OnPropertyChanged(nameof(HasRows));
}
private async Task PauseCurrentAsync()
{
if (_model.Current is { } current && _queue is not null) await _queue.PauseAsync(current.Id);
}
private async Task PauseAllAsync()
{
if (_queue is null) return;
foreach (var entry in _model.Ordered(JobFilter.Running).Where(e => e.State == JobState.Running).ToList()) await _queue.PauseAsync(entry.Id);
}
private void ClearDone()
{
Shell.Services.Settings.JobsClearedAt = DateTimeOffset.UtcNow;
Shell.Services.SaveSettings();
SyncRows();
}
/// <summary>
/// Opens what a job worked on inside Chronos: its sequence in the editor; several sequences (a deep analysis of a
/// Library selection) in the Library, every one of them selected; else the Archive screen. A job over more sequences
/// than a Library page holds (a maintenance run over a whole archive) opens the Library as it is: looking each one
/// up, then reading page after page to select them all, would hold the screen.
/// </summary>
internal async Task OpenTargetAsync(Job job)
{
var db = Shell.Services.Database;
if (db is null || job.TargetIds.Count == 0) return;
var targets = job.TargetIds.Distinct().ToList();
if (targets.Count > LibraryPager.DefaultPageSize)
{
Shell.Navigate(SectionKey.Library);
return;
}
// Each one is looked up: an id no longer in the index would have the Library read every page in search of it.
var sequences = new List<Guid>(targets.Count);
foreach (var id in targets)
{
if (await db.Sequences.GetAsync(id) is { } sequence) sequences.Add(sequence.Id);
}
switch (sequences.Count)
{
case 0:
Shell.Navigate(SectionKey.Archive);
break;
case 1:
Shell.OpenSequence(sequences[0]);
break;
default:
Shell.Navigate(SectionKey.Library);
await Shell.Library.ShowSelectedAsync(sequences);
break;
}
}
/// <summary>Shows the folder of what a job worked on in Explorer.</summary>
internal async Task RevealTargetAsync(Job job)
{
var db = Shell.Services.Database;
if (db is null || job.TargetIds.Count == 0) return;
var id = job.TargetIds[0];
if (await db.Sequences.GetAsync(id) is { } sequence && await db.Archives.GetAsync(sequence.ArchiveId) is { } owner)
ShellActions.Reveal(Path.Combine(owner.RootPath, sequence.Folder.Replace('/', Path.DirectorySeparatorChar)));
else if (await db.Archives.GetAsync(id) is { } archive)
ShellActions.Reveal(archive.RootPath);
}
}
/// <summary>Row actions per job state (Jobs.html) and their commands.</summary>
internal sealed class JobActions(JobsViewModel owner)
{
public string WorkerId => owner.Queue?.WorkerId ?? Environment.MachineName;
public IReadOnlyList<JobAction> For(JobEntry entry)
{
var job = entry.Job;
var row = JobText.Name(job);
return entry.State switch
{
JobState.Running =>
[
OnQueue("Jobs.Action.Pause", "Tooltips.Jobs.Pause", row, q => q.PauseAsync(job.Id)),
OnQueue("Jobs.Action.Cancel", "Tooltips.Jobs.Cancel", row, q => q.CancelAsync(job.Id)),
],
JobState.Paused =>
[
OnQueue("Jobs.Action.Resume", "Tooltips.Jobs.Resume", row, q => q.ResumeAsync(job.Id)),
OnQueue("Jobs.Action.Cancel", "Tooltips.Jobs.Cancel", row, q => q.CancelAsync(job.Id)),
],
JobState.Queued when job.Priority < JobPriority.User =>
[
OnQueue("Jobs.Action.MoveUp", "Tooltips.Jobs.MoveUp", row, q => q.RaisePriorityAsync(job.Id)),
OnQueue("Jobs.Action.Remove", "Tooltips.Jobs.Remove", row, q => q.CancelAsync(job.Id)),
],
JobState.Queued =>
[
OnQueue("Jobs.Action.Pause", "Tooltips.Jobs.PauseQueued", row, q => q.PauseAsync(job.Id)),
OnQueue("Jobs.Action.Remove", "Tooltips.Jobs.Remove", row, q => q.CancelAsync(job.Id)),
],
JobState.Failed =>
[
OnQueue("Jobs.Action.Retry", "Tooltips.Jobs.Retry", row, q => q.ResumeAsync(job.Id)),
Action("Jobs.Action.Show", "Tooltips.Jobs.Show", row, () => owner.OpenTargetAsync(job)),
],
JobState.Cancelled =>
[
OnQueue("Jobs.Action.Retry", "Tooltips.Jobs.Retry", row, q => q.ResumeAsync(job.Id)),
],
_ =>
[
Action("Jobs.Action.Open", "Tooltips.Jobs.Open", row, () => owner.OpenTargetAsync(job)),
Action("Jobs.Action.Folder", "Tooltips.Jobs.Folder", row, () => owner.RevealTargetAsync(job)),
],
};
}
/// <summary>Reads the stored log tail of a row (persisted with each checkpoint).</summary>
public async Task LoadLogAsync(JobRowViewModel row)
{
if (owner.Queue is not { } queue) return;
try
{
if (await queue.GetAsync(row.Id) is { } job) row.SetLog(job.LogTail);
}
catch (DatabaseException ex)
{
Log.Warning("jobs", "Job log unavailable", ex);
}
}
/// <summary>A row button named with its row for screen readers ("Pause: Render · Harbour sunset").</summary>
private static JobAction Action(string textKey, string toolTipKey, string row, Func<Task> run)
{
var text = Loc.L(textKey);
return new JobAction(text, Loc.L(toolTipKey), Loc.L("Jobs.ActionFor", text, row), new AsyncRelayCommand(run));
}
private JobAction OnQueue(string textKey, string toolTipKey, string row, Func<IJobQueue, Task> run) =>
Action(textKey, toolTipKey, row, async () =>
{
if (owner.Queue is { } queue) await run(queue);
});
}
+445
View File
@@ -0,0 +1,445 @@
<UserControl x:Class="Chronos.App.Sections.LibraryView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:v="clr-namespace:Chronos.Ui.Visuals;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:lib="clr-namespace:Chronos.App.Library"
xmlns:shell="clr-namespace:Chronos.App.Shell">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Chronos;component/Archive/ArchiveDialogs.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- A double-click is read on the card or row itself: it takes the mouse-down to select, so a gesture on the list never sees it. -->
<Style x:Key="ListBoxItem.LibraryCard" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Card}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<EventSetter Event="MouseDoubleClick" Handler="OnItemDoubleClick" />
</Style>
<Style x:Key="ListBoxItem.LibraryRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Height" Value="38" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<EventSetter Event="MouseDoubleClick" Handler="OnItemDoubleClick" />
</Style>
<Style x:Key="Button.Header" TargetType="Button" BasedOn="{StaticResource Button.Subtle}">
<Setter Property="Height" Value="28" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="FontSize" Value="11" />
<Setter Property="Foreground" Value="{DynamicResource Brush.TextFaint}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="ui:ControlState.HoverBackground" Value="Transparent" />
</Style>
<Style x:Key="Button.Bar" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="0,0,8,8" />
</Style>
<!-- Quick actions revealed on a card (28 px) or a row (26 px, DESIGN §4). -->
<Style x:Key="Button.Quick" TargetType="Button" BasedOn="{StaticResource Button.Icon}">
<Setter Property="Width" Value="28" />
<Setter Property="Height" Value="28" />
<Setter Property="MinWidth" Value="28" />
<Setter Property="Margin" Value="6,0,0,0" />
</Style>
<Style x:Key="Button.RowQuick" TargetType="Button" BasedOn="{StaticResource Button.Quick}">
<Setter Property="Width" Value="26" />
<Setter Property="Height" Value="26" />
<Setter Property="MinWidth" Value="26" />
</Style>
<!-- A menu of choices (saved views, ratings): each checked while it is the one in force. -->
<Style x:Key="MenuItem.View" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header" Value="{Binding Label}" />
<Setter Property="IsChecked" Value="{Binding IsChecked, Mode=OneWay}" />
<Setter Property="Command" Value="{Binding Command}" />
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Library.ViewChoice}" />
</Style>
<Style x:Key="MenuItem.Rating" TargetType="MenuItem" BasedOn="{StaticResource MenuItem.View}">
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Library.RateChoice}" />
</Style>
<DataTemplate x:Key="Template.Status" DataType="{x:Type v:CardStatus}">
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ToolTip}" Margin="0,0,8,0" />
</DataTemplate>
<!-- A row's quick actions: on the hovered row, on selected rows and while the keyboard is in the row (Tab reaches them). -->
<Style x:Key="Border.RowActions" TargetType="Border">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
<!-- The toolbar's filters: each capped and trimmed; they wrap to a second line rather than push the right-hand group out. -->
<Style x:Key="ComboBox.ToolbarFilter" TargetType="ComboBox" BasedOn="{StaticResource ComboBox.Filter}">
<Setter Property="Margin" Value="10,4,0,4" />
<Setter Property="MaxWidth" Value="170" />
<Setter Property="ItemTemplate" Value="{StaticResource Template.FilterOption}" />
</Style>
<ItemsPanelTemplate x:Key="Panel.Row">
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
<!-- Save view / Rename view: one name field. -->
<DataTemplate DataType="{x:Type lib:ViewNameDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="460">
<StackPanel>
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="116" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{l:Loc Library.Views.Name}" Style="{StaticResource Text.DialogLabel}" />
<TextBox Grid.Column="1" Text="{Binding Name.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding Name}"
ToolTip="{Binding Name.ToolTip}" AutomationProperties.Name="{l:Loc Library.Views.Name}" />
</Grid>
<DockPanel Margin="0,18,0,0">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Library.Views.Save}" Command="{Binding SaveCommand}"
ToolTip="{Binding SaveToolTip}" IsDefault="True" 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" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" Margin="0,0,12,0" />
</DockPanel>
</StackPanel>
</Border>
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid IsEnabled="{Binding IsContentEnabled}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!--
Toolbar (Main.html): search, filters, sort · saved views, layout switch, rescan. The search box gives way first
(down to 160 px); filters that still do not fit wrap to a second line, so the right-hand group is never cut.
-->
<Grid Grid.ColumnSpan="2" Margin="20,0" MinHeight="56">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="160" MaxWidth="260" />
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox VerticalAlignment="Top" Margin="0,12,0,0" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Search}"
ui:Field.Placeholder="{l:Loc Library.Search}" ToolTip="{l:Loc Tooltips.Library.Search}" AutomationProperties.Name="{l:Loc Library.Search}" />
<WrapPanel Grid.Column="1" VerticalAlignment="Top" Margin="0,8">
<ComboBox Style="{StaticResource ComboBox.ToolbarFilter}" ItemsSource="{Binding Years}" SelectedItem="{Binding SelectedYear}" Tag="{Binding IsYearFiltered}"
ToolTip="{l:Loc Tooltips.Library.Year}" AutomationProperties.Name="{l:Loc Library.Filter.Year}" />
<ComboBox Style="{StaticResource ComboBox.ToolbarFilter}" ItemsSource="{Binding Cameras}" SelectedItem="{Binding SelectedCamera}" Tag="{Binding IsCameraFiltered}"
ToolTip="{l:Loc Tooltips.Library.Camera}" AutomationProperties.Name="{l:Loc Library.Filter.Camera}" />
<ComboBox Style="{StaticResource ComboBox.ToolbarFilter}" ItemsSource="{Binding Statuses}" SelectedItem="{Binding SelectedStatus}" Tag="{Binding IsStatusFiltered}"
ToolTip="{l:Loc Tooltips.Library.Status}" AutomationProperties.Name="{l:Loc Library.Filter.Status}" />
<ComboBox Style="{StaticResource ComboBox.ToolbarFilter}" ItemsSource="{Binding Tags}" SelectedItem="{Binding SelectedTag}" Tag="{Binding IsTagFiltered}"
ToolTip="{l:Loc Tooltips.Library.Tags}" AutomationProperties.Name="{l:Loc Library.Filter.Tags}" />
<ComboBox Style="{StaticResource ComboBox.ToolbarFilter}" ItemsSource="{Binding Origins}" SelectedItem="{Binding SelectedOrigin}" Tag="{Binding IsOriginFiltered}"
ToolTip="{l:Loc Tooltips.Library.Origin}" AutomationProperties.Name="{l:Loc Library.Filter.Origin}"
Visibility="{Binding ShowsOrigin, Converter={StaticResource BoolToVisibility}}" />
<ComboBox Style="{StaticResource ComboBox.ToolbarFilter}" ItemsSource="{Binding Sorts}" SelectedItem="{Binding SelectedSort}"
ToolTip="{l:Loc Tooltips.Library.Sort}" AutomationProperties.Name="{l:Loc Library.Sort}" />
</WrapPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Top" Margin="10,12,0,0">
<Button x:Name="ViewsButton" Click="OnOpenMenu" ui:ButtonIcon.Glyph="{StaticResource Icon.Filter}" ToolTip="{Binding ViewsToolTip}"
AutomationProperties.Name="{l:Loc Library.Views}" Margin="0,0,10,0">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource Button.Icon}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsViewActive}" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="{l:Loc Library.Views.Apply}" ItemsSource="{Binding ViewChoices}" ItemContainerStyle="{StaticResource MenuItem.View}"
IsEnabled="{Binding HasViews}" ToolTip="{Binding ViewsApplyToolTip}" ToolTipService.ShowOnDisabled="True" />
<Separator />
<MenuItem Header="{l:Loc Library.Views.SaveMenu}" Command="{Binding SaveViewCommand}" ToolTip="{Binding ViewSaveToolTip}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Library.Views.RenameMenu}" Command="{Binding RenameViewCommand}" ToolTip="{Binding ViewRenameToolTip}"
ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Library.Views.Delete}" Command="{Binding DeleteViewCommand}" ToolTip="{Binding ViewDeleteToolTip}"
ToolTipService.ShowOnDisabled="True" />
</ContextMenu>
</Button.ContextMenu>
</Button>
<v:SegmentedControl SelectedIndex="{Binding LayoutIndex, Mode=TwoWay}" AutomationProperties.Name="{l:Loc Library.View}">
<v:SegmentedItem Glyph="{StaticResource Icon.ViewGrid}" ToolTip="{l:Loc Tooltips.Library.Grid}" AutomationProperties.Name="{l:Loc Library.View.Grid}" />
<v:SegmentedItem Glyph="{StaticResource Icon.ViewList}" ToolTip="{l:Loc Tooltips.Library.List}" AutomationProperties.Name="{l:Loc Library.View.List}" />
<v:SegmentedItem Glyph="{StaticResource Icon.ViewTimeline}" ToolTip="{l:Loc Tooltips.Library.Timeline}" AutomationProperties.Name="{l:Loc Library.View.Timeline}" />
</v:SegmentedControl>
<Button Style="{StaticResource Button.Icon}" ui:ButtonIcon.Glyph="{StaticResource Icon.Refresh}" Command="{Binding RescanCommand}"
ToolTip="{l:Loc Tooltips.Library.Rescan}" AutomationProperties.Name="{l:Loc Library.Rescan}" Margin="10,0,0,0" />
</StackPanel>
</Grid>
<!-- Timeline: one band per year, photos per month; a month narrows to its year and scrolls the grid to it. -->
<Border Grid.Row="1" Grid.ColumnSpan="2" Style="{StaticResource Border.Panel}" Margin="20,4,20,8" Padding="14,8"
Visibility="{Binding IsTimeline, Converter={StaticResource BoolToVisibility}}">
<ScrollViewer MaxHeight="172" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Focusable="False">
<v:TimelineBands x:Name="Timeline" Bands="{Binding TimelineBands}" SlotLabels="{Binding MonthLabels}" BandHeight="56"
CurrentBand="{Binding TimelineBand, Mode=OneWay}" CurrentSlot="{Binding TimelineSlot, Mode=OneWay}" ValueFormatter="{Binding CountFormatter}"
SlotActivated="OnSlotActivated" ToolTip="{l:Loc Tooltips.Library.TimelineBands}" AutomationProperties.Name="{l:Loc Library.View.Timeline}" />
</ScrollViewer>
</Border>
<!-- Grid view (also under the timeline): virtualised, recycling card grid. -->
<ListBox x:Name="CardGrid" Grid.Row="2" Style="{StaticResource ListBox.Cards}" ItemsSource="{Binding Items}" ItemContainerStyle="{StaticResource ListBoxItem.LibraryCard}"
Visibility="{Binding IsGrid, Converter={StaticResource BoolToVisibility}}" AutomationProperties.Name="{l:Loc Shell.Nav.Library}"
ScrollViewer.ScrollChanged="OnScrollChanged" KeyboardNavigation.TabNavigation="Continue">
<ListBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding OpenCommand}" />
</ListBox.InputBindings>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type lib:SequenceItem}">
<v:SequenceCard Title="{Binding Title}" Subtitle="{Binding Subtitle}" Statuses="{Binding Statuses}" Thumbnail="{Binding Thumbnail}"
ScrubSource="{Binding ScrubSource}" lib:ThumbnailLoading.Width="236"
IsSelected="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}, Mode=TwoWay}"
SelectToolTip="{l:Loc Tooltips.Library.Select}" ToolTip="{Binding CardToolTip}">
<v:SequenceCard.ActionsContent>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Button.Quick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Sequence}"
Command="{Binding DataContext.OpenItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Library.Open}" AutomationProperties.Name="{l:Loc Library.Action.Open}" />
<Button Style="{StaticResource Button.Quick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Analyse}"
Command="{Binding DataContext.AnalyseItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding AnalyseToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Analyse}" />
<Button Style="{StaticResource Button.Quick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Render}"
Command="{Binding DataContext.RenderItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding RenderToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Render}" />
<Button Style="{StaticResource Button.Quick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Sync}"
Command="{Binding DataContext.SyncItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding SyncToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Sync}" />
</StackPanel>
</v:SequenceCard.ActionsContent>
</v:SequenceCard>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- List view: virtualised table with sortable headers; columns share the width, row actions appear on the hovered row. -->
<Border Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource Border.Panel}" Margin="20,4,20,12" Visibility="{Binding IsList, Converter={StaticResource BoolToVisibility}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="14,2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" MinWidth="160" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="72" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="64" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<Button Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Sequence}" Command="{Binding SortByCommand}" CommandParameter="Title" ToolTip="{l:Loc Tooltips.Library.SortTitle}" />
<Button Grid.Column="1" Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Date}" Command="{Binding SortByCommand}" CommandParameter="Date" ToolTip="{l:Loc Tooltips.Library.SortDate}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.Camera}" Margin="10,0,0,0" />
<Button Grid.Column="3" Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Frames}" HorizontalContentAlignment="Right" Command="{Binding SortByCommand}" CommandParameter="FrameCount" ToolTip="{l:Loc Tooltips.Library.SortFrames}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.Span}" TextAlignment="Right" Margin="10,0,0,0" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.Interval}" TextAlignment="Right" Margin="10,0,0,0" />
<Button Grid.Column="6" Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Size}" HorizontalContentAlignment="Right" Command="{Binding SortByCommand}" CommandParameter="Size" ToolTip="{l:Loc Tooltips.Library.SortSize}" Margin="10,0,0,0" />
<TextBlock Grid.Column="7" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.State}" Margin="16,0,0,0" />
</Grid>
</Border>
<ListBox x:Name="RowList" Grid.Row="1" ItemsSource="{Binding Items}" ItemContainerStyle="{StaticResource ListBoxItem.LibraryRow}" SelectionMode="Extended"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.ScrollChanged="OnScrollChanged" AutomationProperties.Name="{l:Loc Shell.Nav.Library}"
KeyboardNavigation.TabNavigation="Continue">
<ListBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding OpenCommand}" />
</ListBox.InputBindings>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type lib:SequenceItem}">
<Grid ToolTip="{l:Loc Tooltips.Library.Row}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" MinWidth="160" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="72" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="64" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Title}" ToolTip="{Binding Title}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding DateText}" Margin="10,0,0,0" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding Camera}" Margin="10,0,0,0" Foreground="{DynamicResource Brush.TextMuted}"
ToolTip="{Binding Camera, Converter={x:Static ui:EmptyToNullConverter.Instance}}" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.CellNumber}" Text="{Binding FramesText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.CellNumber}" Text="{Binding SpanText}" Margin="10,0,0,0"
ToolTip="{Binding SpanText, Converter={x:Static ui:EmptyToNullConverter.Instance}}" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.CellNumber}" Text="{Binding IntervalText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="6" Style="{StaticResource Text.CellNumber}" Text="{Binding SizeText}" Margin="10,0,0,0" ToolTip="{Binding SizeText}" />
<ItemsControl Grid.Column="7" Margin="16,0,0,0" ItemsSource="{Binding Statuses}" ItemTemplate="{StaticResource Template.Status}"
ItemsPanel="{StaticResource Panel.Row}" VerticalAlignment="Center" Focusable="False" ClipToBounds="True" />
<Border Grid.Column="7" HorizontalAlignment="Right" Background="{DynamicResource Brush.Card}" Padding="6,0,0,0" Style="{StaticResource Border.RowActions}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Button Style="{StaticResource Button.RowQuick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Sequence}"
Command="{Binding DataContext.OpenItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Library.Open}" AutomationProperties.Name="{l:Loc Library.Action.Open}" />
<Button Style="{StaticResource Button.RowQuick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Analyse}"
Command="{Binding DataContext.AnalyseItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding AnalyseToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Analyse}" />
<Button Style="{StaticResource Button.RowQuick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Render}"
Command="{Binding DataContext.RenderItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding RenderToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Render}" />
<Button Style="{StaticResource Button.RowQuick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Sync}"
Command="{Binding DataContext.SyncItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding SyncToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Sync}" />
</StackPanel>
</Border>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
<!-- Empty states: one sentence plus the first actions (Components.html). -->
<ui:EmptyState Grid.Row="2" Grid.ColumnSpan="2" Message="{l:Loc Library.Empty}" Visibility="{Binding IsLibraryEmpty, Converter={StaticResource BoolToVisibility}}">
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Library.Empty.ImportCard}" Command="{Binding ImportCardCommand}" ToolTip="{l:Loc Tooltips.Library.ImportCard}" Margin="0,0,8,0" />
<Button Content="{l:Loc Library.Empty.Adopt}" Command="{Binding AdoptFolderCommand}" ToolTip="{l:Loc Tooltips.Library.Adopt}" Margin="0,0,8,0" />
<Button Content="{l:Loc Library.Empty.Connect}" Command="{Binding ConnectCommand}" ToolTip="{l:Loc Tooltips.Library.Connect}" />
</StackPanel>
</ui:EmptyState>
<ui:EmptyState Grid.Row="2" Grid.ColumnSpan="2" Message="{l:Loc Library.NoMatch}" Visibility="{Binding IsNoMatch, Converter={StaticResource BoolToVisibility}}">
<Button Content="{l:Loc Library.ClearFilters}" Command="{Binding ClearFiltersCommand}" ToolTip="{l:Loc Tooltips.Library.ClearFilters}" />
</ui:EmptyState>
<!-- One sequence selected in the grid or the timeline: its details (320 px, DESIGN §3). -->
<Border Grid.Row="2" Grid.Column="1" Width="320" Margin="0,4,20,12" Style="{StaticResource Border.Panel}" Padding="16"
Visibility="{Binding ShowsDetails, Converter={StaticResource BoolToVisibility}}">
<ScrollViewer VerticalScrollBarVisibility="Auto" Focusable="False" DataContext="{Binding Selected}">
<StackPanel>
<v:AspectRatioDecorator>
<Border CornerRadius="6" Background="{DynamicResource Brush.Preview}">
<Border CornerRadius="6">
<Border.Background>
<ImageBrush ImageSource="{Binding Thumbnail}" Stretch="UniformToFill" />
</Border.Background>
</Border>
</Border>
</v:AspectRatioDecorator>
<TextBlock Text="{Binding Title}" Style="{StaticResource Text.Title}" Margin="0,12,0,0" TextWrapping="Wrap" TextTrimming="None" />
<ItemsControl ItemsSource="{Binding Statuses}" ItemTemplate="{StaticResource Template.Status}" ItemsPanel="{StaticResource Panel.Row}" Margin="0,6,0,0" Focusable="False" />
<Grid Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="24" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Style="{StaticResource Text.Label}" Text="{l:Loc Library.Column.Date}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding DateText}" />
<TextBlock Grid.Row="1" Style="{StaticResource Text.Label}" Text="{l:Loc Library.Column.Frames}" />
<TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding FramesText}" />
<TextBlock Grid.Row="2" Style="{StaticResource Text.Label}" Text="{l:Loc Library.Column.Span}" />
<TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding SpanText}" />
<TextBlock Grid.Row="3" Style="{StaticResource Text.Label}" Text="{l:Loc Library.Column.Interval}" />
<TextBlock Grid.Row="3" Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding IntervalText}" />
<TextBlock Grid.Row="4" Style="{StaticResource Text.Label}" Text="{l:Loc Library.Column.Camera}" />
<TextBlock Grid.Row="4" Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Camera}" />
<TextBlock Grid.Row="5" Style="{StaticResource Text.Label}" Text="{l:Loc Library.Column.Size}" />
<TextBlock Grid.Row="5" Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding SizeText}" />
<TextBlock Grid.Row="6" Style="{StaticResource Text.Label}" Text="{l:Loc Library.Column.Folder}" VerticalAlignment="Top" Margin="0,4,14,0" />
<!-- A folder path reads left to right in every language. -->
<TextBlock Grid.Row="6" Grid.Column="1" Text="{Binding Sequence.Folder}" TextWrapping="Wrap" Margin="0,4,0,0" FlowDirection="LeftToRight"
HorizontalAlignment="Left" />
<TextBlock Grid.Row="7" Style="{StaticResource Text.Label}" Text="{l:Loc Library.Column.Tags}" VerticalAlignment="Top" Margin="0,8,14,0" />
<TextBlock Grid.Row="7" Grid.Column="1" Text="{Binding TagsText}" TextWrapping="Wrap" Margin="0,8,0,0" />
</Grid>
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Library.Action.Open}" HorizontalAlignment="Stretch" Margin="0,18,0,0"
Command="{Binding DataContext.OpenCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" ToolTip="{l:Loc Tooltips.Library.Open}" />
<WrapPanel Margin="0,8,0,0">
<Button Content="{l:Loc Library.Action.Render}" Command="{Binding DataContext.RenderItemCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
CommandParameter="{Binding}" ToolTip="{Binding RenderToolTip}" ui:ButtonIcon.Glyph="{StaticResource Icon.Render}" Margin="0,0,8,8" />
<Button Content="{l:Loc Library.Action.Folder}" Command="{Binding DataContext.RevealCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
ToolTip="{Binding DataContext.RevealToolTip, RelativeSource={RelativeSource AncestorType=UserControl}}" ui:ButtonIcon.Glyph="{StaticResource Icon.FolderOpen}"
Margin="0,0,8,8" />
</WrapPanel>
</StackPanel>
</ScrollViewer>
</Border>
<!--
Mass actions bar on the selection (BRIEF §12.2): each button disabled with its reason when it cannot run on it.
Delete… stands apart at the far right (Archive.html), the destructive action last.
-->
<Border Grid.Row="3" Grid.ColumnSpan="2" Style="{StaticResource Border.Panel}" Padding="14,8,6,0" Margin="20,0,20,12" MinHeight="48"
Visibility="{Binding HasSelection, Converter={StaticResource BoolToVisibility}}">
<!-- Delete… last in the tab order too. -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="{Binding SelectionTitle}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="0,0,8,8" Typography.NumeralAlignment="Tabular" />
<TextBlock Text="{Binding SelectionSummary}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Margin="0,0,12,8"
Typography.NumeralAlignment="Tabular" />
<Border Width="1" Height="22" Background="{DynamicResource Brush.Stroke}" Margin="0,0,12,8" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Analyse}" Command="{Binding AnalyseCommand}" ToolTip="{Binding AnalyseToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Proxies}" Command="{Binding ProxiesCommand}" ToolTip="{Binding ProxiesToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Verify}" Command="{Binding VerifyCommand}" ToolTip="{Binding VerifyToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Tag}" Command="{Binding TagCommand}" ToolTip="{Binding TagToolTip}" />
<Button Style="{StaticResource Button.Bar}" Click="OnOpenMenu" IsEnabled="{Binding CanRate}" ToolTip="{Binding RateToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Rate}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Library.Action.Rate}" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu ItemsSource="{Binding RatingChoices}" ItemContainerStyle="{StaticResource MenuItem.Rating}" />
</Button.ContextMenu>
</Button>
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Move}" Command="{Binding MoveCommand}" ToolTip="{Binding MoveToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Upload}" Command="{Binding UploadCommand}" ToolTip="{Binding UploadToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Download}" Command="{Binding DownloadCommand}" ToolTip="{Binding DownloadToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.ExportList}" Command="{Binding ExportListCommand}" ToolTip="{Binding ExportListToolTip}" />
<Button Style="{StaticResource Button.Subtle}" Height="30" Margin="0,0,8,8" Content="{l:Loc Library.Action.ClearSelection}" Command="{Binding ClearSelectionCommand}"
ToolTip="{l:Loc Tooltips.Library.ClearSelection}" />
</WrapPanel>
<Button Grid.Column="1" Style="{StaticResource Button.Destructive}" Height="30" Margin="8,0,8,8" VerticalAlignment="Top"
Content="{l:Loc Library.Action.Delete}" Command="{Binding DeleteCommand}" ToolTip="{Binding DeleteToolTip}" />
</Grid>
</Border>
</Grid>
<!-- In-window dialogs (tags, move, view name, delete) over a scrim; the keyboard stays inside the dialog. -->
<Grid Visibility="{Binding IsDialogOpen, Converter={StaticResource BoolToVisibility}}" KeyboardNavigation.TabNavigation="Cycle"
KeyboardNavigation.ControlTabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Contained">
<Border Background="{DynamicResource Brush.Scrim}" />
<ContentPresenter x:Name="DialogHost" Content="{Binding Dialog}" Margin="20" />
</Grid>
</Grid>
</UserControl>
@@ -0,0 +1,81 @@
using System.ComponentModel;
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 Chronos.App.Library;
using Chronos.Ui.Visuals;
namespace Chronos.App.Sections;
public partial class LibraryView : UserControl
{
public LibraryView()
{
InitializeComponent();
DataContextChanged += OnDataContextChanged;
}
private LibraryViewModel? Model => DataContext as LibraryViewModel;
/// <summary>Loads the next page when the grid or the list scrolls within two screens of its end.</summary>
private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (Model is not { } vm || e.ExtentHeight <= 0) return;
if (e.VerticalOffset + e.ViewportHeight >= e.ExtentHeight - 2 * Math.Max(e.ViewportHeight, 200)) _ = vm.LoadMoreAsync();
}
/// <summary>
/// A double-click on a card or a row opens its sequence (the left button only; not on one of its own buttons, which act
/// on their own).
/// </summary>
private void OnItemDoubleClick(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton != MouseButton.Left || sender is not ListBoxItem { DataContext: SequenceItem item } container || Model is not { } vm) return;
for (var node = Mouse.DirectlyOver as DependencyObject; node is not null && !ReferenceEquals(node, container); node = VisualTreeHelper.GetParent(node))
{
if (node is ButtonBase) return;
}
if (vm.OpenItemCommand.CanExecute(item)) vm.OpenItemCommand.Execute(item);
e.Handled = true;
}
/// <summary>A month of the timeline: the Library narrows to its year and the grid scrolls to it.</summary>
private void OnSlotActivated(object sender, ChartItemEventArgs e) => Model?.ShowSlot(e.Row, e.Column);
/// <summary>"Saved views" and "Rate ▾" open their menu under themselves.</summary>
private void OnOpenMenu(object sender, RoutedEventArgs e)
{
if (sender is not Button { ContextMenu: { } menu } button) return;
menu.DataContext = DataContext;
menu.PlacementTarget = button;
menu.Placement = PlacementMode.Bottom;
menu.IsOpen = true;
}
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.OldValue is LibraryViewModel old)
{
old.ScrollRequested -= OnScrollRequested;
old.PropertyChanged -= OnModelChanged;
}
if (e.NewValue is LibraryViewModel model)
{
model.ScrollRequested += OnScrollRequested;
model.PropertyChanged += OnModelChanged;
}
}
private void OnScrollRequested(SequenceItem item) =>
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () => CardGrid.ScrollIntoView(item));
/// <summary>A dialog that opens takes the keyboard: its first field or button.</summary>
private void OnModelChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != nameof(LibraryViewModel.Dialog) || Model?.Dialog is null || !IsVisible) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,105 @@
<UserControl x:Class="Chronos.App.Sections.SequencePickerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:v="clr-namespace:Chronos.Ui.Visuals;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:lib="clr-namespace:Chronos.App.Library"
IsVisibleChanged="OnVisibleChanged">
<!--
The sequence picker of Edit (owner review 1, R7), over the section's view model: one searchable list of this PC's and
the server's sequences, newest first; Enter or a double-click opens one, Esc clears the search and then goes back to
the open sequence. Each row reads as its title to screen readers; the date, frames and states columns are as wide as
their widest row, so the states are never cut.
-->
<UserControl.Resources>
<DataTemplate x:Key="Template.Status" DataType="{x:Type v:CardStatus}">
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ToolTip}" Margin="0,0,8,0" />
</DataTemplate>
<ItemsPanelTemplate x:Key="Panel.Row">
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
<!-- A double-click is read on the row itself: the row takes the mouse-down to select, so a gesture on the list never sees it. -->
<Style x:Key="ListBoxItem.PickerRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<EventSetter Event="MouseDoubleClick" Handler="OnRowDoubleClick" />
</Style>
</UserControl.Resources>
<Border Style="{StaticResource Border.Panel}" MaxWidth="880" Margin="16,24,16,16">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="56" />
<RowDefinition Height="Auto" />
<RowDefinition Height="6" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<DockPanel Margin="16,0">
<TextBlock DockPanel.Dock="Left" Text="{l:Loc Editor.Picker.Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" Margin="0,0,16,0"
TextTrimming="CharacterEllipsis" MaxWidth="220" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Common.Open}" Command="{Binding Picker.OpenCommand}"
ToolTip="{l:Loc Tooltips.Editor.Picker.Open}" ToolTipService.ShowOnDisabled="True" VerticalAlignment="Center" Margin="8,0,0,0" />
<Button DockPanel.Dock="Right" Content="{l:Loc Editor.Picker.Cancel}" Command="{Binding CancelPickCommand}" ToolTip="{Binding CancelPickToolTip}"
VerticalAlignment="Center" Margin="8,0,0,0" Visibility="{Binding CanCancelPick, Converter={StaticResource BoolToVisibility}}" />
<TextBox x:Name="Search" MaxWidth="360" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Picker.SearchText, UpdateSourceTrigger=PropertyChanged}"
ui:Field.Glyph="{StaticResource Icon.Search}" ui:Field.Placeholder="{l:Loc Library.Search}" ToolTip="{l:Loc Tooltips.Editor.Picker.Search}"
AutomationProperties.Name="{l:Loc Library.Search}" PreviewKeyDown="OnSearchKeyDown" />
</DockPanel>
<!-- A server sequence chosen without its proxies here: they download first, then it opens. -->
<DockPanel Grid.Row="1" Margin="16,0,16,8" Visibility="{Binding FetchingText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Link}" Content="{l:Loc Shell.Nav.Jobs}" Command="{Binding OpenJobsCommand}"
ToolTip="{l:Loc Tooltips.Nav.Jobs}" Margin="8,0,0,0" VerticalAlignment="Center" />
<ui:StatusGlyph Kind="Running" Text="{Binding FetchingText}" ToolTip="{Binding FetchingText}" VerticalAlignment="Center" />
</DockPanel>
<ProgressBar Grid.Row="2" Margin="16,0" Height="6" IsIndeterminate="True" Visibility="{Binding Picker.IsLoading, Converter={StaticResource BoolToVisibility}}"
AutomationProperties.Name="{l:Loc Editor.Picker.Loading}" />
<ListBox x:Name="List" Grid.Row="3" Margin="0,4,0,8" ItemsSource="{Binding Picker.Items}" SelectedItem="{Binding Picker.Selected}" SelectionMode="Single"
ItemContainerStyle="{StaticResource ListBoxItem.PickerRow}" TextSearch.TextPath="Title" VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.ScrollChanged="OnScrollChanged" AutomationProperties.Name="{l:Loc Editor.Picker.List}" ToolTip="{l:Loc Tooltips.Editor.Picker.Row}"
KeyboardNavigation.TabNavigation="Continue" Grid.IsSharedSizeScope="True" SelectionChanged="OnSelectionChanged">
<ListBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding Picker.OpenCommand}" />
</ListBox.InputBindings>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type lib:SequenceItem}">
<Grid Height="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="2*" MinWidth="140" />
<ColumnDefinition Width="Auto" MinWidth="84" SharedSizeGroup="PickerDate" />
<ColumnDefinition Width="*" MinWidth="80" />
<ColumnDefinition Width="Auto" MinWidth="56" SharedSizeGroup="PickerFrames" />
<ColumnDefinition Width="Auto" SharedSizeGroup="PickerStates" />
</Grid.ColumnDefinitions>
<!-- Pictures stay left to right in a right-to-left window. -->
<Border Width="64" Height="36" CornerRadius="4" Background="{DynamicResource Brush.Card}" ClipToBounds="True" FlowDirection="LeftToRight"
lib:ThumbnailLoading.Width="64">
<Image Source="{Binding Thumbnail}" Stretch="UniformToFill" />
</Border>
<!-- Cells that may be shortened show their text in their tooltip (an empty camera has none). -->
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Title}" Margin="12,0,0,0" FontWeight="SemiBold" ToolTip="{Binding Title}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding DateText}" Margin="12,0,0,0" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Cell}" Text="{Binding Camera}" Margin="12,0,0,0" Foreground="{DynamicResource Brush.TextMuted}"
ToolTip="{Binding Camera, Converter={x:Static ui:EmptyToNullConverter.Instance}}" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.CellNumber}" Text="{Binding FramesText}" Margin="12,0,0,0" />
<ItemsControl Grid.Column="5" Margin="12,0,0,0" ItemsSource="{Binding Statuses}" ItemTemplate="{StaticResource Template.Status}"
ItemsPanel="{StaticResource Panel.Row}" VerticalAlignment="Center" Focusable="False" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ui:EmptyState Grid.Row="3" Message="{l:Loc Library.Empty}" Visibility="{Binding Picker.IsEmptyLibrary, Converter={StaticResource BoolToVisibility}}">
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Shell.Nav.Import}" Command="{Binding OpenImportCommand}" ToolTip="{l:Loc Tooltips.Nav.Import}" />
</ui:EmptyState>
<ui:EmptyState Grid.Row="3" Message="{l:Loc Editor.Picker.NoMatch}" Visibility="{Binding Picker.IsNoMatch, Converter={StaticResource BoolToVisibility}}">
<Button Content="{l:Loc Editor.Picker.Clear}" Command="{Binding Picker.ClearCommand}" ToolTip="{l:Loc Tooltips.Editor.Picker.Clear}" />
</ui:EmptyState>
</Grid>
</Border>
</UserControl>
@@ -0,0 +1,112 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using Chronos.App.Library;
namespace Chronos.App.Sections;
/// <summary>
/// The picker's keyboard and mouse: the search box takes the focus when the picker shows, ↓ goes to the list, Enter opens
/// the selected sequence (else the first) once the list has caught up with what was typed, Esc clears the search and then
/// goes back to the open sequence; a double-click opens a row. The selected row is always scrolled into view.
/// </summary>
public partial class SequencePickerView : UserControl
{
public SequencePickerView()
{
InitializeComponent();
PreviewKeyDown += OnPreviewKeyDown;
}
private SequenceViewModel? Section => DataContext as SequenceViewModel;
private void OnVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue is not true) return;
Dispatcher.BeginInvoke(() =>
{
if (!IsVisible) return;
// Logical focus first, so the search box has it also in a window that is not active yet.
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(Search), Search);
Keyboard.Focus(Search);
// Selected while the picker was hidden, or before the view existed (arriving in Edit).
if (List.SelectedItem is { } item) List.ScrollIntoView(item);
}, DispatcherPriority.Input);
}
/// <summary>The selected row is in view: the one chosen first when the list loads, after each search, after ↓.</summary>
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (List.SelectedItem is { } item) List.ScrollIntoView(item);
}
/// <summary>A double-click on a row opens it (the left button only).</summary>
private void OnRowDoubleClick(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton != MouseButton.Left || sender is not ListBoxItem { DataContext: SequenceItem item } || Section is not { } section) return;
if (section.Picker.OpenItemCommand.CanExecute(item)) section.Picker.OpenItemCommand.Execute(item);
e.Handled = true;
}
/// <summary>Esc anywhere in the picker: the search first, then back to the open sequence.</summary>
private void OnPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.Escape || Section is not { } section) return;
if (section.Picker.SearchText.Length > 0)
{
section.Picker.SearchText = string.Empty;
e.Handled = true;
}
else if (section.CancelPickCommand.CanExecute(null))
{
section.CancelPickCommand.Execute(null);
e.Handled = true;
}
}
/// <summary>
/// In the search box, Enter opens the selected sequence and ↓ moves to it in the list, both once the list matches what
/// was typed (a key pressed within the search's 250 ms acts on the new list, not on the old one).
/// </summary>
private void OnSearchKeyDown(object sender, KeyEventArgs e)
{
if (Section is not { } section) return;
switch (e.Key)
{
case Key.Enter:
if (section.Picker.SearchOpenCommand.CanExecute(null)) section.Picker.SearchOpenCommand.Execute(null);
e.Handled = true;
break;
case Key.Down:
e.Handled = true;
_ = DownAsync(section);
break;
}
}
private async Task DownAsync(SequenceViewModel section)
{
await section.Picker.SettleAsync();
if (!section.ShowsPicker || section.Picker.Items.Count == 0) return;
section.Picker.Selected ??= section.Picker.Items[0];
FocusSelectedRow();
}
private void FocusSelectedRow()
{
if (List.SelectedItem is not { } item) return;
List.ScrollIntoView(item);
Dispatcher.BeginInvoke(() =>
{
if (List.ItemContainerGenerator.ContainerFromItem(item) is ListBoxItem row) row.Focus();
}, DispatcherPriority.Loaded);
}
/// <summary>The next page when the list nears its end.</summary>
private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (Section is not { } section || e.ExtentHeight <= 0) return;
if (e.VerticalOffset + e.ViewportHeight >= e.ExtentHeight - 2 * Math.Max(e.ViewportHeight, 200)) _ = section.Picker.LoadMoreAsync();
}
}
@@ -0,0 +1,213 @@
using System.Collections.ObjectModel;
using System.Windows.Input;
using System.Windows.Threading;
using Chronos.App.Library;
using Chronos.App.Shell;
using Chronos.Core.Model;
using Chronos.Data;
using Chronos.Data.Repositories;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Sections;
/// <summary>
/// The sequence picker of the Edit section (owner review 1, R7): this PC's sequences and, while signed in, the server's
/// sequences without a copy here, newest first, searched by title, camera or tag as the user types (after 250 ms, like
/// the Library) and read page by page as the list scrolls. One sequence is chosen and opened; when the list loads, the
/// open sequence is selected, else the one edited last (pages are read until it is listed), else the first.
/// </summary>
public sealed class SequencePickerViewModel : LocalizedViewModel
{
private readonly SequenceViewModel _section;
private readonly DispatcherTimer _searchDelay;
private readonly RemoteMerge _merge = new();
private readonly AsyncRelayCommand _open;
private LibraryPager? _pager;
private string _searchText = string.Empty;
private SequenceItem? _selected;
private bool _isLoading;
private bool _hasLoaded;
private Task _loading = Task.CompletedTask;
private int _pageSize = LibraryPager.DefaultPageSize;
/// <summary>Counts reloads, so a reload that a newer one replaced stops reading pages.</summary>
private int _generation;
public SequencePickerViewModel(SequenceViewModel section)
{
_section = section;
_searchDelay = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(250) };
_searchDelay.Tick += (_, _) => _ = ReloadAsync();
_open = new AsyncRelayCommand(() => (Selected ?? Items.FirstOrDefault()) is { } item ? _section.PickAsync(item) : Task.CompletedTask, () => Items.Count > 0);
OpenItemCommand = new AsyncRelayCommand((p, _) => p is SequenceItem item ? _section.PickAsync(item) : Task.CompletedTask);
SearchOpenCommand = new AsyncRelayCommand(OpenFromSearchAsync);
ClearCommand = new RelayCommand(() => SearchText = string.Empty);
}
/// <summary>The sequences listed, in order.</summary>
public ObservableCollection<SequenceItem> Items { get; } = [];
/// <summary>Title, camera or tag text; the list follows a moment after the last key.</summary>
public string SearchText
{
get => _searchText;
set
{
if (!Set(ref _searchText, value ?? string.Empty)) return;
_searchDelay.Stop();
_searchDelay.Start();
}
}
public SequenceItem? Selected
{
get => _selected;
set => Set(ref _selected, value);
}
/// <summary>A page is being read (the thin bar under the toolbar).</summary>
public bool IsLoading
{
get => _isLoading;
private set => Set(ref _isLoading, value);
}
/// <summary>There is no sequence at all: Import is offered.</summary>
public bool IsEmptyLibrary => _hasLoaded && !_isLoading && Items.Count == 0 && string.IsNullOrWhiteSpace(_searchText);
/// <summary>The search matches nothing: Clear search is offered.</summary>
public bool IsNoMatch => _hasLoaded && !_isLoading && Items.Count == 0 && !string.IsNullOrWhiteSpace(_searchText);
/// <summary>The list read last (capture and tests wait for it).</summary>
public Task Loading => _loading;
/// <summary>Opens the selected sequence, else the first listed (Enter).</summary>
public ICommand OpenCommand => _open;
/// <summary>Opens a row (double-click, Enter in the list).</summary>
public ICommand OpenItemCommand { get; }
/// <summary>Enter in the search box: once the list matches what was typed, opens its selected sequence, else its first.</summary>
public ICommand SearchOpenCommand { get; }
public ICommand ClearCommand { get; }
/// <summary>Rows read per page (tests set a small one; the next read uses it).</summary>
internal int PageSize
{
get => _pageSize;
set
{
_pageSize = value;
_pager?.Cancel();
_pager = null;
}
}
private ShellViewModel Shell => _section.Shell;
/// <summary>Reads the list again from its first page (the picker shows, the search changed).</summary>
public Task ReloadAsync()
{
_searchDelay.Stop();
_generation++;
_loading = LoadFirstAsync();
return _loading;
}
/// <summary>Completes once the list matches the search text: a search still waiting for its 250 ms runs now.</summary>
public async Task SettleAsync()
{
if (_searchDelay.IsEnabled) await ReloadAsync();
else await _loading;
}
/// <summary>The next page, when the list scrolled near its end.</summary>
public Task LoadMoreAsync()
{
if (_pager is not { HasMore: true, IsLoading: false }) return Task.CompletedTask;
_loading = ApplyAsync(_pager.LoadMoreAsync(), first: false);
return _loading;
}
public override void Dispose()
{
_searchDelay.Stop();
_pager?.Cancel();
base.Dispose();
}
private async Task OpenFromSearchAsync()
{
await SettleAsync();
if (_section.ShowsPicker && (Selected ?? Items.FirstOrDefault()) is { } item) await _section.PickAsync(item);
}
private async Task LoadFirstAsync()
{
var generation = _generation;
var filter = new LibraryFilter { Text = string.IsNullOrWhiteSpace(_searchText) ? null : _searchText.Trim(), Sort = SequenceSort.Newest };
_merge.Reset(filter, Shell.Library.RemoteSequences);
if (Shell.Services.Database is not { } db)
{
// Still opening: neither "no sequences" nor Import yet (the shell reads the list again once the index is open).
if (Shell.Services.OpenError is null) return;
// No index (it could not open): the server's sequences alone, if any.
await ApplyAsync(Task.FromResult<LibraryPage?>(new LibraryPage(0, [], IsFirst: true, HasMore: false)), first: true);
return;
}
_pager ??= new LibraryPager((q, ct) => db.Sequences.ListAsync(q, ct), PageSize);
await ApplyAsync(_pager.ResetAsync(filter), first: true);
// The sequence to select may be older than the first page: without a search every sequence is listed, newest first,
// so the pages are read until it comes (it exists), then it is selected.
if (filter.Text is not null || Wanted is not { } wanted || Items.Any(i => i.Id == wanted)) return;
if (await db.Sequences.GetAsync(wanted) is null && Shell.Library.RemoteSequences.All(s => s.Id != wanted)) return;
while (generation == _generation && _pager is { HasMore: true } pager && Items.All(i => i.Id != wanted))
await ApplyAsync(pager.LoadMoreAsync(), first: false);
if (generation == _generation) Preselect();
}
private async Task ApplyAsync(Task<LibraryPage?> pending, bool first)
{
IsLoading = true;
RaiseStates();
try
{
if (await pending is not { } page) return;
if (page.IsFirst) Items.Clear();
foreach (var sequence in _merge.Merge(page.Items, last: !page.HasMore))
{
var remote = sequence is { Origin: SequenceOrigin.Server, SyncState: SyncState.RemoteOnly };
Items.Add(new SequenceItem(sequence, remote ? Shell.Library.RemoteThumbnails : Shell.Services.Thumbnails as ISequenceThumbnails));
}
_hasLoaded = true;
if (first) Preselect();
}
catch (Exception ex) when (ex is DatabaseException or InvalidOperationException)
{
Shell.ReportError(ex);
}
finally
{
IsLoading = _pager?.IsLoading ?? false;
RaiseStates();
}
}
/// <summary>The sequence selected first: the open one, else the one edited last.</summary>
private Guid? Wanted => _section.OpenSequenceId ?? Shell.Services.Settings.LastEditedSequence;
/// <summary>The open sequence, else the one edited last, else the first.</summary>
private void Preselect()
{
var wanted = Wanted;
Selected = Items.FirstOrDefault(i => i.Id == wanted) ?? Items.FirstOrDefault();
}
private void RaiseStates()
{
OnPropertyChanged(nameof(IsEmptyLibrary));
OnPropertyChanged(nameof(IsNoMatch));
_open.RaiseCanExecuteChanged();
}
}
+274
View File
@@ -0,0 +1,274 @@
<UserControl x:Class="Chronos.App.Sections.SequenceView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:v="clr-namespace:Chronos.Ui.Visuals;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
xmlns:sections="clr-namespace:Chronos.App.Sections"
KeyDown="OnKeyDown" Loaded="OnLoaded">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Chronos;component/Editor/EditorStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<UserControl.InputBindings>
<!-- Owner review 1, R7: the picker over the open sequence. -->
<KeyBinding Key="O" Modifiers="Control" Command="{Binding ChangeSequenceCommand}" />
</UserControl.InputBindings>
<Grid>
<ProgressBar Width="240" IsIndeterminate="True" VerticalAlignment="Center" Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibility}}"
AutomationProperties.Name="{l:Loc Editor.Loading}" />
<!--
The open sequence stays laid out behind the picker (hidden, not collapsed: collapsing it would shrink the preview
and render it again when it comes back), and while a switch is under way (the progress bar shows).
-->
<Grid x:Name="EditorHost">
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<DataTrigger Binding="{Binding IsPicking}" Value="True">
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
<DataTrigger Binding="{Binding IsLoading}" Value="True">
<Setter Property="Visibility" Value="Hidden" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<!-- Editor.html: header, the step bar, then the preview, filmstrip and the step's measure on the left and its column on the right. -->
<Grid x:Name="EditorRoot" DataContext="{Binding Editor}" Margin="16,0,16,12" IsVisibleChanged="OnEditorVisibleChanged"
PreviewKeyDown="OnEditorPreviewKeyDown" Visibility="{Binding Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<Grid.InputBindings>
<KeyBinding Key="Z" Modifiers="Control" Command="{Binding UndoCommand}" />
<KeyBinding Key="Y" Modifiers="Control" Command="{Binding RedoCommand}" />
<KeyBinding Key="D0" Modifiers="Control" Command="{Binding FitCommand}" />
<KeyBinding Key="D1" Modifiers="Control+Shift" Command="{Binding ActualSizeCommand}" />
<KeyBinding Key="R" Modifiers="Control" Command="{Binding RenderCommand}" />
<KeyBinding Key="A" Modifiers="Control+Shift" Command="{Binding AnalyseCommand}" />
<!-- Steps by number; no Alt+NumPad bindings, which type characters into text fields. -->
<KeyBinding Key="D1" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="1" />
<KeyBinding Key="D2" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="2" />
<KeyBinding Key="D3" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="3" />
<KeyBinding Key="D4" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="4" />
<KeyBinding Key="D5" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="5" />
<KeyBinding Key="D6" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="6" />
<KeyBinding Key="D7" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="7" />
<KeyBinding Key="D8" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="8" />
<KeyBinding Key="D9" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="9" />
</Grid.InputBindings>
<Grid.RowDefinitions>
<RowDefinition Height="52" />
<RowDefinition Height="44" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button Style="{StaticResource Button.IconSubtle}" ui:ButtonIcon.Glyph="{StaticResource Icon.Back}" Command="{Binding BackCommand}"
ToolTip="{l:Loc Tooltips.Editor.Back}" AutomationProperties.Name="{l:Loc Editor.Back}" Margin="-6,0,0,0" />
<!-- The title, where a server sequence edited with proxies lives (read-only or out of date says so) and the summary share what the
server job and the actions leave, and give way first: each ends in an ellipsis. The title chooses another sequence (Ctrl+O): the
picker covers the editor until one opens or Esc. Its tooltip and its accessible name start with the whole title. -->
<DockPanel Grid.Column="1" VerticalAlignment="Center">
<Button x:Name="ChangeSequence" DockPanel.Dock="Left" Style="{StaticResource Button.Title}" Margin="2,0,12,0" MaxWidth="340" Padding="6,0"
Command="{Binding DataContext.ChangeSequenceCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
ToolTip="{Binding ChangeToolTip}" ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{Binding ChangeName}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<ui:Icon Grid.Column="1" Glyph="{StaticResource Icon.ChevronDown}" Size="14" Margin="6,0,0,0" VerticalAlignment="Center"
Foreground="{DynamicResource Brush.TextMuted}" />
</Grid>
</Button>
<ui:StatusGlyph DockPanel.Dock="Left" Kind="Remote" Text="{Binding RemoteText}" ToolTip="{Binding RemoteToolTip}" FontSize="{StaticResource Size.Body}" Margin="0,0,12,0"
MaxWidth="220" VerticalAlignment="Center" Visibility="{Binding IsRemote, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{Binding Summary}" Style="{StaticResource Text.Secondary}" FontSize="{StaticResource Size.Body}" VerticalAlignment="Center"
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{Binding Summary}" />
</DockPanel>
<!-- The server job: its bar, what it is and how far, and Cancel, which always stays (BRIEF §11.5): its own column, so the title gives way
before it at the minimum window. -->
<Grid Grid.Column="2" Margin="12,0,0,0" MaxWidth="300" VerticalAlignment="Center"
Visibility="{Binding ServerJobText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ProgressBar Width="48" Maximum="1" Value="{Binding ServerJobProgress, Mode=OneWay}" VerticalAlignment="Center" Margin="0,0,8,0"
AutomationProperties.Name="{Binding ServerJobText}" Visibility="{Binding HasServerJobProgress, Converter={StaticResource BoolToVisibility}}" />
<ui:StatusGlyph Grid.Column="1" Kind="{Binding ServerJobKind}" Text="{Binding ServerJobText}" ToolTip="{Binding ServerJobToolTip}"
FontSize="{StaticResource Size.Body}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<Button Grid.Column="2" Style="{StaticResource Button.IconSubtle}" Width="26" Height="26" Margin="4,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.Cancel}"
Command="{Binding CancelServerJobCommand}" ToolTip="{Binding CancelServerJobToolTip}" ToolTipService.ShowOnDisabled="True"
AutomationProperties.Name="{l:Loc Editor.ServerJob.Cancel}" />
</Grid>
<StackPanel Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="12,0,0,0">
<Button Content="{l:Loc Editor.Analyse}" Command="{Binding AnalyseCommand}" ToolTip="{Binding AnalyseToolTip}" ToolTipService.ShowOnDisabled="True" />
<Button Content="{l:Loc Editor.OptimiseAll}" Command="{Binding OptimiseAllCommand}" ToolTip="{Binding OptimiseAllToolTip}"
ToolTipService.ShowOnDisabled="True" Margin="12,0,0,0" />
<v:SplitButton x:Name="RenderButton" IsPrimary="True" Margin="12,0,0,0" Content="{Binding RenderText}" Command="{Binding RenderCommand}"
ItemsSource="{Binding RenderChoices}" DisplayMemberPath="Label" SelectedItem="{Binding SelectedRenderChoice}" ToolTip="{Binding RenderToolTip}"
ToolTipService.ShowOnDisabled="True" DropDownToolTip="{Binding RenderChoiceToolTip}"
AutomationProperties.Name="{l:Loc Editor.RenderButton}" />
</StackPanel>
</Grid>
<!-- The path (owner review 1, R7): one row of steps, each with where it stands; any step opens at any time (Alt+n, ←/→ in the bar). -->
<ListBox x:Name="Steps" Grid.Row="1" Style="{StaticResource ListBox.Steps}" ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab}"
ItemContainerStyle="{StaticResource ListBoxItem.Step}" Margin="0,0,0,8" AutomationProperties.Name="{l:Loc Editor.Path}" KeyDown="OnStepsKeyDown"
PreviewKeyDown="OnStepsPreviewKeyDown" PreviewMouseLeftButtonDown="OnStepsPreviewMouseDown" SelectionChanged="OnStepsSelectionChanged" />
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="{StaticResource Editor.Grid.Panel}" />
</Grid.ColumnDefinitions>
<Grid Margin="0,0,16,0">
<Grid.RowDefinitions>
<RowDefinition MinHeight="160">
<RowDefinition.Style>
<Style TargetType="RowDefinition">
<Setter Property="Height" Value="{StaticResource Editor.Grid.Preview}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsTallMeasure}" Value="True">
<Setter Property="Height" Value="{StaticResource Editor.Grid.ExportPreview}" />
</DataTrigger>
</Style.Triggers>
</Style>
</RowDefinition.Style>
</RowDefinition>
<RowDefinition Height="Auto" />
<RowDefinition MinHeight="150">
<RowDefinition.Style>
<Style TargetType="RowDefinition">
<Setter Property="Height" Value="{StaticResource Editor.Grid.Measure}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsTallMeasure}" Value="True">
<Setter Property="Height" Value="{StaticResource Editor.Grid.ExportMeasure}" />
</DataTrigger>
</Style.Triggers>
</Style>
</RowDefinition.Style>
</RowDefinition>
</Grid.RowDefinitions>
<v:PreviewViewport x:Name="Preview" Source="{Binding PreviewImage}" OriginalSource="{Binding OriginalImage}" IsCompareEnabled="{Binding IsCompare}"
WipeLabel="{Binding WipeLabel}" ZoomMode="{Binding ZoomMode, Mode=TwoWay}" ShowVectors="{Binding ViewVectors}"
MotionVectors="{Binding MotionVectors}" VectorScale="{Binding VectorScale}" ShowRegions="{Binding ViewRegions}"
RegionBoundary="{Binding RegionBoundary}" ShowCropMask="{Binding ShowCropMask}" CropRect="{Binding CropRect}"
CropMaskMode="{Binding CropMaskMode}" InfoText="{Binding InfoText}" ToolTip="{l:Loc Tooltips.Editor.Preview.View}"
AutomationProperties.Name="{l:Loc Editor.Preview}" SizeChanged="OnPreviewSizeChanged">
<v:PreviewViewport.ToolsContent>
<!-- Tools give the keyboard back to the preview after a click, so Space keeps playing (OnToolClicked). They take a second
line rather than lose Play and Full screen where long labels meet a narrow preview (1200 px, 200 px rail). -->
<WrapPanel ButtonBase.Click="OnToolClicked" Margin="0,0,0,-6">
<ToggleButton Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding IsCompare}" ui:ButtonIcon.Glyph="{StaticResource Icon.Compare}"
Content="{l:Loc Editor.Preview.Compare}" ToolTip="{l:Loc Tooltips.Editor.Preview.Compare}" />
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
IsChecked="{Binding ShowVectors}" ui:ButtonIcon.Glyph="{StaticResource Icon.Vectors}" Content="{l:Loc Editor.Preview.Vectors}"
ToolTip="{l:Loc Tooltips.Editor.Preview.Vectors}" />
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
IsChecked="{Binding ShowRegions}" ui:ButtonIcon.Glyph="{StaticResource Icon.Regions}" Content="{l:Loc Editor.Preview.Regions}"
ToolTip="{l:Loc Tooltips.Editor.Preview.Regions}" />
<ToggleButton Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding ShowCropMask}" ui:ButtonIcon.Glyph="{StaticResource Icon.CropMask}"
Content="{l:Loc Editor.Preview.CropMask}" ToolTip="{l:Loc Tooltips.Editor.Preview.CropMask}" />
<!-- "What I lose" (dimmed) or "how it will look" (hidden) outside the crop (BRIEF §12.3), beside the mask and always there (disabled
while the mask is off), so turning the mask on never moves the other tools to another line. -->
<ToggleButton Style="{StaticResource ToggleButton.PreviewToolIcon}" IsChecked="{Binding IsCropResult}" IsEnabled="{Binding ShowCropMask}"
ui:ButtonIcon.Glyph="{StaticResource Icon.Eye}" ToolTip="{Binding CropModeToolTip}" ToolTipService.ShowOnDisabled="True"
AutomationProperties.Name="{l:Loc Editor.Preview.CropResult}" />
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
IsChecked="{Binding IsActualSize}" Content="{l:Loc Editor.Preview.ActualSize}" ToolTip="{l:Loc Tooltips.Editor.Preview.OneToOne}" />
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PreviewToolIcon}"
ui:ButtonIcon.Glyph="{StaticResource Icon.Fullscreen}" Click="OnFullScreen" ToolTip="{l:Loc Tooltips.Editor.Preview.FullScreen}"
AutomationProperties.Name="{l:Loc Editor.Preview.FullScreen}" />
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PlayTool}"
Command="{Binding PlayCommand}" ToolTip="{Binding PlayToolTip}" AutomationProperties.Name="{Binding PlayName}" />
<Button Content="{l:Loc Editor.Preview.Clip}" Command="{Binding PreviewClipCommand}" ToolTip="{Binding ClipToolTip}"
Visibility="{Binding IsExportTab, Converter={StaticResource BoolToVisibility}}">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource Button.PreviewTool}">
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Play}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsPlaying}" Value="True">
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Pause}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</WrapPanel>
</v:PreviewViewport.ToolsContent>
</v:PreviewViewport>
<!-- The frame on screen cannot be read: one sentence instead of another frame's picture. -->
<TextBlock Text="{Binding PreviewMessage}" Style="{StaticResource Text.Secondary}" HorizontalAlignment="Center" VerticalAlignment="Center"
IsHitTestVisible="False" Visibility="{Binding PreviewMessage, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<v:Filmstrip Grid.Row="1" Margin="0,10,0,0" Source="{Binding Thumbnails}" CurrentIndex="{Binding CurrentIndex, Mode=TwoWay}" Markers="{Binding Markers}"
ToolTip="{l:Loc Tooltips.Editor.Filmstrip}" AutomationProperties.Name="{l:Loc Editor.Filmstrip}" />
<!-- The step's measuring tool. -->
<ContentControl x:Name="StepMeasure" Grid.Row="2" Content="{Binding SelectedTab}" Focusable="False">
<ContentControl.Resources>
<ResourceDictionary Source="pack://application:,,,/Chronos;component/Editor/EditorMeasures.xaml" />
</ContentControl.Resources>
</ContentControl>
</Grid>
<!-- The step's column, then Previous · 3 / 8 · Next. -->
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ContentControl x:Name="StepPanel" Content="{Binding SelectedTab}" Focusable="False">
<ContentControl.Resources>
<ResourceDictionary Source="pack://application:,,,/Chronos;component/Editor/EditorPanels.xaml" />
</ContentControl.Resources>
</ContentControl>
<!-- Both buttons are measured whole (the longest "Next sequence" fits the 320 px column in every language); the counter takes
what they leave and gives way first. -->
<Grid Grid.Row="1" Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button x:Name="PreviousStep" ui:ButtonIcon.Glyph="{StaticResource Icon.ChevronLeft}" Content="{l:Loc Editor.Step.Previous}"
Command="{Binding PreviousStepCommand}" ToolTip="{Binding PreviousToolTip}" ToolTipService.ShowOnDisabled="True" />
<!-- The step counter says each step change to screen readers ("Step 3 of 8: Exposure, Auto"). -->
<TextBlock Grid.Column="1" Text="{Binding StepCounter}" Style="{StaticResource Text.Secondary}" VerticalAlignment="Center" HorizontalAlignment="Center"
Margin="8,0" TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" infra:LiveRegion.Text="{Binding StepAnnouncement}"
AutomationProperties.LiveSetting="Polite" />
<Button x:Name="NextStep" Grid.Column="2" Command="{Binding NextStepCommand}" ToolTip="{Binding NextToolTip}" ToolTipService.ShowOnDisabled="True"
AutomationProperties.Name="{Binding NextText}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding NextText}" VerticalAlignment="Center" />
<ui:Icon Glyph="{StaticResource Icon.ChevronRight}" Size="14" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
</Button>
</Grid>
</Grid>
</Grid>
</Grid>
</Grid>
<!-- The picker (owner review 1, R7): without an open sequence, or over it after Change sequence. -->
<sections:SequencePickerView x:Name="Picker" Visibility="{Binding ShowsPicker, Converter={StaticResource BoolToVisibility}}" />
</Grid>
</UserControl>
@@ -0,0 +1,221 @@
using System.ComponentModel;
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 Chronos.App.Editor;
using Chronos.App.Shell;
using Chronos.Core.Diagnostics;
namespace Chronos.App.Sections;
public partial class SequenceView : UserControl
{
/// <summary>Set on a window once its closing waits for the editor's last save.</summary>
private static readonly DependencyProperty SavesBeforeClosingProperty =
DependencyProperty.RegisterAttached("SavesBeforeClosing", typeof(bool), typeof(SequenceView), new PropertyMetadata(false));
public SequenceView()
{
InitializeComponent();
// A drag, a click or a key press is one undo step even when it moves a slider many times (ProjectHistory runs);
// handled events too, because sliders and repeat buttons mark theirs handled.
EditorRoot.AddHandler(Thumb.DragCompletedEvent, new DragCompletedEventHandler((_, _) => EndEditRun()), handledEventsToo: true);
EditorRoot.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler((_, _) => EndEditRun()), handledEventsToo: true);
EditorRoot.AddHandler(KeyUpEvent, new KeyEventHandler((_, _) => EndEditRun()), handledEventsToo: true);
EditorRoot.IsKeyboardFocusWithinChanged += OnEditorFocusWithinChanged;
}
private EditorViewModel? Editor => (DataContext as SequenceViewModel)?.Editor;
/// <summary>The picker covers the open sequence: its keys are the picker's.</summary>
private bool IsPicking => (DataContext as SequenceViewModel)?.IsPicking == true;
/// <summary>
/// Ctrl+PgDn and Ctrl+PgUp move one step along the path (owner review 1, R7); null for any other key. They are read as
/// the key goes down the tree, because the filmstrip and the curve editors take Page Up and Page Down whatever the
/// modifiers.
/// </summary>
internal static int? StepDelta(Key key, ModifierKeys modifiers) => modifiers != ModifierKeys.Control ? null : key switch
{
Key.PageDown => 1,
Key.PageUp => -1,
_ => null,
};
/// <summary>
/// The project is saved a moment after each edit; closing the window first stores the last edit, and asks before
/// discarding one that cannot be stored (once per window, so it holds even when another section is showing).
/// </summary>
private void OnLoaded(object sender, RoutedEventArgs e)
{
FocusPreview();
if (Window.GetWindow(this) is not { } window || (bool)window.GetValue(SavesBeforeClosingProperty)) return;
window.SetValue(SavesBeforeClosingProperty, true);
var (saved, asking, closed) = (false, false, false);
window.Closing += OnClosing;
window.Closed += (_, _) => closed = true;
async void OnClosing(object? s, CancelEventArgs args)
{
if (saved || args.Cancel || window.DataContext is not ShellViewModel { Sequence: { HasPendingSave: true } section }) return;
args.Cancel = true;
if (asking) return;
asking = true;
var close = true;
try
{
close = await section.ConfirmCloseAsync();
if (close) await section.CloseAsync();
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning("editor", "The last edit was not saved before closing", ex);
}
finally
{
asking = false;
}
// "Keep editing": the window stays open with the edit still pending.
if (!close) return;
saved = true;
// An application shutdown closes the window without waiting.
if (!closed) window.Close();
}
}
/// <summary>
/// Space plays or pauses, arrows step a frame (BRIEF §12.3) — unless a text field or a control that uses the key has
/// it, or the picker covers the editor.
/// </summary>
private void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Handled || IsPicking || Editor is not { } editor || Keyboard.Modifiers != ModifierKeys.None || e.OriginalSource is TextBoxBase) return;
var command = e.Key switch
{
Key.Space => editor.PlayCommand,
Key.Left => editor.StepBackCommand,
Key.Right => editor.StepForwardCommand,
_ => null,
};
if (command is null) return;
command.Execute(null);
e.Handled = true;
}
/// <summary>Ctrl+PgDn and Ctrl+PgUp: the next and the previous step, stopping at the ends.</summary>
private void OnEditorPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Handled || Editor is not { } editor || StepDelta(e.Key, Keyboard.Modifiers) is not { } delta) return;
editor.MoveStep(delta);
e.Handled = true;
}
/// <summary>The arrows move between steps while the step bar has the keyboard; at either end they do nothing else (no frame step).</summary>
private void OnStepsKeyDown(object sender, KeyEventArgs e)
{
if (e.Key is Key.Left or Key.Right or Key.Up or Key.Down) e.Handled = true;
}
/// <summary>
/// On the step shown, Space plays or pauses as everywhere in the editor (the list would only select the step again), and
/// Ctrl+Space does nothing (the list would leave the bar without a current step). Read on the way down, before the list.
/// </summary>
private void OnStepsPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.Space || IsPicking || Editor is not { } editor || e.OriginalSource is not ListBoxItem { IsSelected: true }) return;
if (Keyboard.Modifiers == ModifierKeys.None) editor.PlayCommand.Execute(null);
e.Handled = Keyboard.Modifiers is ModifierKeys.None or ModifierKeys.Control;
}
/// <summary>Ctrl+click on the step shown keeps it the current one (a list would unselect it).</summary>
private void OnStepsPreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if ((Keyboard.Modifiers & ModifierKeys.Control) == 0
|| ItemsControl.ContainerFromElement(Steps, e.OriginalSource as DependencyObject) is not ListBoxItem { IsSelected: true } item) return;
item.Focus();
e.Handled = true;
}
/// <summary>
/// After a step change (Alt+n, Ctrl+PgUp/PgDn, Previous/Next, a step's own button) the keyboard stays in the editor: when
/// it was in the step bar, on a control of the step that is about to be replaced, or on Previous about to be disabled
/// on the first step, it goes to the new step's cell; otherwise it stays where it is.
/// </summary>
private void OnStepsSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!ReferenceEquals(e.OriginalSource, Steps) || IsPicking || Editor is not { } editor || e.AddedItems.Count == 0) return;
if (Window.GetWindow(this) is not { } window || FocusManager.GetFocusedElement(window) is not DependencyObject focused) return;
var follows = Steps.IsAncestorOf(focused) || StepMeasure.IsAncestorOf(focused) || StepPanel.IsAncestorOf(focused)
|| (ReferenceEquals(focused, PreviousStep) && editor.SelectedTab.Number == 1);
if (!follows) return;
// After the step's templates are swapped and the commands re-read (Background), so the cell is laid out and nothing takes it back;
// logical focus too, so a window that is not active gives the keyboard to the cell when it is activated.
Dispatcher.BeginInvoke(() =>
{
if (Editor is not { } current || Steps.ItemContainerGenerator.ContainerFromItem(current.SelectedTab) is not ListBoxItem { IsVisible: true } cell) return;
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(cell), cell);
Keyboard.Focus(cell);
}, DispatcherPriority.Background);
}
/// <summary>An opened editor takes the keyboard, so its shortcuts work without clicking into it first.</summary>
private void OnEditorVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue is true) FocusPreview();
}
/// <summary>
/// The focused control left the editor's tree or was disabled (a control of a step replaced by another, a button whose
/// command stopped applying): the keyboard fell to the window, where none of the editor's shortcuts are, so the preview
/// takes it back. A deliberate move out of the editor (the rail, a toast, another window) is left alone.
/// </summary>
private void OnEditorFocusWithinChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue is true) return;
// After WPF has re-evaluated the focus (Input), which is what raised this.
Dispatcher.BeginInvoke(() =>
{
if (Window.GetWindow(this) is { IsActive: true } window && ReferenceEquals(Keyboard.FocusedElement, window) && EditorRoot.IsVisible && !IsPicking && Editor is not null)
Keyboard.Focus(Preview);
}, DispatcherPriority.Background);
}
/// <summary>A tool clicked with the mouse hands the keyboard back to the preview (Space keeps playing); keyboard users keep their focus.</summary>
private void OnToolClicked(object sender, RoutedEventArgs e)
{
if (InputManager.Current.MostRecentInputDevice is MouseDevice) Preview.Focus();
}
private void FocusPreview()
{
if (Editor is null || IsPicking) return;
Dispatcher.BeginInvoke(() =>
{
// Back from the picker, the focus is still in it (now hidden): the preview takes it.
if (Preview.IsVisible && (!IsKeyboardFocusWithin || Picker.IsKeyboardFocusWithin)) Keyboard.Focus(Preview);
}, DispatcherPriority.Input);
}
private void EndEditRun() => Editor?.Session.EndEditRun();
/// <summary>The preview renders at the size it is shown, in device pixels.</summary>
private void OnPreviewSizeChanged(object sender, SizeChangedEventArgs e)
{
if (Editor is not { } editor) return;
var scale = VisualTreeHelper.GetDpi(this).DpiScaleX;
editor.PreviewEdge = (int)(double.Max(e.NewSize.Width, e.NewSize.Height) * scale);
}
private void OnFullScreen(object sender, RoutedEventArgs e)
{
if (Editor is not { } editor) return;
var restore = editor.PreviewEdge;
var window = new FullScreenPreview(editor) { Owner = Window.GetWindow(this) };
window.ShowDialog();
editor.PreviewEdge = restore;
Preview.Focus();
}
}
@@ -0,0 +1,530 @@
using System.ComponentModel;
using System.Net;
using System.Windows.Input;
using System.Windows.Threading;
using Chronos.App.Editor;
using Chronos.App.Infrastructure;
using Chronos.App.Library;
using Chronos.App.Shell;
using Chronos.Core.Diagnostics;
using Chronos.Core.Export;
using Chronos.Core.Imaging.Decoders;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Data.Jobs;
using Chronos.Data.Sync;
using Chronos.Protocol.Client;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Sections;
/// <summary>
/// The Edit section (BRIEF §12.3; owner review 1, R7, formerly Sequence): opens the sequence the Library, Jobs, the
/// Server screen or its own picker chose into an <see cref="EditorViewModel"/> (from this PC's archive, or a server
/// sequence with this PC's proxies). The next sequence is read first; only then does the open one close, after its
/// last edit is stored. Without a sequence, or after Change sequence, it shows the picker (the editor stays open behind
/// it until another sequence opens). A server sequence whose proxies are missing or out of date fetches them first and
/// opens once they are here, the open sequence staying open meanwhile. A failed open is reported once and leaves the
/// open sequence open; an edit that cannot be saved is never dropped without the user's confirmation, and never written
/// after they chose to drop it. The step each sequence showed is kept for the rest of the run.
/// </summary>
public sealed class SequenceViewModel : SectionViewModel
{
private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;
private readonly Dictionary<Guid, StepMemory> _steps = [];
private EditorViewModel? _editor;
private Guid? _openId;
private bool _isLoading;
private bool _isPicking;
private bool _showsPicker = true;
/// <summary>The shell's <see cref="ShellViewModel.SequenceRequests"/> this section has answered.</summary>
private int _seenRequests;
private Task _switch = Task.CompletedTask;
private ProxyFetch? _fetch;
public SequenceViewModel(ShellViewModel shell)
: base(SectionKey.Edit, "Icon.Sequence")
{
Shell = shell;
Picker = new SequencePickerViewModel(this);
OpenImportCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Import));
OpenJobsCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Jobs));
ChangeSequenceCommand = new RelayCommand(() => IsPicking = true, () => _editor is not null && !_isLoading && !_isPicking);
CancelPickCommand = new RelayCommand(KeepOpenSequence, () => CanCancelPick);
shell.PropertyChanged += OnShellChanged;
}
public ShellViewModel Shell { get; }
/// <summary>The list the next sequence is chosen from.</summary>
public SequencePickerViewModel Picker { get; }
/// <summary>Import, from the picker of an empty library.</summary>
public ICommand OpenImportCommand { get; }
/// <summary>The Jobs screen, from the picker's line about proxies on their way.</summary>
public ICommand OpenJobsCommand { get; }
/// <summary>
/// Shows the picker over the open sequence (Ctrl+O, the title's ▾, Next on the last step); the editor is not closed and
/// its changes keep being saved as usual.
/// </summary>
public ICommand ChangeSequenceCommand { get; }
/// <summary>Hides the picker again, back to the open sequence (Esc); a server sequence chosen meanwhile no longer opens over it.</summary>
public ICommand CancelPickCommand { get; }
/// <summary>The open sequence; null shows the picker.</summary>
public EditorViewModel? Editor
{
get => _editor;
private set
{
if (!Set(ref _editor, value)) return;
// A sequence that opens ends the choice.
if (value is not null)
{
_isPicking = false;
OnPropertyChanged(nameof(IsPicking));
Picker.SearchText = string.Empty;
}
OnPropertyChanged(nameof(Title));
OnPickerChanged();
}
}
/// <summary>The id of the open sequence; null when none is open.</summary>
public Guid? OpenSequenceId => _editor is null ? null : _openId;
public bool IsLoading
{
get => _isLoading;
private set
{
if (Set(ref _isLoading, value)) OnPickerChanged();
}
}
/// <summary>The picker shows over the open sequence, which stays laid out behind it.</summary>
public bool IsPicking
{
get => _isPicking;
private set
{
if (!Set(ref _isPicking, value)) return;
OnPropertyChanged(nameof(Title));
OnPickerChanged();
}
}
/// <summary>The picker is on screen: no sequence is open, or another is being chosen.</summary>
public bool ShowsPicker => _showsPicker;
/// <summary>An open sequence waits behind the picker, so Cancel (Esc) goes back to it; not while a switch is under way.</summary>
public bool CanCancelPick => _isPicking && _editor is not null && !_isLoading;
public string? CancelPickToolTip => _editor is { } editor ? Loc.L("Tooltips.Editor.Picker.Cancel", editor.Title) : null;
/// <summary>The server sequence whose proxies are on their way before it opens; null when none.</summary>
public string? FetchingTitle => _fetch?.Title;
/// <summary>"Getting the proxies · Harbour sunset".</summary>
public string? FetchingText => _fetch is { } fetch ? string.Join(Loc.Separator, Loc.L("Editor.Proxies.Fetching"), fetch.Title) : null;
/// <summary>The open sequence has an edit not stored yet (the save follows each change after a moment, and retries after a failure).</summary>
public bool HasPendingSave => _editor?.Session.HasPendingSave == true;
/// <summary>"Chronos — Harbour sunset" while a sequence is open and shown; the section's name while choosing one.</summary>
public override string Title => !_isPicking && _editor is { } editor ? editor.Title : Label;
/// <summary>Opens <paramref name="sequenceId"/> (the editor of another sequence is saved and closed first).</summary>
/// <param name="reload">Opens it again even when it is the open one (its proxies were fetched again).</param>
public Task OpenAsync(Guid sequenceId, bool reload = false)
{
_switch = SwitchAsync(_switch, sequenceId, reload);
return _switch;
}
/// <summary>
/// Shows <paramref name="sequenceId"/> in the editor, as the Library does, and returns its editor once open; null
/// when it did not open (the reason was reported, or the open sequence's unsaved edit was kept) or waits for its
/// proxies.
/// </summary>
public async Task<EditorViewModel?> ShowAsync(Guid sequenceId)
{
Shell.OpenSequence(sequenceId);
// Already the sequence asked for but not open (the shell did not change, so nothing started): opening it again is
// what is asked now, unless its proxies are on their way (it opens when they are here).
if (_openId != sequenceId && _switch.IsCompleted && Shell.CurrentSequenceId == sequenceId && !Fetching(sequenceId)) _ = OpenAsync(sequenceId);
await Settled(_switch);
if (_openId != sequenceId) return null;
// Asking for the open sequence ends a choice of another.
IsPicking = false;
return Editor;
}
/// <summary>
/// Opens the sequence chosen in the picker: the open one simply shows again; another opens once it is read, after the
/// open one's last edit is stored (or the user chose to discard it). Keeping an edit that cannot be stored keeps the
/// open sequence; a server sequence whose proxies are not here yet leaves the picker on screen while they arrive.
/// </summary>
public async Task PickAsync(SequenceItem item)
{
ArgumentNullException.ThrowIfNull(item);
if (_editor is not null && item.Id == _openId)
{
KeepOpenSequence();
return;
}
await ShowAsync(item.Id);
}
/// <summary>
/// Fetches the proxies of server sequence <paramref name="remoteId"/> into this PC's cache (a download job, shown in
/// the job bar and on the Jobs screen) and opens it in the editor once they are here, if it is still the sequence
/// asked for.
/// </summary>
public async Task FetchProxiesAsync(Guid remoteId, string title)
{
var services = Shell.Services;
var sync = services.Sync;
if (sync.Server is not { } server || sync.Service is not { } service) throw new InvalidOperationException(Loc.L("Editor.Error.SignedOut"));
if (services.Engine is not { } engine || services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
var followed = _fetch is { } current && current.RemoteId == remoteId ? current.JobId : Guid.Empty;
StopFetch();
var fetch = new ProxyFetch(remoteId, title, engine);
fetch.Handler = job => _dispatcher.BeginInvoke(() => OnFetchChanged(fetch, job));
engine.JobChanged += fetch.Handler;
_fetch = fetch;
OnFetchingChanged();
Job job;
try
{
job = await service.EnqueueDownloadAsync(engine, server, remoteId, title, SyncDownloadMode.Proxies, null);
}
catch
{
// Nothing is on its way: the picker's line about it goes, and asking for the sequence again tries again.
if (ReferenceEquals(_fetch, fetch)) StopFetch();
throw;
}
fetch.JobId = job.Id;
// The download already followed (the same sequence asked for again) is not announced twice.
if (job.Id != followed)
Shell.Notify(Loc.L("Editor.Proxies.Fetching"), title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
// A download that ended before its id was known here is handled now.
if (await db.Jobs.GetAsync(job.Id) is { State: JobState.Done or JobState.Failed or JobState.Cancelled } ended) OnFetchChanged(fetch, ended);
}
/// <summary>
/// Stores the open sequence's last edit. When the save fails (archive offline, read-only, busy), asks whether to
/// discard the edit (BRIEF §12.1: modals only for destructive confirmations). No retry runs while the question is
/// open, so the answer holds: Discard drops the edit unwritten, Keep editing lets the retries go on.
/// </summary>
/// <returns>True when the editor may close: everything is stored or the user chose to discard.</returns>
public async Task<bool> ConfirmCloseAsync()
{
if (Editor is not { } editor || await editor.Session.FlushAsync()) return true;
var session = editor.Session;
if (!await session.HoldPendingAsync())
{
// A retry stored it meanwhile: nothing to ask.
session.KeepPending();
return true;
}
var discard = Shell.Services.Dialogs.Confirm(new ConfirmRequest
{
Heading = Loc.L("Editor.Unsaved.Title"),
Message = Loc.L("Editor.Unsaved.Message", editor.Title, session.LastSaveError?.Message ?? string.Empty),
SafeText = Loc.L("Editor.Unsaved.Keep"),
SafeToolTip = Loc.L("Tooltips.Editor.Unsaved.Keep"),
ActionText = Loc.L("Editor.Unsaved.Discard"),
ActionToolTip = Loc.L("Tooltips.Editor.Unsaved.Discard"),
IsDestructive = true,
});
if (discard) session.DiscardPending();
else session.KeepPending();
return discard;
}
/// <summary>Closes the open sequence (after <see cref="ConfirmCloseAsync"/>, which stores its last edit).</summary>
public async Task CloseAsync()
{
await Settled(_switch);
if (Editor is not { } editor) return;
Remember(editor);
Editor = null;
_openId = null;
await editor.DisposeAsync();
}
/// <summary>Shows <paramref name="editor"/>, which the caller opened over a source of its own (tests), as the open sequence.</summary>
internal void Attach(EditorViewModel editor)
{
_openId = editor.Session.Content.Sequence.Id;
if (_steps.TryGetValue(editor.Session.Content.Sequence.Id, out var memory)) editor.RestoreSteps(memory);
Editor = editor;
}
public override void Dispose()
{
Shell.PropertyChanged -= OnShellChanged;
StopFetch();
Editor?.Dispose();
Picker.Dispose();
base.Dispose();
}
protected override void OnActivated()
{
OpenRequested();
ShowRequested();
if (_showsPicker) _ = Picker.ReloadAsync();
}
/// <summary>Opens the sequence the shell asks for when it is not the open one (nor one whose proxies are on their way).</summary>
private void OpenRequested()
{
if (Shell.CurrentSequenceId is { } id && id != _openId && !Fetching(id)) _ = OpenAsync(id);
}
/// <summary>
/// Asking for the open sequence again (the Library, Jobs, a project file, also while Edit is on screen) ends a choice of
/// another; coming back to Edit alone leaves the choice on screen.
/// </summary>
private void ShowRequested()
{
if (Shell.SequenceRequests == _seenRequests) return;
_seenRequests = Shell.SequenceRequests;
if (_editor is not null && Shell.CurrentSequenceId == _openId) KeepOpenSequence();
}
/// <summary>
/// Back to the open sequence (Cancel, Esc, or the open sequence chosen again): it is again the one asked for, and a
/// server sequence still waiting for its proxies no longer opens over it when they arrive (its download goes on).
/// </summary>
private void KeepOpenSequence()
{
if (_fetch is { } pending && pending.RemoteId != _openId) StopFetch();
Shell.KeepSequence(_openId);
IsPicking = false;
}
/// <summary>The proxies of server sequence <paramref name="sequenceId"/> are on their way: it opens when they are here.</summary>
private bool Fetching(Guid sequenceId) => _fetch?.RemoteId == sequenceId;
/// <summary>
/// Whether the picker shows changed (a sequence opened or failed to, Change sequence, Cancel): it reads the list again
/// each time it appears on screen.
/// </summary>
private void OnPickerChanged()
{
OnPropertyChanged(nameof(CanCancelPick));
OnPropertyChanged(nameof(CancelPickToolTip));
var shows = !_isLoading && (_editor is null || _isPicking);
if (shows != _showsPicker)
{
_showsPicker = shows;
OnPropertyChanged(nameof(ShowsPicker));
if (shows && IsSelected) _ = Picker.ReloadAsync();
}
CommandManager.InvalidateRequerySuggested();
}
private void OnFetchingChanged()
{
OnPropertyChanged(nameof(FetchingTitle));
OnPropertyChanged(nameof(FetchingText));
}
/// <summary>Keeps the step <paramref name="editor"/> shows and the steps visited, for when its sequence opens again in this run.</summary>
private void Remember(EditorViewModel editor) => _steps[editor.Session.Content.Sequence.Id] = editor.StepMemory();
private void OnShellChanged(object? sender, PropertyChangedEventArgs e)
{
if (!IsSelected) return;
if (e.PropertyName == nameof(ShellViewModel.CurrentSequenceId)) OpenRequested();
else if (e.PropertyName == nameof(ShellViewModel.SequenceRequests)) ShowRequested();
}
/// <summary>
/// Where <paramref name="sequenceId"/> lives: this PC's index, else a sequence of the signed-in server whose proxies
/// this PC keeps (Server screen, "Open with proxies"), edited through the server (BRIEF §14.5), or only shown when the
/// account may not change it. Null when the proxies are not here yet: they are being fetched (<see cref="FetchProxiesAsync"/>).
/// </summary>
private async Task<(ISequenceSource Source, string Title)?> OpenSourceAsync(AppServices services, Guid sequenceId)
{
if (services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
var processing = services.Processing?.Options;
var decoder = processing?.Archive.Decoder ?? DecoderFactory.CreateClient(null);
if (await db.Sequences.GetAsync(sequenceId) is { } row)
{
var local = new LocalSequenceSource(db, sequenceId, decoder, services.Engine, processing?.Archive);
local.HeroChanged += OnHeroChanged;
return (local, row.DisplayTitle);
}
var sync = services.Sync;
if (sync.Server is not { } server || sync.Service is not { } service || sync.ConnectEditor() is not { } api)
throw new InvalidOperationException(Loc.L("Editor.Error.SignedOut"));
// The proxy cache's index and files are read off the UI thread.
if (await Task.Run(() => service.OpenRemote(server, sequenceId)) is { } remote)
return (new RemoteSequenceSource(remote, api, decoder, readOnly: !sync.Policy.CanEdit), remote.Sequence.DisplayTitle);
using (api)
{
string title;
try
{
title = (await api.GetSequenceAsync(sequenceId, CancellationToken.None)).DisplayTitle;
}
catch (ChronosApiException ex) when (ex.Status == HttpStatusCode.NotFound)
{
throw new InvalidOperationException(Loc.L("Editor.Error.Missing"), ex);
}
await FetchProxiesAsync(sequenceId, title);
return null;
}
}
/// <summary>The proxy download for an open waiting on it moved: opens the sequence once it is done, says why not when it failed.</summary>
private void OnFetchChanged(ProxyFetch fetch, Job job)
{
if (!ReferenceEquals(fetch, _fetch) || job.Id != fetch.JobId || job.State is not (JobState.Done or JobState.Failed or JobState.Cancelled)) return;
StopFetch();
switch (job.State)
{
// Opened only when it is still the sequence asked for; otherwise the next visit opens it from the cache.
case JobState.Done when Shell.CurrentSequenceId == fetch.RemoteId && IsSelected:
_ = OpenAsync(fetch.RemoteId, reload: true);
break;
case JobState.Failed:
Shell.Notify(Loc.L("Editor.Proxies.Failed"), job.Error ?? fetch.Title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"),
() => Shell.Navigate(SectionKey.Jobs), isError: true);
break;
}
}
private void StopFetch()
{
if (_fetch is not { } fetch) return;
_fetch = null;
if (fetch.Handler is { } handler) fetch.Engine.JobChanged -= handler;
OnFetchingChanged();
}
/// <summary>Set hero changed the frame the Library shows (any thread): its card loads the new thumbnail.</summary>
private void OnHeroChanged(Sequence row) => _dispatcher.BeginInvoke(() =>
{
if (Shell.Library.Items.FirstOrDefault(i => i.Id == row.Id) is { } item) item.Update(row);
});
/// <summary>Waits for <paramref name="task"/>; its failure was reported where it happened.</summary>
private static async Task Settled(Task task)
{
try
{
await task;
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Debug("editor", $"An earlier open of the editor failed: {ex.Message}");
}
}
private async Task SwitchAsync(Task previous, Guid sequenceId, bool reload)
{
await Settled(previous);
if (sequenceId == _openId && !reload) return;
// Asked for again while its proxies are on their way (the next visit, a second pick): it opens when they are here.
if (!reload && Fetching(sequenceId)) return;
var services = Shell.Services;
// The progress bar shows until the switch ends; the picker, its Cancel and the editor are hidden meanwhile.
IsLoading = true;
ISequenceSource? source = null;
try
{
// The next sequence is read first: the open one stays open when this one cannot open now.
if (await OpenSourceAsync(services, sequenceId) is not { } opened) return;
source = opened.Source;
SequenceContent content;
try
{
content = await source.LoadAsync(CancellationToken.None);
}
catch (ProxiesOutdatedException)
{
// The server's frames are no longer these proxies: fetch them again, then open.
await source.DisposeAsync();
source = null;
await FetchProxiesAsync(sequenceId, opened.Title);
return;
}
// Only now does the open sequence close: its last edit is stored first, or discarded on the user's word. Keeping
// it keeps the open sequence as the one asked for, so the next visit to Edit does not ask once more.
if (!await ConfirmCloseAsync())
{
Shell.KeepSequence(_openId);
IsPicking = false;
return;
}
// A server sequence that was waiting for its proxies is no longer the one asked for.
if (_fetch is { } pending && pending.RemoteId != sequenceId) StopFetch();
if (Editor is { } old)
{
Remember(old);
Editor = null;
_openId = null;
await old.DisposeAsync();
}
var processing = services.Processing?.Options;
var encoders = processing?.Encoders ?? [];
var session = new EditorSession(source, content, [.. encoders.SelectMany(e => e.Capabilities)]);
// The session owns the source from here on.
source = null;
EditorViewModel editor;
try
{
editor = new EditorViewModel(Shell, session, encoders, processing?.Host ?? EncoderHost.Client);
}
catch
{
await session.DisposeAsync();
throw;
}
if (_steps.TryGetValue(sequenceId, out var memory)) editor.RestoreSteps(memory);
_openId = sequenceId;
Editor = editor;
services.Settings.LastEditedSequence = sequenceId;
services.SavePreferences();
await editor.AttachJobsAsync();
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
// Whatever failed (index, decoder set-up, advisor, the job list), the section stays usable: the sequence open
// before (or the one that has just opened) stays open and is again the one asked for, so coming back to Edit
// neither tries nor reports it again; choosing the sequence again does.
Log.Warning("editor", $"Sequence {sequenceId} could not be opened", ex);
Shell.ReportError(ex);
Shell.KeepSequence(OpenSequenceId);
}
finally
{
if (source is not null) await source.DisposeAsync();
IsLoading = false;
}
}
/// <summary>A proxy download an open waits on, with its engine subscription.</summary>
private sealed class ProxyFetch(Guid remoteId, string title, JobEngine engine)
{
public Guid RemoteId { get; } = remoteId;
public string Title { get; } = title;
public JobEngine Engine { get; } = engine;
public Guid JobId { get; set; }
public Action<Job>? Handler { get; set; }
}
}
+310
View File
@@ -0,0 +1,310 @@
<UserControl x:Class="Chronos.App.Sections.ServerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
xmlns:shell="clr-namespace:Chronos.App.Shell"
xmlns:srv="clr-namespace:Chronos.App.Server">
<UserControl.Resources>
<Style x:Key="Text.RowLabel" TargetType="TextBlock" BasedOn="{StaticResource Text.Label}">
<Setter Property="MinWidth" Value="60" />
<Setter Property="Margin" Value="0,0,10,0" />
</Style>
<Style x:Key="Text.Dot" TargetType="TextBlock">
<Setter Property="Text" Value="·" />
<Setter Property="Foreground" Value="{DynamicResource Brush.TextFaint}" />
<Setter Property="Margin" Value="8,0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<ItemsPanelTemplate x:Key="Panel.Wrap">
<WrapPanel />
</ItemsPanelTemplate>
<!-- Filter chip (Server.html, aria-pressed): one of a group, so screen readers hear which filter is on. -->
<Style x:Key="RadioButton.Chip" TargetType="RadioButton" BasedOn="{StaticResource Button.Base}">
<Setter Property="Height" Value="28" />
<Setter Property="Padding" Value="12,0" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Typography.NumeralAlignment" Value="Tabular" />
<Setter Property="ui:ControlState.CornerRadius" Value="14" />
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}" />
<Setter Property="ui:ControlState.HoverBorderBrush" Value="{DynamicResource Brush.Accent}" />
</Trigger>
</Style.Triggers>
</Style>
<!-- A row reads as its sequence and state; Tab goes to its buttons. -->
<Style x:Key="ListBoxItem.Sync" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<Setter Property="AutomationProperties.ItemStatus" Value="{Binding StateText}" />
</Style>
</UserControl.Resources>
<!-- Server.html: the connection panel, then the sync table. The render-node status panel is not built (see the decisions). -->
<Grid Margin="20,16,20,12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="16,14">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Address (read-only while connected, still selectable), servers found on the LAN, connect / disconnect; Tab follows this order. -->
<TextBlock Style="{StaticResource Text.RowLabel}" Text="{l:Loc Server.Label.Server}" />
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox x:Name="AddressBox" Text="{Binding Address, UpdateSourceTrigger=PropertyChanged}" ui:Field.Placeholder="{l:Loc Server.AddressPlaceholder}"
ToolTip="{l:Loc Tooltips.Server.Address}" AutomationProperties.Name="{l:Loc Server.Label.Server}" IsReadOnly="{Binding IsConnected}"
FlowDirection="LeftToRight">
<TextBox.InputBindings>
<KeyBinding Key="Enter" Command="{Binding ConnectCommand}" />
</TextBox.InputBindings>
</TextBox>
<Button x:Name="KnownButton" Grid.Column="1" Style="{StaticResource Button.Icon}" Margin="10,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.ChevronDown}"
IsEnabled="{Binding HasKnownServers}" Click="OnShowKnown" ToolTip="{Binding KnownToolTip}" AutomationProperties.Name="{l:Loc Server.Found}">
<Button.ContextMenu>
<ContextMenu ItemsSource="{Binding KnownServers}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header" Value="{Binding Address}" />
<!-- An address reads left to right in every language. -->
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding}" FlowDirection="LeftToRight" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="InputGestureText" Value="{Binding Name}" />
<Setter Property="Command" Value="{Binding DataContext.UseServerCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}" />
<Setter Property="CommandParameter" Value="{Binding}" />
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Server.UseFound}" />
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button Grid.Column="2" Style="{StaticResource Button.Primary}" Content="{l:Loc Server.Connect}" Command="{Binding ConnectCommand}"
ToolTip="{Binding ConnectToolTip}" Margin="10,0,0,0" MinWidth="96"
Visibility="{Binding IsDisconnected, Converter={StaticResource BoolToVisibility}}" />
<Button Grid.Column="2" Content="{l:Loc Server.Disconnect}" Command="{Binding DisconnectCommand}" ToolTip="{l:Loc Tooltips.Server.Disconnect}"
Margin="10,0,0,0" MinWidth="96" Visibility="{Binding IsConnected, Converter={StaticResource BoolToVisibility}}" />
</Grid>
<!-- Status: state · server · version · latency · trusted certificate; screen readers hear the state and the error change. -->
<TextBlock Grid.Row="1" Style="{StaticResource Text.RowLabel}" Text="{l:Loc Server.Label.Status}" Margin="0,12,10,0" />
<WrapPanel Grid.Row="1" Grid.Column="1" Margin="0,12,0,0" VerticalAlignment="Center">
<ui:StatusGlyph Kind="{Binding StatusKind}" Text="{Binding StatusText}" FontSize="13" VerticalAlignment="Center" ToolTip="{l:Loc Tooltips.Server.Status}"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding StatusText}" />
<StackPanel Orientation="Horizontal" Visibility="{Binding ServerText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<TextBlock Style="{StaticResource Text.Dot}" />
<TextBlock Text="{Binding ServerText}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
</StackPanel>
<StackPanel Orientation="Horizontal" Visibility="{Binding CertificateText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<TextBlock Style="{StaticResource Text.Dot}" />
<TextBlock Text="{Binding CertificateText}" VerticalAlignment="Center" ToolTip="{Binding CertificateToolTip}" />
<Button Style="{StaticResource Button.Row}" Content="{l:Loc Server.Certificate}" Command="{Binding CertificateCommand}"
ToolTip="{l:Loc Tooltips.Server.Certificate}" Height="24" Margin="10,0,0,0" />
</StackPanel>
<StackPanel Orientation="Horizontal" Visibility="{Binding ErrorText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<TextBlock Style="{StaticResource Text.Dot}" />
<ui:StatusGlyph Kind="Error" Text="{Binding ErrorText}" FontSize="13" VerticalAlignment="Center"
AutomationProperties.LiveSetting="Assertive" infra:LiveRegion.Text="{Binding ErrorText}" />
</StackPanel>
</WrapPanel>
<!-- Account: user · role · quota · sign out. -->
<TextBlock Grid.Row="2" Style="{StaticResource Text.RowLabel}" Text="{l:Loc Server.Label.Account}" Margin="0,12,10,0"
Visibility="{Binding IsConnected, Converter={StaticResource BoolToVisibility}}" />
<DockPanel Grid.Row="2" Grid.Column="1" Margin="0,12,0,0" LastChildFill="False" Visibility="{Binding IsConnected, Converter={StaticResource BoolToVisibility}}">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Compact}" Content="{l:Loc Server.SignOut}" Command="{Binding SignOutCommand}" ToolTip="{l:Loc Tooltips.Server.SignOut}" />
<Border Width="28" Height="28" CornerRadius="14" Background="{DynamicResource Brush.Card}" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="1">
<TextBlock Text="{Binding Initial}" FontWeight="SemiBold" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<TextBlock Text="{Binding Username}" Margin="10,0,0,0" VerticalAlignment="Center" />
<TextBlock Style="{StaticResource Text.Dot}" />
<TextBlock Text="{Binding RoleText}" ToolTip="{Binding RoleToolTip}" VerticalAlignment="Center" />
<StackPanel Orientation="Horizontal" Visibility="{Binding HasQuota, Converter={StaticResource BoolToVisibility}}">
<TextBlock Style="{StaticResource Text.Dot}" />
<ProgressBar Width="160" Maximum="1" Value="{Binding QuotaFraction, Mode=OneWay}" VerticalAlignment="Center" ToolTip="{l:Loc Tooltips.Server.Quota}"
AutomationProperties.Name="{Binding QuotaText}" />
</StackPanel>
<TextBlock Text="{Binding QuotaText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Server.Quota}" />
</DockPanel>
<!-- Options of this PC; the render-node option names the encoders it offers. -->
<Border Grid.Row="3" Grid.ColumnSpan="2" Margin="0,14,0,0" Padding="0,10,0,0" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,0">
<WrapPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,22,0">
<CheckBox Content="{l:Loc Server.RenderNode}" IsChecked="{Binding RenderNodeOptIn}" ToolTip="{l:Loc Tooltips.Server.RenderNode}" VerticalAlignment="Center" />
<TextBlock Text="{Binding NodeCodecsText}" ToolTip="{Binding NodeCodecsToolTip}" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0"
VerticalAlignment="Center" Visibility="{Binding NodeCodecsText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
</StackPanel>
<CheckBox Content="{l:Loc Server.KeepProxies}" IsChecked="{Binding KeepProxiesOffline}" ToolTip="{l:Loc Tooltips.Server.KeepProxies}" Margin="0,0,22,0" />
<CheckBox Content="{l:Loc Server.AutoSync}" IsChecked="{Binding SyncSettingsAutomatically}" ToolTip="{l:Loc Tooltips.Server.AutoSync}" Margin="0,0,22,0" />
<CheckBox Content="{l:Loc Server.PauseMetered}" IsChecked="{Binding PauseUploadsOnMetered}" ToolTip="{l:Loc Tooltips.Server.PauseMetered}" Margin="0,0,22,0" />
</WrapPanel>
</Border>
</Grid>
</Border>
<!-- Sequences of this PC and of the server: chips, search, Upload all local; table; footer. -->
<Border Grid.Row="1" Style="{StaticResource Border.Panel}" Margin="0,14,0,0" DataContext="{Binding Sync}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Toolbar in visual (and Tab) order: title, chips, search, Upload all local. Chips wrap before anything is cut;
the filters and search show only while signed in. -->
<Grid Margin="14,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="{l:Loc Server.Sync.Title}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="0,4,10,4" />
<ItemsControl ItemsSource="{Binding Chips}" ItemsPanel="{StaticResource Panel.Wrap}" Focusable="False" VerticalAlignment="Center"
Visibility="{Binding IsActive, Converter={StaticResource BoolToVisibility}}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type srv:SyncFilterChip}">
<RadioButton x:Name="Chip" Style="{StaticResource RadioButton.Chip}" GroupName="SyncFilters" Content="{Binding Text}"
IsChecked="{Binding IsSelected, Mode=OneWay}" Command="{Binding SelectCommand}" ToolTip="{Binding ToolTip}" Margin="0,1,10,1" />
<DataTemplate.Triggers>
<!-- Conflicts waiting are drawn in warning colours, unless the chip is the chosen one (then Accent, DESIGN §4). -->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding NeedsAttention}" Value="True" />
<Condition Binding="{Binding IsSelected}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter TargetName="Chip" Property="BorderBrush" Value="{DynamicResource Brush.Warning}" />
<Setter TargetName="Chip" Property="Foreground" Value="{DynamicResource Brush.Warning}" />
</MultiDataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</WrapPanel>
<TextBox Grid.Column="1" Width="200" Height="30" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Search}"
ui:Field.Placeholder="{l:Loc Server.Sync.Search}" ToolTip="{l:Loc Tooltips.Server.Sync.Search}" AutomationProperties.Name="{l:Loc Server.Sync.Search}"
Margin="10,0,0,0" Visibility="{Binding IsActive, Converter={StaticResource BoolToVisibility}}" />
<Button Grid.Column="2" Content="{l:Loc Server.Sync.UploadAll}" Command="{Binding UploadAllCommand}" ToolTip="{Binding UploadAllToolTip}"
ToolTipService.ShowOnDisabled="True" Height="30" Margin="10,0,0,0" />
</Grid>
<!-- Header; the rows repeat its columns (Server.html: 1.6fr 150px 150px 150px 1.4fr with 10 px gaps). The list always
keeps its 10 px scroll-bar gutter and the header the same on its right, so the columns line up with or without scrolling. -->
<Border Grid.Row="1" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,1" Padding="14,8,24,8">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.6*" MinWidth="140" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="1.4*" MinWidth="280" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Server.Sync.Column.Sequence}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Server.Sync.Column.Local}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Server.Sync.Column.Server}" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Server.Sync.Column.State}" Margin="10,0,0,0" />
</Grid>
</Border>
<!-- Rows (virtualised): this PC, the server, the state and the actions that apply; conflicts on the warning tint.
Tab walks every row button (the rows themselves take no focus). Actions wrap when longer labels need it. -->
<ListBox x:Name="SyncList" Grid.Row="2" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.Sync}"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" KeyboardNavigation.TabNavigation="Continue"
AutomationProperties.Name="{l:Loc Server.Sync.Title}" Visibility="{Binding HasRows, Converter={StaticResource BoolToVisibility}}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type srv:SyncRow}">
<Border x:Name="RowBorder" Background="Transparent" Padding="14,0">
<Grid MinHeight="40">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.6*" MinWidth="140" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="160" />
<ColumnDefinition Width="1.4*" MinWidth="280" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Title}" ToolTip="{Binding Title}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding LocalText}" ToolTip="{Binding LocalText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding ServerText}" ToolTip="{Binding ServerText}" Margin="10,0,0,0" />
<!-- A new state (uploading, in sync, failed) is announced with its sequence; progress ticks are not. -->
<ui:StatusGlyph Grid.Column="3" Kind="{Binding StateKind}" Text="{Binding StateText}" ToolTip="{Binding StateToolTip}"
FontSize="13" VerticalAlignment="Center" Margin="10,0,0,0"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding StateAnnouncement}" />
<ItemsControl Grid.Column="4" ItemsSource="{Binding Actions}" ItemsPanel="{StaticResource Panel.Wrap}" Focusable="False" VerticalAlignment="Center" Margin="10,4,0,4">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type srv:SyncRowAction}">
<Button Style="{StaticResource Button.Row}" Content="{Binding Text}" Command="{Binding Command}" ToolTip="{Binding ToolTip}"
AutomationProperties.Name="{Binding AccessibleName}" FontSize="12" Margin="0,2,6,2" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsConflict}" Value="True">
<Setter TargetName="RowBorder" Property="Background" Value="{DynamicResource Brush.WarningSubtle}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- One sentence and its one action: connect, bring photos in, or show every sequence again. -->
<ui:EmptyState Grid.Row="2" Message="{Binding EmptyText}" Visibility="{Binding EmptyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<Grid>
<Button Content="{l:Loc Server.Connect}" Command="{Binding DataContext.ConnectCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
ToolTip="{Binding DataContext.ConnectToolTip, RelativeSource={RelativeSource AncestorType=UserControl}}"
Visibility="{Binding Empty, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=SignedOut}" />
<Button Content="{l:Loc Shell.Nav.Import}" Command="{Binding ImportCommand}" ToolTip="{l:Loc Tooltips.Server.Sync.Import}"
Visibility="{Binding Empty, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Nothing}" />
<Button Content="{l:Loc Server.Sync.ClearFilters}" Command="{Binding ClearFiltersCommand}" ToolTip="{l:Loc Tooltips.Server.Sync.ClearFilters}"
Visibility="{Binding Empty, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=NoMatch}" />
</Grid>
</ui:EmptyState>
<!-- Footer: last comparison · server archive · retry state (announced) · admin panel for administrators. -->
<Border Grid.Row="3" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,0" Padding="14,8">
<DockPanel LastChildFill="False" TextElement.FontSize="12">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Link}" Content="{l:Loc Server.Sync.OpenAdmin}" Command="{Binding OpenAdminCommand}"
ToolTip="{l:Loc Tooltips.Server.Sync.OpenAdmin}" Visibility="{Binding CanOpenAdmin, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{Binding LastSyncText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,16,0" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Server.Sync.LastSync}"
Visibility="{Binding LastSyncText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<TextBlock Text="{Binding ArchiveText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,16,0" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Server.Sync.Archive}"
Visibility="{Binding ArchiveText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<ui:StatusGlyph Kind="Warning" Text="{Binding ErrorText}" ToolTip="{Binding ErrorToolTip}" FontSize="12" VerticalAlignment="Center"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding ErrorText}"
Visibility="{Binding ErrorText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
</DockPanel>
</Border>
</Grid>
</Border>
</Grid>
</UserControl>
@@ -0,0 +1,20 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
namespace Chronos.App.Sections;
public partial class ServerView : UserControl
{
public ServerView() => InitializeComponent();
/// <summary>The ▾ button opens the list of servers found on the LAN under itself.</summary>
private void OnShowKnown(object sender, RoutedEventArgs e)
{
if (KnownButton.ContextMenu is not { } menu) return;
menu.DataContext = DataContext;
menu.PlacementTarget = KnownButton;
menu.Placement = PlacementMode.Bottom;
menu.IsOpen = true;
}
}
+285
View File
@@ -0,0 +1,285 @@
using System.ComponentModel;
using System.Windows.Input;
using Chronos.App.Infrastructure;
using Chronos.App.Server;
using Chronos.App.Settings;
using Chronos.App.Shell;
using Chronos.Core.Export;
using Chronos.Core.Localization;
using Chronos.Ui.Controls;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Sections;
/// <summary>
/// Server (BRIEF §12.7, Server.html): address with LAN-discovered servers, connect with trust-on-first-use and login,
/// status (name, version, latency, certificate), account and quota, sign out, the options of this PC (render node,
/// proxies kept offline, automatic project sync, uploads paused on metered networks) and the sync table (<see cref="Sync"/>).
/// The rail badge counts the settings conflicts waiting for a choice.
/// </summary>
public sealed class ServerViewModel : SectionViewModel
{
private readonly SyncFilterChip _conflicts;
private string _address;
private string? _errorText;
private ServerSession? _session;
public ServerViewModel(ShellViewModel shell)
: base(SectionKey.Server, "Icon.Server")
{
Shell = shell;
_address = ServerAddress.Display(shell.Services.Settings.ServerUrl);
ConnectCommand = new AsyncRelayCommand(ConnectAsync, () => !IsBusy && !IsConnected && Address.Trim().Length > 0);
DisconnectCommand = new RelayCommand(() => Session.Disconnect(), () => IsConnected);
SignOutCommand = new AsyncRelayCommand(SignOutAsync, () => IsConnected);
UseServerCommand = new RelayCommand(p =>
{
if (p is DiscoveredServer s) Address = s.Address;
else if (p is string text) Address = text;
});
CertificateCommand = new RelayCommand(ShowCertificate, () => Fingerprint is not null);
Sync = new SyncTableViewModel(shell);
_conflicts = Sync.Chips.Single(c => c.Filter == SyncFilter.Conflicts);
_conflicts.PropertyChanged += OnConflictsChanged;
}
/// <summary>Sequences of this PC and of the server, where they stand and what can be done.</summary>
public SyncTableViewModel Sync { get; }
public ShellViewModel Shell { get; }
private ServerSession Session => _session ?? Shell.Services.Server;
public ICommand ConnectCommand { get; }
public ICommand DisconnectCommand { get; }
public ICommand SignOutCommand { get; }
public ICommand UseServerCommand { get; }
public ICommand CertificateCommand { get; }
/// <summary>Servers found on the LAN plus recently used ones, for the ▾ list.</summary>
public IEnumerable<DiscoveredServer> KnownServers =>
Session.Discovered.Concat(Shell.Services.Settings.RecentServers
.Where(r => !Session.Discovered.Any(d => d.Address.Equals(r, StringComparison.OrdinalIgnoreCase)))
.Select(r => new DiscoveredServer(r, r)));
public bool HasKnownServers => KnownServers.Any();
/// <summary>What ▾ lists, or why it is disabled.</summary>
public string KnownToolTip => Loc.L(HasKnownServers ? "Tooltips.Server.Found" : "Tooltips.Server.NoneFound");
/// <summary>What Connect does, or why it is disabled.</summary>
public string ConnectToolTip => Loc.L(Address.Trim().Length > 0 ? "Tooltips.Server.Connect" : "Tooltips.Server.ConnectNoAddress");
public string Address
{
get => _address;
set
{
if (!Set(ref _address, value ?? string.Empty)) return;
OnPropertyChanged(nameof(ConnectToolTip));
CommandManager.InvalidateRequerySuggested();
}
}
public bool IsBusy => Session.IsBusy;
public bool IsConnected => Session.IsConnected;
public bool IsDisconnected => !Session.IsConnected;
/// <summary>One sentence about the last failure; null when none.</summary>
public string? ErrorText
{
get => _errorText;
private set => Set(ref _errorText, value);
}
// ---- Status row ----
public StatusKind StatusKind => IsConnected ? StatusKind.Online : IsBusy ? StatusKind.Running : ErrorText is null ? StatusKind.Offline : StatusKind.Error;
public string StatusText => IsConnected ? Loc.L("Server.Status.Connected")
: IsBusy ? Loc.L("Server.Status.Connecting")
: Session.HasSavedSession ? Loc.L("Server.Status.Disconnected")
: Loc.L("Server.Status.NotConnected");
/// <summary>"Studio NAS · v1.3.0 · 14 ms".</summary>
public string? ServerText
{
get
{
if (!IsConnected || Session.Flow.Info is not { } info) return null;
var parts = new List<string> { info.Name, Loc.L("Server.Version", info.Version) };
if (Session.Flow.Latency is { } latency) parts.Add(Loc.L("Server.Latency", Math.Max(1, (int)Math.Round(latency.TotalMilliseconds))));
return string.Join(Loc.Separator, parts);
}
}
/// <summary>Fingerprint of the trusted self-signed certificate; null for a publicly valid certificate.</summary>
public string? Fingerprint => IsConnected ? Session.TrustOf(Session.Flow.Info?.TlsFingerprint)?.Fingerprint : null;
/// <summary>"TLS 9A:3C:71:E0:… trusted 2026-09-01".</summary>
public string? CertificateText => Fingerprint is { } fp && Session.TrustOf(fp) is { } trust
? Loc.L("Server.Certificate.Trusted", Formatting.LeftToRight(ServerSession.ShortFingerprint(fp)), Formatting.Date(trust.TrustedAt))
: null;
public string CertificateToolTip => Loc.L("Tooltips.Server.CertificateTrusted");
// ---- Account row ----
public string? Username => Session.User?.Username;
public string Initial => Username is { Length: > 0 } u ? char.ToUpper(u[0], Loc.Culture).ToString() : string.Empty;
public string? RoleText => Session.User?.Role is { } role ? KnownRole(role) is { } known ? Loc.L("Server.Role." + known) : role : null;
public string? RoleToolTip => Session.User?.Role is { } role && KnownRole(role) is { } known ? Loc.L("Tooltips.Server.Role." + known) : null;
public bool HasQuota => Session.User is { QuotaBytes: > 0 };
public double QuotaFraction => Session.User is { QuotaBytes: > 0 } u ? Math.Clamp((double)u.UsedBytes / u.QuotaBytes, 0, 1) : 0;
/// <summary>"2.1 TB of 5 TB", or the used bytes when unlimited.</summary>
public string? QuotaText => Session.User is not { } u ? null
: u.QuotaBytes > 0 ? Loc.L("Server.Quota", Formatting.Bytes(u.UsedBytes), Formatting.Bytes(u.QuotaBytes))
: Loc.L("Server.QuotaUnlimited", Formatting.Bytes(u.UsedBytes));
// ---- Options ----
public bool RenderNodeOptIn
{
get => Shell.Services.Settings.RenderNodeOptIn;
set
{
if (Shell.Services.Settings.RenderNodeOptIn == value) return;
Shell.Services.Settings.RenderNodeOptIn = value;
Shell.Services.SaveSettings();
OnPropertyChanged();
}
}
/// <summary>The video encoders a render node on this PC offers the server.</summary>
private IReadOnlyList<EncoderRow> NodeEncoders => EncoderUse.Node(Shell.Settings.Encoders.Select(e => e.Row),
AppServices.AllowsHardware(Shell.Services.Settings.HardwareEncoding, ExportResolver.CustomId));
/// <summary>"HEVC · H.264 · AV1" beside "Offer this PC as render node" (BRIEF §12.7); null before the encoders are known.</summary>
public string? NodeCodecsText => EncoderUse.Codecs(NodeEncoders);
public string NodeCodecsToolTip => Loc.L("Tooltips.Server.NodeEncoders", string.Join(", ", NodeEncoders.Select(e => e.DisplayName)));
/// <summary>Keep the proxy caches of server sequences opened with proxies up to date on this PC.</summary>
public bool KeepProxiesOffline
{
get => Shell.Services.Settings.KeepProxiesOffline;
set => SetSyncOption(value, Shell.Services.Settings.KeepProxiesOffline, v => Shell.Services.Settings.KeepProxiesOffline = v);
}
/// <summary>Send and take project settings changed on one side without asking.</summary>
public bool SyncSettingsAutomatically
{
get => Shell.Services.Settings.SyncSettingsAutomatically;
set => SetSyncOption(value, Shell.Services.Settings.SyncSettingsAutomatically, v => Shell.Services.Settings.SyncSettingsAutomatically = v);
}
/// <summary>Pause uploads while the connection is metered.</summary>
public bool PauseUploadsOnMetered
{
get => Shell.Services.Settings.PauseUploadsOnMetered;
set
{
if (Shell.Services.Settings.PauseUploadsOnMetered == value) return;
Shell.Services.Settings.PauseUploadsOnMetered = value;
Shell.Services.SaveSettings();
Shell.Services.Sync.Uploads.Request();
OnPropertyChanged();
}
}
/// <summary>Re-reads values another screen changed (Settings › Server and Rendering).</summary>
public void Refresh()
{
OnPropertyChanged(nameof(RenderNodeOptIn));
OnPropertyChanged(nameof(NodeCodecsText));
OnPropertyChanged(nameof(NodeCodecsToolTip));
}
/// <summary>Restores the saved session and starts listening for LAN servers.</summary>
public async Task AttachAsync()
{
_session = Shell.Services.Server;
_session.PropertyChanged += OnSessionChanged;
_session.Discovered.CollectionChanged += (_, _) =>
{
OnPropertyChanged(nameof(KnownServers));
OnPropertyChanged(nameof(HasKnownServers));
if (Address.Length == 0 && Session.Discovered.Count > 0) Address = Session.Discovered[0].Address;
};
if (!Shell.Services.Environment.IsCapture) _session.StartDiscovery();
Shell.Settings.Encoders.CollectionChanged += OnEncodersChanged;
Sync.Attach();
await _session.RestoreAsync();
if (_session.Flow.Error is not ConnectError.None and var error && !_session.IsConnected) ErrorText = ServerSession.ErrorText(error);
}
public override void Dispose()
{
_conflicts.PropertyChanged -= OnConflictsChanged;
if (_session is not null) _session.PropertyChanged -= OnSessionChanged;
Shell.Settings.Encoders.CollectionChanged -= OnEncodersChanged;
Sync.Dispose();
base.Dispose();
}
/// <summary>The encoders next to the render-node option are listed on the first visit.</summary>
protected override void OnActivated()
{
if (Shell.Settings.Encoders.Count == 0 && !Shell.Settings.IsDetecting) _ = Shell.Settings.DetectEncodersAsync();
}
private void OnConflictsChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName is nameof(SyncFilterChip.Count) or "" or null) Badge = _conflicts.Count;
}
private void SetSyncOption(bool value, bool current, Action<bool> store, [System.Runtime.CompilerServices.CallerMemberName] string? name = null)
{
if (value == current) return;
store(value);
Shell.Services.SaveSettings();
Shell.Services.Sync.RequestRefresh();
OnPropertyChanged(name);
}
private async Task ConnectAsync()
{
ErrorText = null;
var connected = await Session.ConnectAsync(Address, Shell.Services.Dialogs);
if (connected)
{
Address = ServerAddress.Display(Session.SavedAddress);
return;
}
if (Session.Flow.Error is not ConnectError.None and var error) ErrorText = ServerSession.ErrorText(error);
}
private async Task SignOutAsync()
{
await Session.SignOutAsync();
ErrorText = null;
}
private void ShowCertificate()
{
if (Fingerprint is { } fingerprint) Session.ConfirmForget(fingerprint, Shell.Services.Dialogs);
}
private void OnEncodersChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
OnPropertyChanged(nameof(NodeCodecsText));
OnPropertyChanged(nameof(NodeCodecsToolTip));
}
private void OnSessionChanged(object? sender, PropertyChangedEventArgs e)
{
OnAllPropertiesChanged();
CommandManager.InvalidateRequerySuggested();
}
/// <summary>The <see cref="Core.Model.UserRole"/> name of a server role, or null for a role this build does not know.</summary>
private static string? KnownRole(string role) =>
Enum.TryParse<Core.Model.UserRole>(role, ignoreCase: true, out var parsed) ? parsed.ToString() : null;
}
+661
View File
@@ -0,0 +1,661 @@
<UserControl x:Class="Chronos.App.Sections.SettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
xmlns:shell="clr-namespace:Chronos.App.Shell"
xmlns:st="clr-namespace:Chronos.App.Settings">
<UserControl.Resources>
<!-- Every page is a size scope: its labels share one column as wide as the longest label (at least 180 px, DESIGN §3),
wrapping only past 280 px, so translations 40 % longer are never cut (DESIGN §2: MinWidth only). -->
<Style x:Key="Page" TargetType="StackPanel">
<Setter Property="Visibility" Value="Collapsed" />
<Setter Property="Grid.IsSharedSizeScope" Value="True" />
</Style>
<Style x:Key="Setting.Row" TargetType="HeaderedContentControl">
<Setter Property="Focusable" Value="False" />
<Setter Property="Margin" Value="0,0,0,14" />
<Setter Property="MinHeight" Value="32" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="HeaderedContentControl">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="180" SharedSizeGroup="SettingLabel" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Header, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource Text.Label}" VerticalAlignment="Top"
TextTrimming="None" TextWrapping="Wrap" MaxWidth="280" Margin="0,7,14,0" />
<ContentPresenter Grid.Column="1" VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- A path in a row with buttons: up to 360 px, narrower before anything wraps or is cut; left to right in every language. -->
<Style x:Key="TextBox.Path" TargetType="TextBox" BasedOn="{StaticResource TextBox.Setting}">
<Setter Property="Width" Value="Auto" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style>
<!-- Numbers stay right-aligned in both reading directions. -->
<Style x:Key="TextBox.SettingNumber" TargetType="TextBox" BasedOn="{StaticResource TextBox.Number}">
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style>
<!-- Keyboard focus in the section list: a 2 px Accent ring inside the item (DESIGN §4), distinct from the selected fill. -->
<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>
<Style x:Key="ListBoxItem.SettingsSection" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Section}">
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
</Style>
<Style x:Key="Slider.Budget" TargetType="Slider" BasedOn="{StaticResource {x:Type Slider}}">
<Setter Property="ui:ControlState.Accent" Value="{DynamicResource Brush.Sun}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMemoryAuto}" Value="True">
<Setter Property="ui:ControlState.Accent" Value="{DynamicResource Brush.Accent}" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="Button.Reset" TargetType="Button" BasedOn="{StaticResource Button.IconSubtle}">
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="24" />
<Setter Property="MinWidth" Value="24" />
<Setter Property="ui:ControlState.CornerRadius" Value="12" />
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Reset}" />
</Style>
<!-- "Auto · 8": a pill of text with the advisor's reason in its tooltip (DESIGN §4), not a button. -->
<Style x:Key="Text.AutoPill" TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource Size.Chip}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Typography.NumeralAlignment" Value="Tabular" />
</Style>
</UserControl.Resources>
<Grid Margin="20,16,20,16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.SettingsList}" />
<ColumnDefinition Width="16" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Section list: search, sections, settings as JSON (visual and Tab order). -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox Margin="0,0,0,8" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Search}"
ui:Field.Placeholder="{l:Loc Settings.Search}" ToolTip="{l:Loc Tooltips.Settings.Search}" AutomationProperties.Name="{l:Loc Settings.Search}" />
<ListBox Grid.Row="1" ItemsSource="{Binding VisiblePages}" SelectedItem="{Binding SelectedPageItem}" ItemContainerStyle="{StaticResource ListBoxItem.SettingsSection}"
ScrollViewer.VerticalScrollBarVisibility="Auto" AutomationProperties.Name="{l:Loc Shell.Nav.Settings}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type st:SettingsPageItem}">
<TextBlock Text="{Binding Label}" ToolTip="{Binding ToolTip}" TextTrimming="CharacterEllipsis" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="2" Margin="0,8,0,0">
<Button Content="{l:Loc Settings.Export}" Command="{Binding ExportSettingsCommand}" ToolTip="{l:Loc Tooltips.Settings.Export}" HorizontalAlignment="Stretch" Margin="0,0,0,8" />
<Button Content="{l:Loc Settings.Import}" Command="{Binding ImportSettingsCommand}" ToolTip="{l:Loc Tooltips.Settings.Import}" HorizontalAlignment="Stretch" />
</StackPanel>
</Grid>
<Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="22,18">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding PageTitle}" Style="{StaticResource Text.PageTitle}" Margin="0,0,0,18" />
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Focusable="False">
<Grid>
<!-- ================= General ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=General}">
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.General.Language}">
<ComboBox Width="240" HorizontalAlignment="Left" ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage}" DisplayMemberPath="Name"
ToolTip="{l:Loc Tooltips.Settings.Language}" AutomationProperties.Name="{l:Loc Settings.General.Language}" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.General.Theme}">
<WrapPanel VerticalAlignment="Center" Margin="0,4,0,0">
<RadioButton Content="{l:Loc Settings.General.Theme.Dark}" IsChecked="{Binding IsDarkTheme}" ToolTip="{l:Loc Tooltips.Settings.ThemeDark}" Margin="0,0,20,0" />
<RadioButton Content="{l:Loc Settings.General.Theme.Light}" IsChecked="{Binding IsLightTheme}" ToolTip="{l:Loc Tooltips.Settings.ThemeLight}" Margin="0,0,20,0" />
<RadioButton Content="{l:Loc Settings.General.Theme.System}" IsChecked="{Binding IsSystemTheme}" ToolTip="{l:Loc Tooltips.Settings.ThemeSystem}" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.General.Startup}"
Visibility="{Binding ShowsStartup, Converter={StaticResource BoolToVisibility}}">
<CheckBox Content="{l:Loc Settings.General.StartWithWindows}" IsChecked="{Binding StartWithWindows}" ToolTip="{l:Loc Tooltips.Settings.StartWithWindows}" Margin="0,4,0,0" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.General.Notifications}">
<CheckBox Content="{l:Loc Settings.General.OsNotifications}" IsChecked="{Binding OsNotifications}" ToolTip="{l:Loc Tooltips.Settings.OsNotifications}" Margin="0,4,0,0" />
</HeaderedContentControl>
<!-- Monetization consent (BRIEF §21): only in builds made with ChronosAdsEnabled=true. -->
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.General.Usage}"
Visibility="{Binding ShowsUsageCounts, Converter={StaticResource BoolToVisibility}}">
<CheckBox Content="{l:Loc Settings.General.UsageCounts}" IsChecked="{Binding UsageCounts}" ToolTip="{l:Loc Tooltips.Settings.UsageCounts}" Margin="0,4,0,0" />
</HeaderedContentControl>
</StackPanel>
<!-- ================= Archive ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Archive}">
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Archive.Root}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="160" MaxWidth="360" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Style="{StaticResource TextBox.Path}" Text="{Binding ArchiveRoot.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding ArchiveRoot}" ToolTip="{Binding ArchiveRoot.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Archive.Root}" />
<Button Grid.Column="1" Style="{StaticResource Button.Icon}" Margin="10,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.FolderOpen}" Command="{Binding BrowseArchiveCommand}"
ToolTip="{l:Loc Tooltips.Settings.BrowseArchive}" AutomationProperties.Name="{l:Loc Settings.Browse}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Hint}" Text="{Binding ArchiveFreeText}" Margin="10,0,0,0" ToolTip="{l:Loc Tooltips.Settings.ArchiveFree}" />
</Grid>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Archive.Folders}">
<TextBox Style="{StaticResource TextBox.SettingMono}" Text="{Binding FolderTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding FolderTemplate}" ToolTip="{Binding FolderTemplate.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Archive.Folders}"
FlowDirection="LeftToRight" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Archive.Files}">
<TextBox Style="{StaticResource TextBox.SettingMono}" Text="{Binding FileTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding FileTemplate}" ToolTip="{Binding FileTemplate.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Archive.Files}"
FlowDirection="LeftToRight" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Archive.Preview}">
<ItemsControl ItemsSource="{Binding PreviewNames}" Focusable="False" Margin="0,7,0,0" ToolTip="{l:Loc Tooltips.Settings.Preview}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontFamily="{StaticResource Font.Mono}" FontSize="12" Foreground="{DynamicResource Brush.TextMuted}" LineHeight="20"
TextTrimming="CharacterEllipsis" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Archive.Proxies}">
<ComboBox Width="170" HorizontalAlignment="Left" ItemsSource="{Binding ProxySizes}" SelectedItem="{Binding SelectedProxySize}" DisplayMemberPath="Label"
ToolTip="{l:Loc Tooltips.Settings.ProxySize}" AutomationProperties.Name="{l:Loc Settings.Archive.Proxies}" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Archive.Thumbnails}">
<ComboBox Width="140" HorizontalAlignment="Left" ItemsSource="{Binding ThumbnailSizes}" SelectedItem="{Binding SelectedThumbnailSize}" DisplayMemberPath="Label"
ToolTip="{l:Loc Tooltips.Settings.ThumbnailSize}" AutomationProperties.Name="{l:Loc Settings.Archive.Thumbnails}" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Archive.Polling}">
<ComboBox Width="140" HorizontalAlignment="Left" ItemsSource="{Binding ScanIntervals}" SelectedItem="{Binding SelectedScanInterval}" DisplayMemberPath="Label"
ToolTip="{l:Loc Tooltips.Settings.Polling}" AutomationProperties.Name="{l:Loc Settings.Archive.Polling}" />
</HeaderedContentControl>
</StackPanel>
<!-- ================= Import: defaults of new cards and folders ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Import}">
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Import.Scan.Sessions}">
<WrapPanel>
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding SessionGap.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding SessionGap}" ToolTip="{Binding SessionGap.ToolTip}" AutomationProperties.Name="{l:Loc Import.Scan.GapName}" />
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Import.Scan.Minutes}" Margin="8,0,20,0" />
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding MinimumFrames.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding MinimumFrames}" ToolTip="{Binding MinimumFrames.ToolTip}" AutomationProperties.Name="{l:Loc Import.Scan.MinimumName}" />
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Import.Scan.Frames}" Margin="8,0,0,0" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Import.Label.Scan}">
<WrapPanel Margin="0,4,0,0">
<CheckBox Content="{l:Loc Import.Scan.Subfolders}" IsChecked="{Binding ImportSubfolders}" ToolTip="{l:Loc Tooltips.Import.Subfolders}" Margin="0,0,20,0" />
<CheckBox Content="{l:Loc Import.Scan.Verify}" IsChecked="{Binding ImportVerify}" ToolTip="{l:Loc Tooltips.Import.Verify}" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Import.Label.Duplicates}">
<WrapPanel Margin="0,4,0,0">
<RadioButton Content="{l:Loc Import.Duplicates.Skip}" IsChecked="{Binding IsSkipDuplicates}" ToolTip="{l:Loc Tooltips.Import.Skip}" Margin="0,0,20,0" />
<RadioButton Content="{l:Loc Import.Duplicates.Again}" IsChecked="{Binding IsImportDuplicates}" ToolTip="{l:Loc Tooltips.Import.Again}" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Import.Label.After}">
<StackPanel Margin="0,4,0,0">
<WrapPanel>
<RadioButton Content="{l:Loc Import.After.Keep}" IsChecked="{Binding IsKeepCard}" ToolTip="{l:Loc Tooltips.Import.KeepCard}" Margin="0,0,20,0" />
<RadioButton Content="{l:Loc Import.After.Delete}" IsChecked="{Binding IsDeleteImported}" ToolTip="{l:Loc Tooltips.Import.DeleteChoice}" Margin="0,0,20,0" />
<RadioButton Content="{l:Loc Import.After.Format}" IsChecked="{Binding IsFormatCard}" ToolTip="{l:Loc Tooltips.Import.FormatChoice}" />
</WrapPanel>
<CheckBox Content="{l:Loc Import.After.Eject}" IsChecked="{Binding ImportEject}" ToolTip="{l:Loc Tooltips.Import.EjectChoice}" HorizontalAlignment="Left" Margin="0,10,0,0" />
</StackPanel>
</HeaderedContentControl>
</StackPanel>
<!-- ================= Analysis ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Analysis}">
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Analysis.Width}">
<WrapPanel>
<ComboBox Width="140" ItemsSource="{Binding AnalysisWidths}" SelectedItem="{Binding SelectedAnalysisWidth}" DisplayMemberPath="Label"
ToolTip="{l:Loc Tooltips.Settings.AnalysisWidth}" AutomationProperties.Name="{l:Loc Settings.Analysis.Width}" />
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Settings.Analysis.WidthUnit}" Margin="12,0,0,0" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Analysis.Night}">
<WrapPanel>
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding NightBrightness.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding NightBrightness}" ToolTip="{Binding NightBrightness.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Analysis.Night}" />
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Settings.Analysis.NightUnit}" Margin="12,0,0,0" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Analysis.Stars}">
<WrapPanel>
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding StarDensity.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding StarDensity}" ToolTip="{Binding StarDensity.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Analysis.Stars}" />
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Settings.Analysis.StarsUnit}" Margin="12,0,0,0" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Analysis.Deep}">
<WrapPanel Margin="0,4,0,0">
<CheckBox Content="{l:Loc Settings.Analysis.AfterImport}" IsChecked="{Binding DeepAnalysisAfterImport}" ToolTip="{l:Loc Tooltips.Settings.DeepAfterImport}" Margin="0,0,20,0" />
<CheckBox Content="{l:Loc Settings.Analysis.AfterScan}" IsChecked="{Binding DeepAnalysisAfterScan}" ToolTip="{l:Loc Tooltips.Settings.DeepAfterScan}" />
</WrapPanel>
</HeaderedContentControl>
</StackPanel>
<!-- ================= Rendering (Settings.html) ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Rendering}">
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Rendering.Quality}">
<ComboBox Width="170" HorizontalAlignment="Left" ItemsSource="{Binding Qualities}" SelectedItem="{Binding SelectedQuality}" DisplayMemberPath="Label"
ToolTip="{l:Loc Tooltips.Settings.QualityProfile}" AutomationProperties.Name="{l:Loc Settings.Rendering.Quality}" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Rendering.Memory}">
<WrapPanel>
<Slider Style="{StaticResource Slider.Budget}" Width="320" Minimum="{Binding MemoryMinimum}" Maximum="{Binding MemoryMaximum}" Value="{Binding MemoryBudget}"
TickFrequency="1" IsSnapToTickEnabled="True" SmallChange="1" LargeChange="2" VerticalAlignment="Center"
ToolTip="{l:Loc Tooltips.Settings.Memory}" AutomationProperties.Name="{l:Loc Settings.Rendering.Memory}" />
<TextBlock Text="{Binding MemoryText}" Margin="12,0,0,0" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<TextBlock Style="{StaticResource Text.Hint}" Text="{Binding InstalledText}" Margin="12,0,0,0" />
<Border Style="{StaticResource Pill.Auto}" Margin="12,0,0,0" VerticalAlignment="Center" ToolTip="{l:Loc Tooltips.Settings.MemoryAuto}"
Visibility="{Binding IsMemoryAuto, Converter={StaticResource BoolToVisibility}}">
<TextBlock Style="{StaticResource Text.AutoPill}" Text="{Binding MemoryAutoText}" />
</Border>
<Button Style="{StaticResource Button.Reset}" Margin="12,0,0,0" Command="{Binding ResetMemoryCommand}" ToolTip="{l:Loc Tooltips.Settings.MemoryReset}"
AutomationProperties.Name="{l:Loc Settings.BackToAuto}"
Visibility="{Binding IsMemoryAuto, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Rendering.Parallelism}">
<WrapPanel>
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding Parallelism.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding Parallelism}" ToolTip="{Binding Parallelism.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Rendering.Parallelism}" />
<TextBlock Style="{StaticResource Text.Hint}" Text="{Binding CoresText}" Margin="12,0,0,0" />
<Border Style="{StaticResource Pill.Auto}" Margin="12,0,0,0" VerticalAlignment="Center" ToolTip="{l:Loc Tooltips.Settings.ParallelismAuto}"
Visibility="{Binding IsParallelismAuto, Converter={StaticResource BoolToVisibility}}">
<TextBlock Style="{StaticResource Text.AutoPill}" Text="{Binding ParallelismAutoText}" />
</Border>
<Button Style="{StaticResource Button.Reset}" Margin="12,0,0,0" Command="{Binding ResetParallelismCommand}" ToolTip="{l:Loc Tooltips.Settings.ParallelismReset}"
AutomationProperties.Name="{l:Loc Settings.BackToAuto}"
Visibility="{Binding IsParallelismAuto, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<CheckBox Content="{l:Loc Settings.Rendering.Background}" IsChecked="{Binding BackgroundPriority}" ToolTip="{l:Loc Tooltips.Settings.InterfacePriority}"
Margin="24,0,0,0" VerticalAlignment="Center" />
</WrapPanel>
</HeaderedContentControl>
<!-- Owner review 1: jobs run one at a time; the priority queue lets a higher kind pause the running job. -->
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Rendering.PriorityQueue}">
<StackPanel Margin="0,4,0,0">
<CheckBox Content="{l:Loc Settings.Rendering.PriorityQueueOn}" IsChecked="{Binding PriorityQueue}" ToolTip="{l:Loc Tooltips.Settings.PriorityQueue}"
HorizontalAlignment="Left" />
<ItemsControl ItemsSource="{Binding JobPriorities}" Margin="0,8,0,0" Focusable="False"
Visibility="{Binding PriorityQueue, Converter={StaticResource BoolToVisibility}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Width="300" Margin="0,0,16,6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="112" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Label}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" Margin="0,0,8,0" ToolTip="{Binding Label}" />
<ComboBox Grid.Column="1" ItemsSource="{Binding Levels}" SelectedItem="{Binding Selected}" DisplayMemberPath="Label"
ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Rendering.Hardware}">
<WrapPanel Margin="0,4,0,0">
<RadioButton Content="{l:Loc Settings.Rendering.PreferHardware}" IsChecked="{Binding IsPreferHardware}" ToolTip="{l:Loc Tooltips.Settings.PreferHardware}" Margin="0,0,18,0" />
<RadioButton Content="{l:Loc Settings.Rendering.SoftwareOnly}" IsChecked="{Binding IsSoftwareOnly}" ToolTip="{l:Loc Tooltips.Settings.SoftwareOnly}" Margin="0,0,18,0" />
<RadioButton Content="{l:Loc Settings.Rendering.PreviewsOnly}" IsChecked="{Binding IsHardwareForPreviews}" ToolTip="{l:Loc Tooltips.Settings.PreviewsOnly}" />
</WrapPanel>
</HeaderedContentControl>
<!-- Encoders on this PC (title, adapter, Re-detect, Run self-test: visual and Tab order). -->
<Grid Margin="0,4,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{l:Loc Settings.Rendering.Encoders}" FontWeight="SemiBold" VerticalAlignment="Center" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Hint}" Text="{Binding AdapterText}" Margin="10,0,0,0" ToolTip="{Binding AdapterToolTip}" />
<Button Grid.Column="2" Style="{StaticResource Button.Compact}" Content="{l:Loc Settings.Rendering.Redetect}" Command="{Binding RedetectCommand}"
ToolTip="{l:Loc Tooltips.Settings.Redetect}" Margin="8,0,0,0" />
<Button Grid.Column="3" Style="{StaticResource Button.Compact}" Content="{l:Loc Settings.Rendering.SelfTest}" Command="{Binding SelfTestCommand}"
ToolTip="{l:Loc Tooltips.Settings.SelfTest}" Margin="8,0,0,0" />
</Grid>
<!-- Settings.html encoder table: codec, encoder, 10-bit, max size, self-test (announced as it moves on), presets served. -->
<Border Style="{StaticResource Border.Card}">
<StackPanel>
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="14,8">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="96" />
<ColumnDefinition Width="1.2*" MinWidth="140" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="130" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Rendering.Column.Codec}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Rendering.Column.Encoder}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Rendering.Column.TenBit}" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Rendering.Column.Max}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Rendering.Column.SelfTest}" Margin="10,0,0,0" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Rendering.Column.UsedFor}" Margin="10,0,0,0" />
</Grid>
</Border>
<ItemsControl ItemsSource="{Binding Encoders}" Focusable="False">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type st:EncoderRowViewModel}">
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Height="36" Padding="14,0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="96" />
<ColumnDefinition Width="1.2*" MinWidth="140" />
<ColumnDefinition Width="70" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="130" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Codec}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Name}" Margin="10,0,0,0" ToolTip="{Binding Name}" />
<TextBlock x:Name="TenBit" Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding TenBitText}" Margin="10,0,0,0" Foreground="{DynamicResource Brush.TextFaint}" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Cell}" Text="{Binding MaxText}" Margin="10,0,0,0" ToolTip="{Binding MaxText}" />
<ui:StatusGlyph Grid.Column="4" Kind="{Binding ResultKind}" Text="{Binding ResultText}" ToolTip="{Binding ResultToolTip}" FontSize="13"
VerticalAlignment="Center" Margin="10,0,0,0" Visibility="{Binding HasResult, Converter={StaticResource BoolToVisibility}}"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding ResultAnnouncement}" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.Cell}" Text="{Binding UsedForText}" ToolTip="{Binding UsedForText}"
Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" />
</Grid>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding HasTenBit}" Value="True">
<Setter TargetName="TenBit" Property="Foreground" Value="{DynamicResource Brush.Success}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Border>
</StackPanel>
<!-- ================= Formats (BRIEF §8.1): missing-codec notices, then the tier of every format on this PC ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Formats}">
<ItemsControl ItemsSource="{Binding MissingExtensions}" Focusable="False" Margin="0,0,0,8"
Visibility="{Binding HasMissingExtensions, Converter={StaticResource BoolToVisibility}}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type st:MissingExtensionViewModel}">
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:StatusGlyph Kind="Warning" Text="{Binding Text}" FontSize="13" VerticalAlignment="Center" ToolTip="{l:Loc Tooltips.Settings.MissingCodec}" />
<Button Grid.Column="1" Style="{StaticResource Button.Compact}" Content="{l:Loc Settings.Formats.Install}" Command="{Binding InstallCommand}"
ToolTip="{l:Loc Tooltips.Settings.Install}" AutomationProperties.Name="{Binding InstallName}" Margin="12,0,0,0" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{l:Loc Settings.Formats.Title}" FontWeight="SemiBold" VerticalAlignment="Center" />
<Button Grid.Column="1" Style="{StaticResource Button.Compact}" Content="{l:Loc Settings.Rendering.Redetect}" Command="{Binding RedetectFormatsCommand}"
ToolTip="{l:Loc Tooltips.Settings.RedetectFormats}" />
</Grid>
<!-- Format, extensions, tier on this PC (glyph and word), decoder, extension that would decode it fully. -->
<Border Style="{StaticResource Border.Card}">
<StackPanel>
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="14,8">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
<ColumnDefinition Width="140" />
<ColumnDefinition Width="Auto" MinWidth="130" SharedSizeGroup="FormatTier" />
<ColumnDefinition Width="Auto" MinWidth="110" SharedSizeGroup="FormatDecoder" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Formats.Column.Format}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Formats.Column.Extensions}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Formats.Column.Tier}" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Formats.Column.Decoder}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.Header}" Text="{l:Loc Settings.Formats.Column.Needs}" Margin="10,0,0,0" />
</Grid>
</Border>
<ItemsControl ItemsSource="{Binding Formats}" Focusable="False">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type st:FormatRowViewModel}">
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Height="36" Padding="14,0"
AutomationProperties.Name="{Binding Announcement}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
<ColumnDefinition Width="140" />
<ColumnDefinition Width="Auto" MinWidth="130" SharedSizeGroup="FormatTier" />
<ColumnDefinition Width="Auto" MinWidth="110" SharedSizeGroup="FormatDecoder" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Name}" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Extensions}" ToolTip="{Binding Extensions}" FontFamily="{StaticResource Font.Mono}"
FontSize="12" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
<ui:StatusGlyph Grid.Column="2" Kind="{Binding TierKind}" Text="{Binding TierText}" ToolTip="{Binding TierToolTip}" FontSize="13"
VerticalAlignment="Center" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Cell}" Text="{Binding DecoderText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.Cell}" Text="{Binding NeedsText}" ToolTip="{Binding NeedsText}"
Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" />
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Border>
</StackPanel>
<!-- ================= Storage ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Storage}">
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Storage.Folder}">
<!-- Path, browse, usage, Clear on one line: the path gives way first (Settings.html), down to 110 px, so the row fits at 1200 px
beside the 200 px rail in every language. -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="110" MaxWidth="360" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Style="{StaticResource TextBox.Path}" Text="{Binding CacheFolder.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding CacheFolder}" ToolTip="{Binding CacheFolder.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Storage.Folder}" />
<Button Grid.Column="1" Style="{StaticResource Button.Icon}" Margin="10,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.FolderOpen}" Command="{Binding BrowseCacheCommand}"
ToolTip="{l:Loc Tooltips.Settings.BrowseCache}" AutomationProperties.Name="{l:Loc Settings.Browse}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Hint}" Text="{Binding CacheUsageText}" Margin="10,0,0,0" ToolTip="{l:Loc Tooltips.Settings.CacheUsage}" />
<Button Grid.Column="3" Style="{StaticResource Button.Compact}" Content="{l:Loc Settings.Storage.Clear}" Command="{Binding ClearCacheCommand}"
ToolTip="{l:Loc Tooltips.Settings.ClearCacheAsk}" Margin="10,0,0,0" />
</Grid>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Storage.Thumbnails}">
<WrapPanel>
<TextBox Style="{StaticResource TextBox.SettingNumber}" Width="96" Text="{Binding ThumbnailMemory.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding ThumbnailMemory}" ToolTip="{Binding ThumbnailMemory.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Storage.Thumbnails}" />
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Settings.Storage.ThumbnailsUnit}" Margin="12,0,0,0" />
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Storage.Limit}">
<WrapPanel>
<TextBox Style="{StaticResource TextBox.SettingNumber}" Text="{Binding CacheLimit.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding CacheLimit}" ToolTip="{Binding CacheLimit.ToolTip}" AutomationProperties.Name="{l:Loc Settings.Storage.Limit}" />
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Settings.Storage.LimitUnit}" Margin="12,0,0,0" />
</WrapPanel>
</HeaderedContentControl>
</StackPanel>
<!-- ================= Server ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Server}">
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.Default}">
<TextBox Style="{StaticResource TextBox.Setting}" Text="{Binding DefaultServer.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding DefaultServer}" ToolTip="{Binding DefaultServer.ToolTip}" ui:Field.Placeholder="{l:Loc Server.AddressPlaceholder}"
AutomationProperties.Name="{l:Loc Settings.Server.Default}" FlowDirection="LeftToRight" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.RenderNode}">
<CheckBox Content="{l:Loc Settings.Server.OfferPc}" IsChecked="{Binding RenderNodeOptIn}" ToolTip="{l:Loc Tooltips.Server.RenderNode}" Margin="0,4,0,0" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Server.Certificates}">
<Grid>
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Settings.Server.NoCertificates}" Margin="0,7,0,0" VerticalAlignment="Top"
Visibility="{Binding HasCertificates, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<ItemsControl ItemsSource="{Binding Certificates}" Focusable="False" Visibility="{Binding HasCertificates, Converter={StaticResource BoolToVisibility}}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type st:TrustedCertificateRow}">
<Grid Height="36">
<!-- The server name gives way first (it ends in an ellipsis), so Forget fits at 1200 px in longer languages. -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="120" />
<ColumnDefinition Width="170" />
<ColumnDefinition Width="110" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Server}" ToolTip="{Binding Server}" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Fingerprint}" FontFamily="{StaticResource Font.Mono}" FontSize="12"
ToolTip="{Binding FullFingerprint}" Margin="10,0,0,0" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding TrustedText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" />
<Button Grid.Column="3" Style="{StaticResource Button.Row}" Content="{l:Loc Server.Certificate.Forget}" Command="{Binding ForgetCommand}"
ToolTip="{l:Loc Tooltips.Server.ForgetTrust}" AutomationProperties.Name="{Binding ForgetName}" Margin="10,0,0,0" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</HeaderedContentControl>
</StackPanel>
<!-- ================= Updates ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Updates}">
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.General.Updates}">
<CheckBox Content="{l:Loc Settings.General.CheckOnStart}" IsChecked="{Binding CheckForUpdates}" ToolTip="{l:Loc Tooltips.Settings.CheckForUpdates}" Margin="0,4,0,0" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Updates.Latest}">
<WrapPanel>
<Button Content="{l:Loc About.Update.Check}" Command="{Binding Shell.About.CheckCommand}" ToolTip="{l:Loc Tooltips.About.Check}" />
<ui:StatusGlyph Kind="{Binding Shell.About.UpdateKind}" Text="{Binding Shell.About.UpdateText}" FontSize="13" VerticalAlignment="Center" Margin="12,0,0,0"
Visibility="{Binding Shell.About.HasUpdateText, Converter={StaticResource BoolToVisibility}}"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding Shell.About.UpdateAnnouncement}" />
<Button Style="{StaticResource Button.Link}" Content="{l:Loc About.Update.Download}" Command="{Binding Shell.About.DownloadCommand}" ToolTip="{Binding Shell.About.DownloadToolTip}"
VerticalAlignment="Center" Margin="12,0,0,0" FontSize="13"
Visibility="{Binding Shell.About.IsUpdateAvailable, Converter={StaticResource BoolToVisibility}}" />
<Button Style="{StaticResource Button.Link}" Content="{l:Loc About.Update.Cancel}" Command="{Binding Shell.About.CancelDownloadCommand}" ToolTip="{l:Loc Tooltips.About.CancelDownload}"
VerticalAlignment="Center" Margin="12,0,0,0" FontSize="13"
Visibility="{Binding Shell.About.IsDownloading, Converter={StaticResource BoolToVisibility}}" />
<Button Style="{StaticResource Button.Link}" Content="{l:Loc About.Update.ShowFile}" Command="{Binding Shell.About.ShowPackageCommand}" ToolTip="{Binding Shell.About.ShowPackageToolTip}"
VerticalAlignment="Center" Margin="12,0,0,0" FontSize="13"
Visibility="{Binding Shell.About.IsPackageReady, Converter={StaticResource BoolToVisibility}}" />
</WrapPanel>
</HeaderedContentControl>
</StackPanel>
<!-- ================= Advanced ================= -->
<StackPanel Style="{StaticResource Page}" Visibility="{Binding Page, Converter={x:Static shell:EqualsToVisibilityConverter.Instance}, ConverterParameter=Advanced}">
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Advanced.Portable}">
<TextBlock Text="{Binding PortableText}" Margin="0,7,0,0" ToolTip="{l:Loc Tooltips.Settings.Portable}" />
</HeaderedContentControl>
<!-- Read-only folders: the full path in the tooltip; Open says what it does. -->
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Advanced.DataFolder}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="160" MaxWidth="360" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Style="{StaticResource TextBox.Path}" IsReadOnly="True" Text="{Binding DataFolder, Mode=OneWay}" ToolTip="{Binding DataFolder}"
AutomationProperties.Name="{l:Loc Settings.Advanced.DataFolder}" />
<Button Grid.Column="1" Content="{l:Loc Common.Open}" Command="{Binding OpenDataFolderCommand}" ToolTip="{l:Loc Tooltips.Settings.OpenDataFolder}" Margin="10,0,0,0" />
</Grid>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Advanced.Logs}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="160" MaxWidth="360" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox Style="{StaticResource TextBox.Path}" IsReadOnly="True" Text="{Binding LogsFolder, Mode=OneWay}" ToolTip="{Binding LogsFolder}"
AutomationProperties.Name="{l:Loc Settings.Advanced.Logs}" />
<Button Grid.Column="1" Content="{l:Loc Common.Open}" Command="{Binding OpenLogsCommand}" ToolTip="{l:Loc Tooltips.Common.OpenLogs}" Margin="10,0,0,0" />
</Grid>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Advanced.Diagnostics}">
<Button HorizontalAlignment="Left" Content="{l:Loc Settings.Advanced.ExportBundle}" Command="{Binding ExportDiagnosticsCommand}" ToolTip="{l:Loc Tooltips.Settings.Diagnostics}"
ui:ButtonIcon.Glyph="{StaticResource Icon.Export}" />
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Advanced.Backup}">
<Button HorizontalAlignment="Left" Content="{l:Loc Settings.Advanced.BackupNow}" Command="{Binding BackupDatabaseCommand}" ToolTip="{l:Loc Tooltips.Settings.Backup}"
ui:ButtonIcon.Glyph="{StaticResource Icon.Database}" />
</HeaderedContentControl>
<!-- Restore: a daily copy, its dry run and confirmation; it replaces the index at the next start. -->
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Advanced.Restore}">
<WrapPanel>
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Settings.Advanced.NoBackups}" Margin="0,0,12,0"
Visibility="{Binding HasBackups, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<WrapPanel Visibility="{Binding HasBackups, Converter={StaticResource BoolToVisibility}}" Margin="0,0,12,0">
<ComboBox Width="240" ItemsSource="{Binding Backups}" SelectedItem="{Binding SelectedBackup}" DisplayMemberPath="Label"
ToolTip="{l:Loc Tooltips.Settings.Backups}" AutomationProperties.Name="{l:Loc Settings.Advanced.Restore}" />
<Button Content="{l:Loc Settings.Advanced.RestoreNow}" Command="{Binding RestoreDatabaseCommand}" ToolTip="{l:Loc Tooltips.Settings.Restore}" Margin="10,0,0,0" />
</WrapPanel>
<!-- A staged restore can be cancelled even when its copy has been pruned since. -->
<WrapPanel Visibility="{Binding IsRestoreStaged, Converter={StaticResource BoolToVisibility}}">
<TextBlock Style="{StaticResource Text.Hint}" Text="{l:Loc Settings.Advanced.RestorePending}" ToolTip="{l:Loc Tooltips.Settings.RestorePending}" />
<Button Style="{StaticResource Button.Link}" Content="{l:Loc Settings.Advanced.RestoreCancel}" Command="{Binding CancelRestoreCommand}"
ToolTip="{l:Loc Tooltips.Settings.RestoreCancel}" VerticalAlignment="Center" Margin="12,0,0,0" FontSize="13" />
</WrapPanel>
</WrapPanel>
</HeaderedContentControl>
<HeaderedContentControl Style="{StaticResource Setting.Row}" Header="{l:Loc Settings.Advanced.Reset}">
<Button Style="{StaticResource Button.Destructive}" HorizontalAlignment="Left" Content="{l:Loc Settings.Advanced.ResetAll}" Command="{Binding ResetAllCommand}"
ToolTip="{l:Loc Tooltips.Settings.ResetAll}" />
</HeaderedContentControl>
</StackPanel>
</Grid>
</ScrollViewer>
<!-- Reset section: only on pages with settings to reset. -->
<Border Grid.Row="2" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,1,0,0" Padding="0,12,0,0" Margin="0,12,0,0"
Visibility="{Binding CanResetSection, Converter={StaticResource BoolToVisibility}}">
<Button Style="{StaticResource Button.Subtle}" HorizontalAlignment="Right" Content="{l:Loc Settings.ResetSection}" Command="{Binding ResetSectionCommand}"
ToolTip="{l:Loc Tooltips.Settings.ResetSection}" BorderBrush="{DynamicResource Brush.Stroke}" Foreground="{DynamicResource Brush.TextMuted}" />
</Border>
</Grid>
</Border>
</Grid>
</UserControl>
@@ -0,0 +1,8 @@
using System.Windows.Controls;
namespace Chronos.App.Sections;
public partial class SettingsView : UserControl
{
public SettingsView() => InitializeComponent();
}
File diff suppressed because it is too large. Load diff
+124
View File
@@ -0,0 +1,124 @@
<UserControl x:Class="Chronos.App.Sections.WelcomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:Chronos.Ui.Controls;assembly=Chronos.Ui"
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui">
<UserControl.Resources>
<!-- Welcome.html choice: 68 px card, highlighted = accent border with the AccentSelected glow. -->
<Style x:Key="RadioButton.Choice" TargetType="RadioButton">
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Ring}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
<Setter Property="Height" Value="68" />
<Setter Property="Margin" Value="0,0,0,10" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid>
<Border x:Name="Glow" Margin="-3" CornerRadius="11" BorderThickness="3" BorderBrush="{DynamicResource Brush.AccentSelected}" Visibility="Collapsed" />
<Border x:Name="Bd" Background="{DynamicResource Brush.Card}" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="1"
CornerRadius="{StaticResource Radius.Card}" Padding="16,0">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Stretch" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.CardHover}" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter TargetName="Glow" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Text.ChoiceTitle" TargetType="TextBlock">
<Setter Property="FontSize" Value="14" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
</Style>
<Style x:Key="Text.ChoiceDetail" TargetType="TextBlock">
<Setter Property="FontSize" Value="12" />
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
<Setter Property="Margin" Value="0,3,0,0" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
</Style>
</UserControl.Resources>
<!-- A modal dialog over the dimmed shell: Tab, Ctrl+Tab and the arrows stay inside it, and it opens with focus on the chosen card. -->
<Border Width="640" Background="{DynamicResource Brush.Surface}" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="1"
CornerRadius="{StaticResource Radius.Dialog}" Padding="32,28" Effect="{StaticResource Shadow.Popup}"
KeyboardNavigation.TabNavigation="Cycle" KeyboardNavigation.ControlTabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Contained">
<StackPanel>
<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" />
<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" />
</StackPanel>
</DockPanel>
<StackPanel Margin="0,20,0,0">
<!-- Create a local archive -->
<RadioButton x:Name="LocalChoice" Style="{StaticResource RadioButton.Choice}" IsChecked="{Binding IsLocal}" ToolTip="{l:Loc Tooltips.Welcome.Local}"
AutomationProperties.Name="{l:Loc Shell.Welcome.Local}">
<DockPanel>
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Subtle}" Content="{l:Loc Shell.Welcome.Change}" Command="{Binding ChangeRootCommand}"
ToolTip="{l:Loc Tooltips.Welcome.Change}" Foreground="{DynamicResource Brush.TextMuted}" />
<ui:Icon Glyph="{StaticResource Icon.Folder}" Size="24" Foreground="{DynamicResource Brush.Accent}" VerticalAlignment="Center" />
<StackPanel Margin="14,0,8,0" VerticalAlignment="Center">
<TextBlock Style="{StaticResource Text.ChoiceTitle}" Text="{l:Loc Shell.Welcome.Local}" />
<TextBlock Style="{StaticResource Text.ChoiceDetail}" Text="{Binding LocalDetail}" Typography.NumeralAlignment="Tabular" />
</StackPanel>
</DockPanel>
</RadioButton>
<!-- Adopt an existing folder -->
<RadioButton x:Name="AdoptChoice" Style="{StaticResource RadioButton.Choice}" IsChecked="{Binding IsAdopt}" ToolTip="{l:Loc Tooltips.Welcome.Adopt}"
AutomationProperties.Name="{l:Loc Shell.Welcome.Adopt}">
<DockPanel>
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Subtle}" Content="{l:Loc Shell.Welcome.Choose}" Command="{Binding ChooseAdoptCommand}"
ToolTip="{l:Loc Tooltips.Welcome.Choose}" Foreground="{DynamicResource Brush.TextMuted}" />
<ui:Icon Glyph="{StaticResource Icon.Archive}" Size="24" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" />
<StackPanel Margin="14,0,8,0" VerticalAlignment="Center">
<TextBlock Style="{StaticResource Text.ChoiceTitle}" Text="{l:Loc Shell.Welcome.Adopt}" />
<TextBlock Style="{StaticResource Text.ChoiceDetail}" Text="{Binding AdoptDetail}" Visibility="{Binding HasAdoptDetail, Converter={StaticResource BoolToVisibility}}" />
</StackPanel>
</DockPanel>
</RadioButton>
<!-- Connect to a server -->
<RadioButton x:Name="ServerChoice" Style="{StaticResource RadioButton.Choice}" IsChecked="{Binding IsServer}" ToolTip="{l:Loc Tooltips.Welcome.Server}"
AutomationProperties.Name="{l:Loc Shell.Welcome.Server}" Margin="0">
<DockPanel>
<ui:StatusGlyph DockPanel.Dock="Right" Kind="Online" Text="{l:Loc Shell.Welcome.Found}" VerticalAlignment="Center" ToolTip="{l:Loc Tooltips.Welcome.Found}"
Visibility="{Binding IsServerDiscovered, Converter={StaticResource BoolToVisibility}}" />
<ui:Icon Glyph="{StaticResource Icon.Server}" Size="24" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" />
<StackPanel Margin="14,0,8,0" VerticalAlignment="Center">
<TextBlock Style="{StaticResource Text.ChoiceTitle}" Text="{l:Loc Shell.Welcome.Server}" />
<TextBlock Style="{StaticResource Text.ChoiceDetail}" Text="{Binding ServerDetail}" Visibility="{Binding HasServerDetail, Converter={StaticResource BoolToVisibility}}" />
</StackPanel>
</DockPanel>
</RadioButton>
</StackPanel>
<!-- Consent, then Continue (visual and Tab order); the consent has the same label as in Settings and, like all of
monetization (BRIEF §21), shows only in builds made with ChronosAdsEnabled=true. -->
<Grid Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox Content="{l:Loc Settings.General.UsageCounts}" IsChecked="{Binding UsageCounts}" ToolTip="{l:Loc Tooltips.Settings.UsageCounts}" VerticalAlignment="Center"
HorizontalAlignment="Left" Foreground="{DynamicResource Brush.TextMuted}"
Visibility="{Binding ShowsUsageCounts, Converter={StaticResource BoolToVisibility}}" />
<Button Grid.Column="1" Style="{StaticResource Button.Primary}" Height="36" Padding="22,0" Margin="12,0,0,0" Content="{l:Loc Shell.Welcome.Continue}"
Command="{Binding ContinueCommand}" ToolTip="{l:Loc Tooltips.Welcome.Continue}" IsDefault="True" />
</Grid>
</StackPanel>
</Border>
</UserControl>
@@ -0,0 +1,28 @@
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
namespace Chronos.App.Sections;
public partial class WelcomeView : UserControl
{
public WelcomeView()
{
InitializeComponent();
IsVisibleChanged += (_, e) =>
{
if (e.NewValue is true) Dispatcher.InvokeAsync(FocusChoice, DispatcherPriority.Input);
};
}
/// <summary>
/// The dialog opens with focus on the chosen card, so the keyboard starts inside it; the window keeps it as its focused
/// element, so a window not active yet gives the card keyboard focus when activated.
/// </summary>
private void FocusChoice()
{
var chosen = new[] { LocalChoice, AdoptChoice, ServerChoice }.FirstOrDefault(c => c.IsChecked == true) ?? LocalChoice;
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(chosen), chosen);
Keyboard.Focus(chosen);
}
}
@@ -0,0 +1,234 @@
using System.Collections.Specialized;
using System.Windows.Input;
using Chronos.App.Infrastructure;
using Chronos.App.Server;
using Chronos.App.Settings;
using Chronos.App.Shell;
using Chronos.Core.Diagnostics;
using Chronos.Core.Localization;
using Chronos.Ui.Mvvm;
namespace Chronos.App.Sections;
/// <summary>Where the time-lapses live (first run).</summary>
public enum WelcomeChoice
{
LocalArchive,
AdoptFolder,
Server,
}
/// <summary>
/// First run (BRIEF §12.1, Welcome.html): create a local archive, adopt an existing folder or connect to a server,
/// plus the language and the anonymous-usage consent. Shown once; the archive actions go through
/// <see cref="IArchiveSetup"/>.
/// </summary>
public sealed class WelcomeViewModel : LocalizedViewModel
{
private readonly ShellViewModel _shell;
private WelcomeChoice _choice = WelcomeChoice.LocalArchive;
private string _localRoot;
private string? _adoptFolder;
private bool _isBusy;
public WelcomeViewModel(ShellViewModel shell)
{
_shell = shell;
_localRoot = shell.Services.Settings.LastArchivePath ?? ArchiveLocations.SuggestRoot();
ChooseCommand = new RelayCommand(p =>
{
if (p is WelcomeChoice choice) Choice = choice;
else if (p is string name && Enum.TryParse<WelcomeChoice>(name, out var parsed)) Choice = parsed;
});
ChangeRootCommand = new RelayCommand(ChangeRoot);
ChooseAdoptCommand = new RelayCommand(() => PickAdoptFolder());
ContinueCommand = new AsyncRelayCommand(ContinueAsync, () => !_isBusy);
shell.Services.Server.Discovered.CollectionChanged += OnDiscovered;
if (!shell.Services.Environment.IsCapture) shell.Services.Server.StartDiscovery();
}
public ICommand ChooseCommand { get; }
public ICommand ChangeRootCommand { get; }
public ICommand ChooseAdoptCommand { get; }
public ICommand ContinueCommand { get; }
public WelcomeChoice Choice
{
get => _choice;
set
{
if (!Set(ref _choice, value)) return;
OnPropertyChanged(nameof(IsLocal));
OnPropertyChanged(nameof(IsAdopt));
OnPropertyChanged(nameof(IsServer));
}
}
public bool IsLocal
{
get => _choice == WelcomeChoice.LocalArchive;
set
{
if (value) Choice = WelcomeChoice.LocalArchive;
}
}
public bool IsAdopt
{
get => _choice == WelcomeChoice.AdoptFolder;
set
{
if (value) Choice = WelcomeChoice.AdoptFolder;
}
}
public bool IsServer
{
get => _choice == WelcomeChoice.Server;
set
{
if (value) Choice = WelcomeChoice.Server;
}
}
public string LocalRoot
{
get => _localRoot;
private set
{
if (Set(ref _localRoot, value)) OnPropertyChanged(nameof(LocalDetail));
}
}
/// <summary>"D:\ChronosArchive · 1.8 TB free" (the path left to right in every language).</summary>
public string LocalDetail => ArchiveLocations.FreeSpace(_localRoot) is { } free
? Loc.L("Shell.Welcome.Local.Detail", Formatting.LeftToRight(_localRoot), Formatting.Bytes(free))
: Formatting.LeftToRight(_localRoot);
/// <summary>The chosen folder to adopt; null until picked.</summary>
public string? AdoptDetail => _adoptFolder is { } folder ? Formatting.LeftToRight(folder) : null;
public bool HasAdoptDetail => _adoptFolder is not null;
/// <summary>The first server announced on the LAN (or the saved one).</summary>
public DiscoveredServer? FoundServer =>
_shell.Services.Server.Discovered.FirstOrDefault()
?? (_shell.Services.Settings.ServerUrl is { } saved ? new DiscoveredServer(saved, saved) : null);
/// <summary>"Studio NAS on this network · https://nas.local:8443".</summary>
public string? ServerDetail => FoundServer is { } s
? s.Name == s.Address ? Formatting.LeftToRight(s.Address) : Loc.L("Shell.Welcome.Server.Found", s.Name, Formatting.LeftToRight(s.Address))
: null;
public bool HasServerDetail => ServerDetail is not null;
/// <summary>A server was heard on the LAN (the green dot).</summary>
public bool IsServerDiscovered => _shell.Services.Server.Discovered.Count > 0;
public IReadOnlyList<LanguageOption> Languages => LanguageCatalog.Available;
public LanguageOption SelectedLanguage
{
get => LanguageCatalog.Match(Loc.Culture);
set
{
if (value is null || value == SelectedLanguage) return;
_shell.Services.Settings.Language = value.Code;
UiLanguage.Apply(value.Code);
_shell.Services.SaveSettings();
}
}
/// <summary>The usage counts consent belongs to monetization (BRIEF §21): only builds with it enabled offer it.</summary>
public bool ShowsUsageCounts => ProductFeatures.AdsEnabled;
public bool UsageCounts
{
get => _shell.Services.Settings.AnonymousUsageCounts;
set
{
_shell.Services.Settings.AnonymousUsageCounts = value;
OnPropertyChanged();
}
}
public bool IsBusy
{
get => _isBusy;
private set => Set(ref _isBusy, value);
}
/// <summary>Sample state for screenshots: a server heard on the LAN.</summary>
internal void ShowDiscovered(DiscoveredServer server)
{
if (!_shell.Services.Server.Discovered.Contains(server)) _shell.Services.Server.Discovered.Add(server);
}
public override void Dispose()
{
_shell.Services.Server.Discovered.CollectionChanged -= OnDiscovered;
base.Dispose();
}
private void OnDiscovered(object? sender, NotifyCollectionChangedEventArgs e)
{
OnPropertyChanged(nameof(FoundServer));
OnPropertyChanged(nameof(ServerDetail));
OnPropertyChanged(nameof(HasServerDetail));
OnPropertyChanged(nameof(IsServerDiscovered));
}
private void ChangeRoot()
{
var folder = _shell.Services.Dialogs.PickFolder(Loc.L("Shell.Welcome.Local.PickTitle"), LocalRoot);
if (folder is null) return;
LocalRoot = folder;
Choice = WelcomeChoice.LocalArchive;
}
private bool PickAdoptFolder()
{
var folder = _shell.Services.Dialogs.PickFolder(Loc.L("Library.Adopt.Title"));
if (folder is null) return false;
_adoptFolder = folder;
OnPropertyChanged(nameof(AdoptDetail));
OnPropertyChanged(nameof(HasAdoptDetail));
Choice = WelcomeChoice.AdoptFolder;
return true;
}
private async Task ContinueAsync()
{
IsBusy = true;
try
{
switch (_choice)
{
case WelcomeChoice.LocalArchive:
if (ArchiveLocations.Validate(LocalRoot) is { } problem)
{
_shell.Notify(problem, isError: true);
return;
}
if (!await ArchiveActions.TryAsync(_shell, s => s.CreateAsync(LocalRoot))) return;
break;
case WelcomeChoice.AdoptFolder:
if (_adoptFolder is null && !PickAdoptFolder()) return;
if (!await ArchiveActions.TryAsync(_shell, s => s.AdoptAsync(_adoptFolder!))) return;
break;
case WelcomeChoice.Server:
if (FoundServer is { } server) _shell.Server.Address = server.Address;
break;
}
_shell.Services.SaveSettings();
_shell.CompleteWelcome();
Log.Info("app", $"First run completed: {_choice}");
if (_choice == WelcomeChoice.Server) _shell.Navigate(SectionKey.Server);
else await _shell.Library.RefreshAsync();
}
finally
{
IsBusy = false;
}
}
}