void RegisterValue(object value) { List <TypeRow> newRows = new List <TypeRow>(); Action <object, int> parseObject = null; parseObject = (objValue, indent) => { Data.EditableValue[] editableValues = null; if (objValue is Data.IEditableValueCollection) { editableValues = (objValue as Data.IEditableValueCollection).GetValues(); } else { var props = objValue.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); editableValues = props.Select(_ => Data.EditableValue.Create(_.GetValue(objValue), _)).ToArray(); } List <TypeRow> localRows = new List <TypeRow>(); foreach (var editableValue in editableValues) { var propValue = editableValue.Value; var prop = editableValue; TypeRow row = null; if (!editableValue.IsShown) { continue; } if (objToTypeRow.ContainsKey(propValue)) { row = objToTypeRow[propValue]; row.UpdateTitleAndDesc(prop); row.SetSelector(localRows); row.SelectorIndent = indent; if (row.Selector != null) { row.SelectorIndent++; } #if DEBUG if (row.BindingValue != propValue) { throw new Exception(); } #endif if (!row.IsShown()) { continue; } } else { row = new TypeRow(prop); row.SetSelector(localRows); row.BindingValue = propValue; row.SelectorIndent = indent; if (row.Selector != null) { row.SelectorIndent++; } if (!row.IsShown()) { continue; } if (row.Control == null) { if (prop.Value.GetType() == typeof(Data.NodeBase)) { continue; } if (prop.Value.GetType() == typeof(Data.NodeBase.ChildrenCollection)) { continue; } if (prop.Value.GetType() == typeof(Data.Value.FCurve <float>)) { continue; } if (prop.Value.GetType() == typeof(Data.Value.FCurve <byte>)) { continue; } parseObject(propValue, row.SelectorIndent); continue; } else { row.ControlDynamic.SetBinding(propValue); objToTypeRow.Add(propValue, row); } } newRows.Add(row); localRows.Add(row); if (propValue is Data.IEditableValueCollection) { parseObject(propValue, row.SelectorIndent); } { var o0 = row.BindingValue as Data.Value.EnumBase; var o1 = row.BindingValue as Data.Value.PathForImage; var o2 = row.BindingValue as Data.IEditableValueCollection; #if __EFFEKSEER_BUILD_VERSION16__ var o3 = row.BindingValue as Data.Value.Boolean; #endif if (o0 != null && row.IsSelector) { o0.OnChanged += ChangeSelector; } else if (o1 != null) { o1.OnChanged += ChangeSelector; } else if (o2 != null) { o2.OnChanged += ChangeSelector; } #if __EFFEKSEER_BUILD_VERSION16__ else if (o3 != null) { o3.OnChanged += ChangeSelector; } #endif } } }; parseObject(value, 0); foreach (var row in controlRows.Internal.ToArray()) { if (newRows.Contains(row)) { continue; } RemoveRow(row, true); objToTypeRow.Remove(row.BindingValue); } controlRows.Clear(); foreach (var n in newRows) { controlRows.Add(n); } bindingObject = value; if (bindingObject is Data.IEditableValueCollection) { var o2 = bindingObject as Data.IEditableValueCollection; o2.OnChanged += ChangeSelector; } }
void RegisterValue(object value, int indent) { List <TypeRow> newRows = new List <TypeRow>(); Dictionary <object, TypeRow> objToTypeRow = new Dictionary <object, TypeRow>(); foreach (var row in controlRows.Internal) { objToTypeRow.Add(row.BindingValue, row); } { Data.EditableValue[] editableValues = null; if (value is Data.IEditableValueCollection) { editableValues = (value as Data.IEditableValueCollection).GetValues(); } else { var props = value.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).OrderBy(x => x.MetadataToken); editableValues = props.Select(_ => Data.EditableValue.Create(_.GetValue(value), _)).ToArray(); } List <TypeRow> localRows = new List <TypeRow>(); foreach (var editableValue in editableValues) { var propValue = editableValue.Value; var prop = editableValue; TypeRow row = null; if (!editableValue.IsShown) { continue; } if (objToTypeRow.ContainsKey(propValue)) { row = objToTypeRow[propValue]; row.UpdateTitleAndDesc(prop); row.SetSelector(localRows); row.SelectorIndent = indent; if (row.Selector != null) { row.SelectorIndent++; } #if DEBUG if (row.BindingValue != propValue) { throw new Exception(); } #endif if (!row.IsShown()) { continue; } if (row.Control == null) { // It is possible that children are changed even if a parent is not changed. row.Children.RegisterValue(propValue, row.SelectorIndent); } } else { row = new TypeRow(prop); row.SetSelector(localRows); row.BindingValue = propValue; row.SelectorIndent = indent; if (row.Selector != null) { row.SelectorIndent++; } if (!row.IsShown()) { continue; } if (row.Control == null) { row.Children = new TypeRowCollection(); row.Children.RegisterValue(propValue, row.SelectorIndent); } else { row.ControlDynamic.SetBinding(propValue); } objToTypeRow.Add(propValue, row); } newRows.Add(row); localRows.Add(row); if (propValue is Data.IEditableValueCollection) { row.Children = new TypeRowCollection(); row.Children.RegisterValue(propValue, row.SelectorIndent); } { var o0 = row.BindingValue as Data.Value.EnumBase; var o1 = row.BindingValue as Data.Value.PathForImage; var o2 = row.BindingValue as Data.IEditableValueCollection; var o3 = row.BindingValue as Data.Value.Boolean; if (o0 != null && row.IsSelector) { o0.OnChanged += ChangeSelector; } else if (o1 != null) { o1.OnChanged += ChangeSelector; } else if (o2 != null) { o2.OnChanged += ChangeSelector; } else if (o3 != null) { o3.OnChanged += ChangeSelector; } } } } foreach (var row in controlRows.Internal.ToArray()) { if (newRows.Contains(row)) { continue; } RemoveRow(row, true); objToTypeRow.Remove(row.BindingValue); } controlRows.Clear(); foreach (var n in newRows) { controlRows.Add(n); } bindingObject = value; if (bindingObject is Data.IEditableValueCollection) { var o2 = bindingObject as Data.IEditableValueCollection; o2.OnChanged += ChangeSelector; } }