Switch-Toolbox/Switch_Toolbox_Library/Forms/Dialogs/STOptionsDialog.cs
KillzXGaming e531a779ed Small fixes and additions
Fixed mesh name exporting for assimp.
Fixed clearing models for bfres.
Fixed limit skin count setting.
Fixed material index breaking if a material is removed for bfres.
Update the vertex data properly if a model is imported as new.
Added AMTA editing for BARS.
Added audio player for BARS.
2019-06-07 16:31:13 -04:00

109 lines
3.2 KiB
C#

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;
namespace Switch_Toolbox.Library.Forms
{
//Based from https://stackoverflow.com/questions/8653430/how-can-i-show-a-message-box-with-details-in-winforms/40469355#40469355
/// <summary>
/// A dialog-style form with optional colapsable details section
/// </summary>
public partial class STOptionsDialog : Form
{
private const string DetailsFormat = "Details {0}";
public STOptionsDialog(string message, string title, string details = null)
{
InitializeComponent();
lblMessage.Text = message;
this.Text = title;
if (details != null)
{
btnDetails.Enabled = true;
btnDetails.Text = DownArrow;
tbDetails.Text = details;
}
BackColor = FormThemes.BaseTheme.FormBackColor;
ForeColor = FormThemes.BaseTheme.FormForeColor;
tbDetails.BackColor = FormThemes.BaseTheme.FormBackColor;
tbDetails.ForeColor = FormThemes.BaseTheme.FormForeColor;
}
private string UpArrow
{
get
{
return string.Format(DetailsFormat, char.ConvertFromUtf32(0x25B4));
}
}
private string DownArrow
{
get
{
return string.Format(DetailsFormat, char.ConvertFromUtf32(0x25BE));
}
}
/// <summary>
/// Meant to give the look and feel of a regular MessageBox
/// </summary>
public static DialogResult Show(string message, string title, string details = null)
{
return new STOptionsDialog(message, title, details).ShowDialog();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// Change these properties now so the label is rendered so we get its real height
var height = lblMessage.Height;
SetMessageBoxHeight(height);
}
private void SetMessageBoxHeight(int heightChange)
{
this.Height = this.Height + heightChange;
if (this.Height < 150)
{
this.Height = 150;
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnDetails_Click(object sender, EventArgs e)
{
// Re-anchoring the controls so they stay in their place while the form is resized
btnClose.Anchor = AnchorStyles.Top;
stButton1.Anchor = AnchorStyles.Top;
btnDetails.Anchor = AnchorStyles.Top;
tbDetails.Anchor = AnchorStyles.Top;
tbDetails.Visible = !tbDetails.Visible;
btnDetails.Text = tbDetails.Visible ? UpArrow : DownArrow;
SetMessageBoxHeight(tbDetails.Visible ? tbDetails.Height + 10 : -tbDetails.Height - 10);
}
private void btnCopy_Click(object sender, EventArgs e)
{
Clipboard.SetText(tbDetails.Text);
}
}
}