Exemplo n.º 1
0
		public PropertyEditor CreateEditor(Type baseType, ProviderContext context)
		{
			PropertyEditor e = null;
			bool compRef = !(context.ParentEditor is GameObjectOverviewPropertyEditor);

			// -------- Specialized area --------
			if (baseType == typeof(GameObject))
			{
				if (context.ParentEditor == null)
					e = new GameObjectOverviewPropertyEditor();
				else
					e = new GameObjectRefPropertyEditor();
			}
			else if (baseType == typeof(Transform) && !compRef)		e = new TransformPropertyEditor();
			else if (baseType == typeof(SoundEmitter) && !compRef)	e = new SoundEmitterPropertyEditor();
			else if (baseType == typeof(BatchInfo))					e = new BatchInfoPropertyEditor();
			else if (baseType == typeof(Material))					e = new MaterialPropertyEditor();
			else if (baseType == typeof(Texture))					e = new TexturePropertyEditor();
			else if (baseType == typeof(AudioData))					e = new AudioDataPropertyEditor();
			else if (baseType == typeof(Pixmap))					e = new PixmapPropertyEditor();
			else if (baseType == typeof(Font))						e = new FontPropertyEditor();

			//// -------- Semi-Specialized area --------
			else if (typeof(RigidBody).IsAssignableFrom(baseType) && !compRef)	e = new RigidBodyPropertyEditor();
			else if (typeof(DrawTechnique).IsAssignableFrom(baseType))			e = new DrawTechniquePropertyEditor();

			// -------- General area --------
			else if (typeof(ShapeInfo).IsAssignableFrom(baseType))				e = new RigidBodyShapePropertyEditor();
			else if (typeof(Component).IsAssignableFrom(baseType) && compRef)	e = new ComponentRefPropertyEditor();
			else if (typeof(Component).IsAssignableFrom(baseType) && !compRef)	e = new ComponentPropertyEditor();
			else if (typeof(Resource).IsAssignableFrom(baseType))				e = new ResourcePropertyEditor();
			else if (typeof(IContentRef).IsAssignableFrom(baseType))			e = new IContentRefPropertyEditor();

			return e;
		}
Exemplo n.º 2
0
		public int IsResponsibleFor(Type baseType, ProviderContext context)
		{
			// -------- Specialized area --------
			if (baseType == typeof(GameObject))			return PropertyGrid.EditorPriority_Specialized;
			else if (baseType == typeof(Transform))		return PropertyGrid.EditorPriority_Specialized;
			else if (baseType == typeof(SoundEmitter))	return PropertyGrid.EditorPriority_Specialized;
			else if (baseType == typeof(BatchInfo))		return PropertyGrid.EditorPriority_Specialized;
			else if (baseType == typeof(Material))		return PropertyGrid.EditorPriority_Specialized;
			else if (baseType == typeof(Texture))		return PropertyGrid.EditorPriority_Specialized;
			else if (baseType == typeof(AudioData))		return PropertyGrid.EditorPriority_Specialized;
			else if (baseType == typeof(Pixmap))		return PropertyGrid.EditorPriority_Specialized;
			else if (baseType == typeof(Font))			return PropertyGrid.EditorPriority_Specialized;

			//// -------- Semi-Specialized area --------
			else if (typeof(RigidBody).IsAssignableFrom(baseType))			return PropertyGrid.EditorPriority_General + 1;
			else if (typeof(DrawTechnique).IsAssignableFrom(baseType))		return PropertyGrid.EditorPriority_General + 1;

			// -------- General area --------
			else if (typeof(ShapeInfo).IsAssignableFrom(baseType))	return PropertyGrid.EditorPriority_General;
			else if (typeof(Component).IsAssignableFrom(baseType))			return PropertyGrid.EditorPriority_General;
			else if (typeof(Resource).IsAssignableFrom(baseType))			return PropertyGrid.EditorPriority_General;
			else if (typeof(IContentRef).IsAssignableFrom(baseType))		return PropertyGrid.EditorPriority_General;
			
			else return PropertyGrid.EditorPriority_None;
		}
 /// <summary>
 /// Determines the matching level between a PropertyEditor and the specified property Type.
 /// </summary>
 /// <param name="propertyType"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 public int MatchToProperty(Type propertyType, ProviderContext context)
 {
     if (this.dynamicAssign != null)
         return this.dynamicAssign(propertyType, context);
     else if (this.assignToType.IsAssignableFrom(propertyType))
         return this.assignPriority;
     else
         return PropertyGrid.EditorPriority_None;
 }
