Add material deletion.

This commit is contained in:
KillzXGaming 2019-03-29 16:21:07 -04:00
parent d5f50d91b8
commit 6c676cf410
19 changed files with 518 additions and 262 deletions

Binary file not shown.

View file

@ -25,12 +25,17 @@ namespace Bfres.Structs
ContextMenuStrip = new STContextMenuStrip();
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Import Material", null, Import, Keys.Control | Keys.I));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Import Material", null, ImportAction, Keys.Control | Keys.I));
ContextMenuStrip.Items.Add(new ToolStripSeparator());
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Export All Materials", null, ExportAll, Keys.Control | Keys.A));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Replace (From Folder)",null, ReplaceBatch, Keys.Control | Keys.R));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Export All Materials", null, ExportAllAction, Keys.Control | Keys.A));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Replace (From Folder)",null, ReplaceBatchAction, Keys.Control | Keys.R));
}
public void ExportAll(object sender, EventArgs args)
public void ExportAllAction(object sender, EventArgs args) { ExportAll(); }
public void ReplaceBatchAction(object sender, EventArgs args) { ReplaceBatch(); }
public void ImportAction(object sender, EventArgs args) { Import(); }
public void ExportAll()
{
FolderSelectDialog sfd = new FolderSelectDialog();
@ -44,7 +49,7 @@ namespace Bfres.Structs
}
}
}
public void ReplaceBatch(object sender, EventArgs args)
public void ReplaceBatch()
{
FolderSelectDialog ofd = new FolderSelectDialog();
@ -65,7 +70,7 @@ namespace Bfres.Structs
LibraryGUI.Instance.UpdateViewport();
}
public void Import(object sender, EventArgs args)
public void Import()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Bfres Material |*.bfmat;";
@ -91,14 +96,71 @@ namespace Bfres.Structs
ContextMenuStrip = new STContextMenuStrip();
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Export", null, Export, Keys.Control | Keys.E));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Replace", null, Replace, Keys.Control | Keys.R));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Export", null, ExportAction, Keys.Control | Keys.E));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Replace", null, ReplaceAction, Keys.Control | Keys.R));
ContextMenuStrip.Items.Add(new ToolStripSeparator());
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Copy", null, Copy, Keys.Control | Keys.C));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Rename", null, Rename, Keys.Control | Keys.N));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Copy", null, CopyAction, Keys.Control | Keys.C));
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Rename", null, RenameAction, Keys.Control | Keys.N));
ContextMenuStrip.Items.Add(new ToolStripSeparator());
ContextMenuStrip.Items.Add(new ToolStripMenuItem("Delete", null, DeleteAction, Keys.Control | Keys.N));
}
protected void ExportAction(object sender, EventArgs args) { Export(); }
protected void ReplaceAction(object sender, EventArgs args) { Replace(); }
protected void CopyAction(object sender, EventArgs args) { Copy(); }
protected void RenameAction(object sender, EventArgs args) { Rename(); }
protected void DeleteAction(object sender, EventArgs args) { Delete(); }
public void Delete()
{
string MappedNames = "";
var model = GetParentModel();
int CurrentIndex = Parent.Nodes.IndexOf(this);
if (model.materials.Count == 1 && model.shapes.Count > 0)
{
MessageBox.Show("A single material must exist if any objects exist!", "Material Delete",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
foreach (var shape in model.shapes)
{
if (shape.GetMaterial() == this)
{
MappedNames += $"{shape.Text}\n";
}
}
if (MappedNames != "")
{
var result = STOptionsDialog.Show("Shapes are mapped to this material. Are you sure you want to remove this? (Will default to first material)",
"Material Delete", MappedNames);
if (result == DialogResult.Yes)
{
//Adjust all the indices properly based on this current index
foreach (var shape in model.shapes)
{
//If there are indices higher than this index, shift them
if (shape.MaterialIndex > CurrentIndex)
{
shape.MaterialIndex -= 1;
}
}
model.materials.Remove(Text);
Parent.Nodes.Remove(this);
}
}
}
public FMDL GetParentModel()
{
return ((FMDL)Parent.Parent);
}
public ResFile GetResFile()
{
@ -152,7 +214,7 @@ namespace Bfres.Structs
else
Runtime.activeGame = Runtime.ActiveGame.KSA;
}
private void Rename(object sender, EventArgs args)
private void Rename()
{
RenameDialog dialog = new RenameDialog();
dialog.SetString(Text);
@ -164,11 +226,11 @@ namespace Bfres.Structs
((FMDL)Parent.Parent).materials.Add(Text, this);
}
}
private void Copy(object sender, EventArgs args)
private void Copy()
{
((FMDL)Parent.Parent).CopyMaterial(this);
}
private void Export(object sender, EventArgs args)
private void Export()
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.bfmat;";
@ -188,7 +250,7 @@ namespace Bfres.Structs
else
Material.Export(path, GetResFile());
}
private void Replace(object sender, EventArgs args)
private void Replace()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Supported Formats|*.bfmat;";

