Files
easySif/mainProgram/NewProjectWindow.cs

97 lines
3.0 KiB
C#
Raw Normal View History

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
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 dataPath = DataPathTextBox.Text;
//string currPath = Application.StartupPath;
string projectPath = ProjectPathTextBox.Text;
if (dataPath != null && dataPath.Length == 0)
{
MessageBox.Show(this, "数据文件夹路径不能为空", "提示");
return;
}
if (projectPath != null && projectPath.Length == 0)
{
MessageBox.Show(this, "工程路径不能为空", "提示");
return;
}
ProjectManager projectManager = new ProjectManager(projectPath);
2021-12-16 18:40:51 +08:00
projectManager.CreateProject(dataPath);
2021-12-14 18:39:55 +08:00
TransferEvent(projectManager);//触发事件
2021-12-16 18:40:51 +08:00
MessageBox.Show(this, "工程创建成功!", "提示");
2021-12-14 18:39:55 +08:00
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();
}
}
}