|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
using System.Windows; |
|
|
|
|
using System.Windows.Input; |
|
|
|
|
using GlobalHotKey; |
|
|
|
|
using HandyControl.Controls; |
|
|
|
|
using SparkClient.Model.Helper; |
|
|
|
|
using SparkClient.ViewModel.Grading; |
|
|
|
@ -22,6 +23,15 @@ public class BaseControlVM : BaseViewModel |
|
|
|
|
|
|
|
|
|
public object Content { get; } |
|
|
|
|
public ICommand CloseCommand { get; } |
|
|
|
|
public ICommand EscCloseCommand { get; } |
|
|
|
|
|
|
|
|
|
public ICommand NextCommand { get; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private HotKeyManager _hotKeyManager; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 构造:创建一个带有子页面的模板,并指定子窗口标题,并指定右侧按钮事件内容 |
|
|
|
|
/// </summary> |
|
|
|
@ -33,6 +43,9 @@ public class BaseControlVM : BaseViewModel |
|
|
|
|
Content = vm; |
|
|
|
|
WindowTitle = windowTitle; |
|
|
|
|
CloseCommand = new RelayCommand(CloseVM); |
|
|
|
|
EscCloseCommand = new RelayCommand(OnClose); |
|
|
|
|
NextCommand = new RelayCommand(NextDiamond); |
|
|
|
|
_hotKeyManager = new HotKeyManager(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -44,7 +57,34 @@ public class BaseControlVM : BaseViewModel |
|
|
|
|
{ |
|
|
|
|
Content = vm; |
|
|
|
|
WindowTitle = windowTitle; |
|
|
|
|
ShowFunctionButton = Visibility.Hidden; |
|
|
|
|
CloseCommand = new RelayCommand(CloseVM); |
|
|
|
|
NextCommand = new RelayCommand(NextDiamond); |
|
|
|
|
|
|
|
|
|
if (vm.GetType().Equals(typeof(GradingResultVM))) |
|
|
|
|
{ |
|
|
|
|
Application.Current.Dispatcher.Invoke(() => |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
_hotKeyManager = new HotKeyManager(); |
|
|
|
|
var hotKey = new HotKey(Key.R, ModifierKeys.Control | ModifierKeys.Alt); |
|
|
|
|
_hotKeyManager.Register(hotKey); |
|
|
|
|
_hotKeyManager.KeyPressed += OnHotKeyPressed; |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
Logger.Info("设计缺陷:快捷键重复注册"); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// _hotKeyManager = new HotKeyManager(); |
|
|
|
|
// var hotKey = new HotKey(Key.R, ModifierKeys.Control | ModifierKeys.Alt); |
|
|
|
|
// _hotKeyManager.Unregister(hotKey); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// 构造:创建一个带有子页面的模板 |
|
|
|
@ -55,7 +95,30 @@ public class BaseControlVM : BaseViewModel |
|
|
|
|
Content = vm; |
|
|
|
|
CloseCommand = new RelayCommand(CloseVM); |
|
|
|
|
} |
|
|
|
|
private void OnClose(object parameter) |
|
|
|
|
{ |
|
|
|
|
if (parameter is KeyEventArgs keyEventArgs && keyEventArgs.Key == Key.Escape) |
|
|
|
|
{ |
|
|
|
|
CloseVM(parameter); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void OnHotKeyPressed(object sender, KeyPressedEventArgs e) |
|
|
|
|
{ |
|
|
|
|
if(WindowTitle.StartsWith(MultilingualHelper.getString("DetectionResult"))) |
|
|
|
|
NextDiamond(""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void NextDiamond(object parameter) |
|
|
|
|
{ |
|
|
|
|
CloseVM(parameter); |
|
|
|
|
DiamondSelectVM selectVm = new DiamondSelectVM(); |
|
|
|
|
ViewControl = selectVm; |
|
|
|
|
WindowTitle = MultilingualHelper.getString("DiamondSelect"); |
|
|
|
|
selectVm.StartGrading("ROUND P8 P8"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 关闭并退回至上一个页面 |
|
|
|
|
/// </summary> |
|
|
|
|