1
0
mirror of https://github.com/SirusDoma/VoxCharger.git synced 2024-11-28 01:10:49 +01:00
VoxCharger/Sources/Forms/MixSelectorForm.cs

85 lines
2.7 KiB
C#
Raw Normal View History

2020-04-18 22:24:48 +02:00
using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace VoxCharger
{
public partial class MixSelectorForm : Form
{
public int ExpandedHeight = 165;
public int CollapsedHeight = 140;
2020-04-18 22:24:48 +02:00
public MixSelectorForm(bool createMode = false)
{
InitializeComponent();
if (createMode)
{
Text = "Create Mix";
MixSelectorDropDown.SelectedIndex = 0;
NameTextBox.Location = MixSelectorDropDown.Location;
MixSelectorDropDown.Visible = MixSelectorDropDown.Enabled = false;
ModSelectorLabel.Text = "Enter mix name:";
Size = new Size(Size.Width, CollapsedHeight);
2020-04-18 22:24:48 +02:00
}
}
private void OnModSelectorFormLoad(object sender, EventArgs e)
{
foreach (string mix in AssetManager.GetMixes())
MixSelectorDropDown.Items.Add(mix);
}
private void OnModSelectorDropDownSelectedIndexChanged(object sender, EventArgs e)
{
if (MixSelectorDropDown.SelectedIndex == 0)
Size = new Size(Size.Width, ExpandedHeight);
2020-04-18 22:24:48 +02:00
else
Size = new Size(Size.Width, CollapsedHeight);
2020-04-18 22:24:48 +02:00
NameTextBox.Visible = MixSelectorDropDown.SelectedIndex == 0;
ContinueButton.Enabled = true;
}
private void OnContinueButtonClick(object sender, EventArgs e)
{
if (MixSelectorDropDown.SelectedIndex == 0)
{
if (string.IsNullOrEmpty(NameTextBox.Text))
{
MessageBox.Show(
"Mix name cannot be empty",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Warning
);
return;
}
else if (AssetManager.GetMixes().Contains(NameTextBox.Text) || NameTextBox.Text.ToLower() == "original")
{
MessageBox.Show(
"Mix name is already exists",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Warning
);
return;
}
AssetManager.CreateMix(NameTextBox.Text);
}
else if (MixSelectorDropDown.SelectedIndex == 1)
AssetManager.LoadMix(string.Empty);
else
AssetManager.LoadMix(MixSelectorDropDown.SelectedItem.ToString());
DialogResult = DialogResult.OK;
Close();
}
}
}