Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

PageLayout.cs 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*************************************************************************************
  2. DocX – DocX is the community edition of Xceed Words for .NET
  3. Copyright (C) 2009-2016 Xceed Software Inc.
  4. This program is provided to you under the terms of the Microsoft Public
  5. License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
  6. For more features and fast professional support,
  7. pick up Xceed Words for .NET at https://xceed.com/xceed-words-for-net/
  8. ***********************************************************************************/
  9. using System;
  10. using System.Xml.Linq;
  11. namespace Xceed.Words.NET
  12. {
  13. public class PageLayout : DocXElement
  14. {
  15. #region Constructors
  16. internal PageLayout( DocX document, XElement xml ) : base( document, xml )
  17. {
  18. }
  19. #endregion
  20. #region Public Properties
  21. public Orientation Orientation
  22. {
  23. get
  24. {
  25. /*
  26. * Get the pgSz (page size) element for this Section,
  27. * null will be return if no such element exists.
  28. */
  29. XElement pgSz = Xml.Element( XName.Get( "pgSz", DocX.w.NamespaceName ) );
  30. if( pgSz == null )
  31. return Orientation.Portrait;
  32. // Get the attribute of the pgSz element.
  33. XAttribute val = pgSz.Attribute( XName.Get( "orient", DocX.w.NamespaceName ) );
  34. // If val is null, this cell contains no information.
  35. if( val == null )
  36. return Orientation.Portrait;
  37. if( val.Value.Equals( "Landscape", StringComparison.CurrentCultureIgnoreCase ) )
  38. return Orientation.Landscape;
  39. else
  40. return Orientation.Portrait;
  41. }
  42. set
  43. {
  44. // Check if already correct value.
  45. if( Orientation == value )
  46. return;
  47. /*
  48. * Get the pgSz (page size) element for this Section,
  49. * null will be return if no such element exists.
  50. */
  51. XElement pgSz = Xml.Element( XName.Get( "pgSz", DocX.w.NamespaceName ) );
  52. if( pgSz == null )
  53. {
  54. Xml.SetElementValue( XName.Get( "pgSz", DocX.w.NamespaceName ), string.Empty );
  55. pgSz = Xml.Element( XName.Get( "pgSz", DocX.w.NamespaceName ) );
  56. }
  57. pgSz.SetAttributeValue( XName.Get( "orient", DocX.w.NamespaceName ), value.ToString().ToLower() );
  58. if( value == Xceed.Words.NET.Orientation.Landscape )
  59. {
  60. pgSz.SetAttributeValue( XName.Get( "w", DocX.w.NamespaceName ), "16838" );
  61. pgSz.SetAttributeValue( XName.Get( "h", DocX.w.NamespaceName ), "11906" );
  62. }
  63. else if( value == Xceed.Words.NET.Orientation.Portrait )
  64. {
  65. pgSz.SetAttributeValue( XName.Get( "w", DocX.w.NamespaceName ), "11906" );
  66. pgSz.SetAttributeValue( XName.Get( "h", DocX.w.NamespaceName ), "16838" );
  67. }
  68. }
  69. }
  70. #endregion
  71. }
  72. }