refactor(ui): update MainForm for drawing-based workflow
Refactored MainForm to work with pre-selected drawing ID and number. Added PDF viewer control, enhanced BOM item management with sheet metal properties, and improved UI layout for drawing-specific operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
231
ExportDXF/Forms/MainForm.Designer.cs
generated
231
ExportDXF/Forms/MainForm.Designer.cs
generated
@@ -28,68 +28,46 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.activeDocTitleBox = new System.Windows.Forms.TextBox();
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
this.logTextBox = new System.Windows.Forms.RichTextBox();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.runButton = new System.Windows.Forms.Button();
|
this.runButton = new System.Windows.Forms.Button();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
this.viewFlipDeciderBox = new System.Windows.Forms.ComboBox();
|
this.viewFlipDeciderBox = new System.Windows.Forms.ComboBox();
|
||||||
this.label4 = new System.Windows.Forms.Label();
|
this.mainTabControl = new System.Windows.Forms.TabControl();
|
||||||
this.equipmentNoBox = new System.Windows.Forms.ComboBox();
|
this.logEventsTab = new System.Windows.Forms.TabPage();
|
||||||
this.label5 = new System.Windows.Forms.Label();
|
this.logEventsDataGrid = new System.Windows.Forms.DataGridView();
|
||||||
this.drawingNoBox = new System.Windows.Forms.ComboBox();
|
this.bomTab = new System.Windows.Forms.TabPage();
|
||||||
|
this.bomDataGrid = new System.Windows.Forms.DataGridView();
|
||||||
|
this.cutTemplatesTab = new System.Windows.Forms.TabPage();
|
||||||
|
this.cutTemplatesDataGrid = new System.Windows.Forms.DataGridView();
|
||||||
|
this.dwgDetailsTab = new System.Windows.Forms.TabPage();
|
||||||
|
this.drawingPdfViewer = new AxAcroPDFLib.AxAcroPDF();
|
||||||
|
this.mainTabControl.SuspendLayout();
|
||||||
|
this.logEventsTab.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.logEventsDataGrid)).BeginInit();
|
||||||
|
this.bomTab.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.bomDataGrid)).BeginInit();
|
||||||
|
this.cutTemplatesTab.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.cutTemplatesDataGrid)).BeginInit();
|
||||||
|
this.dwgDetailsTab.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.drawingPdfViewer)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// activeDocTitleBox
|
|
||||||
//
|
|
||||||
this.activeDocTitleBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.activeDocTitleBox.BackColor = System.Drawing.Color.White;
|
|
||||||
this.activeDocTitleBox.Location = new System.Drawing.Point(130, 13);
|
|
||||||
this.activeDocTitleBox.Name = "activeDocTitleBox";
|
|
||||||
this.activeDocTitleBox.ReadOnly = true;
|
|
||||||
this.activeDocTitleBox.Size = new System.Drawing.Size(748, 25);
|
|
||||||
this.activeDocTitleBox.TabIndex = 1;
|
|
||||||
this.activeDocTitleBox.TextChanged += new System.EventHandler(this.activeDocTitleBox_TextChanged);
|
|
||||||
//
|
|
||||||
// logTextBox
|
|
||||||
//
|
|
||||||
this.logTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.logTextBox.BackColor = System.Drawing.Color.White;
|
|
||||||
this.logTextBox.Location = new System.Drawing.Point(12, 106);
|
|
||||||
this.logTextBox.Name = "logTextBox";
|
|
||||||
this.logTextBox.ReadOnly = true;
|
|
||||||
this.logTextBox.Size = new System.Drawing.Size(866, 556);
|
|
||||||
this.logTextBox.TabIndex = 10;
|
|
||||||
this.logTextBox.Text = "";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
this.label1.AutoSize = true;
|
|
||||||
this.label1.Location = new System.Drawing.Point(13, 16);
|
|
||||||
this.label1.Name = "label1";
|
|
||||||
this.label1.Size = new System.Drawing.Size(111, 17);
|
|
||||||
this.label1.TabIndex = 0;
|
|
||||||
this.label1.Text = "Active document :";
|
|
||||||
//
|
|
||||||
// runButton
|
// runButton
|
||||||
//
|
//
|
||||||
this.runButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.runButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.runButton.Image = global::ExportDXF.Properties.Resources.play;
|
this.runButton.Location = new System.Drawing.Point(790, 13);
|
||||||
this.runButton.Location = new System.Drawing.Point(884, 13);
|
|
||||||
this.runButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.runButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.runButton.Name = "runButton";
|
this.runButton.Name = "runButton";
|
||||||
this.runButton.Size = new System.Drawing.Size(46, 56);
|
this.runButton.Size = new System.Drawing.Size(100, 30);
|
||||||
this.runButton.TabIndex = 11;
|
this.runButton.TabIndex = 11;
|
||||||
|
this.runButton.Text = "Start";
|
||||||
this.runButton.UseVisualStyleBackColor = true;
|
this.runButton.UseVisualStyleBackColor = true;
|
||||||
this.runButton.Click += new System.EventHandler(this.button1_Click);
|
this.runButton.Click += new System.EventHandler(this.button1_Click);
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.label3.AutoSize = true;
|
||||||
this.label3.Location = new System.Drawing.Point(12, 47);
|
this.label3.Location = new System.Drawing.Point(12, 20);
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(112, 17);
|
this.label3.Size = new System.Drawing.Size(112, 17);
|
||||||
this.label3.TabIndex = 2;
|
this.label3.TabIndex = 2;
|
||||||
@@ -99,59 +77,123 @@
|
|||||||
//
|
//
|
||||||
this.viewFlipDeciderBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.viewFlipDeciderBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.viewFlipDeciderBox.FormattingEnabled = true;
|
this.viewFlipDeciderBox.FormattingEnabled = true;
|
||||||
this.viewFlipDeciderBox.Location = new System.Drawing.Point(130, 44);
|
this.viewFlipDeciderBox.Location = new System.Drawing.Point(130, 17);
|
||||||
this.viewFlipDeciderBox.Name = "viewFlipDeciderBox";
|
this.viewFlipDeciderBox.Name = "viewFlipDeciderBox";
|
||||||
this.viewFlipDeciderBox.Size = new System.Drawing.Size(432, 25);
|
this.viewFlipDeciderBox.Size = new System.Drawing.Size(375, 25);
|
||||||
this.viewFlipDeciderBox.TabIndex = 3;
|
this.viewFlipDeciderBox.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// label4
|
// mainTabControl
|
||||||
//
|
//
|
||||||
this.label4.AutoSize = true;
|
this.mainTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
this.label4.Location = new System.Drawing.Point(42, 78);
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
this.label4.Name = "label4";
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.label4.Size = new System.Drawing.Size(82, 17);
|
this.mainTabControl.Controls.Add(this.logEventsTab);
|
||||||
this.label4.TabIndex = 4;
|
this.mainTabControl.Controls.Add(this.bomTab);
|
||||||
this.label4.Text = "Equipment #";
|
this.mainTabControl.Controls.Add(this.cutTemplatesTab);
|
||||||
|
this.mainTabControl.Controls.Add(this.dwgDetailsTab);
|
||||||
|
this.mainTabControl.Location = new System.Drawing.Point(15, 50);
|
||||||
|
this.mainTabControl.Name = "mainTabControl";
|
||||||
|
this.mainTabControl.Padding = new System.Drawing.Point(20, 5);
|
||||||
|
this.mainTabControl.SelectedIndex = 0;
|
||||||
|
this.mainTabControl.Size = new System.Drawing.Size(879, 594);
|
||||||
|
this.mainTabControl.TabIndex = 12;
|
||||||
//
|
//
|
||||||
// equipmentNoBox
|
// logEventsTab
|
||||||
//
|
//
|
||||||
this.equipmentNoBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.logEventsTab.Controls.Add(this.logEventsDataGrid);
|
||||||
this.equipmentNoBox.FormattingEnabled = true;
|
this.logEventsTab.Location = new System.Drawing.Point(4, 30);
|
||||||
this.equipmentNoBox.Location = new System.Drawing.Point(130, 75);
|
this.logEventsTab.Name = "logEventsTab";
|
||||||
this.equipmentNoBox.Name = "equipmentNoBox";
|
this.logEventsTab.Padding = new System.Windows.Forms.Padding(3);
|
||||||
this.equipmentNoBox.Size = new System.Drawing.Size(138, 25);
|
this.logEventsTab.Size = new System.Drawing.Size(690, 484);
|
||||||
this.equipmentNoBox.TabIndex = 5;
|
this.logEventsTab.TabIndex = 0;
|
||||||
|
this.logEventsTab.Text = "Log Events";
|
||||||
|
this.logEventsTab.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// label5
|
// logEventsDataGrid
|
||||||
//
|
//
|
||||||
this.label5.AutoSize = true;
|
this.logEventsDataGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
this.label5.Location = new System.Drawing.Point(314, 78);
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
this.label5.Name = "label5";
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.label5.Size = new System.Drawing.Size(68, 17);
|
this.logEventsDataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.label5.TabIndex = 6;
|
this.logEventsDataGrid.Location = new System.Drawing.Point(6, 6);
|
||||||
this.label5.Text = "Drawing #";
|
this.logEventsDataGrid.Name = "logEventsDataGrid";
|
||||||
|
this.logEventsDataGrid.Size = new System.Drawing.Size(1038, 536);
|
||||||
|
this.logEventsDataGrid.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// drawingNoBox
|
// bomTab
|
||||||
//
|
//
|
||||||
this.drawingNoBox.FormattingEnabled = true;
|
this.bomTab.Controls.Add(this.bomDataGrid);
|
||||||
this.drawingNoBox.Location = new System.Drawing.Point(388, 75);
|
this.bomTab.Location = new System.Drawing.Point(4, 30);
|
||||||
this.drawingNoBox.Name = "drawingNoBox";
|
this.bomTab.Name = "bomTab";
|
||||||
this.drawingNoBox.Size = new System.Drawing.Size(174, 25);
|
this.bomTab.Padding = new System.Windows.Forms.Padding(3);
|
||||||
this.drawingNoBox.TabIndex = 7;
|
this.bomTab.Size = new System.Drawing.Size(690, 484);
|
||||||
|
this.bomTab.TabIndex = 1;
|
||||||
|
this.bomTab.Text = "Bill Of Materials";
|
||||||
|
this.bomTab.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// bomDataGrid
|
||||||
|
//
|
||||||
|
this.bomDataGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.bomDataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.bomDataGrid.Location = new System.Drawing.Point(6, 6);
|
||||||
|
this.bomDataGrid.Name = "bomDataGrid";
|
||||||
|
this.bomDataGrid.Size = new System.Drawing.Size(1038, 536);
|
||||||
|
this.bomDataGrid.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// cutTemplatesTab
|
||||||
|
//
|
||||||
|
this.cutTemplatesTab.Controls.Add(this.cutTemplatesDataGrid);
|
||||||
|
this.cutTemplatesTab.Location = new System.Drawing.Point(4, 30);
|
||||||
|
this.cutTemplatesTab.Name = "cutTemplatesTab";
|
||||||
|
this.cutTemplatesTab.Padding = new System.Windows.Forms.Padding(3);
|
||||||
|
this.cutTemplatesTab.Size = new System.Drawing.Size(690, 484);
|
||||||
|
this.cutTemplatesTab.TabIndex = 3;
|
||||||
|
this.cutTemplatesTab.Text = "Cut Templates";
|
||||||
|
this.cutTemplatesTab.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// cutTemplatesDataGrid
|
||||||
|
//
|
||||||
|
this.cutTemplatesDataGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.cutTemplatesDataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.cutTemplatesDataGrid.Location = new System.Drawing.Point(6, 6);
|
||||||
|
this.cutTemplatesDataGrid.Name = "cutTemplatesDataGrid";
|
||||||
|
this.cutTemplatesDataGrid.Size = new System.Drawing.Size(678, 468);
|
||||||
|
this.cutTemplatesDataGrid.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// dwgDetailsTab
|
||||||
|
//
|
||||||
|
this.dwgDetailsTab.Controls.Add(this.drawingPdfViewer);
|
||||||
|
this.dwgDetailsTab.Location = new System.Drawing.Point(4, 30);
|
||||||
|
this.dwgDetailsTab.Name = "dwgDetailsTab";
|
||||||
|
this.dwgDetailsTab.Padding = new System.Windows.Forms.Padding(3);
|
||||||
|
this.dwgDetailsTab.Size = new System.Drawing.Size(871, 560);
|
||||||
|
this.dwgDetailsTab.TabIndex = 2;
|
||||||
|
this.dwgDetailsTab.Text = "Drawing Details";
|
||||||
|
this.dwgDetailsTab.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// drawingPdfViewer
|
||||||
|
//
|
||||||
|
this.drawingPdfViewer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.drawingPdfViewer.Enabled = true;
|
||||||
|
this.drawingPdfViewer.Location = new System.Drawing.Point(6, 6);
|
||||||
|
this.drawingPdfViewer.Name = "drawingPdfViewer";
|
||||||
|
this.drawingPdfViewer.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("drawingPdfViewer.OcxState")));
|
||||||
|
this.drawingPdfViewer.Size = new System.Drawing.Size(859, 548);
|
||||||
|
this.drawingPdfViewer.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||||
this.ClientSize = new System.Drawing.Size(942, 674);
|
this.ClientSize = new System.Drawing.Size(906, 656);
|
||||||
this.Controls.Add(this.drawingNoBox);
|
this.Controls.Add(this.mainTabControl);
|
||||||
this.Controls.Add(this.equipmentNoBox);
|
|
||||||
this.Controls.Add(this.label5);
|
|
||||||
this.Controls.Add(this.viewFlipDeciderBox);
|
this.Controls.Add(this.viewFlipDeciderBox);
|
||||||
this.Controls.Add(this.label4);
|
|
||||||
this.Controls.Add(this.label3);
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.label1);
|
|
||||||
this.Controls.Add(this.logTextBox);
|
|
||||||
this.Controls.Add(this.activeDocTitleBox);
|
|
||||||
this.Controls.Add(this.runButton);
|
this.Controls.Add(this.runButton);
|
||||||
this.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
@@ -160,6 +202,15 @@
|
|||||||
this.Name = "MainForm";
|
this.Name = "MainForm";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "ExportDXF";
|
this.Text = "ExportDXF";
|
||||||
|
this.mainTabControl.ResumeLayout(false);
|
||||||
|
this.logEventsTab.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.logEventsDataGrid)).EndInit();
|
||||||
|
this.bomTab.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.bomDataGrid)).EndInit();
|
||||||
|
this.cutTemplatesTab.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.cutTemplatesDataGrid)).EndInit();
|
||||||
|
this.dwgDetailsTab.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.drawingPdfViewer)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
@@ -168,15 +219,17 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.Button runButton;
|
private System.Windows.Forms.Button runButton;
|
||||||
private System.Windows.Forms.TextBox activeDocTitleBox;
|
|
||||||
private System.Windows.Forms.RichTextBox logTextBox;
|
|
||||||
private System.Windows.Forms.Label label1;
|
|
||||||
private System.Windows.Forms.Label label3;
|
private System.Windows.Forms.Label label3;
|
||||||
private System.Windows.Forms.ComboBox viewFlipDeciderBox;
|
private System.Windows.Forms.ComboBox viewFlipDeciderBox;
|
||||||
private System.Windows.Forms.Label label4;
|
private System.Windows.Forms.TabControl mainTabControl;
|
||||||
private System.Windows.Forms.ComboBox equipmentNoBox;
|
private System.Windows.Forms.TabPage logEventsTab;
|
||||||
private System.Windows.Forms.Label label5;
|
private System.Windows.Forms.TabPage bomTab;
|
||||||
private System.Windows.Forms.ComboBox drawingNoBox;
|
private System.Windows.Forms.TabPage dwgDetailsTab;
|
||||||
|
private System.Windows.Forms.DataGridView logEventsDataGrid;
|
||||||
|
private AxAcroPDFLib.AxAcroPDF drawingPdfViewer;
|
||||||
|
private System.Windows.Forms.DataGridView bomDataGrid;
|
||||||
|
private System.Windows.Forms.TabPage cutTemplatesTab;
|
||||||
|
private System.Windows.Forms.DataGridView cutTemplatesDataGrid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ using ExportDXF.Extensions;
|
|||||||
using ExportDXF.Models;
|
using ExportDXF.Models;
|
||||||
using ExportDXF.Services;
|
using ExportDXF.Services;
|
||||||
using ExportDXF.ViewFlipDeciders;
|
using ExportDXF.ViewFlipDeciders;
|
||||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -17,7 +17,13 @@ namespace ExportDXF.Forms
|
|||||||
private readonly IDxfExportService _exportService;
|
private readonly IDxfExportService _exportService;
|
||||||
private readonly ICutFabApiClient _apiClient;
|
private readonly ICutFabApiClient _apiClient;
|
||||||
private CancellationTokenSource _cancellationTokenSource;
|
private CancellationTokenSource _cancellationTokenSource;
|
||||||
public MainForm(ISolidWorksService solidWorksService, IDxfExportService exportService, ICutFabApiClient apiClient)
|
private readonly BindingList<LogEvent> _logEvents;
|
||||||
|
private readonly BindingList<BomItem> _bomItems;
|
||||||
|
private readonly BindingList<CutFabApiClient.ApiCutTemplate> _cutTemplates;
|
||||||
|
private readonly int _selectedDrawingId;
|
||||||
|
private readonly string _selectedDrawingNumber;
|
||||||
|
|
||||||
|
public MainForm(ISolidWorksService solidWorksService, IDxfExportService exportService, ICutFabApiClient apiClient, int selectedDrawingId, string selectedDrawingNumber)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_solidWorksService = solidWorksService ??
|
_solidWorksService = solidWorksService ??
|
||||||
@@ -26,7 +32,15 @@ namespace ExportDXF.Forms
|
|||||||
throw new ArgumentNullException(nameof(exportService));
|
throw new ArgumentNullException(nameof(exportService));
|
||||||
_apiClient = apiClient ??
|
_apiClient = apiClient ??
|
||||||
throw new ArgumentNullException(nameof(apiClient));
|
throw new ArgumentNullException(nameof(apiClient));
|
||||||
|
_selectedDrawingId = selectedDrawingId;
|
||||||
|
_selectedDrawingNumber = selectedDrawingNumber ?? throw new ArgumentNullException(nameof(selectedDrawingNumber));
|
||||||
|
_logEvents = new BindingList<LogEvent>();
|
||||||
|
_bomItems = new BindingList<BomItem>();
|
||||||
|
_cutTemplates = new BindingList<CutFabApiClient.ApiCutTemplate>();
|
||||||
InitializeViewFlipDeciders();
|
InitializeViewFlipDeciders();
|
||||||
|
InitializeLogEventsGrid();
|
||||||
|
InitializeBomGrid();
|
||||||
|
InitializeCutTemplatesGrid();
|
||||||
}
|
}
|
||||||
~MainForm()
|
~MainForm()
|
||||||
{
|
{
|
||||||
@@ -51,8 +65,13 @@ namespace ExportDXF.Forms
|
|||||||
LogMessage("Ready", Color.Green);
|
LogMessage("Ready", Color.Green);
|
||||||
UpdateActiveDocumentDisplay();
|
UpdateActiveDocumentDisplay();
|
||||||
runButton.Enabled = true;
|
runButton.Enabled = true;
|
||||||
// Populate equipment and (initial) drawings
|
|
||||||
await PopulateEquipmentAsync();
|
// Load the selected drawing's BOM items
|
||||||
|
LogMessage($"Loading BOM items for drawing {_selectedDrawingNumber}...");
|
||||||
|
await LoadBomItemsForDrawingAsync(_selectedDrawingId);
|
||||||
|
|
||||||
|
// Load cut templates
|
||||||
|
await LoadCutTemplatesAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -61,74 +80,70 @@ namespace ExportDXF.Forms
|
|||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async Task PopulateEquipmentAsync()
|
private async Task LoadBomItemsForDrawingAsync(int drawingId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LogMessage($"Loading equipment from {_apiClient.BaseUrl} ...");
|
_bomItems.Clear();
|
||||||
var list = await _apiClient.GetEquipmentAsync();
|
|
||||||
equipmentNoBox.DisplayMember = nameof(CutFabApiClient.ApiEquipment.EquipmentNumber);
|
|
||||||
equipmentNoBox.ValueMember = nameof(CutFabApiClient.ApiEquipment.ID);
|
|
||||||
equipmentNoBox.DataSource = list;
|
|
||||||
equipmentNoBox.SelectedIndexChanged -= equipmentNoBox_SelectedIndexChanged;
|
|
||||||
equipmentNoBox.SelectedIndexChanged += equipmentNoBox_SelectedIndexChanged;
|
|
||||||
if (list != null && list.Count > 0)
|
|
||||||
{
|
|
||||||
equipmentNoBox.SelectedIndex = 0;
|
|
||||||
await PopulateDrawingsForSelectedEquipmentAsync();
|
|
||||||
LogMessage($"Loaded {list.Count} equipment record(s)", Color.Green);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogMessage("No equipment returned by API", Color.DarkBlue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogMessage($"Failed to load equipment: {ex.Message}", Color.Red);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private async void equipmentNoBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
await PopulateDrawingsForSelectedEquipmentAsync();
|
|
||||||
}
|
|
||||||
private async Task PopulateDrawingsForSelectedEquipmentAsync()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var selected = equipmentNoBox.SelectedItem as CutFabApiClient.ApiEquipment;
|
|
||||||
if (selected == null)
|
|
||||||
{
|
|
||||||
drawingNoBox.DataSource = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store the currently selected drawing number
|
var apiBomItems = await _apiClient.GetBomItemsForDrawingAsync(drawingId);
|
||||||
var currentSelectedDrawing = drawingNoBox.SelectedItem as CutFabApiClient.ApiDrawingSummary;
|
|
||||||
var previousDrawingNumber = currentSelectedDrawing?.DrawingNumber;
|
|
||||||
|
|
||||||
var drawings = await _apiClient.GetDrawingsForEquipmentAsync(selected.ID);
|
foreach (var apiItem in apiBomItems)
|
||||||
drawingNoBox.DisplayMember = nameof(CutFabApiClient.ApiDrawingSummary.DrawingNumber);
|
|
||||||
drawingNoBox.ValueMember = nameof(CutFabApiClient.ApiDrawingSummary.ID);
|
|
||||||
drawingNoBox.DataSource = drawings;
|
|
||||||
|
|
||||||
// Try to restore the previous selection if it exists in the new list
|
|
||||||
if (!string.IsNullOrEmpty(previousDrawingNumber) && drawings.Count > 0)
|
|
||||||
{
|
{
|
||||||
var matchingDrawing = drawings.FirstOrDefault(d => d.DrawingNumber == previousDrawingNumber);
|
var bomItem = new BomItem
|
||||||
if (matchingDrawing != null)
|
|
||||||
{
|
{
|
||||||
drawingNoBox.SelectedItem = matchingDrawing;
|
ID = apiItem.ID,
|
||||||
}
|
ItemNo = apiItem.ItemNo ?? "",
|
||||||
|
PartNo = apiItem.PartNo ?? "",
|
||||||
|
SortOrder = apiItem.SortOrder,
|
||||||
|
Qty = apiItem.Qty,
|
||||||
|
TotalQty = apiItem.TotalQty,
|
||||||
|
Description = apiItem.Description ?? "",
|
||||||
|
PartName = apiItem.PartName ?? "",
|
||||||
|
ConfigurationName = apiItem.ConfigurationName ?? "",
|
||||||
|
Material = apiItem.Material ?? "",
|
||||||
|
DrawingID = apiItem.DrawingID,
|
||||||
|
CutTemplateID = apiItem.CutTemplateID,
|
||||||
|
CutTemplateName = apiItem.CutTemplateName ?? "",
|
||||||
|
Thickness = apiItem.Thickness,
|
||||||
|
KFactor = apiItem.KFactor,
|
||||||
|
DefaultBendRadius = apiItem.DefaultBendRadius
|
||||||
|
};
|
||||||
|
|
||||||
|
_bomItems.Add(bomItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage($"Loaded {drawings.Count} drawing(s) for equipment {selected.EquipmentNumber}");
|
LogMessage($"Loaded {apiBomItems.Count} BOM item(s)", Color.Green);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogMessage($"Failed to load drawings: {ex.Message}", Color.Red);
|
LogMessage($"Failed to load BOM items: {ex.Message}", Color.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task LoadCutTemplatesAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_cutTemplates.Clear();
|
||||||
|
|
||||||
|
LogMessage("Loading cut templates...");
|
||||||
|
|
||||||
|
var apiCutTemplates = await _apiClient.GetCutTemplatesAsync();
|
||||||
|
|
||||||
|
foreach (var template in apiCutTemplates)
|
||||||
|
{
|
||||||
|
_cutTemplates.Add(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogMessage($"Loaded {apiCutTemplates.Count} cut template(s)", Color.Green);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogMessage($"Failed to load cut templates: {ex.Message}", Color.Red);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void InitializeViewFlipDeciders()
|
private void InitializeViewFlipDeciders()
|
||||||
{
|
{
|
||||||
var items = ViewFlipDeciderFactory.GetAvailableDeciders()
|
var items = ViewFlipDeciderFactory.GetAvailableDeciders()
|
||||||
@@ -148,6 +163,187 @@ namespace ExportDXF.Forms
|
|||||||
viewFlipDeciderBox.DataSource = items;
|
viewFlipDeciderBox.DataSource = items;
|
||||||
viewFlipDeciderBox.DisplayMember = "Name";
|
viewFlipDeciderBox.DisplayMember = "Name";
|
||||||
}
|
}
|
||||||
|
private void InitializeLogEventsGrid()
|
||||||
|
{
|
||||||
|
// Clear any existing columns first
|
||||||
|
logEventsDataGrid.Columns.Clear();
|
||||||
|
|
||||||
|
// Configure grid settings
|
||||||
|
logEventsDataGrid.AutoGenerateColumns = false;
|
||||||
|
logEventsDataGrid.AllowUserToAddRows = false;
|
||||||
|
logEventsDataGrid.AllowUserToDeleteRows = false;
|
||||||
|
logEventsDataGrid.ReadOnly = true;
|
||||||
|
logEventsDataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
|
||||||
|
// Add columns
|
||||||
|
logEventsDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(LogEvent.Time),
|
||||||
|
HeaderText = "Time",
|
||||||
|
Width = 80,
|
||||||
|
DefaultCellStyle = new DataGridViewCellStyle { Format = "HH:mm:ss" }
|
||||||
|
});
|
||||||
|
|
||||||
|
logEventsDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(LogEvent.Level),
|
||||||
|
HeaderText = "Level",
|
||||||
|
Width = 70
|
||||||
|
});
|
||||||
|
|
||||||
|
logEventsDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(LogEvent.Message),
|
||||||
|
HeaderText = "Message",
|
||||||
|
AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set the data source AFTER adding columns
|
||||||
|
logEventsDataGrid.DataSource = _logEvents;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeBomGrid()
|
||||||
|
{
|
||||||
|
// Clear any existing columns first
|
||||||
|
bomDataGrid.Columns.Clear();
|
||||||
|
|
||||||
|
// Configure grid settings
|
||||||
|
bomDataGrid.AutoGenerateColumns = false;
|
||||||
|
bomDataGrid.AllowUserToAddRows = false;
|
||||||
|
bomDataGrid.AllowUserToDeleteRows = false;
|
||||||
|
bomDataGrid.ReadOnly = true;
|
||||||
|
bomDataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
|
||||||
|
// Add columns
|
||||||
|
bomDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(BomItem.ItemNo),
|
||||||
|
HeaderText = "Item #",
|
||||||
|
Width = 60
|
||||||
|
});
|
||||||
|
|
||||||
|
bomDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(BomItem.PartNo),
|
||||||
|
HeaderText = "Part #",
|
||||||
|
Width = 100
|
||||||
|
});
|
||||||
|
|
||||||
|
bomDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(BomItem.Qty),
|
||||||
|
HeaderText = "Qty",
|
||||||
|
Width = 50
|
||||||
|
});
|
||||||
|
|
||||||
|
bomDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(BomItem.Description),
|
||||||
|
HeaderText = "Description",
|
||||||
|
Width = 200
|
||||||
|
});
|
||||||
|
|
||||||
|
bomDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(BomItem.PartName),
|
||||||
|
HeaderText = "Part Name",
|
||||||
|
Width = 150
|
||||||
|
});
|
||||||
|
|
||||||
|
bomDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(BomItem.ConfigurationName),
|
||||||
|
HeaderText = "Configuration",
|
||||||
|
Width = 120
|
||||||
|
});
|
||||||
|
|
||||||
|
bomDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(BomItem.Material),
|
||||||
|
HeaderText = "Material",
|
||||||
|
Width = 120
|
||||||
|
});
|
||||||
|
|
||||||
|
bomDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(BomItem.CutTemplateName),
|
||||||
|
HeaderText = "Cut Template",
|
||||||
|
Width = 120
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set the data source AFTER adding columns
|
||||||
|
bomDataGrid.DataSource = _bomItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeCutTemplatesGrid()
|
||||||
|
{
|
||||||
|
// Clear any existing columns first
|
||||||
|
cutTemplatesDataGrid.Columns.Clear();
|
||||||
|
|
||||||
|
// Configure grid settings
|
||||||
|
cutTemplatesDataGrid.AutoGenerateColumns = false;
|
||||||
|
cutTemplatesDataGrid.AllowUserToAddRows = false;
|
||||||
|
cutTemplatesDataGrid.AllowUserToDeleteRows = false;
|
||||||
|
cutTemplatesDataGrid.ReadOnly = true;
|
||||||
|
cutTemplatesDataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
|
||||||
|
// Add columns
|
||||||
|
cutTemplatesDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(CutFabApiClient.ApiCutTemplate.Name),
|
||||||
|
HeaderText = "Name",
|
||||||
|
Width = 200
|
||||||
|
});
|
||||||
|
|
||||||
|
cutTemplatesDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(CutFabApiClient.ApiCutTemplate.Material),
|
||||||
|
HeaderText = "Material",
|
||||||
|
Width = 120
|
||||||
|
});
|
||||||
|
|
||||||
|
cutTemplatesDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(CutFabApiClient.ApiCutTemplate.Thickness),
|
||||||
|
HeaderText = "Thickness",
|
||||||
|
Width = 80,
|
||||||
|
DefaultCellStyle = new DataGridViewCellStyle { Format = "0.##" }
|
||||||
|
});
|
||||||
|
|
||||||
|
cutTemplatesDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(CutFabApiClient.ApiCutTemplate.KFactor),
|
||||||
|
HeaderText = "K-Factor",
|
||||||
|
Width = 80,
|
||||||
|
DefaultCellStyle = new DataGridViewCellStyle { Format = "0.####" }
|
||||||
|
});
|
||||||
|
|
||||||
|
cutTemplatesDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(CutFabApiClient.ApiCutTemplate.DefaultBendRadius),
|
||||||
|
HeaderText = "Bend Radius",
|
||||||
|
Width = 90,
|
||||||
|
DefaultCellStyle = new DataGridViewCellStyle { Format = "0.##" }
|
||||||
|
});
|
||||||
|
|
||||||
|
cutTemplatesDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(CutFabApiClient.ApiCutTemplate.Version),
|
||||||
|
HeaderText = "Version",
|
||||||
|
Width = 70
|
||||||
|
});
|
||||||
|
|
||||||
|
cutTemplatesDataGrid.Columns.Add(new DataGridViewTextBoxColumn
|
||||||
|
{
|
||||||
|
DataPropertyName = nameof(CutFabApiClient.ApiCutTemplate.Description),
|
||||||
|
HeaderText = "Description",
|
||||||
|
AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set the data source AFTER adding columns
|
||||||
|
cutTemplatesDataGrid.DataSource = _cutTemplates;
|
||||||
|
}
|
||||||
|
|
||||||
private async void button1_Click(object sender, EventArgs e)
|
private async void button1_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_cancellationTokenSource != null)
|
if (_cancellationTokenSource != null)
|
||||||
@@ -173,14 +369,12 @@ namespace ExportDXF.Forms
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var viewFlipDecider = GetSelectedViewFlipDecider();
|
var viewFlipDecider = GetSelectedViewFlipDecider();
|
||||||
var drawingNumberText = drawingNoBox.Text?.Trim();
|
|
||||||
var selectedEquipment = equipmentNoBox.SelectedItem as CutFabApiClient.ApiEquipment;
|
|
||||||
var exportContext = new ExportContext
|
var exportContext = new ExportContext
|
||||||
{
|
{
|
||||||
ActiveDocument = activeDoc,
|
ActiveDocument = activeDoc,
|
||||||
ViewFlipDecider = viewFlipDecider,
|
ViewFlipDecider = viewFlipDecider,
|
||||||
FilePrefix = drawingNumberText,
|
FilePrefix = _selectedDrawingNumber,
|
||||||
EquipmentId = selectedEquipment?.ID,
|
EquipmentId = null, // Not needed for export
|
||||||
CancellationToken = token,
|
CancellationToken = token,
|
||||||
ProgressCallback = LogMessage
|
ProgressCallback = LogMessage
|
||||||
};
|
};
|
||||||
@@ -216,17 +410,11 @@ namespace ExportDXF.Forms
|
|||||||
}
|
}
|
||||||
private void UpdateUIForExportStart()
|
private void UpdateUIForExportStart()
|
||||||
{
|
{
|
||||||
activeDocTitleBox.Enabled = false;
|
|
||||||
viewFlipDeciderBox.Enabled = false;
|
viewFlipDeciderBox.Enabled = false;
|
||||||
runButton.Image = Properties.Resources.stop_alt;
|
runButton.Image = Properties.Resources.stop_alt;
|
||||||
if (logTextBox.TextLength != 0)
|
|
||||||
{
|
|
||||||
logTextBox.AppendText("\n\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void UpdateUIForExportComplete()
|
private void UpdateUIForExportComplete()
|
||||||
{
|
{
|
||||||
activeDocTitleBox.Enabled = true;
|
|
||||||
viewFlipDeciderBox.Enabled = true;
|
viewFlipDeciderBox.Enabled = true;
|
||||||
runButton.Image = Properties.Resources.play;
|
runButton.Image = Properties.Resources.play;
|
||||||
runButton.Enabled = true;
|
runButton.Enabled = true;
|
||||||
@@ -239,50 +427,52 @@ namespace ExportDXF.Forms
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UpdateActiveDocumentDisplay();
|
UpdateActiveDocumentDisplay();
|
||||||
UpdatePrefixFromActiveDocument();
|
|
||||||
}
|
}
|
||||||
private void UpdateActiveDocumentDisplay()
|
private void UpdateActiveDocumentDisplay()
|
||||||
{
|
{
|
||||||
var activeDoc = _solidWorksService.GetActiveDocument();
|
var activeDoc = _solidWorksService.GetActiveDocument();
|
||||||
activeDocTitleBox.Text = activeDoc?.Title ?? "<No Document Open>";
|
var docTitle = activeDoc?.Title ?? "No Document Open";
|
||||||
}
|
this.Text = $"ExportDXF - {docTitle}";
|
||||||
private void UpdatePrefixFromActiveDocument()
|
|
||||||
{
|
|
||||||
var activeDoc = _solidWorksService.GetActiveDocument();
|
|
||||||
|
|
||||||
if (activeDoc == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (activeDoc.DocumentType == DocumentType.Drawing)
|
|
||||||
{
|
|
||||||
var drawingInfo = DrawingInfo.Parse(activeDoc.Title);
|
|
||||||
|
|
||||||
if (drawingInfo != null)
|
|
||||||
{
|
|
||||||
drawingNoBox.Text = drawingInfo.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void activeDocTitleBox_TextChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
UpdatePrefixFromActiveDocument();
|
|
||||||
}
|
}
|
||||||
private void LogMessage(string message, Color? color = null)
|
private void LogMessage(string message, Color? color = null)
|
||||||
|
{
|
||||||
|
var level = color.HasValue && color.Value == Color.Red ? LogLevel.Error :
|
||||||
|
color.HasValue && color.Value == Color.Green ? LogLevel.Info :
|
||||||
|
color.HasValue && color.Value == Color.DarkBlue ? LogLevel.Warning :
|
||||||
|
LogLevel.Info;
|
||||||
|
|
||||||
|
AddLogEvent(level, LogAction.Start, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddLogEvent(LogLevel level, LogAction action, string message, string equipment = "", string drawing = "", string part = "", string target = "", string result = "OK", int durationMs = 0)
|
||||||
{
|
{
|
||||||
if (InvokeRequired)
|
if (InvokeRequired)
|
||||||
{
|
{
|
||||||
Invoke(new Action(() => LogMessage(message, color)));
|
Invoke(new Action(() => AddLogEvent(level, action, message, equipment, drawing, part, target, result, durationMs)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (color.HasValue)
|
|
||||||
|
var logEvent = new LogEvent
|
||||||
{
|
{
|
||||||
logTextBox.AppendText(message + System.Environment.NewLine, color.Value);
|
Time = DateTime.Now,
|
||||||
}
|
Level = level,
|
||||||
else
|
Action = action,
|
||||||
|
Message = message,
|
||||||
|
Equipment = equipment,
|
||||||
|
Drawing = drawing,
|
||||||
|
Part = part,
|
||||||
|
Target = target,
|
||||||
|
Result = result,
|
||||||
|
DurationMs = durationMs
|
||||||
|
};
|
||||||
|
|
||||||
|
_logEvents.Add(logEvent);
|
||||||
|
|
||||||
|
// Auto-scroll to the last row
|
||||||
|
if (logEventsDataGrid.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
logTextBox.AppendText(message + System.Environment.NewLine);
|
logEventsDataGrid.FirstDisplayedScrollingRowIndex = logEventsDataGrid.Rows.Count - 1;
|
||||||
}
|
}
|
||||||
logTextBox.ScrollToCaret();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,4 +117,12 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<data name="drawingPdfViewer.OcxState" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||||
|
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0
|
||||||
|
ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAIQAAAAIB
|
||||||
|
AAAAAQAAAAAAAAAAAAAAAAwAAAAADgAASGsAANA3AAAL
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Reference in New Issue
Block a user