This repository was archived by the owner on Dec 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +104
-0
lines changed
CookPopularControl/Communal/Commands Expand file tree Collapse file tree 3 files changed +104
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments