From 5d9ad3034d306e4a0bf6f43d14a198abf80066bf Mon Sep 17 00:00:00 2001 From: AdunFang <30402408+AdunFang@users.noreply.github.com> Date: Thu, 18 Apr 2019 18:22:13 +0800 Subject: [PATCH] [NUI] Sync Xaml code to newest (#795) --- .../src/internal/Xaml/ApplyPropertiesVisitor.cs | 9 +- .../src/internal/Xaml/CreateValuesVisitor.cs | 1 + .../src/internal/Xaml/ExpandMarkupsVisitor.cs | 1 + .../Xaml/FillResourceDictionariesVisitor.cs | 3 +- .../src/internal/Xaml/IReferenceProvider.cs | 7 + .../Xaml/MarkupExtensions/BindingExtension.cs | 24 +-- .../Xaml/MarkupExtensions/NullExtension.cs | 2 +- .../Xaml/MarkupExtensions/StaticExtension.cs | 2 +- .../Xaml/MarkupExtensions/StyleSheetExtension.cs | 2 +- .../Xaml/MarkupExtensions/TypeExtension.cs | 2 +- .../src/internal/Xaml/NamescopingVisitor.cs | 1 + .../src/internal/Xaml/PruneIgnoredNodesVisitor.cs | 3 +- .../src/internal/Xaml/ReflectionExtensions.cs | 1 - .../src/internal/Xaml/RegisterXNamesVisitor.cs | 4 +- .../src/internal/Xaml/TypeConversionExtensions.cs | 42 ++++-- .../src/internal/Xaml/ValueConverterProvider.cs | 1 - src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs | 74 ++++------ src/Tizen.NUI/src/internal/Xaml/XamlNode.cs | 4 +- src/Tizen.NUI/src/internal/Xaml/XamlNodeVisitor.cs | 2 + .../src/internal/Xaml/XamlParseException.cs | 19 ++- src/Tizen.NUI/src/internal/Xaml/XamlParser.cs | 2 +- .../src/internal/XamlBinding/Application.cs | 2 +- .../src/internal/XamlBinding/BindableProperty.cs | 13 ++ .../XamlBinding/BindablePropertyConverter.cs | 2 +- src/Tizen.NUI/src/internal/XamlBinding/Binding.cs | 5 +- .../src/internal/XamlBinding/BindingBase.cs | 25 +++- .../internal/XamlBinding/BindingTypeConverter.cs | 2 +- .../src/internal/XamlBinding/ColorTypeConverter.cs | 12 +- src/Tizen.NUI/src/internal/XamlBinding/Device.cs | 2 +- .../internal/XamlBinding/ExtentsTypeConverter.cs | 6 +- .../XamlBinding/Interactivity/BindingCondition.cs | 2 +- .../XamlBinding/Interactivity/DataTrigger.cs | 2 +- .../XamlBinding/Interactivity/PropertyCondition.cs | 112 ++++++++++++++ .../internal/XamlBinding/Interactivity/Trigger.cs | 2 +- .../Interactivity/XamlPropertyCondition.cs | 3 +- .../XamlBinding/Internals/DynamicResource.cs | 1 - .../XamlBinding/Internals/IDataTemplate.cs | 1 - .../XamlBinding/Internals/IDeserializer.cs | 1 - .../Internals/IDynamicResourceHandler.cs | 1 - .../internal/XamlBinding/Internals/INameScope.cs | 1 - .../XamlBinding/Internals/InvalidationTrigger.cs | 1 - .../internal/XamlBinding/Internals/NameScope.cs | 1 - .../XamlBinding/Internals/NumericExtensions.cs | 1 - .../XamlBinding/Internals/PreserveAttribute.cs | 22 +++ .../src/internal/XamlBinding/Internals/Ticker.cs | 1 - .../internal/XamlBinding/Internals/TypedBinding.cs | 2 - src/Tizen.NUI/src/internal/XamlBinding/Layout.cs | 2 +- .../internal/XamlBinding/LayoutOptionsConverter.cs | 2 +- .../XamlBinding/ListStringTypeConverter.cs | 2 +- .../src/internal/XamlBinding/NavigationPage.cs | 7 +- .../internal/XamlBinding/RectangleTypeConverter.cs | 2 +- .../internal/XamlBinding/RotationTypeConverter.cs | 47 ++++-- src/Tizen.NUI/src/internal/XamlBinding/Setter.cs | 2 +- .../src/internal/XamlBinding/SizeTypeConverter.cs | 3 + src/Tizen.NUI/src/internal/XamlBinding/Style.cs | 6 +- .../src/internal/XamlBinding/SynchronizedList.cs | 11 +- .../internal/XamlBinding/ThicknessTypeConverter.cs | 2 +- .../internal/XamlBinding/TizenPlatformServices.cs | 4 +- .../src/internal/XamlBinding/TypeTypeConverter.cs | 2 +- .../src/internal/XamlBinding/UriTypeConverter.cs | 2 +- .../src/public/Xaml/ProvideCompiledAttribute.cs | 15 ++ src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs | 9 +- .../src/public/XamlBinding/BindableObject.cs | 7 +- .../src/public/XamlBinding/ContentPage.cs | 57 +++----- src/Tizen.NUI/src/public/XamlBinding/Element.cs | 11 +- .../src/public/XamlBinding/IResourcesProvider.cs | 1 + .../src/public/XamlBinding/IValueConverter.cs | 1 + .../src/public/XamlBinding/NameScopeExtensions.cs | 23 +++ .../src/public/XamlBinding/ResourceDictionary.cs | 2 +- src/Tizen.NUI/src/public/XamlBinding/Transition.cs | 161 ++++++++++++++------- 70 files changed, 565 insertions(+), 245 deletions(-) create mode 100755 src/Tizen.NUI/src/internal/Xaml/IReferenceProvider.cs create mode 100755 src/Tizen.NUI/src/internal/XamlBinding/Interactivity/PropertyCondition.cs create mode 100755 src/Tizen.NUI/src/internal/XamlBinding/Internals/PreserveAttribute.cs create mode 100755 src/Tizen.NUI/src/public/Xaml/ProvideCompiledAttribute.cs diff --git a/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs index 588f5c7..76451c7 100755 --- a/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs @@ -37,6 +37,7 @@ namespace Tizen.NUI.Xaml public bool StopOnResourceDictionary { get; } public bool VisitNodeOnDataTemplate => true; public bool SkipChildren(INode node, INode parentNode) => false; + public bool IsResourceDictionary(ElementNode node) => typeof(ResourceDictionary).IsAssignableFrom(Context.Types[node]); public void Visit(ValueNode node, INode parentNode) { @@ -281,7 +282,12 @@ namespace Tizen.NUI.Xaml #if NETSTANDARD1_0 var bindableFieldInfo = elementType.GetFields().FirstOrDefault(fi => fi.Name == localName + "Property"); #else - var bindableFieldInfo = elementType.GetFields(BindingFlags.Static | BindingFlags.Public|BindingFlags.FlattenHierarchy).FirstOrDefault(fi => fi.Name == localName + "Property"); + var bindableFieldInfo = elementType.GetFields(BindingFlags.Static | BindingFlags.NonPublic|BindingFlags.FlattenHierarchy).FirstOrDefault(fi => fi.Name == localName + "Property"); + + if (null == bindableFieldInfo) + { + bindableFieldInfo = elementType.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy).FirstOrDefault(fi => fi.Name == localName + "Property"); + } #endif Exception exception = null; if (exception == null && bindableFieldInfo == null) { @@ -323,6 +329,7 @@ namespace Tizen.NUI.Xaml //If it's an attached BP, update elementType and propertyName var bpOwnerType = xamlelement.GetType(); var attached = GetRealNameAndType(ref bpOwnerType, propertyName.NamespaceURI, ref localName, context, lineInfo); + var property = GetBindableProperty(bpOwnerType, localName, lineInfo, false); //If the target is an event, connect diff --git a/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs index bd4c9b3..c4e4c50 100755 --- a/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs @@ -29,6 +29,7 @@ namespace Tizen.NUI.Xaml public bool StopOnResourceDictionary => false; public bool VisitNodeOnDataTemplate => false; public bool SkipChildren(INode node, INode parentNode) => false; + public bool IsResourceDictionary(ElementNode node) => typeof(ResourceDictionary).IsAssignableFrom(Context.Types[node]); public void Visit(ValueNode node, INode parentNode) { diff --git a/src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs index 4332472..308e9e2 100755 --- a/src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/ExpandMarkupsVisitor.cs @@ -33,6 +33,7 @@ namespace Tizen.NUI.Xaml public bool StopOnResourceDictionary => false; public bool VisitNodeOnDataTemplate => true; public bool SkipChildren(INode node, INode parentNode) => false; + public bool IsResourceDictionary(ElementNode node) => false; public void Visit(ValueNode node, INode parentNode) { diff --git a/src/Tizen.NUI/src/internal/Xaml/FillResourceDictionariesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/FillResourceDictionariesVisitor.cs index 07197a2..2be8e7b 100755 --- a/src/Tizen.NUI/src/internal/Xaml/FillResourceDictionariesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/FillResourceDictionariesVisitor.cs @@ -21,6 +21,8 @@ namespace Tizen.NUI.Xaml public bool StopOnResourceDictionary => false; public bool VisitNodeOnDataTemplate => false; + public bool IsResourceDictionary(ElementNode node) => typeof(ResourceDictionary).IsAssignableFrom(Context.Types[node]); + public void Visit(ValueNode node, INode parentNode) { if (!typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)])) @@ -81,6 +83,5 @@ namespace Tizen.NUI.Xaml return true; return false; } - } } \ No newline at end of file diff --git a/src/Tizen.NUI/src/internal/Xaml/IReferenceProvider.cs b/src/Tizen.NUI/src/internal/Xaml/IReferenceProvider.cs new file mode 100755 index 0000000..89cb53f --- /dev/null +++ b/src/Tizen.NUI/src/internal/Xaml/IReferenceProvider.cs @@ -0,0 +1,7 @@ +namespace Tizen.NUI.Xaml +{ + internal interface IReferenceProvider + { + object FindByName(string name); + } +} \ No newline at end of file diff --git a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/BindingExtension.cs b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/BindingExtension.cs index e362dd1..9276783 100755 --- a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/BindingExtension.cs +++ b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/BindingExtension.cs @@ -8,15 +8,8 @@ namespace Tizen.NUI.Xaml [AcceptEmptyServiceProvider] internal sealed class BindingExtension : IMarkupExtension { - public BindingExtension() - { - Mode = BindingMode.Default; - Path = Tizen.NUI.Binding.Binding.SelfPath; - } - - public string Path { get; set; } - - public BindingMode Mode { get; set; } + public string Path { get; set; } = Binding.Binding.SelfPath; + public BindingMode Mode { get; set; } = BindingMode.Default; public IValueConverter Converter { get; set; } @@ -28,12 +21,21 @@ namespace Tizen.NUI.Xaml public string UpdateSourceEventName { get; set; } + public object TargetNullValue { get; set; } + + public object FallbackValue { get; set; } + public TypedBindingBase TypedBinding { get; set; } BindingBase IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) { if (TypedBinding == null) - return new Tizen.NUI.Binding.Binding(Path, Mode, Converter, ConverterParameter, StringFormat, Source) { UpdateSourceEventName = UpdateSourceEventName }; + return new Tizen.NUI.Binding.Binding(Path, Mode, Converter, ConverterParameter, StringFormat, Source) + { + UpdateSourceEventName = UpdateSourceEventName, + FallbackValue = FallbackValue, + TargetNullValue = TargetNullValue, + }; TypedBinding.Mode = Mode; TypedBinding.Converter = Converter; @@ -41,6 +43,8 @@ namespace Tizen.NUI.Xaml TypedBinding.StringFormat = StringFormat; TypedBinding.Source = Source; TypedBinding.UpdateSourceEventName = UpdateSourceEventName; + TypedBinding.FallbackValue = FallbackValue; + TypedBinding.TargetNullValue = TargetNullValue; return TypedBinding; } diff --git a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/NullExtension.cs b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/NullExtension.cs index 091e30e..b5a310c 100755 --- a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/NullExtension.cs +++ b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/NullExtension.cs @@ -2,7 +2,7 @@ namespace Tizen.NUI.Xaml { - // [ProvideCompiled("Tizen.NUI.Build.Tasks.NullExtension")] + [ProvideCompiled("Tizen.NUI.Xaml.Build.Tasks.NullExtension")] [AcceptEmptyServiceProvider] internal class NullExtension : IMarkupExtension { diff --git a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StaticExtension.cs b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StaticExtension.cs index d22e0ed..5a4151d 100755 --- a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StaticExtension.cs +++ b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StaticExtension.cs @@ -7,7 +7,7 @@ using Tizen.NUI.Binding; namespace Tizen.NUI.Xaml { [ContentProperty(nameof(Member))] - // [ProvideCompiled("Tizen.NUI.Build.Tasks.StaticExtension")] + [ProvideCompiled("Tizen.NUI.Xaml.Build.Tasks.StaticExtension")] internal class StaticExtension : IMarkupExtension { public string Member { get; set; } diff --git a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StyleSheetExtension.cs b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StyleSheetExtension.cs index b97485e..2b4c483 100755 --- a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StyleSheetExtension.cs +++ b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StyleSheetExtension.cs @@ -8,7 +8,7 @@ using Tizen.NUI.Binding; namespace Tizen.NUI.Xaml { [ContentProperty(nameof(Style))] - // [ProvideCompiled("Tizen.NUI.Core.XamlC.StyleSheetProvider")] + [ProvideCompiled("Tizen.NUI.Core.XamlC.StyleSheetProvider")] internal sealed class StyleSheetExtension : IValueProvider { public string Style { get; set; } diff --git a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/TypeExtension.cs b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/TypeExtension.cs index bfd3bd5..9bcd36b 100755 --- a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/TypeExtension.cs +++ b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/TypeExtension.cs @@ -4,7 +4,7 @@ using Tizen.NUI.Binding; namespace Tizen.NUI.Xaml { [ContentProperty(nameof(TypeName))] - // [ProvideCompiled("Tizen.NUI.Build.Tasks.TypeExtension")] + [ProvideCompiled("Tizen.NUI.Xaml.Build.Tasks.TypeExtension")] internal class TypeExtension : IMarkupExtension { public string TypeName { get; set; } diff --git a/src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs index 18d8d37..99e0f89 100755 --- a/src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/NamescopingVisitor.cs @@ -19,6 +19,7 @@ namespace Tizen.NUI.Xaml public bool StopOnResourceDictionary => false; public bool VisitNodeOnDataTemplate => true; public bool SkipChildren(INode node, INode parentNode) => false; + public bool IsResourceDictionary(ElementNode node) => false; public void Visit(ValueNode node, INode parentNode) { diff --git a/src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs index f881a2e..8c025e5 100755 --- a/src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/PruneIgnoredNodesVisitor.cs @@ -10,6 +10,7 @@ namespace Tizen.NUI.Xaml public bool StopOnResourceDictionary => false; public bool VisitNodeOnDataTemplate => true; public bool SkipChildren(INode node, INode parentNode) => false; + public bool IsResourceDictionary(ElementNode node) => false; public void Visit(ElementNode node, INode parentNode) { @@ -21,7 +22,7 @@ namespace Tizen.NUI.Xaml continue; if (!propertyName.Equals(XamlParser.McUri, "Ignorable")) continue; - (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List()))?.AddRange(propertyValue.Split(',')); + (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List())).AddRange(propertyValue.Split(',')); } foreach (var propertyKvp in node.Properties.ToList()) diff --git a/src/Tizen.NUI/src/internal/Xaml/ReflectionExtensions.cs b/src/Tizen.NUI/src/internal/Xaml/ReflectionExtensions.cs index c356b05..98e036d 100755 --- a/src/Tizen.NUI/src/internal/Xaml/ReflectionExtensions.cs +++ b/src/Tizen.NUI/src/internal/Xaml/ReflectionExtensions.cs @@ -6,7 +6,6 @@ using System.Reflection; namespace Tizen.NUI.Binding.Internals { - [EditorBrowsable(EditorBrowsableState.Never)] internal static class ReflectionExtensions { public static FieldInfo GetField(this Type type, Func predicate) diff --git a/src/Tizen.NUI/src/internal/Xaml/RegisterXNamesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/RegisterXNamesVisitor.cs index 481493c..8ca6dde 100755 --- a/src/Tizen.NUI/src/internal/Xaml/RegisterXNamesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/RegisterXNamesVisitor.cs @@ -8,16 +8,18 @@ namespace Tizen.NUI.Xaml { public RegisterXNamesVisitor(HydrationContext context) { + Context = context; Values = context.Values; } Dictionary Values { get; } - + HydrationContext Context { get; } public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown; public bool StopOnDataTemplate => true; public bool StopOnResourceDictionary => false; public bool VisitNodeOnDataTemplate => false; public bool SkipChildren(INode node, INode parentNode) => false; + public bool IsResourceDictionary(ElementNode node) => typeof(ResourceDictionary).IsAssignableFrom(Context.Types[node]); public void Visit(ValueNode node, INode parentNode) { diff --git a/src/Tizen.NUI/src/internal/Xaml/TypeConversionExtensions.cs b/src/Tizen.NUI/src/internal/Xaml/TypeConversionExtensions.cs index 153897e..8f46593 100755 --- a/src/Tizen.NUI/src/internal/Xaml/TypeConversionExtensions.cs +++ b/src/Tizen.NUI/src/internal/Xaml/TypeConversionExtensions.cs @@ -100,6 +100,19 @@ namespace Tizen.NUI.Xaml return value.ConvertTo(toType, getConverter, serviceProvider); } + private delegate void ParseValueFunc(string s, IFormatProvider provider); + + static private Dictionary typeToParseValueFunc = null; + + static private void BuildParseValueFunc() + { + if (null == typeToParseValueFunc) + { + typeToParseValueFunc = new Dictionary(); + + } + } + internal static object ConvertTo(this object value, Type toType, Func getConverter, IServiceProvider serviceProvider) { @@ -111,20 +124,24 @@ namespace Tizen.NUI.Xaml { //If there's a [TypeConverter], use it object converter = getConverter?.Invoke(); - var xfTypeConverter = converter as TypeConverter; - var xfExtendedTypeConverter = xfTypeConverter as IExtendedTypeConverter; - if (xfExtendedTypeConverter != null) - return value = xfExtendedTypeConverter.ConvertFromInvariantString(str, serviceProvider); - if (xfTypeConverter != null) - return value = xfTypeConverter.ConvertFromInvariantString(str); - var converterType = converter?.GetType(); - if (converterType != null) + if (null != converter) { - var convertFromStringInvariant = converterType.GetRuntimeMethod("ConvertFromInvariantString", - new[] { typeof (string) }); - if (convertFromStringInvariant != null) - return value = convertFromStringInvariant.Invoke(converter, new object[] { str }); + var xfTypeConverter = converter as TypeConverter; + var xfExtendedTypeConverter = xfTypeConverter as IExtendedTypeConverter; + if (xfExtendedTypeConverter != null) + return value = xfExtendedTypeConverter.ConvertFromInvariantString(str, serviceProvider); + if (xfTypeConverter != null) + return value = xfTypeConverter.ConvertFromInvariantString(str); + var converterType = converter?.GetType(); + if (converterType != null) + { + var convertFromStringInvariant = converterType.GetRuntimeMethod("ConvertFromInvariantString", + new[] { typeof(string) }); + if (convertFromStringInvariant != null) + return value = convertFromStringInvariant.Invoke(converter, new object[] { str }); + } } + var ignoreCase = (serviceProvider?.GetService(typeof(IConverterOptions)) as IConverterOptions)?.IgnoreCase ?? false; //If the type is nullable, as the value is not null, it's safe to assume we want the built-in conversion @@ -134,6 +151,7 @@ namespace Tizen.NUI.Xaml //Obvious Built-in conversions if (toType.GetTypeInfo().IsEnum) return Enum.Parse(toType, str, ignoreCase); + if (toType == typeof(SByte)) return SByte.Parse(str, CultureInfo.InvariantCulture); if (toType == typeof(Int16)) diff --git a/src/Tizen.NUI/src/internal/Xaml/ValueConverterProvider.cs b/src/Tizen.NUI/src/internal/Xaml/ValueConverterProvider.cs index d4b5e61..1b8a56c 100755 --- a/src/Tizen.NUI/src/internal/Xaml/ValueConverterProvider.cs +++ b/src/Tizen.NUI/src/internal/Xaml/ValueConverterProvider.cs @@ -4,7 +4,6 @@ using System.Reflection; using Tizen.NUI; using Tizen.NUI.Xaml; -// [assembly:Dependency(typeof(ValueConverterProvider))] namespace Tizen.NUI.Xaml { internal class ValueConverterProvider : IValueConverterProvider diff --git a/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs b/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs index 502be8b..758a45f 100755 --- a/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs +++ b/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs @@ -27,11 +27,13 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Text.RegularExpressions; using System.Xml; +using Tizen.NUI.BaseComponents; using Tizen.NUI.Binding; using Tizen.NUI.Binding.Internals; @@ -58,60 +60,34 @@ namespace Tizen.NUI.Xaml.Internals namespace Tizen.NUI.Xaml { - static class XamlLoader + static internal class XamlLoader { public static void Load(object view, Type callingType) { - var xaml = GetXamlForType(callingType); - if (string.IsNullOrEmpty(xaml)) - throw new XamlParseException(string.Format("No embeddedresource found for {0}", callingType), new XmlLineInfo()); - Console.WriteLine("============= Got xaml text is {0} ===========", xaml); - Load(view, xaml); - } - - public static Transition LoadTransition(string animationXamlPath) - { - var xaml = GetAnimationXaml(animationXamlPath); - if (string.IsNullOrEmpty(xaml)) - throw new XamlParseException(string.Format("No embeddedresource found for {0}", animationXamlPath), new XmlLineInfo()); - Transition animation = new Transition(); - using (var textReader = new StringReader(xaml)) - using (var reader = XmlReader.Create(textReader)) + try { - while (reader.Read()) - { - //Skip until element - if (reader.NodeType == XmlNodeType.Whitespace) - continue; - if (reader.NodeType == XmlNodeType.XmlDeclaration) - continue; - if (reader.NodeType != XmlNodeType.Element) - { - Debug.WriteLine("Unhandled node {0} {1} {2}", reader.NodeType, reader.Name, reader.Value); - continue; - } - - var rootnode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), animation, (IXmlNamespaceResolver)reader); - XamlParser.ParseXaml(rootnode, reader); - Visit(rootnode, new HydrationContext - { - RootElement = animation, -#pragma warning disable 0618 - ExceptionHandler = ResourceLoader.ExceptionHandler ?? (Internals.XamlLoader.DoNotThrowOnExceptions ? e => { } : (Action)null) -#pragma warning restore 0618 - }); - break; - } + var xaml = GetXamlForType(callingType); + if (string.IsNullOrEmpty(xaml)) + throw new XamlParseException(string.Format("Can't get xaml from type {0}", callingType), new XmlLineInfo()); + Load(view, xaml); + } + catch (XamlParseException e) + { + Tizen.Log.Fatal("NUI", "XamlParseException e.Message: " + e.Message); + Console.WriteLine("\n[FATAL] XamlParseException e.Message: {0}\n", e.Message); } - return animation; } - public static Animation LoadAnimation(string animationXamlPath) + public static T LoadObject(string path) { - var xaml = GetAnimationXaml(animationXamlPath); + var xaml = GetAnimationXaml(path); if (string.IsNullOrEmpty(xaml)) - throw new XamlParseException(string.Format("No embeddedresource found for {0}", animationXamlPath), new XmlLineInfo()); - Animation animation = new Animation(); + throw new XamlParseException(string.Format("No embeddedresource found for {0}", path), new XmlLineInfo()); + Type type = typeof(T); + T ret = (T)type.Assembly.CreateInstance(type.FullName); + + NameScopeExtensions.PushElement(ret); + using (var textReader = new StringReader(xaml)) using (var reader = XmlReader.Create(textReader)) { @@ -128,11 +104,11 @@ namespace Tizen.NUI.Xaml continue; } - var rootnode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), animation, (IXmlNamespaceResolver)reader); + var rootnode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), ret, (IXmlNamespaceResolver)reader); XamlParser.ParseXaml(rootnode, reader); Visit(rootnode, new HydrationContext { - RootElement = animation, + RootElement = ret, #pragma warning disable 0618 ExceptionHandler = ResourceLoader.ExceptionHandler ?? (Internals.XamlLoader.DoNotThrowOnExceptions ? e => { } : (Action)null) #pragma warning restore 0618 @@ -140,7 +116,9 @@ namespace Tizen.NUI.Xaml break; } } - return animation; + + NameScopeExtensions.PopElement(); + return ret; } public static void Load(object view, string xaml) diff --git a/src/Tizen.NUI/src/internal/Xaml/XamlNode.cs b/src/Tizen.NUI/src/internal/Xaml/XamlNode.cs index ea38a72..44a7df8 100755 --- a/src/Tizen.NUI/src/internal/Xaml/XamlNode.cs +++ b/src/Tizen.NUI/src/internal/Xaml/XamlNode.cs @@ -164,11 +164,9 @@ namespace Tizen.NUI.Xaml return false; } - bool IsResourceDictionary() => XmlType.Name == "ResourceDictionary"; - protected bool SkipChildren(IXamlNodeVisitor visitor, INode node, INode parentNode) => (visitor.StopOnDataTemplate && IsDataTemplate(parentNode)) - || (visitor.StopOnResourceDictionary && IsResourceDictionary()) + || (visitor.StopOnResourceDictionary && visitor.IsResourceDictionary(this)) || visitor.SkipChildren(node, parentNode); protected bool SkipVisitNode(IXamlNodeVisitor visitor, INode parentNode) => diff --git a/src/Tizen.NUI/src/internal/Xaml/XamlNodeVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/XamlNodeVisitor.cs index f1254bc..6868780 100755 --- a/src/Tizen.NUI/src/internal/Xaml/XamlNodeVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/XamlNodeVisitor.cs @@ -15,6 +15,7 @@ namespace Tizen.NUI.Xaml void Visit(RootNode node, INode parentNode); void Visit(ListNode node, INode parentNode); bool SkipChildren(INode node, INode parentNode); + bool IsResourceDictionary(ElementNode node); } internal enum TreeVisitingMode { @@ -45,5 +46,6 @@ namespace Tizen.NUI.Xaml public void Visit(RootNode node, INode parentNode) => action(node, parentNode); public void Visit(ListNode node, INode parentNode) => action(node, parentNode); public bool SkipChildren(INode node, INode parentNode) => false; + public bool IsResourceDictionary(ElementNode node) => false; } } \ No newline at end of file diff --git a/src/Tizen.NUI/src/internal/Xaml/XamlParseException.cs b/src/Tizen.NUI/src/internal/Xaml/XamlParseException.cs index 055c1a5..27a5841 100755 --- a/src/Tizen.NUI/src/internal/Xaml/XamlParseException.cs +++ b/src/Tizen.NUI/src/internal/Xaml/XamlParseException.cs @@ -1,4 +1,6 @@ using System; +using System.Diagnostics; +using System.Text; using System.Xml; namespace Tizen.NUI.Xaml @@ -7,7 +9,22 @@ namespace Tizen.NUI.Xaml { readonly string _unformattedMessage; - public XamlParseException(string message, IXmlLineInfo xmlInfo, Exception innerException = null) : base(FormatMessage(message, xmlInfo), innerException) + static private StringBuilder GetStackInfo() + { + StringBuilder ret = new StringBuilder("\nStack:\n"); + + StackTrace st = new StackTrace(); + + for (int i = 2; i < st.FrameCount; i++) + { + StackFrame sf = st.GetFrame(i); + ret.AppendFormat("File:{0}, Method:{1}, Line:{2}\n", sf.GetFileName(), sf.GetMethod().Name, sf.GetFileLineNumber()); + } + + return ret; + } + + public XamlParseException(string message, IXmlLineInfo xmlInfo, Exception innerException = null) : base(FormatMessage(message + GetStackInfo(), xmlInfo), innerException) { _unformattedMessage = message; XmlInfo = xmlInfo; diff --git a/src/Tizen.NUI/src/internal/Xaml/XamlParser.cs b/src/Tizen.NUI/src/internal/Xaml/XamlParser.cs index 63f30da..c2707dd 100755 --- a/src/Tizen.NUI/src/internal/Xaml/XamlParser.cs +++ b/src/Tizen.NUI/src/internal/Xaml/XamlParser.cs @@ -40,7 +40,7 @@ namespace Tizen.NUI.Xaml { internal static class XamlParser { - public const string XFUri = "http://xamarin.com/schemas/2014/forms"; + public const string XFUri = "http://tizen.org/Tizen.NUI/2018/XAML"; public const string NUI2018Uri = "http://tizen.org/Tizen.NUI/2018/XAML"; public const string X2006Uri = "http://schemas.microsoft.com/winfx/2006/xaml"; public const string X2009Uri = "http://schemas.microsoft.com/winfx/2009/xaml"; diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Application.cs b/src/Tizen.NUI/src/internal/XamlBinding/Application.cs index cbfefcc..1461a00 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Application.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Application.cs @@ -47,7 +47,7 @@ namespace Tizen.NUI.Binding if (_appIndexProvider == null) throw new ArgumentException("No IAppIndexingProvider was provided"); if (_appIndexProvider.AppLinks == null) - throw new ArgumentException("No AppLinks implementation was found, if in Android make sure you installed the Xamarin.Forms.AppLinks"); + throw new ArgumentException("No AppLinks implementation was found, if in Android make sure you installed the Tizen.NUI.Binding.AppLinks"); return _appIndexProvider.AppLinks; } } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/BindableProperty.cs b/src/Tizen.NUI/src/internal/XamlBinding/BindableProperty.cs index 48fb4bf..8f4c1f3 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/BindableProperty.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/BindableProperty.cs @@ -105,6 +105,19 @@ namespace Tizen.NUI.Binding { { typeof(Uri), new UriTypeConverter() }, { typeof(Color), new ColorTypeConverter() }, + { typeof(Size2D), new Size2DTypeConverter() }, + { typeof(Position2D), new Position2DTypeConverter() }, + { typeof(Size), new SizeTypeConverter() }, + { typeof(Position), new PositionTypeConverter() }, + { typeof(Rectangle), new RectangleTypeConverter() }, + { typeof(Rotation), new RotationTypeConverter() }, + { typeof(Thickness), new ThicknessTypeConverter() }, + { typeof(Vector2), new Vector2TypeConverter() }, + { typeof(Vector3), new Vector3TypeConverter() }, + { typeof(Vector4), new Vector4TypeConverter() }, + { typeof(RelativeVector2), new RelativeVector2TypeConverter() }, + { typeof(RelativeVector3), new RelativeVector3TypeConverter() }, + { typeof(RelativeVector4), new RelativeVector4TypeConverter() }, }; // more or less the encoding of this, without the need to reflect diff --git a/src/Tizen.NUI/src/internal/XamlBinding/BindablePropertyConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/BindablePropertyConverter.cs index 9f99006..ea258e6 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/BindablePropertyConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/BindablePropertyConverter.cs @@ -10,7 +10,7 @@ using Tizen.NUI.Xaml; namespace Tizen.NUI.Binding { - // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.BindablePropertyConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.BindablePropertyConverter")] [Xaml.TypeConversion(typeof(BindableProperty))] internal sealed class BindablePropertyConverter : TypeConverter, IExtendedTypeConverter { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Binding.cs b/src/Tizen.NUI/src/internal/XamlBinding/Binding.cs index 6debd8c..bbbd9d9 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Binding.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Binding.cs @@ -100,9 +100,8 @@ namespace Tizen.NUI.Binding if (propertyGetter == null) throw new ArgumentNullException("propertyGetter"); - string path = GetBindingPath(propertyGetter); - return new Binding(path, mode, converter, converterParameter, stringFormat); - } + return new Binding(GetBindingPath(propertyGetter), mode, converter, converterParameter, stringFormat); + } internal override void Apply(bool fromTarget) { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/BindingBase.cs b/src/Tizen.NUI/src/internal/XamlBinding/BindingBase.cs index 8ea280d..93a2355 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/BindingBase.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/BindingBase.cs @@ -15,6 +15,8 @@ namespace Tizen.NUI.Binding BindingMode _mode = BindingMode.Default; string _stringFormat; + object _targetNullValue; + object _fallbackValue; internal BindingBase() { @@ -55,7 +57,24 @@ namespace Tizen.NUI.Binding } } - internal bool AllowChaining { get; set; } + public object TargetNullValue + { + get { return _targetNullValue; } + set { + ThrowIfApplied(); + _targetNullValue = value; + } + } + + public object FallbackValue { + get => _fallbackValue; + set { + ThrowIfApplied(); + _fallbackValue = value; + } + } + + internal bool AllowChaining { get; set; } internal object Context { get; set; } @@ -73,7 +92,7 @@ namespace Tizen.NUI.Binding SynchronizedCollections.Remove(collection); } - internal static void EnableCollectionSynchronization(IEnumerable collection, object context, CollectionSynchronizationCallback callback) + public static void EnableCollectionSynchronization(IEnumerable collection, object context, CollectionSynchronizationCallback callback) { if (collection == null) throw new ArgumentNullException(nameof(collection)); @@ -106,6 +125,8 @@ namespace Tizen.NUI.Binding internal virtual object GetSourceValue(object value, Type targetPropertyType) { + if (value == null && TargetNullValue != null) + return TargetNullValue; if (StringFormat != null) return string.Format(StringFormat, value); diff --git a/src/Tizen.NUI/src/internal/XamlBinding/BindingTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/BindingTypeConverter.cs index 014640f..62839e2 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/BindingTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/BindingTypeConverter.cs @@ -1,6 +1,6 @@ namespace Tizen.NUI.Binding { - // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.BindingTypeConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.BindingTypeConverter")] [Xaml.TypeConversion(typeof(Binding))] internal sealed class BindingTypeConverter : TypeConverter { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/ColorTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/ColorTypeConverter.cs index 494218c..51cb273 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/ColorTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/ColorTypeConverter.cs @@ -1,12 +1,9 @@ using System; -using System.Linq; -using System.Reflection; - -using Tizen.NUI; +using System.Globalization; namespace Tizen.NUI.Binding { - // [Xaml.ProvideCompiled("Tizen.NUI.XamlC.ColorTypeConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.ColorTypeConverter")] [Xaml.TypeConversion(typeof(Color))] internal class ColorTypeConverter : TypeConverter { @@ -47,7 +44,10 @@ namespace Tizen.NUI.Binding } else if (parts.Length == 4) //like 0.5,0.5,0.5,0.5 { - return new Color(float.Parse(parts[0].Trim()), float.Parse(parts[1].Trim()), float.Parse(parts[2].Trim()), float.Parse(parts[3].Trim())); + return new Color(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture), + Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture), + Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture), + Single.Parse(parts[3].Trim(), CultureInfo.InvariantCulture)); } } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Device.cs b/src/Tizen.NUI/src/internal/XamlBinding/Device.cs index c223287..8987212 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Device.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Device.cs @@ -61,7 +61,7 @@ namespace Tizen.NUI.Binding get { // if (info == null) - // throw new InvalidOperationException("You MUST call Xamarin.Forms.Init(); prior to using it."); + // throw new InvalidOperationException("You MUST call Tizen.NUI.Xaml.Init(); prior to using it."); return info; } set { info = value; } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/ExtentsTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/ExtentsTypeConverter.cs index 5903c02..cd95113 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/ExtentsTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/ExtentsTypeConverter.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Linq; using System.Reflection; @@ -15,7 +16,10 @@ namespace Tizen.NUI.Binding string[] parts = value.Split(','); if (parts.Length == 4) { - return new Extents(ushort.Parse(parts[0].Trim()), ushort.Parse(parts[1].Trim()), ushort.Parse(parts[2].Trim()), ushort.Parse(parts[3].Trim())); + return new Extents(ushort.Parse(parts[0].Trim(), CultureInfo.InvariantCulture), + ushort.Parse(parts[1].Trim(), CultureInfo.InvariantCulture), + ushort.Parse(parts[2].Trim(), CultureInfo.InvariantCulture), + ushort.Parse(parts[3].Trim(), CultureInfo.InvariantCulture)); } } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/BindingCondition.cs b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/BindingCondition.cs index 738addf..63f0319 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/BindingCondition.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/BindingCondition.cs @@ -3,7 +3,7 @@ using Tizen.NUI.Xaml; namespace Tizen.NUI.Binding { - // [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")] + [ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.PassthroughValueProvider")] [AcceptEmptyServiceProvider] internal sealed class BindingCondition : Condition, IValueProvider { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/DataTrigger.cs b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/DataTrigger.cs index 9bc0266..96e8815 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/DataTrigger.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/DataTrigger.cs @@ -5,7 +5,7 @@ using Tizen.NUI.Xaml; namespace Tizen.NUI.Binding { [ContentProperty("Setters")] - // [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")] + [ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.PassthroughValueProvider")] [AcceptEmptyServiceProvider] internal sealed class DataTrigger : TriggerBase, IValueProvider { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/PropertyCondition.cs b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/PropertyCondition.cs new file mode 100755 index 0000000..54bc675 --- /dev/null +++ b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/PropertyCondition.cs @@ -0,0 +1,112 @@ +using System; +using System.ComponentModel; +using System.Reflection; +using Tizen.NUI.Binding; + +namespace Tizen.NUI.Xaml +{ + [ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.PassthroughValueProvider")] + [AcceptEmptyServiceProvider] + internal sealed class PropertyCondition : Condition, IValueProvider + { + readonly BindableProperty _stateProperty; + + BindableProperty _property; + object _triggerValue; + + public PropertyCondition() + { + _stateProperty = BindableProperty.CreateAttached("State", typeof(bool), typeof(PropertyCondition), false, propertyChanged: OnStatePropertyChanged); + } + + public BindableProperty Property + { + get { return _property; } + set + { + if (_property == value) + return; + if (IsSealed) + throw new InvalidOperationException("Can not change Property once the Trigger has been applied."); + _property = value; + + //convert the value + if (_property != null && s_valueConverter != null) + { + Func minforetriever = () => Property.DeclaringType.GetRuntimeProperty(Property.PropertyName); + Value = s_valueConverter.Convert(Value, Property.ReturnType, minforetriever, null); + } + } + } + + public object Value + { + get { return _triggerValue; } + set + { + if (_triggerValue == value) + return; + if (IsSealed) + throw new InvalidOperationException("Can not change Value once the Trigger has been applied."); + + //convert the value + if (_property != null && s_valueConverter != null) + { + Func minforetriever = () => Property.DeclaringType.GetRuntimeProperty(Property.PropertyName); + value = s_valueConverter.Convert(value, Property.ReturnType, minforetriever, null); + } + _triggerValue = value; + } + } + + object IValueProvider.ProvideValue(IServiceProvider serviceProvider) + { + //This is no longer required + return this; + } + + internal override bool GetState(BindableObject bindable) + { + return (bool)bindable.GetValue(_stateProperty); + } + + static IValueConverterProvider s_valueConverter = DependencyService.Get(); + + internal override void SetUp(BindableObject bindable) + { + object newvalue = bindable.GetValue(Property); + bool newState = (newvalue == Value) || (newvalue != null && newvalue.Equals(Value)); + bindable.SetValue(_stateProperty, newState); + bindable.PropertyChanged += OnAttachedObjectPropertyChanged; + } + + internal override void TearDown(BindableObject bindable) + { + bindable.ClearValue(_stateProperty); + bindable.PropertyChanged -= OnAttachedObjectPropertyChanged; + } + + void OnAttachedObjectPropertyChanged(object sender, PropertyChangedEventArgs e) + { + var bindable = (BindableObject)sender; + var oldState = (bool)bindable.GetValue(_stateProperty); + + if (Property == null) + return; + if (e.PropertyName != Property.PropertyName) + return; + object newvalue = bindable.GetValue(Property); + bool newstate = (newvalue == Value) || (newvalue != null && newvalue.Equals(Value)); + if (oldState != newstate) + bindable.SetValue(_stateProperty, newstate); + } + + void OnStatePropertyChanged(BindableObject bindable, object oldValue, object newValue) + { + if ((bool)oldValue == (bool)newValue) + return; + + ConditionChanged?.Invoke(bindable, (bool)oldValue, (bool)newValue); + } + } +} \ No newline at end of file diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/Trigger.cs b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/Trigger.cs index 6a41249..28fd944 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/Trigger.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/Trigger.cs @@ -7,7 +7,7 @@ using Tizen.NUI.Xaml; namespace Tizen.NUI.Binding { [ContentProperty("Setters")] - // [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")] + [ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.PassthroughValueProvider")] [AcceptEmptyServiceProvider] internal sealed class Trigger : TriggerBase, IValueProvider { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/XamlPropertyCondition.cs b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/XamlPropertyCondition.cs index 1f83d18..b17ac58 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/XamlPropertyCondition.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Interactivity/XamlPropertyCondition.cs @@ -5,7 +5,7 @@ using Tizen.NUI.Xaml; namespace Tizen.NUI.Binding { - // [ProvideCompiled("Tizen.NUI.Core.XamlC.PassthroughValueProvider")] + [ProvideCompiled("Tizen.NUI.Core.XamlC.PassthroughValueProvider")] [AcceptEmptyServiceProvider] internal sealed class XamlPropertyCondition : Condition, IValueProvider { @@ -28,7 +28,6 @@ namespace Tizen.NUI.Binding return; if (IsSealed) throw new InvalidOperationException("Can not change Property once the Trigger has been applied."); - _property = value; //convert the value diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/DynamicResource.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/DynamicResource.cs index 67c6ff7..30545a8 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/DynamicResource.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/DynamicResource.cs @@ -2,7 +2,6 @@ using System.ComponentModel; namespace Tizen.NUI.Binding.Internals { - [EditorBrowsable(EditorBrowsableState.Never)] internal class DynamicResource { public DynamicResource(string key) diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDataTemplate.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDataTemplate.cs index 727cd98..676ec7a 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDataTemplate.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDataTemplate.cs @@ -3,7 +3,6 @@ using System.ComponentModel; namespace Tizen.NUI.Binding.Internals { - [EditorBrowsable(EditorBrowsableState.Never)] internal interface IDataTemplate { Func LoadTemplate { get; set; } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDeserializer.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDeserializer.cs index 21bc94d..8c6c63d 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDeserializer.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDeserializer.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; namespace Tizen.NUI.Binding.Internals { - [EditorBrowsable(EditorBrowsableState.Never)] internal interface IDeserializer { Task> DeserializePropertiesAsync(); diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDynamicResourceHandler.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDynamicResourceHandler.cs index cef4d8c..62d53a2 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDynamicResourceHandler.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/IDynamicResourceHandler.cs @@ -3,7 +3,6 @@ using Tizen.NUI.Binding; namespace Tizen.NUI.Binding.Internals { - [EditorBrowsable(EditorBrowsableState.Never)] internal interface IDynamicResourceHandler { void SetDynamicResource(BindableProperty property, string key); diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/INameScope.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/INameScope.cs index 6da4b4c..c9b6ba8 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/INameScope.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/INameScope.cs @@ -4,7 +4,6 @@ using System.Xml; namespace Tizen.NUI.Binding.Internals { - [EditorBrowsable(EditorBrowsableState.Never)] internal interface INameScope { object FindByName(string name); diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/InvalidationTrigger.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/InvalidationTrigger.cs index 78e0d8b..1e09321 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/InvalidationTrigger.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/InvalidationTrigger.cs @@ -4,7 +4,6 @@ using System.ComponentModel; namespace Tizen.NUI.Binding.Internals { [Flags] - [EditorBrowsable(EditorBrowsableState.Never)] internal enum InvalidationTrigger { Undefined = 0, diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/NameScope.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/NameScope.cs index 9eee776..13b4bfa 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/NameScope.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/NameScope.cs @@ -7,7 +7,6 @@ using Tizen.NUI.Xaml; namespace Tizen.NUI.Binding.Internals { - [EditorBrowsable(EditorBrowsableState.Never)] internal class NameScope : INameScope { public static readonly BindableProperty NameScopeProperty = BindableProperty.CreateAttached("NameScope", typeof(INameScope), typeof(NameScope), default(INameScope)); diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/NumericExtensions.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/NumericExtensions.cs index 1c6342c..995554a 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/NumericExtensions.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/NumericExtensions.cs @@ -3,7 +3,6 @@ using System.ComponentModel; namespace Tizen.NUI.Binding.Internals { - [EditorBrowsable(EditorBrowsableState.Never)] internal static class NumericExtensions { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/PreserveAttribute.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/PreserveAttribute.cs new file mode 100755 index 0000000..08aa02a --- /dev/null +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/PreserveAttribute.cs @@ -0,0 +1,22 @@ +using System; +using System.ComponentModel; + +namespace Tizen.NUI.Binding.Internals +{ + [AttributeUsage(AttributeTargets.All)] + internal class PreserveAttribute : Attribute + { + public bool AllMembers; + public bool Conditional; + + public PreserveAttribute(bool allMembers, bool conditional) + { + AllMembers = allMembers; + Conditional = conditional; + } + + public PreserveAttribute() + { + } + } +} \ No newline at end of file diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/Ticker.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/Ticker.cs index 3b21a99..7b00bb9 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/Ticker.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/Ticker.cs @@ -7,7 +7,6 @@ using Tizen.NUI.Binding; namespace Tizen.NUI.Binding.Internals { - [EditorBrowsable(EditorBrowsableState.Never)] internal abstract class Ticker { static Ticker s_ticker; diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Internals/TypedBinding.cs b/src/Tizen.NUI/src/internal/XamlBinding/Internals/TypedBinding.cs index 69b35c9..ed30914 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Internals/TypedBinding.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Internals/TypedBinding.cs @@ -9,7 +9,6 @@ using Tizen.NUI.Binding; namespace Tizen.NUI.Binding.Internals { //FIXME: need a better name for this, and share with Binding, so we can share more unittests - [EditorBrowsable(EditorBrowsableState.Never)] internal abstract class TypedBindingBase : BindingBase { IValueConverter _converter; @@ -54,7 +53,6 @@ namespace Tizen.NUI.Binding.Internals } } - [EditorBrowsable(EditorBrowsableState.Never)] internal sealed class TypedBinding : TypedBindingBase { readonly Func _getter; diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Layout.cs b/src/Tizen.NUI/src/internal/XamlBinding/Layout.cs index d7c12a8..f3a0071 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Layout.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Layout.cs @@ -58,7 +58,7 @@ namespace Tizen.NUI.Binding public static readonly BindableProperty CascadeInputTransparentProperty = BindableProperty.Create( nameof(CascadeInputTransparent), typeof(bool), typeof(Layout), true); - public new static readonly BindableProperty PaddingProperty = PaddingElement.PaddingProperty; + public static new readonly BindableProperty PaddingProperty = PaddingElement.PaddingProperty; static IList> s_resolutionList = new List>(); static bool s_relayoutInProgress; diff --git a/src/Tizen.NUI/src/internal/XamlBinding/LayoutOptionsConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/LayoutOptionsConverter.cs index e486931..98cddaa 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/LayoutOptionsConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/LayoutOptionsConverter.cs @@ -7,7 +7,7 @@ using Tizen.NUI; namespace Tizen.NUI.Binding { - // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.LayoutOptionsConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.LayoutOptionsConverter")] [Xaml.TypeConversion(typeof(LayoutOptions))] internal sealed class LayoutOptionsConverter : TypeConverter { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/ListStringTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/ListStringTypeConverter.cs index 8960553..e7327c3 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/ListStringTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/ListStringTypeConverter.cs @@ -4,7 +4,7 @@ using System.Linq; namespace Tizen.NUI.Binding { - // [Xaml.ProvideCompiled("Tizen.NUI.Core.XamlC.ListStringTypeConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Core.XamlC.ListStringTypeConverter")] [Xaml.TypeConversion(typeof(List))] internal class ListStringTypeConverter : TypeConverter { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/NavigationPage.cs b/src/Tizen.NUI/src/internal/XamlBinding/NavigationPage.cs index 887f0d9..eef0cb8 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/NavigationPage.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/NavigationPage.cs @@ -172,7 +172,7 @@ namespace Tizen.NUI /// The title of the back button for the specified page. /// /// The Page whose back-button's title is being requested. - /// The title of the back button that would be shown if the specified page were the Xamarin.Forms.CurrentPage. + /// The title of the back button that would be shown if the specified page were the Tizen.NUI.Xaml.CurrentPage. public static string GetBackButtonTitle(BindableObject page) { return (string)page.GetValue(BackButtonTitleProperty); @@ -242,6 +242,11 @@ namespace Tizen.NUI public event EventHandler Popped; /// + /// Event that is raised when the last nonroot element is popped from this NavigationPage element. + /// + public event EventHandler PoppedToRoot; + + /// /// Pops all but the root Page off the navigation stack. /// /// A task that represents the asynchronous dismiss operation. diff --git a/src/Tizen.NUI/src/internal/XamlBinding/RectangleTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/RectangleTypeConverter.cs index 9bbbfd9..9bdaef6 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/RectangleTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/RectangleTypeConverter.cs @@ -5,7 +5,7 @@ using Tizen.NUI; namespace Tizen.NUI.Binding { - // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.RectangleTypeConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.RectangleTypeConverter")] [Xaml.TypeConversion(typeof(Rectangle))] internal class RectangleTypeConverter : TypeConverter { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/RotationTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/RotationTypeConverter.cs index dc28713..4f48d72 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/RotationTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/RotationTypeConverter.cs @@ -1,8 +1,5 @@ using System; -using System.Linq; -using System.Reflection; - -using Tizen.NUI; +using System.Globalization; namespace Tizen.NUI.Binding { @@ -10,16 +7,48 @@ namespace Tizen.NUI.Binding { public override object ConvertFromInvariantString(string value) { + /// public Rotation(Radian radian(float), Vector3 vector3) + /// Default: + /// Oritation="D:23, 0, 0, 1" + /// Oritation="R:23, 0, 0, 1" if (value != null) { string[] parts = value.Split(','); if (parts.Length == 4) { - Radian radian = new Radian(float.Parse(parts[0].Trim())); - Vector3 vector3 = new Vector3( float.Parse(parts[1].Trim()), float.Parse(parts[2].Trim()), float.Parse(parts[3].Trim()) ); - //Ex: - // public Rotation(Radian radian(float), Vector3 vector3) - return new Rotation( radian, vector3 ); + bool useDefault = true; + Radian radian = null; + string[] head = parts[0].Trim().Split(':'); + if (head.Length == 2) + { + useDefault = false; + string radianOrDegree = head[0].Trim().ToLowerInvariant(); + if(radianOrDegree == "d" || radianOrDegree == "degree") + { + /// Oritation="D:23, 0, 0, 1" + radian = new Radian( new Degree( Single.Parse( head[1].Trim(), CultureInfo.InvariantCulture ) ) ); + } + else if (radianOrDegree == "r" || radianOrDegree == "radian") + { + /// Oritation="R:23, 0, 0, 1" + radian = new Radian( Single.Parse( head[1].Trim(), CultureInfo.InvariantCulture ) ); + } + else + { + throw new InvalidOperationException($"Cannot convert the first parameter \"{value}\" into Radian of {typeof(Rotation)}"); + } + } + + if (useDefault) + { + ///Default: + radian = new Radian( Single.Parse( parts[0].Trim(), CultureInfo.InvariantCulture ) ); + } + + Vector3 vector3 = new Vector3(Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture), + Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture), + Single.Parse(parts[3].Trim(), CultureInfo.InvariantCulture)); + return new Rotation(radian, vector3); } } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Setter.cs b/src/Tizen.NUI/src/internal/XamlBinding/Setter.cs index 2902186..7e0bb79 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Setter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Setter.cs @@ -9,7 +9,7 @@ using Tizen.NUI.Xaml; namespace Tizen.NUI.Binding { [ContentProperty("Value")] - // [ProvideCompiled("Tizen.NUI.Core.XamlC.SetterValueProvider")] + [ProvideCompiled("Tizen.NUI.Core.XamlC.SetterValueProvider")] internal sealed class Setter : IValueProvider { readonly ConditionalWeakTable _originalValues = new ConditionalWeakTable(); diff --git a/src/Tizen.NUI/src/internal/XamlBinding/SizeTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/SizeTypeConverter.cs index 1b54bb5..2a2d06c 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/SizeTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/SizeTypeConverter.cs @@ -4,9 +4,11 @@ using System.Reflection; using System.Globalization; using Tizen.NUI; +using Tizen.NUI.Xaml; namespace Tizen.NUI.Binding { + [ProvideCompiledAttribute("Tizen.NUI.Xaml.Core.XamlC.Size2DTypeConverter")] internal class SizeTypeConverter : TypeConverter { public override object ConvertFromInvariantString(string value) @@ -26,6 +28,7 @@ namespace Tizen.NUI.Binding } } + [ProvideCompiledAttribute("Tizen.NUI.Xaml.Core.XamlC.Size2DTypeConverter")] internal class Size2DTypeConverter : TypeConverter { public override object ConvertFromInvariantString(string value) diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Style.cs b/src/Tizen.NUI/src/internal/XamlBinding/Style.cs index 305d9f7..a571964 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Style.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Style.cs @@ -8,7 +8,7 @@ namespace Tizen.NUI.Binding [ContentProperty("Setters")] internal sealed class Style : IStyle { - internal const string StyleClassPrefix = "Xamarin.Forms.StyleClass."; + internal const string StyleClassPrefix = "Tizen.NUI.Binding.StyleClass."; readonly BindableProperty _basedOnResourceProperty = BindableProperty.CreateAttached("BasedOnResource", typeof(Style), typeof(Style), default(Style), propertyChanged: OnBasedOnResourceChanged); @@ -74,7 +74,7 @@ namespace Tizen.NUI.Binding } } - public IList Behaviors + internal IList Behaviors { get { return _behaviors ?? (_behaviors = new AttachedCollection()); } } @@ -85,7 +85,7 @@ namespace Tizen.NUI.Binding public IList Setters { get; } - public IList Triggers + internal IList Triggers { get { return _triggers ?? (_triggers = new AttachedCollection()); } } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/SynchronizedList.cs b/src/Tizen.NUI/src/internal/XamlBinding/SynchronizedList.cs index a0761b4..54f6648 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/SynchronizedList.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/SynchronizedList.cs @@ -75,15 +75,14 @@ namespace Tizen.NUI.Binding public IEnumerator GetEnumerator() { - lock (_list) + ReadOnlyCollection snap = _snapshot; + if (snap == null) { - ReadOnlyCollection snap = _snapshot; - if (snap == null) - { + lock (_list) _snapshot = snap = new ReadOnlyCollection(_list.ToList()); - } - return snap?.GetEnumerator(); } + + return snap?.GetEnumerator(); } public int IndexOf(T item) diff --git a/src/Tizen.NUI/src/internal/XamlBinding/ThicknessTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/ThicknessTypeConverter.cs index a1a376d..72271c3 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/ThicknessTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/ThicknessTypeConverter.cs @@ -3,7 +3,7 @@ using System.Globalization; namespace Tizen.NUI.Binding { - // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.ThicknessTypeConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.ThicknessTypeConverter")] [Xaml.TypeConversion(typeof(Thickness))] internal class ThicknessTypeConverter : TypeConverter { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/TizenPlatformServices.cs b/src/Tizen.NUI/src/internal/XamlBinding/TizenPlatformServices.cs index b1f804f..d05bf08 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/TizenPlatformServices.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/TizenPlatformServices.cs @@ -215,9 +215,9 @@ namespace Tizen.NUI.Binding if (refAsm != null) { RegisterAssemblyRecursively(refAsm); - if (refName.Name == "Xamarin.Forms.Core") + if (refName.Name == "Tizen.NUI.Xaml.Core") { - if (refAsm.GetType("Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement") != null) + if (refAsm.GetType("Tizen.NUI.Xaml.PlatformConfiguration.TizenSpecific.VisualElement") != null) { IsTizenSpecificAvailable = true; } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/TypeTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/TypeTypeConverter.cs index cd61401..fa8f392 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/TypeTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/TypeTypeConverter.cs @@ -4,7 +4,7 @@ using Tizen.NUI.Xaml; namespace Tizen.NUI.Binding { - // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.TypeTypeConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.TypeTypeConverter")] [Xaml.TypeConversion(typeof(Type))] internal sealed class TypeTypeConverter : TypeConverter, IExtendedTypeConverter { diff --git a/src/Tizen.NUI/src/internal/XamlBinding/UriTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/UriTypeConverter.cs index 8a5437d..67928a3 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/UriTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/UriTypeConverter.cs @@ -2,7 +2,7 @@ namespace Tizen.NUI.Binding { - // [Xaml.ProvideCompiled("Tizen.NUI.Core.XamlC.UriTypeConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Core.XamlC.UriTypeConverter")] [Xaml.TypeConversion(typeof(Uri))] internal class UriTypeConverter : TypeConverter { diff --git a/src/Tizen.NUI/src/public/Xaml/ProvideCompiledAttribute.cs b/src/Tizen.NUI/src/public/Xaml/ProvideCompiledAttribute.cs new file mode 100755 index 0000000..4ea4385 --- /dev/null +++ b/src/Tizen.NUI/src/public/Xaml/ProvideCompiledAttribute.cs @@ -0,0 +1,15 @@ +using System; + +namespace Tizen.NUI.Xaml +{ + [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] + sealed class ProvideCompiledAttribute : Attribute + { + public string CompiledVersion { get; } + + public ProvideCompiledAttribute (string compiledVersion) + { + CompiledVersion = compiledVersion; + } + } +} \ No newline at end of file diff --git a/src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs b/src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs index 9523d35..2197921 100755 --- a/src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs +++ b/src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs @@ -28,11 +28,12 @@ using System; using System.Reflection; using System.ComponentModel; +using Tizen.NUI.Binding; namespace Tizen.NUI.Xaml { /// - /// Extension class for View defining Xamarin.Forms.Xaml.Extensions.LoadFromXaml{TView} method. + /// Extension class for View defining Tizen.NUI.Xaml.Extensions.LoadFromXaml{TView} method. /// [EditorBrowsable(EditorBrowsableState.Never)] public static class Extensions @@ -69,9 +70,9 @@ namespace Tizen.NUI.Xaml /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public static Transition LoadTransition(string animationXamlPath) + public static T LoadObject(string path) { - return XamlLoader.LoadTransition(animationXamlPath); + return XamlLoader.LoadObject(path); } - } + } } \ No newline at end of file diff --git a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs index 09f565c..7ddbc04 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs @@ -17,7 +17,8 @@ namespace Tizen.NUI.Binding /// /// Implements the bound property whose interface is provided by the BindingContext property. /// - internal static readonly BindableProperty BindingContextProperty = + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty BindingContextProperty = BindableProperty.Create("BindingContext", typeof(object), typeof(BindableObject), default(object), BindingMode.OneWay, null, BindingContextPropertyChanged, null, null, BindingContextPropertyBindingChanging); @@ -62,7 +63,7 @@ namespace Tizen.NUI.Binding } /// - /// Clears any value set by Xamarin.Forms.BindableObject.SetValue. + /// Clears any value set by Tizen.NUI.Xaml.BindableObject.SetValue. /// /// The BindableProperty to clear internal void ClearValue(BindableProperty property) @@ -71,7 +72,7 @@ namespace Tizen.NUI.Binding } /// - /// Clears any value set by Xamarin.Forms.BindableObject.SetValue for the property that is identified by propertyKey. + /// Clears any value set by Tizen.NUI.Xaml.BindableObject.SetValue for the property that is identified by propertyKey. /// /// The BindablePropertyKey that identifies the BindableProperty to clear. internal void ClearValue(BindablePropertyKey propertyKey) diff --git a/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs b/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs index 5f04e47..63891ff 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs @@ -35,27 +35,13 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public View Root {get; internal set;} - internal static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(ContentPage), null, propertyChanged: (bindable, oldValue, newValue) => + /// + /// The contents of ContentPage can be added into it. + /// + /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(ContentPage), null, propertyChanged: (bindable, oldValue, newValue) => { - // var self = (IControlTemplated)bindable; - // var newElement = (Element)newValue; - // if (self.ControlTemplate == null) - // { - // while (self.InternalChildren.Count > 0) - // { - // self.InternalChildren.RemoveAt(self.InternalChildren.Count - 1); - // } - - // if (newValue != null) - // self.InternalChildren.Add(newElement); - // } - // else - // { - // if (newElement != null) - // { - // BindableObject.SetInheritedBindingContext(newElement, bindable.BindingContext); - // } - // } var self = (ContentPage)bindable; if (newValue != null) { @@ -115,10 +101,8 @@ namespace Tizen.NUI IsCreateByXaml = true; Root = new View(); - Root.Size2D = new Size2D(win.WindowSize.Width, win.WindowSize.Height); - Root.ParentOrigin = ParentOrigin.TopLeft; - Root.PivotPoint = PivotPoint.TopLeft; - Root.PositionUsesPivotPoint = true; + Root.WidthResizePolicy = ResizePolicyType.FillToParent; + Root.HeightResizePolicy = ResizePolicyType.FillToParent; win.Add(Root); } @@ -247,19 +231,16 @@ namespace Tizen.NUI /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public Animation CreateAnimation(string animationType) + public Transition GetTransition(string transitionName) { - Animation ani = null; Transition trans = null; - transDictionary.TryGetValue(animationType, out trans); - - ani = trans?.CreateAnimation(); - return ani; + transDictionary.TryGetValue(transitionName, out trans); + return trans; } - private void CreateAnimationFactory() + private void LoadTransitions() { - foreach (string str in transitionType) + foreach (string str in transitionNames) { string resourceName = str + ".xaml"; Transition trans = null; @@ -270,7 +251,7 @@ namespace Tizen.NUI if (File.Exists(likelyResourcePath)) { - trans = Extensions.LoadTransition(likelyResourcePath); + trans = Extensions.LoadObject(likelyResourcePath); } if (trans) { @@ -279,20 +260,20 @@ namespace Tizen.NUI } } - private string[] transitionType; + private string[] transitionNames; /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public string[] TransitionType + public string[] TransitionNames { get { - return transitionType; + return transitionNames; } set { - transitionType = value; - CreateAnimationFactory(); + transitionNames = value; + LoadTransitions(); } } } diff --git a/src/Tizen.NUI/src/public/XamlBinding/Element.cs b/src/Tizen.NUI/src/public/XamlBinding/Element.cs index f932e69..59a9cda 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/Element.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/Element.cs @@ -347,8 +347,13 @@ namespace Tizen.NUI.Binding { INameScope namescope = GetNameScope(); if (namescope == null) - throw new InvalidOperationException("this element is not in a namescope"); - return namescope.FindByName(name); + { + return null; + } + else + { + return namescope.FindByName(name); + } } void INameScope.RegisterName(string name, object scopedElement) @@ -600,6 +605,8 @@ namespace Tizen.NUI.Binding object value; if (this.TryGetResource(key, out value)) OnResourceChanged(property, value); + + Tizen.NUI.Application.AddResourceChangedCallback(this, (this as Element).OnResourcesChanged); } internal event EventHandler ParentSet; diff --git a/src/Tizen.NUI/src/public/XamlBinding/IResourcesProvider.cs b/src/Tizen.NUI/src/public/XamlBinding/IResourcesProvider.cs index add06df..613ac89 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/IResourcesProvider.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/IResourcesProvider.cs @@ -10,6 +10,7 @@ namespace Tizen.NUI.Binding /// Check if resources created. /// bool IsResourcesCreated { get; } + /// /// Saved xaml resources. /// diff --git a/src/Tizen.NUI/src/public/XamlBinding/IValueConverter.cs b/src/Tizen.NUI/src/public/XamlBinding/IValueConverter.cs index 504bb7e..3ba97ca 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/IValueConverter.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/IValueConverter.cs @@ -17,6 +17,7 @@ namespace Tizen.NUI.Binding /// The culture to use in the converter. /// A converted value. If the method returns null, the valid null value is used. object Convert(object value, Type targetType, object parameter, CultureInfo culture); + /// /// Converts a value. /// diff --git a/src/Tizen.NUI/src/public/XamlBinding/NameScopeExtensions.cs b/src/Tizen.NUI/src/public/XamlBinding/NameScopeExtensions.cs index 4f92cde..b1c047f 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/NameScopeExtensions.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/NameScopeExtensions.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.ComponentModel; using Tizen.NUI.Binding.Internals; @@ -18,5 +19,27 @@ namespace Tizen.NUI.Binding { return (T)namescope.FindByName(name); } + + private static Stack elementStack = new Stack(); + + internal static void PushElement(object element) + { + elementStack.Push((Element)element); + } + + internal static void PopElement() + { + elementStack.Pop(); + } + + /// + /// Used to find the object defined in Xaml file. + /// + /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public static T FindByNameInCurrentNameScope(string name) + { + return FindByName(elementStack.Peek(), name); + } } } \ No newline at end of file diff --git a/src/Tizen.NUI/src/public/XamlBinding/ResourceDictionary.cs b/src/Tizen.NUI/src/public/XamlBinding/ResourceDictionary.cs index 5e32d27..4f9f30f 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/ResourceDictionary.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/ResourceDictionary.cs @@ -369,7 +369,7 @@ namespace Tizen.NUI.Binding event EventHandler ValuesChanged; - // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.RDSourceTypeConverter")] + [Xaml.ProvideCompiled("Tizen.NUI.Xaml.Core.XamlC.RDSourceTypeConverter")] internal class RDSourceTypeConverter : TypeConverter, IExtendedTypeConverter { object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider) diff --git a/src/Tizen.NUI/src/public/XamlBinding/Transition.cs b/src/Tizen.NUI/src/public/XamlBinding/Transition.cs index c8c4745..9dc577e 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/Transition.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/Transition.cs @@ -1,157 +1,216 @@ +using System.Collections.Generic; using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Reflection; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Binding; +using Tizen.NUI.Xaml; using static Tizen.NUI.Animation; namespace Tizen.NUI { + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public class Transition : BaseHandle + public class AnimationBehavior { - private string name; - + private string _key = null; + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - - public string Name + public string Key { get { - return name; + return _key; } set { - name = value; + _key = value; } } - private int duration; + private string _property = null; + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public int Duration + public string Property { get { - return duration; + return _property; } set { - duration = value; + _property = value; } } - private int loopCount; + private string _destValue = null; + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public int LoopCount + public string DestValue { get { - return loopCount; + return _destValue; } set { - loopCount = value; + _destValue = value; } } - private EndActions endAction; + private int _startTime = -1; + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public EndActions EndAction + public int StartTime { get { - return endAction; + return _startTime; } set { - endAction = value; + _startTime = value; } } - private string[] _properties = null; + private int _endTime = -1; + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public string[] Properties + public int EndTime { get { - return _properties; + return _endTime; } set { - _properties = value; + _endTime = value; } } + } - private string[] _destValue = null; + /// 5 + /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class Transition : Animation + { + private string name; + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public string[] DestValue + public string Name { get { - return _destValue; + return name; } set { - _destValue = value; + name = value; } } - private int[] _startTime = null; + private Dictionary behaviors = new Dictionary(); + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public int[] StartTime + public AnimationBehavior[] Behaviors { - get - { - return _startTime; - } set { - _startTime = value; + if (null != value) + { + foreach (AnimationBehavior behavior in value) + { + behaviors.Add(behavior.Key, behavior); + } + } } } - private int[] _endTime = null; - + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public int[] EndTime + public void AnimateTo(View instance, string behaviorKey) { - get + AnimationBehavior behavior = null; + behaviors.TryGetValue(behaviorKey, out behavior); + + if (null != behavior) { - return _endTime; + var elementType = instance.GetType(); + PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == behavior.Property); + + if (propertyInfo != null) + { + object destinationValue = ConvertTo(behavior.DestValue, propertyInfo.PropertyType); + + if (destinationValue != null) + { + if (0 <= behavior.StartTime) + { + AnimateTo(instance, behavior.Property, destinationValue, behavior.StartTime, behavior.EndTime); + } + else + { + AnimateTo(instance, behavior.Property, destinationValue); + } + } + } } - set + else { - _endTime = value; + throw new XamlParseException(string.Format("Behaviors don't have key {0}", behaviorKey), new XmlLineInfo()); } } + /// 5 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public Animation CreateAnimation() + public void AnimateBy(View instance, string behaviorKey) { - Animation ani = new Animation(); + AnimationBehavior behavior = null; + behaviors.TryGetValue(behaviorKey, out behavior); - ani.Duration = Duration; - ani.LoopCount = LoopCount; - ani.EndAction = EndAction; + if (null != behavior) + { + var elementType = instance.GetType(); + PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == behavior.Property); - ani.Properties = Properties; - ani.DestValue = DestValue; - ani.StartTime = StartTime; - ani.EndTime = EndTime; + if (propertyInfo != null) + { + object destinationValue = ConvertTo(behavior.DestValue, propertyInfo.PropertyType); - return ani; + if (destinationValue != null) + { + if (0 <= behavior.StartTime) + { + AnimateBy(instance, behavior.Property, destinationValue, behavior.StartTime, behavior.EndTime); + } + else + { + AnimateBy(instance, behavior.Property, destinationValue); + } + } + } + } + else + { + throw new XamlParseException(string.Format("Behaviors don't have key {0}", behaviorKey), new XmlLineInfo()); + } } } } \ No newline at end of file -- 2.7.4