"start wox on system startup" config changes.

This commit is contained in:
qianlifeng
2014-02-07 22:10:00 +08:00
parent 67f14d6a62
commit 3442081d20
5 changed files with 28 additions and 31 deletions

View File

@@ -66,7 +66,6 @@ namespace Wox.Infrastructure
var process = new Process(); var process = new Process();
process.StartInfo = psi; process.StartInfo = psi;
process.Start(); process.Start();
process.WaitForExit();
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -9,6 +9,8 @@ namespace Wox.Infrastructure.UserSettings
public bool ReplaceWinR { get; set; } public bool ReplaceWinR { get; set; }
public List<WebSearch> WebSearches { get; set; } public List<WebSearch> WebSearches { get; set; }
public bool StartWoxOnSystemStartup { get; set; }
public List<WebSearch> LoadDefaultWebSearches() public List<WebSearch> LoadDefaultWebSearches()
{ {
List<WebSearch> webSearches = new List<WebSearch>(); List<WebSearch> webSearches = new List<WebSearch>();

View File

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

View File

@@ -38,6 +38,7 @@ namespace Wox
{ {
InitializeComponent(); InitializeComponent();
InitialTray();
hook.KeyPressed += OnHotKey; hook.KeyPressed += OnHotKey;
hook.RegisterHotKey(XModifierKeys.Alt, Keys.Space); hook.RegisterHotKey(XModifierKeys.Alt, Keys.Space);
resultCtrl.resultItemChangedEvent += resultCtrl_resultItemChangedEvent; resultCtrl.resultItemChangedEvent += resultCtrl_resultItemChangedEvent;
@@ -151,7 +152,7 @@ namespace Wox
}, TimeSpan.FromSeconds(1), tbQuery.Text); }, TimeSpan.FromSeconds(1), tbQuery.Text);
} }
}, TimeSpan.FromMilliseconds(300)); }, TimeSpan.FromMilliseconds(150));
} }
private void StartProgress() private void StartProgress()
@@ -196,41 +197,22 @@ namespace Wox
tbQuery.SelectAll(); tbQuery.SelectAll();
} }
break; break;
case "starthide":
HideApp();
break;
} }
} }
} }
private void SetAutoStart(bool IsAtuoRun)
{
//string LnkPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "//Wox.lnk";
//if (IsAtuoRun)
//{
// WshShell shell = new WshShell();
// IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(LnkPath);
// shortcut.TargetPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
// shortcut.WorkingDirectory = Environment.CurrentDirectory;
// shortcut.WindowStyle = 1; //normal window
// shortcut.Description = "Wox";
// shortcut.Save();
//}
//else
//{
// System.IO.File.Delete(LnkPath);
//}
}
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{ {
Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2; Left = (SystemParameters.PrimaryScreenWidth - ActualWidth) / 2;
Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3; Top = (SystemParameters.PrimaryScreenHeight - ActualHeight) / 3;
Plugins.Init();
InitialTray();
SetAutoStart(true);
WakeupApp(); WakeupApp();
Plugins.Init();
//var engine = new Jurassic.ScriptEngine();
//MessageBox.Show(engine.Evaluate("5 * 10 + 2").ToString());
keyboardListener.hookedKeyboardCallback += KListener_hookedKeyboardCallback; keyboardListener.hookedKeyboardCallback += KListener_hookedKeyboardCallback;
} }

View File

@@ -53,6 +53,7 @@ namespace Wox
themeComboBox.SelectedItem = CommonStorage.Instance.UserSetting.Theme; themeComboBox.SelectedItem = CommonStorage.Instance.UserSetting.Theme;
cbReplaceWinR.IsChecked = CommonStorage.Instance.UserSetting.ReplaceWinR; cbReplaceWinR.IsChecked = CommonStorage.Instance.UserSetting.ReplaceWinR;
webSearchView.ItemsSource = CommonStorage.Instance.UserSetting.WebSearches; webSearchView.ItemsSource = CommonStorage.Instance.UserSetting.WebSearches;
cbStartWithWindows.IsChecked = CommonStorage.Instance.UserSetting.StartWoxOnSystemStartup;
} }
public void ReloadWebSearchView() public void ReloadWebSearchView()
@@ -111,15 +112,21 @@ namespace Wox
} }
} }
private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e) private void CbStartWithWindows_OnChecked(object sender, RoutedEventArgs e)
{ {
OnStartWithWindowsChecked(); if (!CommonStorage.Instance.UserSetting.StartWoxOnSystemStartup)
{
CommonStorage.Instance.UserSetting.StartWoxOnSystemStartup = true;
OnStartWithWindowsChecked();
CommonStorage.Instance.Save();
}
} }
private void CbStartWithWindows_OnUnchecked(object sender, RoutedEventArgs e) private void CbStartWithWindows_OnUnchecked(object sender, RoutedEventArgs e)
{ {
CommonStorage.Instance.UserSetting.StartWoxOnSystemStartup = false;
OnStartWithWindowUnChecked(); OnStartWithWindowUnChecked();
CommonStorage.Instance.Save();
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
@@ -142,7 +149,7 @@ namespace Wox
{ {
if (startup) if (startup)
{ {
rk.SetValue("Wox",Path.Combine(Directory.GetCurrentDirectory(),"Wox.exe startHide")); rk.SetValue("Wox", Path.Combine(Directory.GetCurrentDirectory(), "Wox.exe startHide"));
} }
else else
{ {