分析模块重新调整
This commit is contained in:
@@ -11,18 +11,18 @@ namespace CPSO.Forms._92_Knowledge
|
||||
{
|
||||
public partial class FrmEditProcessingJobs : Form
|
||||
{
|
||||
// Variables
|
||||
private readonly Controller _controller;
|
||||
private Controller Self { get; }
|
||||
private bool _modified;
|
||||
|
||||
// Constructors
|
||||
public FrmEditProcessingJobs(Controller controller)
|
||||
public FrmEditProcessingJobs(Controller self)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Text = @"分析模型查看";
|
||||
dgvCommands.DataBindingComplete += DataBindingComplete;
|
||||
|
||||
_controller = controller;
|
||||
Self = self;
|
||||
_modified = false;
|
||||
}
|
||||
|
||||
@@ -41,10 +41,6 @@ namespace CPSO.Forms._92_Knowledge
|
||||
dgvCommands.Rows[e.RowIndex].DefaultCellStyle.BackColor = green;
|
||||
}
|
||||
|
||||
private void btnReorganize_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btnClearAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
dgvCommands.DataSource = null;
|
||||
@@ -63,10 +59,10 @@ namespace CPSO.Forms._92_Knowledge
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
if (_modified && dgvCommands.DataSource is BindingSource source
|
||||
&& source.DataSource is List<ViewToolPosition> list)
|
||||
&& source.DataSource is List<ViewProcessingJob> list)
|
||||
{
|
||||
_controller.ToolPositions.Clear();
|
||||
_controller.ToolPositions.AddRange(list);
|
||||
Self.ProcessingJobs.Clear();
|
||||
Self.ProcessingJobs.AddRange(list);
|
||||
_modified = false;
|
||||
}
|
||||
|
||||
@@ -85,9 +81,9 @@ namespace CPSO.Forms._92_Knowledge
|
||||
{
|
||||
_viewProcessingJobs.Clear();
|
||||
|
||||
if (_controller.ProcessingJobs.Count > 0)
|
||||
if (Self.ProcessingJobs.Count > 0)
|
||||
{
|
||||
_viewProcessingJobs.AddRange(_controller.ProcessingJobs);
|
||||
_viewProcessingJobs.AddRange(Self.ProcessingJobs);
|
||||
}
|
||||
|
||||
SetBinding();
|
||||
@@ -95,8 +91,11 @@ namespace CPSO.Forms._92_Knowledge
|
||||
|
||||
private void SetBinding()
|
||||
{
|
||||
BindingSource binding = new BindingSource();
|
||||
binding.DataSource = _viewProcessingJobs;
|
||||
BindingSource binding = new BindingSource()
|
||||
{
|
||||
DataSource = _viewProcessingJobs
|
||||
};
|
||||
|
||||
dgvCommands.DataSource = binding;
|
||||
}
|
||||
|
||||
@@ -124,12 +123,62 @@ namespace CPSO.Forms._92_Knowledge
|
||||
|
||||
private void tsmiOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void tsmiSaveAs_Click(object sender, EventArgs e)
|
||||
{
|
||||
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;
|
||||
|
||||
var jobs = Self.ProcessingJobs.Select(x => x.Base).ToList();
|
||||
|
||||
// 保存到数据库
|
||||
KnowledgeTools.SaveDatabase(fullPath, jobs);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExceptionTools.Show(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user