|
using LB_VisionProcesses.Cameras;
|
using LB_VisionProcesses.Communicators;
|
using LB_VisionProcesses;
|
using LB_VisionProcesses.Alogrithms.Halcon;
|
using LB_VisionProcesses.Communicators;
|
using LB_SmartVision.Tool;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using ReaLTaiizor.Forms;
|
using RJCP.IO.Ports;
|
using System;
|
using System.Collections.Concurrent;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Data.SqlClient;
|
using System.Drawing;
|
using System.IO.Ports;
|
using System.Linq;
|
using System.Text;
|
using System.Text.RegularExpressions;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
namespace LB_SmartVision.Forms.Pages
|
{
|
public partial class CreateProductForm : MaterialForm
|
{
|
public bool bCreate = false;
|
|
public CreateProductForm()
|
{
|
InitializeComponent();
|
// 禁止修改窗口大小
|
this.FormBorderStyle = FormBorderStyle.FixedDialog;
|
|
uiButtonCreate.Enabled = false;
|
|
btnDel.Click += (s, e) =>
|
{
|
LB_SmartVision.Tool.Tool.ReadStringConfig("产品列表", out string Products);
|
List<string> lstProduct = (Products.Split(',')).ToList();
|
|
if (string.IsNullOrEmpty(uiComboBoxProducts.Text)
|
|| lstProduct.Count <= 1 || !lstProduct.Contains(uiComboBoxProducts.Text))
|
return;
|
|
lstProduct.Remove(uiComboBoxProducts.Text);
|
LB_SmartVision.Tool.Tool.WriteConfig("产品列表", string.Join(",", lstProduct));
|
Directory.Delete(Path.Combine(GlobalVar.strApplicationPath + "所有产品\\", uiComboBoxProducts.Text), true);
|
this.Close();
|
};
|
}
|
|
private void uiButtonTest_Click(object sender, EventArgs e)
|
{
|
uiButtonCreate.Enabled = false;
|
|
LB_SmartVision.Tool.Tool.ReadStringConfig("产品列表", out string Products);
|
List<string> lstProduct = (Products.Split(',')).ToList();
|
if (lstProduct.Contains(uiTextBoxProductName.Text))
|
MessageBox.Show($"产品[{uiTextBoxProductName.Text}]已存在!", "异常");
|
else
|
uiButtonCreate.Enabled = true;
|
}
|
|
private void uiButtonCreate_Click(object sender, EventArgs e)
|
{
|
if (LB_SmartVision.Tool.Tool.CopyDirectory(Path.Combine(GlobalVar.strApplicationPath + "所有产品\\", GlobalVar.strProductName)
|
, Path.Combine(GlobalVar.strApplicationPath + "所有产品\\", uiTextBoxProductName.Text)))
|
{
|
LB_SmartVision.Tool.Tool.ReadStringConfig("产品列表", out string Products);
|
List<string> lstProduct = (Products.Split(',')).ToList();
|
lstProduct.Add(uiTextBoxProductName.Text);
|
LB_SmartVision.Tool.Tool.WriteConfig("产品列表", string.Join(",", lstProduct));
|
MessageBox.Show($"创建产品[{uiTextBoxProductName.Text}]成功!");
|
this.Close();
|
}
|
}
|
|
private void uiButtonCancel_Click(object sender, EventArgs e)
|
{
|
bCreate = false;
|
this.Close();
|
}
|
|
private void uiComboBoxProducts_MouseClick(object sender, MouseEventArgs e)
|
{
|
uiButtonCreate.Enabled = false;
|
|
uiComboBoxProducts.Items.Clear();
|
uiComboBoxProducts.Items.Add("无");
|
|
LB_SmartVision.Tool.Tool.ReadStringConfig("产品列表", out string Products);
|
List<string> lstProduct = (Products.Split(',')).ToList();
|
foreach (string DatabaseName in lstProduct)
|
{
|
uiComboBoxProducts.Items.Add(DatabaseName);
|
}
|
}
|
|
private void uiTextBoxProductName_TextChanged(object sender, EventArgs e)
|
{
|
uiButtonCreate.Enabled = false;
|
}
|
}
|
}
|