/
QueryPageSettingsEventArgs.cs
43 lines (38 loc) · 1.53 KB
/
QueryPageSettingsEventArgs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Drawing.Printing;
/// <summary>
/// Provides data for the <see cref='PrintDocument.QueryPageSettings'/> event.
/// </summary>
public class QueryPageSettingsEventArgs : PrintEventArgs
{
private PageSettings _pageSettings;
/// <summary>
/// Initializes a new instance of the <see cref='QueryPageSettingsEventArgs'/> class.
/// </summary>
public QueryPageSettingsEventArgs(PageSettings pageSettings) : base() => _pageSettings = pageSettings;
/// <summary>
/// Gets or sets the page settings for the page to be printed.
/// </summary>
public PageSettings PageSettings
{
get
{
PageSettingsChanged = true;
return _pageSettings;
}
set
{
value ??= new PageSettings();
_pageSettings = value;
PageSettingsChanged = true;
}
}
/// <summary>
/// It's too expensive to compare 2 instances of PageSettings class, as the getters are accessing the printer
/// spooler, thus we track any explicit invocations of the setters or getters on this class, and this field tracks
/// if PageSettings property was accessed. It will return a false positive when the user is reading property values,
/// but we'll take a perf hit in this case assuming this event is not used often.
/// </summary>
internal bool PageSettingsChanged { get; set; }
}