Say why the folders cannot be made instead of dying
Something already sitting where Documents/N1MM Logger+ should go — a file, or a link to somewhere that is not there — threw out of Directory.CreateDirectory before the program had a window, so the operator got a stack trace and nothing else. CreateFolders answers with what stopped it, and the program shows it in a window naming the path and stops there. NONEMM_HOME moves the whole lot somewhere else, for a station that keeps its files off the Documents folder. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Nonemm.App.Windows;
|
||||
|
||||
/// What the operator sees when the program cannot make the folders it keeps
|
||||
/// everything in. There is no log, no settings and no entry window at that
|
||||
/// point, so this says what is wrong and what to do about it, and closing it
|
||||
/// ends the program.
|
||||
public sealed class StartupProblemWindow : Window
|
||||
{
|
||||
public StartupProblemWindow(string problem, string root)
|
||||
{
|
||||
Title = "Nonemm cannot start";
|
||||
Width = 560;
|
||||
SizeToContent = SizeToContent.Height;
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
Content = new StackPanel
|
||||
{
|
||||
Margin = new Avalonia.Thickness(18),
|
||||
Spacing = 10,
|
||||
Children =
|
||||
{
|
||||
new TextBlock
|
||||
{
|
||||
Text = "The program keeps its files with N1MM's, and could not make them:",
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
},
|
||||
new TextBlock { Text = problem, TextWrapping = TextWrapping.Wrap, FontWeight = FontWeight.Bold },
|
||||
new TextBlock
|
||||
{
|
||||
Text = $"The folder it works in is {root}. Setting NONEMM_HOME to another "
|
||||
+ "path moves the whole lot somewhere else.",
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
FontSize = 11,
|
||||
Opacity = 0.75,
|
||||
},
|
||||
new Button
|
||||
{
|
||||
Content = "Quit",
|
||||
HorizontalAlignment = HorizontalAlignment.Right,
|
||||
IsDefault = true,
|
||||
},
|
||||
},
|
||||
};
|
||||
if (((StackPanel)Content).Children[^1] is Button quit)
|
||||
{
|
||||
quit.Click += (_, _) => Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user