mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Save more
This commit is contained in:
@@ -22,6 +22,8 @@ namespace Wox
|
|||||||
private const string Unique = "Wox_Unique_Application_Mutex";
|
private const string Unique = "Wox_Unique_Application_Mutex";
|
||||||
private static bool _disposed;
|
private static bool _disposed;
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
|
private MainViewModel _mainVM;
|
||||||
|
private SettingWindowViewModel _settingsVM;
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main()
|
public static void Main()
|
||||||
@@ -48,13 +50,13 @@ namespace Wox
|
|||||||
ImageLoader.Initialize();
|
ImageLoader.Initialize();
|
||||||
Alphabet.Initialize();
|
Alphabet.Initialize();
|
||||||
|
|
||||||
var settingVM = new SettingWindowViewModel();
|
_settingsVM = new SettingWindowViewModel();
|
||||||
_settings = settingVM.Settings;
|
_settings = _settingsVM.Settings;
|
||||||
|
|
||||||
PluginManager.LoadPlugins(_settings.PluginSettings);
|
PluginManager.LoadPlugins(_settings.PluginSettings);
|
||||||
var mainVM = new MainViewModel(_settings);
|
_mainVM = new MainViewModel(_settings);
|
||||||
var window = new MainWindow(_settings, mainVM);
|
var window = new MainWindow(_settings, _mainVM);
|
||||||
API = new PublicAPIInstance(settingVM, mainVM);
|
API = new PublicAPIInstance(_settingsVM, _mainVM);
|
||||||
PluginManager.InitializePlugins(API);
|
PluginManager.InitializePlugins(API);
|
||||||
|
|
||||||
Current.MainWindow = window;
|
Current.MainWindow = window;
|
||||||
@@ -75,7 +77,7 @@ namespace Wox
|
|||||||
AutoStartup();
|
AutoStartup();
|
||||||
AutoUpdates();
|
AutoUpdates();
|
||||||
|
|
||||||
mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible;
|
_mainVM.MainWindowVisibility = _settings.HideOnStartup ? Visibility.Hidden : Visibility.Visible;
|
||||||
Log.Info("|App.OnStartup|End Wox startup ---------------------------------------------------- ");
|
Log.Info("|App.OnStartup|End Wox startup ---------------------------------------------------- ");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -98,16 +100,14 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
// check udpate every 5 hours
|
// check udpate every 5 hours
|
||||||
var timer = new Timer(1000 * 60 * 60 * 5);
|
var timer = new Timer(1000 * 60 * 60 * 5);
|
||||||
timer.Elapsed += (s, e) =>
|
timer.Elapsed += (s, e) => { Updater.UpdateApp(); };
|
||||||
{
|
|
||||||
Updater.UpdateApp();
|
|
||||||
};
|
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
|
||||||
// check updates on startup
|
// check updates on startup
|
||||||
Updater.UpdateApp();
|
Updater.UpdateApp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterExitEvents()
|
private void RegisterExitEvents()
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.ProcessExit += (s, e) => Dispose();
|
AppDomain.CurrentDomain.ProcessExit += (s, e) => Dispose();
|
||||||
@@ -125,19 +125,15 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// let exception throw as normal is better for Debug
|
/// let exception throw as normal is better for Debug
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Conditional("RELEASE")]
|
[Conditional("RELEASE")]
|
||||||
private static void RegisterAppDomainExceptions()
|
private static void RegisterAppDomainExceptions()
|
||||||
{
|
{
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle;
|
AppDomain.CurrentDomain.UnhandledException += ErrorReporting.UnhandledExceptionHandle;
|
||||||
AppDomain.CurrentDomain.FirstChanceException += (s, e) =>
|
AppDomain.CurrentDomain.FirstChanceException +=
|
||||||
{
|
(s, e) => { Log.Exception("|App.RegisterAppDomainExceptions|First Chance Exception:", e.Exception); };
|
||||||
Log.Exception("|App.RegisterAppDomainExceptions|First Chance Exception:", e.Exception);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
@@ -146,7 +142,8 @@ namespace Wox
|
|||||||
// but if sessionending is not called, exit won't be called when log off / shutdown
|
// but if sessionending is not called, exit won't be called when log off / shutdown
|
||||||
if (!_disposed)
|
if (!_disposed)
|
||||||
{
|
{
|
||||||
Current.Dispatcher.Invoke(() => ((MainViewModel)Current.MainWindow?.DataContext)?.Save());
|
_mainVM.Save();
|
||||||
|
_settingsVM.Save();
|
||||||
|
|
||||||
PluginManager.Save();
|
PluginManager.Save();
|
||||||
ImageLoader.Save();
|
ImageLoader.Save();
|
||||||
|
|||||||
@@ -11,12 +11,10 @@ using Wox.Helper;
|
|||||||
using Wox.Infrastructure.UserSettings;
|
using Wox.Infrastructure.UserSettings;
|
||||||
using Wox.ViewModel;
|
using Wox.ViewModel;
|
||||||
using Screen = System.Windows.Forms.Screen;
|
using Screen = System.Windows.Forms.Screen;
|
||||||
using ContextMenu = System.Windows.Forms.ContextMenu;
|
|
||||||
using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
|
using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
|
||||||
using DataFormats = System.Windows.DataFormats;
|
using DataFormats = System.Windows.DataFormats;
|
||||||
using DragEventArgs = System.Windows.DragEventArgs;
|
using DragEventArgs = System.Windows.DragEventArgs;
|
||||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||||
using MenuItem = System.Windows.Forms.MenuItem;
|
|
||||||
using MessageBox = System.Windows.MessageBox;
|
using MessageBox = System.Windows.MessageBox;
|
||||||
using NotifyIcon = System.Windows.Forms.NotifyIcon;
|
using NotifyIcon = System.Windows.Forms.NotifyIcon;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ using Squirrel;
|
|||||||
using Wox.Core.Plugin;
|
using Wox.Core.Plugin;
|
||||||
using Wox.Core.Resource;
|
using Wox.Core.Resource;
|
||||||
using Wox.Helper;
|
using Wox.Helper;
|
||||||
|
using Wox.Infrastructure;
|
||||||
using Wox.Infrastructure.Hotkey;
|
using Wox.Infrastructure.Hotkey;
|
||||||
|
using Wox.Infrastructure.Image;
|
||||||
using Wox.Plugin;
|
using Wox.Plugin;
|
||||||
using Wox.ViewModel;
|
using Wox.ViewModel;
|
||||||
|
|
||||||
@@ -53,11 +55,16 @@ namespace Wox
|
|||||||
public void RestarApp()
|
public void RestarApp()
|
||||||
{
|
{
|
||||||
_mainVM.MainWindowVisibility = Visibility.Hidden;
|
_mainVM.MainWindowVisibility = Visibility.Hidden;
|
||||||
|
|
||||||
// we must manually save
|
// we must manually save
|
||||||
// UpdateManager.RestartApp() will call Environment.Exit(0)
|
// UpdateManager.RestartApp() will call Environment.Exit(0)
|
||||||
// which will cause ungraceful exit
|
// which will cause ungraceful exit
|
||||||
var vm = (MainViewModel) Application.Current.MainWindow.DataContext;
|
_mainVM.Save();
|
||||||
vm.Save();
|
_settingsVM.Save();
|
||||||
|
PluginManager.Save();
|
||||||
|
ImageLoader.Save();
|
||||||
|
Alphabet.Save();
|
||||||
|
|
||||||
UpdateManager.RestartApp();
|
UpdateManager.RestartApp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user