@@ -21,6 +21,27 @@ public DocumentPageEventArgs(DocumentPage page)
21
21
}
22
22
}
23
23
24
+ /// <summary>
25
+ /// Arguments for the <see cref="DocumentControl"/> to get the current page.
26
+ /// </summary>
27
+ public class DocumentPageClosingEventArgs : CancelEventArgs
28
+ {
29
+ /// <summary>
30
+ /// Gets the document page.
31
+ /// </summary>
32
+ /// <value>The document page.</value>
33
+ public DocumentPage Page { get ; private set ; }
34
+
35
+ /// <summary>
36
+ /// Initializes a new instance of the <see cref="T:Eto.Forms.DocumentPageClosingEventArgs"/> class.
37
+ /// </summary>
38
+ /// <param name="page">Page.</param>
39
+ public DocumentPageClosingEventArgs ( DocumentPage page )
40
+ {
41
+ Page = page ;
42
+ }
43
+ }
44
+
24
45
/// <summary>
25
46
/// Arguments for the <see cref="DocumentControl"/> when reordering pages.
26
47
/// </summary>
@@ -70,6 +91,7 @@ public class DocumentControl : Container
70
91
public override IEnumerable < Control > Controls => pages ?? Enumerable . Empty < Control > ( ) ;
71
92
72
93
static readonly object PageClosedEvent = new object ( ) ;
94
+ static readonly object PageClosingEvent = new object ( ) ;
73
95
static readonly object SelectedIndexChangedEvent = new object ( ) ;
74
96
75
97
/// <summary>
@@ -86,6 +108,15 @@ public event EventHandler<DocumentPageEventArgs> PageClosed
86
108
remove { Properties . RemoveEvent ( PageClosedEvent , value ) ; }
87
109
}
88
110
111
+ /// <summary>
112
+ /// Occurs when the <see cref="DocumentPage"/> is closing.
113
+ /// </summary>
114
+ public event EventHandler < DocumentPageClosingEventArgs > PageClosing
115
+ {
116
+ add { Properties . AddEvent ( PageClosingEvent , value ) ; }
117
+ remove { Properties . RemoveEvent ( PageClosingEvent , value ) ; }
118
+ }
119
+
89
120
/// <summary>
90
121
/// Occurs when the <see cref="SelectedIndex"/> is changed.
91
122
/// </summary>
@@ -116,6 +147,15 @@ protected virtual void OnPageClosed(DocumentPageEventArgs e)
116
147
page . TriggerClose ( e ) ;
117
148
}
118
149
150
+ /// <summary>
151
+ /// Raises the <see cref="PageClosing"/> event.
152
+ /// </summary>
153
+ /// <param name="e">Event arguments.</param>
154
+ protected virtual void OnPageClosing ( DocumentPageClosingEventArgs e )
155
+ {
156
+ Properties . TriggerEvent ( PageClosingEvent , this , e ) ;
157
+ }
158
+
119
159
/// <summary>
120
160
/// Raises the <see cref="SelectedIndexChanged"/> event.
121
161
/// </summary>
@@ -350,6 +390,11 @@ IEnumerator IEnumerable.GetEnumerator()
350
390
/// </summary>
351
391
void OnPageClosed ( DocumentControl widget , DocumentPageEventArgs e ) ;
352
392
393
+ /// <summary>
394
+ /// Raises the page closing event.
395
+ /// </summary>
396
+ void OnPageClosing ( DocumentControl widget , DocumentPageClosingEventArgs e ) ;
397
+
353
398
/// <summary>
354
399
/// Raises the selected index changed event.
355
400
/// </summary>
@@ -375,6 +420,15 @@ public void OnPageClosed(DocumentControl widget, DocumentPageEventArgs e)
375
420
widget . OnPageClosed ( e ) ;
376
421
}
377
422
423
+ /// <summary>
424
+ /// Raises the page closing event.
425
+ /// </summary>
426
+ public void OnPageClosing ( DocumentControl widget , DocumentPageClosingEventArgs e )
427
+ {
428
+ using ( widget . Platform . Context )
429
+ widget . OnPageClosing ( e ) ;
430
+ }
431
+
378
432
/// <summary>
379
433
/// Raises the page reordered event.
380
434
/// </summary>
0 commit comments