2021-12-14 18:39:55 +08:00
|
|
|
|
using System;
|
|
|
|
|
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;
|
|
|
|
|
using System.IO;
|
2021-12-22 18:07:40 +08:00
|
|
|
|
using System.Threading;
|
2021-12-14 18:39:55 +08:00
|
|
|
|
|
|
|
|
|
namespace mainProgram
|
|
|
|
|
{
|
|
|
|
|
//子窗口向父窗口传递参数:https://www.cnblogs.com/xcong/p/3386085.html
|
2022-01-14 11:56:12 +08:00
|
|
|
|
public delegate void transferProjectManagerDelegate(ProjectManager value);//申明委托
|
2021-12-14 18:39:55 +08:00
|
|
|
|
|
|
|
|
|
public partial class NewProjectWindow : Form
|
|
|
|
|
{
|
|
|
|
|
public NewProjectWindow()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public event transferProjectManagerDelegate TransferEvent;//申明事件
|
|
|
|
|
|
|
|
|
|
private void CreateProjectBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//获取数据
|
|
|
|
|
//string currPath = Application.StartupPath;
|
2022-01-14 11:56:12 +08:00
|
|
|
|
string dataPath = DataPathTextBox.Text;
|
2021-12-14 18:39:55 +08:00
|
|
|
|
string projectPath = ProjectPathTextBox.Text;
|
2022-01-14 11:56:12 +08:00
|
|
|
|
string calFilePath = CalFilePathTextBox.Text;
|
2021-12-14 18:39:55 +08:00
|
|
|
|
|
2022-06-16 15:45:54 +08:00
|
|
|
|
//当创建工程时,工程文件夹必须为空
|
|
|
|
|
DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(projectPath));
|
|
|
|
|
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos();
|
|
|
|
|
if (fileinfo.Length != 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "工程文件夹中有内容", "提示");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-14 18:39:55 +08:00
|
|
|
|
if (dataPath != null && dataPath.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "数据文件夹路径不能为空", "提示");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (projectPath != null && projectPath.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "工程路径不能为空", "提示");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-01-14 11:56:12 +08:00
|
|
|
|
if (calFilePath != null && calFilePath.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "定标路径不能为空", "提示");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-12-14 18:39:55 +08:00
|
|
|
|
|
2022-06-16 13:26:55 +08:00
|
|
|
|
//创建工程
|
|
|
|
|
ProjectManager projectManager = new ProjectManager(projectPath);
|
|
|
|
|
int value = projectManager.CreateProject(calFilePath, dataPath);
|
2021-12-16 18:40:51 +08:00
|
|
|
|
|
2022-06-16 13:26:55 +08:00
|
|
|
|
switch (value)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
TransferEvent(projectManager);//触发事件
|
|
|
|
|
|
|
|
|
|
MessageBox.Show(this, "工程创建成功!", "提示");
|
|
|
|
|
|
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
|
|
Close();//创建工程完成后,关闭窗口
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
MessageBox.Show(this, "定标文件夹有错!", "提示");
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
MessageBox.Show(this, "数据文件夹有错!", "提示");
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
MessageBox.Show(this, "工程路径有错!", "提示");
|
|
|
|
|
break;
|
|
|
|
|
default: /* 可选的 */
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-03-15 10:19:53 +08:00
|
|
|
|
|
2022-06-16 13:26:55 +08:00
|
|
|
|
|
2021-12-14 18:39:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SelectDataPathBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
FolderBrowserDialog dialog = new FolderBrowserDialog();
|
|
|
|
|
dialog.Description = "请选择数据所在文件夹";
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(dialog.SelectedPath))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "文件夹路径不能为空", "提示");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string savePath = dialog.SelectedPath;
|
|
|
|
|
|
|
|
|
|
DataPathTextBox.Text = savePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SelectProjectPathBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2022-06-16 13:26:55 +08:00
|
|
|
|
//FolderBrowserDialog dialog = new FolderBrowserDialog();
|
|
|
|
|
//dialog.Description = "请选择工程文件夹";
|
|
|
|
|
//if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
//{
|
|
|
|
|
// if (string.IsNullOrEmpty(dialog.SelectedPath))
|
|
|
|
|
// {
|
|
|
|
|
// MessageBox.Show(this, "文件夹路径不能为空", "提示");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// string savePath = dialog.SelectedPath;
|
|
|
|
|
// ProjectPathTextBox.Text = savePath;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OpenFileDialog dialog = new OpenFileDialog();
|
|
|
|
|
dialog.CheckFileExists = false; //设置不弹出警告
|
|
|
|
|
//dialog.Multiselect = true;//该值确定是否可以选择多个文件
|
|
|
|
|
dialog.Title = "请输入工程名";
|
|
|
|
|
dialog.Filter = "所有文件(*.*)|*.*";
|
|
|
|
|
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
2021-12-14 18:39:55 +08:00
|
|
|
|
{
|
2022-06-16 13:26:55 +08:00
|
|
|
|
string filePath = dialog.FileName;
|
|
|
|
|
filePath = filePath + ".EasySif";
|
|
|
|
|
ProjectPathTextBox.Text = filePath;
|
2021-12-14 18:39:55 +08:00
|
|
|
|
}
|
2022-06-16 13:26:55 +08:00
|
|
|
|
|
2021-12-14 18:39:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2022-03-15 10:19:53 +08:00
|
|
|
|
this.DialogResult = DialogResult.Cancel;
|
2021-12-14 18:39:55 +08:00
|
|
|
|
Close();
|
|
|
|
|
}
|
2022-01-14 11:56:12 +08:00
|
|
|
|
|
|
|
|
|
private void SelectCalFilePathBtn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
FolderBrowserDialog dialog = new FolderBrowserDialog();
|
|
|
|
|
dialog.Description = "请选择定标文件夹";
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(dialog.SelectedPath))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(this, "文件夹路径不能为空", "提示");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
string savePath = dialog.SelectedPath;
|
|
|
|
|
CalFilePathTextBox.Text = savePath;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-14 18:39:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|