Exemplo n.º 4
0
		public PropertyEditor CreateEditor(Type baseType, ProviderContext context)
		{
			PropertyEditor e = null;

			if (baseType == typeof(ArrayNode))			e = new ArrayNodePropertyEditor();
			else if (baseType == typeof(PrimitiveNode))	e = new PrimitiveNodePropertyEditor();

			return e;
		}
Exemplo n.º 5
0
		public int IsResponsibleFor(Type baseType, ProviderContext context)
		{
			if (baseType == typeof(Vector2))		return PropertyGrid.EditorPriority_General;
			else if (baseType == typeof(Vector3))	return PropertyGrid.EditorPriority_General;
			else if (baseType == typeof(Vector4))	return PropertyGrid.EditorPriority_General;
			else if (baseType == typeof(Rect))		return PropertyGrid.EditorPriority_General;

			else if (typeof(IColorData).IsAssignableFrom(baseType))		return PropertyGrid.EditorPriority_General;

			else return PropertyGrid.EditorPriority_None;
		}
Exemplo n.º 6
0
		public PropertyEditor CreateEditor(Type baseType, ProviderContext context)
		{
			PropertyEditor e = null;

			if (baseType == typeof(Vector2))		e = new Vector2PropertyEditor();
			else if (baseType == typeof(Vector3))	e = new Vector3PropertyEditor();
			else if (baseType == typeof(Vector4))	e = new Vector4PropertyEditor();
			else if (baseType == typeof(Rect))		e = new RectPropertyEditor();

			else if (typeof(IColorData).IsAssignableFrom(baseType))		e = new IColorDataPropertyEditor();

			return e;
		}
Exemplo n.º 7
0
 public int IsResponsibleFor(Type baseType, ProviderContext context)
 {
     IEnumerable<Type> propertyEditorTypes = DualityEditorApp.GetAvailDualityEditorTypes(typeof(PropertyEditor));
     if (propertyEditorTypes.Any())
     {
         int bestScore = PropertyGrid.EditorPriority_None;
         foreach (Type editorType in propertyEditorTypes)
         {
             var assignment = editorType.GetCustomAttributes<PropertyEditorAssignmentAttribute>().FirstOrDefault();
             if (assignment == null) continue;
             int score = assignment.MatchToProperty(baseType, context);
             if (score > bestScore)
             {
                 bestScore = score;
             }
         }
         return bestScore;
     }
     else
     {
         return PropertyGrid.EditorPriority_None;
     }
 }
Exemplo n.º 8
0
        public PropertyEditor CreateEditor(Type baseType, ProviderContext context)
        {
            IEnumerable<Type> propertyEditorTypes = DualityEditorApp.GetAvailDualityEditorTypes(typeof(PropertyEditor));
            if (propertyEditorTypes.Any())
            {
                int bestScore = PropertyGrid.EditorPriority_None;
                Type bestType = null;
                foreach (Type editorType in propertyEditorTypes)
                {
                    var assignment = editorType.GetCustomAttributes<PropertyEditorAssignmentAttribute>().FirstOrDefault();
                    if (assignment == null) continue;
                    int score = assignment.MatchToProperty(baseType, context);
                    if (score > bestScore)
                    {
                        bestScore = score;
                        bestType = editorType;
                    }
                }
                if (bestType != null) return bestType.CreateInstanceOf() as PropertyEditor;
            }

            return null;
        }
Exemplo n.º 9
0
 private static int MatchToProperty(Type propertyType, ProviderContext context)
 {
     bool compRef = !(context.ParentEditor is GameObjectOverviewPropertyEditor);
     if (typeof(Transform).IsAssignableFrom(propertyType) && !compRef)
         return PropertyEditorAssignmentAttribute.PrioritySpecialized;
     else
         return PropertyEditorAssignmentAttribute.PriorityNone;
 }
 private static int MatchToProperty(Type propertyType, ProviderContext context)
 {
     if (typeof(GameObject).IsAssignableFrom(propertyType) && context.ParentEditor == null)
         return PropertyEditorAssignmentAttribute.PrioritySpecialized;
     else
         return PropertyEditorAssignmentAttribute.PriorityNone;
 }
