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; using System.Threading; namespace mainProgram { //子窗口向父窗口传递参数:https://www.cnblogs.com/xcong/p/3386085.html public delegate void transferProjectManagerDelegate(ProjectManager value);//申明委托 public partial class NewProjectWindow : Form { public NewProjectWindow() { InitializeComponent(); } public event transferProjectManagerDelegate TransferEvent;//申明事件 private void CreateProjectBtn_Click(object sender, EventArgs e) { //获取数据 //string currPath = Application.StartupPath; string dataPath = DataPathTextBox.Text; string projectPath = ProjectPathTextBox.Text; string calFilePath = CalFilePathTextBox.Text; if (dataPath != null && dataPath.Length == 0) { MessageBox.Show(this, "数据文件夹路径不能为空", "提示"); return; } if (projectPath != null && projectPath.Length == 0) { MessageBox.Show(this, "工程路径不能为空", "提示"); return; } if (calFilePath != null && calFilePath.Length == 0) { MessageBox.Show(this, "定标路径不能为空", "提示"); return; } ProjectManager projectManager = new ProjectManager(projectPath); projectManager.CreateProject(calFilePath, dataPath); TransferEvent(projectManager);//触发事件 MessageBox.Show(this, "工程创建成功!", "提示"); Close();//创建工程完成后,关闭窗口 } 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) { 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; } } private void Cancel_Click(object sender, EventArgs e) { Close(); } 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; } } } }