public override string GetSafeName(object obj, bool hasChildren) { String name = base.GetSafeName(obj, hasChildren); if (hasChildren) { if (obj is IHasEvents) { List <StoryEvent> events = (obj as IHasEvents).GetEvents(); name += AddNameChildren(events); } else if (obj is ObjectEditor.Json.DataObject) { var accessors = FieldAccessor.GetForObject(obj); foreach (Accessor accessor in accessors) { Type type = accessor.GetAccessorType(); if (DataObjectEditor.IsGenericList(type)) { IList list = (IList)accessor.Get(); if (list == null) { continue; } Type listOf = DataObjectEditor.GetFirstGenericType(list); if (typeof(Outcome).IsAssignableFrom(listOf)) { name += AddNameChildren(list); } } } } } return(name); }
public static FieldEditor CreateEditor(Accessor accessor, DataObjectEditor lookup) { if (accessor.GetTags().Any(tag => tag.flag == FieldTags.Hide)) { return(null); } Type type = accessor.GetAccessorType(); if (type.IsEnum) { return(new EnumEditor(accessor)); } if (accessor.GetAccessorType() == typeof(string) && accessor.GetTags().Any(tag => tag.flag == FieldTags.Image)) { return(new ImageEditor(accessor)); } if (accessor.GetAccessorType() == typeof(string) && accessor.GetTags().Any(tag => tag.flag == FieldTags.File)) { return(new FileEditor(accessor)); } if (typeof(Reference).IsAssignableFrom(accessor.GetAccessorType())) { return(new ReferenceEditor(accessor, lookup)); } if (fieldEditors.ContainsKey(type)) { return(fieldEditors[type](accessor, lookup)); } Console.WriteLine("No editor for type " + type.Name); return(null); }
public MapPointEditor(Accessor accessor, DataObjectEditor lookup) : base(accessor) { this.lookup = lookup; button = new Button(); button.Click += button_Click; SetUIValue(GetValue()); }
public ReferenceEditor(Accessor accessor, Lookup lookup) : base(accessor) { this.lookup = lookup; this.type = DataObjectEditor.GetFirstGenericType(accessor.GetAccessorType()); comboBox = new NoScrollComboBox(); comboBox.DropDownStyle = ComboBoxStyle.DropDownList; comboBox.Width = 200; reference = (Reference)accessor.Get(); if (reference != null) { reference.Context = context; } else { throw new Exception("Reference not initialized"); } SetUIValue(GetValue()); comboBox.SelectedValueChanged += UpdateValue; }