Restructure project layout to flatten directory structure
Move all projects from Source/ to repository root for simpler navigation. - Remove External/ dependency DLLs (will use NuGet packages) - Remove Installer/ NSIS script - Replace PartCollection/PlateCollection with ObservableList - Add packages.config for NuGet dependencies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
BIN
External/Ionic.Zip.dll
vendored
BIN
External/Ionic.Zip.dll
vendored
Binary file not shown.
BIN
External/netDxf.dll
vendored
BIN
External/netDxf.dll
vendored
Binary file not shown.
@@ -1,138 +0,0 @@
|
||||
!include "MUI2.nsh"
|
||||
|
||||
Name "OpenNest"
|
||||
|
||||
OutFile "opennest-setup.exe"
|
||||
|
||||
InstallDir "$PROGRAMFILES\OpenNest"
|
||||
|
||||
RequestExecutionLevel admin
|
||||
|
||||
!define DOT_MAJOR "4"
|
||||
!define DOT_MINOR "0"
|
||||
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
!insertmacro MUI_PAGE_LICENSE "../license.txt"
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
|
||||
UninstPage uninstConfirm
|
||||
UninstPage instfiles
|
||||
|
||||
Section "OpenNest (required)"
|
||||
Call IsDotNETInstalled
|
||||
SectionIn RO
|
||||
#!/usr/bin/env
|
||||
; Set output path to the installation directory.
|
||||
SetOutPath $INSTDIR
|
||||
|
||||
File "OpenNest.exe"
|
||||
File "OpenNest.Core.dll"
|
||||
File "OpenNest.Engine.dll"
|
||||
File "Ionic.Zip.dll"
|
||||
File "netDxf.dll"
|
||||
|
||||
; Write the installation path into the registry
|
||||
WriteRegStr HKLM SOFTWARE\OpenNest "Install_Dir" "$INSTDIR"
|
||||
|
||||
; Write the uninstall keys for Windows
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenNest" "DisplayName" "OpenNest"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenNest" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenNest" "NoModify" 1
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenNest" "NoRepair" 1
|
||||
WriteUninstaller "uninstall.exe"
|
||||
SectionEnd
|
||||
|
||||
Section "Start Menu Shortcuts"
|
||||
CreateDirectory "$SMPROGRAMS\OpenNest"
|
||||
CreateShortCut "$SMPROGRAMS\OpenNest\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
|
||||
CreateShortCut "$SMPROGRAMS\OpenNest\OpenNest.lnk" "$INSTDIR\OpenNest.exe" "" "$INSTDIR\OpenNest.exe" 0
|
||||
SectionEnd
|
||||
|
||||
Section "Uninstall"
|
||||
Delete "$INSTDIR\uninstall.exe"
|
||||
Delete "$INSTDIR\OpenNest.exe"
|
||||
Delete "$INSTDIR\OpenNest.Core.dll"
|
||||
Delete "$INSTDIR\OpenNest.Engine.dll"
|
||||
Delete "$INSTDIR\Ionic.Zip.dll"
|
||||
Delete "$INSTDIR\netDxf.dll"
|
||||
|
||||
Delete "$SMPROGRAMS\OpenNest\Uninstall.lnk"
|
||||
Delete "$SMPROGRAMS\OpenNest\OpenNest.lnk"
|
||||
Delete "$SMPROGRAMS\OpenNest"
|
||||
SectionEnd
|
||||
|
||||
; Usage
|
||||
; Define in your script two constants:
|
||||
; DOT_MAJOR "(Major framework version)"
|
||||
; DOT_MINOR "{Minor framework version)"
|
||||
;
|
||||
; Call IsDotNetInstalled
|
||||
; This function will abort the installation if the required version
|
||||
; or higher version of the .NET Framework is not installed. Place it in
|
||||
; either your .onInit function or your first install section before
|
||||
; other code.
|
||||
Function IsDotNetInstalled
|
||||
|
||||
StrCpy $0 "0"
|
||||
StrCpy $1 "SOFTWARE\Microsoft\.NETFramework" ;registry entry to look in.
|
||||
StrCpy $2 0
|
||||
|
||||
StartEnum:
|
||||
;Enumerate the versions installed.
|
||||
EnumRegKey $3 HKLM "$1\policy" $2
|
||||
|
||||
;If we don't find any versions installed, it's not here.
|
||||
StrCmp $3 "" noDotNet notEmpty
|
||||
|
||||
;We found something.
|
||||
notEmpty:
|
||||
;Find out if the RegKey starts with 'v'.
|
||||
;If it doesn't, goto the next key.
|
||||
StrCpy $4 $3 1 0
|
||||
StrCmp $4 "v" +1 goNext
|
||||
StrCpy $4 $3 1 1
|
||||
|
||||
;It starts with 'v'. Now check to see how the installed major version
|
||||
;relates to our required major version.
|
||||
;If it's equal check the minor version, if it's greater,
|
||||
;we found a good RegKey.
|
||||
IntCmp $4 ${DOT_MAJOR} +1 goNext yesDotNetReg
|
||||
;Check the minor version. If it's equal or greater to our requested
|
||||
;version then we're good.
|
||||
StrCpy $4 $3 1 3
|
||||
IntCmp $4 ${DOT_MINOR} yesDotNetReg goNext yesDotNetReg
|
||||
|
||||
goNext:
|
||||
;Go to the next RegKey.
|
||||
IntOp $2 $2 + 1
|
||||
goto StartEnum
|
||||
|
||||
yesDotNetReg:
|
||||
;Now that we've found a good RegKey, let's make sure it's actually
|
||||
;installed by getting the install path and checking to see if the
|
||||
;mscorlib.dll exists.
|
||||
EnumRegValue $2 HKLM "$1\policy\$3" 0
|
||||
;$2 should equal whatever comes after the major and minor versions
|
||||
;(ie, v1.1.4322)
|
||||
StrCmp $2 "" noDotNet
|
||||
ReadRegStr $4 HKLM $1 "InstallRoot"
|
||||
;Hopefully the install root isn't empty.
|
||||
StrCmp $4 "" noDotNet
|
||||
;build the actuall directory path to mscorlib.dll.
|
||||
StrCpy $4 "$4$3.$2\mscorlib.dll"
|
||||
IfFileExists $4 yesDotNet noDotNet
|
||||
|
||||
noDotNet:
|
||||
;Nope, something went wrong along the way. Looks like the
|
||||
;proper .NET Framework isn't installed.
|
||||
MessageBox MB_OK "You must have v${DOT_MAJOR}.${DOT_MINOR} or greater of the .NET Framework installed. Aborting!"
|
||||
Abort
|
||||
|
||||
yesDotNet:
|
||||
;Everything checks out. Go on with the rest of the installation.
|
||||
|
||||
FunctionEnd
|
||||
164
OpenNest.Core/Collections/ObservableList.cs
Normal file
164
OpenNest.Core/Collections/ObservableList.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenNest.Collections
|
||||
{
|
||||
public class ObservableList<T> : IList<T>, ICollection<T>, IEnumerable<T>
|
||||
{
|
||||
private readonly List<T> items;
|
||||
|
||||
public event EventHandler<ItemAddedEventArgs<T>> ItemAdded;
|
||||
public event EventHandler<ItemRemovedEventArgs<T>> ItemRemoved;
|
||||
public event EventHandler<ItemChangedEventArgs<T>> ItemChanged;
|
||||
|
||||
public ObservableList()
|
||||
{
|
||||
items = new List<T>();
|
||||
}
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
var index = items.Count;
|
||||
items.Add(item);
|
||||
ItemAdded?.Invoke(this, new ItemAddedEventArgs<T>(item, index));
|
||||
}
|
||||
|
||||
public void AddRange(IEnumerable<T> collection)
|
||||
{
|
||||
var index = items.Count;
|
||||
items.AddRange(collection);
|
||||
|
||||
if (ItemAdded != null)
|
||||
{
|
||||
foreach (var item in collection)
|
||||
ItemAdded.Invoke(this, new ItemAddedEventArgs<T>(item, index++));
|
||||
}
|
||||
}
|
||||
|
||||
public void Insert(int index, T item)
|
||||
{
|
||||
items.Insert(index, item);
|
||||
ItemAdded?.Invoke(this, new ItemAddedEventArgs<T>(item, index));
|
||||
}
|
||||
|
||||
public bool Remove(T item)
|
||||
{
|
||||
var success = items.Remove(item);
|
||||
ItemRemoved?.Invoke(this, new ItemRemovedEventArgs<T>(item, success));
|
||||
return success;
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
var item = items[index];
|
||||
items.RemoveAt(index);
|
||||
ItemRemoved?.Invoke(this, new ItemRemovedEventArgs<T>(item, true));
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
for (int i = items.Count - 1; i >= 0; --i)
|
||||
RemoveAt(i);
|
||||
}
|
||||
|
||||
public int IndexOf(T item)
|
||||
{
|
||||
return items.IndexOf(item);
|
||||
}
|
||||
|
||||
public T this[int index]
|
||||
{
|
||||
get => items[index];
|
||||
set
|
||||
{
|
||||
var old = items[index];
|
||||
items[index] = value;
|
||||
ItemChanged?.Invoke(this, new ItemChangedEventArgs<T>(old, value, index));
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains(T item)
|
||||
{
|
||||
return items.Contains(item);
|
||||
}
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
items.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public int Count => items.Count;
|
||||
|
||||
public bool IsReadOnly => false;
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
return items.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return items.GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemAddedEventArgs<T> : EventArgs
|
||||
{
|
||||
public T Item { get; }
|
||||
public int Index { get; }
|
||||
|
||||
public ItemAddedEventArgs(T item, int index)
|
||||
{
|
||||
Item = item;
|
||||
Index = index;
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemRemovedEventArgs<T> : EventArgs
|
||||
{
|
||||
public T Item { get; }
|
||||
public bool Succeeded { get; }
|
||||
|
||||
public ItemRemovedEventArgs(T item, bool succeeded)
|
||||
{
|
||||
Item = item;
|
||||
Succeeded = succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemChangedEventArgs<T> : EventArgs
|
||||
{
|
||||
public T OldItem { get; }
|
||||
public T NewItem { get; }
|
||||
public int Index { get; }
|
||||
|
||||
public ItemChangedEventArgs(T oldItem, T newItem, int index)
|
||||
{
|
||||
OldItem = oldItem;
|
||||
NewItem = newItem;
|
||||
Index = index;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlateCollectionExtensions
|
||||
{
|
||||
public static void RemoveEmptyPlates(this ObservableList<Plate> plates)
|
||||
{
|
||||
if (plates.Count < 2)
|
||||
return;
|
||||
|
||||
for (int i = plates.Count - 1; i >= 0; --i)
|
||||
{
|
||||
if (plates[i].Parts.Count == 0)
|
||||
plates.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static int TotalCount(this ObservableList<Plate> plates)
|
||||
{
|
||||
return plates.Sum(plate => plate.Quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace OpenNest
|
||||
{
|
||||
public class Nest
|
||||
{
|
||||
public PlateCollection Plates;
|
||||
public ObservableList<Plate> Plates;
|
||||
public DrawingCollection Drawings;
|
||||
|
||||
public Nest()
|
||||
@@ -16,17 +16,17 @@ namespace OpenNest
|
||||
public Nest(string name)
|
||||
{
|
||||
Name = name;
|
||||
Plates = new PlateCollection();
|
||||
Plates.PlateRemoved += Plates_PlateRemoved;
|
||||
Plates = new ObservableList<Plate>();
|
||||
Plates.ItemRemoved += Plates_PlateRemoved;
|
||||
Drawings = new DrawingCollection();
|
||||
PlateDefaults = new PlateSettings();
|
||||
Customer = string.Empty;
|
||||
Notes = string.Empty;
|
||||
}
|
||||
|
||||
private static void Plates_PlateRemoved(object sender, PlateRemovedEventArgs e)
|
||||
private static void Plates_PlateRemoved(object sender, ItemRemovedEventArgs<Plate> e)
|
||||
{
|
||||
e.Plate.Parts.Clear();
|
||||
e.Item.Parts.Clear();
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
@@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenNest</RootNamespace>
|
||||
<AssemblyName>OpenNest.Core</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
@@ -21,6 +21,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -29,6 +30,7 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
@@ -86,9 +88,8 @@
|
||||
<Compile Include="ConvertMode.cs" />
|
||||
<Compile Include="Nest.cs" />
|
||||
<Compile Include="Part.cs" />
|
||||
<Compile Include="Collections\PartCollection.cs" />
|
||||
<Compile Include="Collections\ObservableList.cs" />
|
||||
<Compile Include="Plate.cs" />
|
||||
<Compile Include="Collections\PlateCollection.cs" />
|
||||
<Compile Include="CNC\Program.cs" />
|
||||
<Compile Include="ConvertProgram.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -9,22 +9,22 @@ namespace OpenNest
|
||||
{
|
||||
private int quadrant;
|
||||
|
||||
public event EventHandler<PartAddedEventArgs> PartAdded
|
||||
public event EventHandler<ItemAddedEventArgs<Part>> PartAdded
|
||||
{
|
||||
add { Parts.PartAdded += value; }
|
||||
remove { Parts.PartAdded -= value; }
|
||||
add { Parts.ItemAdded += value; }
|
||||
remove { Parts.ItemAdded -= value; }
|
||||
}
|
||||
|
||||
public event EventHandler<PartRemovedEventArgs> PartRemoved
|
||||
public event EventHandler<ItemRemovedEventArgs<Part>> PartRemoved
|
||||
{
|
||||
add { Parts.PartRemoved += value; }
|
||||
remove { Parts.PartRemoved -= value; }
|
||||
add { Parts.ItemRemoved += value; }
|
||||
remove { Parts.ItemRemoved -= value; }
|
||||
}
|
||||
|
||||
public event EventHandler<PartChangedEventArgs> PartChanged
|
||||
public event EventHandler<ItemChangedEventArgs<Part>> PartChanged
|
||||
{
|
||||
add { Parts.PartChanged += value; }
|
||||
remove { Parts.PartChanged -= value; }
|
||||
add { Parts.ItemChanged += value; }
|
||||
remove { Parts.ItemChanged -= value; }
|
||||
}
|
||||
|
||||
public Plate()
|
||||
@@ -42,20 +42,20 @@ namespace OpenNest
|
||||
EdgeSpacing = new Spacing();
|
||||
Size = size;
|
||||
Material = new Material();
|
||||
Parts = new PartCollection();
|
||||
Parts.PartAdded += Parts_PartAdded;
|
||||
Parts.PartRemoved += Parts_PartRemoved;
|
||||
Parts = new ObservableList<Part>();
|
||||
Parts.ItemAdded += Parts_PartAdded;
|
||||
Parts.ItemRemoved += Parts_PartRemoved;
|
||||
Quadrant = 1;
|
||||
}
|
||||
|
||||
private void Parts_PartAdded(object sender, PartAddedEventArgs e)
|
||||
private void Parts_PartAdded(object sender, ItemAddedEventArgs<Part> e)
|
||||
{
|
||||
e.Part.BaseDrawing.Quantity.Nested += Quantity;
|
||||
e.Item.BaseDrawing.Quantity.Nested += Quantity;
|
||||
}
|
||||
|
||||
private void Parts_PartRemoved(object sender, PartRemovedEventArgs e)
|
||||
private void Parts_PartRemoved(object sender, ItemRemovedEventArgs<Part> e)
|
||||
{
|
||||
e.Part.BaseDrawing.Quantity.Nested -= Quantity;
|
||||
e.Item.BaseDrawing.Quantity.Nested -= Quantity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,7 +86,7 @@ namespace OpenNest
|
||||
/// <summary>
|
||||
/// The parts that the plate contains.
|
||||
/// </summary>
|
||||
public PartCollection Parts { get; set; }
|
||||
public ObservableList<Part> Parts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of times to cut the plate.
|
||||
@@ -9,8 +9,9 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenNest</RootNamespace>
|
||||
<AssemblyName>OpenNest.Engine</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -20,6 +21,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -28,6 +30,7 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user