feat: implement color and line type exclusion filters on CadConverterForm
Add per-entity IsVisible flag and wire up the Colors and Line Types checkedlistboxes to filter entities by exclusion — checking an item hides matching entities from the preview and from drawing export. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using OpenNest.Math;
|
||||
|
||||
namespace OpenNest.Geometry
|
||||
@@ -13,6 +14,21 @@ namespace OpenNest.Geometry
|
||||
boundingBox = new Box();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Entity color (resolved from DXF ByLayer/ByBlock to actual color).
|
||||
/// </summary>
|
||||
public Color Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity linetype name (e.g. "Continuous", "Center", "Dashed").
|
||||
/// </summary>
|
||||
public string LineTypeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this entity is visible (used for color/linetype filtering).
|
||||
/// </summary>
|
||||
public bool IsVisible { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Smallest box that contains the entity.
|
||||
/// </summary>
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace OpenNest.Controls
|
||||
|
||||
private void DrawEntity(Graphics g, Entity e, Pen pen)
|
||||
{
|
||||
if (!e.Layer.IsVisible)
|
||||
if (!e.Layer.IsVisible || !e.IsVisible)
|
||||
return;
|
||||
|
||||
switch (e.Type)
|
||||
|
||||
363
OpenNest/Forms/CadConverterForm.Designer.cs
generated
363
OpenNest/Forms/CadConverterForm.Designer.cs
generated
@@ -29,247 +29,252 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.checkedListBox1 = new System.Windows.Forms.CheckedListBox();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.checkedListBox2 = new System.Windows.Forms.CheckedListBox();
|
||||
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||
this.checkedListBox3 = new System.Windows.Forms.CheckedListBox();
|
||||
this.entityView1 = new OpenNest.Controls.EntityView();
|
||||
this.bottomPanel1 = new OpenNest.Controls.BottomPanel();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.acceptButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
|
||||
this.splitContainer2.Panel1.SuspendLayout();
|
||||
this.splitContainer2.Panel2.SuspendLayout();
|
||||
this.splitContainer2.SuspendLayout();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.tabPage2.SuspendLayout();
|
||||
this.tabPage3.SuspendLayout();
|
||||
this.bottomPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
splitContainer2 = new System.Windows.Forms.SplitContainer();
|
||||
tabControl1 = new System.Windows.Forms.TabControl();
|
||||
tabPage1 = new System.Windows.Forms.TabPage();
|
||||
checkedListBox1 = new System.Windows.Forms.CheckedListBox();
|
||||
tabPage2 = new System.Windows.Forms.TabPage();
|
||||
checkedListBox2 = new System.Windows.Forms.CheckedListBox();
|
||||
tabPage3 = new System.Windows.Forms.TabPage();
|
||||
checkedListBox3 = new System.Windows.Forms.CheckedListBox();
|
||||
entityView1 = new OpenNest.Controls.EntityView();
|
||||
bottomPanel1 = new OpenNest.Controls.BottomPanel();
|
||||
cancelButton = new System.Windows.Forms.Button();
|
||||
acceptButton = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
|
||||
splitContainer1.Panel1.SuspendLayout();
|
||||
splitContainer1.Panel2.SuspendLayout();
|
||||
splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer2).BeginInit();
|
||||
splitContainer2.Panel1.SuspendLayout();
|
||||
splitContainer2.Panel2.SuspendLayout();
|
||||
splitContainer2.SuspendLayout();
|
||||
tabControl1.SuspendLayout();
|
||||
tabPage1.SuspendLayout();
|
||||
tabPage2.SuspendLayout();
|
||||
tabPage3.SuspendLayout();
|
||||
bottomPanel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
splitContainer1.Name = "splitContainer1";
|
||||
splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.dataGridView1);
|
||||
splitContainer1.Panel1.Controls.Add(dataGridView1);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(928, 479);
|
||||
this.splitContainer1.SplitterDistance = 225;
|
||||
this.splitContainer1.TabIndex = 0;
|
||||
splitContainer1.Panel2.Controls.Add(splitContainer2);
|
||||
splitContainer1.Size = new System.Drawing.Size(928, 643);
|
||||
splitContainer1.SplitterDistance = 302;
|
||||
splitContainer1.TabIndex = 0;
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
this.dataGridView1.AllowUserToAddRows = false;
|
||||
this.dataGridView1.AllowUserToResizeRows = false;
|
||||
this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.AllowUserToAddRows = false;
|
||||
dataGridView1.AllowUserToResizeRows = false;
|
||||
dataGridView1.BackgroundColor = System.Drawing.Color.White;
|
||||
dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
|
||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
|
||||
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
|
||||
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(255, 255, 192);
|
||||
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.Black;
|
||||
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
|
||||
this.dataGridView1.DefaultCellStyle = dataGridViewCellStyle1;
|
||||
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGridView1.GridColor = System.Drawing.Color.Gainsboro;
|
||||
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView1.MultiSelect = false;
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.RowHeadersVisible = false;
|
||||
this.dataGridView1.RowTemplate.Height = 26;
|
||||
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.dataGridView1.Size = new System.Drawing.Size(928, 225);
|
||||
this.dataGridView1.TabIndex = 0;
|
||||
this.dataGridView1.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.dataGridView1_DataBindingComplete);
|
||||
this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
|
||||
dataGridView1.DefaultCellStyle = dataGridViewCellStyle1;
|
||||
dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
dataGridView1.GridColor = System.Drawing.Color.Gainsboro;
|
||||
dataGridView1.Location = new System.Drawing.Point(0, 0);
|
||||
dataGridView1.MultiSelect = false;
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.RowHeadersVisible = false;
|
||||
dataGridView1.RowTemplate.Height = 26;
|
||||
dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView1.Size = new System.Drawing.Size(928, 302);
|
||||
dataGridView1.TabIndex = 0;
|
||||
dataGridView1.DataBindingComplete += dataGridView1_DataBindingComplete;
|
||||
dataGridView1.SelectionChanged += dataGridView1_SelectionChanged;
|
||||
//
|
||||
// splitContainer2
|
||||
//
|
||||
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer2.Name = "splitContainer2";
|
||||
splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
splitContainer2.Location = new System.Drawing.Point(0, 0);
|
||||
splitContainer2.Name = "splitContainer2";
|
||||
//
|
||||
// splitContainer2.Panel1
|
||||
//
|
||||
this.splitContainer2.Panel1.Controls.Add(this.tabControl1);
|
||||
splitContainer2.Panel1.Controls.Add(tabControl1);
|
||||
//
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
this.splitContainer2.Panel2.Controls.Add(this.entityView1);
|
||||
this.splitContainer2.Size = new System.Drawing.Size(928, 250);
|
||||
this.splitContainer2.SplitterDistance = 309;
|
||||
this.splitContainer2.TabIndex = 0;
|
||||
splitContainer2.Panel2.Controls.Add(entityView1);
|
||||
splitContainer2.Size = new System.Drawing.Size(928, 337);
|
||||
splitContainer2.SplitterDistance = 309;
|
||||
splitContainer2.TabIndex = 0;
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Controls.Add(this.tabPage1);
|
||||
this.tabControl1.Controls.Add(this.tabPage2);
|
||||
this.tabControl1.Controls.Add(this.tabPage3);
|
||||
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tabControl1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(309, 250);
|
||||
this.tabControl1.TabIndex = 0;
|
||||
tabControl1.Controls.Add(tabPage1);
|
||||
tabControl1.Controls.Add(tabPage2);
|
||||
tabControl1.Controls.Add(tabPage3);
|
||||
tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
tabControl1.Location = new System.Drawing.Point(0, 0);
|
||||
tabControl1.Name = "tabControl1";
|
||||
tabControl1.SelectedIndex = 0;
|
||||
tabControl1.Size = new System.Drawing.Size(309, 337);
|
||||
tabControl1.TabIndex = 0;
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.checkedListBox1);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 25);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(301, 221);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "Layers";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
tabPage1.Controls.Add(checkedListBox1);
|
||||
tabPage1.Location = new System.Drawing.Point(4, 25);
|
||||
tabPage1.Name = "tabPage1";
|
||||
tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
tabPage1.Size = new System.Drawing.Size(301, 308);
|
||||
tabPage1.TabIndex = 0;
|
||||
tabPage1.Text = "Layers";
|
||||
tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkedListBox1
|
||||
//
|
||||
this.checkedListBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.checkedListBox1.CheckOnClick = true;
|
||||
this.checkedListBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.checkedListBox1.FormattingEnabled = true;
|
||||
this.checkedListBox1.Location = new System.Drawing.Point(3, 3);
|
||||
this.checkedListBox1.Name = "checkedListBox1";
|
||||
this.checkedListBox1.Size = new System.Drawing.Size(295, 215);
|
||||
this.checkedListBox1.TabIndex = 0;
|
||||
this.checkedListBox1.SelectedIndexChanged += new System.EventHandler(this.checkedListBox1_SelectedIndexChanged);
|
||||
checkedListBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
checkedListBox1.CheckOnClick = true;
|
||||
checkedListBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
checkedListBox1.FormattingEnabled = true;
|
||||
checkedListBox1.Location = new System.Drawing.Point(3, 3);
|
||||
checkedListBox1.Name = "checkedListBox1";
|
||||
checkedListBox1.Size = new System.Drawing.Size(295, 302);
|
||||
checkedListBox1.TabIndex = 0;
|
||||
checkedListBox1.SelectedIndexChanged += checkedListBox1_SelectedIndexChanged;
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.checkedListBox2);
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(301, 294);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Colors";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
tabPage2.Controls.Add(checkedListBox2);
|
||||
tabPage2.Location = new System.Drawing.Point(4, 24);
|
||||
tabPage2.Name = "tabPage2";
|
||||
tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
tabPage2.Size = new System.Drawing.Size(301, 309);
|
||||
tabPage2.TabIndex = 1;
|
||||
tabPage2.Text = "Colors";
|
||||
tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkedListBox2
|
||||
//
|
||||
this.checkedListBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.checkedListBox2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.checkedListBox2.FormattingEnabled = true;
|
||||
this.checkedListBox2.Location = new System.Drawing.Point(3, 3);
|
||||
this.checkedListBox2.Name = "checkedListBox2";
|
||||
this.checkedListBox2.Size = new System.Drawing.Size(295, 288);
|
||||
this.checkedListBox2.TabIndex = 1;
|
||||
checkedListBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
checkedListBox2.CheckOnClick = true;
|
||||
checkedListBox2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
checkedListBox2.FormattingEnabled = true;
|
||||
checkedListBox2.Location = new System.Drawing.Point(3, 3);
|
||||
checkedListBox2.Name = "checkedListBox2";
|
||||
checkedListBox2.Size = new System.Drawing.Size(295, 303);
|
||||
checkedListBox2.TabIndex = 1;
|
||||
checkedListBox2.DrawItem += checkedListBox2_DrawItem;
|
||||
checkedListBox2.SelectedIndexChanged += checkedListBox2_SelectedIndexChanged;
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
this.tabPage3.Controls.Add(this.checkedListBox3);
|
||||
this.tabPage3.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage3.Name = "tabPage3";
|
||||
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage3.Size = new System.Drawing.Size(301, 294);
|
||||
this.tabPage3.TabIndex = 2;
|
||||
this.tabPage3.Text = "Line Types";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
tabPage3.Controls.Add(checkedListBox3);
|
||||
tabPage3.Location = new System.Drawing.Point(4, 24);
|
||||
tabPage3.Name = "tabPage3";
|
||||
tabPage3.Padding = new System.Windows.Forms.Padding(3);
|
||||
tabPage3.Size = new System.Drawing.Size(301, 309);
|
||||
tabPage3.TabIndex = 2;
|
||||
tabPage3.Text = "Line Types";
|
||||
tabPage3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkedListBox3
|
||||
//
|
||||
this.checkedListBox3.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.checkedListBox3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.checkedListBox3.FormattingEnabled = true;
|
||||
this.checkedListBox3.Location = new System.Drawing.Point(3, 3);
|
||||
this.checkedListBox3.Name = "checkedListBox3";
|
||||
this.checkedListBox3.Size = new System.Drawing.Size(295, 288);
|
||||
this.checkedListBox3.TabIndex = 2;
|
||||
checkedListBox3.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
checkedListBox3.CheckOnClick = true;
|
||||
checkedListBox3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
checkedListBox3.FormattingEnabled = true;
|
||||
checkedListBox3.Location = new System.Drawing.Point(3, 3);
|
||||
checkedListBox3.Name = "checkedListBox3";
|
||||
checkedListBox3.Size = new System.Drawing.Size(295, 303);
|
||||
checkedListBox3.TabIndex = 2;
|
||||
checkedListBox3.SelectedIndexChanged += checkedListBox3_SelectedIndexChanged;
|
||||
//
|
||||
// entityView1
|
||||
//
|
||||
this.entityView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(40)))), ((int)(((byte)(48)))));
|
||||
this.entityView1.Cursor = System.Windows.Forms.Cursors.Cross;
|
||||
this.entityView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.entityView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.entityView1.Name = "entityView1";
|
||||
this.entityView1.Size = new System.Drawing.Size(615, 250);
|
||||
this.entityView1.TabIndex = 0;
|
||||
this.entityView1.Text = "entityView1";
|
||||
entityView1.BackColor = System.Drawing.Color.FromArgb(33, 40, 48);
|
||||
entityView1.Cursor = System.Windows.Forms.Cursors.Cross;
|
||||
entityView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
entityView1.Location = new System.Drawing.Point(0, 0);
|
||||
entityView1.Name = "entityView1";
|
||||
entityView1.Size = new System.Drawing.Size(615, 337);
|
||||
entityView1.TabIndex = 0;
|
||||
entityView1.Text = "entityView1";
|
||||
//
|
||||
// bottomPanel1
|
||||
//
|
||||
this.bottomPanel1.Controls.Add(this.cancelButton);
|
||||
this.bottomPanel1.Controls.Add(this.acceptButton);
|
||||
this.bottomPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.bottomPanel1.Location = new System.Drawing.Point(0, 479);
|
||||
this.bottomPanel1.Name = "bottomPanel1";
|
||||
this.bottomPanel1.Size = new System.Drawing.Size(928, 50);
|
||||
this.bottomPanel1.TabIndex = 1;
|
||||
bottomPanel1.Controls.Add(cancelButton);
|
||||
bottomPanel1.Controls.Add(acceptButton);
|
||||
bottomPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
bottomPanel1.Location = new System.Drawing.Point(0, 643);
|
||||
bottomPanel1.Name = "bottomPanel1";
|
||||
bottomPanel1.Size = new System.Drawing.Size(928, 50);
|
||||
bottomPanel1.TabIndex = 1;
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(826, 10);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(90, 28);
|
||||
this.cancelButton.TabIndex = 1;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
cancelButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
cancelButton.Location = new System.Drawing.Point(826, 10);
|
||||
cancelButton.Name = "cancelButton";
|
||||
cancelButton.Size = new System.Drawing.Size(90, 28);
|
||||
cancelButton.TabIndex = 1;
|
||||
cancelButton.Text = "Cancel";
|
||||
cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// acceptButton
|
||||
//
|
||||
this.acceptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.acceptButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.acceptButton.Location = new System.Drawing.Point(730, 10);
|
||||
this.acceptButton.Name = "acceptButton";
|
||||
this.acceptButton.Size = new System.Drawing.Size(90, 28);
|
||||
this.acceptButton.TabIndex = 0;
|
||||
this.acceptButton.Text = "Accept";
|
||||
this.acceptButton.UseVisualStyleBackColor = true;
|
||||
acceptButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
acceptButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
acceptButton.Location = new System.Drawing.Point(730, 10);
|
||||
acceptButton.Name = "acceptButton";
|
||||
acceptButton.Size = new System.Drawing.Size(90, 28);
|
||||
acceptButton.TabIndex = 0;
|
||||
acceptButton.Text = "Accept";
|
||||
acceptButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// CadConverterForm
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.ClientSize = new System.Drawing.Size(928, 529);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Controls.Add(this.bottomPanel1);
|
||||
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "CadConverterForm";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "CAD Converter";
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||
this.splitContainer2.Panel1.ResumeLayout(false);
|
||||
this.splitContainer2.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
|
||||
this.splitContainer2.ResumeLayout(false);
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.tabPage2.ResumeLayout(false);
|
||||
this.tabPage3.ResumeLayout(false);
|
||||
this.bottomPanel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
ClientSize = new System.Drawing.Size(928, 693);
|
||||
Controls.Add(splitContainer1);
|
||||
Controls.Add(bottomPanel1);
|
||||
Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
|
||||
MinimizeBox = false;
|
||||
Name = "CadConverterForm";
|
||||
ShowIcon = false;
|
||||
ShowInTaskbar = false;
|
||||
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
Text = "CAD Converter";
|
||||
splitContainer1.Panel1.ResumeLayout(false);
|
||||
splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
|
||||
splitContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
splitContainer2.Panel1.ResumeLayout(false);
|
||||
splitContainer2.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer2).EndInit();
|
||||
splitContainer2.ResumeLayout(false);
|
||||
tabControl1.ResumeLayout(false);
|
||||
tabPage1.ResumeLayout(false);
|
||||
tabPage2.ResumeLayout(false);
|
||||
tabPage3.ResumeLayout(false);
|
||||
bottomPanel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ namespace OpenNest.Forms
|
||||
entityView1.Entities.AddRange(item.Entities);
|
||||
entityView1.ZoomToFit();
|
||||
|
||||
item.Entities.ForEach(e => e.IsVisible = true);
|
||||
|
||||
// Layers
|
||||
checkedListBox1.Items.Clear();
|
||||
|
||||
var layers = item.Entities
|
||||
@@ -56,6 +59,27 @@ namespace OpenNest.Forms
|
||||
|
||||
foreach (var layer in layers)
|
||||
checkedListBox1.Items.Add(layer, true);
|
||||
|
||||
// Colors
|
||||
checkedListBox2.Items.Clear();
|
||||
|
||||
var colors = item.Entities
|
||||
.Select(e => e.Color.ToArgb())
|
||||
.Distinct()
|
||||
.Select(argb => new ColorItem(Color.FromArgb(argb)));
|
||||
|
||||
foreach (var color in colors)
|
||||
checkedListBox2.Items.Add(color, false);
|
||||
|
||||
// Line Types
|
||||
checkedListBox3.Items.Clear();
|
||||
|
||||
var lineTypes = item.Entities
|
||||
.Select(e => e.LineTypeName ?? "Continuous")
|
||||
.Distinct();
|
||||
|
||||
foreach (var lineType in lineTypes)
|
||||
checkedListBox3.Items.Add(lineType, false);
|
||||
}
|
||||
|
||||
private static Color GetNextColor()
|
||||
@@ -77,7 +101,7 @@ namespace OpenNest.Forms
|
||||
|
||||
foreach (var item in Items)
|
||||
{
|
||||
var entities = item.Entities.Where(e => e.Layer.IsVisible).ToList();
|
||||
var entities = item.Entities.Where(e => e.Layer.IsVisible && e.IsVisible).ToList();
|
||||
|
||||
if (entities.Count == 0)
|
||||
continue;
|
||||
@@ -216,6 +240,64 @@ namespace OpenNest.Forms
|
||||
|
||||
entityView1.Invalidate();
|
||||
}
|
||||
|
||||
private void checkedListBox2_SelectedIndexChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
UpdateEntityVisibility();
|
||||
}
|
||||
|
||||
private void checkedListBox3_SelectedIndexChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
UpdateEntityVisibility();
|
||||
}
|
||||
|
||||
private void UpdateEntityVisibility()
|
||||
{
|
||||
var item = CurrentItem;
|
||||
if (item == null) return;
|
||||
|
||||
var checkedColors = new HashSet<int>();
|
||||
for (var i = 0; i < checkedListBox2.Items.Count; i++)
|
||||
{
|
||||
if (checkedListBox2.GetItemChecked(i))
|
||||
checkedColors.Add(((ColorItem)checkedListBox2.Items[i]).Argb);
|
||||
}
|
||||
|
||||
var checkedLineTypes = new HashSet<string>();
|
||||
for (var i = 0; i < checkedListBox3.Items.Count; i++)
|
||||
{
|
||||
if (checkedListBox3.GetItemChecked(i))
|
||||
checkedLineTypes.Add(checkedListBox3.Items[i].ToString());
|
||||
}
|
||||
|
||||
item.Entities.ForEach(entity =>
|
||||
{
|
||||
entity.IsVisible = !checkedColors.Contains(entity.Color.ToArgb())
|
||||
&& !checkedLineTypes.Contains(entity.LineTypeName ?? "Continuous");
|
||||
});
|
||||
|
||||
entityView1.Invalidate();
|
||||
}
|
||||
|
||||
private void checkedListBox2_DrawItem(object sender, DrawItemEventArgs e)
|
||||
{
|
||||
if (e.Index < 0) return;
|
||||
|
||||
e.DrawBackground();
|
||||
|
||||
var colorItem = (ColorItem)checkedListBox2.Items[e.Index];
|
||||
var swatchRect = new Rectangle(e.Bounds.Left + 20, e.Bounds.Top + 2, 16, e.Bounds.Height - 4);
|
||||
|
||||
using (var brush = new SolidBrush(colorItem.Color))
|
||||
e.Graphics.FillRectangle(brush, swatchRect);
|
||||
|
||||
e.Graphics.DrawRectangle(Pens.Gray, swatchRect);
|
||||
|
||||
var textRect = new Rectangle(swatchRect.Right + 4, e.Bounds.Top, e.Bounds.Width - swatchRect.Right - 4, e.Bounds.Height);
|
||||
TextRenderer.DrawText(e.Graphics, colorItem.ToString(), e.Font, textRect, e.ForeColor, TextFormatFlags.VerticalCenter);
|
||||
|
||||
e.DrawFocusRectangle();
|
||||
}
|
||||
}
|
||||
|
||||
class CadConverterItem
|
||||
@@ -233,6 +315,22 @@ namespace OpenNest.Forms
|
||||
public List<Entity> Entities { get; set; }
|
||||
}
|
||||
|
||||
class ColorItem
|
||||
{
|
||||
public int Argb { get; }
|
||||
public Color Color { get; }
|
||||
|
||||
public ColorItem(Color color)
|
||||
{
|
||||
Color = color;
|
||||
Argb = color.ToArgb();
|
||||
}
|
||||
|
||||
public override string ToString() => $"RGB({Color.R}, {Color.G}, {Color.B})";
|
||||
public override bool Equals(object obj) => obj is ColorItem other && Argb == other.Argb;
|
||||
public override int GetHashCode() => Argb;
|
||||
}
|
||||
|
||||
public class RandomColorGenerator
|
||||
{
|
||||
private readonly Random random;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
<!--
|
||||
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
|
||||
|
||||
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>
|
||||
@@ -26,36 +26,36 @@
|
||||
<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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
|
||||
Reference in New Issue
Block a user