1
- using SavePandaWolongEditionCore . Helpers ;
1
+ // v2024-08-06 23:50:49
2
2
3
- namespace SavePandaWLE . Helpers
4
- {
5
- public class SimpleMediatorWinForms : ISimpleMediator
6
- {
7
- /// <summary>
8
- /// Default constructor.
9
- /// </summary>
10
- public SimpleMediatorWinForms ( ) { }
3
+ using SavePandaWolongEditionCore . Helpers ;
4
+ using static SavePandaWolongEditionCore . Helpers . ISimpleMediator ;
11
5
12
- /// <summary>
13
- /// Translates <see cref="ISimpleMediator.QuestionOptions"/> to <see cref="MessageBoxButtons"/>
14
- /// </summary>
15
- /// <param name="questionOptions"></param>
16
- /// <returns></returns>
17
- private static MessageBoxButtons GetDialogOpt ( ISimpleMediator . QuestionOptions questionOptions )
18
- {
19
- return questionOptions switch
20
- {
21
- ISimpleMediator . QuestionOptions . OkCancel => MessageBoxButtons . OKCancel ,
22
- ISimpleMediator . QuestionOptions . AbortRetryIgnore => MessageBoxButtons . AbortRetryIgnore ,
23
- ISimpleMediator . QuestionOptions . YesNoCancel => MessageBoxButtons . YesNoCancel ,
24
- ISimpleMediator . QuestionOptions . YesNo => MessageBoxButtons . YesNo ,
25
- ISimpleMediator . QuestionOptions . RetryCancel => MessageBoxButtons . RetryCancel ,
26
- ISimpleMediator . QuestionOptions . CancelTryContinue => MessageBoxButtons . CancelTryContinue ,
27
- _ => MessageBoxButtons . OKCancel
28
- } ;
29
- }
6
+ namespace SavePandaWLE . Helpers ;
30
7
31
- /// <summary>
32
- /// Translates <see cref="ISimpleMediator.DialogType"/> to <see cref="MessageBoxIcon"/>
33
- /// </summary>
34
- /// <param name="dialogType"></param>
35
- /// <returns></returns>
36
- private static MessageBoxIcon GetDialogType ( ISimpleMediator . DialogType dialogType )
8
+ public class SimpleMediatorWinForms : ISimpleMediator
9
+ {
10
+ /// <summary>
11
+ /// Default constructor.
12
+ /// </summary>
13
+ public SimpleMediatorWinForms ( ) { }
14
+
15
+ /// <summary>
16
+ /// Translates <see cref="ISimpleMediator.QuestionOptions"/> to <see cref="MessageBoxButtons"/>
17
+ /// </summary>
18
+ /// <param name="questionOptions"></param>
19
+ /// <returns></returns>
20
+ private static MessageBoxButtons GetDialogOpt ( QuestionOptions questionOptions )
21
+ {
22
+ return questionOptions switch
37
23
{
38
- return dialogType switch
39
- {
40
- ISimpleMediator . DialogType . None => MessageBoxIcon . None ,
41
- ISimpleMediator . DialogType . Question => MessageBoxIcon . Question ,
42
- ISimpleMediator . DialogType . Exclamation => MessageBoxIcon . Exclamation ,
43
- ISimpleMediator . DialogType . Error => MessageBoxIcon . Error ,
44
- ISimpleMediator . DialogType . Warning => MessageBoxIcon . Warning ,
45
- ISimpleMediator . DialogType . Information => MessageBoxIcon . Information ,
46
- _ => MessageBoxIcon . None
47
- } ;
48
- }
24
+ QuestionOptions . OkCancel => MessageBoxButtons . OKCancel ,
25
+ QuestionOptions . AbortRetryIgnore => MessageBoxButtons . AbortRetryIgnore ,
26
+ QuestionOptions . YesNoCancel => MessageBoxButtons . YesNoCancel ,
27
+ QuestionOptions . YesNo => MessageBoxButtons . YesNo ,
28
+ QuestionOptions . RetryCancel => MessageBoxButtons . RetryCancel ,
29
+ QuestionOptions . CancelTryContinue => MessageBoxButtons . CancelTryContinue ,
30
+ _ => MessageBoxButtons . OKCancel
31
+ } ;
32
+ }
49
33
50
- /// <summary>
51
- /// Ask the user a simple question and get an answer.
52
- /// </summary>
53
- /// <param name="question"></param>
54
- /// <param name="caption"></param>
55
- /// <param name="questionOptions"></param>
56
- /// <param name="dialogType"></param>
57
- /// <returns></returns>
58
- public ISimpleMediator . DialogAnswer Ask ( string question , string caption , ISimpleMediator . QuestionOptions questionOptions , ISimpleMediator . DialogType dialogType )
34
+ /// <summary>
35
+ /// Translates <see cref="ISimpleMediator.DialogType"/> to <see cref="MessageBoxIcon"/>
36
+ /// </summary>
37
+ /// <param name="dialogType"></param>
38
+ /// <returns></returns>
39
+ private static MessageBoxIcon GetDialogType ( DialogType dialogType )
40
+ {
41
+ return dialogType switch
59
42
{
60
- var dlgOpt = GetDialogOpt ( questionOptions ) ;
61
- var dlgType = GetDialogType ( dialogType ) ;
43
+ DialogType . None => MessageBoxIcon . None ,
44
+ DialogType . Question => MessageBoxIcon . Question ,
45
+ DialogType . Exclamation => MessageBoxIcon . Exclamation ,
46
+ DialogType . Error => MessageBoxIcon . Error ,
47
+ DialogType . Warning => MessageBoxIcon . Warning ,
48
+ DialogType . Information => MessageBoxIcon . Information ,
49
+ _ => MessageBoxIcon . None
50
+ } ;
51
+ }
62
52
63
- var dialogResult = MessageBox . Show ( question , caption , dlgOpt , dlgType ) ;
53
+ /// <summary>
54
+ /// Ask the user a simple question and get an answer.
55
+ /// </summary>
56
+ /// <param name="question"></param>
57
+ /// <param name="caption"></param>
58
+ /// <param name="questionOptions"></param>
59
+ /// <param name="dialogType"></param>
60
+ /// <returns></returns>
61
+ public DialogAnswer Ask ( string question , string caption , QuestionOptions questionOptions , DialogType dialogType )
62
+ {
63
+ var dlgOpt = GetDialogOpt ( questionOptions ) ;
64
+ var dlgType = GetDialogType ( dialogType ) ;
64
65
65
- return dialogResult switch
66
- {
67
- DialogResult . None => ISimpleMediator . DialogAnswer . None ,
68
- DialogResult . OK => ISimpleMediator . DialogAnswer . Ok ,
69
- DialogResult . Cancel => ISimpleMediator . DialogAnswer . Cancel ,
70
- DialogResult . Abort => ISimpleMediator . DialogAnswer . Abort ,
71
- DialogResult . Retry => ISimpleMediator . DialogAnswer . Retry ,
72
- DialogResult . Ignore => ISimpleMediator . DialogAnswer . Ignore ,
73
- DialogResult . Yes => ISimpleMediator . DialogAnswer . Yes ,
74
- DialogResult . No => ISimpleMediator . DialogAnswer . No ,
75
- DialogResult . TryAgain => ISimpleMediator . DialogAnswer . TryAgain ,
76
- DialogResult . Continue => ISimpleMediator . DialogAnswer . Continue ,
77
- _ => ISimpleMediator . DialogAnswer . None
78
- } ;
79
- }
66
+ var dialogResult = MessageBox . Show ( question , caption , dlgOpt , dlgType ) ;
80
67
81
- /// <summary>
82
- /// Send a message to the user.
83
- /// </summary>
84
- /// <param name="info"></param>
85
- /// <param name="caption"></param>
86
- /// <param name="dialogType"></param>
87
- public void Inform ( string info , string caption , ISimpleMediator . DialogType dialogType )
68
+ return dialogResult switch
88
69
{
89
- var dlgType = GetDialogType ( dialogType ) ;
90
- MessageBox . Show ( info , caption , MessageBoxButtons . OK , dlgType ) ;
91
- }
70
+ DialogResult . None => DialogAnswer . None ,
71
+ DialogResult . OK => DialogAnswer . Ok ,
72
+ DialogResult . Cancel => DialogAnswer . Cancel ,
73
+ DialogResult . Abort => DialogAnswer . Abort ,
74
+ DialogResult . Retry => DialogAnswer . Retry ,
75
+ DialogResult . Ignore => DialogAnswer . Ignore ,
76
+ DialogResult . Yes => DialogAnswer . Yes ,
77
+ DialogResult . No => DialogAnswer . No ,
78
+ DialogResult . TryAgain => DialogAnswer . TryAgain ,
79
+ DialogResult . Continue => DialogAnswer . Continue ,
80
+ _ => DialogAnswer . None
81
+ } ;
82
+ }
83
+
84
+ /// <summary>
85
+ /// Send a message to the user.
86
+ /// </summary>
87
+ /// <param name="info"></param>
88
+ /// <param name="caption"></param>
89
+ /// <param name="dialogType"></param>
90
+ public void Inform ( string info , string caption , DialogType dialogType )
91
+ {
92
+ var dlgType = GetDialogType ( dialogType ) ;
93
+ MessageBox . Show ( info , caption , MessageBoxButtons . OK , dlgType ) ;
92
94
}
93
- }
95
+ }
0 commit comments