예제 #1
0
    public static UIField NewField(FieldInfo info, int arrayLevel, bool makeReadOnly)
    {
        if (info == null)
        {
            return(null);
        }
        Type fieldType = GetElementType(info.FieldType, arrayLevel);

        if (fieldType == null)
        {
            return(null);
        }
        UIField newField;
        bool    isArray = fieldType.IsArray;
        DatabaseReferenceAttribute databaseReference = GetDatabaseReferenceAttribute(info);

        if (databaseReference != null)
        {
            fieldType = databaseReference.dataType;
        }

        if (isArray == false)
        {
            InputType inputType = GetInputType(fieldType);
            switch (inputType)
            {
            case InputType.Value: newField = new UIValueField(); break;

            case InputType.Data: newField = new UIDataPackField(); break;

            default: return(null);
            }
        }
        else
        {
            Type      arrayType = isArray ? fieldType.GetElementType() : null;
            InputType inputType = GetInputType(arrayType);
            switch (inputType)
            {
            case InputType.Value: newField = new UIValueArrayField(); break;

            case InputType.Data: newField = new UIDataPackArrayField(); break;

            default: return(null);
            }
        }

        newField.Info       = info;
        newField.ArrayLevel = arrayLevel;
        newField.label      = UITranslator.TranslateCurrent(info.Name);
        newField.DatabaseID = null;
        newField.ReadOnly   = makeReadOnly;// || databaseReference != null;
        return(newField);
    }
예제 #2
0
    private void OnFieldValueChange(string stringValue)
    {
        if (CurrentField == null || (CurrentField is UIValueField == false))
        {
            return;
        }
        UIValueField currentValueField = CurrentField as UIValueField;

        if (currentValueField.StringInput != stringValue)
        {
            onEdit.Invoke();
            CurrentField.Edit();
        }
    }
예제 #3
0
    private void OnFieldEndEdit(string stringValue)
    {
        if (CurrentField == null || (CurrentField is UIValueField == false))
        {
            return;
        }
        UIValueField currentValueField = CurrentField as UIValueField;

        if (currentValueField.StringInput != stringValue)
        {
            //currentValueField.StringInput = stringValue;
            currentValueField.SetInput(stringValue);
            onEndEdit.Invoke();
            CurrentField.ApplyChanges();
            CurrentField.EndEdit();
        }
    }