3 using System.Runtime.InteropServices.WindowsRuntime;
5 using Windows.UI.Xaml.Controls;
7 using Windows.Storage.Pickers;
8 using Windows.Graphics.Printing;
9 using FooEditEngine.UWP;
11 // 空白ページのアイテム テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 を参照してください
16 /// それ自体で使用できる空白ページまたはフレーム内に移動できる空白ページ。
18 public sealed partial class MainPage : Page
20 MainViewModel vm = new MainViewModel();
23 this.InitializeComponent();
24 this.DataContext = this.vm;
25 this.fooTextBox.Document = this.vm.CurrentDocument;
26 PrintManager.GetForCurrentView().PrintTaskRequested += MainPage_PrintTaskRequested;
29 void MainPage_PrintTaskRequested(PrintManager sender, PrintTaskRequestedEventArgs args)
31 FooPrintText printtext = new FooPrintText();
32 printtext.Fotter = "fotter";
33 printtext.Header = "header";
34 printtext.Padding = new FooEditEngine.Padding(20, 20, 20, 20);
35 printtext.Print(args.Request, "Text Print", this.fooTextBox);
38 private async void Button_Click(object sender, RoutedEventArgs e)
40 var filepicker = new FileOpenPicker();
41 filepicker.FileTypeFilter.Add(".txt");
42 var file = await filepicker.PickSingleFileAsync();
45 using (var ws = await file.OpenAsync(FileAccessMode.Read))
46 using (var fs = new StreamReader(ws.AsStream()))
48 await this.fooTextBox.LoadFileAsync(fs, null);
53 private async void Print_Button_Click(object sender, RoutedEventArgs e)
55 await PrintManager.ShowPrintUIAsync();