1
0
mirror of synced 2024-11-30 18:24:39 +01:00

Add proper file remove dialog and update the menus

This commit is contained in:
KillzXGaming 2019-07-31 20:27:46 -04:00
parent 2340d6a7a4
commit d244ceab0a
7 changed files with 37 additions and 4 deletions

View File

@ -99,7 +99,7 @@ namespace FirstPlugin.Forms
stTabControl2.myBackColor = FormThemes.BaseTheme.FormBackColor;
//Always create an instance of the viewport unless opengl is disabled
if (viewport == null && Runtime.UseOpenGL)
if (viewport == null && Runtime.UseOpenGL || viewport.IsDisposed && Runtime.UseOpenGL)
{
viewport = new Viewport(ObjectEditor.GetDrawableContainers());
viewport.Dock = DockStyle.Fill;

View File

@ -292,6 +292,9 @@ namespace Toolbox.Library.Forms
var node = treeViewCustom1.SelectedNode;
if (node != null)
{
var result = MessageBox.Show("If you remove this file, any unsaved progress will be lost! Continue?",
"Remove Dialog", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (node is IFileFormat)
{
((IFileFormat)node).Unload();
@ -299,6 +302,14 @@ namespace Toolbox.Library.Forms
treeViewCustom1.Nodes.Remove(node);
ResetEditor();
//Force garbage collection.
GC.Collect();
// Wait for all finalizers to complete before continuing.
GC.WaitForPendingFinalizers();
((IUpdateForm)Runtime.MainForm).UpdateForm();
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Toolbox.Library
{
//A simple interface for updating a form
public interface IUpdateForm
{
void UpdateForm();
}
}

View File

@ -249,6 +249,7 @@
<Compile Include="Interfaces\ICloneableNode.cs" />
<Compile Include="Interfaces\IMeshContainer.cs" />
<Compile Include="Interfaces\ITextureContainer.cs" />
<Compile Include="Interfaces\IUpdateForm.cs" />
<Compile Include="IO\Extensions\UintExtension.cs" />
<Compile Include="IO\STColor.cs" />
<Compile Include="Rendering\GenericModelRenderer\GenericModelRenderer.cs" />

View File

@ -20,7 +20,7 @@ using Toolbox.Library.Rendering;
namespace Toolbox
{
public partial class MainForm : Form, IMdiContainer
public partial class MainForm : Form, IMdiContainer, IUpdateForm
{
private static MainForm _instance;
public static MainForm Instance { get { return _instance == null ? _instance = new MainForm() : _instance; } }
@ -55,6 +55,15 @@ namespace Toolbox
LoadConfig();
}
public void UpdateForm()
{
if (ActiveMdiChild is ObjectEditor)
{
var activeFile = ((ObjectEditor)ActiveMdiChild).GetActiveFile();
SetFormatSettings(activeFile);
}
}
public void Reload()
{
LoadConfig();
@ -243,10 +252,8 @@ namespace Toolbox
if (File.Exists(FileName))
SaveRecentFile(FileName);
object file = STFileLoader.OpenFileFormat(FileName);
if (file == null) //File might not be supported so return
return;