feat(app): library, jobs, settings, server, welcome and about screens
Local-mode composition root (SQLite index, one JobEngine fed by a single handler registration list), keyset-paged library with thumbnail cache and hover scrub, live job list with throttled updates and the shell job bar, settings with live template validation and encoder self-test, server connection with trust-on-first-use and DPAPI token, first-run welcome, About with update check, and --capture screenshots with synthetic data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
94 files changed
+10130
-374
No files matched your search
@@ -0,0 +1,27 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Interop;
|
||||
using Titano.Core.Localization;
|
||||
|
||||
namespace Titano.App.Shell;
|
||||
|
||||
/// <summary>Window-owned dialogs: the shell's folder and file pickers, confirmations and the login form.</summary>
|
||||
public sealed class AppDialogs : IAppDialogs
|
||||
{
|
||||
/// <summary>Owner of the dialogs; the main window once it exists.</summary>
|
||||
public Window? Owner { get; set; }
|
||||
|
||||
private IntPtr OwnerHandle => Owner is null ? IntPtr.Zero : new WindowInteropHelper(Owner).Handle;
|
||||
|
||||
public string? PickFolder(string title, string? initialFolder = null) => FileDialogs.PickFolder(OwnerHandle, title);
|
||||
|
||||
public string? PickJsonFile(string title) => FileDialogs.PickFile(OwnerHandle, title,
|
||||
[
|
||||
new FileFilter(Loc.L("Settings.Import.Filter"), "*.json"),
|
||||
]);
|
||||
|
||||
public bool Confirm(ConfirmRequest request) => ConfirmDialog.Ask(Owner, request);
|
||||
|
||||
public bool SignIn(string server, string? username, Func<string, string, Task<string?>> signIn) => LoginDialog.Ask(Owner, server, username, signIn);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Titano.App.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// The client's own styles (<c>Shell/AppStyles.xaml</c>) and view templates. They build on the Titano.Ui kit with
|
||||
/// StaticResource, so they are merged after <see cref="Ui.Theming.ThemeManager.Initialize"/> loaded the kit.
|
||||
/// </summary>
|
||||
public static class AppResources
|
||||
{
|
||||
private static readonly Uri Styles = new("pack://application:,,,/Titano;component/Shell/AppStyles.xaml", UriKind.Absolute);
|
||||
|
||||
/// <summary>Merges the client styles into <paramref name="app"/> once.</summary>
|
||||
public static void Merge(Application app)
|
||||
{
|
||||
if (app.Resources.MergedDictionaries.Any(d => d.Source == Styles)) return;
|
||||
app.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = Styles });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:sys="clr-namespace:System;assembly=System.Runtime">
|
||||
<!--
|
||||
Styles shared by the client screens, built on the kit of Titano.Ui (DESIGN.md §3–4). Brushes are DynamicResource;
|
||||
sizes come from Typography.xaml through the kit's StaticResources.
|
||||
-->
|
||||
|
||||
<!-- Label column text (116 px panels, 180 px Settings). -->
|
||||
<Style x:Key="Text.Label" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
|
||||
<Setter Property="Margin" Value="0,0,14,0" />
|
||||
</Style>
|
||||
|
||||
<!-- Faint helper value next to a control ("of 32 GB installed"). -->
|
||||
<Style x:Key="Text.Hint" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.TextFaint}" />
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
|
||||
</Style>
|
||||
|
||||
<!-- Table header cell: 11 px faint. -->
|
||||
<Style x:Key="Text.Header" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.TextFaint}" />
|
||||
<Setter Property="FontSize" Value="11" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
|
||||
</Style>
|
||||
|
||||
<!-- Table cell: one line, tabular figures, ellipsis. -->
|
||||
<Style x:Key="Text.Cell" TargetType="TextBlock">
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
|
||||
<Setter Property="Typography.NumeralAlignment" Value="Tabular" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="Text.CellNumber" TargetType="TextBlock" BasedOn="{StaticResource Text.Cell}">
|
||||
<Setter Property="TextAlignment" Value="Right" />
|
||||
</Style>
|
||||
|
||||
<!-- Log tail: monospaced, muted. -->
|
||||
<Style x:Key="Text.Log" TargetType="TextBlock">
|
||||
<Setter Property="FontFamily" Value="{StaticResource Font.Mono}" />
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="LineHeight" Value="18" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
|
||||
<Setter Property="TextWrapping" Value="Wrap" />
|
||||
</Style>
|
||||
|
||||
<!-- Table row container (DESIGN §4: 36–40 px, hover = Card fill, 1 px divider; selected = AccentSubtle). -->
|
||||
<Style x:Key="ListBoxItem.Row" TargetType="ListBoxItem">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="Padding" Value="14,0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border x:Name="Bd" Background="Transparent" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
</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.AccentSubtle}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Row container without selection (Jobs, encoder tables): hover only. -->
|
||||
<Style x:Key="ListBoxItem.PlainRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style>
|
||||
|
||||
<!-- Section list entry of Settings: 34 px, active = Card fill + 3 px accent edge (Settings.html). -->
|
||||
<Style x:Key="ListBoxItem.Section" TargetType="ListBoxItem">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
|
||||
<Setter Property="Height" Value="34" />
|
||||
<Setter Property="Margin" Value="0,0,0,2" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border x:Name="Bd" Background="Transparent" CornerRadius="{StaticResource Radius.Control}">
|
||||
<Grid>
|
||||
<Border x:Name="Edge" Width="3" HorizontalAlignment="Left" CornerRadius="1.5" Margin="0,7" Background="{DynamicResource Brush.Accent}" Visibility="Hidden" />
|
||||
<ContentPresenter Margin="12,0" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.Card}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.Card}" />
|
||||
<Setter TargetName="Edge" Property="Visibility" Value="Visible" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.Card}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Filter chip (Jobs.html): 30 px pill, accent border and text when chosen (bind Tag to the chosen state). -->
|
||||
<Style x:Key="Button.Chip" TargetType="Button" BasedOn="{StaticResource Button.Base}">
|
||||
<Setter Property="Height" Value="30" />
|
||||
<Setter Property="Padding" Value="12,0" />
|
||||
<Setter Property="ui:ControlState.CornerRadius" Value="15" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Tag">
|
||||
<Trigger.Value>
|
||||
<sys:Boolean>True</sys:Boolean>
|
||||
</Trigger.Value>
|
||||
<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>
|
||||
|
||||
<!-- Row action (26 px, DESIGN §4 tables). -->
|
||||
<Style x:Key="Button.Row" TargetType="Button" BasedOn="{StaticResource Button.Compact}">
|
||||
<Setter Property="Height" Value="26" />
|
||||
<Setter Property="Padding" Value="10,0" />
|
||||
<Setter Property="Margin" Value="0,0,6,0" />
|
||||
</Style>
|
||||
|
||||
<!-- "Auto · 8" pill (DESIGN §4 Auto/manual): accent outline, 24 px, 11 px text. -->
|
||||
<Style x:Key="Button.AutoPill" TargetType="Button" BasedOn="{StaticResource Button.Base}">
|
||||
<Setter Property="Height" Value="24" />
|
||||
<Setter Property="MinWidth" Value="0" />
|
||||
<Setter Property="Padding" Value="8,0" />
|
||||
<Setter Property="FontSize" Value="11" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}" />
|
||||
<Setter Property="ui:ControlState.CornerRadius" Value="12" />
|
||||
<Setter Property="ui:ControlState.HoverBackground" Value="{DynamicResource Brush.AccentSubtle}" />
|
||||
<Setter Property="ui:ControlState.HoverBorderBrush" Value="{DynamicResource Brush.Accent}" />
|
||||
<Setter Property="ui:ControlState.PressedBackground" Value="{DynamicResource Brush.AccentSubtle}" />
|
||||
</Style>
|
||||
|
||||
<!-- Toolbar dropdown (Library filters): accent border while a filter is active (bind Tag to the active flag). -->
|
||||
<Style x:Key="ComboBox.Filter" TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
|
||||
<Setter Property="MinWidth" Value="88" />
|
||||
<Setter Property="MaxDropDownHeight" Value="420" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Tag">
|
||||
<Trigger.Value>
|
||||
<sys:Boolean>True</sys:Boolean>
|
||||
</Trigger.Value>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!-- Closed box shows BoxText ("Year"), the open list shows Label ("All years"). -->
|
||||
<DataTemplate x:Key="Template.FilterOption">
|
||||
<TextBlock x:Name="Text" Text="{Binding Label}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=ComboBoxItem}}" Value="{x:Null}">
|
||||
<Setter TargetName="Text" Property="Text" Value="{Binding BoxText}" />
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="Template.Label">
|
||||
<TextBlock Text="{Binding Label}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Panel title (Text.Section, 14/600) for sub-sections inside a panel. -->
|
||||
<Style x:Key="Text.PanelTitle" TargetType="TextBlock" BasedOn="{StaticResource Text.Section}" />
|
||||
|
||||
<!-- One Settings row: 180 px label column, then the controls (Settings.html grid; 14 px between rows). -->
|
||||
<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="{StaticResource Grid.SettingsLabelColumn}" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{TemplateBinding Header}" Style="{StaticResource Text.Label}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="0,7,14,0" />
|
||||
<ContentPresenter Grid.Column="1" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="VerticalContentAlignment" Value="Top" />
|
||||
</Style>
|
||||
|
||||
<!-- Path and template fields in Settings (360 px, DESIGN mockup). -->
|
||||
<Style x:Key="TextBox.Setting" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
|
||||
<Setter Property="Width" Value="360" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TextBox.SettingMono" TargetType="TextBox" BasedOn="{StaticResource TextBox.Mono}">
|
||||
<Setter Property="Width" Value="360" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="TextBox.Number" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
|
||||
<Setter Property="Width" Value="72" />
|
||||
<Setter Property="Padding" Value="8,0" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Right" />
|
||||
<Setter Property="Typography.NumeralAlignment" Value="Tabular" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,22 @@
|
||||
<ui:TitanoWindow x:Class="Titano.App.Shell.ConfirmDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
|
||||
Title="{l:Loc Shell.AppName}"
|
||||
IsDialog="True" ResizeMode="NoResize" SizeToContent="Height" Width="460"
|
||||
WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
|
||||
<!-- DESIGN §4 dialog: two buttons, safe action left and default, the action on the right. -->
|
||||
<StackPanel Margin="24,18,24,20">
|
||||
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" TextWrapping="Wrap" TextTrimming="None" />
|
||||
<TextBlock Text="{Binding Message}" Margin="0,8,0,0" Foreground="{DynamicResource Brush.TextMuted}" TextWrapping="Wrap" TextTrimming="None" LineHeight="18" />
|
||||
<Border Style="{StaticResource Border.Card}" Margin="0,16,0,0" Padding="12,10" ToolTip="{Binding DetailToolTip}"
|
||||
Visibility="{Binding Detail, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<TextBlock Text="{Binding Detail}" FontFamily="{StaticResource Font.Mono}" FontSize="{StaticResource Size.Secondary}" TextWrapping="Wrap" TextTrimming="None" LineHeight="18" />
|
||||
</Border>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,24,0,0">
|
||||
<Button Content="{Binding SafeText}" ToolTip="{Binding SafeToolTip}" IsDefault="True" IsCancel="True" MinWidth="96" Click="OnSafe" />
|
||||
<Button x:Name="Action" Content="{Binding ActionText}" ToolTip="{Binding ActionToolTip}" MinWidth="96" Margin="8,0,0,0" Click="OnAction" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ui:TitanoWindow>
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Windows;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.Ui.Controls;
|
||||
|
||||
namespace Titano.App.Shell;
|
||||
|
||||
/// <summary>Modal confirmation for trusting a certificate and for destructive actions (BRIEF §12.1).</summary>
|
||||
public sealed partial class ConfirmDialog : TitanoWindow
|
||||
{
|
||||
public ConfirmDialog(ConfirmRequest request)
|
||||
{
|
||||
DataContext = request;
|
||||
InitializeComponent();
|
||||
Action.SetResourceReference(StyleProperty, request.IsDestructive ? "Button.Destructive" : "Button.Primary");
|
||||
}
|
||||
|
||||
/// <summary>True when the user chose the action.</summary>
|
||||
public static bool Ask(Window? owner, ConfirmRequest request)
|
||||
{
|
||||
var dialog = new ConfirmDialog(request);
|
||||
if (owner is { IsVisible: true }) dialog.Owner = owner;
|
||||
else dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
return dialog.ShowDialog() == true;
|
||||
}
|
||||
|
||||
private void OnSafe(object sender, RoutedEventArgs e) => DialogResult = false;
|
||||
|
||||
private void OnAction(object sender, RoutedEventArgs e) => DialogResult = true;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using Titano.App.Settings;
|
||||
|
||||
namespace Titano.App.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// Attaches an <see cref="EditableField"/> to a text box (DESIGN §4 inputs): Enter commits, Esc reverts, leaving
|
||||
/// the field commits a valid value.
|
||||
/// </summary>
|
||||
public static class EditBehavior
|
||||
{
|
||||
public static readonly DependencyProperty FieldProperty = DependencyProperty.RegisterAttached(
|
||||
"Field", typeof(EditableField), typeof(EditBehavior), new PropertyMetadata(null, OnFieldChanged));
|
||||
|
||||
public static EditableField? GetField(DependencyObject d) => (EditableField?)d.GetValue(FieldProperty);
|
||||
|
||||
public static void SetField(DependencyObject d, EditableField? value) => d.SetValue(FieldProperty, value);
|
||||
|
||||
private static void OnFieldChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is not TextBox box) return;
|
||||
box.PreviewKeyDown -= OnKeyDown;
|
||||
box.LostKeyboardFocus -= OnLostFocus;
|
||||
if (e.NewValue is null) return;
|
||||
box.PreviewKeyDown += OnKeyDown;
|
||||
box.LostKeyboardFocus += OnLostFocus;
|
||||
}
|
||||
|
||||
private static void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (sender is not TextBox box || GetField(box) is not { } field) return;
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
field.Commit();
|
||||
box.SelectAll();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Escape)
|
||||
{
|
||||
field.Revert();
|
||||
box.SelectAll();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnLostFocus(object sender, KeyboardFocusChangedEventArgs e)
|
||||
{
|
||||
if (sender is TextBox box && GetField(box) is { HasErrors: false } field) field.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Visible when the bound value's text equals the converter parameter (settings pages).</summary>
|
||||
public sealed class EqualsToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public static EqualsToVisibilityConverter Instance { get; } = new();
|
||||
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
string.Equals(value?.ToString(), parameter?.ToString(), StringComparison.Ordinal) ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotSupportedException();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<ui:TitanoWindow x:Class="Titano.App.Shell.LoginDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
|
||||
Title="{l:Loc Shell.AppName}"
|
||||
IsDialog="True" ResizeMode="NoResize" SizeToContent="Height" Width="440"
|
||||
WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
|
||||
<!-- BRIEF §12.7 login modal: the server is already identified and its certificate trusted. -->
|
||||
<StackPanel Margin="24,18,24,20">
|
||||
<TextBlock Text="{l:Loc Server.Login.Title}" Style="{StaticResource Text.Title}" />
|
||||
<TextBlock x:Name="ServerText" Margin="0,4,0,0" Style="{StaticResource Text.Secondary}" />
|
||||
<Grid Margin="0,18,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="92" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="10" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{l:Loc Server.Login.User}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,12,0" />
|
||||
<TextBox x:Name="User" Grid.Column="1" ToolTip="{l:Loc Tooltips.Server.LoginUser}" AutomationProperties.Name="{l:Loc Server.Login.User}" />
|
||||
<TextBlock Grid.Row="2" Text="{l:Loc Server.Login.Password}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,12,0" />
|
||||
<PasswordBox x:Name="Password" Grid.Row="2" Grid.Column="1" ToolTip="{l:Loc Tooltips.Server.LoginPassword}" AutomationProperties.Name="{l:Loc Server.Login.Password}" />
|
||||
</Grid>
|
||||
<ui:StatusGlyph x:Name="Error" Kind="Error" Margin="0,12,0,0" FontSize="{StaticResource Size.Secondary}" Visibility="Collapsed" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,22,0,0">
|
||||
<Button Content="{l:Loc Server.Login.Cancel}" ToolTip="{l:Loc Tooltips.Server.LoginCancel}" IsCancel="True" MinWidth="96" Click="OnCancel" />
|
||||
<Button x:Name="SignIn" Style="{StaticResource Button.Primary}" Content="{l:Loc Server.Login.SignIn}" ToolTip="{l:Loc Tooltips.Server.SignIn}" IsDefault="True" MinWidth="96" Margin="8,0,0,0" Click="OnSignIn" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ui:TitanoWindow>
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Windows;
|
||||
using Titano.Ui.Controls;
|
||||
|
||||
namespace Titano.App.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// The login form (BRIEF §12.7). It calls back the connection with the credentials and stays open with the
|
||||
/// error sentence until the sign-in succeeds or the user cancels. The password never leaves the PasswordBox
|
||||
/// except for that call.
|
||||
/// </summary>
|
||||
public sealed partial class LoginDialog : TitanoWindow
|
||||
{
|
||||
private readonly Func<string, string, Task<string?>> _signIn;
|
||||
|
||||
private LoginDialog(string server, string? username, Func<string, string, Task<string?>> signIn)
|
||||
{
|
||||
_signIn = signIn;
|
||||
InitializeComponent();
|
||||
ServerText.Text = server;
|
||||
User.Text = username ?? string.Empty;
|
||||
Loaded += (_, _) =>
|
||||
{
|
||||
if (User.Text.Length == 0) User.Focus();
|
||||
else Password.Focus();
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>True when the user signed in.</summary>
|
||||
public static bool Ask(Window? owner, string server, string? username, Func<string, string, Task<string?>> signIn)
|
||||
{
|
||||
var dialog = new LoginDialog(server, username, signIn);
|
||||
if (owner is { IsVisible: true }) dialog.Owner = owner;
|
||||
else dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
return dialog.ShowDialog() == true;
|
||||
}
|
||||
|
||||
private void OnCancel(object sender, RoutedEventArgs e) => DialogResult = false;
|
||||
|
||||
private async void OnSignIn(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SignIn.IsEnabled = false;
|
||||
Error.Visibility = Visibility.Collapsed;
|
||||
try
|
||||
{
|
||||
var error = await _signIn(User.Text, Password.Password);
|
||||
if (error is null)
|
||||
{
|
||||
DialogResult = true;
|
||||
return;
|
||||
}
|
||||
Error.Text = error;
|
||||
Error.Visibility = Visibility.Visible;
|
||||
Password.Clear();
|
||||
Password.Focus();
|
||||
}
|
||||
finally
|
||||
{
|
||||
SignIn.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
|
||||
xmlns:shell="clr-namespace:Titano.App.Shell"
|
||||
xmlns:s="clr-namespace:Titano.App.Sections"
|
||||
Title="{Binding WindowTitle}"
|
||||
Width="1440" Height="900" MinWidth="1200" MinHeight="760"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
@@ -47,23 +48,30 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Job bar (DESIGN §4): current job, progress, time left, pause; "Ready" when idle. -->
|
||||
<ui:JobBar Text="{Binding JobText}" Progress="{Binding JobProgress}" IsActive="{Binding IsJobActive}" IsIndeterminate="{Binding IsJobIndeterminate}"
|
||||
StopCommand="{Binding StopJobCommand}" StopToolTip="{l:Loc Tooltips.Shell.StopJob}" />
|
||||
StopCommand="{Binding StopJobCommand}" StopToolTip="{l:Loc Tooltips.Shell.PauseJob}" ActionGlyph="{StaticResource Icon.Pause}" />
|
||||
|
||||
<ContentControl Grid.Row="1" Content="{Binding Current}" Focusable="False" />
|
||||
|
||||
<!-- Status strip -->
|
||||
<Border Grid.Row="2" Height="30" Background="{DynamicResource Brush.Chrome}" Padding="20,0">
|
||||
<StackPanel Orientation="Horizontal" TextElement.FontSize="12" TextElement.Foreground="{DynamicResource Brush.TextMuted}">
|
||||
<TextBlock Text="{Binding SequencesText}" Margin="0,0,18,0" />
|
||||
<TextBlock Text="{Binding PhotosText}" Margin="0,0,18,0" />
|
||||
<TextBlock Text="{Binding StorageText}" Margin="0,0,18,0" />
|
||||
<TextBlock x:Name="Connection" Text="{Binding ConnectionText}" Margin="0,0,18,0" />
|
||||
<TextBlock Text="{Binding JobsText}" />
|
||||
<TextBlock Text="{Binding SequencesText}" Margin="0,0,18,0" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding PhotosText}" Margin="0,0,18,0" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding StorageText}" Margin="0,0,18,0" VerticalAlignment="Center" />
|
||||
<TextBlock x:Name="Connection" Text="{Binding ConnectionText}" Margin="0,0,18,0" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding JobsText}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<ui:ToastHost x:Name="Toasts" Grid.Row="0" Grid.RowSpan="3" />
|
||||
</Grid>
|
||||
|
||||
<!-- First run (Welcome.html): the shell dimmed behind one dialog. -->
|
||||
<Grid Grid.ColumnSpan="2" Visibility="{Binding IsWelcomeOpen, Converter={StaticResource BoolToVisibility}}">
|
||||
<Border Background="{DynamicResource Brush.Scrim}" />
|
||||
<s:WelcomeView DataContext="{Binding Welcome}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,114,0,0" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ui:TitanoWindow>
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Windows;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.Ui.Controls;
|
||||
|
||||
namespace Titano.App.Shell;
|
||||
@@ -14,18 +15,21 @@ public partial class MainWindow : TitanoWindow
|
||||
DataContext = shell;
|
||||
InitializeComponent();
|
||||
Rail.Width = shell.IsRailCollapsed ? 48 : 128;
|
||||
UpdateConnection();
|
||||
shell.PropertyChanged += (_, e) =>
|
||||
{
|
||||
if (e.PropertyName is nameof(ShellViewModel.IsRailCollapsed) or "")
|
||||
Rail.Width = shell.IsRailCollapsed ? 48 : 128;
|
||||
if (e.PropertyName is nameof(ShellViewModel.IsConnected) or "")
|
||||
Connection.Foreground = (System.Windows.Media.Brush)FindResource(shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
|
||||
if (e.PropertyName is nameof(ShellViewModel.IsConnected) or "") UpdateConnection();
|
||||
};
|
||||
shell.PendingToasts.CollectionChanged += OnToastRequested;
|
||||
RestorePlacement();
|
||||
Closing += (_, _) => SavePlacement();
|
||||
}
|
||||
|
||||
private void UpdateConnection() =>
|
||||
Connection.SetResourceReference(System.Windows.Controls.TextBlock.ForegroundProperty, _shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
|
||||
|
||||
private void OnToastRequested(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.Action != NotifyCollectionChangedAction.Add || e.NewItems is null) return;
|
||||
@@ -35,8 +39,8 @@ public partial class MainWindow : TitanoWindow
|
||||
|
||||
private void RestorePlacement()
|
||||
{
|
||||
var p = App.Current.Settings.Window;
|
||||
if (p is null || p.Width < MinWidth || p.Height < MinHeight) return;
|
||||
var p = _shell.Services.Settings.Window;
|
||||
if (p is null || p.Width < MinWidth || p.Height < MinHeight || _shell.Services.Environment.IsCapture) return;
|
||||
var virtualScreen = new Rect(SystemParameters.VirtualScreenLeft, SystemParameters.VirtualScreenTop, SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight);
|
||||
var rect = new Rect(p.Left, p.Top, p.Width, p.Height);
|
||||
if (!virtualScreen.IntersectsWith(rect)) return;
|
||||
@@ -50,8 +54,9 @@ public partial class MainWindow : TitanoWindow
|
||||
|
||||
private void SavePlacement()
|
||||
{
|
||||
if (_shell.Services.Environment.IsCapture) return;
|
||||
var b = RestoreBounds;
|
||||
App.Current.Settings.Window = new Infrastructure.AppSettings.WindowPlacement
|
||||
_shell.Services.Settings.Window = new AppSettings.WindowPlacement
|
||||
{
|
||||
Left = b.Left,
|
||||
Top = b.Top,
|
||||
|
||||
@@ -3,64 +3,134 @@ using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.DesignTime;
|
||||
using Titano.App.Settings;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Ui.Theming;
|
||||
|
||||
namespace Titano.App.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// <c>Titano.exe --capture <dir></c>: renders every section at 1440×900 in dark and light themes to PNG for
|
||||
/// visual regression and phase reports (BRIEF §20.2), then exits.
|
||||
/// <c>Titano.exe --capture <dir></c>: renders every client screen at 1440×900 in the dark and light themes to
|
||||
/// <c><screen>-<theme>.png</c> from <see cref="SampleData"/> (first run on an empty index, then a populated
|
||||
/// one), for visual review and phase reports (BRIEF §20.2), then exits.
|
||||
/// </summary>
|
||||
public static class ScreenCapture
|
||||
{
|
||||
public static void Run(MainWindow window, ShellViewModel shell, string directory)
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
window.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
window.Left = -20000;
|
||||
window.Top = -20000;
|
||||
window.Width = 1440;
|
||||
window.Height = 900;
|
||||
window.ShowActivated = false;
|
||||
window.ShowInTaskbar = false;
|
||||
window.Show();
|
||||
private static readonly AppTheme[] Themes = [AppTheme.Dark, AppTheme.Light];
|
||||
|
||||
window.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, () =>
|
||||
public static async Task RunAsync(MainWindow window, ShellViewModel shell, SampleData sample, string directory)
|
||||
{
|
||||
var written = 0;
|
||||
try
|
||||
{
|
||||
var written = 0;
|
||||
try
|
||||
Directory.CreateDirectory(directory);
|
||||
window.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
window.Left = -20000;
|
||||
window.Top = -20000;
|
||||
window.Width = 1440;
|
||||
window.Height = 900;
|
||||
window.ShowActivated = false;
|
||||
window.ShowInTaskbar = false;
|
||||
window.Show();
|
||||
|
||||
// First run: empty index, nothing connected, the welcome dialog over the empty Library.
|
||||
await sample.OpenEmptyAsync();
|
||||
await shell.StartAsync();
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
foreach (var theme in new[] { AppTheme.Dark, AppTheme.Light })
|
||||
ThemeManager.Apply(theme);
|
||||
shell.Navigate(SectionKey.Library);
|
||||
shell.ShowWelcome();
|
||||
shell.Welcome!.ShowDiscovered(new Server.DiscoveredServer("Studio NAS", "https://nas.local:8443"));
|
||||
written += await SaveAsync(window, directory, "welcome", theme);
|
||||
shell.CompleteWelcome();
|
||||
written += await SaveAsync(window, directory, "library-empty", theme);
|
||||
shell.Navigate(SectionKey.Server);
|
||||
written += await SaveAsync(window, directory, "server-signedout", theme);
|
||||
}
|
||||
|
||||
// A populated archive, jobs in every state and a signed-in server.
|
||||
await sample.FillAsync();
|
||||
await shell.Library.RefreshAsync();
|
||||
await shell.Jobs.ReloadAsync();
|
||||
await shell.Services.Server.RestoreAsync();
|
||||
shell.About.SetResult(null);
|
||||
await shell.Settings.DetectEncodersAsync();
|
||||
await shell.Settings.SelfTestAsync();
|
||||
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
|
||||
shell.Library.LayoutIndex = 0;
|
||||
shell.Library.ClearSelectionCommand.Execute(null);
|
||||
shell.Navigate(SectionKey.Library);
|
||||
written += await SaveAsync(window, directory, "library", theme, waitForThumbnails: shell);
|
||||
if (shell.Library.Items.Count > 0) shell.Library.Items[0].IsSelected = true;
|
||||
written += await SaveAsync(window, directory, "library-selection", theme, waitForThumbnails: shell);
|
||||
shell.Library.LayoutIndex = 1;
|
||||
written += await SaveAsync(window, directory, "library-list", theme, waitForThumbnails: shell);
|
||||
shell.Library.LayoutIndex = 0;
|
||||
shell.Library.ClearSelectionCommand.Execute(null);
|
||||
|
||||
shell.Navigate(SectionKey.Jobs);
|
||||
if (shell.Jobs.Rows.Count > 0) shell.Jobs.Rows[0].IsExpanded = true;
|
||||
written += await SaveAsync(window, directory, "jobs", theme);
|
||||
|
||||
shell.Navigate(SectionKey.Server);
|
||||
written += await SaveAsync(window, directory, "server", theme);
|
||||
|
||||
shell.Navigate(SectionKey.Settings);
|
||||
foreach (var page in Enum.GetValues<SettingsPage>())
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
foreach (var section in shell.AllSections)
|
||||
{
|
||||
shell.Navigate(section.Key);
|
||||
Settle(window);
|
||||
if (Save(window, Path.Combine(directory, $"{section.Key}-{theme.ToString().ToLowerInvariant()}.png"))) written++;
|
||||
}
|
||||
shell.Settings.Page = page;
|
||||
written += await SaveAsync(window, directory, "settings-" + page.ToString().ToLowerInvariant(), theme);
|
||||
}
|
||||
|
||||
shell.Navigate(SectionKey.About);
|
||||
written += await SaveAsync(window, directory, "about", theme);
|
||||
|
||||
foreach (var key in new[] { SectionKey.Import, SectionKey.Sequence, SectionKey.Archive })
|
||||
{
|
||||
shell.Navigate(key);
|
||||
written += await SaveAsync(window, directory, key.ToString().ToLowerInvariant(), theme);
|
||||
}
|
||||
Log.Info("capture", $"{written} screenshot(s) written to {Path.GetFullPath(directory)}");
|
||||
if (written == 0) Environment.ExitCode = 1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("capture", "Capture failed", ex);
|
||||
Environment.ExitCode = 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
});
|
||||
Log.Info("capture", $"{written} screenshot(s) written to {Path.GetFullPath(directory)}");
|
||||
if (written == 0) Environment.ExitCode = 1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("capture", "Capture failed", ex);
|
||||
Environment.ExitCode = 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private static void Settle(Window window)
|
||||
private static async Task<int> SaveAsync(Window window, string directory, string screen, AppTheme theme, ShellViewModel? waitForThumbnails = null)
|
||||
{
|
||||
await Settle(window);
|
||||
if (waitForThumbnails?.Services.Thumbnails is { } thumbnails)
|
||||
{
|
||||
// Thumbnails decode on the thread pool; give them a moment, then settle again.
|
||||
for (var i = 0; i < 40 && thumbnails.PendingLoads > 0; i++) await Task.Delay(50);
|
||||
await Task.Delay(100);
|
||||
await Settle(window);
|
||||
}
|
||||
return Save(window, Path.Combine(directory, $"{screen}-{theme.ToString().ToLowerInvariant()}.png")) ? 1 : 0;
|
||||
}
|
||||
|
||||
private static async Task Settle(Window window)
|
||||
{
|
||||
window.UpdateLayout();
|
||||
// Let bindings, templates and deferred renders complete.
|
||||
window.Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, () => { });
|
||||
// Let bindings, templates, async continuations and deferred renders complete.
|
||||
await window.Dispatcher.InvokeAsync(() => { }, DispatcherPriority.ApplicationIdle);
|
||||
await Task.Delay(30);
|
||||
await window.Dispatcher.InvokeAsync(() => { }, DispatcherPriority.ApplicationIdle);
|
||||
window.UpdateLayout();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ using Titano.Ui.Mvvm;
|
||||
|
||||
namespace Titano.App.Shell;
|
||||
|
||||
/// <summary>State of the main window: rail, current section, job bar and status strip (BRIEF §12.1).</summary>
|
||||
/// <summary>State of the main window: rail, current section, job bar, status strip and first run (BRIEF §12.1).</summary>
|
||||
public sealed class ShellViewModel : LocalizedViewModel
|
||||
{
|
||||
private readonly AppSettings _settings;
|
||||
@@ -24,18 +24,22 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
private long _totalBytes;
|
||||
private string? _serverName;
|
||||
private int _jobCount;
|
||||
private int _queuedCount;
|
||||
private WelcomeViewModel? _welcome;
|
||||
private Guid? _currentSequenceId;
|
||||
|
||||
public ShellViewModel(AppSettings settings)
|
||||
public ShellViewModel(AppServices services)
|
||||
{
|
||||
_settings = settings;
|
||||
_isRailCollapsed = settings.RailCollapsed;
|
||||
Services = services;
|
||||
_settings = services.Settings;
|
||||
_isRailCollapsed = _settings.RailCollapsed;
|
||||
Library = new LibraryViewModel(this);
|
||||
Import = new ImportViewModel(this);
|
||||
Sequence = new SequenceViewModel(this);
|
||||
Archive = new ArchiveViewModel(this);
|
||||
Jobs = new JobsViewModel(this);
|
||||
Server = new ServerViewModel(this);
|
||||
Settings = new SettingsViewModel(this, settings);
|
||||
Settings = new SettingsViewModel(this);
|
||||
About = new AboutViewModel(this);
|
||||
TopSections = [Library, Import, Sequence, Archive, Jobs, Server];
|
||||
BottomSections = [Settings, About];
|
||||
@@ -49,8 +53,12 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
else if (p is string name && Enum.TryParse<SectionKey>(name, out var key)) Navigate(key);
|
||||
});
|
||||
ToggleRailCommand = new RelayCommand(() => IsRailCollapsed = !IsRailCollapsed);
|
||||
services.Server.PropertyChanged += (_, _) => SetConnection(services.Server.ServerName);
|
||||
if (!_settings.FirstRunCompleted) _welcome = new WelcomeViewModel(this);
|
||||
}
|
||||
|
||||
public AppServices Services { get; }
|
||||
|
||||
public LibraryViewModel Library { get; }
|
||||
public ImportViewModel Import { get; }
|
||||
public SequenceViewModel Sequence { get; }
|
||||
@@ -70,6 +78,18 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
/// <summary>In-window notifications; the window binds its <see cref="ToastHost"/> here.</summary>
|
||||
public ObservableCollection<Toast> PendingToasts { get; } = [];
|
||||
|
||||
/// <summary>First-run choice (Welcome.html); null once made.</summary>
|
||||
public WelcomeViewModel? Welcome
|
||||
{
|
||||
get => _welcome;
|
||||
private set
|
||||
{
|
||||
if (Set(ref _welcome, value)) OnPropertyChanged(nameof(IsWelcomeOpen));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsWelcomeOpen => _welcome is not null;
|
||||
|
||||
public SectionViewModel Current
|
||||
{
|
||||
get => _current;
|
||||
@@ -94,12 +114,54 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
|
||||
public string RailToggleToolTip => Loc.L(IsRailCollapsed ? "Tooltips.Shell.ExpandRail" : "Tooltips.Shell.CollapseRail");
|
||||
|
||||
/// <summary>The sequence the editor opens (set by the Library and the Jobs screen).</summary>
|
||||
public Guid? CurrentSequenceId
|
||||
{
|
||||
get => _currentSequenceId;
|
||||
private set => Set(ref _currentSequenceId, value);
|
||||
}
|
||||
|
||||
/// <summary>Loads the data of every screen once the index is open (or failed to open).</summary>
|
||||
public async Task StartAsync()
|
||||
{
|
||||
if (Services.OpenError is { } error) ReportError(error);
|
||||
Jobs.Attach();
|
||||
await Library.AttachAsync();
|
||||
Settings.Attach();
|
||||
About.Attach();
|
||||
await Server.AttachAsync();
|
||||
}
|
||||
|
||||
/// <summary>Opens a sequence in the editor.</summary>
|
||||
public void OpenSequence(Guid sequenceId)
|
||||
{
|
||||
CurrentSequenceId = sequenceId;
|
||||
Navigate(SectionKey.Sequence);
|
||||
}
|
||||
|
||||
/// <summary>Closes the first-run overlay for good.</summary>
|
||||
public void CompleteWelcome()
|
||||
{
|
||||
_settings.FirstRunCompleted = true;
|
||||
Services.SaveSettings();
|
||||
Welcome?.Dispose();
|
||||
Welcome = null;
|
||||
}
|
||||
|
||||
/// <summary>Shows the first-run overlay again (capture, tests).</summary>
|
||||
public void ShowWelcome() => Welcome ??= new WelcomeViewModel(this);
|
||||
|
||||
// ---- Job bar ----
|
||||
public string JobText => _jobActive && _jobText is not null ? _jobText : Loc.L("Shell.JobBar.Ready", _jobCount);
|
||||
public string JobText => _jobActive && _jobText is not null
|
||||
? _jobText
|
||||
: _queuedCount > 0 ? Loc.L("Shell.JobBar.Ready", _queuedCount) : Loc.L("Shell.JobBar.Idle");
|
||||
|
||||
public double JobProgress { get => _jobProgress; private set => Set(ref _jobProgress, value); }
|
||||
public bool IsJobActive { get => _jobActive; private set => Set(ref _jobActive, value); }
|
||||
public bool IsJobIndeterminate { get => _jobIndeterminate; private set => Set(ref _jobIndeterminate, value); }
|
||||
public ICommand? StopJobCommand { get; set; }
|
||||
|
||||
/// <summary>Pauses the job the bar shows.</summary>
|
||||
public ICommand? StopJobCommand => Jobs.PauseCurrentCommand;
|
||||
|
||||
/// <summary>Updates the global job bar (and the taskbar progress through the window).</summary>
|
||||
public void SetJob(string? text, double progress, bool indeterminate = false)
|
||||
@@ -114,7 +176,7 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
// ---- Status strip ----
|
||||
public string SequencesText => Loc.Plural("Shell.Status.Sequences", _sequenceCount);
|
||||
public string PhotosText => Loc.Plural("Shell.Status.Photos", _photoCount);
|
||||
public string StorageText => Formatting.Bytes(_totalBytes);
|
||||
public string StorageText => _sequenceCount == 0 && _settings.LastArchivePath is null ? Loc.L("Shell.Status.NoArchive") : Formatting.Bytes(_totalBytes);
|
||||
public string ConnectionText => _serverName is null ? Loc.L("Shell.Status.NotConnected") : Loc.L("Shell.Status.Connected", _serverName);
|
||||
public bool IsConnected => _serverName is not null;
|
||||
public string JobsText => Loc.Plural("Shell.Status.Jobs", _jobCount);
|
||||
@@ -131,14 +193,17 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
|
||||
public void SetConnection(string? serverName)
|
||||
{
|
||||
if (_serverName == serverName) return;
|
||||
_serverName = serverName;
|
||||
OnPropertyChanged(nameof(ConnectionText));
|
||||
OnPropertyChanged(nameof(IsConnected));
|
||||
}
|
||||
|
||||
public void SetJobCount(int count)
|
||||
/// <summary>Active jobs (running + queued) for the status strip, queued ones for the idle job bar.</summary>
|
||||
public void SetJobCount(int active, int queued = 0)
|
||||
{
|
||||
_jobCount = count;
|
||||
_jobCount = active;
|
||||
_queuedCount = queued;
|
||||
OnPropertyChanged(nameof(JobsText));
|
||||
OnPropertyChanged(nameof(JobText));
|
||||
}
|
||||
@@ -152,6 +217,17 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
|
||||
public void ShowToast(Toast toast) => PendingToasts.Add(toast);
|
||||
|
||||
/// <summary>A one-line notice with one action (job done, update available).</summary>
|
||||
public void Notify(string title, string? message = null, string? actionText = null, string? actionToolTip = null, Action? action = null) =>
|
||||
ShowToast(new Toast
|
||||
{
|
||||
Title = title,
|
||||
Message = message,
|
||||
ActionText = actionText,
|
||||
ActionToolTip = actionToolTip,
|
||||
ActionCommand = action is null ? null : new RelayCommand(action),
|
||||
});
|
||||
|
||||
/// <summary>Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6).</summary>
|
||||
public void ReportError(Exception ex)
|
||||
{
|
||||
@@ -162,7 +238,18 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
Message = ex.Message,
|
||||
ActionText = Loc.L("Common.OpenLogs"),
|
||||
ActionToolTip = Loc.L("Tooltips.Common.OpenLogs"),
|
||||
ActionCommand = new RelayCommand(() => ShellActions.OpenFolder(App.Current.Environment.LogDirectory)),
|
||||
ActionCommand = new RelayCommand(() => ShellActions.Reveal(Services.Environment.LogDirectory)),
|
||||
});
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Jobs.Dispose();
|
||||
Library.Dispose();
|
||||
Server.Dispose();
|
||||
Settings.Dispose();
|
||||
About.Dispose();
|
||||
Welcome?.Dispose();
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user