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; namespace mainProgram { public partial class OpenProjectWindow : Form { public OpenProjectWindow() { InitializeComponent(); } 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; } } public event transferProjectManagerDelegate TransferEvent;//申明事件 private void OpenProjectPathBtn_Click(object sender, EventArgs e) { string projectPath = ProjectPathTextBox.Text; if (projectPath != null && projectPath.Length == 0) { MessageBox.Show(this, "工程路径不能为空", "提示"); return; } ProjectManager projectManager = new ProjectManager(projectPath); if(projectManager.OpenProject()) { TransferEvent(projectManager);//触发事件 MessageBox.Show(this, "工程打开成功!", "提示"); this.DialogResult = DialogResult.OK; Close();//打开工程完成后,关闭窗口 } else { MessageBox.Show(this, "工程打开失败!", "提示"); } } private void CancelBtn_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; Close(); } } }