merge: resolve conflicts from remote nesting progress changes

Kept using OpenNest.Api in Timing.cs and EditNestForm.cs alongside
remote's reorganized usings and namespace changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 09:35:25 -04:00
211 changed files with 4751 additions and 1632 deletions
+10 -9
View File
@@ -1,9 +1,10 @@
using System.Collections.Generic;
using OpenNest.Controls;
using OpenNest.Engine.Fill;
using OpenNest.Geometry;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using OpenNest.Controls;
using OpenNest.Geometry;
namespace OpenNest.Actions
{
@@ -71,7 +72,7 @@ namespace OpenNest.Actions
{
if (plateView.ViewScale != lastScale)
{
parts.ForEach(p =>
parts.ForEach(p =>
{
p.Update(plateView);
p.Draw(e.Graphics);
@@ -146,11 +147,11 @@ namespace OpenNest.Actions
PushDirection hDir, vDir;
switch (plateView.Plate.Quadrant)
{
case 1: hDir = PushDirection.Left; vDir = PushDirection.Down; break;
case 2: hDir = PushDirection.Right; vDir = PushDirection.Down; break;
case 3: hDir = PushDirection.Right; vDir = PushDirection.Up; break;
case 4: hDir = PushDirection.Left; vDir = PushDirection.Up; break;
default: hDir = PushDirection.Left; vDir = PushDirection.Down; break;
case 1: hDir = PushDirection.Left; vDir = PushDirection.Down; break;
case 2: hDir = PushDirection.Right; vDir = PushDirection.Down; break;
case 3: hDir = PushDirection.Right; vDir = PushDirection.Up; break;
case 4: hDir = PushDirection.Left; vDir = PushDirection.Up; break;
default: hDir = PushDirection.Left; vDir = PushDirection.Down; break;
}
// Phase 1: BB-only push to get past irregular geometry quickly.
+1 -1
View File
@@ -1,10 +1,10 @@
using OpenNest.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenNest.Controls;
namespace OpenNest.Actions
{
+3 -3
View File
@@ -1,8 +1,8 @@
using System.ComponentModel;
using OpenNest.Controls;
using OpenNest.Geometry;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using OpenNest.Controls;
using OpenNest.Geometry;
namespace OpenNest.Actions
{
+7 -9
View File
@@ -1,11 +1,9 @@
using System;
using OpenNest.Controls;
using OpenNest.Geometry;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using OpenNest.Controls;
using OpenNest.Geometry;
namespace OpenNest.Actions
{
@@ -94,12 +92,12 @@ namespace OpenNest.Actions
var location = plateView.PointWorldToGraph(SelectedArea.Location);
var size = new SizeF(
plateView.LengthWorldToGui(SelectedArea.Width),
plateView.LengthWorldToGui(SelectedArea.Width),
plateView.LengthWorldToGui(SelectedArea.Length));
var rect = new System.Drawing.RectangleF(location.X, location.Y - size.Height, size.Width, size.Height);
e.Graphics.DrawRectangle(pen,
e.Graphics.DrawRectangle(pen,
rect.X,
rect.Y,
rect.Width,
@@ -109,9 +107,9 @@ namespace OpenNest.Actions
e.Graphics.DrawString(
SelectedArea.Size.ToString(2),
font,
Brushes.Green,
rect,
font,
Brushes.Green,
rect,
stringFormat);
}
+5 -5
View File
@@ -1,12 +1,12 @@
using System.Collections.Generic;
using OpenNest.Controls;
using OpenNest.Converters;
using OpenNest.Forms;
using OpenNest.Geometry;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using OpenNest.Controls;
using OpenNest.Converters;
using OpenNest.Forms;
using OpenNest.Geometry;
namespace OpenNest.Actions
{
+3 -3
View File
@@ -1,8 +1,8 @@
using System.ComponentModel;
using OpenNest.Controls;
using OpenNest.Geometry;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using OpenNest.Controls;
using OpenNest.Geometry;
namespace OpenNest.Actions
{
+12
View File
@@ -59,6 +59,10 @@ namespace OpenNest
public Brush PreviewPartBrush { get; private set; }
public Pen ActivePreviewPartPen { get; private set; }
public Brush ActivePreviewPartBrush { get; private set; }
#endregion Pens/Brushes
#region Colors
@@ -170,8 +174,16 @@ namespace OpenNest
if (PreviewPartBrush != null)
PreviewPartBrush.Dispose();
if (ActivePreviewPartPen != null)
ActivePreviewPartPen.Dispose();
if (ActivePreviewPartBrush != null)
ActivePreviewPartBrush.Dispose();
PreviewPartPen = new Pen(value, 1);
PreviewPartBrush = new SolidBrush(Color.FromArgb(60, value));
ActivePreviewPartPen = new Pen(Color.FromArgb(128, value), 1);
ActivePreviewPartBrush = new SolidBrush(Color.FromArgb(30, value));
}
}
+2 -2
View File
@@ -1,8 +1,8 @@
using OpenNest.Engine.BestFit;
using OpenNest.Math;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using OpenNest.Engine.BestFit;
using OpenNest.Math;
namespace OpenNest.Controls
{
+71
View File
@@ -0,0 +1,71 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace OpenNest.Controls
{
public class DensityBar : Control
{
private static readonly Color TrackColor = Color.FromArgb(224, 224, 224);
private static readonly Color LowColor = Color.FromArgb(245, 166, 35);
private static readonly Color HighColor = Color.FromArgb(76, 175, 80);
private double value;
public DensityBar()
{
DoubleBuffered = true;
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
Size = new Size(60, 8);
}
public double Value
{
get => value;
set
{
this.value = System.Math.Clamp(value, 0.0, 1.0);
Invalidate();
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
var rect = new Rectangle(0, 0, Width - 1, Height - 1);
// Track background
using var trackPath = CreateRoundedRect(rect, 4);
using var trackBrush = new SolidBrush(TrackColor);
g.FillPath(trackBrush, trackPath);
// Fill
var fillWidth = (int)(rect.Width * value);
if (fillWidth > 0)
{
var fillRadius = System.Math.Min(4, fillWidth / 2);
var fillRect = new Rectangle(rect.X, rect.Y, fillWidth, rect.Height);
using var fillPath = CreateRoundedRect(fillRect, fillRadius);
using var gradientBrush = new LinearGradientBrush(
new Point(rect.X, 0), new Point(rect.Right, 0),
LowColor, HighColor);
g.FillPath(gradientBrush, fillPath);
}
}
private static GraphicsPath CreateRoundedRect(Rectangle rect, int radius)
{
var path = new GraphicsPath();
var d = radius * 2;
path.AddArc(rect.X, rect.Y, d, d, 180, 90);
path.AddArc(rect.Right - d, rect.Y, d, d, 270, 90);
path.AddArc(rect.Right - d, rect.Bottom - d, d, d, 0, 90);
path.AddArc(rect.X, rect.Bottom - d, d, d, 90, 90);
path.CloseFigure();
return path;
}
}
}
+2 -2
View File
@@ -1,8 +1,8 @@
using System;
using OpenNest.Geometry;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using OpenNest.Geometry;
namespace OpenNest.Controls
{
+1 -2
View File
@@ -1,5 +1,4 @@
using System;
using System.Drawing;
using System.Drawing;
using System.Windows.Forms;
namespace OpenNest.Controls
+3 -4
View File
@@ -1,10 +1,9 @@
using System;
using OpenNest.Geometry;
using OpenNest.Math;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using OpenNest.Geometry;
using OpenNest.Math;
namespace OpenNest.Controls
{
@@ -137,7 +136,7 @@ namespace OpenNest.Controls
var diameter = radius * 2.0f;
var startAngle = arc.IsReversed
? -(float)Angle.ToDegrees(arc.EndAngle)
? -(float)Angle.ToDegrees(arc.EndAngle)
: -(float)Angle.ToDegrees(arc.StartAngle);
g.DrawArc(
+3 -3
View File
@@ -6,7 +6,7 @@ namespace OpenNest.Controls
{
private string suffix;
public NumericUpDown()
{
@@ -16,8 +16,8 @@ namespace OpenNest.Controls
public string Suffix
{
get { return suffix; }
set
{
set
{
suffix = value;
UpdateEditText();
}
+146
View File
@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace OpenNest.Controls
{
public class PhaseStepperControl : UserControl
{
private static readonly Color AccentColor = Color.FromArgb(0, 120, 212);
private static readonly Color GlowColor = Color.FromArgb(60, 0, 120, 212);
private static readonly Color PendingBorder = Color.FromArgb(192, 192, 192);
private static readonly Color LineColor = Color.FromArgb(208, 208, 208);
private static readonly Color PendingTextColor = Color.FromArgb(153, 153, 153);
private static readonly Color ActiveTextColor = Color.FromArgb(51, 51, 51);
private static readonly Font LabelFont = new Font("Segoe UI", 8f, FontStyle.Regular);
private static readonly Font BoldLabelFont = new Font("Segoe UI", 8f, FontStyle.Bold);
private static readonly NestPhase[] Phases = (NestPhase[])Enum.GetValues(typeof(NestPhase));
private readonly HashSet<NestPhase> visitedPhases = new();
private NestPhase? activePhase;
private bool isComplete;
public PhaseStepperControl()
{
DoubleBuffered = true;
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
Height = 60;
}
public NestPhase? ActivePhase
{
get => activePhase;
set
{
activePhase = value;
if (value.HasValue)
visitedPhases.Add(value.Value);
Invalidate();
}
}
public bool IsComplete
{
get => isComplete;
set
{
isComplete = value;
if (value)
{
foreach (var phase in Phases)
visitedPhases.Add(phase);
activePhase = null;
}
Invalidate();
}
}
private static string GetDisplayName(NestPhase phase)
{
switch (phase)
{
case NestPhase.RectBestFit: return "BestFit";
case NestPhase.Nfp: return "NFP";
default: return phase.ToString();
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
var count = Phases.Length;
if (count == 0) return;
var padding = 30;
var usableWidth = Width - padding * 2;
var spacing = (float)usableWidth / (count - 1);
var circleY = 18;
var normalRadius = 9;
var activeRadius = 11;
using var linePen = new Pen(LineColor, 2f);
using var accentBrush = new SolidBrush(AccentColor);
using var glowBrush = new SolidBrush(GlowColor);
using var pendingPen = new Pen(PendingBorder, 2f);
using var activeTextBrush = new SolidBrush(ActiveTextColor);
using var pendingTextBrush = new SolidBrush(PendingTextColor);
// Draw connecting lines
for (var i = 0; i < count - 1; i++)
{
var x1 = (int)(padding + i * spacing);
var x2 = (int)(padding + (i + 1) * spacing);
g.DrawLine(linePen, x1, circleY, x2, circleY);
}
// Draw circles and labels
for (var i = 0; i < count; i++)
{
var phase = Phases[i];
var cx = (int)(padding + i * spacing);
var isActive = activePhase == phase && !isComplete;
var isVisited = visitedPhases.Contains(phase) || isComplete;
if (isActive)
{
// Glow
g.FillEllipse(glowBrush,
cx - activeRadius - 3, circleY - activeRadius - 3,
(activeRadius + 3) * 2, (activeRadius + 3) * 2);
// Filled circle
g.FillEllipse(accentBrush,
cx - activeRadius, circleY - activeRadius,
activeRadius * 2, activeRadius * 2);
}
else if (isVisited)
{
g.FillEllipse(accentBrush,
cx - normalRadius, circleY - normalRadius,
normalRadius * 2, normalRadius * 2);
}
else
{
g.DrawEllipse(pendingPen,
cx - normalRadius, circleY - normalRadius,
normalRadius * 2, normalRadius * 2);
}
// Label
var label = GetDisplayName(phase);
var font = isVisited || isActive ? BoldLabelFont : LabelFont;
var brush = isVisited || isActive ? activeTextBrush : pendingTextBrush;
var labelSize = g.MeasureString(label, font);
g.DrawString(label, font, brush,
cx - labelSize.Width / 2, circleY + activeRadius + 5);
}
}
}
}
+78 -39
View File
@@ -1,4 +1,11 @@
using System;
using OpenNest.Actions;
using OpenNest.CNC;
using OpenNest.Collections;
using OpenNest.Engine.Fill;
using OpenNest.Forms;
using OpenNest.Geometry;
using OpenNest.Math;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
@@ -9,12 +16,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenNest.Actions;
using OpenNest.CNC;
using OpenNest.Collections;
using OpenNest.Forms;
using OpenNest.Geometry;
using OpenNest.Math;
using Action = OpenNest.Actions.Action;
using Timer = System.Timers.Timer;
@@ -30,7 +31,8 @@ namespace OpenNest.Controls
private Action currentAction;
private Action previousAction;
private List<LayoutPart> parts;
private List<LayoutPart> temporaryParts = new List<LayoutPart>();
private List<LayoutPart> stationaryParts = new List<LayoutPart>();
private List<LayoutPart> activeParts = new List<LayoutPart>();
private Point middleMouseDownPoint;
private Box activeWorkArea;
private List<Box> debugRemnants;
@@ -59,7 +61,7 @@ namespace OpenNest.Controls
public List<LayoutPart> SelectedParts;
public ReadOnlyCollection<LayoutPart> Parts;
public event EventHandler<ItemAddedEventArgs<Part>> PartAdded;
public event EventHandler<ItemRemovedEventArgs<Part>> PartRemoved;
public event EventHandler StatusChanged;
@@ -148,7 +150,8 @@ namespace OpenNest.Controls
plate.PartAdded -= plate_PartAdded;
plate.PartRemoved -= plate_PartRemoved;
parts.Clear();
temporaryParts.Clear();
stationaryParts.Clear();
activeParts.Clear();
SelectedParts.Clear();
}
@@ -381,7 +384,7 @@ namespace OpenNest.Controls
e.Graphics.DrawLine(ColorScheme.OriginPen, origin.X, 0, origin.X, Height);
e.Graphics.DrawLine(ColorScheme.OriginPen, 0, origin.Y, Width, origin.Y);
}
e.Graphics.TranslateTransform(origin.X, origin.Y);
DrawPlate(e.Graphics);
@@ -407,7 +410,8 @@ namespace OpenNest.Controls
public override void Refresh()
{
parts.ForEach(p => p.Update(this));
temporaryParts.ForEach(p => p.Update(this));
stationaryParts.ForEach(p => p.Update(this));
activeParts.ForEach(p => p.Update(this));
Invalidate();
}
@@ -502,24 +506,38 @@ namespace OpenNest.Controls
part.Draw(g, (i + 1).ToString());
}
// Draw temporary (preview) parts
for (var i = 0; i < temporaryParts.Count; i++)
// Draw stationary preview parts (overall best — full opacity)
for (var i = 0; i < stationaryParts.Count; i++)
{
var temp = temporaryParts[i];
var part = stationaryParts[i];
if (temp.IsDirty)
temp.Update(this);
if (part.IsDirty)
part.Update(this);
var path = temp.Path;
var pathBounds = path.GetBounds();
if (!pathBounds.IntersectsWith(viewBounds))
var path = part.Path;
if (!path.GetBounds().IntersectsWith(viewBounds))
continue;
g.FillPath(ColorScheme.PreviewPartBrush, path);
g.DrawPath(ColorScheme.PreviewPartPen, path);
}
// Draw active preview parts (current strategy — reduced opacity)
for (var i = 0; i < activeParts.Count; i++)
{
var part = activeParts[i];
if (part.IsDirty)
part.Update(this);
var path = part.Path;
if (!path.GetBounds().IntersectsWith(viewBounds))
continue;
g.FillPath(ColorScheme.ActivePreviewPartBrush, path);
g.DrawPath(ColorScheme.ActivePreviewPartPen, path);
}
if (DrawOffset && Plate.PartSpacing > 0)
DrawOffsetGeometry(g);
@@ -878,34 +896,49 @@ namespace OpenNest.Controls
Plate.Parts.Add(part);
}
public void SetTemporaryParts(List<Part> parts)
public void SetStationaryParts(List<Part> parts)
{
temporaryParts.Clear();
stationaryParts.Clear();
if (parts != null)
{
foreach (var part in parts)
temporaryParts.Add(LayoutPart.Create(part, this));
stationaryParts.Add(LayoutPart.Create(part, this));
}
Invalidate();
}
public void ClearTemporaryParts()
public void SetActiveParts(List<Part> parts)
{
temporaryParts.Clear();
activeParts.Clear();
if (parts != null)
{
foreach (var part in parts)
activeParts.Add(LayoutPart.Create(part, this));
}
Invalidate();
}
public int AcceptTemporaryParts()
public void ClearPreviewParts()
{
var count = temporaryParts.Count;
stationaryParts.Clear();
activeParts.Clear();
Invalidate();
}
foreach (var layoutPart in temporaryParts)
Plate.Parts.Add(layoutPart.BasePart);
public void AcceptPreviewParts(List<Part> parts)
{
if (parts != null)
{
foreach (var part in parts)
Plate.Parts.Add(part);
}
temporaryParts.Clear();
return count;
stationaryParts.Clear();
activeParts.Clear();
}
public async void FillWithProgress(List<Part> groupParts, Box workArea)
@@ -917,7 +950,12 @@ namespace OpenNest.Controls
var progress = new Progress<NestProgress>(p =>
{
progressForm.UpdateProgress(p);
SetTemporaryParts(p.BestParts);
if (p.IsOverallBest)
SetStationaryParts(p.BestParts);
else
SetActiveParts(p.BestParts);
ActiveWorkArea = p.ActiveWorkArea;
});
@@ -929,22 +967,22 @@ namespace OpenNest.Controls
var parts = await Task.Run(() =>
engine.Fill(groupParts, workArea, progress, cts.Token));
if (parts.Count > 0 && !cts.IsCancellationRequested)
if (parts.Count > 0 && (!cts.IsCancellationRequested || progressForm.Accepted))
{
AcceptTemporaryParts();
AcceptPreviewParts(parts);
sw.Stop();
Status = $"Fill: {parts.Count} parts in {sw.ElapsedMilliseconds} ms";
}
else
{
ClearTemporaryParts();
ClearPreviewParts();
}
progressForm.ShowCompleted();
}
catch (Exception)
{
ClearTemporaryParts();
ClearPreviewParts();
}
finally
{
@@ -1001,7 +1039,7 @@ namespace OpenNest.Controls
{
base.ZoomToPoint(pt, zoomFactor, false);
if (redraw)
if (redraw)
Invalidate();
}
@@ -1081,7 +1119,8 @@ namespace OpenNest.Controls
{
base.UpdateMatrix();
parts.ForEach(p => p.Update(this));
temporaryParts.ForEach(p => p.Update(this));
stationaryParts.ForEach(p => p.Update(this));
activeParts.ForEach(p => p.Update(this));
}
}
}
+2 -5
View File
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using OpenNest.IO;
using System;
using System.IO;
using System.Linq;
using System.Text;
using OpenNest.IO;
namespace OpenNest
{
+2 -2
View File
@@ -1,9 +1,9 @@
using OpenNest.Controls;
using OpenNest.Engine.BestFit;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;
using OpenNest.Controls;
using OpenNest.Engine.BestFit;
namespace OpenNest.Forms
{
+9 -10
View File
@@ -1,17 +1,16 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenNest.CNC;
using OpenNest.CNC;
using OpenNest.Converters;
using OpenNest.Geometry;
using OpenNest.IO;
using OpenNest.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OpenNest.Forms
{
@@ -101,7 +100,7 @@ namespace OpenNest.Forms
if (entities.Count == 0)
continue;
var drawing = new Drawing(item.Name);
drawing.Color = GetNextColor();
drawing.Customer = item.Customer;
+1 -1
View File
@@ -48,7 +48,7 @@ namespace OpenNest.Forms
var suffix = UnitsHelper.GetShortTimeUnitPair(units);
numericUpDown1.Suffix = " " + suffix;
numericUpDown2.Suffix = " " + suffix;
numericUpDown2.Suffix = " " + suffix;
}
public CutParameters GetCutParameters()
+19 -12
View File
@@ -1,4 +1,12 @@
using System;
using OpenNest.Actions;
using OpenNest.CNC.CuttingStrategy;
using OpenNest.Collections;
using OpenNest.Controls;
using OpenNest.Engine.Sequencing;
using OpenNest.IO;
using OpenNest.Math;
using OpenNest.Properties;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
@@ -6,16 +14,6 @@ using System.IO;
using System.Linq;
using System.Windows.Forms;
using OpenNest.Api;
using OpenNest.Actions;
using OpenNest.CNC.CuttingStrategy;
using OpenNest.Collections;
using OpenNest.Controls;
using OpenNest.Engine;
using OpenNest.Engine.RapidPlanning;
using OpenNest.Engine.Sequencing;
using OpenNest.IO;
using OpenNest.Math;
using OpenNest.Properties;
using Timer = System.Timers.Timer;
namespace OpenNest.Forms
@@ -32,6 +30,7 @@ namespace OpenNest.Forms
private Panel plateHeaderPanel;
private Label plateInfoLabel;
private Button btnFirstPlate;
private Button btnRemovePlate;
private Button btnPreviousPlate;
private Button btnNextPlate;
@@ -122,7 +121,7 @@ namespace OpenNest.Forms
navPanel.Controls.AddRange(new Control[] { btnFirstPlate, btnPreviousPlate, btnNextPlate, btnLastPlate });
var btnRemovePlate = CreateNavButton(Resources.remove);
btnRemovePlate = CreateNavButton(Resources.remove);
btnRemovePlate.Dock = DockStyle.Right;
btnRemovePlate.Click += (s, e) => RemoveCurrentPlate();
@@ -178,6 +177,7 @@ namespace OpenNest.Forms
UpdatePlateList();
UpdateDrawingList();
UpdateRemovePlateButton();
LoadFirstPlate();
@@ -731,6 +731,7 @@ namespace OpenNest.Forms
PlateView.Plate = Nest.Plates[CurrentPlateIndex];
UpdatePlateList();
UpdateRemovePlateButton();
PlateView.ZoomToFit();
}
@@ -738,10 +739,16 @@ namespace OpenNest.Forms
{
tabControl1.SelectedIndex = 0;
UpdatePlateList();
UpdateRemovePlateButton();
LoadLastPlate();
PlateView.ZoomToFit();
}
private void UpdateRemovePlateButton()
{
btnRemovePlate.Enabled = Nest.Plates.Count > 1;
}
#endregion
private static ListViewItem GetListViewItem(Plate plate, int id)
+2 -2
View File
@@ -1,6 +1,6 @@
using System;
using OpenNest.Geometry;
using System;
using System.Windows.Forms;
using OpenNest.Geometry;
using Timer = System.Timers.Timer;
namespace OpenNest.Forms
+2 -3
View File
@@ -1,6 +1,5 @@
using System;
using System.Windows.Forms;
using OpenNest.Geometry;
using Timer = System.Timers.Timer;
namespace OpenNest.Forms
@@ -15,7 +14,7 @@ namespace OpenNest.Forms
public EditPlateForm(Plate plate)
{
InitializeComponent();
this.plate = plate;
timer = new Timer
@@ -57,7 +56,7 @@ namespace OpenNest.Forms
else
increment = 1;
var controls = new []
var controls = new[]
{
numericUpDownThickness,
numericUpDownPartSpacing,
+3 -3
View File
@@ -1,8 +1,8 @@
using System.Drawing;
using System.Windows.Forms;
using OpenNest.Collections;
using OpenNest.Collections;
using OpenNest.Controls;
using OpenNest.Geometry;
using System.Drawing;
using System.Windows.Forms;
namespace OpenNest.Forms
{
+37 -21
View File
@@ -1,4 +1,12 @@
using System;
using OpenNest.Actions;
using OpenNest.Collections;
using OpenNest.Engine.BestFit;
using OpenNest.Engine.Fill;
using OpenNest.Geometry;
using OpenNest.Gpu;
using OpenNest.IO;
using OpenNest.Properties;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
@@ -7,13 +15,6 @@ using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenNest.Actions;
using OpenNest.Collections;
using OpenNest.Engine.BestFit;
using OpenNest.Gpu;
using OpenNest.Geometry;
using OpenNest.IO;
using OpenNest.Properties;
namespace OpenNest.Forms
{
@@ -812,7 +813,7 @@ namespace OpenNest.Forms
if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
var items = form.GetNestItems();
if (!items.Any(it => it.Quantity > 0))
@@ -826,7 +827,12 @@ namespace OpenNest.Forms
var progress = new Progress<NestProgress>(p =>
{
progressForm.UpdateProgress(p);
activeForm.PlateView.SetTemporaryParts(p.BestParts);
if (p.IsOverallBest)
activeForm.PlateView.SetStationaryParts(p.BestParts);
else
activeForm.PlateView.SetActiveParts(p.BestParts);
activeForm.PlateView.ActiveWorkArea = p.ActiveWorkArea;
});
@@ -862,9 +868,9 @@ namespace OpenNest.Forms
var nestParts = await Task.Run(() =>
engine.Nest(remaining, progress, token));
activeForm.PlateView.ClearTemporaryParts();
activeForm.PlateView.ClearPreviewParts();
if (nestParts.Count > 0 && !token.IsCancellationRequested)
if (nestParts.Count > 0 && (!token.IsCancellationRequested || progressForm.Accepted))
{
plate.Parts.AddRange(nestParts);
activeForm.PlateView.Invalidate();
@@ -880,7 +886,7 @@ namespace OpenNest.Forms
}
catch (Exception ex)
{
activeForm.PlateView.ClearTemporaryParts();
activeForm.PlateView.ClearPreviewParts();
MessageBox.Show($"Nesting error: {ex.Message}", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
@@ -896,7 +902,7 @@ namespace OpenNest.Forms
private void SequenceAllPlates_Click(object sender, EventArgs e)
{
if (activeForm == null)
if (activeForm == null)
return;
activeForm.AutoSequenceAllPlates();
@@ -963,7 +969,12 @@ namespace OpenNest.Forms
var progress = new Progress<NestProgress>(p =>
{
progressForm.UpdateProgress(p);
activeForm.PlateView.SetTemporaryParts(p.BestParts);
if (p.IsOverallBest)
activeForm.PlateView.SetStationaryParts(p.BestParts);
else
activeForm.PlateView.SetActiveParts(p.BestParts);
activeForm.PlateView.ActiveWorkArea = p.ActiveWorkArea;
});
@@ -980,15 +991,15 @@ namespace OpenNest.Forms
plate.WorkArea(), progress, token));
if (parts.Count > 0)
activeForm.PlateView.AcceptTemporaryParts();
activeForm.PlateView.AcceptPreviewParts(parts);
else
activeForm.PlateView.ClearTemporaryParts();
activeForm.PlateView.ClearPreviewParts();
progressForm.ShowCompleted();
}
catch (Exception ex)
{
activeForm.PlateView.ClearTemporaryParts();
activeForm.PlateView.ClearPreviewParts();
MessageBox.Show($"Nesting error: {ex.Message}", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
@@ -1025,16 +1036,21 @@ namespace OpenNest.Forms
var progress = new Progress<NestProgress>(p =>
{
progressForm.UpdateProgress(p);
activeForm.PlateView.SetTemporaryParts(p.BestParts);
if (p.IsOverallBest)
activeForm.PlateView.SetStationaryParts(p.BestParts);
else
activeForm.PlateView.SetActiveParts(p.BestParts);
activeForm.PlateView.ActiveWorkArea = p.ActiveWorkArea;
});
Action<List<Part>> onComplete = parts =>
{
if (parts != null && parts.Count > 0)
activeForm.PlateView.AcceptTemporaryParts();
activeForm.PlateView.AcceptPreviewParts(parts);
else
activeForm.PlateView.ClearTemporaryParts();
activeForm.PlateView.ClearPreviewParts();
activeForm.PlateView.ActiveWorkArea = null;
progressForm.Close();
+271 -188
View File
@@ -2,15 +2,8 @@ namespace OpenNest.Forms
{
partial class NestProgressForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@@ -22,247 +15,323 @@ namespace OpenNest.Forms
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
table = new System.Windows.Forms.TableLayoutPanel();
phaseLabel = new System.Windows.Forms.Label();
phaseValue = new System.Windows.Forms.Label();
plateLabel = new System.Windows.Forms.Label();
plateValue = new System.Windows.Forms.Label();
phaseStepper = new OpenNest.Controls.PhaseStepperControl();
resultsPanel = new System.Windows.Forms.Panel();
resultsTable = new System.Windows.Forms.TableLayoutPanel();
partsLabel = new System.Windows.Forms.Label();
partsValue = new System.Windows.Forms.Label();
densityLabel = new System.Windows.Forms.Label();
densityPanel = new System.Windows.Forms.FlowLayoutPanel();
densityValue = new System.Windows.Forms.Label();
densityBar = new OpenNest.Controls.DensityBar();
nestedAreaLabel = new System.Windows.Forms.Label();
nestedAreaValue = new System.Windows.Forms.Label();
remnantLabel = new System.Windows.Forms.Label();
remnantValue = new System.Windows.Forms.Label();
resultsHeader = new System.Windows.Forms.Label();
statusPanel = new System.Windows.Forms.Panel();
statusTable = new System.Windows.Forms.TableLayoutPanel();
plateLabel = new System.Windows.Forms.Label();
plateValue = new System.Windows.Forms.Label();
elapsedLabel = new System.Windows.Forms.Label();
elapsedValue = new System.Windows.Forms.Label();
descriptionLabel = new System.Windows.Forms.Label();
descriptionValue = new System.Windows.Forms.Label();
stopButton = new System.Windows.Forms.Button();
statusHeader = new System.Windows.Forms.Label();
buttonPanel = new System.Windows.Forms.FlowLayoutPanel();
table.SuspendLayout();
stopButton = new System.Windows.Forms.Button();
acceptButton = new System.Windows.Forms.Button();
resultsPanel.SuspendLayout();
resultsTable.SuspendLayout();
densityPanel.SuspendLayout();
statusPanel.SuspendLayout();
statusTable.SuspendLayout();
buttonPanel.SuspendLayout();
SuspendLayout();
//
// table
// phaseStepper
//
table.AutoSize = true;
table.ColumnCount = 2;
table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 93F));
table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
table.Controls.Add(phaseLabel, 0, 0);
table.Controls.Add(phaseValue, 1, 0);
table.Controls.Add(plateLabel, 0, 1);
table.Controls.Add(plateValue, 1, 1);
table.Controls.Add(partsLabel, 0, 2);
table.Controls.Add(partsValue, 1, 2);
table.Controls.Add(densityLabel, 0, 3);
table.Controls.Add(densityValue, 1, 3);
table.Controls.Add(nestedAreaLabel, 0, 4);
table.Controls.Add(nestedAreaValue, 1, 4);
table.Controls.Add(remnantLabel, 0, 5);
table.Controls.Add(remnantValue, 1, 5);
table.Controls.Add(elapsedLabel, 0, 6);
table.Controls.Add(elapsedValue, 1, 6);
table.Controls.Add(descriptionLabel, 0, 7);
table.Controls.Add(descriptionValue, 1, 7);
table.Dock = System.Windows.Forms.DockStyle.Top;
table.Location = new System.Drawing.Point(0, 45);
table.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
table.Name = "table";
table.Padding = new System.Windows.Forms.Padding(9, 9, 9, 9);
table.RowCount = 8;
table.RowStyles.Add(new System.Windows.Forms.RowStyle());
table.RowStyles.Add(new System.Windows.Forms.RowStyle());
table.RowStyles.Add(new System.Windows.Forms.RowStyle());
table.RowStyles.Add(new System.Windows.Forms.RowStyle());
table.RowStyles.Add(new System.Windows.Forms.RowStyle());
table.RowStyles.Add(new System.Windows.Forms.RowStyle());
table.RowStyles.Add(new System.Windows.Forms.RowStyle());
table.RowStyles.Add(new System.Windows.Forms.RowStyle());
table.Size = new System.Drawing.Size(425, 218);
table.TabIndex = 0;
phaseStepper.ActivePhase = null;
phaseStepper.Dock = System.Windows.Forms.DockStyle.Top;
phaseStepper.IsComplete = false;
phaseStepper.Location = new System.Drawing.Point(0, 0);
phaseStepper.Name = "phaseStepper";
phaseStepper.Size = new System.Drawing.Size(450, 60);
phaseStepper.TabIndex = 0;
//
// phaseLabel
// resultsPanel
//
phaseLabel.AutoSize = true;
phaseLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
phaseLabel.Location = new System.Drawing.Point(14, 14);
phaseLabel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
phaseLabel.Name = "phaseLabel";
phaseLabel.Size = new System.Drawing.Size(46, 13);
phaseLabel.TabIndex = 0;
phaseLabel.Text = "Phase:";
resultsPanel.BackColor = System.Drawing.Color.White;
resultsPanel.Controls.Add(resultsTable);
resultsPanel.Controls.Add(resultsHeader);
resultsPanel.Dock = System.Windows.Forms.DockStyle.Top;
resultsPanel.Location = new System.Drawing.Point(0, 60);
resultsPanel.Margin = new System.Windows.Forms.Padding(10, 4, 10, 4);
resultsPanel.Name = "resultsPanel";
resultsPanel.Padding = new System.Windows.Forms.Padding(14, 10, 14, 10);
resultsPanel.Size = new System.Drawing.Size(450, 120);
resultsPanel.TabIndex = 1;
//
// phaseValue
// resultsTable
//
phaseValue.AutoSize = true;
phaseValue.Location = new System.Drawing.Point(107, 14);
phaseValue.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
phaseValue.Name = "phaseValue";
phaseValue.Size = new System.Drawing.Size(19, 15);
phaseValue.TabIndex = 1;
phaseValue.Text = "—";
//
// plateLabel
//
plateLabel.AutoSize = true;
plateLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
plateLabel.Location = new System.Drawing.Point(14, 39);
plateLabel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
plateLabel.Name = "plateLabel";
plateLabel.Size = new System.Drawing.Size(40, 13);
plateLabel.TabIndex = 2;
plateLabel.Text = "Plate:";
//
// plateValue
//
plateValue.AutoSize = true;
plateValue.Location = new System.Drawing.Point(107, 39);
plateValue.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
plateValue.Name = "plateValue";
plateValue.Size = new System.Drawing.Size(19, 15);
plateValue.TabIndex = 3;
plateValue.Text = "—";
resultsTable.AutoSize = true;
resultsTable.ColumnCount = 2;
resultsTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 90F));
resultsTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
resultsTable.Controls.Add(partsLabel, 0, 0);
resultsTable.Controls.Add(partsValue, 1, 0);
resultsTable.Controls.Add(densityLabel, 0, 1);
resultsTable.Controls.Add(densityPanel, 1, 1);
resultsTable.Controls.Add(nestedAreaLabel, 0, 2);
resultsTable.Controls.Add(nestedAreaValue, 1, 2);
resultsTable.Dock = System.Windows.Forms.DockStyle.Top;
resultsTable.Location = new System.Drawing.Point(14, 29);
resultsTable.Name = "resultsTable";
resultsTable.RowCount = 3;
resultsTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
resultsTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
resultsTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
resultsTable.Size = new System.Drawing.Size(422, 57);
resultsTable.TabIndex = 1;
//
// partsLabel
//
partsLabel.AutoSize = true;
partsLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
partsLabel.Location = new System.Drawing.Point(14, 64);
partsLabel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
partsLabel.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Bold);
partsLabel.ForeColor = System.Drawing.Color.FromArgb(51, 51, 51);
partsLabel.Location = new System.Drawing.Point(0, 3);
partsLabel.Margin = new System.Windows.Forms.Padding(0, 3, 5, 3);
partsLabel.Name = "partsLabel";
partsLabel.Size = new System.Drawing.Size(40, 13);
partsLabel.TabIndex = 4;
partsLabel.Size = new System.Drawing.Size(36, 13);
partsLabel.TabIndex = 0;
partsLabel.Text = "Parts:";
//
// partsValue
//
partsValue.AutoSize = true;
partsValue.Location = new System.Drawing.Point(107, 64);
partsValue.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
partsValue.Font = new System.Drawing.Font("Consolas", 9.75F);
partsValue.Location = new System.Drawing.Point(80, 3);
partsValue.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
partsValue.Name = "partsValue";
partsValue.Size = new System.Drawing.Size(19, 15);
partsValue.TabIndex = 5;
partsValue.Text = "";
partsValue.Size = new System.Drawing.Size(13, 13);
partsValue.TabIndex = 1;
partsValue.Text = "";
//
// densityLabel
//
densityLabel.AutoSize = true;
densityLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
densityLabel.Location = new System.Drawing.Point(14, 89);
densityLabel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
densityLabel.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Bold);
densityLabel.ForeColor = System.Drawing.Color.FromArgb(51, 51, 51);
densityLabel.Location = new System.Drawing.Point(0, 22);
densityLabel.Margin = new System.Windows.Forms.Padding(0, 3, 5, 3);
densityLabel.Name = "densityLabel";
densityLabel.Size = new System.Drawing.Size(53, 13);
densityLabel.TabIndex = 6;
densityLabel.Size = new System.Drawing.Size(49, 13);
densityLabel.TabIndex = 2;
densityLabel.Text = "Density:";
//
// densityPanel
//
densityPanel.AutoSize = true;
densityPanel.Controls.Add(densityValue);
densityPanel.Controls.Add(densityBar);
densityPanel.Location = new System.Drawing.Point(80, 19);
densityPanel.Margin = new System.Windows.Forms.Padding(0);
densityPanel.Name = "densityPanel";
densityPanel.Size = new System.Drawing.Size(311, 19);
densityPanel.TabIndex = 3;
densityPanel.WrapContents = false;
//
// densityValue
//
densityValue.AutoSize = true;
densityValue.Location = new System.Drawing.Point(107, 89);
densityValue.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
densityValue.Font = new System.Drawing.Font("Consolas", 9.75F);
densityValue.Location = new System.Drawing.Point(0, 3);
densityValue.Margin = new System.Windows.Forms.Padding(0, 3, 8, 3);
densityValue.Name = "densityValue";
densityValue.Size = new System.Drawing.Size(19, 15);
densityValue.TabIndex = 7;
densityValue.Text = "";
densityValue.Size = new System.Drawing.Size(13, 13);
densityValue.TabIndex = 0;
densityValue.Text = "";
//
// densityBar
//
densityBar.Location = new System.Drawing.Point(21, 5);
densityBar.Margin = new System.Windows.Forms.Padding(0, 5, 0, 0);
densityBar.Name = "densityBar";
densityBar.Size = new System.Drawing.Size(290, 8);
densityBar.TabIndex = 1;
densityBar.Value = 0D;
//
// nestedAreaLabel
//
nestedAreaLabel.AutoSize = true;
nestedAreaLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
nestedAreaLabel.Location = new System.Drawing.Point(14, 114);
nestedAreaLabel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
nestedAreaLabel.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Bold);
nestedAreaLabel.ForeColor = System.Drawing.Color.FromArgb(51, 51, 51);
nestedAreaLabel.Location = new System.Drawing.Point(0, 41);
nestedAreaLabel.Margin = new System.Windows.Forms.Padding(0, 3, 5, 3);
nestedAreaLabel.Name = "nestedAreaLabel";
nestedAreaLabel.Size = new System.Drawing.Size(51, 13);
nestedAreaLabel.TabIndex = 8;
nestedAreaLabel.Size = new System.Drawing.Size(47, 13);
nestedAreaLabel.TabIndex = 4;
nestedAreaLabel.Text = "Nested:";
//
// nestedAreaValue
//
nestedAreaValue.AutoSize = true;
nestedAreaValue.Location = new System.Drawing.Point(107, 114);
nestedAreaValue.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
nestedAreaValue.Font = new System.Drawing.Font("Consolas", 9.75F);
nestedAreaValue.Location = new System.Drawing.Point(80, 41);
nestedAreaValue.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
nestedAreaValue.Name = "nestedAreaValue";
nestedAreaValue.Size = new System.Drawing.Size(19, 15);
nestedAreaValue.TabIndex = 9;
nestedAreaValue.Text = "";
nestedAreaValue.Size = new System.Drawing.Size(13, 13);
nestedAreaValue.TabIndex = 5;
nestedAreaValue.Text = "";
//
// remnantLabel
// resultsHeader
//
remnantLabel.AutoSize = true;
remnantLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
remnantLabel.Location = new System.Drawing.Point(14, 139);
remnantLabel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
remnantLabel.Name = "remnantLabel";
remnantLabel.Size = new System.Drawing.Size(54, 13);
remnantLabel.TabIndex = 10;
remnantLabel.Text = "Unused:";
resultsHeader.AutoSize = true;
resultsHeader.Dock = System.Windows.Forms.DockStyle.Top;
resultsHeader.Font = new System.Drawing.Font("Segoe UI", 10.5F, System.Drawing.FontStyle.Bold);
resultsHeader.ForeColor = System.Drawing.Color.FromArgb(85, 85, 85);
resultsHeader.Location = new System.Drawing.Point(14, 10);
resultsHeader.Name = "resultsHeader";
resultsHeader.Padding = new System.Windows.Forms.Padding(0, 0, 0, 4);
resultsHeader.Size = new System.Drawing.Size(56, 19);
resultsHeader.TabIndex = 0;
resultsHeader.Text = "RESULTS";
//
// remnantValue
// statusPanel
//
remnantValue.AutoSize = true;
remnantValue.Location = new System.Drawing.Point(107, 139);
remnantValue.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
remnantValue.Name = "remnantValue";
remnantValue.Size = new System.Drawing.Size(19, 15);
remnantValue.TabIndex = 11;
remnantValue.Text = "—";
statusPanel.BackColor = System.Drawing.Color.White;
statusPanel.Controls.Add(statusTable);
statusPanel.Controls.Add(statusHeader);
statusPanel.Dock = System.Windows.Forms.DockStyle.Top;
statusPanel.Location = new System.Drawing.Point(0, 165);
statusPanel.Name = "statusPanel";
statusPanel.Padding = new System.Windows.Forms.Padding(14, 10, 14, 10);
statusPanel.Size = new System.Drawing.Size(450, 115);
statusPanel.TabIndex = 2;
//
// statusTable
//
statusTable.AutoSize = true;
statusTable.ColumnCount = 2;
statusTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 90F));
statusTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
statusTable.Controls.Add(plateLabel, 0, 0);
statusTable.Controls.Add(plateValue, 1, 0);
statusTable.Controls.Add(elapsedLabel, 0, 1);
statusTable.Controls.Add(elapsedValue, 1, 1);
statusTable.Controls.Add(descriptionLabel, 0, 2);
statusTable.Controls.Add(descriptionValue, 1, 2);
statusTable.Dock = System.Windows.Forms.DockStyle.Top;
statusTable.Location = new System.Drawing.Point(14, 29);
statusTable.Name = "statusTable";
statusTable.RowCount = 3;
statusTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
statusTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
statusTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
statusTable.Size = new System.Drawing.Size(422, 57);
statusTable.TabIndex = 1;
//
// plateLabel
//
plateLabel.AutoSize = true;
plateLabel.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Bold);
plateLabel.ForeColor = System.Drawing.Color.FromArgb(51, 51, 51);
plateLabel.Location = new System.Drawing.Point(0, 3);
plateLabel.Margin = new System.Windows.Forms.Padding(0, 3, 5, 3);
plateLabel.Name = "plateLabel";
plateLabel.Size = new System.Drawing.Size(36, 13);
plateLabel.TabIndex = 0;
plateLabel.Text = "Plate:";
//
// plateValue
//
plateValue.AutoSize = true;
plateValue.Font = new System.Drawing.Font("Consolas", 9.75F);
plateValue.Location = new System.Drawing.Point(80, 3);
plateValue.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
plateValue.Name = "plateValue";
plateValue.Size = new System.Drawing.Size(13, 13);
plateValue.TabIndex = 1;
plateValue.Text = "";
//
// elapsedLabel
//
elapsedLabel.AutoSize = true;
elapsedLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
elapsedLabel.Location = new System.Drawing.Point(14, 164);
elapsedLabel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
elapsedLabel.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Bold);
elapsedLabel.ForeColor = System.Drawing.Color.FromArgb(51, 51, 51);
elapsedLabel.Location = new System.Drawing.Point(0, 22);
elapsedLabel.Margin = new System.Windows.Forms.Padding(0, 3, 5, 3);
elapsedLabel.Name = "elapsedLabel";
elapsedLabel.Size = new System.Drawing.Size(56, 13);
elapsedLabel.TabIndex = 12;
elapsedLabel.Size = new System.Drawing.Size(50, 13);
elapsedLabel.TabIndex = 2;
elapsedLabel.Text = "Elapsed:";
//
// elapsedValue
//
elapsedValue.AutoSize = true;
elapsedValue.Location = new System.Drawing.Point(107, 164);
elapsedValue.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
elapsedValue.Font = new System.Drawing.Font("Consolas", 9.75F);
elapsedValue.Location = new System.Drawing.Point(80, 22);
elapsedValue.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
elapsedValue.Name = "elapsedValue";
elapsedValue.Size = new System.Drawing.Size(28, 15);
elapsedValue.TabIndex = 13;
elapsedValue.Size = new System.Drawing.Size(31, 13);
elapsedValue.TabIndex = 3;
elapsedValue.Text = "0:00";
//
// descriptionLabel
//
descriptionLabel.AutoSize = true;
descriptionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
descriptionLabel.Location = new System.Drawing.Point(14, 189);
descriptionLabel.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
descriptionLabel.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Bold);
descriptionLabel.ForeColor = System.Drawing.Color.FromArgb(51, 51, 51);
descriptionLabel.Location = new System.Drawing.Point(0, 41);
descriptionLabel.Margin = new System.Windows.Forms.Padding(0, 3, 5, 3);
descriptionLabel.Name = "descriptionLabel";
descriptionLabel.Size = new System.Drawing.Size(44, 13);
descriptionLabel.TabIndex = 14;
descriptionLabel.Size = new System.Drawing.Size(40, 13);
descriptionLabel.TabIndex = 4;
descriptionLabel.Text = "Detail:";
//
// descriptionValue
//
descriptionValue.AutoSize = true;
descriptionValue.Location = new System.Drawing.Point(107, 189);
descriptionValue.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5);
descriptionValue.Font = new System.Drawing.Font("Segoe UI", 9.75F);
descriptionValue.Location = new System.Drawing.Point(80, 41);
descriptionValue.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
descriptionValue.Name = "descriptionValue";
descriptionValue.Size = new System.Drawing.Size(19, 15);
descriptionValue.TabIndex = 15;
descriptionValue.Text = "";
descriptionValue.Size = new System.Drawing.Size(18, 13);
descriptionValue.TabIndex = 5;
descriptionValue.Text = "";
//
// statusHeader
//
statusHeader.AutoSize = true;
statusHeader.Dock = System.Windows.Forms.DockStyle.Top;
statusHeader.Font = new System.Drawing.Font("Segoe UI", 10.5F, System.Drawing.FontStyle.Bold);
statusHeader.ForeColor = System.Drawing.Color.FromArgb(85, 85, 85);
statusHeader.Location = new System.Drawing.Point(14, 10);
statusHeader.Name = "statusHeader";
statusHeader.Padding = new System.Windows.Forms.Padding(0, 0, 0, 4);
statusHeader.Size = new System.Drawing.Size(50, 19);
statusHeader.TabIndex = 0;
statusHeader.Text = "STATUS";
//
// buttonPanel
//
buttonPanel.AutoSize = true;
buttonPanel.Controls.Add(stopButton);
buttonPanel.Controls.Add(acceptButton);
buttonPanel.Dock = System.Windows.Forms.DockStyle.Top;
buttonPanel.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
buttonPanel.Location = new System.Drawing.Point(0, 265);
buttonPanel.Name = "buttonPanel";
buttonPanel.Padding = new System.Windows.Forms.Padding(9, 6, 9, 6);
buttonPanel.Size = new System.Drawing.Size(450, 45);
buttonPanel.TabIndex = 3;
//
// stopButton
//
stopButton.Anchor = System.Windows.Forms.AnchorStyles.None;
stopButton.Location = new System.Drawing.Point(314, 9);
stopButton.Margin = new System.Windows.Forms.Padding(0, 9, 0, 9);
stopButton.Enabled = false;
stopButton.Font = new System.Drawing.Font("Segoe UI", 9.75F);
stopButton.Location = new System.Drawing.Point(339, 9);
stopButton.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
stopButton.Name = "stopButton";
stopButton.Size = new System.Drawing.Size(93, 27);
stopButton.TabIndex = 0;
@@ -270,36 +339,45 @@ namespace OpenNest.Forms
stopButton.UseVisualStyleBackColor = true;
stopButton.Click += StopButton_Click;
//
// buttonPanel
// acceptButton
//
buttonPanel.AutoSize = true;
buttonPanel.Controls.Add(stopButton);
buttonPanel.Dock = System.Windows.Forms.DockStyle.Top;
buttonPanel.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
buttonPanel.Location = new System.Drawing.Point(0, 0);
buttonPanel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
buttonPanel.Name = "buttonPanel";
buttonPanel.Padding = new System.Windows.Forms.Padding(9, 0, 9, 0);
buttonPanel.Size = new System.Drawing.Size(425, 45);
buttonPanel.TabIndex = 1;
acceptButton.Enabled = false;
acceptButton.Font = new System.Drawing.Font("Segoe UI", 9.75F);
acceptButton.Location = new System.Drawing.Point(246, 9);
acceptButton.Margin = new System.Windows.Forms.Padding(6, 3, 0, 3);
acceptButton.Name = "acceptButton";
acceptButton.Size = new System.Drawing.Size(93, 27);
acceptButton.TabIndex = 1;
acceptButton.Text = "Accept";
acceptButton.UseVisualStyleBackColor = true;
acceptButton.Click += AcceptButton_Click;
//
// NestProgressForm
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new System.Drawing.Size(425, 266);
Controls.Add(table);
ClientSize = new System.Drawing.Size(450, 345);
Controls.Add(buttonPanel);
Controls.Add(statusPanel);
Controls.Add(resultsPanel);
Controls.Add(phaseStepper);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
MaximizeBox = false;
MinimizeBox = false;
Name = "NestProgressForm";
ShowInTaskbar = false;
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
Text = "Nesting Progress";
table.ResumeLayout(false);
table.PerformLayout();
resultsPanel.ResumeLayout(false);
resultsPanel.PerformLayout();
resultsTable.ResumeLayout(false);
resultsTable.PerformLayout();
densityPanel.ResumeLayout(false);
densityPanel.PerformLayout();
statusPanel.ResumeLayout(false);
statusPanel.PerformLayout();
statusTable.ResumeLayout(false);
statusTable.PerformLayout();
buttonPanel.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
@@ -307,24 +385,29 @@ namespace OpenNest.Forms
#endregion
private System.Windows.Forms.TableLayoutPanel table;
private System.Windows.Forms.Label phaseLabel;
private System.Windows.Forms.Label phaseValue;
private System.Windows.Forms.Label plateLabel;
private System.Windows.Forms.Label plateValue;
private Controls.PhaseStepperControl phaseStepper;
private System.Windows.Forms.Panel resultsPanel;
private System.Windows.Forms.Label resultsHeader;
private System.Windows.Forms.TableLayoutPanel resultsTable;
private System.Windows.Forms.Label partsLabel;
private System.Windows.Forms.Label partsValue;
private System.Windows.Forms.Label densityLabel;
private System.Windows.Forms.FlowLayoutPanel densityPanel;
private System.Windows.Forms.Label densityValue;
private Controls.DensityBar densityBar;
private System.Windows.Forms.Label nestedAreaLabel;
private System.Windows.Forms.Label nestedAreaValue;
private System.Windows.Forms.Label remnantLabel;
private System.Windows.Forms.Label remnantValue;
private System.Windows.Forms.Panel statusPanel;
private System.Windows.Forms.Label statusHeader;
private System.Windows.Forms.TableLayoutPanel statusTable;
private System.Windows.Forms.Label plateLabel;
private System.Windows.Forms.Label plateValue;
private System.Windows.Forms.Label elapsedLabel;
private System.Windows.Forms.Label elapsedValue;
private System.Windows.Forms.Label descriptionLabel;
private System.Windows.Forms.Label descriptionValue;
private System.Windows.Forms.Button stopButton;
private System.Windows.Forms.FlowLayoutPanel buttonPanel;
private System.Windows.Forms.Button acceptButton;
private System.Windows.Forms.Button stopButton;
}
}
+119 -9
View File
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
@@ -7,9 +10,22 @@ namespace OpenNest.Forms
{
public partial class NestProgressForm : Form
{
private static readonly Color DefaultFlashColor = Color.FromArgb(0, 160, 0);
private static readonly Color DensityLowColor = Color.FromArgb(200, 40, 40);
private static readonly Color DensityMidColor = Color.FromArgb(200, 160, 0);
private static readonly Color DensityHighColor = Color.FromArgb(0, 160, 0);
private const int FadeSteps = 20;
private const int FadeIntervalMs = 50;
private readonly CancellationTokenSource cts;
private readonly Stopwatch stopwatch = Stopwatch.StartNew();
private readonly System.Windows.Forms.Timer elapsedTimer;
private readonly System.Windows.Forms.Timer fadeTimer;
private readonly Dictionary<Label, (int remaining, Color flashColor)> fadeCounters = new();
private bool hasReceivedProgress;
public bool Accepted { get; private set; }
public NestProgressForm(CancellationTokenSource cts, bool showPlateRow = true)
{
@@ -25,6 +41,9 @@ namespace OpenNest.Forms
elapsedTimer = new System.Windows.Forms.Timer { Interval = 1000 };
elapsedTimer.Tick += (s, e) => UpdateElapsed();
elapsedTimer.Start();
fadeTimer = new System.Windows.Forms.Timer { Interval = FadeIntervalMs };
fadeTimer.Tick += FadeTimer_Tick;
}
public void UpdateProgress(NestProgress progress)
@@ -32,14 +51,29 @@ namespace OpenNest.Forms
if (IsDisposed || !IsHandleCreated)
return;
phaseValue.Text = FormatPhase(progress.Phase);
plateValue.Text = progress.PlateNumber.ToString();
partsValue.Text = progress.BestPartCount.ToString();
densityValue.Text = progress.BestDensity.ToString("P1");
nestedAreaValue.Text = $"{progress.NestedWidth:F1} x {progress.NestedLength:F1} ({progress.NestedArea:F1} sq in)";
if (!hasReceivedProgress)
{
hasReceivedProgress = true;
acceptButton.Enabled = true;
stopButton.Enabled = true;
}
if (!string.IsNullOrEmpty(progress.Description))
descriptionValue.Text = progress.Description;
phaseStepper.ActivePhase = progress.Phase;
SetValueWithFlash(plateValue, progress.PlateNumber.ToString());
SetValueWithFlash(partsValue, progress.BestPartCount.ToString());
var densityText = progress.BestDensity.ToString("P1");
var densityFlashColor = GetDensityColor(progress.BestDensity);
SetValueWithFlash(densityValue, densityText, densityFlashColor);
densityBar.Value = progress.BestDensity;
SetValueWithFlash(nestedAreaValue,
$"{progress.NestedWidth:F1} x {progress.NestedLength:F1} ({progress.NestedArea:F1} sq in)");
descriptionValue.Text = !string.IsNullOrEmpty(progress.Description)
? progress.Description
: FormatPhase(progress.Phase);
}
public void ShowCompleted()
@@ -51,8 +85,10 @@ namespace OpenNest.Forms
elapsedTimer.Stop();
UpdateElapsed();
phaseValue.Text = "Done";
phaseStepper.IsComplete = true;
descriptionValue.Text = "\u2014";
acceptButton.Visible = false;
stopButton.Text = "Close";
stopButton.Enabled = true;
stopButton.Click -= StopButton_Click;
@@ -70,15 +106,28 @@ namespace OpenNest.Forms
: elapsed.ToString(@"m\:ss");
}
private void AcceptButton_Click(object sender, EventArgs e)
{
Accepted = true;
cts.Cancel();
acceptButton.Enabled = false;
stopButton.Enabled = false;
acceptButton.Text = "Accepted";
stopButton.Text = "Stopping...";
}
private void StopButton_Click(object sender, EventArgs e)
{
cts.Cancel();
stopButton.Text = "Stopping...";
acceptButton.Enabled = false;
stopButton.Enabled = false;
stopButton.Text = "Stopping...";
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
fadeTimer.Stop();
fadeTimer.Dispose();
elapsedTimer.Stop();
elapsedTimer.Dispose();
stopwatch.Stop();
@@ -89,6 +138,65 @@ namespace OpenNest.Forms
base.OnFormClosing(e);
}
private void SetValueWithFlash(Label label, string text, Color? flashColor = null)
{
if (label.Text == text)
return;
var color = flashColor ?? DefaultFlashColor;
label.Text = text;
label.ForeColor = color;
fadeCounters[label] = (FadeSteps, color);
if (!fadeTimer.Enabled)
fadeTimer.Start();
}
private void FadeTimer_Tick(object sender, EventArgs e)
{
if (IsDisposed || !IsHandleCreated)
{
fadeTimer.Stop();
return;
}
var defaultColor = SystemColors.ControlText;
var labels = fadeCounters.Keys.ToList();
foreach (var label in labels)
{
var (remaining, flashColor) = fadeCounters[label];
remaining--;
if (remaining <= 0)
{
label.ForeColor = defaultColor;
fadeCounters.Remove(label);
}
else
{
var ratio = (float)remaining / FadeSteps;
var r = (int)(defaultColor.R + (flashColor.R - defaultColor.R) * ratio);
var g = (int)(defaultColor.G + (flashColor.G - defaultColor.G) * ratio);
var b = (int)(defaultColor.B + (flashColor.B - defaultColor.B) * ratio);
label.ForeColor = Color.FromArgb(r, g, b);
fadeCounters[label] = (remaining, flashColor);
}
}
if (fadeCounters.Count == 0)
fadeTimer.Stop();
}
private static Color GetDensityColor(double density)
{
if (density < 0.5)
return DensityLowColor;
if (density < 0.7)
return DensityMidColor;
return DensityHighColor;
}
private static string FormatPhase(NestPhase phase)
{
switch (phase)
@@ -96,6 +204,8 @@ namespace OpenNest.Forms
case NestPhase.Linear: return "Trying rotations...";
case NestPhase.RectBestFit: return "Trying best fit...";
case NestPhase.Pairs: return "Trying pairs...";
case NestPhase.Extents: return "Trying extents...";
case NestPhase.Nfp: return "Trying NFP...";
default: return phase.ToString();
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
using System.Windows.Forms;
using OpenNest.Properties;
using OpenNest.Properties;
using System.Windows.Forms;
namespace OpenNest.Forms
{
+355 -121
View File
@@ -13,140 +13,368 @@ namespace OpenNest.Forms
private void InitializeComponent()
{
this.topPanel = new System.Windows.Forms.FlowLayoutPanel();
this.lblDrawingA = new System.Windows.Forms.Label();
this.cboDrawingA = new System.Windows.Forms.ComboBox();
this.lblDrawingB = new System.Windows.Forms.Label();
this.cboDrawingB = new System.Windows.Forms.ComboBox();
this.lblPlateSize = new System.Windows.Forms.Label();
this.txtPlateSize = new System.Windows.Forms.TextBox();
this.lblPartSpacing = new System.Windows.Forms.Label();
this.nudPartSpacing = new System.Windows.Forms.NumericUpDown();
this.btnAutoArrange = new System.Windows.Forms.Button();
this.btnApply = new System.Windows.Forms.Button();
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.topPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudPartSpacing)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
this.splitContainer.SuspendLayout();
this.SuspendLayout();
//
ColorScheme colorScheme1 = new ColorScheme();
Plate plate1 = new Plate();
Material material1 = new Material();
Collections.ObservableList<Part> observableList_11 = new Collections.ObservableList<Part>();
Plate plate2 = new Plate();
Material material2 = new Material();
Collections.ObservableList<Part> observableList_12 = new Collections.ObservableList<Part>();
Plate plate3 = new Plate();
Material material3 = new Material();
Collections.ObservableList<Part> observableList_13 = new Collections.ObservableList<Part>();
topPanel = new System.Windows.Forms.FlowLayoutPanel();
lblDrawingA = new System.Windows.Forms.Label();
cboDrawingA = new System.Windows.Forms.ComboBox();
lblDrawingB = new System.Windows.Forms.Label();
cboDrawingB = new System.Windows.Forms.ComboBox();
lblPlateSize = new System.Windows.Forms.Label();
txtPlateSize = new System.Windows.Forms.TextBox();
lblPartSpacing = new System.Windows.Forms.Label();
nudPartSpacing = new System.Windows.Forms.NumericUpDown();
btnAutoArrange = new System.Windows.Forms.Button();
btnApply = new System.Windows.Forms.Button();
splitContainer = new System.Windows.Forms.SplitContainer();
cellView = new OpenNest.Controls.PlateView();
splitContainer1 = new System.Windows.Forms.SplitContainer();
hPreview = new OpenNest.Controls.PlateView();
hLabel = new System.Windows.Forms.Label();
vPreview = new OpenNest.Controls.PlateView();
vLabel = new System.Windows.Forms.Label();
topPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)nudPartSpacing).BeginInit();
((System.ComponentModel.ISupportInitialize)splitContainer).BeginInit();
splitContainer.Panel1.SuspendLayout();
splitContainer.Panel2.SuspendLayout();
splitContainer.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
SuspendLayout();
//
// topPanel
//
this.topPanel.Controls.Add(this.lblDrawingA);
this.topPanel.Controls.Add(this.cboDrawingA);
this.topPanel.Controls.Add(this.lblDrawingB);
this.topPanel.Controls.Add(this.cboDrawingB);
this.topPanel.Controls.Add(this.lblPlateSize);
this.topPanel.Controls.Add(this.txtPlateSize);
this.topPanel.Controls.Add(this.lblPartSpacing);
this.topPanel.Controls.Add(this.nudPartSpacing);
this.topPanel.Controls.Add(this.btnAutoArrange);
this.topPanel.Controls.Add(this.btnApply);
this.topPanel.Dock = System.Windows.Forms.DockStyle.Top;
this.topPanel.Height = 36;
this.topPanel.Name = "topPanel";
this.topPanel.WrapContents = false;
this.topPanel.Padding = new System.Windows.Forms.Padding(4, 2, 4, 2);
//
//
topPanel.Controls.Add(lblDrawingA);
topPanel.Controls.Add(cboDrawingA);
topPanel.Controls.Add(lblDrawingB);
topPanel.Controls.Add(cboDrawingB);
topPanel.Controls.Add(lblPlateSize);
topPanel.Controls.Add(txtPlateSize);
topPanel.Controls.Add(lblPartSpacing);
topPanel.Controls.Add(nudPartSpacing);
topPanel.Controls.Add(btnAutoArrange);
topPanel.Controls.Add(btnApply);
topPanel.Dock = System.Windows.Forms.DockStyle.Top;
topPanel.Location = new System.Drawing.Point(0, 0);
topPanel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
topPanel.Name = "topPanel";
topPanel.Padding = new System.Windows.Forms.Padding(5, 2, 5, 2);
topPanel.Size = new System.Drawing.Size(1220, 42);
topPanel.TabIndex = 2;
topPanel.WrapContents = false;
//
// lblDrawingA
//
this.lblDrawingA.AutoSize = true;
this.lblDrawingA.Margin = new System.Windows.Forms.Padding(3, 5, 0, 0);
this.lblDrawingA.Name = "lblDrawingA";
this.lblDrawingA.Text = "Drawing A:";
//
//
lblDrawingA.AutoSize = true;
lblDrawingA.Location = new System.Drawing.Point(9, 8);
lblDrawingA.Margin = new System.Windows.Forms.Padding(4, 6, 0, 0);
lblDrawingA.Name = "lblDrawingA";
lblDrawingA.Size = new System.Drawing.Size(65, 15);
lblDrawingA.TabIndex = 0;
lblDrawingA.Text = "Drawing A:";
//
// cboDrawingA
//
this.cboDrawingA.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboDrawingA.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0);
this.cboDrawingA.Name = "cboDrawingA";
this.cboDrawingA.Width = 130;
//
//
cboDrawingA.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
cboDrawingA.Location = new System.Drawing.Point(78, 5);
cboDrawingA.Margin = new System.Windows.Forms.Padding(4, 3, 0, 0);
cboDrawingA.Name = "cboDrawingA";
cboDrawingA.Size = new System.Drawing.Size(151, 23);
cboDrawingA.TabIndex = 1;
//
// lblDrawingB
//
this.lblDrawingB.AutoSize = true;
this.lblDrawingB.Margin = new System.Windows.Forms.Padding(10, 5, 0, 0);
this.lblDrawingB.Name = "lblDrawingB";
this.lblDrawingB.Text = "Drawing B:";
//
//
lblDrawingB.AutoSize = true;
lblDrawingB.Location = new System.Drawing.Point(241, 8);
lblDrawingB.Margin = new System.Windows.Forms.Padding(12, 6, 0, 0);
lblDrawingB.Name = "lblDrawingB";
lblDrawingB.Size = new System.Drawing.Size(64, 15);
lblDrawingB.TabIndex = 2;
lblDrawingB.Text = "Drawing B:";
//
// cboDrawingB
//
this.cboDrawingB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboDrawingB.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0);
this.cboDrawingB.Name = "cboDrawingB";
this.cboDrawingB.Width = 130;
//
//
cboDrawingB.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
cboDrawingB.Location = new System.Drawing.Point(309, 5);
cboDrawingB.Margin = new System.Windows.Forms.Padding(4, 3, 0, 0);
cboDrawingB.Name = "cboDrawingB";
cboDrawingB.Size = new System.Drawing.Size(151, 23);
cboDrawingB.TabIndex = 3;
//
// lblPlateSize
//
this.lblPlateSize.AutoSize = true;
this.lblPlateSize.Margin = new System.Windows.Forms.Padding(10, 5, 0, 0);
this.lblPlateSize.Name = "lblPlateSize";
this.lblPlateSize.Text = "Plate:";
//
//
lblPlateSize.AutoSize = true;
lblPlateSize.Location = new System.Drawing.Point(472, 8);
lblPlateSize.Margin = new System.Windows.Forms.Padding(12, 6, 0, 0);
lblPlateSize.Name = "lblPlateSize";
lblPlateSize.Size = new System.Drawing.Size(36, 15);
lblPlateSize.TabIndex = 4;
lblPlateSize.Text = "Plate:";
//
// txtPlateSize
//
this.txtPlateSize.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0);
this.txtPlateSize.Name = "txtPlateSize";
this.txtPlateSize.Width = 90;
//
//
txtPlateSize.Location = new System.Drawing.Point(512, 5);
txtPlateSize.Margin = new System.Windows.Forms.Padding(4, 3, 0, 0);
txtPlateSize.Name = "txtPlateSize";
txtPlateSize.Size = new System.Drawing.Size(104, 23);
txtPlateSize.TabIndex = 5;
//
// lblPartSpacing
//
this.lblPartSpacing.AutoSize = true;
this.lblPartSpacing.Margin = new System.Windows.Forms.Padding(10, 5, 0, 0);
this.lblPartSpacing.Name = "lblPartSpacing";
this.lblPartSpacing.Text = "Spacing:";
//
//
lblPartSpacing.AutoSize = true;
lblPartSpacing.Location = new System.Drawing.Point(628, 8);
lblPartSpacing.Margin = new System.Windows.Forms.Padding(12, 6, 0, 0);
lblPartSpacing.Name = "lblPartSpacing";
lblPartSpacing.Size = new System.Drawing.Size(52, 15);
lblPartSpacing.TabIndex = 6;
lblPartSpacing.Text = "Spacing:";
//
// nudPartSpacing
//
this.nudPartSpacing.DecimalPlaces = 2;
this.nudPartSpacing.Increment = new decimal(new int[] { 25, 0, 0, 131072 });
this.nudPartSpacing.Maximum = new decimal(new int[] { 100, 0, 0, 0 });
this.nudPartSpacing.Minimum = new decimal(new int[] { 0, 0, 0, 0 });
this.nudPartSpacing.Margin = new System.Windows.Forms.Padding(3, 3, 0, 0);
this.nudPartSpacing.Name = "nudPartSpacing";
this.nudPartSpacing.Width = 70;
//
//
nudPartSpacing.DecimalPlaces = 2;
nudPartSpacing.Increment = new decimal(new int[] { 25, 0, 0, 131072 });
nudPartSpacing.Location = new System.Drawing.Point(684, 5);
nudPartSpacing.Margin = new System.Windows.Forms.Padding(4, 3, 0, 0);
nudPartSpacing.Name = "nudPartSpacing";
nudPartSpacing.Size = new System.Drawing.Size(82, 23);
nudPartSpacing.TabIndex = 7;
//
// btnAutoArrange
//
this.btnAutoArrange.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAutoArrange.Margin = new System.Windows.Forms.Padding(10, 3, 0, 0);
this.btnAutoArrange.Name = "btnAutoArrange";
this.btnAutoArrange.Size = new System.Drawing.Size(100, 26);
this.btnAutoArrange.Text = "Auto Arrange";
//
//
btnAutoArrange.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
btnAutoArrange.Location = new System.Drawing.Point(778, 5);
btnAutoArrange.Margin = new System.Windows.Forms.Padding(12, 3, 0, 0);
btnAutoArrange.Name = "btnAutoArrange";
btnAutoArrange.Size = new System.Drawing.Size(117, 30);
btnAutoArrange.TabIndex = 8;
btnAutoArrange.Text = "Auto Arrange";
//
// btnApply
//
this.btnApply.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnApply.Margin = new System.Windows.Forms.Padding(6, 3, 0, 0);
this.btnApply.Name = "btnApply";
this.btnApply.Size = new System.Drawing.Size(80, 26);
this.btnApply.Text = "Apply";
//
//
btnApply.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
btnApply.Location = new System.Drawing.Point(902, 5);
btnApply.Margin = new System.Windows.Forms.Padding(7, 3, 0, 0);
btnApply.Name = "btnApply";
btnApply.Size = new System.Drawing.Size(93, 30);
btnApply.TabIndex = 9;
btnApply.Text = "Apply";
//
// splitContainer
//
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer.Name = "splitContainer";
this.splitContainer.SplitterDistance = 350;
this.splitContainer.TabIndex = 1;
//
//
splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
splitContainer.Location = new System.Drawing.Point(0, 42);
splitContainer.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
splitContainer.Name = "splitContainer";
//
// splitContainer.Panel1
//
splitContainer.Panel1.Controls.Add(cellView);
//
// splitContainer.Panel2
//
splitContainer.Panel2.Controls.Add(splitContainer1);
splitContainer.Size = new System.Drawing.Size(1220, 677);
splitContainer.SplitterDistance = 610;
splitContainer.SplitterWidth = 5;
splitContainer.TabIndex = 1;
//
// cellView
//
cellView.ActiveWorkArea = null;
cellView.AllowDrop = true;
cellView.AllowPan = true;
cellView.AllowSelect = true;
cellView.AllowZoom = true;
cellView.BackColor = System.Drawing.Color.DarkGray;
colorScheme1.BackgroundColor = System.Drawing.Color.DarkGray;
colorScheme1.BoundingBoxColor = System.Drawing.Color.FromArgb(128, 128, 255);
colorScheme1.EdgeSpacingColor = System.Drawing.Color.FromArgb(180, 180, 180);
colorScheme1.LayoutFillColor = System.Drawing.Color.WhiteSmoke;
colorScheme1.LayoutOutlineColor = System.Drawing.Color.Gray;
colorScheme1.OriginColor = System.Drawing.Color.Gray;
colorScheme1.PreviewPartColor = System.Drawing.Color.FromArgb(255, 140, 0);
colorScheme1.RapidColor = System.Drawing.Color.DodgerBlue;
cellView.ColorScheme = colorScheme1;
cellView.DebugRemnantPriorities = null;
cellView.DebugRemnants = null;
cellView.Dock = System.Windows.Forms.DockStyle.Fill;
cellView.DrawBounds = false;
cellView.DrawOffset = false;
cellView.DrawOrigin = false;
cellView.DrawRapid = false;
cellView.FillParts = true;
cellView.Location = new System.Drawing.Point(0, 0);
cellView.Name = "cellView";
cellView.OffsetIncrementDistance = 10D;
cellView.OffsetTolerance = 0.001D;
material1.Density = 0D;
material1.Grade = null;
material1.Name = null;
plate1.Material = material1;
plate1.Parts = observableList_11;
plate1.PartSpacing = 0D;
plate1.Quadrant = 1;
plate1.Quantity = 0;
plate1.Thickness = 0D;
cellView.Plate = plate1;
cellView.RotateIncrementAngle = 10D;
cellView.Size = new System.Drawing.Size(610, 677);
cellView.Status = "Select";
cellView.TabIndex = 0;
//
// splitContainer1
//
splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
splitContainer1.IsSplitterFixed = true;
splitContainer1.Location = new System.Drawing.Point(0, 0);
splitContainer1.Name = "splitContainer1";
splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
splitContainer1.Panel1.Controls.Add(hPreview);
splitContainer1.Panel1.Controls.Add(hLabel);
//
// splitContainer1.Panel2
//
splitContainer1.Panel2.Controls.Add(vPreview);
splitContainer1.Panel2.Controls.Add(vLabel);
splitContainer1.Size = new System.Drawing.Size(605, 677);
splitContainer1.SplitterDistance = 333;
splitContainer1.TabIndex = 0;
//
// hPreview
//
hPreview.ActiveWorkArea = null;
hPreview.AllowPan = true;
hPreview.AllowSelect = false;
hPreview.AllowZoom = true;
hPreview.BackColor = System.Drawing.Color.DarkGray;
hPreview.ColorScheme = colorScheme1;
hPreview.DebugRemnantPriorities = null;
hPreview.DebugRemnants = null;
hPreview.Dock = System.Windows.Forms.DockStyle.Fill;
hPreview.DrawBounds = false;
hPreview.DrawOffset = false;
hPreview.DrawOrigin = true;
hPreview.DrawRapid = false;
hPreview.FillParts = true;
hPreview.Location = new System.Drawing.Point(0, 20);
hPreview.Name = "hPreview";
hPreview.OffsetIncrementDistance = 10D;
hPreview.OffsetTolerance = 0.001D;
material2.Density = 0D;
material2.Grade = null;
material2.Name = null;
plate2.Material = material2;
plate2.Parts = observableList_12;
plate2.PartSpacing = 0D;
plate2.Quadrant = 1;
plate2.Quantity = 0;
plate2.Thickness = 0D;
hPreview.Plate = plate2;
hPreview.RotateIncrementAngle = 10D;
hPreview.Size = new System.Drawing.Size(605, 313);
hPreview.Status = "Select";
hPreview.TabIndex = 0;
//
// hLabel
//
hLabel.Dock = System.Windows.Forms.DockStyle.Top;
hLabel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold);
hLabel.ForeColor = System.Drawing.Color.FromArgb(80, 80, 80);
hLabel.Location = new System.Drawing.Point(0, 0);
hLabel.Name = "hLabel";
hLabel.Padding = new System.Windows.Forms.Padding(4, 0, 0, 0);
hLabel.Size = new System.Drawing.Size(605, 20);
hLabel.TabIndex = 1;
hLabel.Text = "Horizontal — 0 parts";
hLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// vPreview
//
vPreview.ActiveWorkArea = null;
vPreview.AllowPan = true;
vPreview.AllowSelect = false;
vPreview.AllowZoom = true;
vPreview.BackColor = System.Drawing.Color.DarkGray;
vPreview.ColorScheme = colorScheme1;
vPreview.DebugRemnantPriorities = null;
vPreview.DebugRemnants = null;
vPreview.Dock = System.Windows.Forms.DockStyle.Fill;
vPreview.DrawBounds = false;
vPreview.DrawOffset = false;
vPreview.DrawOrigin = true;
vPreview.DrawRapid = false;
vPreview.FillParts = true;
vPreview.Location = new System.Drawing.Point(0, 20);
vPreview.Name = "vPreview";
vPreview.OffsetIncrementDistance = 10D;
vPreview.OffsetTolerance = 0.001D;
material3.Density = 0D;
material3.Grade = null;
material3.Name = null;
plate3.Material = material3;
plate3.Parts = observableList_13;
plate3.PartSpacing = 0D;
plate3.Quadrant = 1;
plate3.Quantity = 0;
plate3.Thickness = 0D;
vPreview.Plate = plate3;
vPreview.RotateIncrementAngle = 10D;
vPreview.Size = new System.Drawing.Size(605, 320);
vPreview.Status = "Select";
vPreview.TabIndex = 0;
//
// vLabel
//
vLabel.Dock = System.Windows.Forms.DockStyle.Top;
vLabel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold);
vLabel.ForeColor = System.Drawing.Color.FromArgb(80, 80, 80);
vLabel.Location = new System.Drawing.Point(0, 0);
vLabel.Name = "vLabel";
vLabel.Padding = new System.Windows.Forms.Padding(4, 0, 0, 0);
vLabel.Size = new System.Drawing.Size(605, 20);
vLabel.TabIndex = 1;
vLabel.Text = "Vertical — 0 parts";
vLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// PatternTileForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(900, 550);
this.Controls.Add(this.splitContainer);
this.Controls.Add(this.topPanel);
this.MinimumSize = new System.Drawing.Size(700, 400);
this.Name = "PatternTileForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Pattern Tile";
this.topPanel.ResumeLayout(false);
this.topPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudPartSpacing)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
this.splitContainer.ResumeLayout(false);
this.ResumeLayout(false);
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new System.Drawing.Size(1220, 719);
Controls.Add(splitContainer);
Controls.Add(topPanel);
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
MinimumSize = new System.Drawing.Size(814, 456);
Name = "PatternTileForm";
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
Text = "Pattern Tile";
WindowState = System.Windows.Forms.FormWindowState.Maximized;
topPanel.ResumeLayout(false);
topPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)nudPartSpacing).EndInit();
splitContainer.Panel1.ResumeLayout(false);
splitContainer.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer).EndInit();
splitContainer.ResumeLayout(false);
splitContainer1.Panel1.ResumeLayout(false);
splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
splitContainer1.ResumeLayout(false);
ResumeLayout(false);
}
private System.Windows.Forms.FlowLayoutPanel topPanel;
@@ -161,5 +389,11 @@ namespace OpenNest.Forms
private System.Windows.Forms.Button btnAutoArrange;
private System.Windows.Forms.Button btnApply;
private System.Windows.Forms.SplitContainer splitContainer;
private OpenNest.Controls.PlateView cellView;
private System.Windows.Forms.SplitContainer splitContainer1;
private OpenNest.Controls.PlateView hPreview;
private System.Windows.Forms.Label hLabel;
private OpenNest.Controls.PlateView vPreview;
private System.Windows.Forms.Label vLabel;
}
}
+38 -81
View File
@@ -1,34 +1,16 @@
using OpenNest.Engine.Fill;
using OpenNest.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using OpenNest.Controls;
using OpenNest.Geometry;
using GeoSize = OpenNest.Geometry.Size;
namespace OpenNest.Forms
{
public enum PatternTileTarget
{
CurrentPlate,
NewPlate
}
public class PatternTileResult
{
public List<Part> Parts { get; set; }
public PatternTileTarget Target { get; set; }
public GeoSize PlateSize { get; set; }
}
public partial class PatternTileForm : Form
{
private readonly Nest nest;
private readonly PlateView cellView;
private readonly PlateView hPreview;
private readonly PlateView vPreview;
private readonly Label hLabel;
private readonly Label vLabel;
public PatternTileResult Result { get; private set; }
@@ -37,53 +19,11 @@ namespace OpenNest.Forms
this.nest = nest;
InitializeComponent();
// Unit cell editor — plate outline hidden via zero-size plate
cellView = new PlateView();
// Hide plate outline via zero-size plate
cellView.Plate.Size = new GeoSize(0, 0);
cellView.Plate.Quantity = 0; // prevent Drawing.Quantity.Nested side-effects
cellView.DrawOrigin = false;
cellView.DrawBounds = false; // hide selection bounding box overlay
cellView.Dock = DockStyle.Fill;
splitContainer.Panel1.Controls.Add(cellView);
// Right side: vertical split with horizontal and vertical preview
var previewSplit = new SplitContainer
{
Dock = DockStyle.Fill,
Orientation = Orientation.Horizontal,
SplitterDistance = 250
};
splitContainer.Panel2.Controls.Add(previewSplit);
hLabel = new Label
{
Dock = DockStyle.Top,
Height = 20,
Text = "Horizontal — 0 parts",
TextAlign = System.Drawing.ContentAlignment.MiddleLeft,
Font = new System.Drawing.Font("Segoe UI", 9f, System.Drawing.FontStyle.Bold),
ForeColor = System.Drawing.Color.FromArgb(80, 80, 80),
Padding = new Padding(4, 0, 0, 0)
};
hPreview = CreatePreviewView();
previewSplit.Panel1.Controls.Add(hPreview);
previewSplit.Panel1.Controls.Add(hLabel);
vLabel = new Label
{
Dock = DockStyle.Top,
Height = 20,
Text = "Vertical — 0 parts",
TextAlign = System.Drawing.ContentAlignment.MiddleLeft,
Font = new System.Drawing.Font("Segoe UI", 9f, System.Drawing.FontStyle.Bold),
ForeColor = System.Drawing.Color.FromArgb(80, 80, 80),
Padding = new Padding(4, 0, 0, 0)
};
vPreview = CreatePreviewView();
previewSplit.Panel2.Controls.Add(vPreview);
previewSplit.Panel2.Controls.Add(vLabel);
cellView.Plate.Quantity = 0;
hPreview.Plate.Quantity = 0;
vPreview.Plate.Quantity = 0;
// Populate drawing dropdowns
var drawings = nest.Drawings.OrderBy(d => d.Name).ToList();
@@ -102,6 +42,12 @@ namespace OpenNest.Forms
txtPlateSize.Text = defaults.Size.ToString();
nudPartSpacing.Value = (decimal)defaults.PartSpacing;
// Format drawing names in dropdowns
cboDrawingA.FormattingEnabled = true;
cboDrawingA.Format += ComboDrawing_Format;
cboDrawingB.FormattingEnabled = true;
cboDrawingB.Format += ComboDrawing_Format;
// Wire events
cboDrawingA.SelectedIndexChanged += OnDrawingChanged;
cboDrawingB.SelectedIndexChanged += OnDrawingChanged;
@@ -112,6 +58,12 @@ namespace OpenNest.Forms
cellView.MouseUp += OnCellMouseUp;
}
private void ComboDrawing_Format(object sender, ListControlConvertEventArgs e)
{
if (e.Value is Drawing d)
e.Value = d.Name;
}
private Drawing SelectedDrawingA =>
cboDrawingA.SelectedItem as Drawing;
@@ -144,6 +96,7 @@ namespace OpenNest.Forms
if (e.Button == MouseButtons.Left && cellView.Plate.Parts.Count >= 2)
{
CompactCellParts();
cellView.ZoomToFit();
}
RebuildPreview();
@@ -212,12 +165,14 @@ namespace OpenNest.Forms
if (System.Math.Sqrt(dx * dx + dy * dy) < 0.01)
continue;
var angle = System.Math.Atan2(dy, dx);
var direction = new Vector(dx, dy);
var len = System.Math.Sqrt(dx * dx + dy * dy);
if (len > 0) direction = new Vector(dx / len, dy / len);
var single = new List<Part> { part };
var obstacles = parts.Where(p => p != part).ToList();
totalMoved += Compactor.Push(single, obstacles,
syntheticWorkArea, spacing, angle);
syntheticWorkArea, spacing, direction);
}
if (totalMoved < 0.01)
@@ -225,17 +180,6 @@ namespace OpenNest.Forms
}
}
private static PlateView CreatePreviewView()
{
var view = new PlateView();
view.Plate.Quantity = 0;
view.AllowSelect = false;
view.AllowDrop = false;
view.DrawBounds = false;
view.Dock = DockStyle.Fill;
return view;
}
private void UpdatePreviewPlateSize()
{
if (!TryGetPlateSize(out var size))
@@ -275,7 +219,7 @@ namespace OpenNest.Forms
if (pattern == null)
return;
var workArea = new Box(0, 0, plateSize.Width, plateSize.Length);
var workArea = new Box(0, 0, plateSize.Length, plateSize.Width);
var filler = new FillLinear(workArea, PartSpacing);
var hParts = filler.Fill(pattern, NestDirection.Horizontal);
@@ -384,7 +328,7 @@ namespace OpenNest.Forms
if (pattern == null)
return;
var filler = new FillLinear(new Box(0, 0, plateSize.Width, plateSize.Length), PartSpacing);
var filler = new FillLinear(new Box(0, 0, plateSize.Length, plateSize.Width), PartSpacing);
var tiledParts = filler.Fill(pattern, applyDirection);
Result = new PatternTileResult
@@ -400,4 +344,17 @@ namespace OpenNest.Forms
Close();
}
}
public enum PatternTileTarget
{
CurrentPlate,
NewPlate
}
public class PatternTileResult
{
public List<Part> Parts { get; set; }
public PatternTileTarget Target { get; set; }
public GeoSize PlateSize { get; set; }
}
}
+120
View File
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+3 -2
View File
@@ -1,9 +1,10 @@
using OpenNest.Controls;
using OpenNest.Engine.Fill;
using OpenNest.Geometry;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using OpenNest.Controls;
using OpenNest.Geometry;
namespace OpenNest.Forms
{
+6 -7
View File
@@ -1,9 +1,8 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using OpenNest.CNC;
using OpenNest.CNC;
using OpenNest.Geometry;
using OpenNest.Math;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace OpenNest
{
@@ -53,7 +52,7 @@ namespace OpenNest
var img = new Bitmap(size.Width, size.Height);
var path = pgm.GetGraphicsPath();
var bounds = path.GetBounds();
var scalex = (size.Height - 10) / bounds.Height;
var scaley = (size.Width - 10) / bounds.Width;
var scale = scalex < scaley ? scalex : scaley;
@@ -132,9 +131,9 @@ namespace OpenNest
var sweepAngle = (endAngle - startAngle);
path.AddArc(
pt.X, pt.Y,
pt.X, pt.Y,
size, size,
(float)startAngle,
(float)startAngle,
(float)sweepAngle);
if (arc.Layer == LayerType.Leadin || arc.Layer == LayerType.Leadout)
+5 -5
View File
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using OpenNest.Controls;
using OpenNest.Converters;
using OpenNest.Geometry;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms;
using OpenNest.Controls;
using OpenNest.Converters;
using OpenNest.Geometry;
namespace OpenNest
{
@@ -49,7 +49,7 @@ namespace OpenNest
internal bool IsDirty { get; set; }
public bool IsSelected { get; set; }
public GraphicsPath Path { get; private set; }
public Color Color
+1 -1
View File
@@ -1,6 +1,6 @@
using OpenNest.Forms;
using System;
using System.Windows.Forms;
using OpenNest.Forms;
namespace OpenNest
{
+30 -17
View File
@@ -151,7 +151,8 @@ namespace OpenNest
return hot ? (int)MenuPopupItemStates.Hover : (int)MenuPopupItemStates.Normal;
return hot ? (int)MenuPopupItemStates.DisabledHover : (int)MenuPopupItemStates.Disabled;
}
else {
else
{
if (item.Pressed)
return item.Enabled ? (int)MenuBarItemStates.Pushed : (int)MenuBarItemStates.DisabledPushed;
if (item.Enabled)
@@ -265,7 +266,8 @@ namespace OpenNest
e.Graphics.Clip = oldClip;
}
}
else {
else
{
base.OnRenderToolStripBorder(e);
}
}
@@ -299,7 +301,8 @@ namespace OpenNest
Rectangle bgRect = GetBackgroundRectangle(e.Item);
renderer.DrawBackground(e.Graphics, bgRect, bgRect);
}
else {
else
{
base.OnRenderMenuItemBackground(e);
}
}
@@ -314,7 +317,8 @@ namespace OpenNest
{
renderer.SetParameters(RebarClass, RebarBackground, 0);
}
else {
else
{
renderer.SetParameters(RebarClass, 0, 0);
}
@@ -325,7 +329,8 @@ namespace OpenNest
e.Handled = true;
}
else {
else
{
base.OnRenderToolStripPanelBackground(e);
}
}
@@ -339,7 +344,8 @@ namespace OpenNest
{
renderer.SetParameters(MenuClass, (int)MenuParts.PopupBackground, 0);
}
else {
else
{
// It's a MenuStrip or a ToolStrip. If it's contained inside a larger panel, it should have a
// transparent background, showing the panel's background.
@@ -350,7 +356,8 @@ namespace OpenNest
// if someone does that.)
return;
}
else {
else
{
// A lone toolbar/menubar should act like it's inside a toolbox, I guess.
// Maybe I should use the MenuClass in the case of a MenuStrip, although that would break
// the other themes...
@@ -366,7 +373,8 @@ namespace OpenNest
renderer.DrawBackground(e.Graphics, e.ToolStrip.ClientRectangle, e.AffectedBounds);
}
else {
else
{
base.OnRenderToolStripBackground(e);
}
}
@@ -383,7 +391,8 @@ namespace OpenNest
// It doesn't matter what colour of arrow we tell it to draw. OnRenderArrow will compute it from the item anyway.
OnRenderArrow(new ToolStripArrowRenderEventArgs(e.Graphics, sb, sb.DropDownButtonBounds, Color.Red, ArrowDirection.Down));
}
else {
else
{
base.OnRenderSplitButtonBackground(e);
}
}
@@ -426,13 +435,15 @@ namespace OpenNest
rect = new Rectangle(rect.X - extraWidth, rect.Y, sepWidth, rect.Height);
rect.X += sepWidth;
}
else {
else
{
rect = new Rectangle(rect.Width + extraWidth - sepWidth, rect.Y, sepWidth, rect.Height);
}
renderer.DrawBackground(e.Graphics, rect);
}
}
else {
else
{
base.OnRenderImageMargin(e);
}
}
@@ -447,10 +458,10 @@ namespace OpenNest
}
else
{
e.Graphics.DrawLine(Pens.LightGray,
e.Item.ContentRectangle.X,
e.Item.ContentRectangle.Y,
e.Item.ContentRectangle.X,
e.Graphics.DrawLine(Pens.LightGray,
e.Item.ContentRectangle.X,
e.Item.ContentRectangle.Y,
e.Item.ContentRectangle.X,
e.Item.ContentRectangle.Y + e.Item.Height - 6);
}
}
@@ -478,7 +489,8 @@ namespace OpenNest
renderer.DrawBackground(e.Graphics, checkRect);
}
else {
else
{
base.OnRenderItemCheck(e);
}
}
@@ -510,7 +522,8 @@ namespace OpenNest
renderer.SetParameters(rebarClass, VisualStyleElement.Rebar.Chevron.Normal.Part, state);
renderer.DrawBackground(e.Graphics, new Rectangle(Point.Empty, e.Item.Size));
}
else {
else
{
base.OnRenderOverflowButtonBackground(e);
}
}