mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-05 04:49:25 -05:00
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>
67 lines
2.4 KiB
C#
67 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Input;
|
|
using Avalonia.LogicalTree;
|
|
|
|
namespace OpenNest.Avalonia
|
|
{
|
|
/// <summary>
|
|
/// Holds a nest view-only while it is inspected (the Cut Simulator), as the WinForms
|
|
/// inspection scope: every control of the window is disabled except the ones kept live (the
|
|
/// plate view and its header's plate and zoom buttons), the plate takes no edits and nothing
|
|
/// can be dropped on the window. Disposing puts each back as it was.
|
|
/// </summary>
|
|
internal sealed class InspectionLock : IDisposable
|
|
{
|
|
private readonly List<(Control Control, bool Enabled)> disabled = new();
|
|
private readonly List<(Control Control, bool AllowDrop)> drops = new();
|
|
private readonly Controls.PlateCanvas canvas;
|
|
private readonly bool wasLocked;
|
|
private bool disposed;
|
|
|
|
public InspectionLock(Window root, Controls.PlateCanvas canvas, IReadOnlyCollection<Control> keepLive)
|
|
{
|
|
this.canvas = canvas;
|
|
wasLocked = canvas.EditsLocked;
|
|
canvas.EditsLocked = true;
|
|
var live = keepLive.Prepend(canvas).Where(control => control != null).ToList();
|
|
Disable(root, live);
|
|
foreach (var control in new Control[] { root, canvas })
|
|
{
|
|
drops.Add((control, DragDrop.GetAllowDrop(control)));
|
|
DragDrop.SetAllowDrop(control, false);
|
|
}
|
|
}
|
|
|
|
private void Disable(ILogical parent, List<Control> live)
|
|
{
|
|
foreach (var child in parent.LogicalChildren.OfType<Control>().ToList())
|
|
{
|
|
if (live.Contains(child))
|
|
continue;
|
|
if (live.Any(control => control.GetLogicalAncestors().Contains(child)))
|
|
Disable(child, live);
|
|
else
|
|
{
|
|
disabled.Add((child, child.IsEnabled));
|
|
child.IsEnabled = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
if (disposed)
|
|
return;
|
|
disposed = true;
|
|
foreach (var (control, enabled) in disabled)
|
|
control.IsEnabled = enabled;
|
|
foreach (var (control, allowDrop) in drops)
|
|
DragDrop.SetAllowDrop(control, allowDrop);
|
|
canvas.EditsLocked = wasLocked;
|
|
}
|
|
}
|
|
}
|