CodeWalker/SelectFolderForm.cs
PNWParksFan d7938dd1d8 Added GTA V folder check to main entry point in Program.cs, improved folder selection dialog
- Added bool app setting for remember GTA folder (vs. prompt every start)
 - Added checkbox to folder selection dialog for remember GTA folder
 - Changed folder selection dialog to fixed dialog window border
 - Set default Enter/Esc buttons on folder selection dialog
2018-02-21 00:27:01 -08:00

74 lines
2.1 KiB
C#

using CodeWalker.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CodeWalker
{
public partial class SelectFolderForm : Form
{
public string SelectedFolder { get; set; }
public DialogResult Result { get; set; } = DialogResult.Cancel;
public SelectFolderForm()
{
InitializeComponent();
}
private void SelectFolderForm_Load(object sender, EventArgs e)
{
FolderTextBox.Text = Settings.Default.GTAFolder;
RememberFolderCheckbox.Checked = Settings.Default.RememberGTAFolder;
}
private void FolderBrowseButton_Click(object sender, EventArgs e)
{
FolderBrowserDialog.SelectedPath = FolderTextBox.Text;
DialogResult res = FolderBrowserDialog.ShowDialog();
if (res == DialogResult.OK)
{
FolderTextBox.Text = FolderBrowserDialog.SelectedPath;
}
}
private void FolderTextBox_TextChanged(object sender, EventArgs e)
{
SelectedFolder = FolderTextBox.Text;
}
private void CancelButton_Click(object sender, EventArgs e)
{
Close();
}
private void OkButton_Click(object sender, EventArgs e)
{
if (!Directory.Exists(SelectedFolder))
{
MessageBox.Show("The folder \"" + SelectedFolder + "\" does not exist, or cannot be accessed. Please select another.");
return;
}
if (!File.Exists(SelectedFolder + "\\gta5.exe"))
{
MessageBox.Show("GTA5.exe not found in folder:\n" + SelectedFolder);
return;
}
Result = DialogResult.OK;
Close();
}
private void RememberFolderCheckbox_CheckedChanged(object sender, EventArgs e)
{
Settings.Default.RememberGTAFolder = RememberFolderCheckbox.Checked;
}
}
}