-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathMainWindowViewModel.cs
More file actions
38 lines (33 loc) · 1.03 KB
/
MainWindowViewModel.cs
File metadata and controls
38 lines (33 loc) · 1.03 KB
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
using DevExpress.Mvvm;
using DevExpress.Mvvm.CodeGenerators;
using HTMLToQPDF.Example.Properties;
using HTMLToQPDF.Example.Utilities;
using System;
using System.IO;
namespace HTMLToQPDF.Example.ViewModels
{
[GenerateViewModel]
public partial class MainWindowViewModel : ViewModelBase
{
public string Html { get; set; }
public string SavePath { get; set; }
public bool CustomStyles { get; set; }
public MainWindowViewModel()
{
Html = Resources.testHtml;
var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
SavePath = Path.Combine(desktop, "example.pdf");
}
[GenerateCommand]
private void SelectSavePath()
{
SavePath = FileDialogHelper.GetSaveFilePath(SavePath);
}
[GenerateCommand]
private void CreatePdf()
{
PdfCreator.Create(Html, SavePath, CustomStyles);
}
private bool CanCreatePdf() => !string.IsNullOrEmpty(Html);
}
}