Exemplo n.º 11
0
			public PropertyEditor CreateEditor(Type baseType, ProviderContext context)
			{
				PropertyEditor e = null;

				// Basic numeric data types
				if (baseType == typeof(sbyte) || baseType == typeof(byte) ||
					baseType == typeof(short) || baseType == typeof(ushort) ||
					baseType == typeof(int) || baseType == typeof(uint) ||
					baseType == typeof(long) || baseType == typeof(ulong) ||
					baseType == typeof(float) || baseType == typeof(double) || baseType == typeof(decimal))
					e = new NumericPropertyEditor();
				// Basic data type: Boolean
				else if (baseType == typeof(bool))
				    e = new BoolPropertyEditor();
				// Basic data type: Flagged Enum
				else if (baseType.IsEnum && baseType.GetCustomAttributes(typeof(FlagsAttribute), true).Any())
					e = new FlaggedEnumPropertyEditor();
				// Basic data type: Other Enums
				else if (baseType.IsEnum)
					e = new EnumPropertyEditor();
				// Basic data type: String
				else if (baseType == typeof(string))
					e = new StringPropertyEditor();
				// IList
				else if (typeof(System.Collections.IList).IsAssignableFrom(baseType))
					e = new IListPropertyEditor();
				// IList
				else if (typeof(System.Collections.IDictionary).IsAssignableFrom(baseType))
					e = new IDictionaryPropertyEditor();
				// Unknown data type
				else
				{
					// Ask around if any sub-editor can handle it and choose the most specialized
					var availSubProviders = 
						from p in this.subProviders
						where p.IsResponsibleFor(baseType, context) != EditorPriority_None
						orderby p.IsResponsibleFor(baseType, context) descending
						select p;
					IPropertyEditorProvider subProvider = availSubProviders.FirstOrDefault();
					if (subProvider != null)
					{
						e = subProvider.CreateEditor(baseType, context);
						e.EditedType = baseType;
						return e;
					}

					// If not, default to reflection-driven MemberwisePropertyEditor
					e = new MemberwisePropertyEditor();
				}

				e.EditedType = baseType;
				return e;
			}
Exemplo n.º 12
0
			public int IsResponsibleFor(Type baseType, ProviderContext context)
			{
				return EditorPriority_General;
			}
Exemplo n.º 13
0
            public PropertyEditor CreateEditor(Type baseType, ProviderContext context)
            {
                PropertyEditor e = null;

                // Basic numeric data types
                if (baseType == typeof(sbyte) || baseType == typeof(byte) ||
                    baseType == typeof(short) || baseType == typeof(ushort) ||
                    baseType == typeof(int) || baseType == typeof(uint) ||
                    baseType == typeof(long) || baseType == typeof(ulong) ||
                    baseType == typeof(float) || baseType == typeof(double) || baseType == typeof(decimal))
                {
                    e = new NumericPropertyEditor();
                }
                // Basic data type: Boolean
                else if (baseType == typeof(bool))
                {
                    e = new BoolPropertyEditor();
                }
                // Basic data type: Flagged Enum
                else if (baseType.IsEnum && baseType.GetCustomAttributes(typeof(FlagsAttribute), true).Any())
                {
                    e = new FlaggedEnumPropertyEditor();
                }
                // Basic data type: Other Enums
                else if (baseType.IsEnum)
                {
                    e = new EnumPropertyEditor();
                }
                // Basic data type: String
                else if (baseType == typeof(string))
                {
                    e = new StringPropertyEditor();
                }
                // IList
                else if (typeof(System.Collections.IList).IsAssignableFrom(baseType))
                {
                    e = new IListPropertyEditor();
                }
                // IList
                else if (typeof(System.Collections.IDictionary).IsAssignableFrom(baseType))
                {
                    e = new IDictionaryPropertyEditor();
                }
                // Unknown data type
                else
                {
                    // Ask around if any sub-editor can handle it and choose the most specialized
                    var availSubProviders =
                        from p in this.subProviders
                        where p.IsResponsibleFor(baseType, context) != EditorPriority_None
                        orderby p.IsResponsibleFor(baseType, context) descending
                        select p;

                    IPropertyEditorProvider subProvider = availSubProviders.FirstOrDefault();
                    if (subProvider != null)
                    {
                        e            = subProvider.CreateEditor(baseType, context);
                        e.EditedType = baseType;
                        return(e);
                    }

                    // If not, default to reflection-driven MemberwisePropertyEditor
                    e = new MemberwisePropertyEditor();
                }

                e.EditedType = baseType;
                return(e);
            }
Exemplo n.º 14
0
 public int IsResponsibleFor(Type baseType, ProviderContext context)
 {
     return(EditorPriority_General);
 }
Exemplo n.º 15
0
		public int IsResponsibleFor(Type baseType, ProviderContext context)
		{
			if (baseType == typeof(ArrayNode))			return PropertyGrid.EditorPriority_Specialized;
			else if (baseType == typeof(PrimitiveNode))	return PropertyGrid.EditorPriority_Specialized;
			else return PropertyGrid.EditorPriority_None;
		}