09c0cd491762f7a91b85a07088a63992cfaf6cde
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Design / Tizen.NUI.Design / AttributeTableBuilder.cs
1 using System;
2 using System.ComponentModel;
3 using Microsoft.Windows.Design;
4 using Tizen.NUI.BaseComponents;
5 using Tizen.NUI.XamlBinding;
6
7 namespace Tizen.NUI.Design
8 {
9     internal class AttributeTableBuilder : Microsoft.Windows.Design.Metadata.AttributeTableBuilder
10     {
11         [EditorBrowsable(EditorBrowsableState.Never)]
12         public AttributeTableBuilder()
13         {
14             // Turn off validation of values, which doesn't work for OnPlatform/OnIdiom
15             AddCustomAttributes(typeof(View).Assembly,
16                 new XmlnsSupportsValidationAttribute("http://tizen.org/Tizen.NUI/2018/XAML", false));
17
18             // Style isn't a view, make it visible
19             AddCallback(typeof(Style), builder => builder.AddCustomAttributes(
20                new EditorBrowsableAttribute(EditorBrowsableState.Always),
21                new global::System.Windows.Markup.ContentPropertyAttribute("Setters"),
22                // Since the class doesn't have a public parameterless ctor, we need to provide a converter
23                new global::System.ComponentModel.TypeConverterAttribute(typeof(StringConverter))));
24
25             // The Setter.Value can actually come from an <OnPlatform />, so enable it as Content.
26             AddCallback(typeof(Setter), builder => builder.AddCustomAttributes(
27               new EditorBrowsableAttribute(EditorBrowsableState.Always),
28               new global::System.Windows.Markup.ContentPropertyAttribute("Value")));
29
30             // Special case for FontSize which isn't an enum.
31             //var fontElements = typeof(View).Assembly.ExportedTypes.Where(t => typeof(IFontElement).IsAssignableFrom(t));
32             //foreach (var fontElement in fontElements)
33             //{
34             //    AddCallback(fontElement, builder => builder.AddCustomAttributes(
35             //       "FontSize",
36             //       new global::System.ComponentModel.TypeConverterAttribute(typeof(NonExclusiveEnumConverter<NamedSize>))));
37             //}
38         }
39     }
40
41     internal class AnythingConverter : global::System.ComponentModel.TypeConverter
42     {
43         [EditorBrowsable(EditorBrowsableState.Never)]
44         public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
45         {
46             return true;
47         }
48
49         [EditorBrowsable(EditorBrowsableState.Never)]
50         public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
51         {
52             return true;
53         }
54
55         [EditorBrowsable(EditorBrowsableState.Never)]
56         public override bool IsValid(ITypeDescriptorContext context, object value)
57         {
58             return true;
59         }
60     }
61 }