+++ /dev/null
-/*\r
- * Copyright (C) 2013 FooProject\r
- * * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.\r
-\r
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of \r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-using System;\r
-using System.Collections.Generic;\r
-using System.Linq;\r
-using System.Text;\r
-using System.Threading.Tasks;\r
-using FooEditEngine;\r
-using Windows.UI.Core;\r
-using Windows.Foundation;\r
-using Windows.Graphics.Printing;\r
-using Windows.Graphics.Printing.OptionDetails;\r
-\r
-namespace FooEditEngine.Metro\r
-{\r
- /// <summary>\r
- /// 印刷を行うクラス\r
- /// </summary>\r
- public class FooPrintText\r
- {\r
- /// <summary>\r
- /// コンストラクター\r
- /// </summary>\r
- public FooPrintText()\r
- {\r
- this.PrintStart += (s, e) => { };\r
- this.PrintComplete += (s, e) => { };\r
- this.ParseHF = (s, e) => { return e.Original; };\r
- }\r
-\r
- DocumentSource source;\r
- /// <summary>\r
- /// ヘッダーやフッターを処理する\r
- /// </summary>\r
- public ParseCommandHandler ParseHF;\r
-\r
- /// <summary>\r
- /// ヘッダー\r
- /// </summary>\r
- public string Header;\r
-\r
- /// <summary>\r
- /// フッター\r
- /// </summary>\r
- public string Fotter;\r
-\r
- /// <summary>\r
- /// 余白\r
- /// </summary>\r
- public Padding Padding;\r
-\r
- /// <summary>\r
- /// 印刷が開始したことを表す\r
- /// </summary>\r
- public event EventHandler PrintStart;\r
-\r
- /// <summary>\r
- /// 印刷が完了したことを表す\r
- /// </summary>\r
- public event EventHandler PrintComplete;\r
-\r
- /// <summary>\r
- /// 印刷する\r
- /// </summary>\r
- /// <param name="req">PrintTaskRequestオブジェクト</param>\r
- /// <param name="title">タイトル</param>\r
- /// <param name="textbox">印刷対象のテキストボックス</param>\r
- public void Print(PrintTaskRequest req,string title,FooTextBox textbox)\r
- {\r
- IAsyncAction async = textbox.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>\r
- {\r
- this.PrintStart(this, null);\r
- source = new DocumentSource(textbox,this.Padding);\r
- source.ParseHF = ParseHF;\r
- source.Header = Header;\r
- source.Fotter = Fotter;\r
-\r
- PrintTask task = null;\r
- task = req.CreatePrintTask(title, (e) =>\r
- {\r
- e.SetSource(source);\r
- });\r
- task.Completed += async (sender, e) => {\r
- source.Dispose();\r
- await textbox.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {\r
- this.PrintComplete(this, null);\r
- });\r
- };\r
- PrintOptionBuilder<DocumentSource> builder = new PrintOptionBuilder<DocumentSource>(source);\r
- builder.BuildPrintOption(PrintTaskOptionDetails.GetFromPrintTaskOptions(task.Options));\r
- });\r
- Task t = WindowsRuntimeSystemExtensions.AsTask(async);\r
- t.Wait();\r
- }\r
- }\r
-}\r