- /*
- * Copyright (C) 2013 FooProject
- * * 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
- * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using FooEditEngine;
- using Windows.UI.Core;
- using Windows.Foundation;
- using Windows.Graphics.Printing;
- using Windows.Graphics.Printing.OptionDetails;
- namespace FooEditEngine.Metro
- {
- sealed class DocumentSource
- {
- internal enum HilightOptions
- {
- [DisplayPrintOptionResourceID("EnableHilight")]
- Enable,
- [DisplayPrintOptionResourceID("DisableHilight")]
- Disable,
- }
- [DisplayPrintOptionResourceID("SyntaxHilight")]
- internal HilightOptions EnableHilight
- {
- get
- {
- return this.factory.EnableHilight ? HilightOptions.Enable : HilightOptions.Disable;
- }
- set
- {
- this.factory.EnableHilight = value == HilightOptions.Enable;
- }
- }
- }
- public class FooPrintText
- {
- DocumentSource source;
- /// <summary>
- /// 印刷する
- /// </summary>
- /// <param name="req">PrintTaskRequestオブジェクト</param>
- /// <param name="title">タイトル</param>
- /// <param name="textbox">印刷対象のテキストボックス</param>
- public void Print(PrintTaskRequest req,string title,FooTextBox textbox)
- {
- IAsyncAction async = textbox.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
- {
- source = new DocumentSource();
- PrintTask task = null;
- task = req.CreatePrintTask(title, (e) =>
- {
- });
- task.Completed += async (sender, e) => {
- };
- PrintOptionBuilder builder = new PrintOptionBuilder(source);
- builder.BuildPrintOption(PrintTaskOptionDetails.GetFromPrintTaskOptions(task.Options));
- });
- Task t = WindowsRuntimeSystemExtensions.AsTask(async);
- t.Wait();
- }
- }
- }