4 using System.Collections.Generic;
6 using System.Text.RegularExpressions;
8 using SiliconStudio.Core;
9 using SiliconStudio.Core.Reflection;
10 using SiliconStudio.Quantum;
12 namespace SiliconStudio.Presentation.Quantum
16 public readonly
string[] ReservedNames = {
"Owner",
"Name",
"DisplayName",
"Path",
"Parent",
"Root",
"Type",
"IsPrimitive",
"IsVisible",
"IsReadOnly",
"Value",
"TypedValue",
"Index",
"Guid",
"Children",
"Commands",
"AssociatedData",
"HasList",
"HasDictionary",
"CombinedNodes",
"HasMultipleValues",
"HasMultipleInitialValues",
"ResetInitialValues",
"DistinctInitialValues" };
26 : base(ownerViewModel, parentNode, index)
28 if (baseName == null && index == null)
29 throw new ArgumentException(
"baseName and index can't be both null.");
42 var observableChild = VirtualObservableNode.Create(Owner, name,
this, order, contentType, initialValue, valueChangedCommand);
43 if (nodeAssociatedData != null)
45 foreach (var data
in nodeAssociatedData)
47 observableChild.AddAssociatedData(data.Key, data.Value);
50 AddChild(observableChild);
51 return observableChild;
57 return string.Format(
"{0}: [{1}]", Name, Value);
60 private void SetName(
string nodeName)
63 nodeName = nodeName != null ? nodeName.Replace(
".",
"-") : null;
65 if (!
string.IsNullOrWhiteSpace(nodeName))
68 DisplayName = Regex.Replace(nodeName,
"([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))",
"$1 ");
70 else if (index != null)
74 if (propertyKey != null)
76 string name = propertyKey.Name.Replace(
".",
"-");
79 name = propertyKey.PropertyType.Name.Replace(
".",
"-");
82 var parts = propertyKey.Name.Split(
'.');
83 DisplayName = parts.Length == 2 ? string.Format(
"{0} ({1})", parts[1], parts[0]) : name;
87 if (index.GetType().IsNumeric())
88 Name =
"Item " + index.ToString().Replace(
".",
"-");
90 Name = index.ToString().Replace(
".",
"-");
96 if (ReservedNames.Contains(Name))
override string ToString()
CombineMode
An enum that describes what to do with a node or a command when combining view models.
A base class to wrap one or multiple INodeCommand instances into a CancellableCommand.
SingleObservableNode(ObservableViewModel ownerViewModel, string baseName, ObservableNode parentNode, object index=null)
Initializes a new instance of the SingleObservableNode class.
VirtualObservableNode CreateVirtualChild(string name, Type contentType, int?order, object initialValue, NodeCommandWrapperBase valueChangedCommand=null, IReadOnlyDictionary< string, object > nodeAssociatedData=null)
A class that represents a tag propety.