LayoutAnchorGroup.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*************************************************************************************
  2. Extended WPF Toolkit
  3. Copyright (C) 2007-2013 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, controls, and fast professional support,
  7. pick up the Plus Edition at http://xceed.com/wpf_toolkit
  8. Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
  9. ***********************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Collections.ObjectModel;
  15. using System.Windows.Markup;
  16. using System.Xml.Serialization;
  17. namespace Xceed.Wpf.AvalonDock.Layout
  18. {
  19. [ContentProperty("Children")]
  20. [Serializable]
  21. public class LayoutAnchorGroup : LayoutGroup<LayoutAnchorable>, ILayoutPreviousContainer, ILayoutPaneSerializable
  22. {
  23. public LayoutAnchorGroup()
  24. {
  25. }
  26. protected override bool GetVisibility()
  27. {
  28. return Children.Count > 0;
  29. }
  30. #region PreviousContainer
  31. [field:NonSerialized]
  32. private ILayoutContainer _previousContainer = null;
  33. [XmlIgnore]
  34. ILayoutContainer ILayoutPreviousContainer.PreviousContainer
  35. {
  36. get { return _previousContainer; }
  37. set
  38. {
  39. if (_previousContainer != value)
  40. {
  41. _previousContainer = value;
  42. RaisePropertyChanged("PreviousContainer");
  43. var paneSerializable = _previousContainer as ILayoutPaneSerializable;
  44. if (paneSerializable != null &&
  45. paneSerializable.Id == null)
  46. paneSerializable.Id = Guid.NewGuid().ToString();
  47. }
  48. }
  49. }
  50. #endregion
  51. string _id;
  52. string ILayoutPaneSerializable.Id
  53. {
  54. get
  55. {
  56. return _id;
  57. }
  58. set
  59. {
  60. _id = value;
  61. }
  62. }
  63. string ILayoutPreviousContainer.PreviousContainerId
  64. {
  65. get;
  66. set;
  67. }
  68. public override void WriteXml(System.Xml.XmlWriter writer)
  69. {
  70. if (_id != null)
  71. writer.WriteAttributeString("Id", _id);
  72. if (_previousContainer != null)
  73. {
  74. var paneSerializable = _previousContainer as ILayoutPaneSerializable;
  75. if (paneSerializable != null)
  76. {
  77. writer.WriteAttributeString("PreviousContainerId", paneSerializable.Id);
  78. }
  79. }
  80. base.WriteXml(writer);
  81. }
  82. public override void ReadXml(System.Xml.XmlReader reader)
  83. {
  84. if (reader.MoveToAttribute("Id"))
  85. _id = reader.Value;
  86. if (reader.MoveToAttribute("PreviousContainerId"))
  87. ((ILayoutPreviousContainer)this).PreviousContainerId = reader.Value;
  88. base.ReadXml(reader);
  89. }
  90. }
  91. }