using LB_VisionControls;
|
using LB_VisionProcesses;
|
using LB_VisionProcesses.Forms;
|
using System;
|
using System.Collections.Concurrent;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace LB_SmartVision.Forms.Pages.SettingPage
|
{
|
public partial class CsvPage : UserControl
|
{
|
public CsvPage()
|
{
|
InitializeComponent();
|
|
btnSave.Click += (sender, e) =>
|
{
|
if (!VisionForm.SaveAllCsv())
|
MessageBox.Show("!!!保存失败!!!", "异常");
|
else
|
MessageBox.Show("保存成功!");
|
};
|
|
btnDel.Click += (sender, e) =>
|
{
|
foreach (var control in pnlLayout.Controls)
|
{
|
if (control is CsvSettingControl csvSettingControl
|
&& csvSettingControl.IsSelected)
|
{
|
var item = GlobalVar.dicCsvSetting.FirstOrDefault(x => x.Value.ProcessName == csvSettingControl.Title);
|
if (item.Value.Others == csvSettingControl.Others)
|
GlobalVar.dicCsvSetting.TryRemove(item.Key, out _);
|
}
|
}
|
this.Invalidate();
|
};
|
}
|
|
private void CsvPage_SizeChanged(object sender, EventArgs e) => CsvPage_VisibleChanged(sender, e);
|
|
private void CsvPage_VisibleChanged(object sender, EventArgs e)
|
{
|
this.pnlLayout.Controls.Clear();
|
|
var sortedKeys = GlobalVar.dicCsvSetting.Keys
|
.OrderBy(k => k, new NaturalStringComparer())
|
.ToList();
|
|
int index = 0;
|
foreach (var key in sortedKeys)
|
{
|
string ProcessesName = key;
|
|
CsvSettingControl control = new CsvSettingControl(GlobalVar.dicCsvSetting[ProcessesName]);
|
control.Size = new Size(this.pnlLayout.Size.Width, control.Size.Height);
|
control.Location = new Point(0, control.Size.Height * index);
|
this.pnlLayout.Controls.Add(control);
|
index++;
|
}
|
}
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
{
|
GlobalVar.dicCsvSetting.TryAdd($"{GlobalVar.dicCsvSetting.Count}", new CsvSetting());
|
|
CsvPage_VisibleChanged(sender, e);
|
}
|
}
|
|
[Serializable]
|
public class CsvSetting
|
{
|
public string ProcessName { get; set; } = string.Empty;
|
|
public List<string> Others { get; set; } = new List<string>();
|
|
public CsvSetting() { }
|
}
|
}
|