-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathSilentPrintingVIewModel.cs
64 lines (59 loc) · 1.99 KB
/
SilentPrintingVIewModel.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#region Copyright Syncfusion® Inc. 2001-2025.
// Copyright Syncfusion® Inc. 2001-2025. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws.
#endregion
using syncfusion.demoscommon.wpf;
using Syncfusion.Windows.PdfViewer;
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using System.Windows.Resources;
namespace syncfusion.pdfviewerdemos.wpf
{
public class SilentPrintingViewModel
{
#region Private Members
private PdfDocumentView pdfViewer;
ICommand m_printCommand;
# endregion
public SilentPrintingViewModel()
{
pdfViewer = new PdfDocumentView();
Uri uriResource = new Uri("/syncfusion.pdfviewerdemos.wpf;component/Assets/EmpDetails.pdf", UriKind.Relative);
StreamResourceInfo streamResourceInfo = Application.GetResourceStream(uriResource);
pdfViewer.Load(streamResourceInfo.Stream);
if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
{
return;
}
}
public ICommand PrintCommand
{
get
{
if (m_printCommand == null)
{
m_printCommand = new DelegateCommand<Window>(Print);
}
return m_printCommand;
}
}
#region Helper Methods
void Print(Window window)
{
pdfViewer.Print();
if (MessageBox.Show("Do you want to close the window?", "Silent Printing",
MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{
if (window != null)
window.Close();
pdfViewer.Unload(true);
}
}
#endregion
}
}