Formato
Plain text
Post date
2013-12-27 23:24
Publication Period
Unlimited
  1. /*
  2. * Copyright (C) 2013 FooProject
  3. * * 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
  4. * the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
  5. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  6. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  7. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
  8. */
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using FooEditEngine;
  15. using Windows.UI.Core;
  16. using Windows.Foundation;
  17. using Windows.Graphics.Printing;
  18. using Windows.Graphics.Printing.OptionDetails;
  19. namespace FooEditEngine.Metro
  20. {
  21. sealed class DocumentSource
  22. {
  23. internal enum HilightOptions
  24. {
  25. [DisplayPrintOptionResourceID("EnableHilight")]
  26. Enable,
  27. [DisplayPrintOptionResourceID("DisableHilight")]
  28. Disable,
  29. }
  30. [DisplayPrintOptionResourceID("SyntaxHilight")]
  31. internal HilightOptions EnableHilight
  32. {
  33. get
  34. {
  35. return this.factory.EnableHilight ? HilightOptions.Enable : HilightOptions.Disable;
  36. }
  37. set
  38. {
  39. this.factory.EnableHilight = value == HilightOptions.Enable;
  40. }
  41. }
  42. }
  43. public class FooPrintText
  44. {
  45. DocumentSource source;
  46. /// <summary>
  47. /// 印刷する
  48. /// </summary>
  49. /// <param name="req">PrintTaskRequestオブジェクト</param>
  50. /// <param name="title">タイトル</param>
  51. /// <param name="textbox">印刷対象のテキストボックス</param>
  52. public void Print(PrintTaskRequest req,string title,FooTextBox textbox)
  53. {
  54. IAsyncAction async = textbox.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
  55. {
  56. source = new DocumentSource();
  57. PrintTask task = null;
  58. task = req.CreatePrintTask(title, (e) =>
  59. {
  60. });
  61. task.Completed += async (sender, e) => {
  62. };
  63. PrintOptionBuilder builder = new PrintOptionBuilder(source);
  64. builder.BuildPrintOption(PrintTaskOptionDetails.GetFromPrintTaskOptions(task.Options));
  65. });
  66. Task t = WindowsRuntimeSystemExtensions.AsTask(async);
  67. t.Wait();
  68. }
  69. }
  70. }
Descargar Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text