diff --git a/RainmeterStudio/Business/ProjectManager.cs b/RainmeterStudio/Business/ProjectManager.cs index 0d94c57a..dbc0e526 100644 --- a/RainmeterStudio/Business/ProjectManager.cs +++ b/RainmeterStudio/Business/ProjectManager.cs @@ -27,7 +27,7 @@ namespace RainmeterStudio.Business #endregion - #region Callbacks + #region Events /// /// Called when a project is opened or the active project closes. @@ -123,7 +123,10 @@ namespace RainmeterStudio.Business { _projectTemplates.Add(template); } - + + /// + /// Gets a list of existing project templates + /// public IEnumerable ProjectTemplates { get { return _projectTemplates; } } } } diff --git a/RainmeterStudio/UI/ViewModel/ReferenceViewModel.cs b/RainmeterStudio/UI/ViewModel/ReferenceViewModel.cs index 0e34e74a..0d9533aa 100644 --- a/RainmeterStudio/UI/ViewModel/ReferenceViewModel.cs +++ b/RainmeterStudio/UI/ViewModel/ReferenceViewModel.cs @@ -1,10 +1,12 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Linq; using System.Text; using RainmeterStudio.Core.Model; +using RainmeterStudio.Core.Utils; namespace RainmeterStudio.UI.ViewModel { @@ -13,7 +15,7 @@ namespace RainmeterStudio.UI.ViewModel /// public class ReferenceViewModel : INotifyPropertyChanged, INotifyCollectionChanged { - private List _children = null; + private ObservableCollection _children = new ObservableCollection(); #region Properties @@ -47,7 +49,7 @@ namespace RainmeterStudio.UI.ViewModel /// /// Gets an enumerable of this object's children /// - public IEnumerable Children + public ObservableCollection Children { get { @@ -118,10 +120,10 @@ namespace RainmeterStudio.UI.ViewModel { Reference = reference; Reference.CollectionChanged += Reference_CollectionChanged; - UpdateChildren(); + RefreshChildren(); } - void Reference_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + private void Reference_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { List newItems = new List(); List oldItems = new List(); @@ -143,12 +145,12 @@ namespace RainmeterStudio.UI.ViewModel break; default: - UpdateChildren(); + RefreshChildren(); break; } - _children.RemoveAll(oldItems.Contains); - _children.AddRange(newItems); + oldItems.ForEach(x => _children.Remove(x)); + newItems.ForEach(_children.Add); // Pass event if (CollectionChanged != null) @@ -168,9 +170,10 @@ namespace RainmeterStudio.UI.ViewModel IsExpanded = value; } - private void UpdateChildren() + private void RefreshChildren() { - _children = Reference.Children.Select(x => new ReferenceViewModel(x)).ToList(); + _children.Clear(); + Reference.Children.Select(x => new ReferenceViewModel(x)).ForEach(_children.Add); } #endregion