2026-03-25 18:20:24 +08:00
|
|
|
|
using CaeGlobals;
|
|
|
|
|
|
using CaeKnowledge;
|
|
|
|
|
|
using CaeKnowledge.View;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CPSO.Forms._92_Knowledge
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class FrmEditProcessingJobs : Form
|
|
|
|
|
|
{
|
2026-03-26 06:50:22 +08:00
|
|
|
|
private Controller Self { get; }
|
2026-03-25 18:20:24 +08:00
|
|
|
|
private bool _modified;
|
|
|
|
|
|
|
|
|
|
|
|
// Constructors
|
2026-03-26 06:50:22 +08:00
|
|
|
|
public FrmEditProcessingJobs(Controller self)
|
2026-03-25 18:20:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
2026-03-26 06:50:22 +08:00
|
|
|
|
Text = @"分析模型查看";
|
2026-03-25 18:20:24 +08:00
|
|
|
|
dgvCommands.DataBindingComplete += DataBindingComplete;
|
|
|
|
|
|
|
2026-03-26 06:50:22 +08:00
|
|
|
|
Self = self;
|
2026-03-25 18:20:24 +08:00
|
|
|
|
_modified = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void tsmiClose_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void dgvCommands_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Color blue = Color.FromArgb(225, 245, 255);
|
|
|
|
|
|
Color green = Color.FromArgb(235, 255, 235);
|
|
|
|
|
|
// Color yellow = Color.FromArgb(255, 255, 205);
|
|
|
|
|
|
// Color red = Color.FromArgb(255, 235, 215);
|
|
|
|
|
|
|
|
|
|
|
|
dgvCommands.Rows[e.RowIndex].DefaultCellStyle.BackColor = green;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnClearAll_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
dgvCommands.DataSource = null;
|
|
|
|
|
|
|
|
|
|
|
|
_viewProcessingJobs.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
SetBinding();
|
|
|
|
|
|
|
|
|
|
|
|
_modified = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
|
|
|
|
|
|
|
if (_modified && dgvCommands.DataSource is BindingSource source
|
2026-03-26 06:50:22 +08:00
|
|
|
|
&& source.DataSource is List<ViewProcessingJob> list)
|
2026-03-25 18:20:24 +08:00
|
|
|
|
{
|
2026-03-26 06:50:22 +08:00
|
|
|
|
Self.ProcessingJobs.Clear();
|
|
|
|
|
|
Self.ProcessingJobs.AddRange(list);
|
2026-03-25 18:20:24 +08:00
|
|
|
|
_modified = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
ExceptionTools.Show(this, ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private readonly List<ViewProcessingJob> _viewProcessingJobs = new List<ViewProcessingJob>();
|
|
|
|
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
|
|
public void PrepareForm()
|
|
|
|
|
|
{
|
|
|
|
|
|
_viewProcessingJobs.Clear();
|
|
|
|
|
|
|
2026-03-26 06:50:22 +08:00
|
|
|
|
if (Self.ProcessingJobs.Count > 0)
|
2026-03-25 18:20:24 +08:00
|
|
|
|
{
|
2026-03-26 06:50:22 +08:00
|
|
|
|
_viewProcessingJobs.AddRange(Self.ProcessingJobs);
|
2026-03-25 18:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetBinding();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetBinding()
|
|
|
|
|
|
{
|
2026-03-26 06:50:22 +08:00
|
|
|
|
BindingSource binding = new BindingSource()
|
|
|
|
|
|
{
|
|
|
|
|
|
DataSource = _viewProcessingJobs
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-03-25 18:20:24 +08:00
|
|
|
|
dgvCommands.DataSource = binding;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Source - https://stackoverflow.com/a/24784960
|
|
|
|
|
|
// Posted by TFischer
|
|
|
|
|
|
private void DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Loops through each row in the DataGridView, and adds the
|
|
|
|
|
|
// row number to the header
|
|
|
|
|
|
foreach (DataGridViewRow dGVRow in dgvCommands.Rows)
|
|
|
|
|
|
{
|
|
|
|
|
|
dGVRow.HeaderCell.Value = $"{dGVRow.Index + 1}";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This resizes the width of the row headers to fit the numbers
|
|
|
|
|
|
dgvCommands.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void FrmEditToolPositions_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
dgvCommands.AllowUserToAddRows = false;
|
|
|
|
|
|
dgvCommands.AllowUserToDeleteRows = false;
|
|
|
|
|
|
dgvCommands.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void tsmiOpen_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2026-03-26 06:50:22 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using (OpenFileDialog ofd = new OpenFileDialog())
|
|
|
|
|
|
{
|
|
|
|
|
|
ofd.Filter = "计算任务列表 (*.wdb)|*.wdb|All Files (*.*)|*.*";
|
|
|
|
|
|
ofd.FilterIndex = 1;
|
|
|
|
|
|
ofd.RestoreDirectory = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (ofd.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 1. 从数据读取
|
|
|
|
|
|
var list = KnowledgeTools.LoadDatabase(ofd.FileName);
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 保存到Controller
|
|
|
|
|
|
Self.ProcessingJobs.Clear();
|
|
|
|
|
|
list.ForEach(x =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Self.ProcessingJobs.Add(new ViewProcessingJob(x));
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 现实到dgv
|
|
|
|
|
|
PrepareForm();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
ExceptionTools.Show(ex);
|
|
|
|
|
|
}
|
2026-03-25 18:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void tsmiSaveAs_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2026-03-26 06:50:22 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using (SaveFileDialog sfd = new SaveFileDialog())
|
|
|
|
|
|
{
|
|
|
|
|
|
sfd.Filter = "计算任务列表 (*.wdb)|*.wdb|All Files (*.*)|*.*";
|
|
|
|
|
|
sfd.FilterIndex = 1;
|
|
|
|
|
|
sfd.RestoreDirectory = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (sfd.ShowDialog() == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
var fullPath = sfd.FileName;
|
2026-03-25 18:20:24 +08:00
|
|
|
|
|
2026-03-26 06:50:22 +08:00
|
|
|
|
var jobs = Self.ProcessingJobs.Select(x => x.Base).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
// 保存到数据库
|
|
|
|
|
|
KnowledgeTools.SaveDatabase(fullPath, jobs);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
ExceptionTools.Show(ex);
|
|
|
|
|
|
}
|
2026-03-25 18:20:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|