mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Project panel now updates when a file is added to project tree.
This commit is contained in:
parent
10aa72176e
commit
e338ae31ca
@ -27,7 +27,7 @@ namespace RainmeterStudio.Business
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Callbacks
|
#region Events
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a project is opened or the active project closes.
|
/// Called when a project is opened or the active project closes.
|
||||||
@ -123,7 +123,10 @@ namespace RainmeterStudio.Business
|
|||||||
{
|
{
|
||||||
_projectTemplates.Add(template);
|
_projectTemplates.Add(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a list of existing project templates
|
||||||
|
/// </summary>
|
||||||
public IEnumerable<IProjectTemplate> ProjectTemplates { get { return _projectTemplates; } }
|
public IEnumerable<IProjectTemplate> ProjectTemplates { get { return _projectTemplates; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using RainmeterStudio.Core.Model;
|
using RainmeterStudio.Core.Model;
|
||||||
|
using RainmeterStudio.Core.Utils;
|
||||||
|
|
||||||
namespace RainmeterStudio.UI.ViewModel
|
namespace RainmeterStudio.UI.ViewModel
|
||||||
{
|
{
|
||||||
@ -13,7 +15,7 @@ namespace RainmeterStudio.UI.ViewModel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ReferenceViewModel : INotifyPropertyChanged, INotifyCollectionChanged
|
public class ReferenceViewModel : INotifyPropertyChanged, INotifyCollectionChanged
|
||||||
{
|
{
|
||||||
private List<ReferenceViewModel> _children = null;
|
private ObservableCollection<ReferenceViewModel> _children = new ObservableCollection<ReferenceViewModel>();
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ namespace RainmeterStudio.UI.ViewModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an enumerable of this object's children
|
/// Gets an enumerable of this object's children
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<ReferenceViewModel> Children
|
public ObservableCollection<ReferenceViewModel> Children
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -118,10 +120,10 @@ namespace RainmeterStudio.UI.ViewModel
|
|||||||
{
|
{
|
||||||
Reference = reference;
|
Reference = reference;
|
||||||
Reference.CollectionChanged += Reference_CollectionChanged;
|
Reference.CollectionChanged += Reference_CollectionChanged;
|
||||||
UpdateChildren();
|
RefreshChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reference_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
private void Reference_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
List<ReferenceViewModel> newItems = new List<ReferenceViewModel>();
|
List<ReferenceViewModel> newItems = new List<ReferenceViewModel>();
|
||||||
List<ReferenceViewModel> oldItems = new List<ReferenceViewModel>();
|
List<ReferenceViewModel> oldItems = new List<ReferenceViewModel>();
|
||||||
@ -143,12 +145,12 @@ namespace RainmeterStudio.UI.ViewModel
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
UpdateChildren();
|
RefreshChildren();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_children.RemoveAll(oldItems.Contains);
|
oldItems.ForEach(x => _children.Remove(x));
|
||||||
_children.AddRange(newItems);
|
newItems.ForEach(_children.Add);
|
||||||
|
|
||||||
// Pass event
|
// Pass event
|
||||||
if (CollectionChanged != null)
|
if (CollectionChanged != null)
|
||||||
@ -168,9 +170,10 @@ namespace RainmeterStudio.UI.ViewModel
|
|||||||
IsExpanded = value;
|
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
|
#endregion
|
||||||
|
Loading…
Reference in New Issue
Block a user