2014-01-29 18:33:24 +08:00
|
|
|
|
using System;
|
2014-10-21 18:16:05 +08:00
|
|
|
|
using System.Collections.Generic;
|
2014-03-11 23:54:37 +08:00
|
|
|
|
using System.IO;
|
2014-01-29 18:33:24 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
2014-10-21 18:16:05 +08:00
|
|
|
|
using Wox.CommandArgs;
|
2015-10-31 04:47:03 +08:00
|
|
|
|
using Wox.Core.Plugin;
|
2014-03-11 23:54:37 +08:00
|
|
|
|
using Wox.Helper;
|
2014-03-27 12:58:36 +08:00
|
|
|
|
using Application = System.Windows.Application;
|
|
|
|
|
using MessageBox = System.Windows.MessageBox;
|
2014-01-29 18:33:24 +08:00
|
|
|
|
using StartupEventArgs = System.Windows.StartupEventArgs;
|
|
|
|
|
|
2014-10-21 18:16:05 +08:00
|
|
|
|
namespace Wox
|
|
|
|
|
{
|
|
|
|
|
public partial class App : Application, ISingleInstanceApp
|
|
|
|
|
{
|
|
|
|
|
private const string Unique = "Wox_Unique_Application_Mutex";
|
|
|
|
|
public static MainWindow Window { get; private set; }
|
|
|
|
|
|
|
|
|
|
[STAThread]
|
|
|
|
|
public static void Main()
|
|
|
|
|
{
|
|
|
|
|
if (SingleInstance<App>.InitializeAsFirstInstance(Unique))
|
|
|
|
|
{
|
|
|
|
|
var application = new App();
|
|
|
|
|
application.InitializeComponent();
|
|
|
|
|
application.Run();
|
|
|
|
|
SingleInstance<App>.Cleanup();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnStartup(e);
|
|
|
|
|
DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException;
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle;
|
|
|
|
|
|
|
|
|
|
Window = new MainWindow();
|
2015-10-31 04:47:03 +08:00
|
|
|
|
PluginManager.Init(Window);
|
|
|
|
|
ImageLoader.ImageLoader.PreloadImages();
|
2014-10-21 18:16:05 +08:00
|
|
|
|
CommandArgsFactory.Execute(e.Args.ToList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool OnActivate(IList<string> args)
|
|
|
|
|
{
|
|
|
|
|
CommandArgsFactory.Execute(args);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-29 18:33:24 +08:00
|
|
|
|
}
|