Files
OpenNest/OpenNest.Avalonia/TimingDialog.cs
T
ajandClaude Opus 5.5 59d263abda feat(avalonia): calculate cut time and simulate cutting
Plate > Calculate Cut Time and Nest > Calculate Cut Time ask for the
outside feed, rapid, pierce time, hole feed, acceleration machine and
etch choice (remembered in the settings both apps share, saved however
the dialog closes, as WinForms), then show the timing as the WinForms
Timing Information window.

Plate > Simulate Cutting and its toolbar button open the Cut Simulator:
play and pause at 1x to 250x, restart and end, part and cutout jumps,
move stepping with the arrow keys, scrubbing, and the time, part,
drawing and motion at the playhead, retimed as the feeds change and
following the shown plate. The plate view draws the cut trail, travel,
the torch and pierces, and mutes parts and cut-off segments the torch
has not reached. While it is open the nest is view-only, as WinForms:
only the plate view and its header stay live, Escape closes it and
Ctrl+Plus and Ctrl+Minus still zoom.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 18:55:40 -05:00

89 lines
3.4 KiB
C#

using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Layout;
using Avalonia.Media;
using OpenNest.Forms;
namespace OpenNest.Avalonia
{
/// <summary>
/// Calculate Cut Time's result, as the WinForms Timing Information window: cut time, cut and
/// rapid distance, pierces and intersections, then the feed, rapid and pierce time used.
/// </summary>
internal sealed class TimingDialog : Window
{
private TimingDialog(CutTimeReport report)
{
Title = "Timing Information";
SizeToContent = SizeToContent.WidthAndHeight;
MinWidth = 320;
CanResize = false;
ShowInTaskbar = false;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
var rows = new (string Label, string Value, string Name)[]
{
("Cut Time :", report.CutTimeText, "CutTime"),
("Cut Distance :", report.CutDistanceText, "CutDistance"),
("Rapid Distance :", report.RapidDistanceText, "RapidDistance"),
("# of Pierces :", report.PierceCountText, "Pierces"),
("# of Intersections :", report.IntersectionCountText, "Intersections"),
(null, null, null),
("Feedrate :", report.FeedrateText, "Feedrate"),
("Rapid Feedrate :", report.RapidText, "Rapid"),
("Pierce Time :", report.PierceTimeText, "PierceTime"),
};
var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), ColumnSpacing = 16, RowSpacing = 6 };
for (var i = 0; i < rows.Length; i++)
{
grid.RowDefinitions.Add(new RowDefinition(GridLength.Auto));
var (label, value, name) = rows[i];
if (label == null)
{
var line = new Border { Height = 1, Background = Brushes.Silver, Margin = new Thickness(0, 4) };
Grid.SetRow(line, i);
Grid.SetColumnSpan(line, 2);
grid.Children.Add(line);
continue;
}
var caption = new TextBlock { Text = label };
Grid.SetRow(caption, i);
grid.Children.Add(caption);
var text = new TextBlock { Name = name, Text = value };
Grid.SetRow(text, i);
Grid.SetColumn(text, 1);
grid.Children.Add(text);
}
var close = new Button
{
Name = "Close",
Content = "Close",
IsDefault = true,
IsCancel = true,
MinWidth = 80,
HorizontalAlignment = HorizontalAlignment.Right,
};
close.Click += (_, _) => Close();
var panel = new StackPanel { Margin = new Thickness(12), Spacing = 14 };
panel.Children.Add(grid);
panel.Children.Add(close);
Content = panel;
AddHandler(KeyDownEvent, (_, e) =>
{
if (e.Key != Key.Escape)
return;
e.Handled = true;
Close();
}, RoutingStrategies.Tunnel);
}
public static Task ShowAsync(Window owner, CutTimeReport report) =>
new TimingDialog(report).ShowDialog(owner);
}
}