42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using CapMachine.Wpf.Services;
|
|
using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using Prism.Ioc;
|
|
|
|
namespace CapMachine.Wpf.ViewModels
|
|
{
|
|
public class TaskBarViewModel : BindableBase
|
|
{
|
|
private readonly IHostDialogService dialog;
|
|
private readonly IAppStartService appStartService;
|
|
public DelegateCommand ExitCommand { get; set; }
|
|
public DelegateCommand ShowViewCommand { get; private set; }
|
|
|
|
public TaskBarViewModel()
|
|
{
|
|
dialog = ContainerLocator.Container.Resolve<IHostDialogService>();
|
|
appStartService = ContainerLocator.Container.Resolve<IAppStartService>();
|
|
|
|
ExitCommand = new DelegateCommand(Exit);
|
|
ShowViewCommand = new DelegateCommand(ShowView);
|
|
}
|
|
|
|
private async void Exit()
|
|
{
|
|
ShowView();
|
|
|
|
if (await dialog.Question("确定","1"))
|
|
appStartService.Exit();
|
|
}
|
|
|
|
private void ShowView()
|
|
{
|
|
if (!App.Current.MainWindow.IsVisible)
|
|
{
|
|
App.Current.MainWindow.Show();
|
|
App.Current.MainWindow.WindowState = System.Windows.WindowState.Normal;
|
|
}
|
|
}
|
|
}
|
|
}
|