mirror of https://github.com/2dust/v2rayN
Using RxApp replace ViewAction
parent
ef4a1903ec
commit
e3a63db966
|
@ -6,7 +6,6 @@ public enum EViewAction
|
|||
ShowYesNo,
|
||||
SaveFileDialog,
|
||||
AddBatchRoutingRulesYesNo,
|
||||
AdjustMainLvColWidth,
|
||||
SetClipboardData,
|
||||
AddServerViaClipboard,
|
||||
ImportRulesFromClipboard,
|
||||
|
|
|
@ -13,5 +13,7 @@ public static class AppEvents
|
|||
|
||||
public static readonly Subject<Unit> AppExitRequested = new();
|
||||
|
||||
public static readonly Subject<Unit> AdjustMainLvColWidthRequested = new();
|
||||
|
||||
public static readonly Subject<ServerSpeedItem> DispatcherStatisticsRequested = new();
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
}
|
||||
if (_config.UiItem.EnableAutoAdjustMainLvColWidth)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null);
|
||||
AppEvents.AdjustMainLvColWidthRequested.OnNext(Unit.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,11 +348,6 @@ public class ProfilesViewModel : MyReactiveObject
|
|||
}
|
||||
}
|
||||
|
||||
public async Task AutofitColumnWidthAsync()
|
||||
{
|
||||
await _updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null);
|
||||
}
|
||||
|
||||
#endregion Actions
|
||||
|
||||
#region Servers && Groups
|
||||
|
|
|
@ -250,12 +250,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||
await ViewModel.AddServerViaClipboardAsync(clipboardData);
|
||||
}
|
||||
break;
|
||||
|
||||
case EViewAction.AdjustMainLvColWidth:
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidthAsync(),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
|
|
|
@ -103,6 +103,12 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
|||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(_ => StorageUI())
|
||||
.DisposeWith(disposables);
|
||||
|
||||
AppEvents.AdjustMainLvColWidthRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(_ => AutofitColumnWidth())
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
|
||||
RestoreUI();
|
||||
|
@ -133,13 +139,6 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
|||
await AvaUtils.SetClipboardData(this, (string)obj);
|
||||
break;
|
||||
|
||||
case EViewAction.AdjustMainLvColWidth:
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
AutofitColumnWidth(),
|
||||
DispatcherPriority.Default);
|
||||
|
||||
break;
|
||||
|
||||
case EViewAction.ProfilesFocus:
|
||||
lstProfiles.Focus();
|
||||
break;
|
||||
|
|
|
@ -234,13 +234,6 @@ public partial class MainWindow
|
|||
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
||||
}
|
||||
break;
|
||||
|
||||
case EViewAction.AdjustMainLvColWidth:
|
||||
Application.Current?.Dispatcher.Invoke((() =>
|
||||
{
|
||||
Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidthAsync();
|
||||
}), DispatcherPriority.Normal);
|
||||
break;
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
|
|
|
@ -97,6 +97,12 @@ public partial class ProfilesView
|
|||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(_ => StorageUI())
|
||||
.DisposeWith(disposables);
|
||||
|
||||
AppEvents.AdjustMainLvColWidthRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(_ => AutofitColumnWidth())
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
|
||||
RestoreUI();
|
||||
|
@ -113,14 +119,7 @@ public partial class ProfilesView
|
|||
if (obj is null)
|
||||
return false;
|
||||
WindowsUtils.SetClipboardData((string)obj);
|
||||
break;
|
||||
|
||||
case EViewAction.AdjustMainLvColWidth:
|
||||
Application.Current?.Dispatcher.Invoke((() =>
|
||||
{
|
||||
AutofitColumnWidth();
|
||||
}), DispatcherPriority.Normal);
|
||||
break;
|
||||
break;
|
||||
|
||||
case EViewAction.ProfilesFocus:
|
||||
lstProfiles.Focus();
|
||||
|
|
Loading…
Reference in New Issue