1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | |
---|
6 | namespace Com.Piwigo.Wpf.Command |
---|
7 | { |
---|
8 | public class EventArgs<T> : EventArgs |
---|
9 | { |
---|
10 | public EventArgs(T value) |
---|
11 | { |
---|
12 | m_value = value; |
---|
13 | } |
---|
14 | |
---|
15 | private T m_value; |
---|
16 | |
---|
17 | public T Value |
---|
18 | { |
---|
19 | get { return m_value; } |
---|
20 | } |
---|
21 | } |
---|
22 | |
---|
23 | public class PwgCmdEvents |
---|
24 | { |
---|
25 | #region Event for command start/stop running |
---|
26 | // The delegate the subscribers must implement. |
---|
27 | public delegate void CmdRunningChangedHandler( |
---|
28 | AsyncCommand cmd, |
---|
29 | EventArgs<Boolean> boolArgs |
---|
30 | ); |
---|
31 | |
---|
32 | // The event we publish |
---|
33 | public static event CmdRunningChangedHandler CmdRunningChanged; |
---|
34 | |
---|
35 | // The method which fires the Event |
---|
36 | public static void OnCmdRunningChanged( |
---|
37 | AsyncCommand cmd, |
---|
38 | EventArgs<Boolean> boolArgs |
---|
39 | ) |
---|
40 | |
---|
41 | { |
---|
42 | // Check if there are any Subscribers |
---|
43 | if (CmdRunningChanged != null) |
---|
44 | { |
---|
45 | // Call the Event |
---|
46 | CmdRunningChanged(cmd, boolArgs); |
---|
47 | } |
---|
48 | } |
---|
49 | #endregion |
---|
50 | |
---|
51 | #region Event for command send UI info |
---|
52 | // The delegate the subscribers must implement. |
---|
53 | public delegate void CmdSendUiInfoHandler( |
---|
54 | AsyncCommand cmd, |
---|
55 | EventArgs<String> stringArgs |
---|
56 | ); |
---|
57 | |
---|
58 | // The event we publish |
---|
59 | public static event CmdSendUiInfoHandler CmdSendUiInfo; |
---|
60 | |
---|
61 | // The method which fires the Event |
---|
62 | public static void OnCmdSendUiInfo( |
---|
63 | AsyncCommand cmd, |
---|
64 | EventArgs<String> stringArgs |
---|
65 | ) |
---|
66 | { |
---|
67 | // Check if there are any Subscribers |
---|
68 | if (CmdSendUiInfo != null) |
---|
69 | { |
---|
70 | // Call the Event |
---|
71 | CmdSendUiInfo(cmd, stringArgs); |
---|
72 | } |
---|
73 | } |
---|
74 | #endregion |
---|
75 | } |
---|
76 | } |
---|