Add proper mdi container method which checks duped names

This commit is contained in:
KillzXGaming 2019-04-21 14:50:57 -04:00
parent fad58c99e5
commit 65b34e1e89
9 changed files with 27 additions and 4 deletions

Binary file not shown.

View file

@ -65,10 +65,9 @@ namespace Switch_Toolbox.Library
}
public void CreateMdiWindow(STForm form, bool Show = true)
{
form.MdiParent = Application.OpenForms[0];
var mainform = Application.OpenForms[0];
if (Show)
form.Show();
((IMdiContainer)mainform).AddChildContainer(form);
}
public ObjectEditor GetObjectEditor()
{

View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Switch_Toolbox.Library
{
public interface IMdiContainer
{
void AddChildContainer(Form form);
}
}

View file

@ -498,6 +498,7 @@
<Compile Include="Helpers\TextureHelper.cs" />
<Compile Include="Interfaces\IEditor.cs" />
<Compile Include="Interfaces\IFIleEditor.cs" />
<Compile Include="Interfaces\IMdiContainer.cs" />
<Compile Include="Interfaces\IMenuExtension.cs" />
<Compile Include="Interfaces\ITexture.cs" />
<Compile Include="Interfaces\IViewportContainer.cs" />

View file

@ -18,7 +18,7 @@ using OpenTK.Graphics.OpenGL;
namespace Toolbox
{
public partial class MainForm : Form
public partial class MainForm : Form, IMdiContainer
{
private static MainForm _instance;
public static MainForm Instance { get { return _instance == null ? _instance = new MainForm() : _instance; } }
@ -26,8 +26,17 @@ namespace Toolbox
IFileFormat[] SupportedFormats;
IFileMenuExtension[] FileMenuExtensions;
public void AddChildContainer(Form form)
{
TabDupeIndex = 0;
form.Text = CheckTabDupes(form.Text);
form.MdiParent = this;
form.Show();
}
public MainForm()
{
FormThemes.ActivePreset = FormThemes.Preset.Dark;
Runtime.MainForm = this;