Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Commit f9742be

Browse files
committed
add some command
1 parent 154e9aa commit f9742be

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Description:CloseWindowCommand
3+
* Author: Chance.Zheng
4+
* Create Time: 2023-03-08 14:53:02
5+
* .Net Version: 4.6
6+
* CLR Version: 4.0.30319.42000
7+
* Copyright (c) CookCSharp 2023 All Rights Reserved.
8+
*/
9+
10+
11+
using System;
12+
using System.Collections.Generic;
13+
using System.Linq;
14+
using System.Text;
15+
using System.Threading.Tasks;
16+
using System.Windows;
17+
using System.Windows.Input;
18+
19+
namespace CookPopularControl.Communal
20+
{
21+
public class CloseWindowCommand : ICommand
22+
{
23+
public bool CanExecute(object parameter) => true;
24+
25+
public void Execute(object parameter)
26+
{
27+
if (parameter is DependencyObject dependencyObject)
28+
{
29+
if (Window.GetWindow(dependencyObject) is { } window)
30+
{
31+
window.Close();
32+
}
33+
}
34+
}
35+
36+
public event EventHandler CanExecuteChanged;
37+
}
38+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Description:SetMainWindowToTopCommand
3+
* Author: Chance.Zheng
4+
* Create Time: 2023-03-08 14:43:51
5+
* .Net Version: 4.6
6+
* CLR Version: 4.0.30319.42000
7+
* Copyright (c) CookCSharp 2023 All Rights Reserved.
8+
*/
9+
10+
11+
using CookPopularCSharpToolkit.Windows;
12+
using System;
13+
using System.Collections.Generic;
14+
using System.Linq;
15+
using System.Text;
16+
using System.Threading.Tasks;
17+
using System.Windows;
18+
using System.Windows.Input;
19+
20+
namespace CookPopularControl.Communal
21+
{
22+
public class SetMainWindowToTopCommand : ICommand
23+
{
24+
public bool CanExecute(object parameter) => true;
25+
26+
public void Execute(object parameter)
27+
{
28+
if (Application.Current.MainWindow != null && Application.Current.MainWindow.Visibility != Visibility.Visible)
29+
{
30+
Application.Current.MainWindow.Show();
31+
Application.Current.MainWindow.SafeActivate();
32+
}
33+
}
34+
35+
public event EventHandler CanExecuteChanged;
36+
}
37+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Description:ShutdownAppCommand
3+
* Author: Chance.Zheng
4+
* Create Time: 2023-03-08 14:42:22
5+
* .Net Version: 4.6
6+
* CLR Version: 4.0.30319.42000
7+
* Copyright (c) CookCSharp 2023 All Rights Reserved.
8+
*/
9+
10+
11+
using System;
12+
using System.Collections.Generic;
13+
using System.Linq;
14+
using System.Text;
15+
using System.Threading.Tasks;
16+
using System.Windows;
17+
using System.Windows.Input;
18+
19+
namespace CookPopularControl.Communal
20+
{
21+
public class ShutdownAppCommand : ICommand
22+
{
23+
public bool CanExecute(object parameter) => true;
24+
25+
public void Execute(object parameter) => Application.Current.Shutdown();
26+
27+
public event EventHandler CanExecuteChanged;
28+
}
29+
}

0 commit comments

Comments
 (0)