Moved much of Windows Forms specific code to Engine proper
This commit is contained in:
parent
c719a60574
commit
89467c900a
@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using UniversalEditor.ObjectModels.Markup;
|
||||
using UniversalEditor.DataFormats.Markup.XML;
|
||||
using System.Drawing;
|
||||
using UniversalEditor.Accessors;
|
||||
|
||||
namespace UniversalEditor.UserInterface.WindowsForms
|
||||
|
||||
@ -133,8 +133,38 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
}
|
||||
}
|
||||
|
||||
[STAThreadAttribute()]
|
||||
protected override void MainLoop()
|
||||
protected override void ShowSplashScreen()
|
||||
{
|
||||
if (LocalConfiguration.SplashScreen.Enabled)
|
||||
{
|
||||
splasher = new SplashScreenWindow();
|
||||
splasher.ShowDialog();
|
||||
}
|
||||
}
|
||||
protected override void HideSplashScreen()
|
||||
{
|
||||
if (LocalConfiguration.SplashScreen.Enabled)
|
||||
{
|
||||
while (splasher == null)
|
||||
{
|
||||
System.Threading.Thread.Sleep(500);
|
||||
}
|
||||
splasher.InvokeClose();
|
||||
}
|
||||
}
|
||||
protected override void UpdateSplashScreenStatus(string message, int progressValue = -1, int progressMinimum = 0, int progressMaximum = 100)
|
||||
{
|
||||
if (LocalConfiguration.SplashScreen.Enabled)
|
||||
{
|
||||
while (splasher == null)
|
||||
{
|
||||
System.Threading.Thread.Sleep(500);
|
||||
}
|
||||
splasher.InvokeUpdateStatus(message);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void BeforeInitialization()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
@ -147,6 +177,13 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
AwesomeControls.Theming.Theme.CurrentTheme = theme;
|
||||
|
||||
Glue.ApplicationInformation.ApplicationID = new Guid("{b359fe9a-080a-43fc-ae38-00ba7ac1703e}");
|
||||
|
||||
base.BeforeInitialization();
|
||||
}
|
||||
|
||||
[STAThreadAttribute()]
|
||||
protected override void MainLoop()
|
||||
{
|
||||
switch (System.Environment.OSVersion.Platform)
|
||||
{
|
||||
case PlatformID.MacOSX:
|
||||
@ -166,15 +203,6 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
}
|
||||
}
|
||||
|
||||
System.Threading.Thread threadLoader = new System.Threading.Thread(threadLoader_ThreadStart);
|
||||
threadLoader.Start();
|
||||
|
||||
if (LocalConfiguration.SplashScreen.Enabled)
|
||||
{
|
||||
splasher = new SplashScreenWindow();
|
||||
splasher.ShowDialog();
|
||||
}
|
||||
|
||||
Glue.ApplicationEventEventArgs e = new Glue.ApplicationEventEventArgs(Glue.Common.Constants.EventNames.ApplicationStart);
|
||||
Glue.Common.Methods.SendApplicationEvent(e);
|
||||
if (e.CancelApplication) return;
|
||||
@ -187,14 +215,8 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
row1.Items.Add("textEditor", "Text Editor");
|
||||
PieMenuManager.Groups.Add(row1);
|
||||
|
||||
OpenWindow(SelectedFileNames.ToArray<string>());
|
||||
|
||||
Application.Run();
|
||||
|
||||
SessionManager.Save();
|
||||
BookmarksManager.Save();
|
||||
RecentFileManager.Save();
|
||||
|
||||
Glue.Common.Methods.SendApplicationEvent(new Glue.ApplicationEventEventArgs(Glue.Common.Constants.EventNames.ApplicationStop));
|
||||
}
|
||||
|
||||
@ -353,30 +375,6 @@ namespace UniversalEditor.UserInterface.WindowsForms
|
||||
}
|
||||
#endif
|
||||
|
||||
private static void threadLoader_ThreadStart()
|
||||
{
|
||||
/*
|
||||
if (Configuration.SplashScreen.Enabled)
|
||||
{
|
||||
while (splasher == null) System.Threading.Thread.Sleep(500);
|
||||
}
|
||||
*/
|
||||
|
||||
// if (Configuration.SplashScreen.Enabled) splasher.InvokeUpdateStatus("Loading object models...");
|
||||
UniversalEditor.Common.Reflection.GetAvailableObjectModels();
|
||||
|
||||
// if (Configuration.SplashScreen.Enabled) splasher.InvokeUpdateStatus("Loading data formats...");
|
||||
UniversalEditor.Common.Reflection.GetAvailableDataFormats();
|
||||
|
||||
if (LocalConfiguration.SplashScreen.Enabled)
|
||||
{
|
||||
while (splasher == null)
|
||||
{
|
||||
System.Threading.Thread.Sleep(500);
|
||||
}
|
||||
splasher.InvokeClose();
|
||||
}
|
||||
}
|
||||
|
||||
protected override IHostApplicationWindow OpenWindowInternal(params string[] FileNames)
|
||||
{
|
||||
|
||||
@ -512,10 +512,71 @@ namespace UniversalEditor.UserInterface
|
||||
private static Engine mvarCurrentEngine = null;
|
||||
public static Engine CurrentEngine { get { return mvarCurrentEngine; } }
|
||||
|
||||
protected virtual void ShowSplashScreen()
|
||||
{
|
||||
}
|
||||
protected virtual void HideSplashScreen()
|
||||
{
|
||||
}
|
||||
protected virtual void UpdateSplashScreenStatus(string message, int progressValue = -1, int progressMinimum = 0, int progressMaximum = 100)
|
||||
{
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
System.Threading.Thread threadLoader = new System.Threading.Thread(threadLoader_ThreadStart);
|
||||
threadLoader.Start();
|
||||
|
||||
ShowSplashScreen();
|
||||
}
|
||||
protected virtual void InitializeInternal()
|
||||
{
|
||||
UpdateSplashScreenStatus("Loading object models...");
|
||||
UniversalEditor.Common.Reflection.GetAvailableObjectModels();
|
||||
|
||||
UpdateSplashScreenStatus("Loading data formats...");
|
||||
UniversalEditor.Common.Reflection.GetAvailableDataFormats();
|
||||
|
||||
// Initialize the XML files
|
||||
InitializeXMLConfiguration();
|
||||
|
||||
// Initialize Recent File Manager
|
||||
mvarRecentFileManager.DataFileName = DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "RecentItems.xml";
|
||||
mvarRecentFileManager.Load();
|
||||
|
||||
// Initialize Bookmarks Manager
|
||||
mvarBookmarksManager.DataFileName = DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Bookmarks.xml";
|
||||
mvarBookmarksManager.Load();
|
||||
|
||||
// Initialize Session Manager
|
||||
mvarSessionManager.DataFileName = DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Sessions.xml";
|
||||
mvarSessionManager.Load();
|
||||
}
|
||||
private void threadLoader_ThreadStart()
|
||||
{
|
||||
/*
|
||||
if (Configuration.SplashScreen.Enabled)
|
||||
{
|
||||
while (splasher == null) System.Threading.Thread.Sleep(500);
|
||||
}
|
||||
*/
|
||||
|
||||
InitializeInternal();
|
||||
HideSplashScreen();
|
||||
}
|
||||
|
||||
public void StartApplication()
|
||||
{
|
||||
Engine.mvarCurrentEngine = this;
|
||||
|
||||
string INSTANCEID = GetType().FullName + "$2d429aa3371c421fb63b42525e51a50c$92751853175891031214292357218181357901238$";
|
||||
if (Configuration.GetValue<bool>("SingleInstanceUniquePerDirectory", true))
|
||||
{
|
||||
// The single instance should be unique per directory
|
||||
INSTANCEID += System.Reflection.Assembly.GetEntryAssembly().Location;
|
||||
}
|
||||
if (!SingleInstanceManager.CreateSingleInstance(INSTANCEID, new EventHandler<SingleInstanceManager.InstanceCallbackEventArgs>(SingleInstanceManager_Callback))) return;
|
||||
|
||||
string[] args1 = Environment.GetCommandLineArgs();
|
||||
string[] args = new string[args1.Length - 1];
|
||||
Array.Copy(args1, 1, args, 0, args.Length);
|
||||
@ -533,36 +594,21 @@ namespace UniversalEditor.UserInterface
|
||||
|
||||
BeforeInitialization();
|
||||
|
||||
// Initialize the XML files
|
||||
InitializeXMLConfiguration();
|
||||
|
||||
// Initialize the branding for the selected application
|
||||
InitializeBranding();
|
||||
|
||||
// Initialize Recent File Manager
|
||||
mvarRecentFileManager.DataFileName = DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "RecentItems.xml";
|
||||
mvarRecentFileManager.Load();
|
||||
|
||||
// Initialize Bookmarks Manager
|
||||
mvarBookmarksManager.DataFileName = DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Bookmarks.xml";
|
||||
mvarBookmarksManager.Load();
|
||||
|
||||
// Initialize Session Manager
|
||||
mvarSessionManager.DataFileName = DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Sessions.xml";
|
||||
mvarSessionManager.Load();
|
||||
|
||||
string INSTANCEID = GetType().FullName + "$2d429aa3371c421fb63b42525e51a50c$92751853175891031214292357218181357901238$";
|
||||
if (Configuration.GetValue<bool>("SingleInstanceUniquePerDirectory", true))
|
||||
{
|
||||
// The single instance should be unique per directory
|
||||
INSTANCEID += System.Reflection.Assembly.GetEntryAssembly().Location;
|
||||
}
|
||||
if (!SingleInstanceManager.CreateSingleInstance(INSTANCEID, new EventHandler<SingleInstanceManager.InstanceCallbackEventArgs>(SingleInstanceManager_Callback))) return;
|
||||
|
||||
Initialize();
|
||||
|
||||
AfterInitializationInternal();
|
||||
AfterInitialization();
|
||||
|
||||
OpenWindow(SelectedFileNames.ToArray<string>());
|
||||
|
||||
MainLoop();
|
||||
|
||||
SessionManager.Save();
|
||||
BookmarksManager.Save();
|
||||
RecentFileManager.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user