View file

@ -41,7 +41,7 @@
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnClose.Location = new System.Drawing.Point(267, 47);
this.btnClose.Location = new System.Drawing.Point(267, 52);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 0;
@ -55,7 +55,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.btnDetails.Enabled = false;
this.btnDetails.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDetails.Location = new System.Drawing.Point(12, 47);
this.btnDetails.Location = new System.Drawing.Point(12, 52);
this.btnDetails.Name = "btnDetails";
this.btnDetails.Size = new System.Drawing.Size(75, 23);
this.btnDetails.TabIndex = 1;
@ -68,7 +68,7 @@
this.btnCopy.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnCopy.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCopy.Location = new System.Drawing.Point(93, 47);
this.btnCopy.Location = new System.Drawing.Point(93, 52);
this.btnCopy.Name = "btnCopy";
this.btnCopy.Size = new System.Drawing.Size(102, 23);
this.btnCopy.TabIndex = 4;
@ -90,16 +90,16 @@
// tbDetails
//
this.tbDetails.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.tbDetails.Location = new System.Drawing.Point(12, 78);
this.tbDetails.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbDetails.Location = new System.Drawing.Point(12, 83);
this.tbDetails.MaximumSize = new System.Drawing.Size(328, 100);
this.tbDetails.Name = "tbDetails";
this.tbDetails.ReadOnly = true;
this.tbDetails.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.tbDetails.Size = new System.Drawing.Size(328, 300);
this.tbDetails.Size = new System.Drawing.Size(328, 100);
this.tbDetails.TabIndex = 6;
this.tbDetails.Text = "";
this.tbDetails.Visible = false;
this.tbDetails.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
//
// pictureBox1
//
@ -115,7 +115,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(354, 82);
this.ClientSize = new System.Drawing.Size(354, 87);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.tbDetails);
this.Controls.Add(this.lblMessage);

View file

