84 lines
2.5 KiB
C#
84 lines
2.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.Specialized;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
using Ubisoft.Controls.Wpf.PropertyBrowser;
|
|
using Ubisoft.Controls.Wpf.PropertyBrowser.ClrProvider;
|
|
using Ubisoft.Controls.Wpf.PropertyBrowser.ViewModels;
|
|
|
|
namespace UAF.PropertyGrid
|
|
{
|
|
|
|
/// <summary>
|
|
/// Special Property Browser for UAF Tools.
|
|
/// </summary>
|
|
public class PropertyGrid : PropertyBrowser
|
|
{
|
|
|
|
#region Resources
|
|
|
|
private static readonly ResourceDictionary PropertyGridResourceDictionary = new ResourceDictionary()
|
|
{
|
|
Source = new Uri(string.Format("pack://application:,,,/{0};component/Themes/Generic.xaml", typeof(PropertyGrid).Assembly.FullName))
|
|
};
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public PropertyGrid()
|
|
{
|
|
|
|
Resources.MergedDictionaries.Add(PropertyGridResourceDictionary);
|
|
//ViewModel.PropertyProvider = new PropertyGridProvider();
|
|
BreadcrumbVisibility = Visibility.Collapsed;
|
|
//ItemsCollectionChanged += OnPropertyItemsCollectionChanged;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Events
|
|
|
|
public event NotifyCollectionChangedEventHandler ItemsCollectionChanged
|
|
{
|
|
add
|
|
{
|
|
((INotifyCollectionChanged) ViewModel.RootPropertyItem.PropertyItemHolderCollection.PropertyItems)
|
|
.CollectionChanged += value;
|
|
}
|
|
remove
|
|
{
|
|
((INotifyCollectionChanged) ViewModel.RootPropertyItem.PropertyItemHolderCollection.PropertyItems)
|
|
.CollectionChanged -= value;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Handlers
|
|
|
|
private void OnPropertyItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
{
|
|
// Completely temp solution
|
|
// TODO : remove this handler when Flattened attribute is handled.
|
|
var items =
|
|
ViewModel.RootPropertyItem.PropertyItems.OfType<ClrPropertyItem>()
|
|
.Where(item => item.PropertyDescriptor.Name == "Model" || item.PropertyDescriptor.Name.ToLower() == "components")
|
|
.ToArray();
|
|
foreach (var propertyItem in items)
|
|
{
|
|
if(!propertyItem.IsExpanded)
|
|
propertyItem.IsExpanded = true;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|