mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-25 21:25:57 +00:00
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using MetroFramework.Forms;
|
|
using OMI.Formats.Pck;
|
|
|
|
namespace PckStudio.Popups
|
|
{
|
|
public partial class AddFilePrompt : MetroForm
|
|
{
|
|
/// <summary>
|
|
/// Text entered only valid when <see cref="DialogResult"/> == <see cref="DialogResult.OK"/>,
|
|
/// otherwise <see cref="string.Empty"/>
|
|
/// </summary>
|
|
public string Filepath => DialogResult == DialogResult.OK ? InputTextBox.Text : string.Empty;
|
|
public PckFile.FileData.FileType Filetype => (PckFile.FileData.FileType)FileTypeComboBox.SelectedIndex;
|
|
|
|
public AddFilePrompt(string initialText) : this(initialText, -1)
|
|
{ }
|
|
|
|
public AddFilePrompt(string initialText, int maxPathLength)
|
|
{
|
|
InitializeComponent();
|
|
InputTextBox.Text = initialText;
|
|
InputTextBox.MaxLength = maxPathLength < 0 ? short.MaxValue : maxPathLength;
|
|
}
|
|
|
|
private void OKBtn_Click(object sender, EventArgs e)
|
|
{
|
|
if(FileTypeComboBox.SelectedIndex > -1)
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
|
|
private void InputTextBox_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
OKBtn_Click(sender, e);
|
|
}
|
|
}
|
|
}
|