@ -1,219 +0,0 @@
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
{
public partial class STExceptionDialog : Form
{
#region designer
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(STExceptionDialog));
this.btnContinue = new System.Windows.Forms.Button();
this.btnDetails = new System.Windows.Forms.Button();
this.btnQuit = new System.Windows.Forms.Button();
this.detailsBox = new System.Windows.Forms.RichTextBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.errorMessageLabel = new System.Windows.Forms.RichTextBox();
this.stPanel1 = new Switch_Toolbox.Library.Forms.STPanel();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.stPanel1.SuspendLayout();
this.SuspendLayout();
//
// btnContinue
//
this.btnContinue.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnContinue.Location = new System.Drawing.Point(203, 102);
this.btnContinue.Name = "btnContinue";
this.btnContinue.Size = new System.Drawing.Size(87, 23);
this.btnContinue.TabIndex = 0;
this.btnContinue.Text = "Continue";
this.btnContinue.UseVisualStyleBackColor = true;
//
// btnDetails
//
this.btnDetails.Location = new System.Drawing.Point(12, 102);
this.btnDetails.Name = "btnDetails";
this.btnDetails.Size = new System.Drawing.Size(93, 23);
this.btnDetails.TabIndex = 1;
this.btnDetails.Text = "Details";
this.btnDetails.UseVisualStyleBackColor = true;
this.btnDetails.Click += new System.EventHandler(this.btnDetails_Click);
//
// btnQuit
//
this.btnQuit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnQuit.Location = new System.Drawing.Point(291, 102);
this.btnQuit.Name = "btnQuit";
this.btnQuit.Size = new System.Drawing.Size(87, 23);
this.btnQuit.TabIndex = 2;
this.btnQuit.Text = "Quit";
this.btnQuit.UseVisualStyleBackColor = true;
this.btnQuit.Click += new System.EventHandler(this.btnQuit_Click);
//
// detailsBox
//
this.detailsBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(70)))), ((int)(((byte)(70)))), ((int)(((byte)(70)))));
this.detailsBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.detailsBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.detailsBox.ForeColor = System.Drawing.Color.White;
this.detailsBox.Location = new System.Drawing.Point(0, 0);
this.detailsBox.Name = "detailsBox";
this.detailsBox.Size = new System.Drawing.Size(386, 219);
this.detailsBox.TabIndex = 3;
this.detailsBox.Text = "";
this.detailsBox.TextChanged += new System.EventHandler(this.detailsBox_TextChanged);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(32, 32);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 4;
this.pictureBox1.TabStop = false;
//
// errorMessageLabel
//
this.errorMessageLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.errorMessageLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.errorMessageLabel.ForeColor = System.Drawing.Color.White;
this.errorMessageLabel.Location = new System.Drawing.Point(67, 12);
this.errorMessageLabel.Name = "errorMessageLabel";
this.errorMessageLabel.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None;
this.errorMessageLabel.Size = new System.Drawing.Size(289, 73);
this.errorMessageLabel.TabIndex = 5;
this.errorMessageLabel.Text = "";
//
// stPanel1
//
this.stPanel1.Controls.Add(this.detailsBox);
this.stPanel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.stPanel1.Location = new System.Drawing.Point(0, 131);
this.stPanel1.Name = "stPanel1";
this.stPanel1.Size = new System.Drawing.Size(386, 219);
this.stPanel1.TabIndex = 6;
//
// STErrorDialog
//
this.AcceptButton = this.btnContinue;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
this.CancelButton = this.btnQuit;
this.ClientSize = new System.Drawing.Size(386, 350);
this.Controls.Add(this.stPanel1);
this.Controls.Add(this.errorMessageLabel);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.btnQuit);
this.Controls.Add(this.btnDetails);
this.Controls.Add(this.btnContinue);
this.Name = "STErrorDialog";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Error";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.stPanel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnContinue;
private System.Windows.Forms.Button btnDetails;
private System.Windows.Forms.Button btnQuit;
private System.Windows.Forms.RichTextBox detailsBox;
private System.Windows.Forms.PictureBox pictureBox1;
private STPanel stPanel1;
private System.Windows.Forms.RichTextBox errorMessageLabel;
#endregion
public STExceptionDialog()
{
InitializeComponent();
detailsBox.Multiline = true;
// no smaller than design time size
MinimumSize = new System.Drawing.Size(this.Width, this.Height);
// no larger than screen size
MaximumSize = new System.Drawing.Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
AutoSize = true;
AutoSizeMode = AutoSizeMode.GrowAndShrink;
}
public static void Show(string ErrorMessage, string Details)
{
STExceptionDialog dlg = new STExceptionDialog();
dlg.errorMessageLabel.Text = ErrorMessage;
dlg.detailsBox.Text = Details;
if (dlg.ShowDialog() == DialogResult.OK)
{
dlg.Close();
}
}
private void AutoSizeTextBox(TextBox txt)
{
const int x_margin = 0;
const int y_margin = 2;
Size size = TextRenderer.MeasureText(txt.Text, txt.Font);
txt.ClientSize =
new Size(size.Width + x_margin, size.Height + y_margin);
}
private void detailsBox_TextChanged(object sender, EventArgs e)
{
AutoSizeTextBox(sender as TextBox);
}
private void btnQuit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnDetails_Click(object sender, EventArgs e)
{
}
}
}

