Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

PageLayout.cs 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Xml.Linq;
  3. namespace Novacode
  4. {
  5. public class PageLayout: DocXElement
  6. {
  7. internal PageLayout(DocX document, XElement xml):base(document, xml)
  8. {
  9. }
  10. public Orientation Orientation
  11. {
  12. get
  13. {
  14. /*
  15. * Get the pgSz (page size) element for this Section,
  16. * null will be return if no such element exists.
  17. */
  18. XElement pgSz = Xml.Element(XName.Get("pgSz", DocX.w.NamespaceName));
  19. if (pgSz == null)
  20. return Orientation.Portrait;
  21. // Get the attribute of the pgSz element.
  22. XAttribute val = pgSz.Attribute(XName.Get("orient", DocX.w.NamespaceName));
  23. // If val is null, this cell contains no information.
  24. if (val == null)
  25. return Orientation.Portrait;
  26. if (val.Value.Equals("Landscape", StringComparison.CurrentCultureIgnoreCase))
  27. return Orientation.Landscape;
  28. else
  29. return Orientation.Portrait;
  30. }
  31. set
  32. {
  33. // Check if already correct value.
  34. if (Orientation == value)
  35. return;
  36. /*
  37. * Get the pgSz (page size) element for this Section,
  38. * null will be return if no such element exists.
  39. */
  40. XElement pgSz = Xml.Element(XName.Get("pgSz", DocX.w.NamespaceName));
  41. if (pgSz == null)
  42. {
  43. Xml.SetElementValue(XName.Get("pgSz", DocX.w.NamespaceName), string.Empty);
  44. pgSz = Xml.Element(XName.Get("pgSz", DocX.w.NamespaceName));
  45. }
  46. pgSz.SetAttributeValue(XName.Get("orient", DocX.w.NamespaceName), value.ToString().ToLower());
  47. if(value == Novacode.Orientation.Landscape)
  48. {
  49. pgSz.SetAttributeValue(XName.Get("w", DocX.w.NamespaceName), "16838");
  50. pgSz.SetAttributeValue(XName.Get("h", DocX.w.NamespaceName), "11906");
  51. }
  52. else if (value == Novacode.Orientation.Portrait)
  53. {
  54. pgSz.SetAttributeValue(XName.Get("w", DocX.w.NamespaceName), "11906");
  55. pgSz.SetAttributeValue(XName.Get("h", DocX.w.NamespaceName), "16838");
  56. }
  57. }
  58. }
  59. }
  60. }