LayoutAnchorSide.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 Xceed.Wpf.AvalonDock.Controls;
  17. namespace Xceed.Wpf.AvalonDock.Layout
  18. {
  19. [ContentProperty("Children")]
  20. [Serializable]
  21. public class LayoutAnchorSide : LayoutGroup<LayoutAnchorGroup>
  22. {
  23. public LayoutAnchorSide()
  24. {
  25. }
  26. protected override bool GetVisibility()
  27. {
  28. return Children.Count > 0;
  29. }
  30. protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue)
  31. {
  32. base.OnParentChanged(oldValue, newValue);
  33. UpdateSide();
  34. }
  35. private void UpdateSide()
  36. {
  37. if (Root.LeftSide == this)
  38. Side = AnchorSide.Left;
  39. else if (Root.TopSide == this)
  40. Side = AnchorSide.Top;
  41. else if (Root.RightSide == this)
  42. Side = AnchorSide.Right;
  43. else if (Root.BottomSide == this)
  44. Side = AnchorSide.Bottom;
  45. }
  46. #region Side
  47. private AnchorSide _side;
  48. public AnchorSide Side
  49. {
  50. get { return _side; }
  51. private set
  52. {
  53. if (_side != value)
  54. {
  55. RaisePropertyChanging("Side");
  56. _side = value;
  57. RaisePropertyChanged("Side");
  58. }
  59. }
  60. }
  61. #endregion
  62. }
  63. }