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