Example #1
0
    internal virtual void OnDuplicate(IList <EntryComponent> entryComponents, int i)
    {
        entryComponents.Insert(i + 1, null);
        entryComponents[i + 1]                     = entryComponents[i].Clone() as EntryComponent;
        entryComponents[i + 1].FieldName           = EntryData.GetNextAvailableName();
        entryComponents[i + 1].OnEditModeModified += () =>
        {
            EntryData.ValidateFieldName(entryComponents[i + 1]);
            OnDataChanged(entryComponents[i + 1]);
        };

        EntryData.OnComponentChanged(ListChangeType.Duplicate, i, -1);
    }
Example #2
0
    public EntryComponent CreateNewComponent(Type componentType)
    {
        if (!typeof(EntryComponent).IsAssignableFrom(componentType))
        {
            throw  new ArgumentException("incompatible type");
        }
        var instance = EntryComponent.CreateInstance(componentType);

        instance.Initialize(EntryData, EntryData.GetNextAvailableName());
        instance.OnEditModeModified += () =>
        {
            EntryData.ValidateFieldName(instance);
            OnDataChanged(instance);
        };
        //EntryData.OnComponentChanged(ListChangeType.Add);
        return(instance);
    }