mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-18 22:45:59 +01:00
A review against WCAG 2.2 AA left places a screen reader user could not work: - Key bindings: a key's button says the command and the key, the clear button which command it clears; a new key is said aloud and focus comes back to its row. The on-screen keyboard is reached with Tab and walked with the arrows. - Number fields read their label; the spin buttons are named and left out of Tab. - Dialogs: Enter presses the main button, Esc closes, focus starts on the first button and the message is read with it. - Consist: every change is said - added, removed, turned, moved, replaced, undone - and the strip is a named list; a turned card says so. - Searches say how many entries are left once typing pauses. - Hasler tapes, the black box timeline, timetable and cab panel take focus, work from the keyboard, read their value as it changes and draw a focus frame. - Section reset and level controls, the crew button and the tabs carry names; English names from Avalonia's templates are read in the starter's language; sort and crew menus are radio items. - Input borders reach 3:1 against the panels; Tab starts at the top bar; the splash screen has a title and its progress reads the loading step.
146 lines
4.2 KiB
C#
146 lines
4.2 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls.Primitives;
|
|
using Avalonia.Layout;
|
|
using Avalonia.Media;
|
|
using StarterNG.Infrastructure;
|
|
|
|
namespace StarterNG.Views;
|
|
|
|
public static class AboutWindow
|
|
{
|
|
private const string RepositoryUrl = "https://github.com/MaSzyna-EU07/StarterNG";
|
|
|
|
private static readonly string[] ChangelogNames =
|
|
{
|
|
"changelog.txt", "starter/changelog.txt", "CHANGELOG.md"
|
|
};
|
|
|
|
public static Window Create()
|
|
{
|
|
var win = new Window
|
|
{
|
|
Title = App.Loc["AboutTitle"],
|
|
Width = 640,
|
|
Height = 460,
|
|
MinWidth = 480,
|
|
MinHeight = 320,
|
|
WindowStartupLocation = WindowStartupLocation.CenterOwner
|
|
};
|
|
|
|
var header = new StackPanel { Spacing = 2, Margin = new Avalonia.Thickness(20, 18, 20, 12) };
|
|
header.Children.Add(new TextBlock
|
|
{
|
|
Text = "Starter MaSzyna",
|
|
FontSize = 22,
|
|
FontWeight = FontWeight.Bold
|
|
});
|
|
header.Children.Add(new TextBlock
|
|
{
|
|
Text = $"{App.Loc["Version"]} {AppInfo.Version}",
|
|
Opacity = 0.8
|
|
});
|
|
header.Children.Add(new TextBlock
|
|
{
|
|
Text = App.Loc["AboutForSimulator"],
|
|
Opacity = 0.8
|
|
});
|
|
|
|
var repo = new Button
|
|
{
|
|
Content = RepositoryUrl,
|
|
Tag = RepositoryUrl,
|
|
Padding = new Avalonia.Thickness(0),
|
|
HorizontalAlignment = HorizontalAlignment.Left,
|
|
Margin = new Avalonia.Thickness(0, 6, 0, 10),
|
|
Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Hand)
|
|
};
|
|
repo.Classes.Add("Basic");
|
|
repo.Click += (_, _) => OpenUrl(RepositoryUrl);
|
|
header.Children.Add(repo);
|
|
|
|
var changelog = new TextBox
|
|
{
|
|
Text = ReadChangelog(),
|
|
IsReadOnly = true,
|
|
AcceptsReturn = true,
|
|
TextWrapping = TextWrapping.NoWrap,
|
|
FontFamily = MonoFont.Family,
|
|
FontSize = 12,
|
|
Margin = new Avalonia.Thickness(20, 0, 20, 12)
|
|
};
|
|
ScrollViewer.SetHorizontalScrollBarVisibility(changelog, ScrollBarVisibility.Auto);
|
|
ScrollViewer.SetVerticalScrollBarVisibility(changelog, ScrollBarVisibility.Auto);
|
|
|
|
var close = new Button
|
|
{
|
|
Content = App.Loc["Close"],
|
|
MinWidth = 90,
|
|
Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Hand)
|
|
};
|
|
close.Classes.Add("Accent");
|
|
close.Click += (_, _) => win.Close();
|
|
close.IsDefault = true;
|
|
close.IsCancel = true;
|
|
|
|
var footer = new StackPanel
|
|
{
|
|
Orientation = Orientation.Horizontal,
|
|
HorizontalAlignment = HorizontalAlignment.Right,
|
|
Margin = new Avalonia.Thickness(20, 0, 20, 16),
|
|
Children = { close }
|
|
};
|
|
|
|
var root = new DockPanel();
|
|
DockPanel.SetDock(header, Dock.Top);
|
|
DockPanel.SetDock(footer, Dock.Bottom);
|
|
root.Children.Add(header);
|
|
root.Children.Add(footer);
|
|
|
|
var logLabel = new TextBlock
|
|
{
|
|
Text = App.Loc["AboutChangelog"],
|
|
Margin = new Avalonia.Thickness(20, 0, 20, 4),
|
|
Opacity = 0.8
|
|
};
|
|
DockPanel.SetDock(logLabel, Dock.Top);
|
|
root.Children.Add(logLabel);
|
|
root.Children.Add(changelog);
|
|
|
|
win.Content = root;
|
|
return win;
|
|
}
|
|
|
|
private static void OpenUrl(string url)
|
|
{
|
|
try
|
|
{
|
|
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Infrastructure.Diagnostics.Log($"Open {url}", ex);
|
|
}
|
|
}
|
|
|
|
private static string ReadChangelog()
|
|
{
|
|
foreach (string name in ChangelogNames)
|
|
{
|
|
string path = Path.Combine(Directory.GetCurrentDirectory(), name);
|
|
if (!File.Exists(path)) continue;
|
|
try
|
|
{
|
|
return File.ReadAllText(path);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Diagnostics.Log($"Changelog {path}", ex);
|
|
}
|
|
}
|
|
return App.Loc["AboutNoChangelog"];
|
|
}
|
|
}
|