mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-12 18:11:11 -05:00
Each open nest gets a tab along the bottom of the window, above the status bar: the shown one is white with a blue line, a dot marks unsaved Auto Nest results, x closes it and + opens another. Inside a tab, Plates and Drawings tabs sit at the top of the left panel (Drawings lists each drawing's nested and required quantity) and the plate header with first/previous/next/last sits over the plate view. Each nest keeps its own plate and zoom when you switch. File > Open takes several files, and a file already open switches to its tab. File > Close and Close All, View > Next/Previous Nest and Ctrl+Tab/Ctrl+Shift+Tab switch or close nests. This version cannot save, so closing a nest with Auto Nest results, or exiting with any, asks first (Cancel is the default). Other nests can be opened and viewed while Auto Nest runs; the nest being nested cannot be closed until it finishes. Several nest paths on the command line open in tabs.
41 lines
1.7 KiB
C#
41 lines
1.7 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
using Avalonia.Markup.Xaml;
|
|
|
|
namespace OpenNest.Avalonia
|
|
{
|
|
public partial class App : Application
|
|
{
|
|
public override void Initialize() => AvaloniaXamlLoader.Load(this);
|
|
|
|
public override void OnFrameworkInitializationCompleted()
|
|
{
|
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
{
|
|
var window = new MainWindow();
|
|
desktop.MainWindow = window;
|
|
var args = desktop.Args ?? System.Array.Empty<string>();
|
|
// Each nest path before the first --option opens in its own tab; the last is shown.
|
|
foreach (var path in args)
|
|
{
|
|
if (path.StartsWith("--"))
|
|
break;
|
|
window.OpenNest(path);
|
|
}
|
|
// --auto-nest: run Auto Nest on the opened nest (with --snapshot, before rendering).
|
|
if (System.Array.IndexOf(args, "--auto-nest") >= 0)
|
|
window.AutoNestOnOpen();
|
|
// --snapshot <png> [plate]: render the window to an image (status line in <png>.txt) and exit.
|
|
var snapshot = System.Array.IndexOf(args, "--snapshot");
|
|
if (snapshot >= 0 && snapshot + 1 < args.Length)
|
|
window.SaveSnapshotAndClose(args[snapshot + 1],
|
|
snapshot + 2 < args.Length && int.TryParse(args[snapshot + 2], out var plate) ? plate : 1);
|
|
else
|
|
window.RememberPlacement();
|
|
}
|
|
|
|
base.OnFrameworkInitializationCompleted();
|
|
}
|
|
}
|
|
}
|