96 lines
No EOL
2.9 KiB
C#
96 lines
No EOL
2.9 KiB
C#
using JD.Bloomberg;
|
|
using JD.Core.ProjectManaging;
|
|
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using JD.Perforce;
|
|
using JD.Kernel.Classes;
|
|
using JD.Kernel.StaticHelpers;
|
|
using JD.TeaBoxAddinSystem.Bootstrap;
|
|
using TeaBox.Macros;
|
|
using TeaBox.SplashScreens;
|
|
|
|
namespace JD.Application.Program
|
|
{
|
|
/// <summary>
|
|
/// Controls the startup and initialization of the editor.
|
|
/// </summary>
|
|
public class GenericApplicationStartup : ApplicationStartup
|
|
{
|
|
private readonly bool _isCmdLine;
|
|
|
|
#region Constructor
|
|
|
|
public GenericApplicationStartup(string[] arguments, bool acceptMacroCmd = false, RuntimeMode runtimeMode = RuntimeMode.Normal)
|
|
: base(arguments, ProgramIdentity.Instance.Name, runtimeMode)
|
|
{
|
|
ProjectManager.Instance.Initialize();
|
|
|
|
JdBloombergLegacy.Instance.Start();
|
|
|
|
PlumeLoggerAdapter plumeLoggerAdapter = PlumeLoggerAdapter.Create();
|
|
P4Manager.Instance.Initialize(plumeLoggerAdapter);
|
|
|
|
if (acceptMacroCmd && arguments.Length > 0)
|
|
{
|
|
// In case we find a path as only argument, we consider it's not a macro and we don't run application on command line
|
|
_isCmdLine = !(arguments.Length == 1 && FileUtility.IsValidPath(arguments[0]));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Configures TeaBox, using the given <paramref name="configuration"/>.
|
|
/// </summary>
|
|
/// <param name="configuration"></param>
|
|
protected override void Configure(ApplicationConfiguration configuration)
|
|
{
|
|
base.Configure(configuration);
|
|
|
|
configuration.ApplicationRootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
configuration.BootstrapAddinPath = "Bootstrap/TeaBox";
|
|
configuration.ConfigApplicationName = ProgramIdentity.Instance.Name;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Event Handlers
|
|
|
|
protected override IDisposable OnShowSplashScreen()
|
|
{
|
|
if (_isCmdLine)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
var image = ProgramIdentity.Instance.SplashScreenImage;
|
|
|
|
if (image != null)
|
|
{
|
|
var splashScreen = new SplashWindow(image);
|
|
splashScreen.Show();
|
|
return new DisposableHelper(splashScreen.Close);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
protected override void OnStarting(out int exitCode)
|
|
{
|
|
base.OnStarting(out exitCode);
|
|
|
|
if (_isCmdLine)
|
|
{
|
|
exitCode = ConsoleApplication.Run();
|
|
Environment.Exit(exitCode);
|
|
}
|
|
}
|
|
|
|
protected bool HasCommandLine { get { return _isCmdLine || Runtime.CommandLineMode; } }
|
|
|
|
#endregion
|
|
}
|
|
} |