SonicAudioTools/Source/CsbBuilder/CreateNewProjectForm.cs

78 lines
2.4 KiB
C#
Raw Normal View History

2017-01-26 21:40:46 +01: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;
using CsbBuilder.Project;
namespace CsbBuilder
{
public partial class CreateNewProjectForm : Form
{
private CsbProject project = new CsbProject();
public CsbProject Project
{
get
{
return project;
}
}
public CreateNewProjectForm(string name) : this()
{
maskedTextBox1.Text = Path.GetFileNameWithoutExtension(name);
string directoryName = Path.GetDirectoryName(name);
2017-04-17 18:06:29 +02:00
maskedTextBox2.Text = !string.IsNullOrEmpty(directoryName) && MainForm.Settings.ImportedCsbProjectDirectory == Settings.ProjectDirectory.DirectoryOfCsb ? Path.ChangeExtension(name, null) : Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), MainForm.Settings.ProjectsDirectory, Path.GetFileNameWithoutExtension(name));
2017-01-26 21:40:46 +01:00
}
public CreateNewProjectForm()
{
InitializeComponent();
maskedTextBox1.Text = project.Name;
maskedTextBox2.Text = project.Directory.FullName;
}
private void maskedTextBox1_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBox1.Text))
{
MessageBox.Show("Name cannot be empty.", "CSB Builder", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
project.Name = maskedTextBox1.Text;
}
private void button1_Click(object sender, EventArgs e)
{
using (FolderBrowserDialog selectFolder = new FolderBrowserDialog())
{
if (selectFolder.ShowDialog() == DialogResult.OK)
{
maskedTextBox2.Text = selectFolder.SelectedPath;
}
}
}
private void maskedTextBox2_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(maskedTextBox2.Text))
{
MessageBox.Show("Path cannot be empty.", "CSB Builder", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
project.Directory = new DirectoryInfo(maskedTextBox2.Text);
}
}
}