60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using PCHMI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Drawing.Design;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms.Design;
|
|
|
|
namespace CowainHmi.UIEditor
|
|
{
|
|
public class UIAxisConfigEdit : UITypeEditor
|
|
{
|
|
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
|
{
|
|
return UITypeEditorEditStyle.Modal;
|
|
}
|
|
|
|
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
|
{
|
|
IWindowsFormsEditorService windowsFormsEditorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
|
|
if (windowsFormsEditorService != null)
|
|
{
|
|
if (value is string fileName)
|
|
{
|
|
if (!string.IsNullOrEmpty(fileName))
|
|
{
|
|
string text = new FILE().GET_RELEASE_DIR() + $"\\DATA\\{fileName}.csv";
|
|
string directoryName = Path.GetDirectoryName(text);
|
|
if (!Directory.Exists(directoryName) && directoryName.Length > 0)
|
|
{
|
|
Directory.CreateDirectory(directoryName);
|
|
}
|
|
if (!File.Exists(text))
|
|
{
|
|
//不存在文件,创建个默认文件
|
|
List<string> data = new List<string>();
|
|
data.Add("轴号");
|
|
data.Add("轴名称");
|
|
for (int i = 0; i < 99; i++)
|
|
{
|
|
data.Add($"位置名称{i}");
|
|
}
|
|
new JUDGE_DIR().CreateCsv(text, data.ToArray());
|
|
}
|
|
Process process = new Process();
|
|
process.StartInfo.FileName = text;
|
|
process.Start();
|
|
}
|
|
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
}
|
|
}
|