fix(uploader): follow right-to-left languages, name and reach every control by keyboard
Uploader: - Mirror the main window, the confirmation dialog and the tray menu for ar/he/fa/ur; keep paths, addresses, file names, the fingerprint, the brand mark and media glyphs left to right. - Queue rows take keyboard focus, are named "file · state" for screen readers, and Enter retries a failed file; a "✕ n failed" link jumps to the first failure; the list follows the upload near its top. - Focus moves into the settings panel (Tab cycles inside) and back to the gear, to Browse after sign-in and to the refused field after a failed one; activity changes and sign-in errors are announced. - A wrong address or password marks its field (error border, message in the tooltip); Retry only where it can help; session-ended toasts offer Sign in; the form stays visible while its own sign-in runs. - Watch chips and the add button wrap and shorten long paths; target choices wrap with their fields; the settings panel uses the side-panel width with wrapping labels; disabled controls say why. - The window opens at 760x700 (min 630 high) so the per-file list shows five rows; --capture adds an Arabic pass. Setup: - Every stage has a default and a cancel button (safe action first), the keyboard moves to the new default and outcomes are announced; the title-bar Close is disabled while files are written. - "Remove my data" measures the user data folder and shows the plan (largest entries, total) before Uninstall can run; the tooltip names backups and the uploader queue. - Folder field before Browse in Tab order; paths and file names left to right; disabled tooltips say why. Both: byte units come from the language (Common.Size.*). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
32 files changed
+1145
-227
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user