mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-24 06:17:39 -05:00
Whole-nest snapshots make undo safe without a hand-written inverse per operation: each recorded edit stores one NestSnapshot in the document's history, and Undo/Redo read one back and swap it into the open window. - Document.History is reset with the opened nest; Save and database saves mark the save point instead of clearing it. - EditNestForm.BeginChange opens a scope: nested scopes merge into the outermost, Complete commits one entry, and leaving it incomplete rolls a changed nest back. No-ops are detected by the scope's changed flag, not by comparing bytes (copies are not byte-stable). - RestoreNest shares the per-nest binding with the constructor and keeps the Document, the nest's identity, the plate index, the viewport and the selection. It ends the action, closes Cutting Inspection, side panels and the remnant viewer, rebuilds the PlateManager, reapplies the view's cut-off settings and recolours the drawings, because each of those holds or derives from the old nest's objects. - An edit no scope recorded (Phase 3 sites) is detected by a cheap fingerprint and committed as its own "Change" entry before a scope, Undo or Redo, so it is never silently discarded; DEBUG builds also warn about it on idle. - Edit > Undo/Redo name the next entry. Ctrl+Z/Ctrl+Y/Ctrl+Shift+Z go to focused text editors first, then to an action's own step-back (Sequence by Path), then to the nest. They wait for jobs, fills, background saves and busy actions, but not for a plain selection. - Recorded: delete, drag, arrow nudges (coalesced), rotate, align, push, expand spacing, add part (drop and clone), cut, add and remove plate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
95 lines
2.9 KiB
C#
95 lines
2.9 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
|
|
namespace OpenNest
|
|
{
|
|
public static class Win32
|
|
{
|
|
[DllImport("kernel32")]
|
|
public static extern long WritePrivateProfileString(
|
|
string section,
|
|
string key,
|
|
string val,
|
|
string filePath
|
|
);
|
|
|
|
[DllImport("kernel32")]
|
|
public static extern int GetPrivateProfileString(
|
|
string section,
|
|
string key,
|
|
string def,
|
|
StringBuilder retVal,
|
|
int size,
|
|
string filePath
|
|
);
|
|
|
|
/// <summary>The window with keyboard focus on this thread, or zero.</summary>
|
|
[DllImport("user32.dll")]
|
|
public static extern IntPtr GetFocus();
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
|
|
|
[DllImport("user32.dll")]
|
|
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
|
|
|
[DllImport("user32.dll", ExactSpelling = true)]
|
|
public static extern int SetWindowPos(
|
|
IntPtr hWnd,
|
|
IntPtr hWndInsertAfter,
|
|
int X,
|
|
int Y,
|
|
int cx,
|
|
int cy,
|
|
uint uFlags
|
|
);
|
|
|
|
[DllImport("user32.dll")]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
private static extern bool FlashWindowEx(ref FLASHWINFO info);
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
private struct FLASHWINFO
|
|
{
|
|
public uint cbSize;
|
|
public IntPtr hwnd;
|
|
public uint dwFlags;
|
|
public uint uCount;
|
|
public uint dwTimeout;
|
|
}
|
|
|
|
/// <summary>Flashes the window's taskbar button until the window comes to the foreground.</summary>
|
|
public static void FlashTaskbarUntilActive(IntPtr hWnd)
|
|
{
|
|
const uint FLASHW_TRAY = 0x2;
|
|
const uint FLASHW_TIMERNOFG = 0xC;
|
|
var info = new FLASHWINFO
|
|
{
|
|
cbSize = (uint)Marshal.SizeOf<FLASHWINFO>(),
|
|
hwnd = hWnd,
|
|
dwFlags = FLASHW_TRAY | FLASHW_TIMERNOFG,
|
|
};
|
|
FlashWindowEx(ref info);
|
|
}
|
|
|
|
#region Constants
|
|
|
|
public const int GWL_EXSTYLE = -20;
|
|
public const int WS_EX_CLIENTEDGE = 0x200;
|
|
public const uint SWP_NOSIZE = 0x0001;
|
|
public const uint SWP_NOMOVE = 0x0002;
|
|
public const uint SWP_NOZORDER = 0x0004;
|
|
public const uint SWP_NOREDRAW = 0x0008;
|
|
public const uint SWP_NOACTIVATE = 0x0010;
|
|
public const uint SWP_FRAMECHANGED = 0x0020;
|
|
public const uint SWP_SHOWWINDOW = 0x0040;
|
|
public const uint SWP_HIDEWINDOW = 0x0080;
|
|
public const uint SWP_NOCOPYBITS = 0x0100;
|
|
public const uint SWP_NOOWNERZORDER = 0x0200;
|
|
public const uint SWP_NOSENDCHANGING = 0x0400;
|
|
|
|
#endregion Constants
|
|
}
|
|
}
|