namespace LB_VisionFlowNode
|
{
|
public partial class FlowNodeEditor : UserControl
|
{
|
public FlowNodeEditor()
|
{
|
InitializeComponent();
|
}
|
|
private void btnRun_Click(object sender, EventArgs e)
|
{
|
pnlMain.Run(out _);
|
}
|
|
private void btnClear_Click(object sender, EventArgs e)
|
{
|
pnlMain.ClearNodes();
|
}
|
|
private void btnLoad_Click(object sender, EventArgs e)
|
{
|
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
{
|
// 设置文件对话框的属性
|
openFileDialog.Multiselect = false; // 不允许多选
|
// 设置文件过滤器,支持多种文件类型
|
openFileDialog.Filter = "Ini Files (*.json)|*.json|All Files (*.*)|*.*";
|
// 显示文件对话框
|
DialogResult result = openFileDialog.ShowDialog();
|
|
// 处理对话框返回结果
|
if (result == DialogResult.OK)
|
{
|
// 获取用户选择的文件名
|
string[] selectedFiles = openFileDialog.FileNames;
|
if (selectedFiles.Length > 0)
|
pnlMain.Load(selectedFiles[0]);
|
}
|
}
|
}
|
|
private void btnSave_Click(object sender, EventArgs e)
|
{
|
// 创建 SaveFileDialog 实例
|
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
{
|
// 设置对话框标题
|
saveFileDialog.Title = "保存文件";
|
|
// 设置默认路径
|
saveFileDialog.InitialDirectory = Application.StartupPath;
|
|
// 设置文件类型过滤器
|
saveFileDialog.Filter = "文本文件 (*.json)|*.json|所有文件 (*.*)|*.*";
|
|
// 设置默认文件名
|
saveFileDialog.FileName = "panel.json";
|
|
// 显示对话框并检查用户是否点击了保存按钮
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
{
|
// 获取用户选择的文件路径
|
string fullPath = saveFileDialog.FileName;
|
pnlMain.Save(fullPath);
|
}
|
}
|
|
|
}
|
}
|
}
|