[#43] App: Use FileSystemWatcher to renew contexts on demand
This commit is contained in:
@ -60,6 +60,10 @@ namespace Elwig {
|
||||
public static ClientParameters Client { get; set; }
|
||||
|
||||
public static Dispatcher MainDispatcher { get; private set; }
|
||||
private readonly FileSystemWatcher Watcher = new(Path.GetDirectoryName(Config.DatabaseFile) ?? "C:\\") {
|
||||
NotifyFilter = NotifyFilters.LastWrite,
|
||||
Filter = "*.sqlite3",
|
||||
};
|
||||
|
||||
public App() : base() {
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
@ -69,6 +73,12 @@ namespace Elwig {
|
||||
Scales = [];
|
||||
CurrentApp = this;
|
||||
OverrideCulture();
|
||||
Watcher.Changed += new FileSystemEventHandler(OnChanged);
|
||||
Watcher.EnableRaisingEvents = true;
|
||||
}
|
||||
|
||||
private void OnChanged(object source, FileSystemEventArgs e) {
|
||||
MainDispatcher.BeginInvoke(async () => await HintContextChange());
|
||||
}
|
||||
|
||||
private static void OverrideCulture() {
|
||||
|
Reference in New Issue
Block a user