mirror of
https://github.com/2dust/v2rayN.git
synced 2026-07-26 09:52:05 +03:00
Fixed the issue with RefreshIcon's call in the desktop version.
This commit is contained in:
@@ -45,8 +45,7 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||
|
||||
ViewModel.DispatcherRefreshIconInteraction.RegisterHandler(interaction =>
|
||||
{
|
||||
Dispatcher.UIThread.Post(RefreshIcon,
|
||||
DispatcherPriority.Default);
|
||||
Dispatcher.UIThread.Post(RefreshIcon, DispatcherPriority.Default);
|
||||
interaction.SetOutput(Unit.Default);
|
||||
}).DisposeWith(disposables);
|
||||
});
|
||||
@@ -57,6 +56,9 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||
{
|
||||
cmbSystemProxy.Items.RemoveAt(cmbSystemProxy.Items.Count - 1);
|
||||
}
|
||||
|
||||
// Because this view has not yet been initialized when DispatcherRefreshIconInteraction is first called.
|
||||
RefreshIcon();
|
||||
}
|
||||
|
||||
private void RefreshIcon()
|
||||
|
||||
@@ -71,16 +71,18 @@ public partial class StatusBarView
|
||||
|
||||
ViewModel.DispatcherRefreshIconInteraction.RegisterHandler(interaction =>
|
||||
{
|
||||
Application.Current?.Dispatcher.Invoke(async () =>
|
||||
{
|
||||
tbNotify.Icon = await WindowsManager.Instance.GetNotifyIcon(_config);
|
||||
Application.Current.MainWindow?.Icon = WindowsManager.Instance.GetAppIcon(_config);
|
||||
}, DispatcherPriority.Normal);
|
||||
Application.Current?.Dispatcher.Invoke(async () => await RefreshIcon(), DispatcherPriority.Normal);
|
||||
interaction.SetOutput(Unit.Default);
|
||||
}).DisposeWith(disposables);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task RefreshIcon()
|
||||
{
|
||||
tbNotify.Icon = await WindowsManager.Instance.GetNotifyIcon(_config);
|
||||
Application.Current.MainWindow?.Icon = WindowsManager.Instance.GetAppIcon(_config);
|
||||
}
|
||||
|
||||
private async void menuExit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tbNotify.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user