Fix "startup wox on window start" issue.

This commit is contained in:
qianlifeng
2014-02-18 22:02:55 +08:00
parent fcdb9e39c6
commit b8fbc837dc
5 changed files with 22 additions and 9 deletions

View File

@@ -55,7 +55,7 @@ namespace Wox.Infrastructure
Debug.WriteLine(args); Debug.WriteLine(args);
var psi = new ProcessStartInfo var psi = new ProcessStartInfo
{ {
FileName = Path.Combine(Directory.GetCurrentDirectory(), "Wox.UAC.exe"), FileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Wox.UAC.exe"),
Arguments = args, Arguments = args,
CreateNoWindow = true, CreateNoWindow = true,
Verb = "runas" Verb = "runas"

View File

@@ -67,7 +67,7 @@ namespace Wox
base.OnStartup(e); base.OnStartup(e);
window = new MainWindow(); window = new MainWindow();
if (e.Args.Length == 0 || e.Args[0].ToLower() != "starthide") if (e.Args.Length == 0 || e.Args[0].ToLower() != "hidestart")
{ {
window.ShowApp(); window.ShowApp();
} }
@@ -77,7 +77,7 @@ namespace Wox
public void Activate(string[] args) public void Activate(string[] args)
{ {
if (args.Length == 0 || args[0].ToLower() != "starthide") if (args.Length == 0 || args[0].ToLower() != "hidestart")
{ {
window.ShowApp(); window.ShowApp();
} }

View File

@@ -10,6 +10,7 @@ using System.Windows.Controls;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using System.Windows.Threading;
using Wox.Commands; using Wox.Commands;
using Wox.Helper; using Wox.Helper;
using Wox.Infrastructure; using Wox.Infrastructure;
@@ -31,6 +32,7 @@ namespace Wox
private KeyboardListener keyboardListener = new KeyboardListener(); private KeyboardListener keyboardListener = new KeyboardListener();
private bool WinRStroked = false; private bool WinRStroked = false;
private static object locker = new object();
private WindowsInput.KeyboardSimulator keyboardSimulator = new WindowsInput.KeyboardSimulator(new WindowsInput.InputSimulator()); private WindowsInput.KeyboardSimulator keyboardSimulator = new WindowsInput.KeyboardSimulator(new WindowsInput.InputSimulator());
@@ -198,7 +200,7 @@ namespace Wox
} }
break; break;
case "starthide": case "hidestart":
HideApp(); HideApp();
break; break;
} }
@@ -300,11 +302,14 @@ namespace Wox
{ {
if (o.AutoAjustScore) o.Score += CommonStorage.Instance.UserSelectedRecords.GetSelectedCount(o); if (o.AutoAjustScore) o.Score += CommonStorage.Instance.UserSelectedRecords.GetSelectedCount(o);
}); });
resultCtrl.Dispatcher.Invoke(new Action(() => lock (locker)
{ {
List<Result> l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).ToList(); resultCtrl.Dispatcher.Invoke(new Action(() =>
resultCtrl.AddResults(l); {
})); List<Result> l = list.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).ToList();
resultCtrl.AddResults(list);
}));
}
} }
} }

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Security.Permissions; using System.Security.Permissions;
using System.Windows; using System.Windows;
@@ -149,7 +150,7 @@ namespace Wox
{ {
if (startup) if (startup)
{ {
rk.SetValue("Wox", Path.Combine(Directory.GetCurrentDirectory(), "Wox.exe startHide")); rk.SetValue("Wox", Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Wox.exe hidestart"));
} }
else else
{ {

View File

@@ -140,6 +140,9 @@
<Compile Include="ResultItem.xaml.cs"> <Compile Include="ResultItem.xaml.cs">
<DependentUpon>ResultItem.xaml</DependentUpon> <DependentUpon>ResultItem.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ResultWindow.xaml.cs">
<DependentUpon>ResultWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SettingWindow.xaml.cs"> <Compile Include="SettingWindow.xaml.cs">
<DependentUpon>SettingWindow.xaml</DependentUpon> <DependentUpon>SettingWindow.xaml</DependentUpon>
</Compile> </Compile>
@@ -170,6 +173,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="ResultWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SettingWindow.xaml"> <Page Include="SettingWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>