Files
easySif/mainProgram/NewProjectWindow.cs

123 lines
4.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);//申明委托
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;
string dataPath = DataPathTextBox.Text;
2021-12-14 18:39:55 +08:00
string projectPath = ProjectPathTextBox.Text;
string calFilePath = CalFilePathTextBox.Text;
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;
}
if (calFilePath != null && calFilePath.Length == 0)
{
MessageBox.Show(this, "定标路径不能为空", "提示");
return;
}
2021-12-14 18:39:55 +08:00
ProjectManager projectManager = new ProjectManager(projectPath);
projectManager.CreateProject(calFilePath, dataPath);
2021-12-14 18:39:55 +08:00
TransferEvent(projectManager);//触发事件
2021-12-16 18:40:51 +08:00
MessageBox.Show(this, "工程创建成功!", "提示");
2022-03-15 10:19:53 +08:00
this.DialogResult = DialogResult.OK;
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)
{
2022-03-15 10:19:53 +08:00
this.DialogResult = DialogResult.Cancel;
2021-12-14 18:39:55 +08:00
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;
}
}
2021-12-14 18:39:55 +08:00
}
}