Files
easySif/mainProgram/OpenProjectWindow.cs

86 lines
2.6 KiB
C#

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;
//}
OpenFileDialog dialog = new OpenFileDialog();
//dialog.CheckFileExists = false; //设置不弹出警告
//dialog.Multiselect = true;//该值确定是否可以选择多个文件
dialog.Title = "请选择工程文件";
dialog.Filter = "工程文件(*.EasySif)|*.EasySif";
if (dialog.ShowDialog() == DialogResult.OK)
{
string filePath = dialog.FileName;
ProjectPathTextBox.Text = filePath;
}
}
public event transferProjectManagerDelegate TransferEvent;//申明事件
private void OpenProjectPathBtn_Click(object sender, EventArgs e)
{
string projectFile = ProjectPathTextBox.Text;
if (projectFile != null && projectFile.Length == 0)
{
MessageBox.Show(this, "工程路径不能为空", "提示");
return;
}
ProjectManager projectManager = new ProjectManager(projectFile);
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();
}
}
}