添加项目文件。
This commit is contained in:
47
MSDevTool/ViewModels/ElementInfoViewModel.cs
Normal file
47
MSDevTool/ViewModels/ElementInfoViewModel.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user