View file

@ -0,0 +1,147 @@
namespace Switch_Toolbox.Library.Forms
{
partial class STOptionsDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnClose = new Switch_Toolbox.Library.Forms.STButton();
this.btnDetails = new Switch_Toolbox.Library.Forms.STButton();
this.lblMessage = new Switch_Toolbox.Library.Forms.STLabel();
this.tbDetails = new System.Windows.Forms.RichTextBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.stButton1 = new Switch_Toolbox.Library.Forms.STButton();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// btnClose
//
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.No;
this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnClose.Location = new System.Drawing.Point(267, 76);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(75, 23);
this.btnClose.TabIndex = 0;
this.btnClose.Text = "No";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnDetails
//
this.btnDetails.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnDetails.Enabled = false;
this.btnDetails.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDetails.Location = new System.Drawing.Point(12, 76);
this.btnDetails.Name = "btnDetails";
this.btnDetails.Size = new System.Drawing.Size(75, 23);
this.btnDetails.TabIndex = 1;
this.btnDetails.Text = "Details";
this.btnDetails.UseVisualStyleBackColor = true;
this.btnDetails.Click += new System.EventHandler(this.btnDetails_Click);
//
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Location = new System.Drawing.Point(68, 18);
this.lblMessage.MaximumSize = new System.Drawing.Size(310, 0);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(35, 13);
this.lblMessage.TabIndex = 5;
this.lblMessage.Text = "label1";
//
// tbDetails
//
this.tbDetails.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.tbDetails.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.tbDetails.Location = new System.Drawing.Point(12, 107);
this.tbDetails.MaximumSize = new System.Drawing.Size(328, 100);
this.tbDetails.Name = "tbDetails";
this.tbDetails.ReadOnly = true;
this.tbDetails.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.tbDetails.Size = new System.Drawing.Size(328, 100);
this.tbDetails.TabIndex = 6;
this.tbDetails.Text = "";
this.tbDetails.Visible = false;
//
// pictureBox1
//
this.pictureBox1.Image = global::Switch_Toolbox.Library.Properties.Resources.QuestionCheck;
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(50, 37);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 7;
this.pictureBox1.TabStop = false;
//
// stButton1
//
this.stButton1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.stButton1.DialogResult = System.Windows.Forms.DialogResult.Yes;
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton1.Location = new System.Drawing.Point(186, 76);
this.stButton1.Name = "stButton1";
this.stButton1.Size = new System.Drawing.Size(75, 23);
this.stButton1.TabIndex = 8;
this.stButton1.Text = "Yes";
this.stButton1.UseVisualStyleBackColor = true;
//
// STOptionsDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(354, 111);
this.Controls.Add(this.stButton1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.tbDetails);
this.Controls.Add(this.lblMessage);
this.Controls.Add(this.btnDetails);
this.Controls.Add(this.btnClose);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "STOptionsDialog";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Switch_Toolbox.Library.Forms.STButton btnClose;
private Switch_Toolbox.Library.Forms.STButton btnDetails;
private Switch_Toolbox.Library.Forms.STLabel lblMessage;
private System.Windows.Forms.RichTextBox tbDetails;
private System.Windows.Forms.PictureBox pictureBox1;
private STButton stButton1;
}
}

View file

