phase 1
This commit is contained in:
58
ModVersionChecker/ui/controls/DirectoryPickerControl.cs
Normal file
58
ModVersionChecker/ui/controls/DirectoryPickerControl.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ModVersionChecker.controls
|
||||
{
|
||||
public class DirectoryPickerControl : UserControl
|
||||
{
|
||||
private readonly TextBox _textBox;
|
||||
private readonly Button _browseButton;
|
||||
|
||||
public string SelectedPath
|
||||
{
|
||||
get => _textBox.Text;
|
||||
set => _textBox.Text = value;
|
||||
}
|
||||
|
||||
public DirectoryPickerControl()
|
||||
{
|
||||
_textBox = new TextBox
|
||||
{
|
||||
Width = 300,
|
||||
ReadOnly = true,
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
|
||||
_browseButton = new Button
|
||||
{
|
||||
Text = "Browse",
|
||||
Width = 80,
|
||||
Dock = DockStyle.Right
|
||||
};
|
||||
|
||||
_browseButton.Click += (s, e) =>
|
||||
{
|
||||
using var folderDialog = new FolderBrowserDialog();
|
||||
folderDialog.Description = "Select directory";
|
||||
if (folderDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
SelectedPath = folderDialog.SelectedPath;
|
||||
}
|
||||
};
|
||||
|
||||
var panel = new TableLayoutPanel
|
||||
{
|
||||
ColumnCount = 2,
|
||||
Dock = DockStyle.Fill,
|
||||
AutoSize = true
|
||||
};
|
||||
panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 80));
|
||||
panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20));
|
||||
panel.Controls.Add(_textBox, 0, 0);
|
||||
panel.Controls.Add(_browseButton, 1, 0);
|
||||
|
||||
Controls.Add(panel);
|
||||
AutoSize = true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user