merge: integration branch into the shared fixes; every window takes its reading direction from TitanoWindow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
286 files changed
+18007
-738
No files matched your search
@@ -3,19 +3,21 @@
|
||||
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 Uploader.App.Title}"
|
||||
Title="{l:Loc Uploader.App.Title}" AutomationProperties.Name="{Binding Heading}" AutomationProperties.HelpText="{Binding Message}"
|
||||
IsDialog="True" ResizeMode="NoResize" SizeToContent="Height" Width="440"
|
||||
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" />
|
||||
<!-- Address and fingerprint read left to right in every language. -->
|
||||
<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" LineHeight="18" />
|
||||
<TextBlock Text="{Binding Detail}" FontFamily="{StaticResource Font.Mono}" FontSize="{StaticResource Size.Secondary}" TextWrapping="Wrap" LineHeight="18"
|
||||
FlowDirection="LeftToRight" />
|
||||
</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="Safe" Content="{Binding SafeText}" ToolTip="{Binding SafeToolTip}" IsDefault="True" IsCancel="True" MinWidth="96" Click="OnSafe" />
|
||||
<Button x:Name="Action" Content="{Binding ActionText}" ToolTip="{Binding ActionToolTip}" MinWidth="96" Margin="8,0,0,0" Click="OnAction" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
@@ -30,6 +30,8 @@ public sealed partial class ConfirmDialog : TitanoWindow
|
||||
DataContext = request;
|
||||
InitializeComponent();
|
||||
Action.SetResourceReference(StyleProperty, request.IsDestructive ? "Button.Destructive" : "Button.Primary");
|
||||
// The keyboard starts on the safe default, as in Windows dialogs.
|
||||
Loaded += (_, _) => Safe.Focus();
|
||||
}
|
||||
|
||||
/// <summary>True when the user chose the action.</summary>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Ui.Mvvm;
|
||||
@@ -8,15 +10,22 @@ namespace Titano.Uploader.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// First-run and signed-out form: server address (with servers found on the LAN), user, password. A self-signed
|
||||
/// certificate is shown to the user once (trust on first use) before the password is sent.
|
||||
/// certificate is shown to the user once (trust on first use) before the password is sent. A wrong address or
|
||||
/// password marks that field (DESIGN §4: error border, message in the tooltip); other failures show one sentence
|
||||
/// with Retry where trying again can help.
|
||||
/// </summary>
|
||||
public sealed class ConnectViewModel : ObservableObject
|
||||
public sealed class ConnectViewModel : ObservableObject, INotifyDataErrorInfo
|
||||
{
|
||||
private readonly IServerSession _session;
|
||||
private readonly IUploaderDialogs _dialogs;
|
||||
private string _address;
|
||||
private string _username;
|
||||
private string _password = string.Empty;
|
||||
private string? _addressError;
|
||||
private string? _passwordError;
|
||||
private string? _errorText;
|
||||
private bool _canRetry;
|
||||
private bool _isSigningIn;
|
||||
|
||||
public ConnectViewModel(IServerSession session, IUploaderDialogs dialogs, string? address, string? username)
|
||||
{
|
||||
@@ -31,6 +40,8 @@ public sealed class ConnectViewModel : ObservableObject
|
||||
});
|
||||
}
|
||||
|
||||
public event EventHandler<DataErrorsChangedEventArgs>? ErrorsChanged;
|
||||
|
||||
/// <summary>Servers that announced themselves on this network.</summary>
|
||||
public ObservableCollection<DiscoveredServer> Discovered { get; } = [];
|
||||
|
||||
@@ -40,7 +51,10 @@ public sealed class ConnectViewModel : ObservableObject
|
||||
public string Address
|
||||
{
|
||||
get => _address;
|
||||
set => Set(ref _address, value);
|
||||
set
|
||||
{
|
||||
if (Set(ref _address, value)) AddressError = null;
|
||||
}
|
||||
}
|
||||
|
||||
public string Username
|
||||
@@ -50,15 +64,69 @@ public sealed class ConnectViewModel : ObservableObject
|
||||
}
|
||||
|
||||
/// <summary>Set from the view's PasswordBox; never stored.</summary>
|
||||
public string Password { private get; set; } = string.Empty;
|
||||
public string Password
|
||||
{
|
||||
private get => _password;
|
||||
set
|
||||
{
|
||||
if (_password == value) return;
|
||||
_password = value;
|
||||
PasswordError = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>One sentence saying what went wrong; the retry action sits next to it.</summary>
|
||||
/// <summary>Why the address was refused (invalid, or not a Titano Server); null when it is not in question.</summary>
|
||||
public string? AddressError
|
||||
{
|
||||
get => _addressError;
|
||||
private set
|
||||
{
|
||||
if (!Set(ref _addressError, value)) return;
|
||||
OnPropertyChanged(nameof(AddressToolTip));
|
||||
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Address)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Wrong user name or password; null otherwise. The password box has no binding, so the view reads this.</summary>
|
||||
public string? PasswordError
|
||||
{
|
||||
get => _passwordError;
|
||||
private set
|
||||
{
|
||||
if (Set(ref _passwordError, value)) OnPropertyChanged(nameof(PasswordToolTip));
|
||||
}
|
||||
}
|
||||
|
||||
public string AddressToolTip => AddressError ?? Loc.L("Tooltips.Uploader.ServerAddress");
|
||||
|
||||
public string PasswordToolTip => PasswordError ?? Loc.L("Tooltips.Uploader.Password");
|
||||
|
||||
/// <summary>One sentence for failures that are not about a field; null otherwise.</summary>
|
||||
public string? ErrorText
|
||||
{
|
||||
get => _errorText;
|
||||
private set => Set(ref _errorText, value);
|
||||
}
|
||||
|
||||
/// <summary>True when trying the same request again can help (no answer, server error).</summary>
|
||||
public bool CanRetry
|
||||
{
|
||||
get => _canRetry;
|
||||
private set => Set(ref _canRetry, value);
|
||||
}
|
||||
|
||||
/// <summary>True while a sign-in started from this form runs; the form stays on screen until it has an outcome.</summary>
|
||||
public bool IsSigningIn
|
||||
{
|
||||
get => _isSigningIn;
|
||||
private set => Set(ref _isSigningIn, value);
|
||||
}
|
||||
|
||||
public bool HasErrors => AddressError is not null;
|
||||
|
||||
public IEnumerable GetErrors(string? propertyName) =>
|
||||
propertyName == nameof(Address) && AddressError is { } error ? new[] { error } : Array.Empty<string>();
|
||||
|
||||
/// <summary>Shows the server address without the trailing slash of the stored base URL.</summary>
|
||||
public static string Display(string? address) => address?.TrimEnd('/') ?? string.Empty;
|
||||
|
||||
@@ -72,30 +140,50 @@ public sealed class ConnectViewModel : ObservableObject
|
||||
private async Task SignInAsync()
|
||||
{
|
||||
if (_session.State is not (ConnectionState.NotConfigured or ConnectionState.SignedOut)) return;
|
||||
ErrorText = null;
|
||||
var (result, fingerprint) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||
if (result == SignInResult.Untrusted && fingerprint is not null)
|
||||
ShowResult(null);
|
||||
IsSigningIn = true;
|
||||
try
|
||||
{
|
||||
if (!_dialogs.ConfirmTrust(Display(Address), fingerprint))
|
||||
{
|
||||
ErrorText = Loc.L("Uploader.Connect.Error.Untrusted");
|
||||
return;
|
||||
}
|
||||
_session.Trust(fingerprint);
|
||||
(result, _) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||
var result = await SignInOrTrustAsync();
|
||||
ShowResult(result);
|
||||
if (result != SignInResult.Success) return;
|
||||
Address = Display(_session.Address);
|
||||
Password = string.Empty;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsSigningIn = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Signs in; an unknown self-signed certificate is shown to the user first and, once trusted, the sign-in is repeated.</summary>
|
||||
private async Task<SignInResult> SignInOrTrustAsync()
|
||||
{
|
||||
var (result, fingerprint) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||
if (result != SignInResult.Untrusted || fingerprint is null) return result;
|
||||
if (!_dialogs.ConfirmTrust(Display(Address), fingerprint)) return SignInResult.Untrusted;
|
||||
_session.Trust(fingerprint);
|
||||
(result, _) = await _session.SignInAsync(Address, Username.Trim(), Password, CancellationToken.None);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Puts each failure where it belongs: on the field it is about, or in the sentence under the form.</summary>
|
||||
private void ShowResult(SignInResult? result)
|
||||
{
|
||||
AddressError = result switch
|
||||
{
|
||||
SignInResult.InvalidAddress => Loc.L("Uploader.Connect.Error.InvalidAddress"),
|
||||
SignInResult.NotTitano => Loc.L("Uploader.Connect.Error.NotTitano"),
|
||||
_ => null,
|
||||
};
|
||||
PasswordError = result == SignInResult.BadCredentials ? Loc.L("Uploader.Connect.Error.BadCredentials") : null;
|
||||
CanRetry = result is SignInResult.Unreachable or SignInResult.Failed;
|
||||
ErrorText = result switch
|
||||
{
|
||||
SignInResult.Success => null,
|
||||
SignInResult.InvalidAddress => Loc.L("Uploader.Connect.Error.InvalidAddress"),
|
||||
SignInResult.Unreachable => Loc.L("Uploader.Connect.Error.Unreachable"),
|
||||
SignInResult.NotTitano => Loc.L("Uploader.Connect.Error.NotTitano"),
|
||||
SignInResult.BadCredentials => Loc.L("Uploader.Connect.Error.BadCredentials"),
|
||||
SignInResult.Untrusted => Loc.L("Uploader.Connect.Error.Untrusted"),
|
||||
_ => Loc.L("Uploader.Connect.Error.Failed"),
|
||||
SignInResult.Failed => Loc.L("Uploader.Connect.Error.Failed"),
|
||||
_ => null,
|
||||
};
|
||||
if (result != SignInResult.Success) return;
|
||||
Address = Display(_session.Address);
|
||||
Password = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,9 @@ public sealed class UploadStateTextConverter : IValueConverter
|
||||
{
|
||||
public static UploadStateTextConverter Instance { get; } = new();
|
||||
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value switch
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value is UploadItemState state ? Text(state) : string.Empty;
|
||||
|
||||
public static string Text(UploadItemState state) => state switch
|
||||
{
|
||||
UploadItemState.Hashing => Loc.L("Uploader.State.Hashing"),
|
||||
UploadItemState.Uploading => Loc.L("Uploader.State.Uploading"),
|
||||
@@ -54,7 +56,7 @@ public sealed class FailureTextConverter : IMultiValueConverter
|
||||
|
||||
public object[] ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotSupportedException();
|
||||
|
||||
private static string? Describe(UploadFailure failure, string? detail) => failure switch
|
||||
public static string? Describe(UploadFailure failure, string? detail) => failure switch
|
||||
{
|
||||
UploadFailure.FileMissing => Loc.L("Uploader.Failure.FileMissing"),
|
||||
UploadFailure.FileUnreadable => Loc.L("Uploader.Failure.FileUnreadable"),
|
||||
@@ -65,6 +67,24 @@ public sealed class FailureTextConverter : IMultiValueConverter
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// (file name, state, failure, detail) → a queue row's accessible name, "IMG_0413.CR2 · Failed · The file could not be
|
||||
/// read.", so a screen reader announces each row instead of its type name.
|
||||
/// </summary>
|
||||
public sealed class QueueRowNameConverter : IMultiValueConverter
|
||||
{
|
||||
public static QueueRowNameConverter Instance { get; } = new();
|
||||
|
||||
public object Convert(object?[] values, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (values is not [string file, UploadItemState state, UploadFailure failure, var detail, ..]) return string.Empty;
|
||||
var name = file + " · " + UploadStateTextConverter.Text(state);
|
||||
return state == UploadItemState.Failed && FailureTextConverter.Describe(failure, detail as string) is { } reason ? name + " · " + reason : name;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
/// <summary>Visible only for <see cref="UploadItemState.Failed"/>; hidden (keeping its space) otherwise so rows stay aligned.</summary>
|
||||
public sealed class FailedToVisibleConverter : IValueConverter
|
||||
{
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Titano.Uploader.Shell;
|
||||
|
||||
/// <summary>Pickers and confirmations the view model asks for.</summary>
|
||||
public interface IUploaderDialogs
|
||||
{
|
||||
/// <summary>Photos to add; empty when cancelled.</summary>
|
||||
IReadOnlyList<string> PickFiles();
|
||||
|
||||
/// <summary>A folder or card root to add; null when cancelled.</summary>
|
||||
string? PickFolder();
|
||||
|
||||
/// <summary>A folder to watch; null when cancelled.</summary>
|
||||
string? PickWatchFolder();
|
||||
|
||||
/// <summary>Trust-on-first-use: shows the certificate fingerprint; true when the user trusts it.</summary>
|
||||
bool ConfirmTrust(string address, string fingerprint);
|
||||
|
||||
/// <summary>Destructive confirmation for "Delete after upload"; true when the user turns it on.</summary>
|
||||
bool ConfirmDeleteAfterUpload();
|
||||
}
|
||||
@@ -47,9 +47,11 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
private bool _startWithWindows;
|
||||
private string _queueText = string.Empty;
|
||||
private string _progressText = string.Empty;
|
||||
private string? _failedText;
|
||||
private string? _currentFileText;
|
||||
private double _progress;
|
||||
private UploadItem? _currentItem;
|
||||
private QueueActivity _activity;
|
||||
|
||||
public MainViewModel(UploaderServices services)
|
||||
{
|
||||
@@ -58,6 +60,10 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
_newTitle = services.Settings.NewSequenceTitle ?? string.Empty;
|
||||
_startWithWindows = services.Startup.IsEnabled;
|
||||
Connect = new ConnectViewModel(services.Session, services.Dialogs, services.Settings.ServerUrl, services.Settings.Username);
|
||||
Connect.PropertyChanged += (_, e) =>
|
||||
{
|
||||
if (e.PropertyName == nameof(ConnectViewModel.IsSigningIn)) OnPropertyChanged(nameof(IsConnectVisible));
|
||||
};
|
||||
foreach (var w in services.Settings.WatchFolders) WatchFolders.Add(NewWatchFolder(w.Path, w.IntervalSeconds));
|
||||
|
||||
OpenSettingsCommand = new RelayCommand(() => IsSettingsOpen = true);
|
||||
@@ -82,6 +88,8 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
_s.Queue.Items.CollectionChanged += (_, _) =>
|
||||
{
|
||||
OnPropertyChanged(nameof(HasItems));
|
||||
OnPropertyChanged(nameof(PauseToolTip));
|
||||
OnPropertyChanged(nameof(StopToolTip));
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
};
|
||||
_refresh = new DispatcherTimer(DispatcherPriority.Background) { Interval = TimeSpan.FromMilliseconds(500) };
|
||||
@@ -92,6 +100,9 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
/// <summary>Raised when the queue finished while work was done, with the number of files the server confirmed.</summary>
|
||||
public event Action<int>? UploadsCompleted;
|
||||
|
||||
/// <summary>Raised by the "Sign in" action of a session-ended toast; the view focuses the password box.</summary>
|
||||
public event EventHandler? SignInRequested;
|
||||
|
||||
public ConnectViewModel Connect { get; }
|
||||
|
||||
/// <summary>In-window notifications; the window forwards them to its <see cref="ToastHost"/>.</summary>
|
||||
@@ -139,8 +150,8 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
? Loc.L("Uploader.Header.Quota", UploaderText.Bytes(Math.Max(0, _s.Session.QuotaBytes - _s.Session.UsedBytes), Loc.Culture), UploaderText.Bytes(_s.Session.QuotaBytes, Loc.Culture))
|
||||
: null;
|
||||
|
||||
/// <summary>The sign-in form replaces the queue on first run and after signing out.</summary>
|
||||
public bool IsConnectVisible => _s.Session.State is ConnectionState.NotConfigured or ConnectionState.SignedOut;
|
||||
/// <summary>The sign-in form replaces the queue on first run and after signing out, and stays while its own sign-in runs.</summary>
|
||||
public bool IsConnectVisible => Connect.IsSigningIn || _s.Session.State is ConnectionState.NotConfigured or ConnectionState.SignedOut;
|
||||
|
||||
public bool IsSettingsOpen
|
||||
{
|
||||
@@ -170,6 +181,9 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
|
||||
public ObservableCollection<SequenceOption> Sequences { get; } = [];
|
||||
|
||||
/// <summary>The sequence list is disabled unless "Sequence" is chosen; its tooltip then says so (DESIGN §4).</summary>
|
||||
public string SequenceToolTip => Loc.L(IsSequenceTarget ? "Tooltips.Uploader.ChooseSequence" : "Tooltips.Uploader.SequenceDisabled");
|
||||
|
||||
public SequenceOption? SelectedSequence
|
||||
{
|
||||
get => _selectedSequence;
|
||||
@@ -212,6 +226,20 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
private set => Set(ref _progressText, value);
|
||||
}
|
||||
|
||||
/// <summary>"3 failed", a link to the first failed file; null when nothing failed.</summary>
|
||||
public string? FailedText
|
||||
{
|
||||
get => _failedText;
|
||||
private set => Set(ref _failedText, value);
|
||||
}
|
||||
|
||||
/// <summary>What the queue is doing; changes only when the activity does, so the view can announce it.</summary>
|
||||
public QueueActivity Activity
|
||||
{
|
||||
get => _activity;
|
||||
private set => Set(ref _activity, value);
|
||||
}
|
||||
|
||||
public string? CurrentFileText
|
||||
{
|
||||
get => _currentFileText;
|
||||
@@ -233,7 +261,10 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
|
||||
public bool IsPaused => _s.Queue.IsPaused;
|
||||
|
||||
public string PauseToolTip => Loc.L(IsPaused ? "Tooltips.Uploader.Resume" : "Tooltips.Uploader.Pause");
|
||||
/// <summary>Pause and Stop are disabled while nothing is queued; their tooltips then say so (DESIGN §4).</summary>
|
||||
public string PauseToolTip => Loc.L(!HasItems ? "Tooltips.Uploader.QueueEmpty" : IsPaused ? "Tooltips.Uploader.Resume" : "Tooltips.Uploader.Pause");
|
||||
|
||||
public string StopToolTip => Loc.L(HasItems ? "Tooltips.Uploader.Stop" : "Tooltips.Uploader.QueueEmpty");
|
||||
|
||||
/// <summary>Accessible name of the pause/resume button (also the tray menu entry).</summary>
|
||||
public string PauseLabel => Loc.L(IsPaused ? "Uploader.Action.Resume" : "Uploader.Action.Pause");
|
||||
@@ -356,6 +387,9 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
if (folder is not null) folder.IsAvailable = available;
|
||||
}
|
||||
|
||||
/// <summary>The failed file nearest the top of the queue; null when none failed.</summary>
|
||||
public UploadItem? FirstFailed() => _s.Queue.Items.FirstOrDefault(i => i.State == UploadItemState.Failed);
|
||||
|
||||
/// <summary>Errors are one sentence plus one action (BRIEF §0.2 rule 6).</summary>
|
||||
public void ReportError(Exception ex)
|
||||
{
|
||||
@@ -421,12 +455,15 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
_ => QueueActivity.Done,
|
||||
};
|
||||
QueueText = UploaderText.QueueLine(summary, activity, rate, RateMeter.TimeLeft(summary.RemainingBytes, rate), Loc.Culture);
|
||||
Activity = activity;
|
||||
ProgressText = summary.Files == 0 ? string.Empty : UploaderText.ProgressLine(summary, Loc.Culture);
|
||||
FailedText = UploaderText.Failed(summary, Loc.Culture);
|
||||
Progress = summary.Progress;
|
||||
CurrentFileText = summary.CurrentFile;
|
||||
CurrentItem = _s.Queue.Items.FirstOrDefault(i => i.State == UploadItemState.Uploading) ?? _s.Queue.Items.FirstOrDefault(i => i.IsActive);
|
||||
OnPropertyChanged(nameof(IsPaused));
|
||||
OnPropertyChanged(nameof(PauseToolTip));
|
||||
OnPropertyChanged(nameof(StopToolTip));
|
||||
OnPropertyChanged(nameof(PauseLabel));
|
||||
OnPropertyChanged(nameof(TrayText));
|
||||
}
|
||||
@@ -440,6 +477,7 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
OnPropertyChanged(nameof(IsSessionsTarget));
|
||||
OnPropertyChanged(nameof(IsSequenceTarget));
|
||||
OnPropertyChanged(nameof(IsNewTarget));
|
||||
OnPropertyChanged(nameof(SequenceToolTip));
|
||||
if (mode == UploadTargetMode.Sequence && Sequences.Count == 0) _ = LoadSequencesAsync();
|
||||
}
|
||||
|
||||
@@ -524,7 +562,8 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
OnPropertyChanged(nameof(BandwidthLimitText));
|
||||
if (e.PropertyName != nameof(IServerSession.State)) return;
|
||||
if (_s.Session.State == ConnectionState.Connected) _ = LoadSequencesAsync();
|
||||
if (IsConnectVisible)
|
||||
// The form's own sign-in keeps what the user typed; only a session that ended refills it.
|
||||
if (IsConnectVisible && !Connect.IsSigningIn)
|
||||
{
|
||||
Connect.Address = ConnectViewModel.Display(_s.Session.Address);
|
||||
Connect.Username = _s.Session.Username ?? Connect.Username;
|
||||
@@ -532,8 +571,10 @@ public sealed class MainViewModel : LocalizedViewModel
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
/// <summary>One sentence plus one action (BRIEF §0.2 rule 6): "Sign in" takes the user to the password box.</summary>
|
||||
private void OnSessionEnded(object? sender, ServerProblem problem) =>
|
||||
ShowToast(Loc.L(problem == ServerProblem.CertificateChanged ? "Uploader.Toast.CertificateChanged" : "Uploader.Toast.SignedOut"));
|
||||
ShowToast(Loc.L(problem == ServerProblem.CertificateChanged ? "Uploader.Toast.CertificateChanged" : "Uploader.Toast.SignedOut"),
|
||||
Loc.L("Uploader.Connect.SignIn"), Loc.L("Tooltips.Uploader.SignIn"), new RelayCommand(() => SignInRequested?.Invoke(this, EventArgs.Empty)));
|
||||
|
||||
private void OnDrained(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
xmlns:s="clr-namespace:Titano.Uploader.Shell"
|
||||
xmlns:u="clr-namespace:Titano.Uploader.Uploads"
|
||||
Title="{l:Loc Uploader.App.Title}"
|
||||
Width="760" Height="560" MinWidth="640" MinHeight="480"
|
||||
Width="760" Height="700" MinWidth="640" MinHeight="630"
|
||||
WindowStartupLocation="CenterScreen" AllowDrop="True">
|
||||
<Window.Resources>
|
||||
<Style x:Key="Text.Label" TargetType="TextBlock" BasedOn="{StaticResource Text.Base}">
|
||||
@@ -15,6 +15,13 @@
|
||||
<Setter Property="Margin" Value="0,0,12,0" />
|
||||
</Style>
|
||||
|
||||
<!-- Labels of the settings panel's fixed label column wrap instead of being cut (+40 % text). -->
|
||||
<Style x:Key="Text.PanelLabel" TargetType="TextBlock" BasedOn="{StaticResource Text.Label}">
|
||||
<Setter Property="MinWidth" Value="0" />
|
||||
<Setter Property="TextWrapping" Value="Wrap" />
|
||||
<Setter Property="TextTrimming" Value="None" />
|
||||
</Style>
|
||||
|
||||
<!-- Watch-folder chip (mockup: 28 px pill, Card fill, status dot). -->
|
||||
<Style x:Key="Button.Chip" TargetType="Button" BasedOn="{StaticResource Button.Base}">
|
||||
<Setter Property="Height" Value="28" />
|
||||
@@ -35,10 +42,31 @@
|
||||
<Setter Property="Height" Value="30" />
|
||||
</Style>
|
||||
|
||||
<!-- Queue rows: hover only, no selection. -->
|
||||
<!-- Keyboard focus on a queue row: the accent ring drawn inside the row, so neighbours do not cover it. -->
|
||||
<Style x:Key="Focus.Row">
|
||||
<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>
|
||||
|
||||
<!-- Queue rows: hover and keyboard focus, no selection look; named "file · state" for screen readers. -->
|
||||
<Style x:Key="QueueRow" TargetType="ListBoxItem">
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Row}" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="AutomationProperties.Name">
|
||||
<Setter.Value>
|
||||
<MultiBinding Converter="{x:Static s:QueueRowNameConverter.Instance}">
|
||||
<Binding Path="FileName" />
|
||||
<Binding Path="State" />
|
||||
<Binding Path="Failure" />
|
||||
<Binding Path="FailureDetail" />
|
||||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
@@ -83,15 +111,16 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Header: server · user · connection, quota, settings. -->
|
||||
<Border Height="40" Background="{DynamicResource Brush.Surface}" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="16,0,10,0">
|
||||
<Border Height="40" Background="{DynamicResource Brush.Surface}" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="16,0">
|
||||
<DockPanel LastChildFill="True">
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Square}" ui:ButtonIcon.Glyph="{StaticResource Icon.Settings}"
|
||||
<Button x:Name="SettingsButton" DockPanel.Dock="Right" Style="{StaticResource Button.Square}" ui:ButtonIcon.Glyph="{StaticResource Icon.Settings}"
|
||||
Command="{Binding OpenSettingsCommand}" ToolTip="{l:Loc Tooltips.Uploader.Settings}" AutomationProperties.Name="{l:Loc Uploader.Settings.Title}" />
|
||||
<TextBlock DockPanel.Dock="Right" Text="{Binding QuotaText}" Style="{StaticResource Text.Secondary}" Margin="12,0,12,0"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.Quota}" Visibility="{Binding QuotaText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<ui:Icon Glyph="{StaticResource Icon.Server}" Foreground="{DynamicResource Brush.Accent}" Margin="0,0,10,0" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding ServerText}" Style="{StaticResource Text.Body}" MaxWidth="320" />
|
||||
<!-- An address reads left to right in every language. -->
|
||||
<TextBlock Text="{Binding ServerText}" Style="{StaticResource Text.Body}" MaxWidth="320" FlowDirection="LeftToRight" />
|
||||
<StackPanel Orientation="Horizontal" Visibility="{Binding UserText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<TextBlock Text="·" Foreground="{DynamicResource Brush.TextFaint}" Margin="10,0" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding UserText}" Style="{StaticResource Text.Body}" />
|
||||
@@ -107,7 +136,8 @@
|
||||
<!-- First run / signed out: connect form. -->
|
||||
<Grid Grid.Row="1" Visibility="{Binding IsConnectVisible, Converter={StaticResource BoolToVisibility}}">
|
||||
<StackPanel DataContext="{Binding Connect}" Width="440" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<ui:BrandMarkIcon Width="48" Height="48" HorizontalAlignment="Center" />
|
||||
<!-- The mark is artwork: its off-centre sun must not flip in right-to-left languages. -->
|
||||
<ui:BrandMarkIcon Width="48" Height="48" HorizontalAlignment="Center" FlowDirection="LeftToRight" />
|
||||
<TextBlock Text="{l:Loc Uploader.Connect.Title}" Style="{StaticResource Text.Title}" HorizontalAlignment="Center" Margin="0,14,0,20" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -124,10 +154,13 @@
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="{l:Loc Uploader.Connect.Server}" Style="{StaticResource Text.Label}" />
|
||||
<TextBox Grid.Column="1" Text="{Binding Address, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Server}"
|
||||
ui:Field.Placeholder="{l:Loc Uploader.Connect.AddressPlaceholder}" ToolTip="{l:Loc Tooltips.Uploader.ServerAddress}" AutomationProperties.Name="{l:Loc Uploader.Connect.Server}" />
|
||||
<!-- A wrong address shows the Error border; the message is the tooltip (DESIGN §4). -->
|
||||
<TextBox x:Name="AddressBox" Grid.Column="1" Text="{Binding Address, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
|
||||
ui:Field.Glyph="{StaticResource Icon.Server}" FlowDirection="LeftToRight"
|
||||
ui:Field.Placeholder="{l:Loc Uploader.Connect.AddressPlaceholder}" ToolTip="{Binding AddressToolTip}" AutomationProperties.Name="{l:Loc Uploader.Connect.Server}" />
|
||||
|
||||
<TextBlock Grid.Row="1" Text="{l:Loc Uploader.Connect.Found}" Style="{StaticResource Text.Label}" Margin="0,8,12,0" VerticalAlignment="Top"
|
||||
<!-- Top margin 14 = 8 + (28 − 16) / 2: the label sits on the chips' text line. -->
|
||||
<TextBlock Grid.Row="1" Text="{l:Loc Uploader.Connect.Found}" Style="{StaticResource Text.Label}" Margin="0,14,12,0" VerticalAlignment="Top"
|
||||
Visibility="{Binding Discovered.Count, Converter={x:Static ui:ZeroToCollapsedConverter.Instance}}" />
|
||||
<ItemsControl Grid.Row="1" Grid.Column="1" ItemsSource="{Binding Discovered}" Margin="0,8,0,0" Focusable="False"
|
||||
Visibility="{Binding Discovered.Count, Converter={x:Static ui:ZeroToCollapsedConverter.Instance}}">
|
||||
@@ -143,7 +176,7 @@
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Ellipse Width="8" Height="8" Fill="{DynamicResource Brush.Accent}" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding Address}" Foreground="{DynamicResource Brush.TextMuted}" Margin="8,0,0,0" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding Address}" Foreground="{DynamicResource Brush.TextMuted}" Margin="8,0,0,0" VerticalAlignment="Center" FlowDirection="LeftToRight" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
@@ -151,26 +184,47 @@
|
||||
</ItemsControl>
|
||||
|
||||
<TextBlock Grid.Row="2" Text="{l:Loc Uploader.Connect.User}" Style="{StaticResource Text.Label}" Margin="0,12,12,0" />
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="0,12,0,0" Text="{Binding Username, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.User}"
|
||||
<TextBox x:Name="UserBox" Grid.Row="2" Grid.Column="1" Margin="0,12,0,0" Text="{Binding Username, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.User}"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.User}" AutomationProperties.Name="{l:Loc Uploader.Connect.User}" />
|
||||
|
||||
<TextBlock Grid.Row="3" Text="{l:Loc Uploader.Connect.Password}" Style="{StaticResource Text.Label}" Margin="0,12,12,0" />
|
||||
<PasswordBox x:Name="Password" Grid.Row="3" Grid.Column="1" Margin="0,12,0,0" PasswordChanged="OnPasswordChanged"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.Password}" AutomationProperties.Name="{l:Loc Uploader.Connect.Password}" />
|
||||
ToolTip="{Binding PasswordToolTip}" AutomationProperties.Name="{l:Loc Uploader.Connect.Password}" />
|
||||
<!--
|
||||
A wrong password: the Error border (DESIGN §4), drawn over the box because the password box has no binding
|
||||
to validate and its template paints the focus border over its own; the message is the tooltip.
|
||||
-->
|
||||
<Border x:Name="PasswordErrorRing" Grid.Row="3" Grid.Column="1" Margin="0,12,0,0" BorderBrush="{DynamicResource Brush.Error}" BorderThickness="1"
|
||||
CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True" IsHitTestVisible="False"
|
||||
Visibility="{Binding PasswordError, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
|
||||
<Border Grid.Row="4" Grid.Column="1" Margin="0,12,0,0" Padding="10,6,6,6" CornerRadius="{StaticResource Radius.Control}" Background="{DynamicResource Brush.ErrorSubtle}"
|
||||
Visibility="{Binding ErrorText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<DockPanel>
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Compact}" Content="{l:Loc Uploader.Action.Retry}" Command="{Binding SignInCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.Retry}" Margin="8,0,0,0" />
|
||||
ToolTip="{l:Loc Tooltips.Uploader.Retry}" Margin="8,0,0,0" Visibility="{Binding CanRetry, Converter={StaticResource BoolToVisibility}}" />
|
||||
<ui:Icon Glyph="{StaticResource Icon.ErrorCircle}" Foreground="{DynamicResource Brush.Error}" Margin="0,0,8,0" VerticalAlignment="Center" />
|
||||
<TextBlock Text="{Binding ErrorText}" TextWrapping="Wrap" VerticalAlignment="Center" />
|
||||
<TextBlock x:Name="ErrorMessage" Text="{Binding ErrorText}" TextWrapping="Wrap" VerticalAlignment="Center" AutomationProperties.LiveSetting="Assertive" />
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
<Button Grid.Row="5" Grid.Column="1" Margin="0,20,0,0" HorizontalAlignment="Left" Style="{StaticResource Button.Primary}" MinWidth="120"
|
||||
IsDefault="{Binding IsVisible, RelativeSource={RelativeSource Self}}"
|
||||
Content="{l:Loc Uploader.Connect.SignIn}" Command="{Binding SignInCommand}" ToolTip="{l:Loc Tooltips.Uploader.SignIn}" />
|
||||
<!-- Enter signs in while the form is on screen, but not from the settings panel drawn over it. -->
|
||||
<Button Grid.Row="5" Grid.Column="1" Margin="0,20,0,0" HorizontalAlignment="Left" MinWidth="120"
|
||||
Content="{l:Loc Uploader.Connect.SignIn}" Command="{Binding SignInCommand}" ToolTip="{l:Loc Tooltips.Uploader.SignIn}">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource Button.Primary}">
|
||||
<Setter Property="IsDefault" Value="True" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsVisible" Value="False">
|
||||
<Setter Property="IsDefault" Value="False" />
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding DataContext.IsSettingsOpen, RelativeSource={RelativeSource AncestorType=Window}}" Value="True">
|
||||
<Setter Property="IsDefault" Value="False" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
@@ -196,7 +250,7 @@
|
||||
<ui:Icon Glyph="{StaticResource Icon.Upload}" Size="28" Foreground="{DynamicResource Brush.TextMuted}" HorizontalAlignment="Center" />
|
||||
<TextBlock Text="{l:Loc Uploader.Drop.Message}" FontSize="{StaticResource Size.Section}" Foreground="{DynamicResource Brush.TextMuted}"
|
||||
HorizontalAlignment="Center" Margin="0,10,0,10" />
|
||||
<Button Content="{l:Loc Uploader.Browse.Button}" Height="30" Padding="14,0" HorizontalAlignment="Center"
|
||||
<Button x:Name="BrowseButton" Content="{l:Loc Uploader.Browse.Button}" Height="30" Padding="14,0" HorizontalAlignment="Center"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.Browse}" Click="OnBrowseClick">
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu>
|
||||
@@ -208,26 +262,30 @@
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Target -->
|
||||
<!-- Target: each choice wraps together with its field; the negative margin keeps one line at 30 px. -->
|
||||
<Grid Grid.Row="1" Margin="0,12,0,0" MinHeight="30">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Label" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{l:Loc Uploader.Target.Label}" Style="{StaticResource Text.Label}" />
|
||||
<WrapPanel Grid.Column="1" VerticalAlignment="Center">
|
||||
<RadioButton GroupName="Target" Content="{l:Loc Uploader.Target.Sessions}" IsChecked="{Binding IsSessionsTarget}" Margin="0,0,16,0" VerticalAlignment="Center"
|
||||
<WrapPanel Grid.Column="1" VerticalAlignment="Center" Margin="0,-4,0,0">
|
||||
<RadioButton GroupName="Target" Content="{l:Loc Uploader.Target.Sessions}" IsChecked="{Binding IsSessionsTarget}" Margin="0,4,16,0" VerticalAlignment="Center"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.TargetSessions}" />
|
||||
<RadioButton GroupName="Target" Content="{l:Loc Uploader.Target.Sequence}" IsChecked="{Binding IsSequenceTarget}" Margin="0,0,8,0" VerticalAlignment="Center"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.TargetSequence}" />
|
||||
<ComboBox Width="170" Height="30" Margin="0,0,16,0" ItemsSource="{Binding Sequences}" SelectedItem="{Binding SelectedSequence}" DisplayMemberPath="Title"
|
||||
IsEnabled="{Binding IsSequenceTarget}" DropDownOpened="OnSequencesDropDownOpened" ToolTip="{l:Loc Tooltips.Uploader.ChooseSequence}"
|
||||
AutomationProperties.Name="{l:Loc Uploader.Target.Sequence}" />
|
||||
<RadioButton GroupName="Target" Content="{l:Loc Uploader.Target.New}" IsChecked="{Binding IsNewTarget}" Margin="0,0,8,0" VerticalAlignment="Center"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.TargetNew}" />
|
||||
<TextBox Width="150" Height="30" Text="{Binding NewTitle}" ui:Field.Placeholder="{l:Loc Uploader.Target.TitlePlaceholder}"
|
||||
Visibility="{Binding IsNewTarget, Converter={StaticResource BoolToVisibility}}" ToolTip="{l:Loc Tooltips.Uploader.NewTitle}"
|
||||
AutomationProperties.Name="{l:Loc Uploader.Target.TitlePlaceholder}" />
|
||||
<StackPanel Orientation="Horizontal" Margin="0,4,16,0">
|
||||
<RadioButton GroupName="Target" Content="{l:Loc Uploader.Target.Sequence}" IsChecked="{Binding IsSequenceTarget}" Margin="0,0,8,0" VerticalAlignment="Center"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.TargetSequence}" />
|
||||
<ComboBox Width="170" Height="30" ItemsSource="{Binding Sequences}" SelectedItem="{Binding SelectedSequence}" DisplayMemberPath="Title"
|
||||
IsEnabled="{Binding IsSequenceTarget}" DropDownOpened="OnSequencesDropDownOpened" ToolTip="{Binding SequenceToolTip}"
|
||||
AutomationProperties.Name="{l:Loc Uploader.Target.Sequence}" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,4,0,0">
|
||||
<RadioButton GroupName="Target" Content="{l:Loc Uploader.Target.New}" IsChecked="{Binding IsNewTarget}" Margin="0,0,8,0" VerticalAlignment="Center"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.TargetNew}" />
|
||||
<TextBox Width="170" Height="30" Text="{Binding NewTitle}" ui:Field.Placeholder="{l:Loc Uploader.Target.TitlePlaceholder}"
|
||||
Visibility="{Binding IsNewTarget, Converter={StaticResource BoolToVisibility}}" ToolTip="{l:Loc Tooltips.Uploader.NewTitle}"
|
||||
AutomationProperties.Name="{l:Loc Uploader.Target.TitlePlaceholder}" />
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -240,9 +298,12 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{l:Loc Uploader.Queue.Label}" Style="{StaticResource Text.Label}" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding QueueText}" Style="{StaticResource Text.Body}" Typography.NumeralAlignment="Tabular" />
|
||||
<!-- Announced when the activity changes (running, paused, waiting, done), not on every refresh. -->
|
||||
<TextBlock x:Name="QueueLine" Grid.Column="1" Text="{Binding QueueText}" Style="{StaticResource Text.Body}" Typography.NumeralAlignment="Tabular"
|
||||
AutomationProperties.LiveSetting="Polite" />
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" Margin="10,0,0,0">
|
||||
<Button Command="{Binding PauseCommand}" ToolTip="{Binding PauseToolTip}" AutomationProperties.Name="{Binding PauseLabel}">
|
||||
<!-- Media glyphs (pause, play) keep their direction in right-to-left languages. -->
|
||||
<Button Command="{Binding PauseCommand}" ToolTip="{Binding PauseToolTip}" AutomationProperties.Name="{Binding PauseLabel}" FlowDirection="LeftToRight">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource Button.Square}">
|
||||
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Pause}" />
|
||||
@@ -255,54 +316,66 @@
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button Style="{StaticResource Button.Square}" Margin="10,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.Stop}" Command="{Binding StopCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.Stop}" AutomationProperties.Name="{l:Loc Uploader.Action.Stop}" />
|
||||
ToolTip="{Binding StopToolTip}" AutomationProperties.Name="{l:Loc Uploader.Action.Stop}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="3" Orientation="Horizontal" Margin="16,0,0,0">
|
||||
<TextBlock Text="{l:Loc Uploader.Limit.Label}" Style="{StaticResource Text.Base}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,6,0" />
|
||||
<TextBox Width="58" Height="30" Text="{Binding BandwidthLimitText}" TextAlignment="Right" ToolTip="{l:Loc Tooltips.Uploader.Limit}"
|
||||
<TextBox Width="58" Height="30" Text="{Binding BandwidthLimitText}" TextAlignment="Right" FlowDirection="LeftToRight" ToolTip="{l:Loc Tooltips.Uploader.Limit}"
|
||||
AutomationProperties.Name="{l:Loc Uploader.Limit.Label}" />
|
||||
<TextBlock Text="{l:Loc Uploader.Limit.Unit}" Style="{StaticResource Text.Base}" Foreground="{DynamicResource Brush.TextMuted}" Margin="6,0,0,0" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Progress: bar, current file, counts -->
|
||||
<!-- Progress: bar, current file, counts, failures -->
|
||||
<StackPanel Grid.Row="3" Margin="0,12,0,0" Visibility="{Binding HasItems, Converter={StaticResource BoolToVisibility}}">
|
||||
<ProgressBar Height="8" Maximum="1" Value="{Binding Progress, Mode=OneWay}" />
|
||||
<ProgressBar Height="8" Maximum="1" Value="{Binding Progress, Mode=OneWay}" AutomationProperties.Name="{l:Loc Uploader.Queue.Progress}" />
|
||||
<Grid Margin="0,5,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding CurrentFileText}" Style="{StaticResource Text.Secondary}" />
|
||||
<TextBlock Text="{Binding CurrentFileText}" Style="{StaticResource Text.Secondary}" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding ProgressText}" Style="{StaticResource Text.Secondary}" Margin="12,0,0,0" Typography.NumeralAlignment="Tabular" />
|
||||
<!-- "✕ 3 failed" (DESIGN §4 status glyph) takes the keyboard to the first failed file. -->
|
||||
<Button x:Name="FailedLink" Grid.Column="2" Style="{StaticResource Button.Subtle}" Height="18" MinWidth="0" Padding="4,0" Margin="6,0,0,0"
|
||||
Click="OnShowFailedClick" ToolTip="{l:Loc Tooltips.Uploader.ShowFailed}" AutomationProperties.Name="{Binding FailedText}"
|
||||
Visibility="{Binding FailedText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<ui:StatusGlyph Kind="Failed" Text="{Binding FailedText}" FontSize="{StaticResource Size.Secondary}" Typography.NumeralAlignment="Tabular" />
|
||||
</Button>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Watch folders -->
|
||||
<!-- Watch folders: chips and the add button wrap; a long path is shortened (full path in the tooltip). -->
|
||||
<Grid Grid.Row="4" Margin="0,12,0,0" MinHeight="30">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="Label" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{l:Loc Uploader.Watch.Label}" Style="{StaticResource Text.Label}" VerticalAlignment="Top" Margin="0,6,12,0" />
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<WrapPanel Grid.Column="1">
|
||||
<ItemsControl ItemsSource="{Binding WatchFolders}" Focusable="False">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type s:WatchFolderViewModel}">
|
||||
<Button Style="{StaticResource Button.Chip}" Margin="0,0,10,0" Click="OnWatchChipClick" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Path}">
|
||||
<Button Style="{StaticResource Button.Chip}" Margin="0,0,10,4" Click="OnWatchChipClick" ToolTip="{Binding ToolTip}"
|
||||
AutomationProperties.Name="{Binding Text}">
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu ItemsSource="{Binding MenuOptions}" ItemContainerStyle="{StaticResource WatchMenuItem}" />
|
||||
</Button.ContextMenu>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Ellipse x:Name="Dot" Width="8" Height="8" Margin="0,0,8,0" VerticalAlignment="Center" StrokeThickness="1.5"
|
||||
<DockPanel>
|
||||
<Ellipse x:Name="Dot" DockPanel.Dock="Left" Width="8" Height="8" Margin="0,0,8,0" VerticalAlignment="Center" StrokeThickness="1.5"
|
||||
Fill="{DynamicResource Brush.TextFaint}" />
|
||||
<TextBlock Text="{Binding Text}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
<TextBlock DockPanel.Dock="Right" Text="{Binding IntervalText}" VerticalAlignment="Center" />
|
||||
<TextBlock DockPanel.Dock="Right" Text="·" Foreground="{DynamicResource Brush.TextFaint}" Margin="6,0" VerticalAlignment="Center" />
|
||||
<!-- The button template lays content out without a width limit, so the path carries its own. -->
|
||||
<TextBlock Text="{Binding Path}" MaxWidth="180" FlowDirection="LeftToRight" HorizontalAlignment="Left" TextTrimming="CharacterEllipsis"
|
||||
VerticalAlignment="Center" />
|
||||
</DockPanel>
|
||||
</Button>
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding IsAvailable}" Value="True">
|
||||
@@ -317,27 +390,28 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<Button Style="{StaticResource Button.Round}" ui:ButtonIcon.Glyph="{StaticResource Icon.Plus}" Command="{Binding AddWatchFolderCommand}"
|
||||
<Button Style="{StaticResource Button.Round}" Margin="0,0,0,4" ui:ButtonIcon.Glyph="{StaticResource Icon.Plus}" Command="{Binding AddWatchFolderCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.AddWatchFolder}" AutomationProperties.Name="{l:Loc Uploader.Action.AddFolder}" />
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Per-file state -->
|
||||
<Border Grid.Row="5" Margin="0,12,0,0" Style="{StaticResource Border.Panel}" Padding="4"
|
||||
<!-- Per-file state: rows take keyboard focus; Enter retries a failed file. -->
|
||||
<Border Grid.Row="5" Margin="0,8,0,0" Style="{StaticResource Border.Panel}" Padding="4"
|
||||
Visibility="{Binding HasItems, Converter={StaticResource BoolToVisibility}}">
|
||||
<ListBox x:Name="ItemList" ItemsSource="{Binding Items}" ItemContainerStyle="{StaticResource QueueRow}">
|
||||
<ListBox x:Name="ItemList" ItemsSource="{Binding Items}" ItemContainerStyle="{StaticResource QueueRow}" VirtualizingPanel.ScrollUnit="Item"
|
||||
AutomationProperties.Name="{l:Loc Uploader.Queue.List}" KeyDown="OnItemListKeyDown">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type u:UploadItem}">
|
||||
<Grid Height="28">
|
||||
<Grid Height="{x:Static s:MainWindow.RowHeight}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" MinWidth="64" />
|
||||
<ColumnDefinition Width="Auto" MinWidth="120" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding FileName}" Style="{StaticResource Text.Body}" />
|
||||
<TextBlock Text="{Binding FileName}" Style="{StaticResource Text.Body}" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding Size, Converter={x:Static s:SizeConverter.Instance}}" Style="{StaticResource Text.Secondary}"
|
||||
Typography.NumeralAlignment="Tabular" Margin="12,0,0,0" />
|
||||
Typography.NumeralAlignment="Tabular" HorizontalAlignment="Right" Margin="12,0,0,0" />
|
||||
<ui:StatusGlyph Grid.Column="2" Margin="16,0,0,0" FontSize="{StaticResource Size.Secondary}" VerticalAlignment="Center"
|
||||
Kind="{Binding State, Converter={x:Static s:UploadStateKindConverter.Instance}}"
|
||||
Text="{Binding State, Converter={x:Static s:UploadStateTextConverter.Instance}}">
|
||||
@@ -348,7 +422,12 @@
|
||||
</MultiBinding>
|
||||
</ui:StatusGlyph.ToolTip>
|
||||
</ui:StatusGlyph>
|
||||
<Button Grid.Column="3" Style="{StaticResource Button.IconSubtle}" Width="26" Height="26" MinWidth="26" Margin="4,0,0,0"
|
||||
<!--
|
||||
Mouse shortcut; keyboard users press Enter on the row, so the button is not a tab stop of its own.
|
||||
The retry arrow turns clockwise, like a clock, in every language: it is not mirrored.
|
||||
-->
|
||||
<Button Grid.Column="3" Style="{StaticResource Button.IconSubtle}" Width="26" Height="26" MinWidth="26" Margin="4,0,0,0" IsTabStop="False"
|
||||
FlowDirection="LeftToRight"
|
||||
ui:ButtonIcon.Glyph="{StaticResource Icon.Retry}" CommandParameter="{Binding}"
|
||||
Command="{Binding DataContext.RetryItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
|
||||
Visibility="{Binding State, Converter={x:Static s:FailedToVisibleConverter.Instance}}"
|
||||
@@ -370,59 +449,65 @@
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Settings panel over the window content. -->
|
||||
<!-- Settings panel over the window content; Tab and arrow keys stay inside it while it is open. -->
|
||||
<Grid Grid.RowSpan="2" Visibility="{Binding IsSettingsOpen, Converter={StaticResource BoolToVisibility}}">
|
||||
<Border Background="{DynamicResource Brush.Scrim}">
|
||||
<Border.InputBindings>
|
||||
<MouseBinding MouseAction="LeftClick" Command="{Binding CloseSettingsCommand}" />
|
||||
</Border.InputBindings>
|
||||
</Border>
|
||||
<Border HorizontalAlignment="Right" Width="340" Background="{DynamicResource Brush.Surface}" BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="1,0,0,0">
|
||||
<Border x:Name="SettingsPanel" HorizontalAlignment="Right" Width="{StaticResource Width.SidePanel}" Background="{DynamicResource Brush.Surface}"
|
||||
BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="1,0,0,0"
|
||||
KeyboardNavigation.TabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.ControlTabNavigation="Cycle">
|
||||
<DockPanel Margin="20,12,12,20">
|
||||
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,12">
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.IconSubtle}" ui:ButtonIcon.Glyph="{StaticResource Icon.Close}" Command="{Binding CloseSettingsCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.CloseSettings}" AutomationProperties.Name="{l:Loc Uploader.Action.Close}" />
|
||||
<Button x:Name="CloseSettingsButton" DockPanel.Dock="Right" Style="{StaticResource Button.IconSubtle}" ui:ButtonIcon.Glyph="{StaticResource Icon.Close}"
|
||||
Command="{Binding CloseSettingsCommand}" ToolTip="{l:Loc Tooltips.Uploader.CloseSettings}" AutomationProperties.Name="{l:Loc Uploader.Action.Close}" />
|
||||
<TextBlock Text="{l:Loc Uploader.Settings.Title}" Style="{StaticResource Text.Title}" />
|
||||
</DockPanel>
|
||||
<Grid Margin="0,0,8,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="100" />
|
||||
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="Auto" MinHeight="36" />
|
||||
<RowDefinition Height="Auto" MinHeight="36" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="44" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="Auto" MinHeight="44" />
|
||||
<RowDefinition Height="Auto" MinHeight="36" />
|
||||
<RowDefinition Height="Auto" MinHeight="36" />
|
||||
<RowDefinition Height="Auto" MinHeight="36" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="{l:Loc Uploader.Settings.Server}" Style="{StaticResource Text.Label}" MinWidth="0" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding ServerText}" Style="{StaticResource Text.Body}" />
|
||||
<TextBlock Grid.Row="1" Text="{l:Loc Uploader.Settings.User}" Style="{StaticResource Text.Label}" MinWidth="0" />
|
||||
<TextBlock Text="{l:Loc Uploader.Settings.Server}" Style="{StaticResource Text.PanelLabel}" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding ServerText}" Style="{StaticResource Text.Body}" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
|
||||
<TextBlock Grid.Row="1" Text="{l:Loc Uploader.Settings.User}" Style="{StaticResource Text.PanelLabel}" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding UserText}" Style="{StaticResource Text.Body}" />
|
||||
<Button Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" Margin="0,4,0,8" Content="{l:Loc Uploader.Settings.SignOut}" Command="{Binding SignOutCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.SignOut}" Visibility="{Binding IsConnectVisible, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
|
||||
|
||||
<TextBlock Grid.Row="3" Text="{l:Loc Uploader.Settings.Bandwidth}" Style="{StaticResource Text.Label}" MinWidth="0" />
|
||||
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock Grid.Row="3" Text="{l:Loc Uploader.Settings.Bandwidth}" Style="{StaticResource Text.PanelLabel}" />
|
||||
<WrapPanel Grid.Row="3" Grid.Column="1" VerticalAlignment="Center">
|
||||
<TextBlock Text="{l:Loc Uploader.Limit.Label}" Style="{StaticResource Text.Base}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,0,6,0" />
|
||||
<TextBox Width="58" Height="30" Text="{Binding BandwidthLimitText}" TextAlignment="Right" ToolTip="{l:Loc Tooltips.Uploader.Limit}"
|
||||
<TextBox Width="58" Height="30" Text="{Binding BandwidthLimitText}" TextAlignment="Right" FlowDirection="LeftToRight" ToolTip="{l:Loc Tooltips.Uploader.Limit}"
|
||||
AutomationProperties.Name="{l:Loc Uploader.Limit.Label}" />
|
||||
<TextBlock Text="{l:Loc Uploader.Limit.Unit}" Style="{StaticResource Text.Base}" Foreground="{DynamicResource Brush.TextMuted}" Margin="6,0,0,0" />
|
||||
</StackPanel>
|
||||
</WrapPanel>
|
||||
|
||||
<TextBlock Grid.Row="4" Text="{l:Loc Uploader.Settings.Startup}" Style="{StaticResource Text.Label}" MinWidth="0" />
|
||||
<CheckBox Grid.Row="4" Grid.Column="1" Content="{l:Loc Uploader.Options.StartWithWindows}" IsChecked="{Binding StartWithWindows}"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.StartWithWindows}" VerticalAlignment="Center" />
|
||||
<CheckBox Grid.Row="5" Grid.Column="1" Content="{l:Loc Uploader.Options.MinimizeToTray}" IsChecked="{Binding MinimizeToTray}"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.MinimizeToTray}" VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Row="4" Text="{l:Loc Uploader.Settings.Startup}" Style="{StaticResource Text.PanelLabel}" />
|
||||
<CheckBox Grid.Row="4" Grid.Column="1" IsChecked="{Binding StartWithWindows}" ToolTip="{l:Loc Tooltips.Uploader.StartWithWindows}" VerticalAlignment="Center">
|
||||
<TextBlock Text="{l:Loc Uploader.Options.StartWithWindows}" TextWrapping="Wrap" />
|
||||
</CheckBox>
|
||||
<CheckBox Grid.Row="5" Grid.Column="1" IsChecked="{Binding MinimizeToTray}" ToolTip="{l:Loc Tooltips.Uploader.MinimizeToTray}" VerticalAlignment="Center">
|
||||
<TextBlock Text="{l:Loc Uploader.Options.MinimizeToTray}" TextWrapping="Wrap" />
|
||||
</CheckBox>
|
||||
|
||||
<TextBlock Grid.Row="6" Text="{l:Loc Uploader.Settings.Files}" Style="{StaticResource Text.Label}" MinWidth="0" />
|
||||
<CheckBox Grid.Row="6" Grid.Column="1" Content="{l:Loc Uploader.Options.DeleteSource}" IsChecked="{Binding DeleteAfterUpload, Mode=OneWay}"
|
||||
Command="{Binding ToggleDeleteAfterUploadCommand}" ToolTip="{l:Loc Tooltips.Uploader.DeleteSource}" VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Row="6" Text="{l:Loc Uploader.Settings.Files}" Style="{StaticResource Text.PanelLabel}" />
|
||||
<CheckBox Grid.Row="6" Grid.Column="1" IsChecked="{Binding DeleteAfterUpload, Mode=OneWay}" Command="{Binding ToggleDeleteAfterUploadCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Uploader.DeleteSource}" VerticalAlignment="Center">
|
||||
<TextBlock Text="{l:Loc Uploader.Options.DeleteSource}" TextWrapping="Wrap" />
|
||||
</CheckBox>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
@@ -1,31 +1,43 @@
|
||||
using System.Collections.Specialized;
|
||||
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.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using Titano.Ui.Controls;
|
||||
using Titano.Uploader.Infrastructure;
|
||||
using Titano.Uploader.Uploads;
|
||||
|
||||
namespace Titano.Uploader.Shell;
|
||||
|
||||
/// <summary>The uploader's single window (mockup Uploader.html).</summary>
|
||||
public sealed partial class MainWindow : TitanoWindow
|
||||
{
|
||||
/// <summary>Height of a queue row; the list scrolls by whole rows.</summary>
|
||||
public const double RowHeight = 28;
|
||||
|
||||
private readonly MainViewModel _vm;
|
||||
private readonly UploaderSettings _settings;
|
||||
private bool _connectShown;
|
||||
|
||||
public MainWindow(MainViewModel vm, UploaderSettings settings)
|
||||
{
|
||||
_vm = vm;
|
||||
_settings = settings;
|
||||
_connectShown = vm.IsConnectVisible;
|
||||
DataContext = vm;
|
||||
InitializeComponent();
|
||||
vm.PendingToasts.CollectionChanged += OnToastRequested;
|
||||
vm.PropertyChanged += OnViewModelChanged;
|
||||
vm.Connect.PropertyChanged += OnConnectChanged;
|
||||
vm.SignInRequested += (_, _) => FocusLater(Password);
|
||||
PreviewKeyDown += OnPreviewKeyDown;
|
||||
Loaded += (_, _) => FocusStart();
|
||||
RestorePlacement();
|
||||
}
|
||||
|
||||
@@ -95,6 +107,23 @@ public sealed partial class MainWindow : TitanoWindow
|
||||
|
||||
private void OnPasswordChanged(object sender, RoutedEventArgs e) => _vm.Connect.Password = Password.Password;
|
||||
|
||||
/// <summary>The "3 failed" link: brings the first failed file into view and gives it the keyboard (Enter retries it).</summary>
|
||||
private void OnShowFailedClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_vm.FirstFailed() is not { } item) return;
|
||||
ScrollNearTop(item);
|
||||
ItemList.UpdateLayout();
|
||||
if (ItemList.ItemContainerGenerator.ContainerFromItem(item) is ListBoxItem row) row.Focus();
|
||||
}
|
||||
|
||||
/// <summary>Enter on a failed row retries it: the keyboard path to the row's Retry button.</summary>
|
||||
private void OnItemListKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key != Key.Enter || e.OriginalSource is not ListBoxItem { DataContext: UploadItem { State: UploadItemState.Failed } item }) return;
|
||||
_vm.RetryItemCommand.Execute(item);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>DESIGN §4 inputs: Enter commits, Esc reverts; Esc also closes the settings panel.</summary>
|
||||
private void OnPreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
@@ -114,8 +143,88 @@ public sealed partial class MainWindow : TitanoWindow
|
||||
|
||||
private void OnViewModelChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(MainViewModel.CurrentItem) && _vm.CurrentItem is { } item) ItemList.ScrollIntoView(item);
|
||||
if (e.PropertyName == nameof(MainViewModel.IsConnectVisible) && _vm.IsConnectVisible) Password.Clear();
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(MainViewModel.CurrentItem) when _vm.CurrentItem is { } item && !ItemList.IsKeyboardFocusWithin:
|
||||
// Follow the upload unless the user is reading the list with the keyboard; a list that has just
|
||||
// appeared has its scroll viewer once it is laid out.
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () => ScrollNearTop(item));
|
||||
break;
|
||||
// Raised with every session change; only a real switch between the form and the queue moves the keyboard.
|
||||
case nameof(MainViewModel.IsConnectVisible) when _vm.IsConnectVisible != _connectShown:
|
||||
_connectShown = _vm.IsConnectVisible;
|
||||
if (_connectShown) Password.Clear();
|
||||
FocusStart();
|
||||
break;
|
||||
case nameof(MainViewModel.IsSettingsOpen):
|
||||
// Focus moves into the panel and comes back to the gear, so it is never left behind the scrim.
|
||||
FocusLater(_vm.IsSettingsOpen ? CloseSettingsButton : SettingsButton);
|
||||
break;
|
||||
case nameof(MainViewModel.Activity):
|
||||
Announce(QueueLine);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A refused address or password takes the keyboard to that field; other failures are announced.</summary>
|
||||
private void OnConnectChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
var connect = _vm.Connect;
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(ConnectViewModel.AddressError) when connect.AddressError is not null:
|
||||
FocusLater(AddressBox);
|
||||
break;
|
||||
case nameof(ConnectViewModel.PasswordError) when connect.PasswordError is not null:
|
||||
FocusLater(Password);
|
||||
break;
|
||||
case nameof(ConnectViewModel.ErrorText) when connect.ErrorText is not null:
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () => Announce(ErrorMessage));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Where the keyboard starts: the first empty field of the sign-in form, or Browse once signed in.</summary>
|
||||
private void FocusStart()
|
||||
{
|
||||
if (!_vm.IsConnectVisible) FocusLater(BrowseButton);
|
||||
else if (_vm.Connect.Address.Length == 0) FocusLater(AddressBox);
|
||||
else FocusLater(_vm.Connect.Username.Length == 0 ? UserBox : Password);
|
||||
}
|
||||
|
||||
/// <summary>Focuses <paramref name="target"/> once a visibility change has been laid out; text is selected so typing replaces it.</summary>
|
||||
private void FocusLater(Control target) => Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () =>
|
||||
{
|
||||
if (!target.IsVisible || !target.Focus()) return;
|
||||
if (target is TextBox box) box.SelectAll();
|
||||
else if (target is PasswordBox password) password.SelectAll();
|
||||
});
|
||||
|
||||
/// <summary>Scrolls so <paramref name="item"/> is the second visible row (the list scrolls by rows), unless it is already in view.</summary>
|
||||
private void ScrollNearTop(UploadItem item)
|
||||
{
|
||||
if (FindScrollViewer(ItemList) is not { } scroll) return;
|
||||
var index = ItemList.Items.IndexOf(item);
|
||||
if (index < 0) return;
|
||||
if (index >= scroll.VerticalOffset && index + 1 <= scroll.VerticalOffset + scroll.ViewportHeight) return;
|
||||
scroll.ScrollToVerticalOffset(Math.Max(0, index - 1));
|
||||
}
|
||||
|
||||
private static ScrollViewer? FindScrollViewer(DependencyObject node)
|
||||
{
|
||||
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(node, i);
|
||||
if (child is ScrollViewer scroll) return scroll;
|
||||
if (FindScrollViewer(child) is { } found) return found;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Asks screen readers to read <paramref name="element"/> again (it carries <see cref="AutomationProperties.LiveSettingProperty"/>).</summary>
|
||||
private static void Announce(UIElement element)
|
||||
{
|
||||
if (element.IsVisible) UIElementAutomationPeer.CreatePeerForElement(element)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
|
||||
}
|
||||
|
||||
private void OnToastRequested(object? sender, NotifyCollectionChangedEventArgs e)
|
||||
|
||||
@@ -10,39 +10,29 @@ using Titano.Uploader.DesignTime;
|
||||
namespace Titano.Uploader.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// <c>Titano.Uploader.exe --capture <dir></c>: renders the window at 760×560 in the dark and light themes —
|
||||
/// first run (connect), queue running, settings panel — from <see cref="SampleData"/>, then exits.
|
||||
/// <c>Titano.Uploader.exe --capture <dir></c>: renders the window at its default 760×700 — first run (connect),
|
||||
/// queue running, settings panel — from <see cref="SampleData"/> in the dark and light themes, then once more in
|
||||
/// Arabic (right to left, dark), and exits.
|
||||
/// </summary>
|
||||
public static class ScreenCapture
|
||||
{
|
||||
public static void Run(MainWindow window, MainViewModel vm, SampleData sample, string directory)
|
||||
private const double Width = 760;
|
||||
private const double Height = 700;
|
||||
|
||||
/// <param name="directory">Where the PNG files go.</param>
|
||||
/// <param name="applyLanguage">Switches the UI language (a culture name; null = the OS language).</param>
|
||||
public static void Run(string directory, Action<string?> applyLanguage)
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
window.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
window.Left = -20000;
|
||||
window.Top = -20000;
|
||||
window.Width = 760;
|
||||
window.Height = 560;
|
||||
window.ShowActivated = false;
|
||||
window.ShowInTaskbar = false;
|
||||
window.Show();
|
||||
|
||||
window.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, () =>
|
||||
Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var theme in new[] { AppTheme.Dark, AppTheme.Light })
|
||||
{
|
||||
var suffix = theme.ToString().ToLowerInvariant();
|
||||
ThemeManager.Apply(theme);
|
||||
sample.ShowConnect();
|
||||
Save(window, Path.Combine(directory, $"uploader-connect-{suffix}.png"));
|
||||
sample.ShowQueue();
|
||||
Save(window, Path.Combine(directory, $"uploader-queue-{suffix}.png"));
|
||||
vm.IsSettingsOpen = true;
|
||||
Save(window, Path.Combine(directory, $"uploader-settings-{suffix}.png"));
|
||||
vm.IsSettingsOpen = false;
|
||||
}
|
||||
applyLanguage(null);
|
||||
CaptureScreens(directory, string.Empty, [AppTheme.Dark, AppTheme.Light]);
|
||||
// Mirrored layout with paths, addresses and file names kept left to right (BRIEF §16).
|
||||
applyLanguage("ar");
|
||||
CaptureScreens(directory, "-ar", [AppTheme.Dark]);
|
||||
Log.Info("capture", $"Screenshots written to {Path.GetFullPath(directory)}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -57,6 +47,44 @@ public static class ScreenCapture
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>A fresh window on fresh sample data, so every text is built in the current language.</summary>
|
||||
private static void CaptureScreens(string directory, string language, IReadOnlyList<AppTheme> themes)
|
||||
{
|
||||
var sample = new SampleData();
|
||||
var vm = sample.CreateViewModel();
|
||||
var window = new MainWindow(vm, sample.Settings)
|
||||
{
|
||||
WindowStartupLocation = WindowStartupLocation.Manual,
|
||||
Left = -20000,
|
||||
Top = -20000,
|
||||
Width = Width,
|
||||
Height = Height,
|
||||
ShowActivated = false,
|
||||
ShowInTaskbar = false,
|
||||
};
|
||||
window.Show();
|
||||
try
|
||||
{
|
||||
foreach (var theme in themes)
|
||||
{
|
||||
var suffix = language + "-" + theme.ToString().ToLowerInvariant();
|
||||
ThemeManager.Apply(theme);
|
||||
sample.ShowConnect();
|
||||
Save(window, Path.Combine(directory, $"uploader-connect{suffix}.png"));
|
||||
sample.ShowQueue();
|
||||
Save(window, Path.Combine(directory, $"uploader-queue{suffix}.png"));
|
||||
vm.IsSettingsOpen = true;
|
||||
Save(window, Path.Combine(directory, $"uploader-settings{suffix}.png"));
|
||||
vm.IsSettingsOpen = false;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
window.Close();
|
||||
vm.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static void Save(Window window, string path)
|
||||
{
|
||||
// Let bindings, templates and deferred layout complete.
|
||||
@@ -70,10 +98,24 @@ public static class ScreenCapture
|
||||
var height = (int)Math.Ceiling(root.ActualHeight * dpi.DpiScaleY);
|
||||
if (width <= 0 || height <= 0) return;
|
||||
var bitmap = new RenderTargetBitmap(width, height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32);
|
||||
bitmap.Render(root);
|
||||
bitmap.Render(window.FlowDirection == FlowDirection.RightToLeft ? Mirrored(root) : root);
|
||||
var encoder = new PngBitmapEncoder();
|
||||
encoder.Frames.Add(BitmapFrame.Create(bitmap));
|
||||
using var stream = File.Create(path);
|
||||
encoder.Save(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A right-to-left window is mirrored by a transform on the window itself, which rendering its content alone
|
||||
/// would leave out (mirrored glyphs, left-to-right layout): draw the content through that mirror.
|
||||
/// </summary>
|
||||
private static DrawingVisual Mirrored(FrameworkElement root)
|
||||
{
|
||||
var size = new Rect(0, 0, root.ActualWidth, root.ActualHeight);
|
||||
var visual = new DrawingVisual();
|
||||
using var dc = visual.RenderOpen();
|
||||
dc.PushTransform(new MatrixTransform(-1, 0, 0, 1, size.Width, 0));
|
||||
dc.DrawRectangle(new VisualBrush(root) { Stretch = Stretch.Fill, ViewboxUnits = BrushMappingMode.Absolute, Viewbox = size }, null, size);
|
||||
return visual;
|
||||
}
|
||||
}
|
||||
@@ -6,25 +6,6 @@ using Titano.Uploader.Interop;
|
||||
|
||||
namespace Titano.Uploader.Shell;
|
||||
|
||||
/// <summary>Pickers and confirmations the view model asks for.</summary>
|
||||
public interface IUploaderDialogs
|
||||
{
|
||||
/// <summary>Photos to add; empty when cancelled.</summary>
|
||||
IReadOnlyList<string> PickFiles();
|
||||
|
||||
/// <summary>A folder or card root to add; null when cancelled.</summary>
|
||||
string? PickFolder();
|
||||
|
||||
/// <summary>A folder to watch; null when cancelled.</summary>
|
||||
string? PickWatchFolder();
|
||||
|
||||
/// <summary>Trust-on-first-use: shows the certificate fingerprint; true when the user trusts it.</summary>
|
||||
bool ConfirmTrust(string address, string fingerprint);
|
||||
|
||||
/// <summary>Destructive confirmation for "Delete after upload"; true when the user turns it on.</summary>
|
||||
bool ConfirmDeleteAfterUpload();
|
||||
}
|
||||
|
||||
/// <summary>Window-owned implementation: shell Open dialogs and <see cref="ConfirmDialog"/>.</summary>
|
||||
public sealed class UploaderDialogs : IUploaderDialogs
|
||||
{
|
||||
|
||||
@@ -41,6 +41,7 @@ public sealed class WatchFolderViewModel : ObservableObject
|
||||
{
|
||||
if (!Set(ref _intervalSeconds, value)) return;
|
||||
OnPropertyChanged(nameof(Text));
|
||||
OnPropertyChanged(nameof(IntervalText));
|
||||
OnPropertyChanged(nameof(ToolTip));
|
||||
OnPropertyChanged(nameof(MenuOptions));
|
||||
}
|
||||
@@ -56,12 +57,16 @@ public sealed class WatchFolderViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>"D:\Cam\Roof · every 1 min".</summary>
|
||||
/// <summary>"D:\Cam\Roof · every 1 min": the chip's accessible name.</summary>
|
||||
public string Text => Loc.L("Uploader.Watch.Chip", Path, Interval(IntervalSeconds));
|
||||
|
||||
public string ToolTip => IsAvailable == false ? Loc.L("Tooltips.Uploader.WatchFolderMissing", Interval(IntervalSeconds))
|
||||
/// <summary>"every 1 min", shown after the path, which the chip draws left to right on its own and may shorten.</summary>
|
||||
public string IntervalText => Loc.L("Uploader.Watch.Interval", Interval(IntervalSeconds));
|
||||
|
||||
/// <summary>The full path (the chip may shorten it), then the folder's state and interval.</summary>
|
||||
public string ToolTip => LeftToRight(Path) + " · " + (IsAvailable == false ? Loc.L("Tooltips.Uploader.WatchFolderMissing", Interval(IntervalSeconds))
|
||||
: IsNetwork ? Loc.L("Tooltips.Uploader.WatchFolderNetwork", Interval(IntervalSeconds))
|
||||
: Loc.L("Tooltips.Uploader.WatchFolder", Interval(IntervalSeconds));
|
||||
: Loc.L("Tooltips.Uploader.WatchFolder", Interval(IntervalSeconds)));
|
||||
|
||||
public IReadOnlyList<WatchMenuOption> MenuOptions =>
|
||||
[
|
||||
@@ -75,4 +80,7 @@ public sealed class WatchFolderViewModel : ObservableObject
|
||||
];
|
||||
|
||||
private static string Interval(int seconds) => UploaderText.Duration(TimeSpan.FromSeconds(seconds), Loc.Culture);
|
||||
|
||||
/// <summary>Embeds a path left to right (LRE … PDF) so a right-to-left tooltip does not reorder its separators.</summary>
|
||||
private static string LeftToRight(string text) => "\u202A" + text + "\u202C";
|
||||
}
|
||||
Reference in new issue
Block a user