diff --git a/PythonHome/wox.py b/PythonHome/wox.py index 8ff4ec3843..e0050e2253 100644 --- a/PythonHome/wox.py +++ b/PythonHome/wox.py @@ -25,7 +25,7 @@ class Wox(object): sub class need to override this method """ return [] - + def debug(self,msg): """ alert msg diff --git a/Wox/App.xaml b/Wox/App.xaml index fe72ce333e..f02f489f06 100644 --- a/Wox/App.xaml +++ b/Wox/App.xaml @@ -4,9 +4,6 @@ > - - - diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 0bf4f342ad..8b4f9af495 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -1,115 +1,49 @@ using System; -using System.Collections.ObjectModel; +using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Threading; -using System.Windows; -using System.Windows.Forms; -using System.Windows.Threading; -using Microsoft.VisualBasic.ApplicationServices; -using Wox; -using Wox.Commands; +using Wox.CommandArgs; using Wox.Helper; using Wox.Helper.ErrorReporting; using Application = System.Windows.Application; using MessageBox = System.Windows.MessageBox; -using MessageBoxOptions = System.Windows.Forms.MessageBoxOptions; using StartupEventArgs = System.Windows.StartupEventArgs; -using UnhandledExceptionEventArgs = System.UnhandledExceptionEventArgs; -namespace Wox { - public static class EntryPoint { - [STAThread] - [System.Diagnostics.DebuggerStepThrough] - public static void Main(string[] args) { - AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle; - System.Windows.Forms.Application.ThreadException += ErrorReporting.ThreadException; +namespace Wox +{ + public partial class App : Application, ISingleInstanceApp + { + private const string Unique = "Wox_Unique_Application_Mutex"; + public static MainWindow Window { get; private set; } - // don't combine Main and Entry since Microsoft.VisualBasic may be unable to load - // seperating them into two methods can make error reporting have the chance to catch exception - Entry(args); - } + [STAThread] + public static void Main() + { + if (SingleInstance.InitializeAsFirstInstance(Unique)) + { + var application = new App(); + application.InitializeComponent(); + application.Run(); + SingleInstance.Cleanup(); + } + } - [System.Diagnostics.DebuggerStepThrough] - private static void Entry(string[] args) { - SingleInstanceManager manager = new SingleInstanceManager(); - manager.Run(args); - } - } + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; + AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle; + System.Windows.Forms.Application.ThreadException += ErrorReporting.ThreadException; - // Using VB bits to detect single instances and process accordingly: - // * OnStartup is fired when the first instance loads - // * OnStartupNextInstance is fired when the application is re-run again - // NOTE: it is redirected to this instance thanks to IsSingleInstance - [System.Diagnostics.DebuggerStepThrough] - public class SingleInstanceManager : WindowsFormsApplicationBase { - App app; + Window = new MainWindow(); + CommandArgsFactory.Execute(e.Args.ToList()); + } - public SingleInstanceManager() { - this.IsSingleInstance = true; - } - - protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e) { - // First time app is launched - app = new App(); - //app.InitializeComponent(); - app.Run(); - return true; - } - - protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs) { - // Subsequent launches - base.OnStartupNextInstance(eventArgs); - app.Activate(eventArgs.CommandLine.ToArray()); - } - } - - public partial class App : Application { - - private static MainWindow window; - - public static MainWindow Window { - get { - return window; - } - } - - protected override void OnStartup(StartupEventArgs e) { - this.DispatcherUnhandledException += ErrorReporting.DispatcherUnhandledException; - - base.OnStartup(e); - - //for install plugin command when wox didn't start up - //we shouldn't init MainWindow, just intall plugin and exit. - if (e.Args.Length > 0 && e.Args[0].ToLower() == "installplugin") { - var path = e.Args[1]; - if (!File.Exists(path)) { - MessageBox.Show("Plugin " + path + " didn't exist"); - return; - } - PluginInstaller.Install(path); - Environment.Exit(0); - } - - if (e.Args.Length > 0 && e.Args[0].ToLower() == "plugindebugger") { - var path = e.Args[1]; - PluginLoader.Plugins.ActivatePluginDebugger(path); - } - - window = new MainWindow(); - if (e.Args.Length == 0 || e.Args[0].ToLower() != "hidestart") { - window.ShowApp(); - } - - window.ParseArgs(e.Args); - } - - public void Activate(string[] args) { - if (args.Length == 0 || args[0].ToLower() != "hidestart") { - window.ShowApp(); - } - window.ParseArgs(args); - } - } + public bool OnActivate(IList args) + { + CommandArgsFactory.Execute(args); + return true; + } + } } diff --git a/Wox/CommandArgs/CommandArgsFactory.cs b/Wox/CommandArgs/CommandArgsFactory.cs new file mode 100644 index 0000000000..1e0f3a0dca --- /dev/null +++ b/Wox/CommandArgs/CommandArgsFactory.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Windows.Input; + +namespace Wox.CommandArgs +{ + internal static class CommandArgsFactory + { + private static List commandArgs; + + static CommandArgsFactory() + { + var type = typeof(ICommandArg); + commandArgs = Assembly.GetExecutingAssembly() + .GetTypes() + .Where(p => type.IsAssignableFrom(p) && !p.IsInterface) + .Select(t => Activator.CreateInstance(t) as ICommandArg).ToList(); + } + + public static void Execute(IList args) + { + if (args.Count > 0) + { + string command = args[0]; + ICommandArg cmd = commandArgs.FirstOrDefault(o => o.Command.ToLower() == command); + if (cmd != null) + { + args.RemoveAt(0); //remove command itself + cmd.Execute(args); + } + } + else + { + App.Window.ShowApp(); + } + } + } +} diff --git a/Wox/CommandArgs/HideStartCommandArg.cs b/Wox/CommandArgs/HideStartCommandArg.cs new file mode 100644 index 0000000000..b8ed670632 --- /dev/null +++ b/Wox/CommandArgs/HideStartCommandArg.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Wox.CommandArgs +{ + public class HideStartCommandArg : ICommandArg + { + public string Command + { + get { return "hidestart"; } + } + + public void Execute(IList args) + { + //App.Window.ShowApp(); + //App.Window.HideApp(); + } + } +} diff --git a/Wox/CommandArgs/ICommandArg.cs b/Wox/CommandArgs/ICommandArg.cs new file mode 100644 index 0000000000..be6391ce02 --- /dev/null +++ b/Wox/CommandArgs/ICommandArg.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Wox.CommandArgs +{ + interface ICommandArg + { + string Command { get; } + void Execute(IList args); + } +} diff --git a/Wox/CommandArgs/InstallPluginCommandArg.cs b/Wox/CommandArgs/InstallPluginCommandArg.cs new file mode 100644 index 0000000000..2c921008f3 --- /dev/null +++ b/Wox/CommandArgs/InstallPluginCommandArg.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows; +using Wox.Helper; + +namespace Wox.CommandArgs +{ + public class InstallPluginCommandArg : ICommandArg + { + public string Command + { + get { return "installplugin"; } + } + + public void Execute(IList args) + { + if (args.Count > 0) + { + var path = args[0]; + if (!File.Exists(path)) + { + MessageBox.Show("Plugin " + path + " didn't exist"); + return; + } + PluginInstaller.Install(path); + } + } + } +} \ No newline at end of file diff --git a/Wox/CommandArgs/PluginDebuggerCommandArg.cs b/Wox/CommandArgs/PluginDebuggerCommandArg.cs new file mode 100644 index 0000000000..dadf639f9f --- /dev/null +++ b/Wox/CommandArgs/PluginDebuggerCommandArg.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace Wox.CommandArgs +{ + public class PluginDebuggerCommandArg : ICommandArg + { + public string Command + { + get { return "plugindebugger"; } + } + + public void Execute(IList args) + { + if (args.Count > 0) + { + var pluginFolderPath = args[0]; + PluginLoader.Plugins.ActivatePluginDebugger(pluginFolderPath); + } + } + } +} diff --git a/Wox/CommandArgs/QueryCommandArg.cs b/Wox/CommandArgs/QueryCommandArg.cs new file mode 100644 index 0000000000..faecc733fb --- /dev/null +++ b/Wox/CommandArgs/QueryCommandArg.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Wox.CommandArgs +{ + public class QueryCommandArg : ICommandArg + { + public string Command + { + get { return "query"; } + } + + public void Execute(IList args) + { + if (args.Count > 0) + { + string query = args[0]; + App.Window.ChangeQuery(query); + } + App.Window.ShowApp(); + } + } +} diff --git a/Wox/CommandArgs/ReloadPluginCommandArg.cs b/Wox/CommandArgs/ReloadPluginCommandArg.cs new file mode 100644 index 0000000000..ccc1a25db5 --- /dev/null +++ b/Wox/CommandArgs/ReloadPluginCommandArg.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Wox.PluginLoader; + +namespace Wox.CommandArgs +{ + public class ReloadPluginCommandArg : ICommandArg + { + public string Command + { + get { return "reloadplugin"; } + } + + public void Execute(IList args) + { + Plugins.Init(); + } + } +} diff --git a/Wox/Helper/SingleInstance.cs b/Wox/Helper/SingleInstance.cs new file mode 100644 index 0000000000..c01d7e1085 --- /dev/null +++ b/Wox/Helper/SingleInstance.cs @@ -0,0 +1,487 @@ +//----------------------------------------------------------------------- +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// +// This class checks to make sure that only one instance of +// this application is running at a time. +// +//----------------------------------------------------------------------- + +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Runtime.InteropServices; +using System.Runtime.Remoting; +using System.Runtime.Remoting.Channels; +using System.Runtime.Remoting.Channels.Ipc; +using System.Runtime.Serialization.Formatters; +using System.Security; +using System.Threading; +using System.Windows; +using System.Windows.Threading; + +//http://blogs.microsoft.co.il/arik/2010/05/28/wpf-single-instance-application/ +namespace Wox.Helper +{ + internal enum WM + { + NULL = 0x0000, + CREATE = 0x0001, + DESTROY = 0x0002, + MOVE = 0x0003, + SIZE = 0x0005, + ACTIVATE = 0x0006, + SETFOCUS = 0x0007, + KILLFOCUS = 0x0008, + ENABLE = 0x000A, + SETREDRAW = 0x000B, + SETTEXT = 0x000C, + GETTEXT = 0x000D, + GETTEXTLENGTH = 0x000E, + PAINT = 0x000F, + CLOSE = 0x0010, + QUERYENDSESSION = 0x0011, + QUIT = 0x0012, + QUERYOPEN = 0x0013, + ERASEBKGND = 0x0014, + SYSCOLORCHANGE = 0x0015, + SHOWWINDOW = 0x0018, + ACTIVATEAPP = 0x001C, + SETCURSOR = 0x0020, + MOUSEACTIVATE = 0x0021, + CHILDACTIVATE = 0x0022, + QUEUESYNC = 0x0023, + GETMINMAXINFO = 0x0024, + + WINDOWPOSCHANGING = 0x0046, + WINDOWPOSCHANGED = 0x0047, + + CONTEXTMENU = 0x007B, + STYLECHANGING = 0x007C, + STYLECHANGED = 0x007D, + DISPLAYCHANGE = 0x007E, + GETICON = 0x007F, + SETICON = 0x0080, + NCCREATE = 0x0081, + NCDESTROY = 0x0082, + NCCALCSIZE = 0x0083, + NCHITTEST = 0x0084, + NCPAINT = 0x0085, + NCACTIVATE = 0x0086, + GETDLGCODE = 0x0087, + SYNCPAINT = 0x0088, + NCMOUSEMOVE = 0x00A0, + NCLBUTTONDOWN = 0x00A1, + NCLBUTTONUP = 0x00A2, + NCLBUTTONDBLCLK = 0x00A3, + NCRBUTTONDOWN = 0x00A4, + NCRBUTTONUP = 0x00A5, + NCRBUTTONDBLCLK = 0x00A6, + NCMBUTTONDOWN = 0x00A7, + NCMBUTTONUP = 0x00A8, + NCMBUTTONDBLCLK = 0x00A9, + + SYSKEYDOWN = 0x0104, + SYSKEYUP = 0x0105, + SYSCHAR = 0x0106, + SYSDEADCHAR = 0x0107, + COMMAND = 0x0111, + SYSCOMMAND = 0x0112, + + MOUSEMOVE = 0x0200, + LBUTTONDOWN = 0x0201, + LBUTTONUP = 0x0202, + LBUTTONDBLCLK = 0x0203, + RBUTTONDOWN = 0x0204, + RBUTTONUP = 0x0205, + RBUTTONDBLCLK = 0x0206, + MBUTTONDOWN = 0x0207, + MBUTTONUP = 0x0208, + MBUTTONDBLCLK = 0x0209, + MOUSEWHEEL = 0x020A, + XBUTTONDOWN = 0x020B, + XBUTTONUP = 0x020C, + XBUTTONDBLCLK = 0x020D, + MOUSEHWHEEL = 0x020E, + + + CAPTURECHANGED = 0x0215, + + ENTERSIZEMOVE = 0x0231, + EXITSIZEMOVE = 0x0232, + + IME_SETCONTEXT = 0x0281, + IME_NOTIFY = 0x0282, + IME_CONTROL = 0x0283, + IME_COMPOSITIONFULL = 0x0284, + IME_SELECT = 0x0285, + IME_CHAR = 0x0286, + IME_REQUEST = 0x0288, + IME_KEYDOWN = 0x0290, + IME_KEYUP = 0x0291, + + NCMOUSELEAVE = 0x02A2, + + DWMCOMPOSITIONCHANGED = 0x031E, + DWMNCRENDERINGCHANGED = 0x031F, + DWMCOLORIZATIONCOLORCHANGED = 0x0320, + DWMWINDOWMAXIMIZEDCHANGE = 0x0321, + + #region Windows 7 + DWMSENDICONICTHUMBNAIL = 0x0323, + DWMSENDICONICLIVEPREVIEWBITMAP = 0x0326, + #endregion + + USER = 0x0400, + + // This is the hard-coded message value used by WinForms for Shell_NotifyIcon. + // It's relatively safe to reuse. + TRAYMOUSEMESSAGE = 0x800, //WM_USER + 1024 + APP = 0x8000, + } + + [SuppressUnmanagedCodeSecurity] + internal static class NativeMethods + { + /// + /// Delegate declaration that matches WndProc signatures. + /// + public delegate IntPtr MessageHandler(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled); + + [DllImport("shell32.dll", EntryPoint = "CommandLineToArgvW", CharSet = CharSet.Unicode)] + private static extern IntPtr _CommandLineToArgvW([MarshalAs(UnmanagedType.LPWStr)] string cmdLine, out int numArgs); + + + [DllImport("kernel32.dll", EntryPoint = "LocalFree", SetLastError = true)] + private static extern IntPtr _LocalFree(IntPtr hMem); + + + public static string[] CommandLineToArgvW(string cmdLine) + { + IntPtr argv = IntPtr.Zero; + try + { + int numArgs = 0; + + argv = _CommandLineToArgvW(cmdLine, out numArgs); + if (argv == IntPtr.Zero) + { + throw new Win32Exception(); + } + var result = new string[numArgs]; + + for (int i = 0; i < numArgs; i++) + { + IntPtr currArg = Marshal.ReadIntPtr(argv, i * Marshal.SizeOf(typeof(IntPtr))); + result[i] = Marshal.PtrToStringUni(currArg); + } + + return result; + } + finally + { + + IntPtr p = _LocalFree(argv); + // Otherwise LocalFree failed. + // Assert.AreEqual(IntPtr.Zero, p); + } + } + + } + + public interface ISingleInstanceApp + { + bool OnActivate(IList args); + } + + /// + /// This class checks to make sure that only one instance of + /// this application is running at a time. + /// + /// + /// Note: this class should be used with some caution, because it does no + /// security checking. For example, if one instance of an app that uses this class + /// is running as Administrator, any other instance, even if it is not + /// running as Administrator, can activate it with command line arguments. + /// For most apps, this will not be much of an issue. + /// + public static class SingleInstance + where TApplication: Application , ISingleInstanceApp + + { + #region Private Fields + + /// + /// String delimiter used in channel names. + /// + private const string Delimiter = ":"; + + /// + /// Suffix to the channel name. + /// + private const string ChannelNameSuffix = "SingeInstanceIPCChannel"; + + /// + /// Remote service name. + /// + private const string RemoteServiceName = "SingleInstanceApplicationService"; + + /// + /// IPC protocol used (string). + /// + private const string IpcProtocol = "ipc://"; + + /// + /// Application mutex. + /// + private static Mutex singleInstanceMutex; + + /// + /// IPC channel for communications. + /// + private static IpcServerChannel channel; + + /// + /// List of command line arguments for the application. + /// + private static IList commandLineArgs; + + #endregion + + #region Public Properties + + /// + /// Gets list of command line arguments for the application. + /// + public static IList CommandLineArgs + { + get { return commandLineArgs; } + } + + #endregion + + #region Public Methods + + /// + /// Checks if the instance of the application attempting to start is the first instance. + /// If not, activates the first instance. + /// + /// True if this is the first instance of the application. + public static bool InitializeAsFirstInstance( string uniqueName ) + { + commandLineArgs = GetCommandLineArgs(uniqueName); + + // Build unique application Id and the IPC channel name. + string applicationIdentifier = uniqueName + Environment.UserName; + + string channelName = String.Concat(applicationIdentifier, Delimiter, ChannelNameSuffix); + + // Create mutex based on unique application Id to check if this is the first instance of the application. + bool firstInstance; + singleInstanceMutex = new Mutex(true, applicationIdentifier, out firstInstance); + if (firstInstance) + { + CreateRemoteService(channelName); + } + else + { + SignalFirstInstance(channelName, commandLineArgs); + } + + return firstInstance; + } + + /// + /// Cleans up single-instance code, clearing shared resources, mutexes, etc. + /// + public static void Cleanup() + { + if (singleInstanceMutex != null) + { + singleInstanceMutex.Close(); + singleInstanceMutex = null; + } + + if (channel != null) + { + ChannelServices.UnregisterChannel(channel); + channel = null; + } + } + + #endregion + + #region Private Methods + + /// + /// Gets command line args - for ClickOnce deployed applications, command line args may not be passed directly, they have to be retrieved. + /// + /// List of command line arg strings. + private static IList GetCommandLineArgs( string uniqueApplicationName ) + { + string[] args = null; + if (AppDomain.CurrentDomain.ActivationContext == null) + { + // The application was not clickonce deployed, get args from standard API's + args = Environment.GetCommandLineArgs(); + } + else + { + // The application was clickonce deployed + // Clickonce deployed apps cannot recieve traditional commandline arguments + // As a workaround commandline arguments can be written to a shared location before + // the app is launched and the app can obtain its commandline arguments from the + // shared location + string appFolderPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), uniqueApplicationName); + + string cmdLinePath = Path.Combine(appFolderPath, "cmdline.txt"); + if (File.Exists(cmdLinePath)) + { + try + { + using (TextReader reader = new StreamReader(cmdLinePath, System.Text.Encoding.Unicode)) + { + args = NativeMethods.CommandLineToArgvW(reader.ReadToEnd()); + } + + File.Delete(cmdLinePath); + } + catch (IOException) + { + } + } + } + + if (args == null) + { + args = new string[] { }; + } + + return new List(args); + } + + /// + /// Creates a remote service for communication. + /// + /// Application's IPC channel name. + private static void CreateRemoteService(string channelName) + { + BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); + serverProvider.TypeFilterLevel = TypeFilterLevel.Full; + IDictionary props = new Dictionary(); + + props["name"] = channelName; + props["portName"] = channelName; + props["exclusiveAddressUse"] = "false"; + + // Create the IPC Server channel with the channel properties + channel = new IpcServerChannel(props, serverProvider); + + // Register the channel with the channel services + ChannelServices.RegisterChannel(channel, true); + + // Expose the remote service with the REMOTE_SERVICE_NAME + IPCRemoteService remoteService = new IPCRemoteService(); + RemotingServices.Marshal(remoteService, RemoteServiceName); + } + + /// + /// Creates a client channel and obtains a reference to the remoting service exposed by the server - + /// in this case, the remoting service exposed by the first instance. Calls a function of the remoting service + /// class to pass on command line arguments from the second instance to the first and cause it to activate itself. + /// + /// Application's IPC channel name. + /// + /// Command line arguments for the second instance, passed to the first instance to take appropriate action. + /// + private static void SignalFirstInstance(string channelName, IList args) + { + IpcClientChannel secondInstanceChannel = new IpcClientChannel(); + ChannelServices.RegisterChannel(secondInstanceChannel, true); + + string remotingServiceUrl = IpcProtocol + channelName + "/" + RemoteServiceName; + + // Obtain a reference to the remoting service exposed by the server i.e the first instance of the application + IPCRemoteService firstInstanceRemoteServiceReference = (IPCRemoteService)RemotingServices.Connect(typeof(IPCRemoteService), remotingServiceUrl); + + // Check that the remote service exists, in some cases the first instance may not yet have created one, in which case + // the second instance should just exit + if (firstInstanceRemoteServiceReference != null) + { + // Invoke a method of the remote service exposed by the first instance passing on the command line + // arguments and causing the first instance to activate itself + firstInstanceRemoteServiceReference.InvokeFirstInstance(args); + } + } + + /// + /// Callback for activating first instance of the application. + /// + /// Callback argument. + /// Always null. + private static object ActivateFirstInstanceCallback(object arg) + { + // Get command line args to be passed to first instance + IList args = arg as IList; + ActivateFirstInstance(args); + return null; + } + + /// + /// Activates the first instance of the application with arguments from a second instance. + /// + /// List of arguments to supply the first instance of the application. + private static void ActivateFirstInstance(IList args) + { + // Set main window state and process command line args + if (Application.Current == null) + { + return; + } + //remove execute path itself + args.RemoveAt(0); + ((TApplication)Application.Current).OnActivate(args); + } + + #endregion + + #region Private Classes + + /// + /// Remoting service class which is exposed by the server i.e the first instance and called by the second instance + /// to pass on the command line arguments to the first instance and cause it to activate itself. + /// + private class IPCRemoteService : MarshalByRefObject + { + /// + /// Activates the first instance of the application. + /// + /// List of arguments to pass to the first instance. + public void InvokeFirstInstance(IList args) + { + if (Application.Current != null) + { + // Do an asynchronous call to ActivateFirstInstance function + Application.Current.Dispatcher.BeginInvoke( + DispatcherPriority.Normal, new DispatcherOperationCallback(SingleInstance.ActivateFirstInstanceCallback), args); + } + } + + /// + /// Remoting Object's ease expires after every 5 minutes by default. We need to override the InitializeLifetimeService class + /// to ensure that lease never expires. + /// + /// Always null. + public override object InitializeLifetimeService() + { + return null; + } + } + + #endregion + } +} diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index d0b5ca5318..5c8abba11c 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -392,42 +392,6 @@ namespace Wox if (selectAll) tbQuery.SelectAll(); } - public void ParseArgs(string[] args) - { - if (args != null && args.Length > 0) - { - switch (args[0].ToLower()) - { - case "reloadplugin": - Plugins.Init(); - break; - - case "query": - if (args.Length > 1) - { - string query = args[1]; - tbQuery.Text = query; - tbQuery.SelectAll(); - } - break; - - case "hidestart": - HideApp(); - break; - - case "installplugin": - var path = args[1]; - if (!File.Exists(path)) - { - MessageBox.Show("Plugin " + path + " didn't exist"); - return; - } - PluginInstaller.Install(path); - break; - } - } - } - private void MainWindow_OnDeactivated(object sender, EventArgs e) { if (UserSettingStorage.Instance.HideWhenDeactive) diff --git a/Wox/SettingWindow.xaml.cs b/Wox/SettingWindow.xaml.cs index db98718839..5e76e7dc24 100644 --- a/Wox/SettingWindow.xaml.cs +++ b/Wox/SettingWindow.xaml.cs @@ -10,10 +10,6 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using IWshRuntimeLibrary; -using Microsoft.VisualBasic.ApplicationServices; -using Wox.Converters; -using Wox.Infrastructure; -using Wox.Infrastructure.Storage; using Wox.Infrastructure.Storage.UserSettings; using Wox.Plugin; using Wox.Helper; @@ -23,7 +19,6 @@ using Application = System.Windows.Forms.Application; using File = System.IO.File; using MessageBox = System.Windows.MessageBox; using System.Windows.Data; -using Label = System.Windows.Forms.Label; namespace Wox { diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 14f4194d30..68211d8da7 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -56,7 +56,7 @@ app.ico - Wox.EntryPoint + Wox.App @@ -68,7 +68,6 @@ False ..\packages\log4net.2.0.3\lib\net35-full\log4net.dll - False ..\packages\Newtonsoft.Json.6.0.5\lib\net35\Newtonsoft.Json.dll @@ -87,6 +86,7 @@ + @@ -103,13 +103,20 @@ - + MSBuild:Compile Designer - + ActionKeyword.xaml + + + + + + + @@ -125,6 +132,7 @@ +