48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
|
|
using System.Collections.ObjectModel;
|
|||
|
|
using System.Windows.Data;
|
|||
|
|
using System.Windows.Input;
|
|||
|
|
|
|||
|
|
|
|||
|
|
using Mstn.Toolkit.External;
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
namespace MSDevTool.ViewModels
|
|||
|
|
{
|
|||
|
|
public class ElementInfoViewModel
|
|||
|
|
{
|
|||
|
|
public ElementInfoViewModel()
|
|||
|
|
{
|
|||
|
|
ECPropValues = [];
|
|||
|
|
var cv = CollectionViewSource.GetDefaultView(ECPropValues);
|
|||
|
|
cv.GroupDescriptions.Add(new PropertyGroupDescription("ECInstanceName"));
|
|||
|
|
|
|||
|
|
ClassPropValues = [];
|
|||
|
|
var cv1 = CollectionViewSource.GetDefaultView(ClassPropValues);
|
|||
|
|
cv1.GroupDescriptions.Add(new PropertyGroupDescription("ClassName"));
|
|||
|
|
}
|
|||
|
|
public ObservableCollection<ECPropValue> ECPropValues { get; set; }
|
|||
|
|
public ObservableCollection<ClassPropValue> ClassPropValues { get; set; }
|
|||
|
|
|
|||
|
|
RelayCommand showElementCommand;
|
|||
|
|
|
|||
|
|
public ICommand ShowObjectCommand => showElementCommand ??= new RelayCommand(ShowObject, b => true);
|
|||
|
|
|
|||
|
|
private void ShowObject(object obj)
|
|||
|
|
{
|
|||
|
|
if (obj is ClassPropValue { PropValue: not null } model)
|
|||
|
|
{
|
|||
|
|
var type = model.PropValue.GetType();
|
|||
|
|
if (type.IsClass || (type.IsValueType && !type.IsEnum && !type.IsPrimitive))
|
|||
|
|
{
|
|||
|
|
var props = SnoopHelpers.GetClassPropDictionary(model.PropValue);
|
|||
|
|
ObjectViewModel viewModel = new ObjectViewModel() { PropValues = props };
|
|||
|
|
ObjectView view = new ObjectView(viewModel);
|
|||
|
|
view.Title = model.PropName;
|
|||
|
|
view.Show();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|