mirror of
https://github.com/yaobiao131/downkyicore.git
synced 2025-08-10 00:52:31 +00:00
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Threading;
|
||||
using DownKyi.Core.Settings;
|
||||
using DownKyi.Events;
|
||||
@@ -17,6 +19,10 @@ public class MainWindowViewModel : BindableBase
|
||||
{
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
|
||||
private readonly IRegionManager _regionManager;
|
||||
|
||||
private const string ContentRegion = nameof(ContentRegion);
|
||||
|
||||
private ClipboardListener? _clipboardListener;
|
||||
|
||||
private bool _messageVisibility;
|
||||
@@ -50,6 +56,9 @@ public class MainWindowViewModel : BindableBase
|
||||
|
||||
public DelegateCommand ClosingCommand => _closingCommand ??= _closingCommand = new DelegateCommand(ExecuteClosingCommand);
|
||||
|
||||
public DelegateCommand<PointerPressedEventArgs> PointerPressedCommand =>
|
||||
new (ExecutePointerPressed);
|
||||
|
||||
private void ExecuteClosingCommand()
|
||||
{
|
||||
if (_clipboardListener == null) return;
|
||||
@@ -57,11 +66,29 @@ public class MainWindowViewModel : BindableBase
|
||||
_clipboardListener.Dispose();
|
||||
}
|
||||
|
||||
private void ExecutePointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
var point = e.GetCurrentPoint(null);
|
||||
var updateKind = point.Properties.PointerUpdateKind;
|
||||
if (updateKind == PointerUpdateKind.XButton1Pressed)
|
||||
{
|
||||
var v = GetCurrentUserControl()?.DataContext;
|
||||
if (v is ViewModelBase vm)
|
||||
{
|
||||
vm.ExecuteBackSpace();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UserControl? GetCurrentUserControl() => _regionManager
|
||||
.Regions[ContentRegion].ActiveViews
|
||||
.FirstOrDefault() as UserControl;
|
||||
|
||||
public MainWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
|
||||
{
|
||||
_eventAggregator = eventAggregator;
|
||||
|
||||
_regionManager = regionManager;
|
||||
#region MyRegion
|
||||
|
||||
_eventAggregator.GetEvent<NavigationEvent>().Subscribe(view =>
|
||||
@@ -71,7 +98,7 @@ public class MainWindowViewModel : BindableBase
|
||||
{ "Parent", view.ParentViewName },
|
||||
{ "Parameter", view.Parameter }
|
||||
};
|
||||
regionManager.RequestNavigate("ContentRegion", view.ViewName, param);
|
||||
regionManager.RequestNavigate(ContentRegion, view.ViewName, param);
|
||||
});
|
||||
|
||||
// 订阅消息发送事件
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ViewDownloadManagerViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
var parameter = new NavigationParam
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace DownKyi.ViewModels
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
//InitView();
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ViewLoginViewModel : ViewModelBase
|
||||
|
||||
public DelegateCommand BackSpaceCommand => _backSpaceCommand ??= new DelegateCommand(ExecuteBackSpace);
|
||||
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
// 初始化状态
|
||||
InitStatus();
|
||||
|
||||
@@ -34,6 +34,11 @@ public class ViewModelBase : BindableBase, INavigationAware
|
||||
ParentView = viewName;
|
||||
}
|
||||
}
|
||||
|
||||
protected internal virtual void ExecuteBackSpace()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool IsNavigationTarget(NavigationContext navigationContext)
|
||||
{
|
||||
@@ -61,4 +66,5 @@ public class ViewModelBase : BindableBase, INavigationAware
|
||||
{
|
||||
Dispatcher.UIThread.Invoke(callback);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class ViewMyBangumiFollowViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
InitView();
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ public class ViewMyFavoritesViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
InitView();
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ public class ViewMyHistoryViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
InitView();
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ public class ViewMySpaceViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
// 结束任务
|
||||
_tokenSource?.Cancel();
|
||||
|
||||
@@ -136,7 +136,7 @@ public class ViewMyToViewVideoViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
InitView();
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public class ViewPublicFavoritesViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
// 结束任务
|
||||
_tokenSource?.Cancel();
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace DownKyi.ViewModels
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
ArrowBack.Fill = DictionaryResource.GetColor("ColorText");
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ViewSeasonsSeriesViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
ArrowBack.Fill = DictionaryResource.GetColor("ColorText");
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ViewSettingsViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
var parameter = new NavigationParam
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace DownKyi.ViewModels
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
var parameter = new NavigationParam
|
||||
{
|
||||
|
||||
@@ -214,7 +214,7 @@ public class ViewUserSpaceViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回事件
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
var parameter = new NavigationParam
|
||||
{
|
||||
|
||||
@@ -153,7 +153,7 @@ public class ViewVideoDetailViewModel : ViewModelBase
|
||||
/// <summary>
|
||||
/// 返回
|
||||
/// </summary>
|
||||
private void ExecuteBackSpace()
|
||||
protected internal override void ExecuteBackSpace()
|
||||
{
|
||||
var parameter = new NavigationParam
|
||||
{
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
<EventTriggerBehavior EventName="Opened">
|
||||
<InvokeCommandAction Command="{Binding LoadedCommand}" />
|
||||
</EventTriggerBehavior>
|
||||
<EventTriggerBehavior EventName="PointerPressed">
|
||||
<InvokeCommandAction Command="{Binding PointerPressedCommand}"
|
||||
PassEventArgsToCommand="True"/>
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
<Grid RowDefinitions="*">
|
||||
<ContentControl prism:RegionManager.RegionName="ContentRegion" />
|
||||
|
||||
Reference in New Issue
Block a user