@ -0,0 +1,108 @@
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;
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);
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -430,6 +430,16 @@ namespace Switch_Toolbox.Library.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap InfoCheck {
get {
object obj = ResourceManager.GetObject("InfoCheck", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@ -650,6 +660,16 @@ namespace Switch_Toolbox.Library.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap QuestionCheck {
get {
object obj = ResourceManager.GetObject("QuestionCheck", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View file

@ -148,8 +148,8 @@
<data name="maximized" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\maximized.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Bfres" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Bfres.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="RewindArrows2L" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Playback\RewindArrows2L.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="IconInt" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\DataTyypes\IconInt.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@ -193,9 +193,6 @@
<data name="arrowL" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrowL.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="IconCurve" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\DataTyypes\IconCurve.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="minimize" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Forms\Toolbar\images\minimize.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -220,9 +217,6 @@
<data name="Byaml" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Byaml.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Init_false" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CheckBox\Init_false.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="diffuseSDR" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Cubemaps\diffuseSDR.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
@ -241,6 +235,9 @@
<data name="specularSDR" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Cubemaps\specularSDR.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="InjectTexErrored" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\InjectTexErrored.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="normalsSphere" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\normalsSphere.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -253,8 +250,8 @@
<data name="IconList" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\DataTyypes\IconList.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="IconBool" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\DataTyypes\IconBool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="Init_false" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CheckBox\Init_false.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="IconBuffer" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\DataTyypes\IconBuffer.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@ -277,9 +274,15 @@
<data name="Close_Hover" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Forms\Toolbar\images\close_sele.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="InfoCheck" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\InfoCheck.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="PlayArrowR" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Playback\PlayArrowR.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NumbericUpDownArrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NumbericUpDownArrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="minimize_sele" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Forms\Toolbar\images\minimize_sele.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -292,14 +295,17 @@
<data name="brsf" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\brsf.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="maximize" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Forms\Toolbar\images\maximize.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="IconBool" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\DataTyypes\IconBool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="LoadingImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\LoadingImage.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="InjectTexErrored" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\InjectTexErrored.dds;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="Bfres" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Bfres.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="IconCurve" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\DataTyypes\IconCurve.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Bnsh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Bnsh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@ -316,9 +322,6 @@
<data name="CheckerBackground" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\CheckerBackground.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="RewindArrows2L" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Playback\RewindArrows2L.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="skeletonAnimation" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\skeletonAnimation.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -340,10 +343,13 @@
<data name="Bntx" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Bntx.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="maximize" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Forms\Toolbar\images\maximize.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="minimize1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\minimize.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NumbericUpDownArrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NumbericUpDownArrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="QuestionCheck" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\QuestionCheck.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 739 B

After

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

@ -234,6 +234,12 @@
<Compile Include="Forms\Custom\STNumericBox.Designer.cs">
<DependentUpon>STNumericBox.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Dialogs\STOptionsDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Dialogs\STOptionsDialog.Designer.cs">
<DependentUpon>STOptionsDialog.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Editors\Audio\LoopEditor.cs">
<SubType>Form</SubType>
</Compile>
@ -463,9 +469,6 @@
<DependentUpon>CubeMapFaceCreator.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Dialogs\DialogCenter.cs" />
<Compile Include="Forms\Dialogs\STExceptionDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Editors\TransformMeshTool.cs">
<SubType>Form</SubType>
</Compile>
@ -615,6 +618,9 @@
<EmbeddedResource Include="Forms\Custom\STTextBox.resx">
<DependentUpon>STTextBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Dialogs\STOptionsDialog.resx">
<DependentUpon>STOptionsDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Dialogs\STErrorDialog.resx">
<DependentUpon>STErrorDialog.cs</DependentUpon>
</EmbeddedResource>
@ -958,6 +964,12 @@
<ItemGroup>
<None Include="Resources\NumbericUpDownArrow.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\InfoCheck.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\QuestionCheck.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\AssimpNet.4.1.0\build\AssimpNet.targets" Condition="Exists('..\packages\AssimpNet.4.1.0\build\AssimpNet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">