コード例 #1
0
        private void DrawProperties()
        {
            // no component type = no drawing
            if (_componentType?.Type == null)
            {
                return;
            }

            // check component instance
            if (_component == null || _component.GetType() != _componentType.Type)
            {
                _component = Activator.CreateInstance(_componentType.Type) as ISharedComponentData;
                if (_component == null)
                {
                    return;
                }

                _fields = _componentType.Type.GetFields(BindingFlags.Instance | BindingFlags.Public)
                          .Select(f => SharedComponentField.Create(_component, f))
                          .ToArray();
                _allFieldsValid = !_fields.Any(f => f is SharedComponentFieldUndefined);
            }

            foreach (var field in _fields)
            {
                field.Draw();
            }
        }
コード例 #2
0
 public SharedComponentFieldFlagEnum(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo)
 {
 }
コード例 #3
0
 public static SharedComponentField Create(ISharedComponentData component, FieldInfo fieldInfo)
 {
     // floating-points
     if (fieldInfo.FieldType == typeof(float))
     {
         return(new SharedComponentFieldFloat(component, fieldInfo));
     }
     if (fieldInfo.FieldType == typeof(double))
     {
         return(new SharedComponentFieldDouble(component, fieldInfo));
     }
     if (fieldInfo.FieldType == typeof(decimal))
     {
         return(new SharedComponentFieldDecimal(component, fieldInfo));
     }
     // integral
     if (fieldInfo.FieldType == typeof(int))
     {
         return(new SharedComponentFieldInt(component, fieldInfo));
     }
     if (fieldInfo.FieldType == typeof(uint))
     {
         return(new SharedComponentFieldUInt(component, fieldInfo));
     }
     if (fieldInfo.FieldType == typeof(long))
     {
         return(new SharedComponentFieldLong(component, fieldInfo));
     }
     if (fieldInfo.FieldType == typeof(ulong))
     {
         return(new SharedComponentFieldULong(component, fieldInfo));
     }
     if (fieldInfo.FieldType == typeof(short))
     {
         return(new SharedComponentFieldShort(component, fieldInfo));
     }
     if (fieldInfo.FieldType == typeof(ushort))
     {
         return(new SharedComponentFieldUShort(component, fieldInfo));
     }
     if (fieldInfo.FieldType == typeof(byte))
     {
         return(new SharedComponentFieldByte(component, fieldInfo));
     }
     if (fieldInfo.FieldType == typeof(sbyte))
     {
         return(new SharedComponentFieldSByte(component, fieldInfo));
     }
     // enum
     if (fieldInfo.FieldType.IsEnum)
     {
         if (fieldInfo.FieldType.IsDefined(typeof(FlagsAttribute), false))
         {
             return(new SharedComponentFieldFlagEnum(component, fieldInfo));
         }
         else
         {
             return(new SharedComponentFieldEnum(component, fieldInfo));
         }
     }
     // fallback
     return(new SharedComponentFieldUndefined(component, fieldInfo));
 }
コード例 #4
0
 public SharedComponentFieldSByte(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo)
 {
 }
コード例 #5
0
 protected SharedComponentField(ISharedComponentData component, FieldInfo fieldInfo)
 {
     _component  = component;
     _fieldInfo  = fieldInfo;
     _editorName = ObjectNames.NicifyVariableName(_fieldInfo.Name);
 }
コード例 #6
0
 public SharedComponentFieldUShort(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo)
 {
 }
コード例 #7
0
 public SharedComponentFieldDecimal(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo)
 {
 }
コード例 #8
0
 public SharedComponentFieldUndefined(ISharedComponentData component, FieldInfo fieldInfo) : base(component, fieldInfo)
 {
 }