LayoutDocumentFloatingWindow.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.Windows.Markup;
  15. using System.Diagnostics;
  16. namespace Xceed.Wpf.AvalonDock.Layout
  17. {
  18. [ContentProperty("RootDocument")]
  19. [Serializable]
  20. public class LayoutDocumentFloatingWindow : LayoutFloatingWindow
  21. {
  22. public LayoutDocumentFloatingWindow()
  23. {
  24. }
  25. #region RootDocument
  26. private LayoutDocument _rootDocument = null;
  27. public LayoutDocument RootDocument
  28. {
  29. get { return _rootDocument; }
  30. set
  31. {
  32. if (_rootDocument != value)
  33. {
  34. RaisePropertyChanging("RootDocument");
  35. _rootDocument = value;
  36. if (_rootDocument != null)
  37. _rootDocument.Parent = this;
  38. RaisePropertyChanged("RootDocument");
  39. if (RootDocumentChanged != null)
  40. RootDocumentChanged(this, EventArgs.Empty);
  41. }
  42. }
  43. }
  44. public event EventHandler RootDocumentChanged;
  45. #endregion
  46. public override IEnumerable<ILayoutElement> Children
  47. {
  48. get
  49. {
  50. if (RootDocument == null)
  51. yield break;
  52. yield return RootDocument;
  53. }
  54. }
  55. public override void RemoveChild(ILayoutElement element)
  56. {
  57. Debug.Assert(element == RootDocument && element != null);
  58. RootDocument = null;
  59. }
  60. public override void ReplaceChild(ILayoutElement oldElement, ILayoutElement newElement)
  61. {
  62. Debug.Assert(oldElement == RootDocument && oldElement != null);
  63. RootDocument = newElement as LayoutDocument;
  64. }
  65. public override int ChildrenCount
  66. {
  67. get { return RootDocument != null ? 1 : 0; }
  68. }
  69. public override bool IsValid
  70. {
  71. get { return RootDocument != null; }
  72. }
  73. #if TRACE
  74. public override void ConsoleDump(int tab)
  75. {
  76. System.Diagnostics.Trace.Write( new string( ' ', tab * 4 ) );
  77. System.Diagnostics.Trace.WriteLine( "FloatingDocumentWindow()" );
  78. RootDocument.ConsoleDump(tab + 1);
  79. }
  80. #endif
  81. }
  82. }