diff --git a/source/Components/AvalonDock.Themes.Aero/AvalonDock.Themes.Aero.csproj b/source/Components/AvalonDock.Themes.Aero/AvalonDock.Themes.Aero.csproj index c560efa6..76e264ec 100644 --- a/source/Components/AvalonDock.Themes.Aero/AvalonDock.Themes.Aero.csproj +++ b/source/Components/AvalonDock.Themes.Aero/AvalonDock.Themes.Aero.csproj @@ -6,9 +6,9 @@ sn.snk true true - 4.20 - 4.20 - 4.20 + 4.30 + 4.30 + 4.30 Open Source Dirkster.AvalonDock 2017-2020 diff --git a/source/Components/AvalonDock.Themes.Expression/AvalonDock.Themes.Expression.csproj b/source/Components/AvalonDock.Themes.Expression/AvalonDock.Themes.Expression.csproj index 99655635..23bc7e2e 100644 --- a/source/Components/AvalonDock.Themes.Expression/AvalonDock.Themes.Expression.csproj +++ b/source/Components/AvalonDock.Themes.Expression/AvalonDock.Themes.Expression.csproj @@ -6,9 +6,9 @@ sn.snk true true - 4.20 - 4.20 - 4.20 + 4.30 + 4.30 + 4.30 Open Source Dirkster.AvalonDock 2017-2020 diff --git a/source/Components/AvalonDock.Themes.Metro/AvalonDock.Themes.Metro.csproj b/source/Components/AvalonDock.Themes.Metro/AvalonDock.Themes.Metro.csproj index a21db920..fc9b8e84 100644 --- a/source/Components/AvalonDock.Themes.Metro/AvalonDock.Themes.Metro.csproj +++ b/source/Components/AvalonDock.Themes.Metro/AvalonDock.Themes.Metro.csproj @@ -6,9 +6,9 @@ sn.snk true true - 4.20 - 4.20 - 4.20 + 4.30 + 4.30 + 4.30 Open Source Dirkster.AvalonDock 2017-2020 diff --git a/source/Components/AvalonDock.Themes.VS2010/AvalonDock.Themes.VS2010.csproj b/source/Components/AvalonDock.Themes.VS2010/AvalonDock.Themes.VS2010.csproj index 8eb32246..fbb987a9 100644 --- a/source/Components/AvalonDock.Themes.VS2010/AvalonDock.Themes.VS2010.csproj +++ b/source/Components/AvalonDock.Themes.VS2010/AvalonDock.Themes.VS2010.csproj @@ -6,9 +6,9 @@ sn.snk true true - 4.20 - 4.20 - 4.20 + 4.30 + 4.30 + 4.30 Open Source Dirkster.AvalonDock 2017-2020 diff --git a/source/Components/AvalonDock.Themes.VS2013/AvalonDock.Themes.VS2013.csproj b/source/Components/AvalonDock.Themes.VS2013/AvalonDock.Themes.VS2013.csproj index 369e425c..19a74be6 100644 --- a/source/Components/AvalonDock.Themes.VS2013/AvalonDock.Themes.VS2013.csproj +++ b/source/Components/AvalonDock.Themes.VS2013/AvalonDock.Themes.VS2013.csproj @@ -6,9 +6,9 @@ sn.snk true true - 4.20 - 4.20 - 4.20 + 4.30 + 4.30 + 4.30 Open Source Dirkster.AvalonDock 2017-2020 diff --git a/source/Components/AvalonDock/AvalonDock.csproj b/source/Components/AvalonDock/AvalonDock.csproj index 64b69c13..7bd99c75 100644 --- a/source/Components/AvalonDock/AvalonDock.csproj +++ b/source/Components/AvalonDock/AvalonDock.csproj @@ -6,9 +6,9 @@ true sn.snk true - 4.20 - 4.20 - 4.20 + 4.30 + 4.30 + 4.30 Open Source Dirkster.AvalonDock 2017-2020 diff --git a/source/Components/AvalonDock/Controls/LayoutDocumentControl.cs b/source/Components/AvalonDock/Controls/LayoutDocumentControl.cs index 3e8558c2..5db5bcbc 100644 --- a/source/Components/AvalonDock/Controls/LayoutDocumentControl.cs +++ b/source/Components/AvalonDock/Controls/LayoutDocumentControl.cs @@ -16,128 +16,128 @@ This program is provided to you under the terms of the Microsoft Public namespace AvalonDock.Controls { - /// - /// Implements the content part of the document control. - /// It hosts a as its . - /// - public class LayoutDocumentControl : Control - { - #region Constructors - - /// - /// Static class constructor - /// - static LayoutDocumentControl() - { - DefaultStyleKeyProperty.OverrideMetadata(typeof(LayoutDocumentControl), new FrameworkPropertyMetadata(typeof(LayoutDocumentControl))); - FocusableProperty.OverrideMetadata(typeof(LayoutDocumentControl), new FrameworkPropertyMetadata(true)); - } - - #endregion Constructors - - #region Properties - - #region Model - - /// dependency property. - public static readonly DependencyProperty ModelProperty = DependencyProperty.Register(nameof(Model), typeof(LayoutContent), typeof(LayoutDocumentControl), - new FrameworkPropertyMetadata(null, OnModelChanged)); - - /// - /// Gets or sets the property. - /// This dependency property indicates the model attached to this view. - /// - public LayoutContent Model - { - get => (LayoutContent)GetValue(ModelProperty); - set => SetValue(ModelProperty, value); - } - - /// Handles changes to the property. - private static void OnModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((LayoutDocumentControl)d).OnModelChanged(e); - - /// Provides derived classes an opportunity to handle changes to the property. - protected virtual void OnModelChanged(DependencyPropertyChangedEventArgs e) - { - if (e.OldValue != null) ((LayoutContent)e.OldValue).PropertyChanged -= Model_PropertyChanged; - if (Model != null) - { - Model.PropertyChanged += Model_PropertyChanged; - SetLayoutItem(Model.Root.Manager.GetLayoutItemFromModel(Model)); - } - else - SetLayoutItem(null); - } - - private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e) - { - if (e.PropertyName != nameof(LayoutContent.IsEnabled)) return; - if (Model == null) return; - IsEnabled = Model.IsEnabled; - if (IsEnabled || !Model.IsActive) return; - if (Model.Parent is LayoutDocumentPane layoutDocumentPane) layoutDocumentPane.SetNextSelectedIndex(); - } - - #endregion Model - - #region LayoutItem - - /// Read-Only dependency property. - private static readonly DependencyPropertyKey LayoutItemPropertyKey = DependencyProperty.RegisterReadOnly(nameof(LayoutItem), typeof(LayoutItem), typeof(LayoutDocumentControl), - new FrameworkPropertyMetadata(null)); - - public static readonly DependencyProperty LayoutItemProperty = LayoutItemPropertyKey.DependencyProperty; - - /// - /// Gets the property. This dependency property - /// indicates the LayoutItem attached to this tag item. - /// - public LayoutItem LayoutItem => (LayoutItem)GetValue(LayoutItemProperty); - - /// - /// Provides a secure method for setting the property. - /// This dependency property indicates the LayoutItem attached to this tag item. - /// - /// The new value for the property. - protected void SetLayoutItem(LayoutItem value) => SetValue(LayoutItemPropertyKey, value); - - #endregion LayoutItem - - #endregion Properties - - #region Overrides - - /// - protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) - { - Debug.WriteLine($"{nameof(OnPreviewMouseLeftButtonUp)}: {LayoutItem.ContentId}"); - SetIsActive(); - base.OnPreviewMouseLeftButtonUp(e); - } - - /// - protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) - { - SetIsActive(); - base.OnMouseLeftButtonDown(e); - } - - /// - protected override void OnMouseRightButtonDown(MouseButtonEventArgs e) - { - SetIsActive(); - base.OnMouseLeftButtonDown(e); - } - - #endregion Overrides - - #region Private Methods - - private void SetIsActive() - { - if (Model != null && !Model.IsActive) Model.IsActive = true; - } - - #endregion Private Methods - } + /// + /// Implements the content part of the document control. + /// It hosts a as its . + /// + public class LayoutDocumentControl : Control + { + #region Constructors + + /// + /// Static class constructor + /// + static LayoutDocumentControl() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(LayoutDocumentControl), new FrameworkPropertyMetadata(typeof(LayoutDocumentControl))); + FocusableProperty.OverrideMetadata(typeof(LayoutDocumentControl), new FrameworkPropertyMetadata(true)); + } + + #endregion Constructors + + #region Properties + + #region Model + + /// dependency property. + public static readonly DependencyProperty ModelProperty = DependencyProperty.Register(nameof(Model), typeof(LayoutContent), typeof(LayoutDocumentControl), + new FrameworkPropertyMetadata(null, OnModelChanged)); + + /// + /// Gets or sets the property. + /// This dependency property indicates the model attached to this view. + /// + public LayoutContent Model + { + get => (LayoutContent)GetValue(ModelProperty); + set => SetValue(ModelProperty, value); + } + + /// Handles changes to the property. + private static void OnModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((LayoutDocumentControl)d).OnModelChanged(e); + + /// Provides derived classes an opportunity to handle changes to the property. + protected virtual void OnModelChanged(DependencyPropertyChangedEventArgs e) + { + if (e.OldValue != null) ((LayoutContent)e.OldValue).PropertyChanged -= Model_PropertyChanged; + if (Model != null) + { + Model.PropertyChanged += Model_PropertyChanged; + SetLayoutItem(Model.Root.Manager.GetLayoutItemFromModel(Model)); + } + else + SetLayoutItem(null); + } + + private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName != nameof(LayoutContent.IsEnabled)) return; + if (Model == null) return; + IsEnabled = Model.IsEnabled; + if (IsEnabled || !Model.IsActive) return; + if (Model.Parent is LayoutDocumentPane layoutDocumentPane) layoutDocumentPane.SetNextSelectedIndex(); + } + + #endregion Model + + #region LayoutItem + + /// Read-Only dependency property. + private static readonly DependencyPropertyKey LayoutItemPropertyKey = DependencyProperty.RegisterReadOnly(nameof(LayoutItem), typeof(LayoutItem), typeof(LayoutDocumentControl), + new FrameworkPropertyMetadata(null)); + + public static readonly DependencyProperty LayoutItemProperty = LayoutItemPropertyKey.DependencyProperty; + + /// + /// Gets the property. This dependency property + /// indicates the LayoutItem attached to this tag item. + /// + public LayoutItem LayoutItem => (LayoutItem)GetValue(LayoutItemProperty); + + /// + /// Provides a secure method for setting the property. + /// This dependency property indicates the LayoutItem attached to this tag item. + /// + /// The new value for the property. + protected void SetLayoutItem(LayoutItem value) => SetValue(LayoutItemPropertyKey, value); + + #endregion LayoutItem + + #endregion Properties + + #region Overrides + + /// + protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) + { + Debug.WriteLine($"{nameof(OnPreviewMouseLeftButtonUp)}: {LayoutItem.ContentId}"); + SetIsActive(); + base.OnPreviewMouseLeftButtonUp(e); + } + + /// + protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) + { + SetIsActive(); + base.OnMouseLeftButtonDown(e); + } + + /// + protected override void OnMouseRightButtonDown(MouseButtonEventArgs e) + { + SetIsActive(); + base.OnMouseLeftButtonDown(e); + } + + #endregion Overrides + + #region Private Methods + + private void SetIsActive() + { + if (Model != null && !Model.IsActive) Model.IsActive = true; + } + + #endregion Private Methods + } } \ No newline at end of file diff --git a/source/Components/AvalonDock/Layout/LayoutGroup.cs b/source/Components/AvalonDock/Layout/LayoutGroup.cs index c90fbf64..98f70163 100644 --- a/source/Components/AvalonDock/Layout/LayoutGroup.cs +++ b/source/Components/AvalonDock/Layout/LayoutGroup.cs @@ -16,261 +16,261 @@ This program is provided to you under the terms of the Microsoft Public namespace AvalonDock.Layout { - /// - /// Provides a base class for layout anchorable (group and non-group) related classes - /// that implement the viewmodel aspect for layout anchorable controls. - /// - /// - [Serializable] - public abstract class LayoutGroup : LayoutGroupBase, ILayoutGroup, IXmlSerializable where T : class, ILayoutElement - { - #region fields - - private readonly ObservableCollection _children = new ObservableCollection(); - private bool _isVisible = true; - - #endregion fields - - #region Constructors - - /// Class constructor. - internal LayoutGroup() - { - _children.CollectionChanged += Children_CollectionChanged; - } - - #endregion Constructors - - #region Properties - - /// Gets a collection of children objects below this object. - public ObservableCollection Children => _children; - - /// Gets the number of of children objects below this object. - public int ChildrenCount => _children.Count; - - /// Gets a collection of based children objects below this object. - IEnumerable ILayoutContainer.Children => _children.Cast(); - - /// Gets whether this object is visible or not. - public bool IsVisible - { - get => _isVisible; - protected set - { - if (value == _isVisible) return; - RaisePropertyChanging(nameof(IsVisible)); - _isVisible = value; - OnIsVisibleChanged(); - RaisePropertyChanged(nameof(IsVisible)); - } - } - - #endregion Properties - - #region Public Methods - - /// - public void ComputeVisibility() => IsVisible = GetVisibility(); - - /// - public void MoveChild(int oldIndex, int newIndex) - { - if (oldIndex == newIndex) return; - _children.Move(oldIndex, newIndex); - ChildMoved(oldIndex, newIndex); - } - - /// - public void RemoveChildAt(int childIndex) - { - _children.RemoveAt(childIndex); - } - - /// - public int IndexOfChild(ILayoutElement element) - { - return _children.Cast().ToList().IndexOf(element); - } - - /// - public void InsertChildAt(int index, ILayoutElement element) - { - if (element is T t) - _children.Insert(index, t); - } - - /// - public void RemoveChild(ILayoutElement element) - { - if (element is T t) - _children.Remove(t); - } - - /// - public void ReplaceChild(ILayoutElement oldElement, ILayoutElement newElement) - { - if (oldElement is T oldT && newElement is T newT) - { - var index = _children.IndexOf(oldT); - _children.Insert(index, newT); - _children.RemoveAt(index + 1); - } - } - - /// - public void ReplaceChildAt(int index, ILayoutElement element) - { - _children[index] = (T)element; - } - - /// - System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() => null; - - /// - /// provides a standard overridable implementation for deriving classes. - public virtual void ReadXml(System.Xml.XmlReader reader) - { - reader.MoveToContent(); - if (reader.IsEmptyElement) - { - reader.Read(); - ComputeVisibility(); - return; - } - var localName = reader.LocalName; - reader.Read(); - while (true) - { - if (reader.LocalName == localName && reader.NodeType == System.Xml.XmlNodeType.EndElement) - break; - if (reader.NodeType == System.Xml.XmlNodeType.Whitespace) - { - reader.Read(); - continue; - } - - XmlSerializer serializer = null; - if (reader.LocalName == nameof(LayoutAnchorablePaneGroup)) - serializer = new XmlSerializer(typeof(LayoutAnchorablePaneGroup)); - else if (reader.LocalName == nameof(LayoutAnchorablePane)) - serializer = new XmlSerializer(typeof(LayoutAnchorablePane)); - else if (reader.LocalName == nameof(LayoutAnchorable)) - serializer = new XmlSerializer(typeof(LayoutAnchorable)); - else if (reader.LocalName == nameof(LayoutDocumentPaneGroup)) - serializer = new XmlSerializer(typeof(LayoutDocumentPaneGroup)); - else if (reader.LocalName == nameof(LayoutDocumentPane)) - serializer = new XmlSerializer(typeof(LayoutDocumentPane)); - else if (reader.LocalName == nameof(LayoutDocument)) - serializer = new XmlSerializer(typeof(LayoutDocument)); - else if (reader.LocalName == nameof(LayoutAnchorGroup)) - serializer = new XmlSerializer(typeof(LayoutAnchorGroup)); - else if (reader.LocalName == nameof(LayoutPanel)) - serializer = new XmlSerializer(typeof(LayoutPanel)); - else - { - var type = FindType(reader.LocalName); - if (type == null) - throw new ArgumentException("AvalonDock.LayoutGroup doesn't know how to deserialize " + reader.LocalName); - serializer = new XmlSerializer(type); - } - - Children.Add((T)serializer.Deserialize(reader)); - } - - reader.ReadEndElement(); - } - - /// - /// provides a standard overridable implementation for deriving classes. - public virtual void WriteXml(System.Xml.XmlWriter writer) - { - foreach (var child in Children) - { - var type = child.GetType(); - var serializer = new XmlSerializer(type); - serializer.Serialize(writer, child); - } - } - - #endregion Public Methods - - #region Internal Methods - - protected virtual void OnIsVisibleChanged() - { - UpdateParentVisibility(); - } - - protected abstract bool GetVisibility(); - - protected virtual void ChildMoved(int oldIndex, int newIndex) - { - } - - #endregion Internal Methods - - #region Overrides - - /// - protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue) - { - base.OnParentChanged(oldValue, newValue); - ComputeVisibility(); - } - - #endregion Overrides - - #region Private Methods - - private void Children_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) - { - if (e.OldItems != null) - { - foreach (LayoutElement element in e.OldItems) - if (element.Parent == this || e.Action == NotifyCollectionChangedAction.Remove) element.Parent = null; - } - } - if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace) - { - if (e.NewItems != null) - { - foreach (LayoutElement element in e.NewItems) - { - if (element.Parent == this) continue; - element.Parent?.RemoveChild(element); - element.Parent = this; - } - } - } - - ComputeVisibility(); - OnChildrenCollectionChanged(); - - if (e.Action == NotifyCollectionChangedAction.Add) - // #81 - Make parents update their children up the tree. Otherwise, they will not be redrawn. - RaiseChildrenTreeChanged(); - else - NotifyChildrenTreeChanged(ChildrenTreeChange.DirectChildrenChanged); - RaisePropertyChanged(nameof(ChildrenCount)); - } - - private void UpdateParentVisibility() - { - if (Parent is ILayoutElementWithVisibility parentPane) - parentPane.ComputeVisibility(); - } - - private Type FindType(string name) - { - foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) - foreach (var t in a.GetTypes()) - if (t.Name.Equals(name)) return t; - return null; - } - - #endregion Private Methods - } + /// + /// Provides a base class for layout anchorable (group and non-group) related classes + /// that implement the viewmodel aspect for layout anchorable controls. + /// + /// + [Serializable] + public abstract class LayoutGroup : LayoutGroupBase, ILayoutGroup, IXmlSerializable where T : class, ILayoutElement + { + #region fields + + private readonly ObservableCollection _children = new ObservableCollection(); + private bool _isVisible = true; + + #endregion fields + + #region Constructors + + /// Class constructor. + internal LayoutGroup() + { + _children.CollectionChanged += Children_CollectionChanged; + } + + #endregion Constructors + + #region Properties + + /// Gets a collection of children objects below this object. + public ObservableCollection Children => _children; + + /// Gets the number of of children objects below this object. + public int ChildrenCount => _children.Count; + + /// Gets a collection of based children objects below this object. + IEnumerable ILayoutContainer.Children => _children.Cast(); + + /// Gets whether this object is visible or not. + public bool IsVisible + { + get => _isVisible; + protected set + { + if (value == _isVisible) return; + RaisePropertyChanging(nameof(IsVisible)); + _isVisible = value; + OnIsVisibleChanged(); + RaisePropertyChanged(nameof(IsVisible)); + } + } + + #endregion Properties + + #region Public Methods + + /// + public void ComputeVisibility() => IsVisible = GetVisibility(); + + /// + public void MoveChild(int oldIndex, int newIndex) + { + if (oldIndex == newIndex) return; + _children.Move(oldIndex, newIndex); + ChildMoved(oldIndex, newIndex); + } + + /// + public void RemoveChildAt(int childIndex) + { + _children.RemoveAt(childIndex); + } + + /// + public int IndexOfChild(ILayoutElement element) + { + return _children.Cast().ToList().IndexOf(element); + } + + /// + public void InsertChildAt(int index, ILayoutElement element) + { + if (element is T t) + _children.Insert(index, t); + } + + /// + public void RemoveChild(ILayoutElement element) + { + if (element is T t) + _children.Remove(t); + } + + /// + public void ReplaceChild(ILayoutElement oldElement, ILayoutElement newElement) + { + if (oldElement is T oldT && newElement is T newT) + { + var index = _children.IndexOf(oldT); + _children.Insert(index, newT); + _children.RemoveAt(index + 1); + } + } + + /// + public void ReplaceChildAt(int index, ILayoutElement element) + { + _children[index] = (T)element; + } + + /// + System.Xml.Schema.XmlSchema IXmlSerializable.GetSchema() => null; + + /// + /// provides a standard overridable implementation for deriving classes. + public virtual void ReadXml(System.Xml.XmlReader reader) + { + reader.MoveToContent(); + if (reader.IsEmptyElement) + { + reader.Read(); + ComputeVisibility(); + return; + } + var localName = reader.LocalName; + reader.Read(); + while (true) + { + if (reader.LocalName == localName && reader.NodeType == System.Xml.XmlNodeType.EndElement) + break; + if (reader.NodeType == System.Xml.XmlNodeType.Whitespace) + { + reader.Read(); + continue; + } + + XmlSerializer serializer = null; + if (reader.LocalName == nameof(LayoutAnchorablePaneGroup)) + serializer = new XmlSerializer(typeof(LayoutAnchorablePaneGroup)); + else if (reader.LocalName == nameof(LayoutAnchorablePane)) + serializer = new XmlSerializer(typeof(LayoutAnchorablePane)); + else if (reader.LocalName == nameof(LayoutAnchorable)) + serializer = new XmlSerializer(typeof(LayoutAnchorable)); + else if (reader.LocalName == nameof(LayoutDocumentPaneGroup)) + serializer = new XmlSerializer(typeof(LayoutDocumentPaneGroup)); + else if (reader.LocalName == nameof(LayoutDocumentPane)) + serializer = new XmlSerializer(typeof(LayoutDocumentPane)); + else if (reader.LocalName == nameof(LayoutDocument)) + serializer = new XmlSerializer(typeof(LayoutDocument)); + else if (reader.LocalName == nameof(LayoutAnchorGroup)) + serializer = new XmlSerializer(typeof(LayoutAnchorGroup)); + else if (reader.LocalName == nameof(LayoutPanel)) + serializer = new XmlSerializer(typeof(LayoutPanel)); + else + { + var type = FindType(reader.LocalName); + if (type == null) + throw new ArgumentException("AvalonDock.LayoutGroup doesn't know how to deserialize " + reader.LocalName); + serializer = new XmlSerializer(type); + } + + Children.Add((T)serializer.Deserialize(reader)); + } + + reader.ReadEndElement(); + } + + /// + /// provides a standard overridable implementation for deriving classes. + public virtual void WriteXml(System.Xml.XmlWriter writer) + { + foreach (var child in Children) + { + var type = child.GetType(); + var serializer = new XmlSerializer(type); + serializer.Serialize(writer, child); + } + } + + #endregion Public Methods + + #region Internal Methods + + protected virtual void OnIsVisibleChanged() + { + UpdateParentVisibility(); + } + + protected abstract bool GetVisibility(); + + protected virtual void ChildMoved(int oldIndex, int newIndex) + { + } + + #endregion Internal Methods + + #region Overrides + + /// + protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue) + { + base.OnParentChanged(oldValue, newValue); + ComputeVisibility(); + } + + #endregion Overrides + + #region Private Methods + + private void Children_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) + { + if (e.OldItems != null) + { + foreach (LayoutElement element in e.OldItems) + if (element.Parent == this || e.Action == NotifyCollectionChangedAction.Remove) element.Parent = null; + } + } + if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace) + { + if (e.NewItems != null) + { + foreach (LayoutElement element in e.NewItems) + { + if (element.Parent == this) continue; + element.Parent?.RemoveChild(element); + element.Parent = this; + } + } + } + + ComputeVisibility(); + OnChildrenCollectionChanged(); + + if (e.Action == NotifyCollectionChangedAction.Add) + // #81 - Make parents update their children up the tree. Otherwise, they will not be redrawn. + RaiseChildrenTreeChanged(); + else + NotifyChildrenTreeChanged(ChildrenTreeChange.DirectChildrenChanged); + RaisePropertyChanged(nameof(ChildrenCount)); + } + + private void UpdateParentVisibility() + { + if (Parent is ILayoutElementWithVisibility parentPane) + parentPane.ComputeVisibility(); + } + + private Type FindType(string name) + { + foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) + foreach (var t in a.GetTypes()) + if (t.Name.Equals(name)) return t; + return null; + } + + #endregion Private Methods + } } \ No newline at end of file