--- /dev/null
+using System.Runtime.CompilerServices;
+
+using Tizen.NUI;
+
+// Xamarin.Forms.Loader.dll Xamarin.Forms.Xaml.XamlLoader.Load(object, string), kzu@microsoft.com
+[assembly: XmlnsDefinition("http://tizen.org/Tizen.NUI/2018/XAML", "Tizen.NUI")]
+[assembly: XmlnsDefinition("http://tizen.org/Tizen.NUI/2018/XAML", "Tizen.NUI.BaseComponents")]
+[assembly: XmlnsDefinition("http://tizen.org/Tizen.NUI/2018/XAML", "Tizen.NUI.UIComponents")]
+[assembly: XmlnsDefinition("http://tizen.org/Tizen.NUI/2018/XAML", "Tizen.NUI.Xaml")]
+[assembly: XmlnsDefinition("http://tizen.org/Tizen.NUI/2018/XAML", "Tizen.NUI.Binding")]
+[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "Tizen.NUI.Xaml")]
+[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System", AssemblyName = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
+[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System", AssemblyName = "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
+[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2009/xaml", "Tizen.NUI.Xaml")]
+[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2009/xaml", "System", AssemblyName = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
+[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2009/xaml", "System", AssemblyName = "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
{
using System;
+ using System.Collections.Generic;
+ using System.Collections.ObjectModel;
+ using System.ComponentModel;
using System.Runtime.InteropServices;
+ using System.Threading;
+ using System.Threading.Tasks;
+ using Tizen.NUI.Binding;
+ using Tizen.NUI.Binding.Internals;
/**
* @brief Event arguments that passed via NUIApplicationInit signal
}
}
- internal class Application : BaseHandle
+ public class GetResourcesProvider
{
+ static public IResourcesProvider Get()
+ {
+ return Tizen.NUI.Application.Current;
+ }
+ }
+
+ internal class Application : BaseHandle, IResourcesProvider, IApplicationController, IElementConfiguration<Application>
+ {
+ static Application s_current;
+ Task<IDictionary<string, object>> _propertiesTask;
+ readonly Lazy<PlatformConfigurationRegistry<Application>> _platformConfigurationRegistry;
+
+ IAppIndexingProvider _appIndexProvider;
+
+ ReadOnlyCollection<Element> _logicalChildren;
+
+ Page _mainPage;
+
+ static SemaphoreSlim SaveSemaphore = new SemaphoreSlim(1, 1);
+
+ public IAppLinks AppLinks
+ {
+ get
+ {
+ 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");
+ return _appIndexProvider.AppLinks;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void SetCurrentApplication(Application value) => Current = value;
+
+ public static Application Current
+ {
+ get { return s_current; }
+ set
+ {
+ if (s_current == value)
+ return;
+ if (value == null)
+ s_current = null; //Allow to reset current for unittesting
+ s_current = value;
+ }
+ }
+
+ public Page MainPage
+ {
+ get { return _mainPage; }
+ set
+ {
+ if (value == null)
+ throw new ArgumentNullException("value");
+
+ if (_mainPage == value)
+ return;
+
+ OnPropertyChanging();
+ if (_mainPage != null)
+ {
+ InternalChildren.Remove(_mainPage);
+ _mainPage.Parent = null;
+ }
+
+ _mainPage = value;
+
+ if (_mainPage != null)
+ {
+ _mainPage.Parent = this;
+ _mainPage.NavigationProxy.Inner = NavigationProxy;
+ InternalChildren.Add(_mainPage);
+ }
+ OnPropertyChanged();
+ }
+ }
+
+ public IDictionary<string, object> Properties
+ {
+ get
+ {
+ if (_propertiesTask == null)
+ {
+ _propertiesTask = GetPropertiesAsync();
+ }
+
+ return _propertiesTask.Result;
+ }
+ }
+
+ internal override ReadOnlyCollection<Element> LogicalChildrenInternal
+ {
+ get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public NavigationProxy NavigationProxy { get; }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int PanGestureId { get; set; }
+
+ internal IResourceDictionary SystemResources { get; }
+
+ ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetAppIndexingProvider(IAppIndexingProvider provider)
+ {
+ _appIndexProvider = provider;
+ }
+
+ ResourceDictionary _resources;
+ public bool IsResourcesCreated => _resources != null;
+
+ public delegate void resChangeCb (object sender, ResourcesChangedEventArgs e);
+
+ static private Dictionary<object, Dictionary<resChangeCb, int>> resourceChangeCallbackDict = new Dictionary<object, Dictionary<resChangeCb, int>>();
+ static public void AddResourceChangedCallback(object handle, resChangeCb cb)
+ {
+ Dictionary<resChangeCb, int> cbDict;
+ resourceChangeCallbackDict.TryGetValue(handle, out cbDict);
+
+ if (null == cbDict)
+ {
+ cbDict = new Dictionary<resChangeCb, int>();
+ resourceChangeCallbackDict.Add(handle, cbDict);
+ }
+
+ if (false == cbDict.ContainsKey(cb))
+ {
+ cbDict.Add(cb, 0);
+ }
+ }
+
+ internal override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
+ {
+ base.OnResourcesChanged(sender, e);
+
+ foreach (KeyValuePair<object, Dictionary<resChangeCb, int>> resourcePair in resourceChangeCallbackDict)
+ {
+ foreach (KeyValuePair<resChangeCb, int> cbPair in resourcePair.Value)
+ {
+ cbPair.Key(sender, e);
+ }
+ }
+ }
+
+ public ResourceDictionary Resources
+ {
+ get
+ {
+ if (_resources != null)
+ return _resources;
+
+ _resources = new ResourceDictionary();
+ int hashCode = _resources.GetHashCode();
+ ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
+ return _resources;
+ }
+ set
+ {
+ if (_resources == value)
+ return;
+ OnPropertyChanging();
+
+ if (_resources != null)
+ ((IResourceDictionary)_resources).ValuesChanged -= OnResourcesChanged;
+ _resources = value;
+ OnResourcesChanged(value);
+ if (_resources != null)
+ ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
+
+ OnPropertyChanged();
+ }
+ }
+
+ public event EventHandler<ModalPoppedEventArgs> ModalPopped;
+
+ public event EventHandler<ModalPoppingEventArgs> ModalPopping;
+
+ public event EventHandler<ModalPushedEventArgs> ModalPushed;
+
+ public event EventHandler<ModalPushingEventArgs> ModalPushing;
+
+ public event EventHandler<Page> PageAppearing;
+
+ public event EventHandler<Page> PageDisappearing;
+
+
+ async void SaveProperties()
+ {
+ try
+ {
+ await SetPropertiesAsync();
+ }
+ catch (Exception exc)
+ {
+ Console.WriteLine(nameof(Application), $"Exception while saving Application Properties: {exc}");
+ }
+ }
+
+ public async Task SavePropertiesAsync()
+ {
+ if (Device.IsInvokeRequired)
+ {
+ Device.BeginInvokeOnMainThread(SaveProperties);
+ }
+ else
+ {
+ await SetPropertiesAsync();
+ }
+ }
+
+ // Don't use this unless there really is no better option
+ internal void SavePropertiesAsFireAndForget()
+ {
+ if (Device.IsInvokeRequired)
+ {
+ Device.BeginInvokeOnMainThread(SaveProperties);
+ }
+ else
+ {
+ SaveProperties();
+ }
+ }
+
+ public IPlatformElementConfiguration<T, Application> On<T>() where T : IConfigPlatform
+ {
+ return _platformConfigurationRegistry.Value.On<T>();
+ }
+
+ protected virtual void OnAppLinkRequestReceived(Uri uri)
+ {
+ }
+
+ protected override void OnParentSet()
+ {
+ throw new InvalidOperationException("Setting a Parent on Application is invalid.");
+ }
+
+ protected virtual void OnResume()
+ {
+ }
+
+ protected virtual void OnSleep()
+ {
+ }
+
+ protected virtual void OnStart()
+ {
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void ClearCurrent()
+ {
+ s_current = null;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static bool IsApplicationOrNull(Element element)
+ {
+ return element == null || element is Application;
+ }
+
+ internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
+ {
+ if (!((IResourcesProvider)this).IsResourcesCreated || Resources.Count == 0)
+ {
+ base.OnParentResourcesChanged(values);
+ return;
+ }
+
+ var innerKeys = new HashSet<string>();
+ var changedResources = new List<KeyValuePair<string, object>>();
+ foreach (KeyValuePair<string, object> c in Resources)
+ innerKeys.Add(c.Key);
+ foreach (KeyValuePair<string, object> value in values)
+ {
+ if (innerKeys.Add(value.Key))
+ changedResources.Add(value);
+ }
+ OnResourcesChanged(changedResources);
+ }
+
+ internal event EventHandler PopCanceled;
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendOnAppLinkRequestReceived(Uri uri)
+ {
+ OnAppLinkRequestReceived(uri);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendResume()
+ {
+ s_current = this;
+ OnResume();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendSleep()
+ {
+ OnSleep();
+ SavePropertiesAsFireAndForget();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Task SendSleepAsync()
+ {
+ OnSleep();
+ return SavePropertiesAsync();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendStart()
+ {
+ OnStart();
+ }
+
+ async Task<IDictionary<string, object>> GetPropertiesAsync()
+ {
+ var deserializer = DependencyService.Get<IDeserializer>();
+ if (deserializer == null)
+ {
+ Console.WriteLine("Startup", "No IDeserialzier was found registered");
+ return new Dictionary<string, object>(4);
+ }
+
+ IDictionary<string, object> properties = await deserializer.DeserializePropertiesAsync().ConfigureAwait(false);
+ if (properties == null)
+ properties = new Dictionary<string, object>(4);
+
+ return properties;
+ }
+
+ internal void OnPageAppearing(Page page)
+ => PageAppearing?.Invoke(this, page);
+
+ internal void OnPageDisappearing(Page page)
+ => PageDisappearing?.Invoke(this, page);
+
+ void OnModalPopped(Page modalPage)
+ => ModalPopped?.Invoke(this, new ModalPoppedEventArgs(modalPage));
+
+ bool OnModalPopping(Page modalPage)
+ {
+ var args = new ModalPoppingEventArgs(modalPage);
+ ModalPopping?.Invoke(this, args);
+ return args.Cancel;
+ }
+
+ void OnModalPushed(Page modalPage)
+ => ModalPushed?.Invoke(this, new ModalPushedEventArgs(modalPage));
+
+ void OnModalPushing(Page modalPage)
+ => ModalPushing?.Invoke(this, new ModalPushingEventArgs(modalPage));
+
+ void OnPopCanceled()
+ => PopCanceled?.Invoke(this, EventArgs.Empty);
+
+ async Task SetPropertiesAsync()
+ {
+ await SaveSemaphore.WaitAsync();
+ try
+ {
+ await DependencyService.Get<IDeserializer>().SerializePropertiesAsync(Properties);
+ }
+ finally
+ {
+ SaveSemaphore.Release();
+ }
+
+ }
+
+ class NavigationImpl : NavigationProxy
+ {
+ readonly Application _owner;
+
+ public NavigationImpl(Application owner)
+ {
+ _owner = owner;
+ }
+
+ protected override async Task<Page> OnPopModal(bool animated)
+ {
+ Page modal = ModalStack[ModalStack.Count - 1];
+ if (_owner.OnModalPopping(modal))
+ {
+ _owner.OnPopCanceled();
+ return null;
+ }
+ Page result = await base.OnPopModal(animated);
+ result.Parent = null;
+ _owner.OnModalPopped(result);
+ return result;
+ }
+
+ protected override async Task OnPushModal(Page modal, bool animated)
+ {
+ _owner.OnModalPushing(modal);
+
+ modal.Parent = _owner;
+
+ if (modal.NavigationProxy.ModalStack.Count == 0)
+ {
+ modal.NavigationProxy.Inner = this;
+ await base.OnPushModal(modal, animated);
+ }
+ else
+ {
+ await base.OnPushModal(modal, animated);
+ modal.NavigationProxy.Inner = this;
+ }
+
+ _owner.OnModalPushed(modal);
+ }
+ }
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Application_SWIGUpcast(cPtr), cMemoryOwn)
{
+ NavigationProxy = new NavigationImpl(this);
+ SetCurrentApplication(this);
+
+ _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Application>>(() => new PlatformConfigurationRegistry<Application>(this));
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
+
+ SendResume();
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Application obj)
{
Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_3(argc, stylesheet, (int)windowMode), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ ret.SendResume();
return ret;
}
return ret;
}
- public bool GetTypeInfo(TypeInfo info)
+ public bool GetTypeInfo(Tizen.NUI.TypeInfo info)
{
- bool ret = NDalicPINVOKE.BaseObject_GetTypeInfo(swigCPtr, TypeInfo.getCPtr(info));
+ bool ret = NDalicPINVOKE.BaseObject_GetTypeInfo(swigCPtr, Tizen.NUI.TypeInfo.getCPtr(info));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
/// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ Size size = obj as Size;
+ bool equal = false;
+ if (Width == size?.Width && Height == size?.Height && Depth == size?.Depth)
+ {
+ equal = true;
+ }
+ return equal;
+ }
+
+
+ /// <summary>
/// Checks equality.<br />
/// Utilizes appropriate machine epsilon values.<br />
/// </summary>
return ret;
}
- public TypeInfo GetTypeInfo(string uniqueTypeName)
+ public Tizen.NUI.TypeInfo GetTypeInfo(string uniqueTypeName)
{
- TypeInfo ret = new TypeInfo(NDalicPINVOKE.TypeRegistry_GetTypeInfo__SWIG_0(swigCPtr, uniqueTypeName), true);
+ Tizen.NUI.TypeInfo ret = new Tizen.NUI.TypeInfo(NDalicPINVOKE.TypeRegistry_GetTypeInfo__SWIG_0(swigCPtr, uniqueTypeName), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
- internal TypeInfo GetTypeInfo(SWIGTYPE_p_std__type_info registerType)
+ internal Tizen.NUI.TypeInfo GetTypeInfo(SWIGTYPE_p_std__type_info registerType)
{
- TypeInfo ret = new TypeInfo(NDalicPINVOKE.TypeRegistry_GetTypeInfo__SWIG_1(swigCPtr, SWIGTYPE_p_std__type_info.getCPtr(registerType)), true);
+ Tizen.NUI.TypeInfo ret = new Tizen.NUI.TypeInfo(NDalicPINVOKE.TypeRegistry_GetTypeInfo__SWIG_1(swigCPtr, SWIGTYPE_p_std__type_info.getCPtr(registerType)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
using System.Linq;
using System.Reflection;
using System.Xml;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI.Binding;
using Tizen.NUI.StyleSheets;
namespace Tizen.NUI.Xaml
{
- class ApplyPropertiesVisitor : IXamlNodeVisitor
- {
- public static readonly IList<XmlName> Skips = new List<XmlName> {
- XmlName.xKey,
- XmlName.xTypeArguments,
- XmlName.xArguments,
- XmlName.xFactoryMethod,
- XmlName.xName,
- XmlName.xDataType
- };
-
- public ApplyPropertiesVisitor(HydrationContext context, bool stopOnResourceDictionary = false)
- {
- Context = context;
- StopOnResourceDictionary = stopOnResourceDictionary;
- }
-
- Dictionary<INode, object> Values => Context.Values;
- HydrationContext Context { get; }
-
- public TreeVisitingMode VisitingMode => TreeVisitingMode.BottomUp;
- public bool StopOnDataTemplate => true;
- public bool StopOnResourceDictionary { get; }
- public bool VisitNodeOnDataTemplate => true;
- public bool SkipChildren(INode node, INode parentNode) => false;
-
- public void Visit(ValueNode node, INode parentNode)
- {
- var parentElement = parentNode as IElementNode;
- var value = Values [node];
- var source = Values [parentNode];
- XmlName propertyName;
-
- if (TryGetPropertyName(node, parentNode, out propertyName)) {
- if (TrySetRuntimeName(propertyName, source, value, node))
- return;
- if (Skips.Contains(propertyName))
- return;
- if (parentElement.SkipProperties.Contains(propertyName))
- return;
- if (propertyName.Equals(XamlParser.McUri, "Ignorable"))
- return;
- SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
- } else if (IsCollectionItem(node, parentNode) && parentNode is IElementNode) {
- // Collection element, implicit content, or implicit collection element.
- var contentProperty = GetContentPropertyName(Context.Types[parentElement].GetTypeInfo());
- if (contentProperty != null) {
- var name = new XmlName(((ElementNode)parentNode).NamespaceURI, contentProperty);
- if (Skips.Contains(name))
- return;
- if (parentElement.SkipProperties.Contains(propertyName))
- return;
- SetPropertyValue(source, name, value, Context.RootElement, node, Context, node);
- }
- }
- }
-
- public void Visit(MarkupNode node, INode parentNode)
- {
- }
-
- public void Visit(ElementNode node, INode parentNode)
- {
- XmlName propertyName;
- if (TryGetPropertyName(node, parentNode, out propertyName) && propertyName == XmlName._CreateContent) {
- var s0 = Values[parentNode];
- if (s0 is ElementTemplate) {
- SetTemplate(s0 as ElementTemplate, node);
- return;
- }
- }
-
- var parentElement = parentNode as IElementNode;
- propertyName = XmlName.Empty;
-
- //Simplify ListNodes with single elements
- var pList = parentNode as ListNode;
- if (pList != null && pList.CollectionItems.Count == 1) {
- propertyName = pList.XmlName;
- parentNode = parentNode.Parent;
- parentElement = parentNode as IElementNode;
- }
-
- var value = Values[node];
-
- if (propertyName != XmlName.Empty || TryGetPropertyName(node, parentNode, out propertyName)) {
- if (Skips.Contains(propertyName))
- return;
- if (parentElement.SkipProperties.Contains(propertyName))
- return;
-
- var source = Values[parentNode];
- ProvideValue(ref value, node, source, propertyName);
- SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
- }
- else if (IsCollectionItem(node, parentNode) && parentNode is IElementNode) {
- var source = Values[parentNode];
- ProvideValue(ref value, node, source, XmlName.Empty);
- string contentProperty;
- Exception xpe = null;
- var xKey = node.Properties.ContainsKey(XmlName.xKey) ? ((ValueNode)node.Properties[XmlName.xKey]).Value as string : null;
-
- //ResourceDictionary
- if (xpe == null && TryAddToResourceDictionary(source as ResourceDictionary, value, xKey, node, out xpe))
- return;
-
- // Collection element, implicit content, or implicit collection element.
- if (xpe == null && typeof(IEnumerable).IsAssignableFrom(Context.Types[parentElement]) && Context.Types[parentElement].GetRuntimeMethods().Any(mi => mi.Name == "Add" && mi.GetParameters().Length == 1)) {
- var addMethod =
- Context.Types[parentElement].GetRuntimeMethods().First(mi => mi.Name == "Add" && mi.GetParameters().Length == 1);
-
- addMethod.Invoke(source, new[] { value });
- return;
- }
- if (xpe == null && (contentProperty = GetContentPropertyName(Context.Types[parentElement].GetTypeInfo())) != null) {
- var name = new XmlName(node.NamespaceURI, contentProperty);
- if (Skips.Contains(name))
- return;
- if (parentElement.SkipProperties.Contains(propertyName))
- return;
-
- SetPropertyValue(source, name, value, Context.RootElement, node, Context, node);
- return;
- }
- if (xpe == null && Context.Types[parentElement].GetRuntimeMethods().Any(mi => mi.Name == "Add" && mi.GetParameters().Length == 1))
- {
- //if there are similar parameters in the function, this will exist issue.
- var addMethod = Context.Types[parentElement].GetRuntimeMethods().First(mi => mi.Name == "Add" && mi.GetParameters().Length == 1);
- if(addMethod != null) addMethod.Invoke(source, new[] { value });
- return;
- }
- xpe = xpe ?? new XamlParseException($"Can not set the content of {((IElementNode)parentNode).XmlType.Name} as it doesn't have a ContentPropertyAttribute", node);
- if (Context.ExceptionHandler != null)
- Context.ExceptionHandler(xpe);
- throw xpe;
- }
- else if (IsCollectionItem(node, parentNode) && parentNode is ListNode) {
- var source = Values[parentNode.Parent];
- ProvideValue(ref value, node, source, XmlName.Empty);
- var parentList = (ListNode)parentNode;
- if (Skips.Contains(parentList.XmlName))
- return;
- Exception xpe = null;
- var xKey = node.Properties.ContainsKey(XmlName.xKey) ? ((ValueNode)node.Properties[XmlName.xKey]).Value as string : null;
-
- object _;
- var collection = GetPropertyValue(source, parentList.XmlName, Context, parentList, out _) as IEnumerable;
- if (collection == null)
- xpe = new XamlParseException($"Property {parentList.XmlName.LocalName} is null or is not IEnumerable", node);
-
- if (xpe == null && TryAddToResourceDictionary(collection as ResourceDictionary, value, xKey, node, out xpe))
- return;
-
- MethodInfo addMethod;
- if (xpe == null && (addMethod = collection.GetType().GetRuntimeMethods().First(mi => mi.Name == "Add" && mi.GetParameters().Length == 1)) != null) {
- addMethod.Invoke(collection, new[] { Values[node] });
- return;
- }
- xpe = xpe ?? new XamlParseException($"Value of {parentList.XmlName.LocalName} does not have a Add() method", node);
- if (Context.ExceptionHandler != null)
- Context.ExceptionHandler(xpe);
- else
- throw xpe;
- }
- }
-
-
-
- public void Visit(RootNode node, INode parentNode)
- {
- }
-
- public void Visit(ListNode node, INode parentNode)
- {
- }
-
- public static bool TryGetPropertyName(INode node, INode parentNode, out XmlName name)
- {
- name = default(XmlName);
- var parentElement = parentNode as IElementNode;
- if (parentElement == null)
- return false;
- foreach (var kvp in parentElement.Properties) {
- if (kvp.Value != node)
- continue;
- name = kvp.Key;
- return true;
- }
- return false;
- }
-
- internal static bool IsCollectionItem(INode node, INode parentNode)
- {
- var parentList = parentNode as IListNode;
- if (parentList == null)
- return false;
- return parentList.CollectionItems.Contains(node);
- }
-
- internal static string GetContentPropertyName(System.Reflection.TypeInfo typeInfo)
- {
- while (typeInfo != null) {
- var propName = GetContentPropertyName(typeInfo.CustomAttributes);
- if (propName != null)
- return propName;
- typeInfo = typeInfo?.BaseType?.GetTypeInfo();
- }
- return null;
- }
-
- void ProvideValue(ref object value, ElementNode node, object source, XmlName propertyName)
- {
- var markupExtension = value as IMarkupExtension;
- var valueProvider = value as IValueProvider;
-
- if (markupExtension == null && valueProvider == null)
- return;
-
- XamlServiceProvider serviceProvider = null;
- if (value.GetType().GetTypeInfo().GetCustomAttribute<AcceptEmptyServiceProviderAttribute>() == null)
- serviceProvider = new XamlServiceProvider(node, Context);
-
- if (serviceProvider != null && propertyName != XmlName.Empty)
- ((XamlValueTargetProvider)serviceProvider.IProvideValueTarget).TargetProperty = GetTargetProperty(source, propertyName, Context, node);
-
- if (markupExtension != null)
- value = markupExtension.ProvideValue(serviceProvider);
- else if (valueProvider != null)
- value = valueProvider.ProvideValue(serviceProvider);
- }
-
- static string GetContentPropertyName(IEnumerable<CustomAttributeData> attributes)
- {
- var contentAttribute =
- attributes.FirstOrDefault(cad => ContentPropertyAttribute.ContentPropertyTypes.Contains(cad.AttributeType.FullName));
- if (contentAttribute == null || contentAttribute.ConstructorArguments.Count != 1)
- return null;
- if (contentAttribute.ConstructorArguments [0].ArgumentType == typeof(string))
- return (string)contentAttribute.ConstructorArguments [0].Value;
- return null;
- }
-
- static bool GetRealNameAndType(ref Type elementType, string namespaceURI, ref string localname,
- HydrationContext context, IXmlLineInfo lineInfo)
- {
- var dotIdx = localname.IndexOf('.');
- if (dotIdx > 0) {
- var typename = localname.Substring(0, dotIdx);
- localname = localname.Substring(dotIdx + 1);
- XamlParseException xpe;
- elementType = XamlParser.GetElementType(new XmlType(namespaceURI, typename, null), lineInfo,
- context.RootElement.GetType().GetTypeInfo().Assembly, out xpe);
-
- if (xpe != null)
- throw xpe;
- return true;
- }
- return false;
- }
-
- static BindableProperty GetBindableProperty(Type elementType, string localName, IXmlLineInfo lineInfo,
- bool throwOnError = false)
- {
+ internal class ApplyPropertiesVisitor : IXamlNodeVisitor
+ {
+ public static readonly IList<XmlName> Skips = new List<XmlName> {
+ XmlName.xKey,
+ XmlName.xTypeArguments,
+ XmlName.xArguments,
+ XmlName.xFactoryMethod,
+ XmlName.xName,
+ XmlName.xDataType
+ };
+
+ public ApplyPropertiesVisitor(HydrationContext context, bool stopOnResourceDictionary = false)
+ {
+ Context = context;
+ StopOnResourceDictionary = stopOnResourceDictionary;
+ }
+
+ Dictionary<INode, object> Values => Context.Values;
+ HydrationContext Context { get; }
+
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.BottomUp;
+ public bool StopOnDataTemplate => true;
+ public bool StopOnResourceDictionary { get; }
+ public bool VisitNodeOnDataTemplate => true;
+ public bool SkipChildren(INode node, INode parentNode) => false;
+
+ public void Visit(ValueNode node, INode parentNode)
+ {
+ var parentElement = parentNode as IElementNode;
+ var value = Values [node];
+ var source = Values [parentNode];
+ XmlName propertyName;
+
+ if (TryGetPropertyName(node, parentNode, out propertyName)) {
+ if (TrySetRuntimeName(propertyName, source, value, node))
+ return;
+ if (Skips.Contains(propertyName))
+ return;
+ if (parentElement.SkipProperties.Contains(propertyName))
+ return;
+ if (propertyName.Equals(XamlParser.McUri, "Ignorable"))
+ return;
+ SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
+ } else if (IsCollectionItem(node, parentNode) && parentNode is IElementNode) {
+ // Collection element, implicit content, or implicit collection element.
+ var contentProperty = GetContentPropertyName(Context.Types[parentElement].GetTypeInfo());
+ if (contentProperty != null) {
+ var name = new XmlName(((ElementNode)parentNode).NamespaceURI, contentProperty);
+ if (Skips.Contains(name))
+ return;
+ if (parentElement.SkipProperties.Contains(propertyName))
+ return;
+ SetPropertyValue(source, name, value, Context.RootElement, node, Context, node);
+ }
+ }
+ }
+
+ public void Visit(MarkupNode node, INode parentNode)
+ {
+ }
+
+ public void Visit(ElementNode node, INode parentNode)
+ {
+ XmlName propertyName;
+ if (TryGetPropertyName(node, parentNode, out propertyName) && propertyName == XmlName._CreateContent) {
+ var s0 = Values[parentNode];
+ if (s0 is ElementTemplate) {
+ SetTemplate(s0 as ElementTemplate, node);
+ return;
+ }
+ }
+
+ var parentElement = parentNode as IElementNode;
+ propertyName = XmlName.Empty;
+
+ //Simplify ListNodes with single elements
+ var pList = parentNode as ListNode;
+ if (pList != null && pList.CollectionItems.Count == 1) {
+ propertyName = pList.XmlName;
+ parentNode = parentNode.Parent;
+ parentElement = parentNode as IElementNode;
+ }
+
+ var value = Values[node];
+
+ if (propertyName != XmlName.Empty || TryGetPropertyName(node, parentNode, out propertyName)) {
+ if (Skips.Contains(propertyName))
+ return;
+ if (parentElement.SkipProperties.Contains(propertyName))
+ return;
+
+ var source = Values[parentNode];
+ ProvideValue(ref value, node, source, propertyName);
+ SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
+ }
+ else if (IsCollectionItem(node, parentNode) && parentNode is IElementNode) {
+ var source = Values[parentNode];
+ ProvideValue(ref value, node, source, XmlName.Empty);
+ string contentProperty;
+ Exception xpe = null;
+ var xKey = node.Properties.ContainsKey(XmlName.xKey) ? ((ValueNode)node.Properties[XmlName.xKey]).Value as string : null;
+
+ //ResourceDictionary
+ if (xpe == null && TryAddToResourceDictionary(source as ResourceDictionary, value, xKey, node, out xpe))
+ return;
+
+ // Collection element, implicit content, or implicit collection element.
+ if (xpe == null && typeof(IEnumerable).IsAssignableFrom(Context.Types[parentElement]) && Context.Types[parentElement].GetRuntimeMethods().Any(mi => mi.Name == "Add" && mi.GetParameters().Length == 1)) {
+ var addMethod =
+ Context.Types[parentElement].GetRuntimeMethods().First(mi => mi.Name == "Add" && mi.GetParameters().Length == 1);
+
+ addMethod.Invoke(source, new[] { value });
+ return;
+ }
+ if (xpe == null && (contentProperty = GetContentPropertyName(Context.Types[parentElement].GetTypeInfo())) != null) {
+ var name = new XmlName(node.NamespaceURI, contentProperty);
+ if (Skips.Contains(name))
+ return;
+ if (parentElement.SkipProperties.Contains(propertyName))
+ return;
+
+ SetPropertyValue(source, name, value, Context.RootElement, node, Context, node);
+ return;
+ }
+ if (xpe == null && Context.Types[parentElement].GetRuntimeMethods().Any(mi => mi.Name == "Add" && mi.GetParameters().Length == 1))
+ {
+ //if there are similar parameters in the function, this will exist issue.
+ var addMethod = Context.Types[parentElement].GetRuntimeMethods().First(mi => mi.Name == "Add" && mi.GetParameters().Length == 1);
+ if(addMethod != null) addMethod.Invoke(source, new[] { value });
+ return;
+ }
+ xpe = xpe ?? new XamlParseException($"Can not set the content of {((IElementNode)parentNode).XmlType.Name} as it doesn't have a ContentPropertyAttribute", node);
+ if (Context.ExceptionHandler != null)
+ Context.ExceptionHandler(xpe);
+ throw xpe;
+ }
+ else if (IsCollectionItem(node, parentNode) && parentNode is ListNode) {
+ var source = Values[parentNode.Parent];
+ ProvideValue(ref value, node, source, XmlName.Empty);
+ var parentList = (ListNode)parentNode;
+ if (Skips.Contains(parentList.XmlName))
+ return;
+ Exception xpe = null;
+ var xKey = node.Properties.ContainsKey(XmlName.xKey) ? ((ValueNode)node.Properties[XmlName.xKey]).Value as string : null;
+
+ object _;
+ var collection = GetPropertyValue(source, parentList.XmlName, Context, parentList, out _) as IEnumerable;
+ if (collection == null)
+ xpe = new XamlParseException($"Property {parentList.XmlName.LocalName} is null or is not IEnumerable", node);
+
+ if (xpe == null && TryAddToResourceDictionary(collection as ResourceDictionary, value, xKey, node, out xpe))
+ return;
+
+ MethodInfo addMethod;
+ if (xpe == null && (addMethod = collection.GetType().GetRuntimeMethods().First(mi => mi.Name == "Add" && mi.GetParameters().Length == 1)) != null) {
+ addMethod.Invoke(collection, new[] { Values[node] });
+ return;
+ }
+ xpe = xpe ?? new XamlParseException($"Value of {parentList.XmlName.LocalName} does not have a Add() method", node);
+ if (Context.ExceptionHandler != null)
+ Context.ExceptionHandler(xpe);
+ else
+ throw xpe;
+ }
+ }
+
+
+
+ public void Visit(RootNode node, INode parentNode)
+ {
+ }
+
+ public void Visit(ListNode node, INode parentNode)
+ {
+ }
+
+ public static bool TryGetPropertyName(INode node, INode parentNode, out XmlName name)
+ {
+ name = default(XmlName);
+ var parentElement = parentNode as IElementNode;
+ if (parentElement == null)
+ return false;
+ foreach (var kvp in parentElement.Properties) {
+ if (kvp.Value != node)
+ continue;
+ name = kvp.Key;
+ return true;
+ }
+ return false;
+ }
+
+ internal static bool IsCollectionItem(INode node, INode parentNode)
+ {
+ var parentList = parentNode as IListNode;
+ if (parentList == null)
+ return false;
+ return parentList.CollectionItems.Contains(node);
+ }
+
+ internal static string GetContentPropertyName(System.Reflection.TypeInfo typeInfo)
+ {
+ while (typeInfo != null) {
+ var propName = GetContentPropertyName(typeInfo.CustomAttributes);
+ if (propName != null)
+ return propName;
+ typeInfo = typeInfo?.BaseType?.GetTypeInfo();
+ }
+ return null;
+ }
+
+ void ProvideValue(ref object value, ElementNode node, object source, XmlName propertyName)
+ {
+ var markupExtension = value as IMarkupExtension;
+ var valueProvider = value as IValueProvider;
+
+ if (markupExtension == null && valueProvider == null)
+ return;
+
+ XamlServiceProvider serviceProvider = null;
+ if (value.GetType().GetTypeInfo().GetCustomAttribute<AcceptEmptyServiceProviderAttribute>() == null)
+ serviceProvider = new XamlServiceProvider(node, Context);
+
+ if (serviceProvider != null && propertyName != XmlName.Empty)
+ ((XamlValueTargetProvider)serviceProvider.IProvideValueTarget).TargetProperty = GetTargetProperty(source, propertyName, Context, node);
+
+ if (markupExtension != null)
+ value = markupExtension.ProvideValue(serviceProvider);
+ else if (valueProvider != null)
+ value = valueProvider.ProvideValue(serviceProvider);
+ }
+
+ static string GetContentPropertyName(IEnumerable<CustomAttributeData> attributes)
+ {
+ var contentAttribute =
+ attributes.FirstOrDefault(cad => ContentPropertyAttribute.ContentPropertyTypes.Contains(cad.AttributeType.FullName));
+ if (contentAttribute == null || contentAttribute.ConstructorArguments.Count != 1)
+ return null;
+ if (contentAttribute.ConstructorArguments [0].ArgumentType == typeof(string))
+ return (string)contentAttribute.ConstructorArguments [0].Value;
+ return null;
+ }
+
+ static bool GetRealNameAndType(ref Type elementType, string namespaceURI, ref string localname,
+ HydrationContext context, IXmlLineInfo lineInfo)
+ {
+ var dotIdx = localname.IndexOf('.');
+ if (dotIdx > 0) {
+ var typename = localname.Substring(0, dotIdx);
+ localname = localname.Substring(dotIdx + 1);
+ XamlParseException xpe;
+ elementType = XamlParser.GetElementType(new XmlType(namespaceURI, typename, null), lineInfo,
+ context.RootElement.GetType().GetTypeInfo().Assembly, out xpe);
+
+ if (xpe != null)
+ throw xpe;
+ return true;
+ }
+ return false;
+ }
+
+ static BindableProperty GetBindableProperty(Type elementType, string localName, IXmlLineInfo lineInfo,
+ bool throwOnError = false)
+ {
#if NETSTANDARD1_0
- var bindableFieldInfo = elementType.GetFields().FirstOrDefault(fi => fi.Name == localName + "Property");
+ 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.Public|BindingFlags.FlattenHierarchy).FirstOrDefault(fi => fi.Name == localName + "Property");
#endif
- Exception exception = null;
- if (exception == null && bindableFieldInfo == null) {
- exception =
- new XamlParseException(
- Format("BindableProperty {0} not found on {1}", localName + "Property", elementType.Name), lineInfo);
- }
-
- if (exception == null)
- return bindableFieldInfo.GetValue(null) as BindableProperty;
- if (throwOnError)
- throw exception;
- return null;
- }
-
- static object GetTargetProperty(object xamlelement, XmlName propertyName, HydrationContext context, IXmlLineInfo lineInfo)
- {
- var localName = propertyName.LocalName;
- //If it's an attached BP, update elementType and propertyName
- var bpOwnerType = xamlelement.GetType();
- GetRealNameAndType(ref bpOwnerType, propertyName.NamespaceURI, ref localName, context, lineInfo);
- var property = GetBindableProperty(bpOwnerType, localName, lineInfo, false);
-
- if (property != null)
- return property;
-
- var elementType = xamlelement.GetType();
- var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
- return propertyInfo;
- }
-
- public static void SetPropertyValue(object xamlelement, XmlName propertyName, object value, object rootElement, INode node, HydrationContext context, IXmlLineInfo lineInfo)
- {
- var localName = propertyName.LocalName;
- var serviceProvider = new XamlServiceProvider(node, context);
- Exception xpe = null;
- var xKey = node is IElementNode && ((IElementNode)node).Properties.ContainsKey(XmlName.xKey) ? ((ValueNode)((IElementNode)node).Properties[XmlName.xKey]).Value as string : null;
-
- //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
- if (xpe == null && TryConnectEvent(xamlelement, localName, attached, value, rootElement, lineInfo, out xpe))
- return;
-
- //If Value is DynamicResource and it's a BP, SetDynamicResource
- if (xpe == null && TrySetDynamicResource(xamlelement, property, value, lineInfo, out xpe))
- return;
-
- //If value is BindingBase, SetBinding
- if (xpe == null && TrySetBinding(xamlelement, property, localName, value, lineInfo, out xpe))
- return;
-
- //If it's a BindableProberty, SetValue
- if (xpe == null && TrySetValue(xamlelement, property, attached, value, lineInfo, serviceProvider, out xpe))
- return;
-
- //If we can assign that value to a normal property, let's do it
- if (xpe == null && TrySetProperty(xamlelement, localName, value, lineInfo, serviceProvider, context, out xpe))
- return;
-
- //If it's an already initialized property, add to it
- if (xpe == null && TryAddToProperty(xamlelement, propertyName, value, xKey, lineInfo, serviceProvider, context, out xpe))
- return;
-
- xpe = xpe ?? new XamlParseException($"Cannot assign property \"{localName}\": Property does not exist, or is not assignable, or mismatching type between value and property", lineInfo);
- if (context.ExceptionHandler != null)
- context.ExceptionHandler(xpe);
- else
- throw xpe;
- }
-
- public static object GetPropertyValue(object xamlElement, XmlName propertyName, HydrationContext context, IXmlLineInfo lineInfo, out object targetProperty)
- {
- var localName = propertyName.LocalName;
- Exception xpe = null;
- object value;
- targetProperty = null;
-
- //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 it's a BindableProberty, GetValue
- if (xpe == null && TryGetValue(xamlElement, property, attached, out value, lineInfo, out xpe, out targetProperty))
- return value;
-
- //If it's a normal property, get it
- if (xpe == null && TryGetProperty(xamlElement, localName, out value, lineInfo, context, out xpe, out targetProperty))
- return value;
-
- xpe = xpe ?? new XamlParseException($"Property {localName} is not found or does not have an accessible getter", lineInfo);
- if (context.ExceptionHandler != null)
- context.ExceptionHandler(xpe);
- else
- throw xpe;
-
- return null;
- }
-
- static bool TryConnectEvent(object element, string localName, bool attached, object value, object rootElement, IXmlLineInfo lineInfo, out Exception exception)
- {
- exception = null;
-
- if (attached)
- return false;
-
- var elementType = element.GetType();
- var eventInfo = elementType.GetRuntimeEvent(localName);
- var stringValue = value as string;
-
- if (eventInfo == null || IsNullOrEmpty(stringValue))
- return false;
-
- var methodInfo = rootElement.GetType().GetRuntimeMethods().FirstOrDefault(mi => mi.Name == (string)value);
- if (methodInfo == null) {
- exception = new XamlParseException($"No method {value} found on type {rootElement.GetType()}", lineInfo);
- return false;
- }
-
- try {
- eventInfo.AddEventHandler(element, methodInfo.CreateDelegate(eventInfo.EventHandlerType, rootElement));
- return true;
- } catch (ArgumentException ae) {
- exception = new XamlParseException($"Method {stringValue} does not have the correct signature", lineInfo, ae);
- }
- return false;
- }
-
- static bool TrySetDynamicResource(object element, BindableProperty property, object value, IXmlLineInfo lineInfo, out Exception exception)
- {
- exception = null;
-
- var elementType = element.GetType();
- var dynamicResource = value as DynamicResource;
- var bindable = element as BindableObject;
-
- if (dynamicResource == null || property == null)
- return false;
-
- if (bindable == null) {
- exception = new XamlParseException($"{elementType.Name} is not a BindableObject", lineInfo);
- return false;
- }
-
- bindable.SetDynamicResource(property, dynamicResource.Key);
- return true;
- }
-
- static bool TrySetBinding(object element, BindableProperty property, string localName, object value, IXmlLineInfo lineInfo, out Exception exception)
- {
- exception = null;
-
- var elementType = element.GetType();
- var binding = value.ConvertTo(typeof(BindingBase),pinfoRetriever:null,serviceProvider:null) as BindingBase;
- var bindable = element as BindableObject;
- var nativeBindingService = DependencyService.Get<INativeBindingService>();
-
- if (binding == null)
- return false;
-
- if (bindable != null && property != null) {
- bindable.SetBinding(property, binding);
- return true;
- }
-
- if (nativeBindingService != null && property != null && nativeBindingService.TrySetBinding(element, property, binding))
- return true;
-
- if (nativeBindingService != null && nativeBindingService.TrySetBinding(element, localName, binding))
- return true;
-
- if (property != null)
- exception = new XamlParseException($"{elementType.Name} is not a BindableObject or does not support native bindings", lineInfo);
-
- return false;
- }
-
- static bool TrySetValue(object element, BindableProperty property, bool attached, object value, IXmlLineInfo lineInfo, XamlServiceProvider serviceProvider, out Exception exception)
- {
- exception = null;
-
- var elementType = element.GetType();
- var bindable = element as BindableObject;
- var nativeBindingService = DependencyService.Get<INativeBindingService>();
-
- if (property == null)
- return false;
-
- if (serviceProvider != null && serviceProvider.IProvideValueTarget != null)
- ((XamlValueTargetProvider)serviceProvider.IProvideValueTarget).TargetProperty = property;
-
- Func<MemberInfo> minforetriever;
- if (attached)
- minforetriever = () => property.DeclaringType.GetRuntimeMethod("Get" + property.PropertyName, new [] { typeof(BindableObject) });
- else
- minforetriever = () => property.DeclaringType.GetRuntimeProperty(property.PropertyName);
- var convertedValue = value.ConvertTo(property.ReturnType, minforetriever, serviceProvider);
-
- if (bindable != null) {
- //SetValue doesn't throw on mismatching type, so check before to get a chance to try the property setting or the collection adding
- var nullable = property.ReturnTypeInfo.IsGenericType &&
- property.ReturnTypeInfo.GetGenericTypeDefinition() == typeof(Nullable<>);
- if ((convertedValue == null && (!property.ReturnTypeInfo.IsValueType || nullable)) ||
- (property.ReturnType.IsInstanceOfType(convertedValue))) {
- bindable.SetValue(property, convertedValue);
- return true;
- }
-
- // This might be a collection; see if we can add to it
- return TryAddValue(bindable, property, value, serviceProvider);
- }
-
- if (nativeBindingService != null && nativeBindingService.TrySetValue(element, property, convertedValue))
- return true;
-
- exception = new XamlParseException($"{elementType.Name} is not a BindableObject or does not support setting native BindableProperties", lineInfo);
- return false;
- }
-
- static bool TryGetValue(object element, BindableProperty property, bool attached, out object value, IXmlLineInfo lineInfo, out Exception exception, out object targetProperty)
- {
- exception = null;
- value = null;
- targetProperty = property;
- var elementType = element.GetType();
- var bindable = element as BindableObject;
-
- if (property == null)
- return false;
-
- if (bindable == null)
- return false;
-
- value = bindable.GetValue(property);
- return true;
- }
-
- static bool TrySetProperty(object element, string localName, object value, IXmlLineInfo lineInfo, XamlServiceProvider serviceProvider, HydrationContext context, out Exception exception)
- {
- exception = null;
-
- var elementType = element.GetType();
- var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
- MethodInfo setter;
- if (propertyInfo == null || !propertyInfo.CanWrite || (setter = propertyInfo.SetMethod) == null)
- return false;
-
- if (!IsVisibleFrom(setter, context.RootElement))
- return false;
-
- if (serviceProvider != null && serviceProvider.IProvideValueTarget != null)
- ((XamlValueTargetProvider)serviceProvider.IProvideValueTarget).TargetProperty = propertyInfo;
-
- object convertedValue = value.ConvertTo(propertyInfo.PropertyType, () => propertyInfo, serviceProvider);
- if (convertedValue != null && !propertyInfo.PropertyType.IsInstanceOfType(convertedValue))
- return false;
-
- setter.Invoke(element, new object [] { convertedValue });
- return true;
- }
-
- static bool TryGetProperty(object element, string localName, out object value, IXmlLineInfo lineInfo, HydrationContext context, out Exception exception, out object targetProperty)
- {
- exception = null;
- value = null;
- var elementType = element.GetType();
- PropertyInfo propertyInfo = null;
- try {
- propertyInfo = elementType.GetRuntimeProperty(localName);
- } catch (AmbiguousMatchException) {
- // Get most derived instance of property
- foreach (var property in elementType.GetRuntimeProperties().Where(prop => prop.Name == localName)) {
- if (propertyInfo == null || propertyInfo.DeclaringType.IsAssignableFrom(property.DeclaringType))
- propertyInfo = property;
- }
- }
- MethodInfo getter;
- targetProperty = propertyInfo;
- if (propertyInfo == null || !propertyInfo.CanRead || (getter = propertyInfo.GetMethod) == null)
- return false;
-
- if (!IsVisibleFrom(getter, context.RootElement))
- return false;
-
- value = getter.Invoke(element, new object[] { });
- return true;
- }
-
- static bool IsVisibleFrom(MethodInfo method, object rootElement)
- {
- if (method.IsPublic)
- return true;
- if (method.IsPrivate && method.DeclaringType == rootElement.GetType())
- return true;
- if ((method.IsAssembly || method.IsFamilyOrAssembly) && method.DeclaringType.AssemblyQualifiedName == rootElement.GetType().AssemblyQualifiedName)
- return true;
- if (method.IsFamily && method.DeclaringType.IsAssignableFrom(rootElement.GetType()))
- return true;
- return false;
- }
-
- static bool TryAddToProperty(object element, XmlName propertyName, object value, string xKey, IXmlLineInfo lineInfo, XamlServiceProvider serviceProvider, HydrationContext context, out Exception exception)
- {
- exception = null;
-
- object targetProperty;
- var collection = GetPropertyValue(element, propertyName, context, lineInfo, out targetProperty) as IEnumerable;
-
- if (collection == null)
- return false;
-
- if (exception == null && TryAddToResourceDictionary(collection as ResourceDictionary, value, xKey, lineInfo, out exception))
- return true;
-
- if (exception != null)
- return false;
-
- var addMethod = collection.GetType().GetRuntimeMethods().First(mi => mi.Name == "Add" && mi.GetParameters().Length == 1);
- if (addMethod == null)
- return false;
-
- if (serviceProvider != null)
- ((XamlValueTargetProvider)serviceProvider.IProvideValueTarget).TargetProperty = targetProperty;
-
- addMethod.Invoke(collection, new [] { value.ConvertTo(addMethod.GetParameters() [0].ParameterType, (Func<TypeConverter>)null, serviceProvider) });
- return true;
- }
-
- static bool TryAddToResourceDictionary(ResourceDictionary resourceDictionary, object value, string xKey, IXmlLineInfo lineInfo, out Exception exception)
- {
- exception = null;
-
- if (resourceDictionary == null)
- return false;
-
- if (xKey != null)
- resourceDictionary.Add(xKey, value);
- else if (value is Tizen.NUI.Binding.Style)
- resourceDictionary.Add((Tizen.NUI.Binding.Style)value);
- else if (value is ResourceDictionary)
- resourceDictionary.Add((ResourceDictionary)value);
- else if (value is StyleSheets.StyleSheet)
- resourceDictionary.Add((StyleSheets.StyleSheet)value);
- else {
- exception = new XamlParseException("resources in ResourceDictionary require a x:Key attribute", lineInfo);
- return false;
- }
- return true;
- }
-
- void SetTemplate(ElementTemplate dt, INode node)
- {
+ Exception exception = null;
+ if (exception == null && bindableFieldInfo == null) {
+ exception =
+ new XamlParseException(
+ Format("BindableProperty {0} not found on {1}", localName + "Property", elementType.Name), lineInfo);
+ }
+
+ if (exception == null)
+ return bindableFieldInfo.GetValue(null) as BindableProperty;
+ if (throwOnError)
+ throw exception;
+ return null;
+ }
+
+ static object GetTargetProperty(object xamlelement, XmlName propertyName, HydrationContext context, IXmlLineInfo lineInfo)
+ {
+ var localName = propertyName.LocalName;
+ //If it's an attached BP, update elementType and propertyName
+ var bpOwnerType = xamlelement.GetType();
+ GetRealNameAndType(ref bpOwnerType, propertyName.NamespaceURI, ref localName, context, lineInfo);
+ var property = GetBindableProperty(bpOwnerType, localName, lineInfo, false);
+
+ if (property != null)
+ return property;
+
+ var elementType = xamlelement.GetType();
+ var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
+ return propertyInfo;
+ }
+
+ public static void SetPropertyValue(object xamlelement, XmlName propertyName, object value, object rootElement, INode node, HydrationContext context, IXmlLineInfo lineInfo)
+ {
+ var localName = propertyName.LocalName;
+ var serviceProvider = new XamlServiceProvider(node, context);
+ Exception xpe = null;
+ var xKey = node is IElementNode && ((IElementNode)node).Properties.ContainsKey(XmlName.xKey) ? ((ValueNode)((IElementNode)node).Properties[XmlName.xKey]).Value as string : null;
+
+ //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
+ if (xpe == null && TryConnectEvent(xamlelement, localName, attached, value, rootElement, lineInfo, out xpe))
+ return;
+
+ //If Value is DynamicResource and it's a BP, SetDynamicResource
+ if (xpe == null && TrySetDynamicResource(xamlelement, property, value, lineInfo, out xpe))
+ return;
+
+ //If value is BindingBase, SetBinding
+ if (xpe == null && TrySetBinding(xamlelement, property, localName, value, lineInfo, out xpe))
+ return;
+
+ //If it's a BindableProberty, SetValue
+ if (xpe == null && TrySetValue(xamlelement, property, attached, value, lineInfo, serviceProvider, out xpe))
+ return;
+
+ //If we can assign that value to a normal property, let's do it
+ if (xpe == null && TrySetProperty(xamlelement, localName, value, lineInfo, serviceProvider, context, out xpe))
+ return;
+
+ //If it's an already initialized property, add to it
+ if (xpe == null && TryAddToProperty(xamlelement, propertyName, value, xKey, lineInfo, serviceProvider, context, out xpe))
+ return;
+
+ xpe = xpe ?? new XamlParseException($"Cannot assign property \"{localName}\": Property does not exist, or is not assignable, or mismatching type between value and property", lineInfo);
+ if (context.ExceptionHandler != null)
+ context.ExceptionHandler(xpe);
+ else
+ throw xpe;
+ }
+
+ public static object GetPropertyValue(object xamlElement, XmlName propertyName, HydrationContext context, IXmlLineInfo lineInfo, out object targetProperty)
+ {
+ var localName = propertyName.LocalName;
+ Exception xpe = null;
+ object value;
+ targetProperty = null;
+
+ //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 it's a BindableProberty, GetValue
+ if (xpe == null && TryGetValue(xamlElement, property, attached, out value, lineInfo, out xpe, out targetProperty))
+ return value;
+
+ //If it's a normal property, get it
+ if (xpe == null && TryGetProperty(xamlElement, localName, out value, lineInfo, context, out xpe, out targetProperty))
+ return value;
+
+ xpe = xpe ?? new XamlParseException($"Property {localName} is not found or does not have an accessible getter", lineInfo);
+ if (context.ExceptionHandler != null)
+ context.ExceptionHandler(xpe);
+ else
+ throw xpe;
+
+ return null;
+ }
+
+ static bool TryConnectEvent(object element, string localName, bool attached, object value, object rootElement, IXmlLineInfo lineInfo, out Exception exception)
+ {
+ exception = null;
+
+ if (attached)
+ return false;
+
+ var elementType = element.GetType();
+ var eventInfo = elementType.GetRuntimeEvent(localName);
+ var stringValue = value as string;
+
+ if (eventInfo == null || IsNullOrEmpty(stringValue))
+ return false;
+
+ var methodInfo = rootElement.GetType().GetRuntimeMethods().FirstOrDefault(mi => mi.Name == (string)value);
+ if (methodInfo == null) {
+ exception = new XamlParseException($"No method {value} found on type {rootElement.GetType()}", lineInfo);
+ return false;
+ }
+
+ try {
+ eventInfo.AddEventHandler(element, methodInfo.CreateDelegate(eventInfo.EventHandlerType, rootElement));
+ return true;
+ } catch (ArgumentException ae) {
+ exception = new XamlParseException($"Method {stringValue} does not have the correct signature", lineInfo, ae);
+ }
+ return false;
+ }
+
+ static bool TrySetDynamicResource(object element, BindableProperty property, object value, IXmlLineInfo lineInfo, out Exception exception)
+ {
+ exception = null;
+
+ var elementType = element.GetType();
+ var dynamicResource = value as DynamicResource;
+ var bindable = element as BindableObject;
+
+ if (dynamicResource == null || property == null)
+ return false;
+
+ if (bindable == null) {
+ exception = new XamlParseException($"{elementType.Name} is not a BindableObject", lineInfo);
+ return false;
+ }
+
+ bindable.SetDynamicResource(property, dynamicResource.Key);
+ return true;
+ }
+
+ static bool TrySetBinding(object element, BindableProperty property, string localName, object value, IXmlLineInfo lineInfo, out Exception exception)
+ {
+ exception = null;
+
+ var elementType = element.GetType();
+ var binding = value.ConvertTo(typeof(BindingBase),pinfoRetriever:null,serviceProvider:null) as BindingBase;
+ var bindable = element as BindableObject;
+ var nativeBindingService = DependencyService.Get<INativeBindingService>();
+
+ if (binding == null)
+ return false;
+
+ if (bindable != null && property != null) {
+ bindable.SetBinding(property, binding);
+ return true;
+ }
+
+ if (nativeBindingService != null && property != null && nativeBindingService.TrySetBinding(element, property, binding))
+ return true;
+
+ if (nativeBindingService != null && nativeBindingService.TrySetBinding(element, localName, binding))
+ return true;
+
+ if (property != null)
+ exception = new XamlParseException($"{elementType.Name} is not a BindableObject or does not support native bindings", lineInfo);
+
+ return false;
+ }
+
+ static bool TrySetValue(object element, BindableProperty property, bool attached, object value, IXmlLineInfo lineInfo, XamlServiceProvider serviceProvider, out Exception exception)
+ {
+ exception = null;
+
+ var elementType = element.GetType();
+ var bindable = element as BindableObject;
+ var nativeBindingService = DependencyService.Get<INativeBindingService>();
+
+ if (property == null)
+ return false;
+
+ if (serviceProvider != null && serviceProvider.IProvideValueTarget != null)
+ ((XamlValueTargetProvider)serviceProvider.IProvideValueTarget).TargetProperty = property;
+
+ Func<MemberInfo> minforetriever;
+ if (attached)
+ minforetriever = () => property.DeclaringType.GetRuntimeMethod("Get" + property.PropertyName, new [] { typeof(BindableObject) });
+ else
+ {
+ minforetriever = () => property.DeclaringType.GetRuntimeProperties().LastOrDefault(p => p.Name == property.PropertyName);
+ }
+ //minforetriever = () => property.DeclaringType.GetRuntimeProperty(property.PropertyName);
+ var convertedValue = value.ConvertTo(property.ReturnType, minforetriever, serviceProvider);
+
+ if (bindable != null) {
+ //SetValue doesn't throw on mismatching type, so check before to get a chance to try the property setting or the collection adding
+ var nullable = property.ReturnTypeInfo.IsGenericType &&
+ property.ReturnTypeInfo.GetGenericTypeDefinition() == typeof(Nullable<>);
+ if ((convertedValue == null && (!property.ReturnTypeInfo.IsValueType || nullable)) ||
+ (property.ReturnType.IsInstanceOfType(convertedValue))) {
+ bindable.SetValue(property, convertedValue);
+ return true;
+ }
+
+ // This might be a collection; see if we can add to it
+ return TryAddValue(bindable, property, value, serviceProvider);
+ }
+
+ if (nativeBindingService != null && nativeBindingService.TrySetValue(element, property, convertedValue))
+ return true;
+
+ exception = new XamlParseException($"{elementType.Name} is not a BindableObject or does not support setting native BindableProperties", lineInfo);
+ return false;
+ }
+
+ static bool TryGetValue(object element, BindableProperty property, bool attached, out object value, IXmlLineInfo lineInfo, out Exception exception, out object targetProperty)
+ {
+ exception = null;
+ value = null;
+ targetProperty = property;
+ var elementType = element.GetType();
+ var bindable = element as BindableObject;
+
+ if (property == null)
+ return false;
+
+ if (bindable == null)
+ return false;
+
+ value = bindable.GetValue(property);
+ return true;
+ }
+
+ static bool TrySetProperty(object element, string localName, object value, IXmlLineInfo lineInfo, XamlServiceProvider serviceProvider, HydrationContext context, out Exception exception)
+ {
+ exception = null;
+
+ var elementType = element.GetType();
+ var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
+ MethodInfo setter;
+ if (propertyInfo == null || !propertyInfo.CanWrite || (setter = propertyInfo.SetMethod) == null)
+ return false;
+
+ if (!IsVisibleFrom(setter, context.RootElement))
+ return false;
+
+ if (serviceProvider != null && serviceProvider.IProvideValueTarget != null)
+ ((XamlValueTargetProvider)serviceProvider.IProvideValueTarget).TargetProperty = propertyInfo;
+
+ object convertedValue = value.ConvertTo(propertyInfo.PropertyType, () => propertyInfo, serviceProvider);
+ if (convertedValue != null && !propertyInfo.PropertyType.IsInstanceOfType(convertedValue))
+ return false;
+
+ setter.Invoke(element, new object [] { convertedValue });
+ return true;
+ }
+
+ static bool TryGetProperty(object element, string localName, out object value, IXmlLineInfo lineInfo, HydrationContext context, out Exception exception, out object targetProperty)
+ {
+ exception = null;
+ value = null;
+ var elementType = element.GetType();
+ PropertyInfo propertyInfo = null;
+ try {
+ propertyInfo = elementType.GetRuntimeProperty(localName);
+ } catch (AmbiguousMatchException) {
+ // Get most derived instance of property
+ foreach (var property in elementType.GetRuntimeProperties().Where(prop => prop.Name == localName)) {
+ if (propertyInfo == null || propertyInfo.DeclaringType.IsAssignableFrom(property.DeclaringType))
+ propertyInfo = property;
+ }
+ }
+ MethodInfo getter;
+ targetProperty = propertyInfo;
+ if (propertyInfo == null || !propertyInfo.CanRead || (getter = propertyInfo.GetMethod) == null)
+ return false;
+
+ if (!IsVisibleFrom(getter, context.RootElement))
+ return false;
+
+ value = getter.Invoke(element, new object[] { });
+ return true;
+ }
+
+ static bool IsVisibleFrom(MethodInfo method, object rootElement)
+ {
+ if (method.IsPublic)
+ return true;
+ if (method.IsPrivate && method.DeclaringType == rootElement.GetType())
+ return true;
+ if ((method.IsAssembly || method.IsFamilyOrAssembly) && method.DeclaringType.AssemblyQualifiedName == rootElement.GetType().AssemblyQualifiedName)
+ return true;
+ if (method.IsFamily && method.DeclaringType.IsAssignableFrom(rootElement.GetType()))
+ return true;
+ return false;
+ }
+
+ static bool TryAddToProperty(object element, XmlName propertyName, object value, string xKey, IXmlLineInfo lineInfo, XamlServiceProvider serviceProvider, HydrationContext context, out Exception exception)
+ {
+ exception = null;
+
+ object targetProperty;
+ var collection = GetPropertyValue(element, propertyName, context, lineInfo, out targetProperty) as IEnumerable;
+
+ if (collection == null)
+ return false;
+
+ if (exception == null && TryAddToResourceDictionary(collection as ResourceDictionary, value, xKey, lineInfo, out exception))
+ return true;
+
+ if (exception != null)
+ return false;
+
+ var addMethod = collection.GetType().GetRuntimeMethods().First(mi => mi.Name == "Add" && mi.GetParameters().Length == 1);
+ if (addMethod == null)
+ return false;
+
+ if (serviceProvider != null)
+ ((XamlValueTargetProvider)serviceProvider.IProvideValueTarget).TargetProperty = targetProperty;
+
+ addMethod.Invoke(collection, new [] { value.ConvertTo(addMethod.GetParameters() [0].ParameterType, (Func<TypeConverter>)null, serviceProvider) });
+ return true;
+ }
+
+ static bool TryAddToResourceDictionary(ResourceDictionary resourceDictionary, object value, string xKey, IXmlLineInfo lineInfo, out Exception exception)
+ {
+ exception = null;
+
+ if (resourceDictionary == null)
+ return false;
+
+ if (xKey != null)
+ resourceDictionary.Add(xKey, value);
+ else if (value is Tizen.NUI.Binding.Style)
+ resourceDictionary.Add((Tizen.NUI.Binding.Style)value);
+ else if (value is ResourceDictionary)
+ resourceDictionary.Add((ResourceDictionary)value);
+ else if (value is StyleSheets.StyleSheet)
+ resourceDictionary.Add((StyleSheets.StyleSheet)value);
+ else {
+ exception = new XamlParseException("resources in ResourceDictionary require a x:Key attribute", lineInfo);
+ return false;
+ }
+ return true;
+ }
+
+ void SetTemplate(ElementTemplate dt, INode node)
+ {
#pragma warning disable 0612
- ((IDataTemplate)dt).LoadTemplate = () => {
+ ((IDataTemplate)dt).LoadTemplate = () => {
#pragma warning restore 0612
- var cnode = node.Clone();
- var context = new HydrationContext { ParentContext = Context, RootElement = Context.RootElement };
- cnode.Accept(new XamlNodeVisitor((n, parent) => n.Parent = parent), node.Parent); //set parents for {StaticResource}
- cnode.Accept(new ExpandMarkupsVisitor(context), null);
- cnode.Accept(new NamescopingVisitor(context), null);
- cnode.Accept(new CreateValuesVisitor(context), null);
- cnode.Accept(new RegisterXNamesVisitor(context), null);
- cnode.Accept(new FillResourceDictionariesVisitor(context), null);
- cnode.Accept(new ApplyPropertiesVisitor(context, true), null);
- return context.Values [cnode];
- };
- }
-
- static bool TryAddValue(BindableObject bindable, BindableProperty property, object value, XamlServiceProvider serviceProvider)
- {
- if(property?.ReturnTypeInfo?.GenericTypeArguments == null){
- return false;
- }
-
- if(property.ReturnType == null){
- return false;
- }
-
- if (property.ReturnTypeInfo.GenericTypeArguments.Length != 1 ||
- !property.ReturnTypeInfo.GenericTypeArguments[0].IsInstanceOfType(value))
- return false;
-
- // This might be a collection we can add to; see if we can find an Add method
- var addMethod = GetAllRuntimeMethods(property.ReturnType)
- .FirstOrDefault(mi => mi.Name == "Add" && mi.GetParameters().Length == 1);
- if (addMethod == null)
- return false;
-
- // If there's an add method, get the collection
- var collection = bindable.GetValue(property);
-
- // And add the new value to it
- addMethod.Invoke(collection, new[] { value.ConvertTo(addMethod.GetParameters()[0].ParameterType, (Func<TypeConverter>)null, serviceProvider) });
- return true;
- }
-
- static IEnumerable<MethodInfo> GetAllRuntimeMethods(Type type)
- {
- return type.GetRuntimeMethods()
- .Concat(type.GetTypeInfo().ImplementedInterfaces.SelectMany(t => t.GetRuntimeMethods()));
- }
-
- bool TrySetRuntimeName(XmlName propertyName, object source, object value, ValueNode node)
- {
- if (propertyName != XmlName.xName)
- return false;
-
- var runTimeName = source.GetType().GetTypeInfo().GetCustomAttribute<RuntimeNamePropertyAttribute>();
- if (runTimeName == null)
- return false;
-
- SetPropertyValue(source, new XmlName("", runTimeName.Name), value, Context.RootElement, node, Context, node);
- return true;
- }
- }
+ var cnode = node.Clone();
+ var context = new HydrationContext { ParentContext = Context, RootElement = Context.RootElement };
+ cnode.Accept(new XamlNodeVisitor((n, parent) => n.Parent = parent), node.Parent); //set parents for {StaticResource}
+ cnode.Accept(new ExpandMarkupsVisitor(context), null);
+ cnode.Accept(new NamescopingVisitor(context), null);
+ cnode.Accept(new CreateValuesVisitor(context), null);
+ cnode.Accept(new RegisterXNamesVisitor(context), null);
+ cnode.Accept(new FillResourceDictionariesVisitor(context), null);
+ cnode.Accept(new ApplyPropertiesVisitor(context, true), null);
+ return context.Values [cnode];
+ };
+ }
+
+ static bool TryAddValue(BindableObject bindable, BindableProperty property, object value, XamlServiceProvider serviceProvider)
+ {
+ if(property?.ReturnTypeInfo?.GenericTypeArguments == null){
+ return false;
+ }
+
+ if(property.ReturnType == null){
+ return false;
+ }
+
+ if (property.ReturnTypeInfo.GenericTypeArguments.Length != 1 ||
+ !property.ReturnTypeInfo.GenericTypeArguments[0].IsInstanceOfType(value))
+ return false;
+
+ // This might be a collection we can add to; see if we can find an Add method
+ var addMethod = GetAllRuntimeMethods(property.ReturnType)
+ .FirstOrDefault(mi => mi.Name == "Add" && mi.GetParameters().Length == 1);
+ if (addMethod == null)
+ return false;
+
+ // If there's an add method, get the collection
+ var collection = bindable.GetValue(property);
+
+ // And add the new value to it
+ addMethod.Invoke(collection, new[] { value.ConvertTo(addMethod.GetParameters()[0].ParameterType, (Func<TypeConverter>)null, serviceProvider) });
+ return true;
+ }
+
+ static IEnumerable<MethodInfo> GetAllRuntimeMethods(Type type)
+ {
+ return type.GetRuntimeMethods()
+ .Concat(type.GetTypeInfo().ImplementedInterfaces.SelectMany(t => t.GetRuntimeMethods()));
+ }
+
+ bool TrySetRuntimeName(XmlName propertyName, object source, object value, ValueNode node)
+ {
+ if (propertyName != XmlName.xName)
+ return false;
+
+ var runTimeName = source.GetType().GetTypeInfo().GetCustomAttribute<RuntimeNamePropertyAttribute>();
+ if (runTimeName == null)
+ return false;
+
+ SetPropertyValue(source, new XmlName("", runTimeName.Name), value, Context.RootElement, node, Context, node);
+ return true;
+ }
+ }
}
using System.Linq;
using System.Reflection;
using System.Xml;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI.Binding;
namespace Tizen.NUI.Xaml
{
- class CreateValuesVisitor : IXamlNodeVisitor
- {
- public CreateValuesVisitor(HydrationContext context)
- {
- Context = context;
- }
-
- Dictionary<INode, object> Values
- {
- get { return Context.Values; }
- }
-
- HydrationContext Context { get; }
-
- public TreeVisitingMode VisitingMode => TreeVisitingMode.BottomUp;
- public bool StopOnDataTemplate => true;
- public bool StopOnResourceDictionary => false;
- public bool VisitNodeOnDataTemplate => false;
- public bool SkipChildren(INode node, INode parentNode) => false;
-
- public void Visit(ValueNode node, INode parentNode)
- {
- Values[node] = node.Value;
- }
-
- public void Visit(MarkupNode node, INode parentNode)
- {
- }
-
- public void Visit(ElementNode node, INode parentNode)
- {
- object value = null;
-
- XamlParseException xpe;
- var type = XamlParser.GetElementType(node.XmlType, node, Context.RootElement?.GetType().GetTypeInfo().Assembly,
- out xpe);
- if (xpe != null)
- throw xpe;
-
- Context.Types[node] = type;
- string ctorargname;
- if (IsXaml2009LanguagePrimitive(node))
- value = CreateLanguagePrimitive(type, node);
- else if (node.Properties.ContainsKey(XmlName.xArguments) || node.Properties.ContainsKey(XmlName.xFactoryMethod))
- value = CreateFromFactory(type, node);
- else if (
- type.GetTypeInfo()
- .DeclaredConstructors.Any(
- ci =>
- ci.IsPublic && ci.GetParameters().Length != 0 &&
- ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute)))) &&
- ValidateCtorArguments(type, node, out ctorargname))
- value = CreateFromParameterizedConstructor(type, node);
- else if (!type.GetTypeInfo().DeclaredConstructors.Any(ci => ci.IsPublic && ci.GetParameters().Length == 0) &&
- !ValidateCtorArguments(type, node, out ctorargname))
- {
- throw new XamlParseException($"The Property {ctorargname} is required to create a {type?.FullName} object.", node);
- }
- else
- {
- //this is a trick as the DataTemplate parameterless ctor is internal, and we can't CreateInstance(..., false) on WP7
- try
- {
- if (type == typeof (DataTemplate))
- value = new DataTemplate();
- if (type == typeof (ControlTemplate))
- value = new ControlTemplate();
- if (value == null && node.CollectionItems.Any() && node.CollectionItems.First() is ValueNode)
- {
- var serviceProvider = new XamlServiceProvider(node, Context);
- var converted = ((ValueNode)node.CollectionItems.First()).Value.ConvertTo(type, () => type.GetTypeInfo(),
- serviceProvider);
- if (converted != null && converted.GetType() == type)
- value = converted;
- }
- if (value == null)
- value = Activator.CreateInstance(type);
- }
- catch (TargetInvocationException e)
- {
- if (e.InnerException is XamlParseException || e.InnerException is XmlException)
- throw e.InnerException;
- throw;
- }
- }
-
- Values[node] = value;
-
- var markup = value as IMarkupExtension;
- if (markup != null && (value is TypeExtension || value is StaticExtension || value is ArrayExtension))
- {
- var serviceProvider = new XamlServiceProvider(node, Context);
-
- var visitor = new ApplyPropertiesVisitor(Context);
- foreach (var cnode in node.Properties.Values.ToList())
- cnode.Accept(visitor, node);
- foreach (var cnode in node.CollectionItems)
- cnode.Accept(visitor, node);
-
- value = markup.ProvideValue(serviceProvider);
-
- INode xKey;
- if (!node.Properties.TryGetValue(XmlName.xKey, out xKey))
- xKey = null;
-
- node.Properties.Clear();
- node.CollectionItems.Clear();
-
- if (xKey != null)
- node.Properties.Add(XmlName.xKey, xKey);
-
- Values[node] = value;
- }
-
- if (value is BindableObject)
- NameScope.SetNameScope(value as BindableObject, node.Namescope);
- }
-
- public void Visit(RootNode node, INode parentNode)
- {
- var rnode = (XamlLoader.RuntimeRootNode)node;
- Values[node] = rnode.Root;
- Context.Types[node] = rnode.Root.GetType();
- var bindableRoot = rnode.Root as BindableObject;
- if (bindableRoot != null)
- NameScope.SetNameScope(bindableRoot, node.Namescope);
- }
-
- public void Visit(ListNode node, INode parentNode)
- {
- //this is a gross hack to keep ListNode alive. ListNode must go in favor of Properties
- XmlName name;
- if (ApplyPropertiesVisitor.TryGetPropertyName(node, parentNode, out name))
- node.XmlName = name;
- }
-
- bool ValidateCtorArguments(Type nodeType, IElementNode node, out string missingArgName)
- {
- missingArgName = null;
- var ctorInfo =
- nodeType.GetTypeInfo()
- .DeclaredConstructors.FirstOrDefault(
- ci =>
- ci.GetParameters().Length != 0 && ci.IsPublic &&
- ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute))));
- if (ctorInfo == null)
- return true;
- foreach (var parameter in ctorInfo.GetParameters())
- {
+ internal class CreateValuesVisitor : IXamlNodeVisitor
+ {
+ public CreateValuesVisitor(HydrationContext context)
+ {
+ Context = context;
+ }
+
+ Dictionary<INode, object> Values
+ {
+ get { return Context.Values; }
+ }
+
+ HydrationContext Context { get; }
+
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.BottomUp;
+ public bool StopOnDataTemplate => true;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => false;
+ public bool SkipChildren(INode node, INode parentNode) => false;
+
+ public void Visit(ValueNode node, INode parentNode)
+ {
+ Values[node] = node.Value;
+ }
+
+ public void Visit(MarkupNode node, INode parentNode)
+ {
+ }
+
+ public void Visit(ElementNode node, INode parentNode)
+ {
+ object value = null;
+
+ XamlParseException xpe;
+ var type = XamlParser.GetElementType(node.XmlType, node, Context.RootElement?.GetType().GetTypeInfo().Assembly,
+ out xpe);
+ if (xpe != null)
+ throw xpe;
+
+ Context.Types[node] = type;
+ string ctorargname;
+ if (IsXaml2009LanguagePrimitive(node))
+ value = CreateLanguagePrimitive(type, node);
+ else if (node.Properties.ContainsKey(XmlName.xArguments) || node.Properties.ContainsKey(XmlName.xFactoryMethod))
+ value = CreateFromFactory(type, node);
+ else if (
+ type.GetTypeInfo()
+ .DeclaredConstructors.Any(
+ ci =>
+ ci.IsPublic && ci.GetParameters().Length != 0 &&
+ ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute)))) &&
+ ValidateCtorArguments(type, node, out ctorargname))
+ value = CreateFromParameterizedConstructor(type, node);
+ else if (!type.GetTypeInfo().DeclaredConstructors.Any(ci => ci.IsPublic && ci.GetParameters().Length == 0) &&
+ !ValidateCtorArguments(type, node, out ctorargname))
+ {
+ throw new XamlParseException($"The Property {ctorargname} is required to create a {type?.FullName} object.", node);
+ }
+ else
+ {
+ //this is a trick as the DataTemplate parameterless ctor is internal, and we can't CreateInstance(..., false) on WP7
+ try
+ {
+ if (type == typeof (DataTemplate))
+ value = new DataTemplate();
+ if (type == typeof (ControlTemplate))
+ value = new ControlTemplate();
+ if (value == null && node.CollectionItems.Any() && node.CollectionItems.First() is ValueNode)
+ {
+ var serviceProvider = new XamlServiceProvider(node, Context);
+ var converted = ((ValueNode)node.CollectionItems.First()).Value.ConvertTo(type, () => type.GetTypeInfo(),
+ serviceProvider);
+ if (converted != null && converted.GetType() == type)
+ value = converted;
+ }
+ if (value == null)
+ {
+ value = Activator.CreateInstance(type);
+ if (value is BindableObject)
+ {
+ ((BindableObject)value).isCreateByXaml = true;
+ }
+ }
+ }
+ catch (TargetInvocationException e)
+ {
+ if (e.InnerException is XamlParseException || e.InnerException is XmlException)
+ throw e.InnerException;
+ throw;
+ }
+ }
+
+ Values[node] = value;
+
+ var markup = value as IMarkupExtension;
+ if (markup != null && (value is TypeExtension || value is StaticExtension || value is ArrayExtension))
+ {
+ var serviceProvider = new XamlServiceProvider(node, Context);
+
+ var visitor = new ApplyPropertiesVisitor(Context);
+ foreach (var cnode in node.Properties.Values.ToList())
+ cnode.Accept(visitor, node);
+ foreach (var cnode in node.CollectionItems)
+ cnode.Accept(visitor, node);
+
+ value = markup.ProvideValue(serviceProvider);
+
+ INode xKey;
+ if (!node.Properties.TryGetValue(XmlName.xKey, out xKey))
+ xKey = null;
+
+ node.Properties.Clear();
+ node.CollectionItems.Clear();
+
+ if (xKey != null)
+ node.Properties.Add(XmlName.xKey, xKey);
+
+ Values[node] = value;
+ }
+
+ if (value is BindableObject)
+ NameScope.SetNameScope(value as BindableObject, node.Namescope);
+ }
+
+ public void Visit(RootNode node, INode parentNode)
+ {
+ var rnode = (XamlLoader.RuntimeRootNode)node;
+ Values[node] = rnode.Root;
+ Context.Types[node] = rnode.Root.GetType();
+ var bindableRoot = rnode.Root as BindableObject;
+ if (bindableRoot != null)
+ NameScope.SetNameScope(bindableRoot, node.Namescope);
+ }
+
+ public void Visit(ListNode node, INode parentNode)
+ {
+ //this is a gross hack to keep ListNode alive. ListNode must go in favor of Properties
+ XmlName name;
+ if (ApplyPropertiesVisitor.TryGetPropertyName(node, parentNode, out name))
+ node.XmlName = name;
+ }
+
+ bool ValidateCtorArguments(Type nodeType, IElementNode node, out string missingArgName)
+ {
+ missingArgName = null;
+ var ctorInfo =
+ nodeType.GetTypeInfo()
+ .DeclaredConstructors.FirstOrDefault(
+ ci =>
+ ci.GetParameters().Length != 0 && ci.IsPublic &&
+ ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute))));
+ if (ctorInfo == null)
+ return true;
+ foreach (var parameter in ctorInfo.GetParameters())
+ {
// Modify the namespace
- var propname =
- parameter.CustomAttributes.First(ca => ca.AttributeType.FullName == "Tizen.NUI.Binding.ParameterAttribute")
- .ConstructorArguments.First()
- .Value as string;
- if (!node.Properties.ContainsKey(new XmlName("", propname)))
- {
- missingArgName = propname;
- return false;
- }
- }
-
- return true;
- }
-
- public object CreateFromParameterizedConstructor(Type nodeType, IElementNode node)
- {
- var ctorInfo =
- nodeType.GetTypeInfo()
- .DeclaredConstructors.FirstOrDefault(
- ci =>
- ci.GetParameters().Length != 0 && ci.IsPublic &&
- ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute))));
- object[] arguments = CreateArgumentsArray(node, ctorInfo);
- return ctorInfo.Invoke(arguments);
- }
-
- public object CreateFromFactory(Type nodeType, IElementNode node)
- {
- object[] arguments = CreateArgumentsArray(node);
-
- if (!node.Properties.ContainsKey(XmlName.xFactoryMethod))
- {
- //non-default ctor
- return Activator.CreateInstance(nodeType, arguments);
- }
-
- var factoryMethod = ((string)((ValueNode)node.Properties[XmlName.xFactoryMethod]).Value);
- Type[] types = arguments == null ? new Type[0] : arguments.Select(a => a.GetType()).ToArray();
- Func<MethodInfo, bool> isMatch = m => {
- if (m.Name != factoryMethod)
- return false;
- var p = m.GetParameters();
- if (p.Length != types.Length)
- return false;
- if (!m.IsStatic)
- return false;
- for (var i = 0; i < p.Length; i++) {
- if ((p [i].ParameterType.IsAssignableFrom(types [i])))
- continue;
- var op_impl = p[i].ParameterType.GetImplicitConversionOperator(fromType: types[i], toType: p[i].ParameterType)
- ?? types[i].GetImplicitConversionOperator(fromType: types[i], toType: p[i].ParameterType);
-
- if (op_impl == null)
- return false;
- arguments [i] = op_impl.Invoke(null, new [] { arguments [i]});
- }
- return true;
- };
- var mi = nodeType.GetRuntimeMethods().FirstOrDefault(isMatch);
- if (mi == null)
- throw new MissingMemberException($"No static method found for {nodeType.FullName}::{factoryMethod} ({string.Join(", ", types.Select(t => t.FullName))})");
- return mi.Invoke(null, arguments);
- }
-
- public object[] CreateArgumentsArray(IElementNode enode)
- {
- if (!enode.Properties.ContainsKey(XmlName.xArguments))
- return null;
- var node = enode.Properties[XmlName.xArguments];
- var elementNode = node as ElementNode;
- if (elementNode != null)
- {
- var array = new object[1];
- array[0] = Values[elementNode];
- return array;
- }
-
- var listnode = node as ListNode;
- if (listnode != null)
- {
- var array = new object[listnode.CollectionItems.Count];
- for (var i = 0; i < listnode.CollectionItems.Count; i++)
- array[i] = Values[(ElementNode)listnode.CollectionItems[i]];
- return array;
- }
- return null;
- }
-
- public object[] CreateArgumentsArray(IElementNode enode, ConstructorInfo ctorInfo)
- {
- var n = ctorInfo.GetParameters().Length;
- var array = new object[n];
- for (var i = 0; i < n; i++)
- {
- var parameter = ctorInfo.GetParameters()[i];
- var propname =
- parameter.CustomAttributes.First(attr => attr.AttributeType == typeof (ParameterAttribute))
- .ConstructorArguments.First()
- .Value as string;
- var name = new XmlName("", propname);
- INode node;
- if (!enode.Properties.TryGetValue(name, out node))
- {
- throw new XamlParseException(
- String.Format("The Property {0} is required to create a {1} object.", propname, ctorInfo.DeclaringType.FullName),
- enode as IXmlLineInfo);
- }
- if (!enode.SkipProperties.Contains(name))
- enode.SkipProperties.Add(name);
- var value = Context.Values[node];
- var serviceProvider = new XamlServiceProvider(enode, Context);
- var convertedValue = value.ConvertTo(parameter.ParameterType, () => parameter, serviceProvider);
- array[i] = convertedValue;
- }
-
- return array;
- }
-
- static bool IsXaml2009LanguagePrimitive(IElementNode node)
- {
- return node.NamespaceURI == XamlParser.X2009Uri;
- }
-
- static object CreateLanguagePrimitive(Type nodeType, IElementNode node)
- {
- object value = null;
- if (nodeType == typeof (string))
- value = String.Empty;
- else if (nodeType == typeof (Uri))
- value = null;
- else
- value = Activator.CreateInstance(nodeType);
-
- if (node.CollectionItems.Count == 1 && node.CollectionItems[0] is ValueNode &&
- ((ValueNode)node.CollectionItems[0]).Value is string)
- {
- var valuestring = ((ValueNode)node.CollectionItems[0]).Value as string;
-
- if (nodeType == typeof(SByte)) {
- sbyte retval;
- if (sbyte.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof(Int16)) {
- short retval;
- if (short.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof(Int32)) {
- int retval;
- if (int.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof(Int64)) {
- long retval;
- if (long.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof(Byte)) {
- byte retval;
- if (byte.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof(UInt16)) {
- ushort retval;
- if (ushort.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof(UInt32)) {
- uint retval;
- if (uint.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof(UInt64)) {
- ulong retval;
- if (ulong.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof(Single)) {
- float retval;
- if (float.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof(Double)) {
- double retval;
- if (double.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof (Boolean))
- {
- bool outbool;
- if (bool.TryParse(valuestring, out outbool))
- return outbool;
- }
- if (nodeType == typeof(TimeSpan)) {
- TimeSpan retval;
- if (TimeSpan.TryParse(valuestring, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
- if (nodeType == typeof (char))
- {
- char retval;
- if (char.TryParse(valuestring, out retval))
- return retval;
- }
- if (nodeType == typeof (string))
- return valuestring;
- if (nodeType == typeof (decimal))
- {
- decimal retval;
- if (decimal.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
- return retval;
- }
-
- else if (nodeType == typeof (Uri))
- {
- Uri retval;
- if (Uri.TryCreate(valuestring, UriKind.RelativeOrAbsolute, out retval))
- return retval;
- }
- }
- return value;
- }
- }
+ var propname =
+ parameter.CustomAttributes.First(ca => ca.AttributeType.FullName == "Tizen.NUI.Binding.ParameterAttribute")
+ .ConstructorArguments.First()
+ .Value as string;
+ if (!node.Properties.ContainsKey(new XmlName("", propname)))
+ {
+ missingArgName = propname;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public object CreateFromParameterizedConstructor(Type nodeType, IElementNode node)
+ {
+ var ctorInfo =
+ nodeType.GetTypeInfo()
+ .DeclaredConstructors.FirstOrDefault(
+ ci =>
+ ci.GetParameters().Length != 0 && ci.IsPublic &&
+ ci.GetParameters().All(pi => pi.CustomAttributes.Any(attr => attr.AttributeType == typeof (ParameterAttribute))));
+ object[] arguments = CreateArgumentsArray(node, ctorInfo);
+ return ctorInfo.Invoke(arguments);
+ }
+
+ public object CreateFromFactory(Type nodeType, IElementNode node)
+ {
+ object[] arguments = CreateArgumentsArray(node);
+
+ if (!node.Properties.ContainsKey(XmlName.xFactoryMethod))
+ {
+ //non-default ctor
+ object ret = Activator.CreateInstance(nodeType, arguments);
+ if (ret is BindableObject)
+ {
+ ((BindableObject)ret).isCreateByXaml = true;
+ }
+ return ret;
+ }
+
+ var factoryMethod = ((string)((ValueNode)node.Properties[XmlName.xFactoryMethod]).Value);
+ Type[] types = arguments == null ? new Type[0] : arguments.Select(a => a.GetType()).ToArray();
+ Func<MethodInfo, bool> isMatch = m => {
+ if (m.Name != factoryMethod)
+ return false;
+ var p = m.GetParameters();
+ if (p.Length != types.Length)
+ return false;
+ if (!m.IsStatic)
+ return false;
+ for (var i = 0; i < p.Length; i++) {
+ if ((p [i].ParameterType.IsAssignableFrom(types [i])))
+ continue;
+ var op_impl = p[i].ParameterType.GetImplicitConversionOperator(fromType: types[i], toType: p[i].ParameterType)
+ ?? types[i].GetImplicitConversionOperator(fromType: types[i], toType: p[i].ParameterType);
+
+ if (op_impl == null)
+ return false;
+ arguments [i] = op_impl.Invoke(null, new [] { arguments [i]});
+ }
+ return true;
+ };
+ var mi = nodeType.GetRuntimeMethods().FirstOrDefault(isMatch);
+ if (mi == null)
+ throw new MissingMemberException($"No static method found for {nodeType.FullName}::{factoryMethod} ({string.Join(", ", types.Select(t => t.FullName))})");
+ return mi.Invoke(null, arguments);
+ }
+
+ public object[] CreateArgumentsArray(IElementNode enode)
+ {
+ if (!enode.Properties.ContainsKey(XmlName.xArguments))
+ return null;
+ var node = enode.Properties[XmlName.xArguments];
+ var elementNode = node as ElementNode;
+ if (elementNode != null)
+ {
+ var array = new object[1];
+ array[0] = Values[elementNode];
+ return array;
+ }
+
+ var listnode = node as ListNode;
+ if (listnode != null)
+ {
+ var array = new object[listnode.CollectionItems.Count];
+ for (var i = 0; i < listnode.CollectionItems.Count; i++)
+ array[i] = Values[(ElementNode)listnode.CollectionItems[i]];
+ return array;
+ }
+ return null;
+ }
+
+ public object[] CreateArgumentsArray(IElementNode enode, ConstructorInfo ctorInfo)
+ {
+ var n = ctorInfo.GetParameters().Length;
+ var array = new object[n];
+ for (var i = 0; i < n; i++)
+ {
+ var parameter = ctorInfo.GetParameters()[i];
+ var propname =
+ parameter.CustomAttributes.First(attr => attr.AttributeType == typeof (ParameterAttribute))
+ .ConstructorArguments.First()
+ .Value as string;
+ var name = new XmlName("", propname);
+ INode node;
+ if (!enode.Properties.TryGetValue(name, out node))
+ {
+ throw new XamlParseException(
+ String.Format("The Property {0} is required to create a {1} object.", propname, ctorInfo.DeclaringType.FullName),
+ enode as IXmlLineInfo);
+ }
+ if (!enode.SkipProperties.Contains(name))
+ enode.SkipProperties.Add(name);
+ var value = Context.Values[node];
+ var serviceProvider = new XamlServiceProvider(enode, Context);
+ var convertedValue = value.ConvertTo(parameter.ParameterType, () => parameter, serviceProvider);
+ array[i] = convertedValue;
+ }
+
+ return array;
+ }
+
+ static bool IsXaml2009LanguagePrimitive(IElementNode node)
+ {
+ return node.NamespaceURI == XamlParser.X2009Uri;
+ }
+
+ static object CreateLanguagePrimitive(Type nodeType, IElementNode node)
+ {
+ object value = null;
+ if (nodeType == typeof(string))
+ value = String.Empty;
+ else if (nodeType == typeof(Uri))
+ value = null;
+ else
+ {
+ value = Activator.CreateInstance(nodeType);
+ if (value is BindableObject)
+ {
+ ((BindableObject)value).isCreateByXaml = true;
+ }
+ }
+
+ if (node.CollectionItems.Count == 1 && node.CollectionItems[0] is ValueNode &&
+ ((ValueNode)node.CollectionItems[0]).Value is string)
+ {
+ var valuestring = ((ValueNode)node.CollectionItems[0]).Value as string;
+
+ if (nodeType == typeof(SByte)) {
+ sbyte retval;
+ if (sbyte.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof(Int16)) {
+ short retval;
+ if (short.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof(Int32)) {
+ int retval;
+ if (int.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof(Int64)) {
+ long retval;
+ if (long.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof(Byte)) {
+ byte retval;
+ if (byte.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof(UInt16)) {
+ ushort retval;
+ if (ushort.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof(UInt32)) {
+ uint retval;
+ if (uint.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof(UInt64)) {
+ ulong retval;
+ if (ulong.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof(Single)) {
+ float retval;
+ if (float.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof(Double)) {
+ double retval;
+ if (double.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof (Boolean))
+ {
+ bool outbool;
+ if (bool.TryParse(valuestring, out outbool))
+ return outbool;
+ }
+ if (nodeType == typeof(TimeSpan)) {
+ TimeSpan retval;
+ if (TimeSpan.TryParse(valuestring, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+ if (nodeType == typeof (char))
+ {
+ char retval;
+ if (char.TryParse(valuestring, out retval))
+ return retval;
+ }
+ if (nodeType == typeof (string))
+ return valuestring;
+ if (nodeType == typeof (decimal))
+ {
+ decimal retval;
+ if (decimal.TryParse(valuestring, NumberStyles.Number, CultureInfo.InvariantCulture, out retval))
+ return retval;
+ }
+
+ else if (nodeType == typeof (Uri))
+ {
+ Uri retval;
+ if (Uri.TryCreate(valuestring, UriKind.RelativeOrAbsolute, out retval))
+ return retval;
+ }
+ }
+ return value;
+ }
+ }
}
namespace Tizen.NUI.Xaml
{
- internal static class DesignMode
- {
- public static bool IsDesignModeEnabled { get; internal set; }
- }
+ internal static class DesignMode
+ {
+ public static bool IsDesignModeEnabled { get; internal set; }
+ }
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Xml;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Xaml
{
- class ExpandMarkupsVisitor : IXamlNodeVisitor
- {
- public ExpandMarkupsVisitor(HydrationContext context)
- {
- Context = context;
- }
-
- public static readonly IList<XmlName> Skips = new List<XmlName>
- {
- XmlName.xKey,
- XmlName.xTypeArguments,
- XmlName.xFactoryMethod,
- XmlName.xName,
- XmlName.xDataType
- };
-
- Dictionary<INode, object> Values
- {
- get { return Context.Values; }
- }
-
- HydrationContext Context { get; }
-
- public TreeVisitingMode VisitingMode => TreeVisitingMode.BottomUp;
- public bool StopOnDataTemplate => false;
- public bool StopOnResourceDictionary => false;
- public bool VisitNodeOnDataTemplate => true;
- public bool SkipChildren(INode node, INode parentNode) => false;
-
- public void Visit(ValueNode node, INode parentNode)
- {
- }
-
- public void Visit(MarkupNode markupnode, INode parentNode)
- {
- var parentElement = parentNode as IElementNode;
- XmlName propertyName;
- if (!ApplyPropertiesVisitor.TryGetPropertyName(markupnode, parentNode, out propertyName))
- return;
- if (Skips.Contains(propertyName))
- return;
- if (parentElement.SkipProperties.Contains(propertyName))
- return;
-
- var markupString = markupnode.MarkupString;
- var node =
- ParseExpression(ref markupString, markupnode.NamespaceResolver, markupnode, markupnode, parentNode) as IElementNode;
- if (node != null)
- {
- ((IElementNode)parentNode).Properties[propertyName] = node;
- node.Parent = parentNode;
- }
- }
-
- public void Visit(ElementNode node, INode parentNode)
- {
- }
-
- public void Visit(RootNode node, INode parentNode)
- {
- }
-
- public void Visit(ListNode node, INode parentNode)
- {
- }
-
- INode ParseExpression(ref string expression, IXmlNamespaceResolver nsResolver, IXmlLineInfo xmlLineInfo, INode node,
- INode parentNode)
- {
- if (expression.StartsWith("{}", StringComparison.Ordinal))
- return new ValueNode(expression.Substring(2), null);
-
- if (expression[expression.Length - 1] != '}')
- throw new Exception("Expression must end with '}'");
-
- int len;
- string match;
- if (!MarkupExpressionParser.MatchMarkup(out match, expression, out len))
- throw new Exception();
- expression = expression.Substring(len).TrimStart();
- if (expression.Length == 0)
- throw new Exception("Expression did not end in '}'");
-
- var serviceProvider = new XamlServiceProvider(node, Context);
- serviceProvider.Add(typeof (IXmlNamespaceResolver), nsResolver);
-
- return new MarkupExpansionParser().Parse(match, ref expression, serviceProvider);
- }
-
- public class MarkupExpansionParser : MarkupExpressionParser, IExpressionParser<INode>
- {
- IElementNode node;
-
- object IExpressionParser.Parse(string match, ref string remaining, IServiceProvider serviceProvider)
- {
- return Parse(match, ref remaining, serviceProvider);
- }
-
- public INode Parse(string match, ref string remaining, IServiceProvider serviceProvider)
- {
- var nsResolver = serviceProvider.GetService(typeof (IXmlNamespaceResolver)) as IXmlNamespaceResolver;
- if (nsResolver == null)
- throw new ArgumentException();
- IXmlLineInfo xmlLineInfo = null;
- var xmlLineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- if (xmlLineInfoProvider != null)
- xmlLineInfo = xmlLineInfoProvider.XmlLineInfo;
-
- var split = match.Split(':');
- if (split.Length > 2)
- throw new ArgumentException();
-
- string prefix; //, name;
- if (split.Length == 2)
- {
- prefix = split[0];
- // name = split [1];
- }
- else
- {
- prefix = "";
- // name = split [0];
- }
-
- Type type;
- var typeResolver = serviceProvider.GetService(typeof (IXamlTypeResolver)) as IXamlTypeResolver;
- if (typeResolver == null)
- type = null;
+ internal class ExpandMarkupsVisitor : IXamlNodeVisitor
+ {
+ public ExpandMarkupsVisitor(HydrationContext context)
+ {
+ Context = context;
+ }
+
+ public static readonly IList<XmlName> Skips = new List<XmlName>
+ {
+ XmlName.xKey,
+ XmlName.xTypeArguments,
+ XmlName.xFactoryMethod,
+ XmlName.xName,
+ XmlName.xDataType
+ };
+
+ Dictionary<INode, object> Values
+ {
+ get { return Context.Values; }
+ }
+
+ HydrationContext Context { get; }
+
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.BottomUp;
+ public bool StopOnDataTemplate => false;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => true;
+ public bool SkipChildren(INode node, INode parentNode) => false;
+
+ public void Visit(ValueNode node, INode parentNode)
+ {
+ }
+
+ public void Visit(MarkupNode markupnode, INode parentNode)
+ {
+ var parentElement = parentNode as IElementNode;
+ XmlName propertyName;
+ if (!ApplyPropertiesVisitor.TryGetPropertyName(markupnode, parentNode, out propertyName))
+ return;
+ if (Skips.Contains(propertyName))
+ return;
+ if (parentElement.SkipProperties.Contains(propertyName))
+ return;
+
+ var markupString = markupnode.MarkupString;
+ var node =
+ ParseExpression(ref markupString, markupnode.NamespaceResolver, markupnode, markupnode, parentNode) as IElementNode;
+ if (node != null)
+ {
+ ((IElementNode)parentNode).Properties[propertyName] = node;
+ node.Parent = parentNode;
+ }
+ }
+
+ public void Visit(ElementNode node, INode parentNode)
+ {
+ }
+
+ public void Visit(RootNode node, INode parentNode)
+ {
+ }
+
+ public void Visit(ListNode node, INode parentNode)
+ {
+ }
+
+ INode ParseExpression(ref string expression, IXmlNamespaceResolver nsResolver, IXmlLineInfo xmlLineInfo, INode node,
+ INode parentNode)
+ {
+ if (expression.StartsWith("{}", StringComparison.Ordinal))
+ return new ValueNode(expression.Substring(2), null);
+
+ if (expression[expression.Length - 1] != '}')
+ throw new Exception("Expression must end with '}'");
+
+ int len;
+ string match;
+ if (!MarkupExpressionParser.MatchMarkup(out match, expression, out len))
+ throw new Exception();
+ expression = expression.Substring(len).TrimStart();
+ if (expression.Length == 0)
+ throw new Exception("Expression did not end in '}'");
+
+ var serviceProvider = new XamlServiceProvider(node, Context);
+ serviceProvider.Add(typeof (IXmlNamespaceResolver), nsResolver);
+
+ return new MarkupExpansionParser().Parse(match, ref expression, serviceProvider);
+ }
+
+ public class MarkupExpansionParser : MarkupExpressionParser, IExpressionParser<INode>
+ {
+ IElementNode node;
+
+ object IExpressionParser.Parse(string match, ref string remaining, IServiceProvider serviceProvider)
+ {
+ return Parse(match, ref remaining, serviceProvider);
+ }
+
+ public INode Parse(string match, ref string remaining, IServiceProvider serviceProvider)
+ {
+ var nsResolver = serviceProvider.GetService(typeof (IXmlNamespaceResolver)) as IXmlNamespaceResolver;
+ if (nsResolver == null)
+ throw new ArgumentException();
+ IXmlLineInfo xmlLineInfo = null;
+ var xmlLineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ if (xmlLineInfoProvider != null)
+ xmlLineInfo = xmlLineInfoProvider.XmlLineInfo;
+
+ var split = match.Split(':');
+ if (split.Length > 2)
+ throw new ArgumentException();
+
+ string prefix; //, name;
+ if (split.Length == 2)
+ {
+ prefix = split[0];
+ // name = split [1];
+ }
+ else
+ {
+ prefix = "";
+ // name = split [0];
+ }
+
+ Type type;
+ var typeResolver = serviceProvider.GetService(typeof (IXamlTypeResolver)) as IXamlTypeResolver;
+ if (typeResolver == null)
+ type = null;
// Add Binding and StaticResource support, The ordinal code can't find BindingExtension for Binding
//else if (match == "Binding")
//{
//{
// type = typeof(StaticResourceExtension);
//}
- else
- {
- //The order of lookup is to look for the Extension-suffixed class name first and then look for the class name without the Extension suffix.
- if (!typeResolver.TryResolve(match + "Extension", out type) && !typeResolver.TryResolve(match, out type))
- {
- var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
- throw new XamlParseException(String.Format("MarkupExtension not found for {0}", match), lineInfo);
- }
- }
-
- var namespaceuri = nsResolver.LookupNamespace(prefix) ?? "";
- var xmltype = new XmlType(namespaceuri, type?.Name, null);
-
- if (type == null)
- throw new NotSupportedException();
-
- node = xmlLineInfo == null
- ? new ElementNode(xmltype, null, nsResolver)
- : new ElementNode(xmltype, null, nsResolver, xmlLineInfo.LineNumber, xmlLineInfo.LinePosition);
-
- if (remaining.StartsWith("}", StringComparison.Ordinal))
- {
- remaining = remaining.Substring(1);
- return node;
- }
-
- char next;
- string piece;
- while ((piece = GetNextPiece(ref remaining, out next)) != null)
- HandleProperty(piece, serviceProvider, ref remaining, next != '=');
-
- return node;
- }
-
- protected override void SetPropertyValue(string prop, string strValue, object value, IServiceProvider serviceProvider)
- {
- var nsResolver = serviceProvider.GetService(typeof (IXmlNamespaceResolver)) as IXmlNamespaceResolver;
-
- var childnode = value as INode ?? new ValueNode(strValue, nsResolver);
- childnode.Parent = node;
- if (prop != null)
- {
- var name = new XmlName(node.NamespaceURI, prop);
- node.Properties[name] = childnode;
- }
- else //ContentProperty
- node.CollectionItems.Add(childnode);
- }
- }
- }
+ else
+ {
+ //The order of lookup is to look for the Extension-suffixed class name first and then look for the class name without the Extension suffix.
+ if (!typeResolver.TryResolve(match + "Extension", out type) && !typeResolver.TryResolve(match, out type))
+ {
+ var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
+ throw new XamlParseException(String.Format("MarkupExtension not found for {0}", match), lineInfo);
+ }
+ }
+
+ var namespaceuri = nsResolver.LookupNamespace(prefix) ?? "";
+ var xmltype = new XmlType(namespaceuri, type?.Name, null);
+
+ if (type == null)
+ throw new NotSupportedException();
+
+ node = xmlLineInfo == null
+ ? new ElementNode(xmltype, null, nsResolver)
+ : new ElementNode(xmltype, null, nsResolver, xmlLineInfo.LineNumber, xmlLineInfo.LinePosition);
+
+ if (remaining.StartsWith("}", StringComparison.Ordinal))
+ {
+ remaining = remaining.Substring(1);
+ return node;
+ }
+
+ char next;
+ string piece;
+ while ((piece = GetNextPiece(ref remaining, out next)) != null)
+ HandleProperty(piece, serviceProvider, ref remaining, next != '=');
+
+ return node;
+ }
+
+ protected override void SetPropertyValue(string prop, string strValue, object value, IServiceProvider serviceProvider)
+ {
+ var nsResolver = serviceProvider.GetService(typeof (IXmlNamespaceResolver)) as IXmlNamespaceResolver;
+
+ var childnode = value as INode ?? new ValueNode(strValue, nsResolver);
+ childnode.Parent = node;
+ if (prop != null)
+ {
+ var name = new XmlName(node.NamespaceURI, prop);
+ node.Properties[name] = childnode;
+ }
+ else //ContentProperty
+ node.CollectionItems.Add(childnode);
+ }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- class FillResourceDictionariesVisitor : IXamlNodeVisitor
- {
- public FillResourceDictionariesVisitor(HydrationContext context)
- {
- Context = context;
- }
+ internal class FillResourceDictionariesVisitor : IXamlNodeVisitor
+ {
+ public FillResourceDictionariesVisitor(HydrationContext context)
+ {
+ Context = context;
+ }
- HydrationContext Context { get; }
- Dictionary<INode, object> Values => Context.Values;
+ HydrationContext Context { get; }
+ Dictionary<INode, object> Values => Context.Values;
- public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
- public bool StopOnDataTemplate => true;
- public bool StopOnResourceDictionary => false;
- public bool VisitNodeOnDataTemplate => false;
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
+ public bool StopOnDataTemplate => true;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => false;
- public void Visit(ValueNode node, INode parentNode)
- {
- if (!typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)]))
- return;
+ public void Visit(ValueNode node, INode parentNode)
+ {
+ if (!typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)]))
+ return;
- node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
- }
+ node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
+ }
- public void Visit(MarkupNode node, INode parentNode)
- {
- }
+ public void Visit(MarkupNode node, INode parentNode)
+ {
+ }
- public void Visit(ElementNode node, INode parentNode)
- {
- var value = Values[node];
- XmlName propertyName;
- //Set RD to VE
- if (typeof(ResourceDictionary).IsAssignableFrom(Context.Types[node]) && ApplyPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName)) {
- if ((propertyName.LocalName == "Resources" ||
- propertyName.LocalName.EndsWith(".Resources", StringComparison.Ordinal)) && value is ResourceDictionary) {
- var source = Values[parentNode];
- ApplyPropertiesVisitor.SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
- return;
- }
- }
+ public void Visit(ElementNode node, INode parentNode)
+ {
+ var value = Values[node];
+ XmlName propertyName;
+ //Set RD to VE
+ if (typeof(ResourceDictionary).IsAssignableFrom(Context.Types[node]) && ApplyPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName)) {
+ if ((propertyName.LocalName == "Resources" ||
+ propertyName.LocalName.EndsWith(".Resources", StringComparison.Ordinal)) && value is ResourceDictionary) {
+ var source = Values[parentNode];
+ ApplyPropertiesVisitor.SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
+ return;
+ }
+ }
- //Only proceed further if the node is a keyless RD
- if ( parentNode is IElementNode
- && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)])
- && !((IElementNode)parentNode).Properties.ContainsKey(XmlName.xKey))
- node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
- else if ( parentNode is ListNode
- && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode.Parent)])
- && !((IElementNode)parentNode.Parent).Properties.ContainsKey(XmlName.xKey))
- node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
- }
+ //Only proceed further if the node is a keyless RD
+ if ( parentNode is IElementNode
+ && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)])
+ && !((IElementNode)parentNode).Properties.ContainsKey(XmlName.xKey))
+ node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
+ else if ( parentNode is ListNode
+ && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode.Parent)])
+ && !((IElementNode)parentNode.Parent).Properties.ContainsKey(XmlName.xKey))
+ node.Accept(new ApplyPropertiesVisitor(Context, stopOnResourceDictionary: false), parentNode);
+ }
- public void Visit(RootNode node, INode parentNode)
- {
- }
+ public void Visit(RootNode node, INode parentNode)
+ {
+ }
- public void Visit(ListNode node, INode parentNode)
- {
- }
+ public void Visit(ListNode node, INode parentNode)
+ {
+ }
- public bool SkipChildren(INode node, INode parentNode)
- {
- var enode = node as ElementNode;
- if (enode is null)
- return false;
- if ( parentNode is IElementNode
- && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)])
- && !((IElementNode)parentNode).Properties.ContainsKey(XmlName.xKey))
- return true;
- if ( parentNode is ListNode
- && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode.Parent)])
- && !((IElementNode)parentNode.Parent).Properties.ContainsKey(XmlName.xKey))
- return true;
- return false;
- }
+ public bool SkipChildren(INode node, INode parentNode)
+ {
+ var enode = node as ElementNode;
+ if (enode is null)
+ return false;
+ if ( parentNode is IElementNode
+ && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode)])
+ && !((IElementNode)parentNode).Properties.ContainsKey(XmlName.xKey))
+ return true;
+ if ( parentNode is ListNode
+ && typeof(ResourceDictionary).IsAssignableFrom(Context.Types[((IElementNode)parentNode.Parent)])
+ && !((IElementNode)parentNode.Parent).Properties.ContainsKey(XmlName.xKey))
+ return true;
+ return false;
+ }
- }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- class HydrationContext
- {
- public HydrationContext()
- {
- Values = new Dictionary<INode, object>();
- Types = new Dictionary<IElementNode, Type>();
- }
+ internal class HydrationContext
+ {
+ public HydrationContext()
+ {
+ Values = new Dictionary<INode, object>();
+ Types = new Dictionary<IElementNode, Type>();
+ }
- public Dictionary<INode, object> Values { get; }
- public Dictionary<IElementNode, Type> Types { get; }
- public HydrationContext ParentContext { get; set; }
- public Action<Exception> ExceptionHandler { get; set; }
- public object RootElement { get; set; }
- }
+ public Dictionary<INode, object> Values { get; }
+ public Dictionary<IElementNode, Type> Types { get; }
+ public HydrationContext ParentContext { get; set; }
+ public Action<Exception> ExceptionHandler { get; set; }
+ public object RootElement { get; set; }
+ }
}
namespace Tizen.NUI.Xaml
{
- interface IConverterOptions
- {
- bool IgnoreCase { get; }
- }
+ internal interface IConverterOptions
+ {
+ bool IgnoreCase { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal static class IDictionaryExtensions
- {
- public static void AddRange<TKey, TValue>(this IDictionary<TKey, TValue> dictionary,
- IEnumerable<KeyValuePair<TKey, TValue>> collection)
- {
- foreach (var kvp in collection)
- dictionary.Add(kvp);
- }
- }
+ internal static class IDictionaryExtensions
+ {
+ public static void AddRange<TKey, TValue>(this IDictionary<TKey, TValue> dictionary,
+ IEnumerable<KeyValuePair<TKey, TValue>> collection)
+ {
+ foreach (var kvp in collection)
+ dictionary.Add(kvp);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal interface IExpressionParser
- {
- object Parse(string match, ref string expression, IServiceProvider serviceProvider);
- }
+ internal interface IExpressionParser
+ {
+ object Parse(string match, ref string expression, IServiceProvider serviceProvider);
+ }
- internal interface IExpressionParser<out T> : IExpressionParser
- where T : class
- {
- new T Parse(string match, ref string expression, IServiceProvider serviceProvider);
- }
+ internal interface IExpressionParser<out T> : IExpressionParser
+ where T : class
+ {
+ new T Parse(string match, ref string expression, IServiceProvider serviceProvider);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal interface IMarkupExtension<out T> : IMarkupExtension
- {
- new T ProvideValue(IServiceProvider serviceProvider);
- }
+ internal interface IMarkupExtension<out T> : IMarkupExtension
+ {
+ new T ProvideValue(IServiceProvider serviceProvider);
+ }
- internal interface IMarkupExtension
- {
- object ProvideValue(IServiceProvider serviceProvider);
- }
+ internal interface IMarkupExtension
+ {
+ object ProvideValue(IServiceProvider serviceProvider);
+ }
- [AttributeUsage(AttributeTargets.Class, Inherited = false)]
- internal sealed class AcceptEmptyServiceProviderAttribute : Attribute
- {
- }
+ [AttributeUsage(AttributeTargets.Class, Inherited = false)]
+ internal sealed class AcceptEmptyServiceProviderAttribute : Attribute
+ {
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml.Internals
{
- internal interface INativeValueConverterService
- {
- bool ConvertTo(object value, Type toType, out object nativeValue);
- }
+ internal interface INativeValueConverterService
+ {
+ bool ConvertTo(object value, Type toType, out object nativeValue);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal interface IProvideParentValues : IProvideValueTarget
- {
- IEnumerable<object> ParentObjects { get; }
- }
+ internal interface IProvideParentValues : IProvideValueTarget
+ {
+ IEnumerable<object> ParentObjects { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal interface IProvideValueTarget
- {
- object TargetObject { get; }
- object TargetProperty { get; }
- }
+ internal interface IProvideValueTarget
+ {
+ object TargetObject { get; }
+ object TargetProperty { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI
{
- interface IResourcesLoader
- {
- T CreateFromResource<T>(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo) where T : new();
- string GetResource(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo);
- }
+ internal interface IResourcesLoader
+ {
+ T CreateFromResource<T>(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo) where T : new();
+ string GetResource(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal interface IRootObjectProvider
- {
- object RootObject { get; }
- }
+ internal interface IRootObjectProvider
+ {
+ object RootObject { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- interface IValueConverterProvider
- {
- object Convert(object value, Type toType, Func<MemberInfo> minfoRetriever, IServiceProvider serviceProvider);
- }
+ internal interface IValueConverterProvider
+ {
+ object Convert(object value, Type toType, Func<MemberInfo> minfoRetriever, IServiceProvider serviceProvider);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal interface IValueProvider
- {
- object ProvideValue(IServiceProvider serviceProvider);
- }
+ internal interface IValueProvider
+ {
+ object ProvideValue(IServiceProvider serviceProvider);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal interface IXamlTypeResolver
- {
- Type Resolve(string qualifiedTypeName, IServiceProvider serviceProvider = null);
- bool TryResolve(string qualifiedTypeName, out Type type);
- }
+ internal interface IXamlTypeResolver
+ {
+ Type Resolve(string qualifiedTypeName, IServiceProvider serviceProvider = null);
+ bool TryResolve(string qualifiedTypeName, out Type type);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal interface IXmlLineInfoProvider
- {
- IXmlLineInfo XmlLineInfo { get; }
- }
+ internal interface IXmlLineInfoProvider
+ {
+ IXmlLineInfo XmlLineInfo { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- abstract class MarkupExpressionParser
- {
- public object ParseExpression(ref string expression, IServiceProvider serviceProvider)
- {
- if (serviceProvider == null)
- throw new ArgumentNullException(nameof(serviceProvider));
- if (expression.StartsWith("{}", StringComparison.Ordinal))
- return expression.Substring(2);
-
- if (expression[expression.Length - 1] != '}')
- throw new Exception("Expression must end with '}'");
-
- int len;
- string match;
- if (!MatchMarkup(out match, expression, out len))
- return false;
- expression = expression.Substring(len).TrimStart();
- if (expression.Length == 0)
- throw new Exception("Expression did not end in '}'");
-
- var parser = Activator.CreateInstance(GetType()) as IExpressionParser;
- return parser.Parse(match, ref expression, serviceProvider);
- }
-
- internal static bool MatchMarkup(out string match, string expression, out int end)
- {
- if (expression.Length < 2)
- {
- end = 1;
- match = null;
- return false;
- }
-
- if (expression[0] != '{')
- {
- end = 2;
- match = null;
- return false;
- }
-
- int i;
- bool found = false;
- for (i = 1; i < expression.Length; i++)
- {
- if (expression[i] == ' ')
- continue;
- found = true;
- break;
- }
-
- if (!found)
- {
- end = 3;
- match = null;
- return false;
- }
-
- int c;
- for (c = 0; c + i < expression.Length; c++)
- {
- if (expression[i + c] == ' ' || expression[i + c] == '}')
- break;
- }
-
- if (i + c == expression.Length)
- {
- end = 6;
- match = null;
- return false;
- }
-
- end = i + c;
- match = expression.Substring(i, c);
- return true;
- }
-
- protected void HandleProperty(string prop, IServiceProvider serviceProvider, ref string remaining, bool isImplicit)
- {
- char next;
- object value = null;
- string str_value;
-
- if (isImplicit)
- {
- SetPropertyValue(null, prop, null, serviceProvider);
- return;
- }
- remaining = remaining.TrimStart();
- if (remaining.StartsWith("{", StringComparison.Ordinal))
- {
- value = ParseExpression(ref remaining, serviceProvider);
- remaining = remaining.TrimStart();
-
- if (remaining.Length > 0 && remaining[0] == ',')
- remaining = remaining.Substring(1);
- else if (remaining.Length > 0 && remaining[0] == '}')
- remaining = remaining.Substring(1);
-
- str_value = value as string;
- }
- else
- str_value = GetNextPiece(ref remaining, out next);
-
- SetPropertyValue(prop, str_value, value, serviceProvider);
- }
-
- protected abstract void SetPropertyValue(string prop, string strValue, object value, IServiceProvider serviceProvider);
-
- protected string GetNextPiece(ref string remaining, out char next)
- {
- bool inString = false;
- int end = 0;
- char stringTerminator = '\0';
- remaining = remaining.TrimStart();
- if (remaining.Length == 0)
- {
- next = Char.MaxValue;
- return null;
- }
-
- var piece = new StringBuilder();
- // If we're inside a quoted string we append all chars to our piece until we hit the ending quote.
- while (end < remaining.Length &&
- (inString || (remaining[end] != '}' && remaining[end] != ',' && remaining[end] != '=')))
- {
- if (inString)
- {
- if (remaining[end] == stringTerminator)
- {
- inString = false;
- end ++;
- break;
- }
- }
- else
- {
- if (remaining[end] == '\'' || remaining[end] == '"')
- {
- inString = true;
- stringTerminator = remaining[end];
- end ++;
- continue;
- }
- }
-
- // If this is an escape char, consume it and append the next char to our piece.
- if (remaining[end] == '\\')
- {
- end ++;
- if (end == remaining.Length)
- break;
- }
- piece.Append(remaining[end]);
- end++;
- }
-
- if (inString && end == remaining.Length)
- throw new Exception("Unterminated quoted string");
-
- if (end == remaining.Length && !remaining.EndsWith("}", StringComparison.Ordinal))
- throw new Exception("Expression did not end with '}'");
-
- if (end == 0)
- {
- next = Char.MaxValue;
- return null;
- }
-
- next = remaining[end];
- remaining = remaining.Substring(end + 1);
-
- // Whitespace is trimmed from the end of the piece before stripping
- // quote chars from the start/end of the string.
- while (piece.Length > 0 && char.IsWhiteSpace(piece[piece.Length - 1]))
- piece.Length --;
-
- if (piece.Length >= 2)
- {
- char first = piece[0];
- char last = piece[piece.Length - 1];
- if ((first == '\'' && last == '\'') || (first == '"' && last == '"'))
- {
- piece.Remove(piece.Length - 1, 1);
- piece.Remove(0, 1);
- }
- }
-
- return piece.ToString();
- }
- }
+ internal abstract class MarkupExpressionParser
+ {
+ public object ParseExpression(ref string expression, IServiceProvider serviceProvider)
+ {
+ if (serviceProvider == null)
+ throw new ArgumentNullException(nameof(serviceProvider));
+ if (expression.StartsWith("{}", StringComparison.Ordinal))
+ return expression.Substring(2);
+
+ if (expression[expression.Length - 1] != '}')
+ throw new Exception("Expression must end with '}'");
+
+ int len;
+ string match;
+ if (!MatchMarkup(out match, expression, out len))
+ return false;
+ expression = expression.Substring(len).TrimStart();
+ if (expression.Length == 0)
+ throw new Exception("Expression did not end in '}'");
+
+ var parser = Activator.CreateInstance(GetType()) as IExpressionParser;
+ return parser.Parse(match, ref expression, serviceProvider);
+ }
+
+ internal static bool MatchMarkup(out string match, string expression, out int end)
+ {
+ if (expression.Length < 2)
+ {
+ end = 1;
+ match = null;
+ return false;
+ }
+
+ if (expression[0] != '{')
+ {
+ end = 2;
+ match = null;
+ return false;
+ }
+
+ int i;
+ bool found = false;
+ for (i = 1; i < expression.Length; i++)
+ {
+ if (expression[i] == ' ')
+ continue;
+ found = true;
+ break;
+ }
+
+ if (!found)
+ {
+ end = 3;
+ match = null;
+ return false;
+ }
+
+ int c;
+ for (c = 0; c + i < expression.Length; c++)
+ {
+ if (expression[i + c] == ' ' || expression[i + c] == '}')
+ break;
+ }
+
+ if (i + c == expression.Length)
+ {
+ end = 6;
+ match = null;
+ return false;
+ }
+
+ end = i + c;
+ match = expression.Substring(i, c);
+ return true;
+ }
+
+ protected void HandleProperty(string prop, IServiceProvider serviceProvider, ref string remaining, bool isImplicit)
+ {
+ char next;
+ object value = null;
+ string str_value;
+
+ if (isImplicit)
+ {
+ SetPropertyValue(null, prop, null, serviceProvider);
+ return;
+ }
+ remaining = remaining.TrimStart();
+ if (remaining.StartsWith("{", StringComparison.Ordinal))
+ {
+ value = ParseExpression(ref remaining, serviceProvider);
+ remaining = remaining.TrimStart();
+
+ if (remaining.Length > 0 && remaining[0] == ',')
+ remaining = remaining.Substring(1);
+ else if (remaining.Length > 0 && remaining[0] == '}')
+ remaining = remaining.Substring(1);
+
+ str_value = value as string;
+ }
+ else
+ str_value = GetNextPiece(ref remaining, out next);
+
+ SetPropertyValue(prop, str_value, value, serviceProvider);
+ }
+
+ protected abstract void SetPropertyValue(string prop, string strValue, object value, IServiceProvider serviceProvider);
+
+ protected string GetNextPiece(ref string remaining, out char next)
+ {
+ bool inString = false;
+ int end = 0;
+ char stringTerminator = '\0';
+ remaining = remaining.TrimStart();
+ if (remaining.Length == 0)
+ {
+ next = Char.MaxValue;
+ return null;
+ }
+
+ var piece = new StringBuilder();
+ // If we're inside a quoted string we append all chars to our piece until we hit the ending quote.
+ while (end < remaining.Length &&
+ (inString || (remaining[end] != '}' && remaining[end] != ',' && remaining[end] != '=')))
+ {
+ if (inString)
+ {
+ if (remaining[end] == stringTerminator)
+ {
+ inString = false;
+ end ++;
+ break;
+ }
+ }
+ else
+ {
+ if (remaining[end] == '\'' || remaining[end] == '"')
+ {
+ inString = true;
+ stringTerminator = remaining[end];
+ end ++;
+ continue;
+ }
+ }
+
+ // If this is an escape char, consume it and append the next char to our piece.
+ if (remaining[end] == '\\')
+ {
+ end ++;
+ if (end == remaining.Length)
+ break;
+ }
+ piece.Append(remaining[end]);
+ end++;
+ }
+
+ if (inString && end == remaining.Length)
+ throw new Exception("Unterminated quoted string");
+
+ if (end == remaining.Length && !remaining.EndsWith("}", StringComparison.Ordinal))
+ throw new Exception("Expression did not end with '}'");
+
+ if (end == 0)
+ {
+ next = Char.MaxValue;
+ return null;
+ }
+
+ next = remaining[end];
+ remaining = remaining.Substring(end + 1);
+
+ // Whitespace is trimmed from the end of the piece before stripping
+ // quote chars from the start/end of the string.
+ while (piece.Length > 0 && char.IsWhiteSpace(piece[piece.Length - 1]))
+ piece.Length --;
+
+ if (piece.Length >= 2)
+ {
+ char first = piece[0];
+ char last = piece[piece.Length - 1];
+ if ((first == '\'' && last == '\'') || (first == '"' && last == '"'))
+ {
+ piece.Remove(piece.Length - 1, 1);
+ piece.Remove(0, 1);
+ }
+ }
+
+ return piece.ToString();
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal sealed class MarkupExtensionParser : MarkupExpressionParser, IExpressionParser<object>
- {
- IMarkupExtension markupExtension;
+ internal sealed class MarkupExtensionParser : MarkupExpressionParser, IExpressionParser<object>
+ {
+ IMarkupExtension markupExtension;
- public object Parse(string match, ref string remaining, IServiceProvider serviceProvider)
- {
- var typeResolver = serviceProvider.GetService(typeof (IXamlTypeResolver)) as IXamlTypeResolver;
+ public object Parse(string match, ref string remaining, IServiceProvider serviceProvider)
+ {
+ var typeResolver = serviceProvider.GetService(typeof (IXamlTypeResolver)) as IXamlTypeResolver;
- //shortcut for Binding and StaticResource, to avoid too many reflection calls.
- if (match == "Binding")
- markupExtension = new BindingExtension();
- else if (match == "TemplateBinding")
- markupExtension = new TemplateBindingExtension();
- else if (match == "StaticResource")
- markupExtension = new StaticResourceExtension();
- else
- {
- if (typeResolver == null)
- return null;
- Type type;
+ //shortcut for Binding and StaticResource, to avoid too many reflection calls.
+ if (match == "Binding")
+ markupExtension = new BindingExtension();
+ else if (match == "TemplateBinding")
+ markupExtension = new TemplateBindingExtension();
+ else if (match == "StaticResource")
+ markupExtension = new StaticResourceExtension();
+ else
+ {
+ if (typeResolver == null)
+ return null;
+ Type type;
- //The order of lookup is to look for the Extension-suffixed class name first and then look for the class name without the Extension suffix.
- if (!typeResolver.TryResolve(match + "Extension", out type) && !typeResolver.TryResolve(match, out type))
- {
- var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
- throw new XamlParseException(String.Format("MarkupExtension not found for {0}", match), lineInfo);
- }
- markupExtension = Activator.CreateInstance(type) as IMarkupExtension;
- }
+ //The order of lookup is to look for the Extension-suffixed class name first and then look for the class name without the Extension suffix.
+ if (!typeResolver.TryResolve(match + "Extension", out type) && !typeResolver.TryResolve(match, out type))
+ {
+ var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
+ throw new XamlParseException(String.Format("MarkupExtension not found for {0}", match), lineInfo);
+ }
+ markupExtension = Activator.CreateInstance(type) as IMarkupExtension;
+ }
- if (markupExtension == null)
- {
- var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
- throw new XamlParseException(String.Format("Missing public default constructor for MarkupExtension {0}", match),
- lineInfo);
- }
+ if (markupExtension == null)
+ {
+ var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
+ throw new XamlParseException(String.Format("Missing public default constructor for MarkupExtension {0}", match),
+ lineInfo);
+ }
- char next;
- if (remaining == "}")
- return markupExtension.ProvideValue(serviceProvider);
+ char next;
+ if (remaining == "}")
+ return markupExtension.ProvideValue(serviceProvider);
- string piece;
- while ((piece = GetNextPiece(ref remaining, out next)) != null)
- HandleProperty(piece, serviceProvider, ref remaining, next != '=');
+ string piece;
+ while ((piece = GetNextPiece(ref remaining, out next)) != null)
+ HandleProperty(piece, serviceProvider, ref remaining, next != '=');
- return markupExtension.ProvideValue(serviceProvider);
- }
+ return markupExtension.ProvideValue(serviceProvider);
+ }
- protected override void SetPropertyValue(string prop, string strValue, object value, IServiceProvider serviceProvider)
- {
- MethodInfo setter;
- if (prop == null)
- {
- //implicit property
- var t = markupExtension.GetType();
- prop = ApplyPropertiesVisitor.GetContentPropertyName(t.GetTypeInfo());
- if (prop == null)
- return;
- setter = t.GetRuntimeProperty(prop).SetMethod;
- }
- else
- setter = markupExtension.GetType().GetRuntimeProperty(prop).SetMethod;
+ protected override void SetPropertyValue(string prop, string strValue, object value, IServiceProvider serviceProvider)
+ {
+ MethodInfo setter;
+ if (prop == null)
+ {
+ //implicit property
+ var t = markupExtension.GetType();
+ prop = ApplyPropertiesVisitor.GetContentPropertyName(t.GetTypeInfo());
+ if (prop == null)
+ return;
+ setter = t.GetRuntimeProperty(prop).SetMethod;
+ }
+ else
+ setter = markupExtension.GetType().GetRuntimeProperty(prop).SetMethod;
- if (value == null && strValue != null)
- {
- value = strValue.ConvertTo(markupExtension.GetType().GetRuntimeProperty(prop).PropertyType,
- (Func<TypeConverter>)null, serviceProvider);
- }
+ if (value == null && strValue != null)
+ {
+ value = strValue.ConvertTo(markupExtension.GetType().GetRuntimeProperty(prop).PropertyType,
+ (Func<TypeConverter>)null, serviceProvider);
+ }
- setter?.Invoke(markupExtension, new[] { value });
- }
- }
+ setter?.Invoke(markupExtension, new[] { value });
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [ContentProperty("Items")]
- [AcceptEmptyServiceProvider]
- internal class ArrayExtension : IMarkupExtension<Array>
- {
- public ArrayExtension()
- {
- Items = new List<object>();
- }
-
- public IList Items { get; }
-
- public Type Type { get; set; }
-
- public Array ProvideValue(IServiceProvider serviceProvider)
- {
- if (Type == null)
- throw new InvalidOperationException("Type argument mandatory for x:Array extension");
-
- if (Items == null)
- return null;
-
- var array = Array.CreateInstance(Type, Items.Count);
- for (var i = 0; i < Items.Count; i++)
- ((IList)array)[i] = Items[i];
-
- return array;
- }
-
- object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
- {
- return (this as IMarkupExtension<Array>).ProvideValue(serviceProvider);
- }
- }
+ [ContentProperty("Items")]
+ [AcceptEmptyServiceProvider]
+ internal class ArrayExtension : IMarkupExtension<Array>
+ {
+ public ArrayExtension()
+ {
+ Items = new List<object>();
+ }
+
+ public IList Items { get; }
+
+ public Type Type { get; set; }
+
+ public Array ProvideValue(IServiceProvider serviceProvider)
+ {
+ if (Type == null)
+ throw new InvalidOperationException("Type argument mandatory for x:Array extension");
+
+ if (Items == null)
+ return null;
+
+ var array = Array.CreateInstance(Type, Items.Count);
+ for (var i = 0; i < Items.Count; i++)
+ ((IList)array)[i] = Items[i];
+
+ return array;
+ }
+
+ object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
+ {
+ return (this as IMarkupExtension<Array>).ProvideValue(serviceProvider);
+ }
+ }
}
\ No newline at end of file
using System;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI.Binding;
namespace Tizen.NUI.Xaml
{
- [ContentProperty("Path")]
- [AcceptEmptyServiceProvider]
- internal sealed class BindingExtension : IMarkupExtension<BindingBase>
- {
- public BindingExtension()
- {
- Mode = BindingMode.Default;
- Path = Tizen.NUI.Binding.Binding.SelfPath;
- }
+ [ContentProperty("Path")]
+ [AcceptEmptyServiceProvider]
+ internal sealed class BindingExtension : IMarkupExtension<BindingBase>
+ {
+ public BindingExtension()
+ {
+ Mode = BindingMode.Default;
+ Path = Tizen.NUI.Binding.Binding.SelfPath;
+ }
- public string Path { get; set; }
+ public string Path { get; set; }
- public BindingMode Mode { get; set; }
+ public BindingMode Mode { get; set; }
- public IValueConverter Converter { get; set; }
+ public IValueConverter Converter { get; set; }
- public object ConverterParameter { get; set; }
+ public object ConverterParameter { get; set; }
- public string StringFormat { get; set; }
+ public string StringFormat { get; set; }
- public object Source { get; set; }
+ public object Source { get; set; }
- public string UpdateSourceEventName { get; set; }
+ public string UpdateSourceEventName { get; set; }
- public TypedBindingBase TypedBinding { get; set; }
+ public TypedBindingBase TypedBinding { get; set; }
- BindingBase IMarkupExtension<BindingBase>.ProvideValue(IServiceProvider serviceProvider)
- {
- if (TypedBinding == null)
- return new Tizen.NUI.Binding.Binding(Path, Mode, Converter, ConverterParameter, StringFormat, Source) { UpdateSourceEventName = UpdateSourceEventName };
+ BindingBase IMarkupExtension<BindingBase>.ProvideValue(IServiceProvider serviceProvider)
+ {
+ if (TypedBinding == null)
+ return new Tizen.NUI.Binding.Binding(Path, Mode, Converter, ConverterParameter, StringFormat, Source) { UpdateSourceEventName = UpdateSourceEventName };
- TypedBinding.Mode = Mode;
- TypedBinding.Converter = Converter;
- TypedBinding.ConverterParameter = ConverterParameter;
- TypedBinding.StringFormat = StringFormat;
- TypedBinding.Source = Source;
- TypedBinding.UpdateSourceEventName = UpdateSourceEventName;
- return TypedBinding;
- }
+ TypedBinding.Mode = Mode;
+ TypedBinding.Converter = Converter;
+ TypedBinding.ConverterParameter = ConverterParameter;
+ TypedBinding.StringFormat = StringFormat;
+ TypedBinding.Source = Source;
+ TypedBinding.UpdateSourceEventName = UpdateSourceEventName;
+ return TypedBinding;
+ }
- object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
- {
- return (this as IMarkupExtension<BindingBase>).ProvideValue(serviceProvider);
- }
- }
+ object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
+ {
+ return (this as IMarkupExtension<BindingBase>).ProvideValue(serviceProvider);
+ }
+ }
}
\ No newline at end of file
using System;
using Tizen.NUI.Binding;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Xaml
{
- [ContentProperty("Key")]
- internal sealed class DynamicResourceExtension : IMarkupExtension<DynamicResource>
- {
- public string Key { get; set; }
+ [ContentProperty("Key")]
+ internal sealed class DynamicResourceExtension : IMarkupExtension<DynamicResource>
+ {
+ public string Key { get; set; }
- public object ProvideValue(IServiceProvider serviceProvider)
- {
- return ((IMarkupExtension<DynamicResource>)this).ProvideValue(serviceProvider);
- }
+ public object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return ((IMarkupExtension<DynamicResource>)this).ProvideValue(serviceProvider);
+ }
- DynamicResource IMarkupExtension<DynamicResource>.ProvideValue(IServiceProvider serviceProvider)
- {
- if (Key == null)
- {
- var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
- throw new XamlParseException("DynamicResource markup require a Key", lineInfo);
- }
- return new DynamicResource(Key);
- }
- }
+ DynamicResource IMarkupExtension<DynamicResource>.ProvideValue(IServiceProvider serviceProvider)
+ {
+ if (Key == null)
+ {
+ var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
+ throw new XamlParseException("DynamicResource markup require a Key", lineInfo);
+ }
+ return new DynamicResource(Key);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- // [ProvideCompiled("Tizen.NUI.Build.Tasks.NullExtension")]
- [AcceptEmptyServiceProvider]
- internal class NullExtension : IMarkupExtension
- {
- public object ProvideValue(IServiceProvider serviceProvider)
- {
- return null;
- }
- }
+ // [ProvideCompiled("Tizen.NUI.Build.Tasks.NullExtension")]
+ [AcceptEmptyServiceProvider]
+ internal class NullExtension : IMarkupExtension
+ {
+ public object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return null;
+ }
+ }
}
using System;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI.Xaml.Internals;
using Tizen.NUI.Binding;
namespace Tizen.NUI.Xaml
{
- [ContentProperty("Name")]
- internal class ReferenceExtension : IMarkupExtension
- {
- public string Name { get; set; }
+ [ContentProperty("Name")]
+ internal class ReferenceExtension : IMarkupExtension
+ {
+ public string Name { get; set; }
- public object ProvideValue(IServiceProvider serviceProvider)
- {
- if (serviceProvider == null)
- throw new ArgumentNullException(nameof(serviceProvider));
- var valueProvider = serviceProvider.GetService(typeof (IProvideValueTarget)) as IProvideParentValues;
- if (valueProvider == null)
- throw new ArgumentException("serviceProvider does not provide an IProvideValueTarget");
- var namescopeprovider = serviceProvider.GetService(typeof (INameScopeProvider)) as INameScopeProvider;
- if (namescopeprovider != null && namescopeprovider.NameScope != null)
- {
- var value = namescopeprovider.NameScope.FindByName(Name);
- if (value != null)
- return value;
- }
+ public object ProvideValue(IServiceProvider serviceProvider)
+ {
+ if (serviceProvider == null)
+ throw new ArgumentNullException(nameof(serviceProvider));
+ var valueProvider = serviceProvider.GetService(typeof (IProvideValueTarget)) as IProvideParentValues;
+ if (valueProvider == null)
+ throw new ArgumentException("serviceProvider does not provide an IProvideValueTarget");
+ var namescopeprovider = serviceProvider.GetService(typeof (INameScopeProvider)) as INameScopeProvider;
+ if (namescopeprovider != null && namescopeprovider.NameScope != null)
+ {
+ var value = namescopeprovider.NameScope.FindByName(Name);
+ if (value != null)
+ return value;
+ }
- foreach (var target in valueProvider.ParentObjects)
- {
- var ns = target as INameScope;
- if (ns == null)
- continue;
- var value = ns.FindByName(Name);
- if (value != null)
- return value;
- }
+ foreach (var target in valueProvider.ParentObjects)
+ {
+ var ns = target as INameScope;
+ if (ns == null)
+ continue;
+ var value = ns.FindByName(Name);
+ if (value != null)
+ return value;
+ }
- var lineInfo = (serviceProvider?.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo ?? new XmlLineInfo();
- throw new XamlParseException($"Can not find the object referenced by `{Name}`", lineInfo);
- }
- }
+ var lineInfo = (serviceProvider?.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo ?? new XmlLineInfo();
+ throw new XamlParseException($"Can not find the object referenced by `{Name}`", lineInfo);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [ContentProperty(nameof(Member))]
- // [ProvideCompiled("Tizen.NUI.Build.Tasks.StaticExtension")]
- internal class StaticExtension : IMarkupExtension
- {
- public string Member { get; set; }
-
- public object ProvideValue(IServiceProvider serviceProvider)
- {
- IXmlLineInfoProvider lineInfoProvider;
- IXmlLineInfo lineInfo;
-
- if (serviceProvider == null)
- throw new ArgumentNullException(nameof(serviceProvider));
- var typeResolver = serviceProvider.GetService(typeof (IXamlTypeResolver)) as IXamlTypeResolver;
- if (typeResolver == null)
- throw new ArgumentException("No IXamlTypeResolver in IServiceProvider");
-
- if (string.IsNullOrEmpty(Member) || !Member.Contains("."))
- {
- lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
- throw new XamlParseException("Syntax for x:Static is [Member=][prefix:]typeName.staticMemberName", lineInfo);
- }
-
- var dotIdx = Member.LastIndexOf('.');
- var typename = Member.Substring(0, dotIdx);
- var membername = Member.Substring(dotIdx + 1);
-
- var type = typeResolver.Resolve(typename, serviceProvider);
-
- var pinfo = type.GetRuntimeProperties().FirstOrDefault(pi => pi.Name == membername && pi.GetMethod.IsStatic);
- if (pinfo != null)
- return pinfo.GetMethod.Invoke(null, new object[] { });
-
- var finfo = type.GetRuntimeFields().FirstOrDefault(fi => fi.Name == membername && fi.IsStatic);
- if (finfo != null)
- return finfo.GetValue(null);
-
- lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
- throw new XamlParseException($"No static member found for {Member}", lineInfo);
- }
- }
+ [ContentProperty(nameof(Member))]
+ // [ProvideCompiled("Tizen.NUI.Build.Tasks.StaticExtension")]
+ internal class StaticExtension : IMarkupExtension
+ {
+ public string Member { get; set; }
+
+ public object ProvideValue(IServiceProvider serviceProvider)
+ {
+ IXmlLineInfoProvider lineInfoProvider;
+ IXmlLineInfo lineInfo;
+
+ if (serviceProvider == null)
+ throw new ArgumentNullException(nameof(serviceProvider));
+ var typeResolver = serviceProvider.GetService(typeof (IXamlTypeResolver)) as IXamlTypeResolver;
+ if (typeResolver == null)
+ throw new ArgumentException("No IXamlTypeResolver in IServiceProvider");
+
+ if (string.IsNullOrEmpty(Member) || !Member.Contains("."))
+ {
+ lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
+ throw new XamlParseException("Syntax for x:Static is [Member=][prefix:]typeName.staticMemberName", lineInfo);
+ }
+
+ var dotIdx = Member.LastIndexOf('.');
+ var typename = Member.Substring(0, dotIdx);
+ var membername = Member.Substring(dotIdx + 1);
+
+ var type = typeResolver.Resolve(typename, serviceProvider);
+
+ var pinfo = type.GetRuntimeProperties().FirstOrDefault(pi => pi.Name == membername && pi.GetMethod.IsStatic);
+ if (pinfo != null)
+ return pinfo.GetMethod.Invoke(null, new object[] { });
+
+ var finfo = type.GetRuntimeFields().FirstOrDefault(fi => fi.Name == membername && fi.IsStatic);
+ if (finfo != null)
+ return finfo.GetValue(null);
+
+ lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
+ throw new XamlParseException($"No static member found for {Member}", lineInfo);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [ContentProperty("Key")]
- internal sealed class StaticResourceExtension : IMarkupExtension
- {
- public string Key { get; set; }
+ [ContentProperty("Key")]
+ internal sealed class StaticResourceExtension : IMarkupExtension
+ {
+ public string Key { get; set; }
- public object ProvideValue(IServiceProvider serviceProvider)
- {
- if (serviceProvider == null)
- throw new ArgumentNullException(nameof(serviceProvider));
- if (Key == null) {
- var lineInfoProvider = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
- throw new XamlParseException("you must specify a key in {StaticResource}", lineInfo);
- }
- var valueProvider = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideParentValues;
- if (valueProvider == null)
- throw new ArgumentException();
- var xmlLineInfoProvider = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- var xmlLineInfo = xmlLineInfoProvider != null ? xmlLineInfoProvider.XmlLineInfo : null;
- object resource = null;
+ public object ProvideValue(IServiceProvider serviceProvider)
+ {
+ if (serviceProvider == null)
+ throw new ArgumentNullException(nameof(serviceProvider));
+ if (Key == null) {
+ var lineInfoProvider = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ var lineInfo = (lineInfoProvider != null) ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
+ throw new XamlParseException("you must specify a key in {StaticResource}", lineInfo);
+ }
+ var valueProvider = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideParentValues;
+ if (valueProvider == null)
+ throw new ArgumentException();
+ var xmlLineInfoProvider = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ var xmlLineInfo = xmlLineInfoProvider != null ? xmlLineInfoProvider.XmlLineInfo : null;
+ object resource = null;
- foreach (var p in valueProvider.ParentObjects) {
- var irp = p as IResourcesProvider;
- var resDict = irp != null && irp.IsResourcesCreated ? irp.Resources : p as ResourceDictionary;
- if (resDict == null)
- continue;
- if (resDict.TryGetValue(Key, out resource))
- break;
- }
- resource = resource ?? GetApplicationLevelResource(Key, xmlLineInfo);
+ foreach (var p in valueProvider.ParentObjects) {
+ var irp = p as IResourcesProvider;
+ var resDict = irp != null && irp.IsResourcesCreated ? irp.Resources : p as ResourceDictionary;
+ if (resDict == null)
+ continue;
+ if (resDict.TryGetValue(Key, out resource))
+ break;
+ }
+ resource = resource ?? GetApplicationLevelResource(Key, xmlLineInfo);
- var bp = valueProvider.TargetProperty as BindableProperty;
- var pi = valueProvider.TargetProperty as PropertyInfo;
- var propertyType = bp?.ReturnType ?? pi?.PropertyType;
- if (propertyType == null) {
- if (resource != null) {
- if (resource.GetType().GetTypeInfo().IsGenericType && (resource.GetType().GetGenericTypeDefinition() == typeof(OnPlatform<>) || resource.GetType().GetGenericTypeDefinition() == typeof(OnIdiom<>))) {
- // This is only there to support our backward compat story with pre 2.3.3 compiled Xaml project who was not providing TargetProperty
- var method = resource.GetType().GetRuntimeMethod("op_Implicit", new[] { resource.GetType() });
- resource = method.Invoke(null, new[] { resource });
- }
- }
- return resource;
- }
- if (propertyType.IsAssignableFrom(resource?.GetType()))
- return resource;
- var implicit_op = resource?.GetType().GetImplicitConversionOperator(fromType: resource?.GetType(), toType: propertyType)
- ?? propertyType.GetImplicitConversionOperator(fromType: resource?.GetType(), toType: propertyType);
- if (implicit_op != null)
- return implicit_op.Invoke(resource, new [] { resource });
+ var bp = valueProvider.TargetProperty as BindableProperty;
+ var pi = valueProvider.TargetProperty as PropertyInfo;
+ var propertyType = bp?.ReturnType ?? pi?.PropertyType;
+ if (propertyType == null) {
+ if (resource.GetType().GetTypeInfo().IsGenericType && (resource.GetType().GetGenericTypeDefinition() == typeof(OnPlatform<>) || resource.GetType().GetGenericTypeDefinition() == typeof(OnIdiom<>))) {
+ // This is only there to support our backward compat story with pre 2.3.3 compiled Xaml project who was not providing TargetProperty
+ var method = resource.GetType().GetRuntimeMethod("op_Implicit", new[] { resource.GetType() });
+ resource = method.Invoke(null, new[] { resource });
+ }
+ return resource;
+ }
+ if (propertyType.IsAssignableFrom(resource?.GetType()))
+ return resource;
+ var implicit_op = resource.GetType().GetImplicitConversionOperator(fromType: resource.GetType(), toType: propertyType)
+ ?? propertyType.GetImplicitConversionOperator(fromType: resource.GetType(), toType: propertyType);
+ if (implicit_op != null)
+ return implicit_op.Invoke(resource, new [] { resource });
- if (resource != null) {
- //Special case for https://bugzilla.xamarin.com/show_bug.cgi?id=59818
- //On OnPlatform, check for an opImplicit from the targetType
- if ( Device.Flags != null
- && Device.Flags.Contains("xamlDoubleImplicitOpHack")
- && resource.GetType().GetTypeInfo().IsGenericType
- && (resource.GetType().GetGenericTypeDefinition() == typeof(OnPlatform<>))) {
- var tType = resource.GetType().GenericTypeArguments[0];
- var opImplicit = tType.GetImplicitConversionOperator(fromType: tType, toType: propertyType)
- ?? propertyType.GetImplicitConversionOperator(fromType: tType, toType: propertyType);
+ //Special case for https://bugzilla.xamarin.com/show_bug.cgi?id=59818
+ //On OnPlatform, check for an opImplicit from the targetType
+ if ( Device.Flags != null
+ && Device.Flags.Contains("xamlDoubleImplicitOpHack")
+ && resource.GetType().GetTypeInfo().IsGenericType
+ && (resource.GetType().GetGenericTypeDefinition() == typeof(OnPlatform<>))) {
+ var tType = resource.GetType().GenericTypeArguments[0];
+ var opImplicit = tType.GetImplicitConversionOperator(fromType: tType, toType: propertyType)
+ ?? propertyType.GetImplicitConversionOperator(fromType: tType, toType: propertyType);
- if (opImplicit != null) {
- //convert the OnPlatform<T> to T
- var opPlatformImplicitConversionOperator = resource?.GetType().GetImplicitConversionOperator(fromType: resource?.GetType(), toType: tType);
- resource = opPlatformImplicitConversionOperator?.Invoke(null, new[] { resource });
+ if (opImplicit != null) {
+ //convert the OnPlatform<T> to T
+ var opPlatformImplicitConversionOperator = resource.GetType().GetImplicitConversionOperator(fromType: resource.GetType(), toType: tType);
+ resource = opPlatformImplicitConversionOperator?.Invoke(null, new[] { resource });
- //and convert to toType
- resource = opImplicit.Invoke(null, new[] { resource });
- return resource;
- }
- }
- }
- return resource;
- }
+ //and convert to toType
+ resource = opImplicit.Invoke(null, new[] { resource });
+ return resource;
+ }
+ }
- internal object GetApplicationLevelResource(string key, IXmlLineInfo xmlLineInfo)
- {
- object resource = null;
- // if (Application.Current == null || !((IResourcesProvider)Application.Current).IsResourcesCreated || !Application.Current.Resources.TryGetValue(Key, out resource))
- // throw new XamlParseException($"StaticResource not found for key {Key}", xmlLineInfo);
- return resource;
- }
- }
-}
+ return resource;
+ }
+
+ internal object GetApplicationLevelResource(string key, IXmlLineInfo xmlLineInfo)
+ {
+ object resource = null;
+ if (Application.Current == null || !((IResourcesProvider)Application.Current).IsResourcesCreated || !Application.Current.Resources.TryGetValue(Key, out resource))
+ throw new XamlParseException($"StaticResource not found for key {Key}", xmlLineInfo);
+ return resource;
+ }
+ }
+}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [ContentProperty(nameof(Style))]
- // [ProvideCompiled("Tizen.NUI.Core.XamlC.StyleSheetProvider")]
- internal sealed class StyleSheetExtension : IValueProvider
- {
- public string Style { get; set; }
- public Uri Source { get; set; }
+ [ContentProperty(nameof(Style))]
+ // [ProvideCompiled("Tizen.NUI.Core.XamlC.StyleSheetProvider")]
+ internal sealed class StyleSheetExtension : IValueProvider
+ {
+ public string Style { get; set; }
+ public Uri Source { get; set; }
- object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
- {
- IXmlLineInfo lineInfo;
+ object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
+ {
+ IXmlLineInfo lineInfo;
- if (!string.IsNullOrEmpty(Style) && Source != null) {
- lineInfo = (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo;
- throw new XamlParseException($"StyleSheet can not have both a Source and a content", lineInfo);
- }
+ if (!string.IsNullOrEmpty(Style) && Source != null) {
+ lineInfo = (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo;
+ throw new XamlParseException($"StyleSheet can not have both a Source and a content", lineInfo);
+ }
- if (Source != null) {
- lineInfo = (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo;
- if (Source.IsAbsoluteUri)
- throw new XamlParseException($"Source only accepts Relative URIs", lineInfo);
+ if (Source != null) {
+ lineInfo = (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo;
+ if (Source.IsAbsoluteUri)
+ throw new XamlParseException($"Source only accepts Relative URIs", lineInfo);
- var rootObjectType = (serviceProvider.GetService(typeof(IRootObjectProvider)) as IRootObjectProvider)?.RootObject.GetType();
- if (rootObjectType == null)
- return null;
- var rootTargetPath = XamlResourceIdAttribute.GetPathForType(rootObjectType);
- var resourcePath = ResourceDictionary.RDSourceTypeConverter.GetResourcePath(Source, rootTargetPath);
- var resString = DependencyService.Get<IResourcesLoader>().GetResource(resourcePath, rootObjectType.GetTypeInfo().Assembly, lineInfo);
- return StyleSheet.FromString(resString);
- }
+ var rootObjectType = (serviceProvider.GetService(typeof(IRootObjectProvider)) as IRootObjectProvider)?.RootObject.GetType();
+ if (rootObjectType == null)
+ return null;
+ var rootTargetPath = XamlResourceIdAttribute.GetPathForType(rootObjectType);
+ var resourcePath = ResourceDictionary.RDSourceTypeConverter.GetResourcePath(Source, rootTargetPath);
+ var resString = DependencyService.Get<IResourcesLoader>().GetResource(resourcePath, rootObjectType.GetTypeInfo().Assembly, lineInfo);
+ return StyleSheet.FromString(resString);
+ }
- if (!string.IsNullOrEmpty(Style)) {
- using (var reader = new StringReader(Style))
- return StyleSheet.FromReader(reader);
- }
+ if (!string.IsNullOrEmpty(Style)) {
+ using (var reader = new StringReader(Style))
+ return StyleSheet.FromReader(reader);
+ }
- lineInfo = (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo;
- throw new XamlParseException($"StyleSheet require either a Source or a content", lineInfo);
- }
- }
+ lineInfo = (serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider)?.XmlLineInfo;
+ throw new XamlParseException($"StyleSheet require either a Source or a content", lineInfo);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [ContentProperty("Path")]
- [AcceptEmptyServiceProvider]
- internal sealed class TemplateBindingExtension : IMarkupExtension<BindingBase>
- {
- internal TemplateBindingExtension()
- {
- Mode = BindingMode.Default;
- Path = Tizen.NUI.Binding.Binding.SelfPath;
- }
+ [ContentProperty("Path")]
+ [AcceptEmptyServiceProvider]
+ internal sealed class TemplateBindingExtension : IMarkupExtension<BindingBase>
+ {
+ internal TemplateBindingExtension()
+ {
+ Mode = BindingMode.Default;
+ Path = Tizen.NUI.Binding.Binding.SelfPath;
+ }
- public string Path { get; set; }
+ public string Path { get; set; }
- public BindingMode Mode { get; set; }
+ public BindingMode Mode { get; set; }
- public IValueConverter Converter { get; set; }
+ public IValueConverter Converter { get; set; }
- public object ConverterParameter { get; set; }
+ public object ConverterParameter { get; set; }
- public string StringFormat { get; set; }
+ public string StringFormat { get; set; }
- BindingBase IMarkupExtension<BindingBase>.ProvideValue(IServiceProvider serviceProvider)
- {
- return new TemplateBinding(Path, Mode, Converter, ConverterParameter, StringFormat);
- }
+ BindingBase IMarkupExtension<BindingBase>.ProvideValue(IServiceProvider serviceProvider)
+ {
+ return new TemplateBinding(Path, Mode, Converter, ConverterParameter, StringFormat);
+ }
- object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
- {
- return (this as IMarkupExtension<BindingBase>).ProvideValue(serviceProvider);
- }
- }
+ object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
+ {
+ return (this as IMarkupExtension<BindingBase>).ProvideValue(serviceProvider);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [ContentProperty(nameof(TypeName))]
- // [ProvideCompiled("Tizen.NUI.Build.Tasks.TypeExtension")]
- internal class TypeExtension : IMarkupExtension<Type>
- {
- public string TypeName { get; set; }
+ [ContentProperty(nameof(TypeName))]
+ // [ProvideCompiled("Tizen.NUI.Build.Tasks.TypeExtension")]
+ internal class TypeExtension : IMarkupExtension<Type>
+ {
+ public string TypeName { get; set; }
- public Type ProvideValue(IServiceProvider serviceProvider)
- {
- if (string.IsNullOrEmpty(TypeName))
- throw new InvalidOperationException("TypeName isn't set.");
- if (serviceProvider == null)
- throw new ArgumentNullException(nameof(serviceProvider));
- var typeResolver = serviceProvider.GetService(typeof (IXamlTypeResolver)) as IXamlTypeResolver;
- if (typeResolver == null)
- throw new ArgumentException("No IXamlTypeResolver in IServiceProvider");
+ public Type ProvideValue(IServiceProvider serviceProvider)
+ {
+ if (string.IsNullOrEmpty(TypeName))
+ throw new InvalidOperationException("TypeName isn't set.");
+ if (serviceProvider == null)
+ throw new ArgumentNullException(nameof(serviceProvider));
+ var typeResolver = serviceProvider.GetService(typeof (IXamlTypeResolver)) as IXamlTypeResolver;
+ if (typeResolver == null)
+ throw new ArgumentException("No IXamlTypeResolver in IServiceProvider");
- return typeResolver.Resolve(TypeName, serviceProvider);
- }
+ return typeResolver.Resolve(TypeName, serviceProvider);
+ }
- object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
- {
- return (this as IMarkupExtension<Type>).ProvideValue(serviceProvider);
- }
- }
+ object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
+ {
+ return (this as IMarkupExtension<Type>).ProvideValue(serviceProvider);
+ }
+ }
}
\ No newline at end of file
using System.Collections.Generic;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Xaml
{
- internal class NamescopingVisitor : IXamlNodeVisitor
- {
- readonly Dictionary<INode, INameScope> scopes = new Dictionary<INode, INameScope>();
+ internal class NamescopingVisitor : IXamlNodeVisitor
+ {
+ readonly Dictionary<INode, INameScope> scopes = new Dictionary<INode, INameScope>();
- public NamescopingVisitor(HydrationContext context)
- {
- Values = context.Values;
- }
+ public NamescopingVisitor(HydrationContext context)
+ {
+ Values = context.Values;
+ }
- Dictionary<INode, object> Values { get; set; }
+ Dictionary<INode, object> Values { get; set; }
- public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
- public bool StopOnDataTemplate => false;
- public bool StopOnResourceDictionary => false;
- public bool VisitNodeOnDataTemplate => true;
- public bool SkipChildren(INode node, INode parentNode) => false;
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
+ public bool StopOnDataTemplate => false;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => true;
+ public bool SkipChildren(INode node, INode parentNode) => false;
- public void Visit(ValueNode node, INode parentNode)
- {
- scopes[node] = scopes[parentNode];
- }
+ public void Visit(ValueNode node, INode parentNode)
+ {
+ scopes[node] = scopes[parentNode];
+ }
- public void Visit(MarkupNode node, INode parentNode)
- {
- scopes[node] = scopes[parentNode];
- }
+ public void Visit(MarkupNode node, INode parentNode)
+ {
+ scopes[node] = scopes[parentNode];
+ }
- public void Visit(ElementNode node, INode parentNode)
- {
- var ns = parentNode == null || IsDataTemplate(node, parentNode) || IsStyle(node, parentNode) || IsVisualStateGroupList(node)
- ? new NameScope()
- : scopes[parentNode];
- node.Namescope = ns;
- scopes[node] = ns;
- }
+ public void Visit(ElementNode node, INode parentNode)
+ {
+ var ns = parentNode == null || IsDataTemplate(node, parentNode) || IsStyle(node, parentNode) || IsVisualStateGroupList(node)
+ ? new NameScope()
+ : scopes[parentNode];
+ node.Namescope = ns;
+ scopes[node] = ns;
+ }
- public void Visit(RootNode node, INode parentNode)
- {
- var ns = new NameScope();
- node.Namescope = ns;
- scopes[node] = ns;
- }
+ public void Visit(RootNode node, INode parentNode)
+ {
+ var ns = new NameScope();
+ node.Namescope = ns;
+ scopes[node] = ns;
+ }
- public void Visit(ListNode node, INode parentNode)
- {
- scopes[node] = scopes[parentNode];
- }
+ public void Visit(ListNode node, INode parentNode)
+ {
+ scopes[node] = scopes[parentNode];
+ }
- static bool IsDataTemplate(INode node, INode parentNode)
- {
- var parentElement = parentNode as IElementNode;
- INode createContent;
- if (parentElement != null && parentElement.Properties.TryGetValue(XmlName._CreateContent, out createContent) &&
- createContent == node)
- return true;
- return false;
- }
+ static bool IsDataTemplate(INode node, INode parentNode)
+ {
+ var parentElement = parentNode as IElementNode;
+ INode createContent;
+ if (parentElement != null && parentElement.Properties.TryGetValue(XmlName._CreateContent, out createContent) &&
+ createContent == node)
+ return true;
+ return false;
+ }
- static bool IsStyle(INode node, INode parentNode)
- {
- var pnode = parentNode as ElementNode;
- return pnode != null && pnode.XmlType.Name == "Style";
- }
+ static bool IsStyle(INode node, INode parentNode)
+ {
+ var pnode = parentNode as ElementNode;
+ return pnode != null && pnode.XmlType.Name == "Style";
+ }
- static bool IsVisualStateGroupList(ElementNode node)
- {
- return node != null && node.XmlType.Name == "VisualStateGroup" && node.Parent is IListNode;
- }
- }
+ static bool IsVisualStateGroupList(ElementNode node)
+ {
+ return node != null && node.XmlType.Name == "VisualStateGroup" && node.Parent is IListNode;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- class PruneIgnoredNodesVisitor : IXamlNodeVisitor
- {
- public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
- public bool StopOnDataTemplate => false;
- public bool StopOnResourceDictionary => false;
- public bool VisitNodeOnDataTemplate => true;
- public bool SkipChildren(INode node, INode parentNode) => false;
+ internal class PruneIgnoredNodesVisitor : IXamlNodeVisitor
+ {
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
+ public bool StopOnDataTemplate => false;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => true;
+ public bool SkipChildren(INode node, INode parentNode) => false;
- public void Visit(ElementNode node, INode parentNode)
- {
- foreach (var propertyKvp in node.Properties)
- {
- var propertyName = propertyKvp.Key;
- var propertyValue = (propertyKvp.Value as ValueNode)?.Value as string;
- if (propertyValue == null)
- continue;
- if (!propertyName.Equals(XamlParser.McUri, "Ignorable"))
- continue;
- (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>())).AddRange(propertyValue.Split(','));
- }
+ public void Visit(ElementNode node, INode parentNode)
+ {
+ foreach (var propertyKvp in node.Properties)
+ {
+ var propertyName = propertyKvp.Key;
+ var propertyValue = (propertyKvp.Value as ValueNode)?.Value as string;
+ if (propertyValue == null)
+ continue;
+ if (!propertyName.Equals(XamlParser.McUri, "Ignorable"))
+ continue;
+ (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>())).AddRange(propertyValue.Split(','));
+ }
- foreach (var propertyKvp in node.Properties.ToList())
- {
- // skip d:foo="bar"
- var prefix = node.NamespaceResolver.LookupPrefix(propertyKvp.Key.NamespaceURI);
- if (node.SkipPrefix(prefix))
- node.Properties.Remove(propertyKvp.Key);
- var propNs = (propertyKvp.Value as IElementNode)?.NamespaceURI ?? "";
- var propPrefix = node.NamespaceResolver.LookupPrefix(propNs);
- if (node.SkipPrefix(propPrefix))
- node.Properties.Remove(propertyKvp.Key);
- }
+ foreach (var propertyKvp in node.Properties.ToList())
+ {
+ // skip d:foo="bar"
+ var prefix = node.NamespaceResolver.LookupPrefix(propertyKvp.Key.NamespaceURI);
+ if (node.SkipPrefix(prefix))
+ node.Properties.Remove(propertyKvp.Key);
+ var propNs = (propertyKvp.Value as IElementNode)?.NamespaceURI ?? "";
+ var propPrefix = node.NamespaceResolver.LookupPrefix(propNs);
+ if (node.SkipPrefix(propPrefix))
+ node.Properties.Remove(propertyKvp.Key);
+ }
- foreach (var prop in node.CollectionItems.ToList())
- {
- var propNs = (prop as IElementNode)?.NamespaceURI ?? "";
- var propPrefix = node.NamespaceResolver.LookupPrefix(propNs);
- if (node.SkipPrefix(propPrefix))
- node.CollectionItems.Remove(prop);
- }
+ foreach (var prop in node.CollectionItems.ToList())
+ {
+ var propNs = (prop as IElementNode)?.NamespaceURI ?? "";
+ var propPrefix = node.NamespaceResolver.LookupPrefix(propNs);
+ if (node.SkipPrefix(propPrefix))
+ node.CollectionItems.Remove(prop);
+ }
- if (node.SkipPrefix(node.NamespaceResolver.LookupPrefix(node.NamespaceURI)))
- {
- node.Properties.Clear();
- node.CollectionItems.Clear();
- }
- }
+ if (node.SkipPrefix(node.NamespaceResolver.LookupPrefix(node.NamespaceURI)))
+ {
+ node.Properties.Clear();
+ node.CollectionItems.Clear();
+ }
+ }
- public void Visit(RootNode node, INode parentNode)
- {
- Visit((ElementNode)node, node);
- }
+ public void Visit(RootNode node, INode parentNode)
+ {
+ Visit((ElementNode)node, node);
+ }
- public void Visit(MarkupNode node, INode parentNode)
- {
- }
+ public void Visit(MarkupNode node, INode parentNode)
+ {
+ }
- public void Visit(ListNode node, INode parentNode)
- {
- foreach (var prop in node.CollectionItems.ToList())
- {
- var propNs = (prop as IElementNode)?.NamespaceURI ?? "";
- var propPrefix = node.NamespaceResolver.LookupPrefix(propNs);
- if (node.SkipPrefix(propPrefix))
- node.CollectionItems.Remove(prop);
- }
- }
+ public void Visit(ListNode node, INode parentNode)
+ {
+ foreach (var prop in node.CollectionItems.ToList())
+ {
+ var propNs = (prop as IElementNode)?.NamespaceURI ?? "";
+ var propPrefix = node.NamespaceResolver.LookupPrefix(propNs);
+ if (node.SkipPrefix(propPrefix))
+ node.CollectionItems.Remove(prop);
+ }
+ }
- public void Visit(ValueNode node, INode parentNode)
- {
- }
- }
+ public void Visit(ValueNode node, INode parentNode)
+ {
+ }
+ }
}
\ No newline at end of file
using System.Linq;
using System.Reflection;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal static class ReflectionExtensions
- {
- public static FieldInfo GetField(this Type type, Func<FieldInfo, bool> predicate)
- {
- return GetFields(type).FirstOrDefault(predicate);
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal static class ReflectionExtensions
+ {
+ public static FieldInfo GetField(this Type type, Func<FieldInfo, bool> predicate)
+ {
+ return GetFields(type).FirstOrDefault(predicate);
+ }
- public static FieldInfo GetField(this Type type, string name)
- {
- return type.GetField(fi => fi.Name == name);
- }
+ public static FieldInfo GetField(this Type type, string name)
+ {
+ return type.GetField(fi => fi.Name == name);
+ }
- public static IEnumerable<FieldInfo> GetFields(this Type type)
- {
- return GetParts(type, i => i.DeclaredFields);
- }
+ public static IEnumerable<FieldInfo> GetFields(this Type type)
+ {
+ return GetParts(type, i => i.DeclaredFields);
+ }
- public static IEnumerable<PropertyInfo> GetProperties(this Type type)
- {
- return GetParts(type, ti => ti.DeclaredProperties);
- }
+ public static IEnumerable<PropertyInfo> GetProperties(this Type type)
+ {
+ return GetParts(type, ti => ti.DeclaredProperties);
+ }
- public static PropertyInfo GetProperty(this Type type, string name)
- {
- Type t = type;
- while (t != null)
- {
- System.Reflection.TypeInfo ti = t.GetTypeInfo();
- PropertyInfo property = ti.GetDeclaredProperty(name);
- if (property != null)
- return property;
+ public static PropertyInfo GetProperty(this Type type, string name)
+ {
+ Type t = type;
+ while (t != null)
+ {
+ System.Reflection.TypeInfo ti = t.GetTypeInfo();
+ PropertyInfo property = ti.GetDeclaredProperty(name);
+ if (property != null)
+ return property;
- t = ti.BaseType;
- }
+ t = ti.BaseType;
+ }
- return null;
- }
+ return null;
+ }
- public static bool IsAssignableFrom(this Type self, Type c)
- {
- return self.GetTypeInfo().IsAssignableFrom(c.GetTypeInfo());
- }
+ public static bool IsAssignableFrom(this Type self, Type c)
+ {
+ return self.GetTypeInfo().IsAssignableFrom(c.GetTypeInfo());
+ }
- public static bool IsInstanceOfType(this Type self, object o)
- {
- return self.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo());
- }
+ public static bool IsInstanceOfType(this Type self, object o)
+ {
+ return self.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo());
+ }
- static IEnumerable<T> GetParts<T>(Type type, Func<System.Reflection.TypeInfo, IEnumerable<T>> selector)
- {
- Type t = type;
- while (t != null)
- {
- System.Reflection.TypeInfo ti = t.GetTypeInfo();
- foreach (T f in selector(ti))
- yield return f;
- t = ti.BaseType;
- }
- }
- }
+ static IEnumerable<T> GetParts<T>(Type type, Func<System.Reflection.TypeInfo, IEnumerable<T>> selector)
+ {
+ Type t = type;
+ while (t != null)
+ {
+ System.Reflection.TypeInfo ti = t.GetTypeInfo();
+ foreach (T f in selector(ti))
+ yield return f;
+ t = ti.BaseType;
+ }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- class RegisterXNamesVisitor : IXamlNodeVisitor
- {
- public RegisterXNamesVisitor(HydrationContext context)
- {
- Values = context.Values;
- }
+ internal class RegisterXNamesVisitor : IXamlNodeVisitor
+ {
+ public RegisterXNamesVisitor(HydrationContext context)
+ {
+ Values = context.Values;
+ }
- Dictionary<INode, object> Values { get; }
+ Dictionary<INode, object> Values { 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 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 void Visit(ValueNode node, INode parentNode)
- {
- if (!IsXNameProperty(node, parentNode))
- return;
- try
- {
- ((IElementNode)parentNode).Namescope.RegisterName((string)node.Value, Values[parentNode]);
- }
- catch (ArgumentException ae)
- {
- if (ae.ParamName != "name")
- throw ae;
- throw new XamlParseException($"An element with the name \"{(string)node.Value}\" already exists in this NameScope", node);
- }
- var element = Values[parentNode] as Element;
- if (element != null)
- element.StyleId = element.StyleId ?? (string)node.Value;
- }
+ public void Visit(ValueNode node, INode parentNode)
+ {
+ if (!IsXNameProperty(node, parentNode))
+ return;
+ try
+ {
+ ((IElementNode)parentNode).Namescope.RegisterName((string)node.Value, Values[parentNode]);
+ }
+ catch (ArgumentException ae)
+ {
+ if (ae.ParamName != "name")
+ throw ae;
+ throw new XamlParseException($"An element with the name \"{(string)node.Value}\" already exists in this NameScope", node);
+ }
+ var element = Values[parentNode] as Element;
+ if (element != null)
+ element.StyleId = element.StyleId ?? (string)node.Value;
+ }
- public void Visit(MarkupNode node, INode parentNode)
- {
- }
+ public void Visit(MarkupNode node, INode parentNode)
+ {
+ }
- public void Visit(ElementNode node, INode parentNode)
- {
- }
+ public void Visit(ElementNode node, INode parentNode)
+ {
+ }
- public void Visit(RootNode node, INode parentNode)
- {
- }
+ public void Visit(RootNode node, INode parentNode)
+ {
+ }
- public void Visit(ListNode node, INode parentNode)
- {
- }
+ public void Visit(ListNode node, INode parentNode)
+ {
+ }
- static bool IsXNameProperty(ValueNode node, INode parentNode)
- {
- var parentElement = parentNode as IElementNode;
- INode xNameNode;
- if (parentElement != null && parentElement.Properties.TryGetValue(XmlName.xName, out xNameNode) && xNameNode == node)
- return true;
- return false;
- }
- }
+ static bool IsXNameProperty(ValueNode node, INode parentNode)
+ {
+ var parentElement = parentNode as IElementNode;
+ INode xNameNode;
+ if (parentElement != null && parentElement.Properties.TryGetValue(XmlName.xName, out xNameNode) && xNameNode == node)
+ return true;
+ return false;
+ }
+ }
}
\ No newline at end of file
using System.Reflection;
using Tizen.NUI;
using System.Xml;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
// [assembly:Dependency(typeof(Tizen.NUI.Xaml.ResourcesLoader))]
namespace Tizen.NUI.Xaml
{
- class ResourcesLoader : IResourcesLoader
- {
- public T CreateFromResource<T>(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo) where T: new()
- {
- var alternateResource = ResourceLoader.ResourceProvider?.Invoke(assembly.GetName(), resourcePath);
- if (alternateResource != null) {
- var rd = new T();
- rd.LoadFromXaml(alternateResource);
- return rd;
- }
+ internal class ResourcesLoader : IResourcesLoader
+ {
+ public T CreateFromResource<T>(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo) where T: new()
+ {
+ var alternateResource = ResourceLoader.ResourceProvider?.Invoke(assembly.GetName(), resourcePath);
+ if (alternateResource != null) {
+ var rd = new T();
+ rd.LoadFromXaml(alternateResource);
+ return rd;
+ }
- var resourceId = XamlResourceIdAttribute.GetResourceIdForPath(assembly, resourcePath);
- if (resourceId == null)
- throw new XamlParseException($"Resource '{resourcePath}' not found.", lineInfo);
+ var resourceId = XamlResourceIdAttribute.GetResourceIdForPath(assembly, resourcePath);
+ if (resourceId == null)
+ throw new XamlParseException($"Resource '{resourcePath}' not found.", lineInfo);
- using (var stream = assembly.GetManifestResourceStream(resourceId)) {
- if (stream == null)
- throw new XamlParseException($"No resource found for '{resourceId}'.", lineInfo);
- using (var reader = new StreamReader(stream)) {
- var rd = new T();
- rd.LoadFromXaml(reader.ReadToEnd());
- return rd;
- }
- }
- }
+ using (var stream = assembly.GetManifestResourceStream(resourceId)) {
+ if (stream == null)
+ throw new XamlParseException($"No resource found for '{resourceId}'.", lineInfo);
+ using (var reader = new StreamReader(stream)) {
+ var rd = new T();
+ rd.LoadFromXaml(reader.ReadToEnd());
+ return rd;
+ }
+ }
+ }
- public string GetResource(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo)
- {
- var alternateResource = ResourceLoader.ResourceProvider?.Invoke(assembly.GetName(), resourcePath);
- if (alternateResource != null)
- return alternateResource;
+ public string GetResource(string resourcePath, Assembly assembly, IXmlLineInfo lineInfo)
+ {
+ var alternateResource = ResourceLoader.ResourceProvider?.Invoke(assembly.GetName(), resourcePath);
+ if (alternateResource != null)
+ return alternateResource;
- var resourceId = XamlResourceIdAttribute.GetResourceIdForPath(assembly, resourcePath);
- if (resourceId == null)
- throw new XamlParseException($"Resource '{resourcePath}' not found.", lineInfo);
+ var resourceId = XamlResourceIdAttribute.GetResourceIdForPath(assembly, resourcePath);
+ if (resourceId == null)
+ throw new XamlParseException($"Resource '{resourcePath}' not found.", lineInfo);
- using (var stream = assembly.GetManifestResourceStream(resourceId)) {
- if (stream == null)
- throw new XamlParseException($"No resource found for '{resourceId}'.", lineInfo);
- using (var reader = new StreamReader(stream))
- return reader.ReadToEnd();
- }
- }
- }
+ using (var stream = assembly.GetManifestResourceStream(resourceId)) {
+ if (stream == null)
+ throw new XamlParseException($"No resource found for '{resourceId}'.", lineInfo);
+ using (var reader = new StreamReader(stream))
+ return reader.ReadToEnd();
+ }
+ }
+ }
}
\ No newline at end of file
+
using System.Collections.Generic;
using System.Xml;
namespace Tizen.NUI.Xaml
{
- static class TypeArgumentsParser
- {
- public static IList<XmlType> ParseExpression(string expression, IXmlNamespaceResolver resolver, IXmlLineInfo lineInfo)
- {
- var typeList = new List<XmlType>();
- while (!string.IsNullOrWhiteSpace(expression))
- {
- var match = expression;
- typeList.Add(Parse(match, ref expression, resolver, lineInfo));
- }
- return typeList;
- }
+ internal static class TypeArgumentsParser
+ {
+ public static IList<XmlType> ParseExpression(string expression, IXmlNamespaceResolver resolver, IXmlLineInfo lineInfo)
+ {
+ var typeList = new List<XmlType>();
+ while (!string.IsNullOrWhiteSpace(expression))
+ {
+ var match = expression;
+ typeList.Add(Parse(match, ref expression, resolver, lineInfo));
+ }
+ return typeList;
+ }
- static XmlType Parse(string match, ref string remaining, IXmlNamespaceResolver resolver, IXmlLineInfo lineinfo)
- {
- remaining = null;
- int parensCount = 0;
- int pos = 0;
- bool isGeneric = false;
+ static XmlType Parse(string match, ref string remaining, IXmlNamespaceResolver resolver, IXmlLineInfo lineinfo)
+ {
+ remaining = null;
+ int parensCount = 0;
+ int pos = 0;
+ bool isGeneric = false;
- for (pos = 0; pos < match.Length; pos++)
- {
- if (match[pos] == '(')
- {
- parensCount++;
- isGeneric = true;
- }
- else if (match[pos] == ')')
- parensCount--;
- else if (match[pos] == ',' && parensCount == 0)
- {
- remaining = match.Substring(pos + 1);
- break;
- }
- }
- var type = match.Substring(0, pos).Trim();
+ for (pos = 0; pos < match.Length; pos++)
+ {
+ if (match[pos] == '(')
+ {
+ parensCount++;
+ isGeneric = true;
+ }
+ else if (match[pos] == ')')
+ parensCount--;
+ else if (match[pos] == ',' && parensCount == 0)
+ {
+ remaining = match.Substring(pos + 1);
+ break;
+ }
+ }
+ var type = match.Substring(0, pos).Trim();
- IList<XmlType> typeArguments = null;
- if (isGeneric)
- {
- typeArguments = ParseExpression(
- type.Substring(type.IndexOf('(') + 1, type.LastIndexOf(')') - type.IndexOf('(') - 1), resolver, lineinfo);
- type = type.Substring(0, type.IndexOf('('));
- }
+ IList<XmlType> typeArguments = null;
+ if (isGeneric)
+ {
+ typeArguments = ParseExpression(
+ type.Substring(type.IndexOf('(') + 1, type.LastIndexOf(')') - type.IndexOf('(') - 1), resolver, lineinfo);
+ type = type.Substring(0, type.IndexOf('('));
+ }
- var split = type.Split(':');
- if (split.Length > 2)
- return null;
+ var split = type.Split(':');
+ if (split.Length > 2)
+ return null;
- string prefix, name;
- if (split.Length == 2) {
- prefix = split [0];
- name = split [1];
- } else {
- prefix = "";
- name = split [0];
- }
+ string prefix, name;
+ if (split.Length == 2) {
+ prefix = split [0];
+ name = split [1];
+ } else {
+ prefix = "";
+ name = split [0];
+ }
- var namespaceuri = resolver.LookupNamespace(prefix);
- if (namespaceuri == null)
- throw new XamlParseException($"No xmlns declaration for prefix '{prefix}'.", lineinfo, null);
- return new XmlType(namespaceuri, name, typeArguments);
- }
- }
+ var namespaceuri = resolver.LookupNamespace(prefix);
+ if (namespaceuri == null)
+ throw new XamlParseException($"No xmlns declaration for prefix '{prefix}'.", lineinfo, null);
+ return new XmlType(namespaceuri, name, typeArguments);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [System.AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
- internal sealed class TypeConversionAttribute : Attribute
- {
- public Type TargetType { get; private set; }
+ [System.AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
+ internal sealed class TypeConversionAttribute : Attribute
+ {
+ public Type TargetType { get; private set; }
- public TypeConversionAttribute(Type targetType)
- {
- TargetType = targetType;
- }
- }
+ public TypeConversionAttribute(Type targetType)
+ {
+ TargetType = targetType;
+ }
+ }
}
\ No newline at end of file
using System.Globalization;
using System.Linq;
using System.Reflection;
-// using Tizen.NUI.Internals;
+// using Tizen.NUI.Binding.Internals;
using Tizen.NUI.Xaml.Internals;
using Tizen.NUI.Binding;
namespace Tizen.NUI.Xaml
{
- static class TypeConversionExtensions
- {
- internal static object ConvertTo(this object value, Type toType, Func<ParameterInfo> pinfoRetriever,
- IServiceProvider serviceProvider)
- {
- Func<TypeConverter> getConverter = () =>
- {
- ParameterInfo pInfo;
- if (pinfoRetriever == null || (pInfo = pinfoRetriever()) == null)
- return null;
-
- var converterTypeName = pInfo.CustomAttributes.GetTypeConverterTypeName();
- if (converterTypeName == null)
- return null;
- var convertertype = Type.GetType(converterTypeName);
- return (TypeConverter)Activator.CreateInstance(convertertype);
- };
-
- return ConvertTo(value, toType, getConverter, serviceProvider);
- }
-
- internal static object ConvertTo(this object value, Type toType, Func<MemberInfo> minfoRetriever,
- IServiceProvider serviceProvider)
- {
- Func<object> getConverter = () =>
- {
- MemberInfo memberInfo;
-
- var converterTypeName = toType.GetTypeInfo().CustomAttributes.GetTypeConverterTypeName();
- if (minfoRetriever != null && (memberInfo = minfoRetriever()) != null)
- converterTypeName = memberInfo.CustomAttributes.GetTypeConverterTypeName() ?? converterTypeName;
- if (converterTypeName == null)
- return null;
-
- var convertertype = Type.GetType(converterTypeName);
- return Activator.CreateInstance(convertertype);
- };
-
- return ConvertTo(value, toType, getConverter, serviceProvider);
- }
-
- static string GetTypeConverterTypeName(this IEnumerable<CustomAttributeData> attributes)
- {
- var converterAttribute =
- attributes.FirstOrDefault(cad => TypeConverterAttribute.TypeConvertersType.Contains(cad.AttributeType.FullName));
- if (converterAttribute == null)
- return null;
- if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof (string))
- return (string)converterAttribute.ConstructorArguments[0].Value;
- if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof (Type))
- return ((Type)converterAttribute.ConstructorArguments[0].Value).AssemblyQualifiedName;
- return null;
- }
-
- //Don't change the name or the signature of this, it's used by XamlC
- public static object ConvertTo(this object value, Type toType, Type convertertype, IServiceProvider serviceProvider)
- {
- if (convertertype == null)
- return value.ConvertTo(toType, (Func<object>)null, serviceProvider);
- Func<object> getConverter = () => Activator.CreateInstance(convertertype);
- ;
- return value.ConvertTo(toType, getConverter, serviceProvider);
- }
-
- internal static object ConvertTo(this object value, Type toType, Func<object> getConverter,
- IServiceProvider serviceProvider)
- {
- if (value == null)
- return null;
-
- var str = value as string;
- if (str != null)
- {
- //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)
- {
- 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
- if (toType.GetTypeInfo().IsGenericType && toType.GetGenericTypeDefinition() == typeof (Nullable<>))
- toType = Nullable.GetUnderlyingType(toType);
-
- //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))
- return Int16.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof(Int32))
- return Int32.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof(Int64))
- return Int64.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof(Byte))
- return Byte.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof(UInt16))
- return UInt16.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof(UInt32))
- return UInt32.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof(UInt64))
- return UInt64.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof (Single))
- return Single.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof (Double))
- return Double.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof (Boolean))
- return Boolean.Parse(str);
- if (toType == typeof (TimeSpan))
- return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof (DateTime))
- return DateTime.Parse(str, CultureInfo.InvariantCulture);
- if (toType == typeof(Char)) {
- char c = '\0';
- Char.TryParse(str, out c);
- return c;
- }
- if (toType == typeof (String) && str.StartsWith("{}", StringComparison.Ordinal))
- return str.Substring(2);
- if (toType == typeof (String))
- return value;
- if (toType == typeof(Decimal))
- return Decimal.Parse(str, CultureInfo.InvariantCulture);
- }
-
- //if the value is not assignable and there's an implicit conversion, convert
- if (value != null && !toType.IsAssignableFrom(value.GetType())) {
- var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
- ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);
-
- if (opImplicit != null) {
- value = opImplicit.Invoke(null, new[] { value });
- return value;
- }
- }
-
- var nativeValueConverterService = DependencyService.Get<INativeValueConverterService>();
-
- object nativeValue = null;
- if (nativeValueConverterService != null && nativeValueConverterService.ConvertTo(value, toType, out nativeValue))
- return nativeValue;
-
- return value;
- }
-
- internal static MethodInfo GetImplicitConversionOperator(this Type onType, Type fromType, Type toType)
- {
+ internal static class TypeConversionExtensions
+ {
+ internal static object ConvertTo(this object value, Type toType, Func<ParameterInfo> pinfoRetriever,
+ IServiceProvider serviceProvider)
+ {
+ Func<TypeConverter> getConverter = () =>
+ {
+ ParameterInfo pInfo;
+ if (pinfoRetriever == null || (pInfo = pinfoRetriever()) == null)
+ return null;
+
+ var converterTypeName = pInfo.CustomAttributes.GetTypeConverterTypeName();
+ if (converterTypeName == null)
+ return null;
+ var convertertype = Type.GetType(converterTypeName);
+ return (TypeConverter)Activator.CreateInstance(convertertype);
+ };
+
+ return ConvertTo(value, toType, getConverter, serviceProvider);
+ }
+
+ internal static object ConvertTo(this object value, Type toType, Func<MemberInfo> minfoRetriever,
+ IServiceProvider serviceProvider)
+ {
+ Func<object> getConverter = () =>
+ {
+ MemberInfo memberInfo;
+
+ var converterTypeName = toType.GetTypeInfo().CustomAttributes.GetTypeConverterTypeName();
+ if (minfoRetriever != null && (memberInfo = minfoRetriever()) != null)
+ converterTypeName = memberInfo.CustomAttributes.GetTypeConverterTypeName() ?? converterTypeName;
+ if (converterTypeName == null)
+ return null;
+
+ var convertertype = Type.GetType(converterTypeName);
+ return Activator.CreateInstance(convertertype);
+ };
+
+ return ConvertTo(value, toType, getConverter, serviceProvider);
+ }
+
+ static string GetTypeConverterTypeName(this IEnumerable<CustomAttributeData> attributes)
+ {
+ var converterAttribute =
+ attributes.FirstOrDefault(cad => TypeConverterAttribute.TypeConvertersType.Contains(cad.AttributeType.FullName));
+ if (converterAttribute == null)
+ return null;
+ if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof (string))
+ return (string)converterAttribute.ConstructorArguments[0].Value;
+ if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof (Type))
+ return ((Type)converterAttribute.ConstructorArguments[0].Value).AssemblyQualifiedName;
+ return null;
+ }
+
+ //Don't change the name or the signature of this, it's used by XamlC
+ public static object ConvertTo(this object value, Type toType, Type convertertype, IServiceProvider serviceProvider)
+ {
+ if (convertertype == null)
+ return value.ConvertTo(toType, (Func<object>)null, serviceProvider);
+ Func<object> getConverter = () => Activator.CreateInstance(convertertype);
+ ;
+ return value.ConvertTo(toType, getConverter, serviceProvider);
+ }
+
+ internal static object ConvertTo(this object value, Type toType, Func<object> getConverter,
+ IServiceProvider serviceProvider)
+ {
+ if (value == null)
+ return null;
+
+ var str = value as string;
+ if (str != null)
+ {
+ //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)
+ {
+ 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
+ if (toType.GetTypeInfo().IsGenericType && toType.GetGenericTypeDefinition() == typeof (Nullable<>))
+ toType = Nullable.GetUnderlyingType(toType);
+
+ //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))
+ return Int16.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Int32))
+ return Int32.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Int64))
+ return Int64.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Byte))
+ return Byte.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(UInt16))
+ return UInt16.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(UInt32))
+ return UInt32.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(UInt64))
+ return UInt64.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof (Single))
+ return Single.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof (Double))
+ return Double.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof (Boolean))
+ return Boolean.Parse(str);
+ if (toType == typeof (TimeSpan))
+ return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof (DateTime))
+ return DateTime.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Char)) {
+ char c = '\0';
+ Char.TryParse(str, out c);
+ return c;
+ }
+ if (toType == typeof (String) && str.StartsWith("{}", StringComparison.Ordinal))
+ return str.Substring(2);
+ if (toType == typeof (String))
+ return value;
+ if (toType == typeof(Decimal))
+ return Decimal.Parse(str, CultureInfo.InvariantCulture);
+ }
+
+ //if the value is not assignable and there's an implicit conversion, convert
+ if (value != null && !toType.IsAssignableFrom(value.GetType())) {
+ var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
+ ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);
+
+ if (opImplicit != null) {
+ value = opImplicit.Invoke(null, new[] { value });
+ return value;
+ }
+ }
+
+ var nativeValueConverterService = DependencyService.Get<INativeValueConverterService>();
+
+ object nativeValue = null;
+ if (nativeValueConverterService != null && nativeValueConverterService.ConvertTo(value, toType, out nativeValue))
+ return nativeValue;
+
+ return value;
+ }
+
+ internal static MethodInfo GetImplicitConversionOperator(this Type onType, Type fromType, Type toType)
+ {
#if NETSTANDARD1_0
- var mi = onType.GetRuntimeMethod("op_Implicit", new[] { fromType });
+ var mi = onType.GetRuntimeMethod("op_Implicit", new[] { fromType });
#else
- var bindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
- var mi = onType.GetMethod("op_Implicit", bindingFlags, null, new[] { fromType }, null);
+ var bindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
+ var mi = onType.GetMethod("op_Implicit", bindingFlags, null, new[] { fromType }, null);
#endif
- if (mi == null) return null;
- if (!mi.IsSpecialName) return null;
- if (!mi.IsPublic) return null;
- if (!mi.IsStatic) return null;
- if (!toType.IsAssignableFrom(mi.ReturnType)) return null;
-
- return mi;
- }
- }
+ if (mi == null) return null;
+ if (!mi.IsSpecialName) return null;
+ if (!mi.IsPublic) return null;
+ if (!mi.IsStatic) return null;
+ if (!toType.IsAssignableFrom(mi.ReturnType)) return null;
+
+ return mi;
+ }
+ }
}
\ No newline at end of file
// [assembly:Dependency(typeof(ValueConverterProvider))]
namespace Tizen.NUI.Xaml
{
- class ValueConverterProvider : IValueConverterProvider
- {
- public object Convert(object value, Type toType, Func<MemberInfo> minfoRetriever, IServiceProvider serviceProvider)
- {
- return value.ConvertTo(toType, minfoRetriever, serviceProvider);
- }
- }
+ internal class ValueConverterProvider : IValueConverterProvider
+ {
+ public object Convert(object value, Type toType, Func<MemberInfo> minfoRetriever, IServiceProvider serviceProvider)
+ {
+ return value.ConvertTo(toType, minfoRetriever, serviceProvider);
+ }
+ }
}
namespace Tizen.NUI.Xaml
{
- internal static class VisualStateManager
- {
- internal class CommonStates
- {
- public const string Normal = "Normal";
- public const string Disabled = "Disabled";
- public const string Focused = "Focused";
- }
-
- public static readonly BindableProperty VisualStateGroupsProperty =
- BindableProperty.CreateAttached("VisualStateGroups", typeof(VisualStateGroupList), typeof(/*VisualElement*/BaseHandle),
- defaultValue: null, propertyChanged: VisualStateGroupsPropertyChanged,
- defaultValueCreator: bindable => new VisualStateGroupList());
-
- static void VisualStateGroupsPropertyChanged(BindableObject bindable, object oldValue, object newValue)
- {
- GoToState((/*VisualElement*/BaseHandle)bindable, CommonStates.Normal);
- }
-
- public static IList<VisualStateGroup> GetVisualStateGroups(/*VisualElement*/BaseHandle visualElement)
- {
- return (IList<VisualStateGroup>)visualElement.GetValue(VisualStateGroupsProperty);
- }
-
- public static void SetVisualStateGroups(/*VisualElement*/BaseHandle visualElement, VisualStateGroupList value)
- {
- visualElement.SetValue(VisualStateGroupsProperty, value);
- }
-
- public static bool GoToState(/*VisualElement*/BaseHandle visualElement, string name)
- {
- if (!visualElement.IsSet(VisualStateGroupsProperty))
- {
- return false;
- }
-
- var groups = (IList<VisualStateGroup>)visualElement.GetValue(VisualStateGroupsProperty);
-
- foreach (VisualStateGroup group in groups)
- {
- if (group.CurrentState?.Name == name)
- {
- // We're already in the target state; nothing else to do
- return true;
- }
-
- // See if this group contains the new state
- var target = group.GetState(name);
- if (target == null)
- {
- continue;
- }
-
- // If we've got a new state to transition to, unapply the setters from the current state
- if (group.CurrentState != null)
- {
- foreach (Setter setter in group.CurrentState.Setters)
- {
- setter.UnApply(visualElement);
- }
- }
-
- // Update the current state
- group.CurrentState = target;
-
- // Apply the setters from the new state
- foreach (Setter setter in target.Setters)
- {
- setter.Apply(visualElement);
- }
-
- return true;
- }
-
- return false;
- }
-
- public static bool HasVisualStateGroups(this /*VisualElement*/BaseHandle element)
- {
- return element.IsSet(VisualStateGroupsProperty);
- }
- }
-
- internal class VisualStateGroupList : IList<VisualStateGroup>
- {
- readonly IList<VisualStateGroup> _internalList;
-
- void Validate(IList<VisualStateGroup> groups)
- {
- // If we have 1 group, no need to worry about duplicate group names
- if (groups.Count > 1)
- {
- if (groups.GroupBy(vsg => vsg.Name).Any(g => g.Count() > 1))
- {
- throw new InvalidOperationException("VisualStateGroup Names must be unique");
- }
- }
-
- // State names must be unique within this group list, so pull in all
- // the states in all the groups, group them by name, and see if we have
- // and duplicates
- if (groups.SelectMany(group => group.States)
- .GroupBy(state => state.Name)
- .Any(g => g.Count() > 1))
- {
- throw new InvalidOperationException("VisualState Names must be unique");
- }
- }
-
- public VisualStateGroupList()
- {
- _internalList = new WatchAddList<VisualStateGroup>(Validate);
- }
-
- void ValidateOnStatesChanged(object sender, EventArgs eventArgs)
- {
- Validate(_internalList);
- }
-
- public IEnumerator<VisualStateGroup> GetEnumerator()
- {
- return _internalList.GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable)_internalList).GetEnumerator();
- }
-
- public void Add(VisualStateGroup item)
- {
- _internalList.Add(item);
- item.StatesChanged += ValidateOnStatesChanged;
- }
-
- public void Clear()
- {
- foreach (var group in _internalList)
- {
- group.StatesChanged -= ValidateOnStatesChanged;
- }
-
- _internalList.Clear();
- }
-
- public bool Contains(VisualStateGroup item)
- {
- return _internalList.Contains(item);
- }
-
- public void CopyTo(VisualStateGroup[] array, int arrayIndex)
- {
- _internalList.CopyTo(array, arrayIndex);
- }
-
- public bool Remove(VisualStateGroup item)
- {
- item.StatesChanged -= ValidateOnStatesChanged;
- return _internalList.Remove(item);
- }
-
- public int Count => _internalList.Count;
-
- public bool IsReadOnly => false;
-
- public int IndexOf(VisualStateGroup item)
- {
- return _internalList.IndexOf(item);
- }
-
- public void Insert(int index, VisualStateGroup item)
- {
- item.StatesChanged += ValidateOnStatesChanged;
- _internalList.Insert(index, item);
- }
-
- public void RemoveAt(int index)
- {
- _internalList[index].StatesChanged -= ValidateOnStatesChanged;
- _internalList.RemoveAt(index);
- }
-
- public VisualStateGroup this[int index]
- {
- get => _internalList[index];
- set => _internalList[index] = value;
- }
- }
-
- [RuntimeNameProperty(nameof(Name))]
- [ContentProperty(nameof(States))]
- internal sealed class VisualStateGroup
- {
- public VisualStateGroup()
- {
- States = new WatchAddList<VisualState>(OnStatesChanged);
- }
-
- public Type TargetType { get; set; }
- public string Name { get; set; }
- public IList<VisualState> States { get; }
- public VisualState CurrentState { get; internal set; }
-
- internal VisualState GetState(string name)
- {
- foreach (VisualState state in States)
- {
- if (string.CompareOrdinal(state.Name, name) == 0)
- {
- return state;
- }
- }
-
- return null;
- }
-
- internal VisualStateGroup Clone()
- {
- var clone = new VisualStateGroup {TargetType = TargetType, Name = Name, CurrentState = CurrentState};
- foreach (VisualState state in States)
- {
- clone.States.Add(state.Clone());
- }
-
- return clone;
- }
-
- internal event EventHandler StatesChanged;
-
- void OnStatesChanged(IList<VisualState> list)
- {
- if (list.Any(state => string.IsNullOrEmpty(state.Name)))
- {
- throw new InvalidOperationException("State names may not be null or empty");
- }
-
- StatesChanged?.Invoke(this, EventArgs.Empty);
- }
- }
-
- [RuntimeNameProperty(nameof(Name))]
- internal sealed class VisualState
- {
- public VisualState()
- {
- Setters = new ObservableCollection<Setter>();
- }
-
- public string Name { get; set; }
- public IList<Setter> Setters { get;}
- public Type TargetType { get; set; }
-
- internal VisualState Clone()
- {
- var clone = new VisualState { Name = Name, TargetType = TargetType };
- foreach (var setter in Setters)
- {
- clone.Setters.Add(setter);
- }
-
- return clone;
- }
- }
-
- internal static class VisualStateGroupListExtensions
- {
- internal static IList<VisualStateGroup> Clone(this IList<VisualStateGroup> groups)
- {
- var actual = new VisualStateGroupList();
- foreach (var group in groups)
- {
- actual.Add(group.Clone());
- }
-
- return actual;
- }
- }
-
- internal class WatchAddList<T> : IList<T>
- {
- readonly Action<List<T>> _onAdd;
- readonly List<T> _internalList;
-
- public WatchAddList(Action<List<T>> onAdd)
- {
- _onAdd = onAdd;
- _internalList = new List<T>();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- return _internalList.GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable)_internalList).GetEnumerator();
- }
-
- public void Add(T item)
- {
- _internalList.Add(item);
- _onAdd(_internalList);
- }
-
- public void Clear()
- {
- _internalList.Clear();
- }
-
- public bool Contains(T item)
- {
- return _internalList.Contains(item);
- }
-
- public void CopyTo(T[] array, int arrayIndex)
- {
- _internalList.CopyTo(array, arrayIndex);
- }
-
- public bool Remove(T item)
- {
- return _internalList.Remove(item);
- }
-
- public int Count => _internalList.Count;
-
- public bool IsReadOnly => false;
-
- public int IndexOf(T item)
- {
- return _internalList.IndexOf(item);
- }
-
- public void Insert(int index, T item)
- {
- _internalList.Insert(index, item);
- _onAdd(_internalList);
- }
-
- public void RemoveAt(int index)
- {
- _internalList.RemoveAt(index);
- }
-
- public T this[int index]
- {
- get => _internalList[index];
- set => _internalList[index] = value;
- }
- }
+ internal static class VisualStateManager
+ {
+ internal class CommonStates
+ {
+ public const string Normal = "Normal";
+ public const string Disabled = "Disabled";
+ public const string Focused = "Focused";
+ }
+
+ public static readonly BindableProperty VisualStateGroupsProperty =
+ BindableProperty.CreateAttached("VisualStateGroups", typeof(VisualStateGroupList), typeof(/*VisualElement*/BaseHandle),
+ defaultValue: null, propertyChanged: VisualStateGroupsPropertyChanged,
+ defaultValueCreator: bindable => new VisualStateGroupList());
+
+ static void VisualStateGroupsPropertyChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ GoToState((/*VisualElement*/BaseHandle)bindable, CommonStates.Normal);
+ }
+
+ public static IList<VisualStateGroup> GetVisualStateGroups(/*VisualElement*/BaseHandle visualElement)
+ {
+ return (IList<VisualStateGroup>)visualElement.GetValue(VisualStateGroupsProperty);
+ }
+
+ public static void SetVisualStateGroups(/*VisualElement*/BaseHandle visualElement, VisualStateGroupList value)
+ {
+ visualElement.SetValue(VisualStateGroupsProperty, value);
+ }
+
+ public static bool GoToState(/*VisualElement*/BaseHandle visualElement, string name)
+ {
+ if (!visualElement.IsSet(VisualStateGroupsProperty))
+ {
+ return false;
+ }
+
+ var groups = (IList<VisualStateGroup>)visualElement.GetValue(VisualStateGroupsProperty);
+
+ foreach (VisualStateGroup group in groups)
+ {
+ if (group.CurrentState?.Name == name)
+ {
+ // We're already in the target state; nothing else to do
+ return true;
+ }
+
+ // See if this group contains the new state
+ var target = group.GetState(name);
+ if (target == null)
+ {
+ continue;
+ }
+
+ // If we've got a new state to transition to, unapply the setters from the current state
+ if (group.CurrentState != null)
+ {
+ foreach (Setter setter in group.CurrentState.Setters)
+ {
+ setter.UnApply(visualElement);
+ }
+ }
+
+ // Update the current state
+ group.CurrentState = target;
+
+ // Apply the setters from the new state
+ foreach (Setter setter in target.Setters)
+ {
+ setter.Apply(visualElement);
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public static bool HasVisualStateGroups(this /*VisualElement*/BaseHandle element)
+ {
+ return element.IsSet(VisualStateGroupsProperty);
+ }
+ }
+
+ internal class VisualStateGroupList : IList<VisualStateGroup>
+ {
+ readonly IList<VisualStateGroup> _internalList;
+
+ void Validate(IList<VisualStateGroup> groups)
+ {
+ // If we have 1 group, no need to worry about duplicate group names
+ if (groups.Count > 1)
+ {
+ if (groups.GroupBy(vsg => vsg.Name).Any(g => g.Count() > 1))
+ {
+ throw new InvalidOperationException("VisualStateGroup Names must be unique");
+ }
+ }
+
+ // State names must be unique within this group list, so pull in all
+ // the states in all the groups, group them by name, and see if we have
+ // and duplicates
+ if (groups.SelectMany(group => group.States)
+ .GroupBy(state => state.Name)
+ .Any(g => g.Count() > 1))
+ {
+ throw new InvalidOperationException("VisualState Names must be unique");
+ }
+ }
+
+ public VisualStateGroupList()
+ {
+ _internalList = new WatchAddList<VisualStateGroup>(Validate);
+ }
+
+ void ValidateOnStatesChanged(object sender, EventArgs eventArgs)
+ {
+ Validate(_internalList);
+ }
+
+ public IEnumerator<VisualStateGroup> GetEnumerator()
+ {
+ return _internalList.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)_internalList).GetEnumerator();
+ }
+
+ public void Add(VisualStateGroup item)
+ {
+ _internalList.Add(item);
+ item.StatesChanged += ValidateOnStatesChanged;
+ }
+
+ public void Clear()
+ {
+ foreach (var group in _internalList)
+ {
+ group.StatesChanged -= ValidateOnStatesChanged;
+ }
+
+ _internalList.Clear();
+ }
+
+ public bool Contains(VisualStateGroup item)
+ {
+ return _internalList.Contains(item);
+ }
+
+ public void CopyTo(VisualStateGroup[] array, int arrayIndex)
+ {
+ _internalList.CopyTo(array, arrayIndex);
+ }
+
+ public bool Remove(VisualStateGroup item)
+ {
+ item.StatesChanged -= ValidateOnStatesChanged;
+ return _internalList.Remove(item);
+ }
+
+ public int Count => _internalList.Count;
+
+ public bool IsReadOnly => false;
+
+ public int IndexOf(VisualStateGroup item)
+ {
+ return _internalList.IndexOf(item);
+ }
+
+ public void Insert(int index, VisualStateGroup item)
+ {
+ item.StatesChanged += ValidateOnStatesChanged;
+ _internalList.Insert(index, item);
+ }
+
+ public void RemoveAt(int index)
+ {
+ _internalList[index].StatesChanged -= ValidateOnStatesChanged;
+ _internalList.RemoveAt(index);
+ }
+
+ public VisualStateGroup this[int index]
+ {
+ get => _internalList[index];
+ set => _internalList[index] = value;
+ }
+ }
+
+ [RuntimeNameProperty(nameof(Name))]
+ [ContentProperty(nameof(States))]
+ internal sealed class VisualStateGroup
+ {
+ public VisualStateGroup()
+ {
+ States = new WatchAddList<VisualState>(OnStatesChanged);
+ }
+
+ public Type TargetType { get; set; }
+ public string Name { get; set; }
+ public IList<VisualState> States { get; }
+ public VisualState CurrentState { get; internal set; }
+
+ internal VisualState GetState(string name)
+ {
+ foreach (VisualState state in States)
+ {
+ if (string.CompareOrdinal(state.Name, name) == 0)
+ {
+ return state;
+ }
+ }
+
+ return null;
+ }
+
+ internal VisualStateGroup Clone()
+ {
+ var clone = new VisualStateGroup {TargetType = TargetType, Name = Name, CurrentState = CurrentState};
+ foreach (VisualState state in States)
+ {
+ clone.States.Add(state.Clone());
+ }
+
+ return clone;
+ }
+
+ internal event EventHandler StatesChanged;
+
+ void OnStatesChanged(IList<VisualState> list)
+ {
+ if (list.Any(state => string.IsNullOrEmpty(state.Name)))
+ {
+ throw new InvalidOperationException("State names may not be null or empty");
+ }
+
+ StatesChanged?.Invoke(this, EventArgs.Empty);
+ }
+ }
+
+ [RuntimeNameProperty(nameof(Name))]
+ internal sealed class VisualState
+ {
+ public VisualState()
+ {
+ Setters = new ObservableCollection<Setter>();
+ }
+
+ public string Name { get; set; }
+ public IList<Setter> Setters { get;}
+ public Type TargetType { get; set; }
+
+ internal VisualState Clone()
+ {
+ var clone = new VisualState { Name = Name, TargetType = TargetType };
+ foreach (var setter in Setters)
+ {
+ clone.Setters.Add(setter);
+ }
+
+ return clone;
+ }
+ }
+
+ internal static class VisualStateGroupListExtensions
+ {
+ internal static IList<VisualStateGroup> Clone(this IList<VisualStateGroup> groups)
+ {
+ var actual = new VisualStateGroupList();
+ foreach (var group in groups)
+ {
+ actual.Add(group.Clone());
+ }
+
+ return actual;
+ }
+ }
+
+ internal class WatchAddList<T> : IList<T>
+ {
+ readonly Action<List<T>> _onAdd;
+ readonly List<T> _internalList;
+
+ public WatchAddList(Action<List<T>> onAdd)
+ {
+ _onAdd = onAdd;
+ _internalList = new List<T>();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return _internalList.GetEnumerator();
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)_internalList).GetEnumerator();
+ }
+
+ public void Add(T item)
+ {
+ _internalList.Add(item);
+ _onAdd(_internalList);
+ }
+
+ public void Clear()
+ {
+ _internalList.Clear();
+ }
+
+ public bool Contains(T item)
+ {
+ return _internalList.Contains(item);
+ }
+
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ _internalList.CopyTo(array, arrayIndex);
+ }
+
+ public bool Remove(T item)
+ {
+ return _internalList.Remove(item);
+ }
+
+ public int Count => _internalList.Count;
+
+ public bool IsReadOnly => false;
+
+ public int IndexOf(T item)
+ {
+ return _internalList.IndexOf(item);
+ }
+
+ public void Insert(int index, T item)
+ {
+ _internalList.Insert(index, item);
+ _onAdd(_internalList);
+ }
+
+ public void RemoveAt(int index)
+ {
+ _internalList.RemoveAt(index);
+ }
+
+ public T this[int index]
+ {
+ get => _internalList[index];
+ set => _internalList[index] = value;
+ }
+ }
}
namespace Tizen.NUI.Xaml
{
- [Flags]
- internal enum XamlCompilationOptions
- {
- Skip = 1 << 0,
- Compile = 1 << 1
- }
+ [Flags]
+ internal enum XamlCompilationOptions
+ {
+ Skip = 1 << 0,
+ Compile = 1 << 1
+ }
- [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class, Inherited = false)]
- internal sealed class XamlCompilationAttribute : Attribute
- {
- public XamlCompilationAttribute(XamlCompilationOptions xamlCompilationOptions)
- {
- XamlCompilationOptions = xamlCompilationOptions;
- }
+ [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class, Inherited = false)]
+ internal sealed class XamlCompilationAttribute : Attribute
+ {
+ public XamlCompilationAttribute(XamlCompilationOptions xamlCompilationOptions)
+ {
+ XamlCompilationOptions = xamlCompilationOptions;
+ }
- public XamlCompilationOptions XamlCompilationOptions { get; set; }
- }
+ public XamlCompilationOptions XamlCompilationOptions { get; set; }
+ }
- static class XamlCExtensions
- {
- public static bool IsCompiled(this Type type)
- {
- var attr = type.GetTypeInfo().GetCustomAttribute<XamlCompilationAttribute>();
- if (attr != null)
- return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
- attr = type.GetTypeInfo().Module.GetCustomAttribute<XamlCompilationAttribute>();
- if (attr != null)
- return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
- attr = type.GetTypeInfo().Assembly.GetCustomAttribute<XamlCompilationAttribute>();
- if (attr != null)
- return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
+ internal static class XamlCExtensions
+ {
+ public static bool IsCompiled(this Type type)
+ {
+ var attr = type.GetTypeInfo().GetCustomAttribute<XamlCompilationAttribute>();
+ if (attr != null)
+ return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
+ attr = type.GetTypeInfo().Module.GetCustomAttribute<XamlCompilationAttribute>();
+ if (attr != null)
+ return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
+ attr = type.GetTypeInfo().Assembly.GetCustomAttribute<XamlCompilationAttribute>();
+ if (attr != null)
+ return attr.XamlCompilationOptions == XamlCompilationOptions.Compile;
- return false;
- }
- }
+ return false;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
- internal sealed class XamlFilePathAttribute : Attribute
- {
- public XamlFilePathAttribute([CallerFilePath] string filePath = "")
- {
- }
- }
+ [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
+ internal sealed class XamlFilePathAttribute : Attribute
+ {
+ public XamlFilePathAttribute([CallerFilePath] string filePath = "")
+ {
+ }
+ }
}
\ No newline at end of file
using System.Text.RegularExpressions;
using System.Xml;
using Tizen.NUI.Binding;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Xaml.Internals
{
- [Obsolete ("Replaced by ResourceLoader")]
- internal static class XamlLoader
- {
- static Func<Type, string> xamlFileProvider;
-
- public static Func<Type, string> XamlFileProvider {
- get { return xamlFileProvider; }
- internal set {
- xamlFileProvider = value;
- Tizen.NUI.Xaml.DesignMode.IsDesignModeEnabled = true;
- //¯\_(ツ)_/¯ the previewer forgot to set that bool
- DoNotThrowOnExceptions = value != null;
- }
- }
-
- internal static bool DoNotThrowOnExceptions { get; set; }
- }
+ [Obsolete ("Replaced by ResourceLoader")]
+ internal static class XamlLoader
+ {
+ static Func<Type, string> xamlFileProvider;
+
+ public static Func<Type, string> XamlFileProvider {
+ get { return xamlFileProvider; }
+ internal set {
+ xamlFileProvider = value;
+ Tizen.NUI.Xaml.DesignMode.IsDesignModeEnabled = true;
+ //¯\_(ツ)_/¯ the previewer forgot to set that bool
+ DoNotThrowOnExceptions = value != null;
+ }
+ }
+
+ internal static bool DoNotThrowOnExceptions { get; set; }
+ }
}
namespace Tizen.NUI.Xaml
{
- static 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 void Load(object view, string xaml)
- {
- using (var textReader = new StringReader(xaml))
- using (var reader = XmlReader.Create(textReader))
- {
- 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), view, (IXmlNamespaceResolver)reader);
- XamlParser.ParseXaml (rootnode, reader);
- Visit (rootnode, new HydrationContext {
- RootElement = view,
+ static 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))
+ {
+ 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<Exception>)null)
+ ExceptionHandler = ResourceLoader.ExceptionHandler ?? (Internals.XamlLoader.DoNotThrowOnExceptions ? e => { } : (Action<Exception>)null)
#pragma warning restore 0618
- });
- break;
- }
- }
- }
-
- [Obsolete ("Use the XamlFileProvider to provide xaml files. We will remove this when Cycle 8 hits Stable.")]
- public static object Create (string xaml, bool doNotThrow = false)
- {
- object inflatedView = null;
- using (var textreader = new StringReader(xaml))
- using (var reader = XmlReader.Create (textreader)) {
- 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), null, (IXmlNamespaceResolver)reader);
- XamlParser.ParseXaml (rootnode, reader);
- var visitorContext = new HydrationContext {
- ExceptionHandler = doNotThrow ? e => { } : (Action<Exception>)null,
- };
- var cvv = new CreateValuesVisitor (visitorContext);
- cvv.Visit ((ElementNode)rootnode, null);
- inflatedView = rootnode.Root = visitorContext.Values [rootnode];
- visitorContext.RootElement = inflatedView as BindableObject;
-
- Visit (rootnode, visitorContext);
- break;
- }
- }
- return inflatedView;
- }
-
- static void Visit (RootNode rootnode, HydrationContext visitorContext)
- {
- rootnode.Accept (new XamlNodeVisitor ((node, parent) => node.Parent = parent), null); //set parents for {StaticResource}
- rootnode.Accept (new ExpandMarkupsVisitor (visitorContext), null);
- rootnode.Accept (new PruneIgnoredNodesVisitor(), null);
- rootnode.Accept (new NamescopingVisitor (visitorContext), null); //set namescopes for {x:Reference}
- rootnode.Accept (new CreateValuesVisitor (visitorContext), null);
- rootnode.Accept (new RegisterXNamesVisitor (visitorContext), null);
- rootnode.Accept (new FillResourceDictionariesVisitor (visitorContext), null);
- rootnode.Accept (new ApplyPropertiesVisitor (visitorContext, true), null);
- }
-
- static string GetXamlForType(Type type)
- {
- //the Previewer might want to provide it's own xaml for this... let them do that
- //the check at the end is preferred (using ResourceLoader). keep this until all the previewers are updated
-
- string xaml;
+ });
+ break;
+ }
+ }
+ return animation;
+ }
+
+ public static Animation LoadAnimation(string animationXamlPath)
+ {
+ var xaml = GetAnimationXaml(animationXamlPath);
+ if (string.IsNullOrEmpty(xaml))
+ throw new XamlParseException(string.Format("No embeddedresource found for {0}", animationXamlPath), new XmlLineInfo());
+ Animation animation = new Animation();
+ using (var textReader = new StringReader(xaml))
+ using (var reader = XmlReader.Create(textReader))
+ {
+ 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
- if (ResourceLoader.ResourceProvider == null && (xaml = Internals.XamlLoader.XamlFileProvider?.Invoke(type)) != null)
- return xaml;
+ ExceptionHandler = ResourceLoader.ExceptionHandler ?? (Internals.XamlLoader.DoNotThrowOnExceptions ? e => { } : (Action<Exception>)null)
#pragma warning restore 0618
-
- var assembly = type.GetTypeInfo().Assembly;
- var resourceId = XamlResourceIdAttribute.GetResourceIdForType(type);
-
- if (resourceId == null)
- return LegacyGetXamlForType(type);
-
- using (var stream = assembly.GetManifestResourceStream(resourceId)) {
- if (stream != null)
- using (var reader = new StreamReader(stream))
- xaml = reader.ReadToEnd();
- else
- xaml = null;
- }
-
- var alternateXaml = ResourceLoader.ResourceProvider?.Invoke(assembly.GetName(), XamlResourceIdAttribute.GetPathForType(type));
- return alternateXaml ?? xaml;
- }
-
- //if the assembly was generated using a version of XamlG that doesn't outputs XamlResourceIdAttributes, we still need to find the resource, and load it
- static readonly Dictionary<Type, string> XamlResources = new Dictionary<Type, string>();
- static string LegacyGetXamlForType(Type type)
- {
- var assembly = type.GetTypeInfo().Assembly;
-
- string resourceId;
- if (XamlResources.TryGetValue(type, out resourceId)) {
- var result = ReadResourceAsXaml(type, assembly, resourceId);
- if (result != null)
- return result;
- }
-
- var likelyResourceName = type.Name + ".xaml";
- var resourceNames = assembly.GetManifestResourceNames();
- string resourceName = null;
-
- // first pass, pray to find it because the user named it correctly
-
- foreach (var resource in resourceNames) {
- if (ResourceMatchesFilename(assembly, resource, likelyResourceName)) {
- resourceName = resource;
- var xaml = ReadResourceAsXaml(type, assembly, resource);
- if (xaml != null)
- return xaml;
- }
- }
-
- // okay maybe they at least named it .xaml
-
- foreach (var resource in resourceNames) {
- if (!resource.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
- continue;
-
- resourceName = resource;
- var xaml = ReadResourceAsXaml(type, assembly, resource);
- if (xaml != null)
- return xaml;
- }
-
- foreach (var resource in resourceNames) {
- if (resource.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
- continue;
-
- resourceName = resource;
- var xaml = ReadResourceAsXaml(type, assembly, resource, true);
- if (xaml != null)
- return xaml;
- }
-
- return null;
- }
-
- //legacy...
- static bool ResourceMatchesFilename(Assembly assembly, string resource, string filename)
- {
- try {
- var info = assembly.GetManifestResourceInfo(resource);
-
- if (!string.IsNullOrEmpty(info.FileName) &&
- string.Compare(info.FileName, filename, StringComparison.OrdinalIgnoreCase) == 0)
- return true;
- }
- catch (PlatformNotSupportedException) {
- // Because Win10 + .NET Native
- }
-
- if (resource.EndsWith("." + filename, StringComparison.OrdinalIgnoreCase) ||
- string.Compare(resource, filename, StringComparison.OrdinalIgnoreCase) == 0)
- return true;
-
- return false;
- }
-
- //part of the legacy as well...
- static string ReadResourceAsXaml(Type type, Assembly assembly, string likelyTargetName, bool validate = false)
- {
- using (var stream = assembly.GetManifestResourceStream(likelyTargetName))
- using (var reader = new StreamReader(stream)) {
- if (validate) {
- // terrible validation of XML. Unfortunately it will probably work most of the time since comments
- // also start with a <. We can't bring in any real deps.
-
- var firstNonWhitespace = (char)reader.Read();
- while (char.IsWhiteSpace(firstNonWhitespace))
- firstNonWhitespace = (char)reader.Read();
-
- if (firstNonWhitespace != '<')
- return null;
-
- stream.Seek(0, SeekOrigin.Begin);
- }
-
- var xaml = reader.ReadToEnd();
-
- var pattern = String.Format("x:Class *= *\"{0}\"", type.FullName);
- var regex = new Regex(pattern, RegexOptions.ECMAScript);
- if (regex.IsMatch(xaml) || xaml.Contains(String.Format("x:Class=\"{0}\"", type.FullName)))
- return xaml;
- }
- return null;
- }
-
- public class RuntimeRootNode : RootNode
- {
- public RuntimeRootNode(XmlType xmlType, object root, IXmlNamespaceResolver resolver) : base (xmlType, resolver)
- {
- Root = root;
- }
-
- public object Root { get; internal set; }
- }
- }
+ });
+ break;
+ }
+ }
+ return animation;
+ }
+
+ public static void Load(object view, string xaml)
+ {
+ using (var textReader = new StringReader(xaml))
+ using (var reader = XmlReader.Create(textReader))
+ {
+ 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), view, (IXmlNamespaceResolver)reader);
+ XamlParser.ParseXaml (rootnode, reader);
+ Visit (rootnode, new HydrationContext {
+ RootElement = view,
+#pragma warning disable 0618
+ ExceptionHandler = ResourceLoader.ExceptionHandler ?? (Internals.XamlLoader.DoNotThrowOnExceptions ? e => { }: (Action<Exception>)null)
+#pragma warning restore 0618
+ });
+ break;
+ }
+ }
+ }
+
+ [Obsolete ("Use the XamlFileProvider to provide xaml files. We will remove this when Cycle 8 hits Stable.")]
+ public static object Create (string xaml, bool doNotThrow = false)
+ {
+ object inflatedView = null;
+ using (var textreader = new StringReader(xaml))
+ using (var reader = XmlReader.Create (textreader)) {
+ 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), null, (IXmlNamespaceResolver)reader);
+ XamlParser.ParseXaml (rootnode, reader);
+ var visitorContext = new HydrationContext {
+ ExceptionHandler = doNotThrow ? e => { } : (Action<Exception>)null,
+ };
+ var cvv = new CreateValuesVisitor (visitorContext);
+ cvv.Visit ((ElementNode)rootnode, null);
+ inflatedView = rootnode.Root = visitorContext.Values [rootnode];
+ visitorContext.RootElement = inflatedView as BindableObject;
+
+ Visit (rootnode, visitorContext);
+ break;
+ }
+ }
+ return inflatedView;
+ }
+
+ static void Visit (RootNode rootnode, HydrationContext visitorContext)
+ {
+ rootnode.Accept (new XamlNodeVisitor ((node, parent) => node.Parent = parent), null); //set parents for {StaticResource}
+ rootnode.Accept (new ExpandMarkupsVisitor (visitorContext), null);
+ rootnode.Accept (new PruneIgnoredNodesVisitor(), null);
+ rootnode.Accept (new NamescopingVisitor (visitorContext), null); //set namescopes for {x:Reference}
+ rootnode.Accept (new CreateValuesVisitor (visitorContext), null);
+ rootnode.Accept (new RegisterXNamesVisitor (visitorContext), null);
+ rootnode.Accept (new FillResourceDictionariesVisitor (visitorContext), null);
+ rootnode.Accept (new ApplyPropertiesVisitor (visitorContext, true), null);
+ }
+
+ static string GetAnimationXaml(string animationXamlPath)
+ {
+ string xaml;
+ if (File.Exists(animationXamlPath))
+ {
+ StreamReader reader = new StreamReader(animationXamlPath);
+ xaml = reader.ReadToEnd();
+ Tizen.Log.Fatal("NUI", "File is exist!, try with xaml: " + xaml);
+ return xaml;
+ }
+
+ return null;
+ }
+ static string GetXamlForType(Type type)
+ {
+ //the Previewer might want to provide it's own xaml for this... let them do that
+ //the check at the end is preferred (using ResourceLoader). keep this until all the previewers are updated
+
+ string xaml;
+ string resourceName = type.Name + ".xaml";
+ string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+
+ Tizen.Log.Fatal("NUI", "the resource path: " + resource);
+ int windowWidth = Window.Instance.Size.Width;
+ int windowHeight = Window.Instance.Size.Height;
+
+ string likelyResourcePath = resource + "layout/" + windowWidth.ToString() + "x" + windowHeight.ToString() + "/" + resourceName;
+ Tizen.Log.Fatal("NUI", "the resource path: " + likelyResourcePath);
+
+ if (!File.Exists(likelyResourcePath))
+ {
+ likelyResourcePath = resource + "layout/" + resourceName;
+ }
+
+ //Find the xaml file in the layout folder
+ if (File.Exists(likelyResourcePath))
+ {
+ StreamReader reader = new StreamReader(likelyResourcePath);
+ xaml = reader.ReadToEnd();
+ Tizen.Log.Fatal("NUI", "File is exist!, try with xaml: " + xaml);
+ var pattern = String.Format("x:Class *= *\"{0}\"", type.FullName);
+ var regex = new Regex(pattern, RegexOptions.ECMAScript);
+ if (regex.IsMatch(xaml) || xaml.Contains(String.Format("x:Class=\"{0}\"", type.FullName)))
+ {
+ return xaml;
+ }
+ else
+ {
+ throw new XamlParseException(string.Format("Can't find type {0}", type.FullName), new XmlLineInfo());
+ }
+ }
+
+ return null;
+ }
+
+ //if the assembly was generated using a version of XamlG that doesn't outputs XamlResourceIdAttributes, we still need to find the resource, and load it
+ static readonly Dictionary<Type, string> XamlResources = new Dictionary<Type, string>();
+ static string LegacyGetXamlForType(Type type)
+ {
+ var assembly = type.GetTypeInfo().Assembly;
+
+ string resourceId;
+ if (XamlResources.TryGetValue(type, out resourceId)) {
+ var result = ReadResourceAsXaml(type, assembly, resourceId);
+ if (result != null)
+ return result;
+ }
+
+ var likelyResourceName = type.Name + ".xaml";
+ var resourceNames = assembly.GetManifestResourceNames();
+ string resourceName = null;
+
+ // first pass, pray to find it because the user named it correctly
+
+ foreach (var resource in resourceNames) {
+ if (ResourceMatchesFilename(assembly, resource, likelyResourceName)) {
+ resourceName = resource;
+ var xaml = ReadResourceAsXaml(type, assembly, resource);
+ if (xaml != null)
+ return xaml;
+ }
+ }
+
+ // okay maybe they at least named it .xaml
+
+ foreach (var resource in resourceNames) {
+ if (!resource.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
+ continue;
+
+ resourceName = resource;
+ var xaml = ReadResourceAsXaml(type, assembly, resource);
+ if (xaml != null)
+ return xaml;
+ }
+
+ foreach (var resource in resourceNames) {
+ if (resource.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase))
+ continue;
+
+ resourceName = resource;
+ var xaml = ReadResourceAsXaml(type, assembly, resource, true);
+ if (xaml != null)
+ return xaml;
+ }
+
+ return null;
+ }
+
+ //legacy...
+ static bool ResourceMatchesFilename(Assembly assembly, string resource, string filename)
+ {
+ try {
+ var info = assembly.GetManifestResourceInfo(resource);
+
+ if (!string.IsNullOrEmpty(info.FileName) &&
+ string.Compare(info.FileName, filename, StringComparison.OrdinalIgnoreCase) == 0)
+ return true;
+ }
+ catch (PlatformNotSupportedException) {
+ // Because Win10 + .NET Native
+ }
+
+ if (resource.EndsWith("." + filename, StringComparison.OrdinalIgnoreCase) ||
+ string.Compare(resource, filename, StringComparison.OrdinalIgnoreCase) == 0)
+ return true;
+
+ return false;
+ }
+
+ //part of the legacy as well...
+ static string ReadResourceAsXaml(Type type, Assembly assembly, string likelyTargetName, bool validate = false)
+ {
+ using (var stream = assembly.GetManifestResourceStream(likelyTargetName))
+ using (var reader = new StreamReader(stream)) {
+ if (validate) {
+ // terrible validation of XML. Unfortunately it will probably work most of the time since comments
+ // also start with a <. We can't bring in any real deps.
+
+ var firstNonWhitespace = (char)reader.Read();
+ while (char.IsWhiteSpace(firstNonWhitespace))
+ firstNonWhitespace = (char)reader.Read();
+
+ if (firstNonWhitespace != '<')
+ return null;
+
+ stream.Seek(0, SeekOrigin.Begin);
+ }
+
+ var xaml = reader.ReadToEnd();
+
+ var pattern = String.Format("x:Class *= *\"{0}\"", type.FullName);
+ var regex = new Regex(pattern, RegexOptions.ECMAScript);
+ if (regex.IsMatch(xaml) || xaml.Contains(String.Format("x:Class=\"{0}\"", type.FullName)))
+ return xaml;
+ }
+ return null;
+ }
+
+ public class RuntimeRootNode : RootNode
+ {
+ public RuntimeRootNode(XmlType xmlType, object root, IXmlNamespaceResolver resolver) : base (xmlType, resolver)
+ {
+ Root = root;
+ }
+
+ public object Root { get; internal set; }
+ }
+ }
}
\ No newline at end of file
using System.Linq;
using System.Xml;
using Tizen.NUI.Binding;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Xaml
{
- interface INode
- {
- List<string> IgnorablePrefixes { get; set; }
-
- IXmlNamespaceResolver NamespaceResolver { get; }
-
- INode Parent { get; set; }
-
- void Accept(IXamlNodeVisitor visitor, INode parentNode);
- INode Clone();
- }
-
- interface IValueNode : INode
- {
- }
-
- interface IElementNode : INode, IListNode
- {
- Dictionary<XmlName, INode> Properties { get; }
- List<XmlName> SkipProperties { get; }
- INameScope Namescope { get; }
- XmlType XmlType { get; }
- string NamespaceURI { get; }
- }
-
- interface IListNode : INode
- {
- List<INode> CollectionItems { get; }
- }
-
- [DebuggerDisplay("{NamespaceUri}:{Name}")]
- class XmlType
- {
- public XmlType(string namespaceUri, string name, IList<XmlType> typeArguments)
- {
- NamespaceUri = namespaceUri;
- Name = name;
- TypeArguments = typeArguments;
- }
-
- public string NamespaceUri { get; }
- public string Name { get; }
- public IList<XmlType> TypeArguments { get; }
- }
-
- abstract class BaseNode : IXmlLineInfo, INode
- {
- protected BaseNode(IXmlNamespaceResolver namespaceResolver, int linenumber = -1, int lineposition = -1)
- {
- NamespaceResolver = namespaceResolver;
- LineNumber = linenumber;
- LinePosition = lineposition;
- }
-
- public IXmlNamespaceResolver NamespaceResolver { get; }
- public INode Parent { get; set; }
- public List<string> IgnorablePrefixes { get; set; }
- public int LineNumber { get; set; }
- public int LinePosition { get; set; }
-
- public bool HasLineInfo() => LineNumber >= 0 && LinePosition >= 0;
-
- public abstract void Accept(IXamlNodeVisitor visitor, INode parentNode);
- public abstract INode Clone();
- }
-
- [DebuggerDisplay("{Value}")]
- class ValueNode : BaseNode, IValueNode
- {
- public ValueNode(object value, IXmlNamespaceResolver namespaceResolver, int linenumber = -1, int lineposition = -1)
- : base(namespaceResolver, linenumber, lineposition)
- {
- Value = value;
- }
-
- public object Value { get; set; }
-
- public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
- {
- visitor.Visit(this, parentNode);
- }
-
- public override INode Clone() => new ValueNode(Value, NamespaceResolver, LineNumber, LinePosition) {
- IgnorablePrefixes = IgnorablePrefixes
- };
- }
-
- [DebuggerDisplay("{MarkupString}")]
- class MarkupNode : BaseNode, IValueNode
- {
- public MarkupNode(string markupString, IXmlNamespaceResolver namespaceResolver, int linenumber = -1, int lineposition = -1)
- : base(namespaceResolver, linenumber, lineposition)
- {
- MarkupString = markupString;
- }
-
- public string MarkupString { get; }
-
- public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
- {
- visitor.Visit(this, parentNode);
- }
-
- public override INode Clone() => new MarkupNode(MarkupString, NamespaceResolver, LineNumber, LinePosition) {
- IgnorablePrefixes = IgnorablePrefixes
- };
- }
-
- [DebuggerDisplay("{XmlType.Name}")]
- class ElementNode : BaseNode, IValueNode, IElementNode
- {
- public ElementNode(XmlType type, string namespaceURI, IXmlNamespaceResolver namespaceResolver, int linenumber = -1,
- int lineposition = -1)
- : base(namespaceResolver, linenumber, lineposition)
- {
- Properties = new Dictionary<XmlName, INode>();
- SkipProperties = new List<XmlName>();
- CollectionItems = new List<INode>();
- XmlType = type;
- NamespaceURI = namespaceURI;
- }
-
- public Dictionary<XmlName, INode> Properties { get; }
- public List<XmlName> SkipProperties { get; }
- public List<INode> CollectionItems { get; }
- public XmlType XmlType { get; }
- public string NamespaceURI { get; }
- public INameScope Namescope { get; set; }
-
- public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
- {
- if (!SkipVisitNode(visitor, parentNode) && visitor.VisitingMode == TreeVisitingMode.TopDown)
- visitor.Visit(this, parentNode);
-
- if (!SkipChildren(visitor, this, parentNode)) {
- foreach (var node in Properties.Values.ToList())
- node.Accept(visitor, this);
- foreach (var node in CollectionItems)
- node.Accept(visitor, this);
- }
-
- if (!SkipVisitNode(visitor, parentNode) && visitor.VisitingMode == TreeVisitingMode.BottomUp)
- visitor.Visit(this, parentNode);
-
- }
-
- bool IsDataTemplate(INode parentNode)
- {
- var parentElement = parentNode as IElementNode;
- INode createContent;
- if (parentElement != null &&
- parentElement.Properties.TryGetValue(XmlName._CreateContent, out createContent) &&
- createContent == this)
- return true;
- return false;
- }
-
- bool IsResourceDictionary() => XmlType.Name == "ResourceDictionary";
-
- protected bool SkipChildren(IXamlNodeVisitor visitor, INode node, INode parentNode) =>
- (visitor.StopOnDataTemplate && IsDataTemplate(parentNode))
- || (visitor.StopOnResourceDictionary && IsResourceDictionary())
- || visitor.SkipChildren(node, parentNode);
-
- protected bool SkipVisitNode(IXamlNodeVisitor visitor, INode parentNode) =>
- !visitor.VisitNodeOnDataTemplate && IsDataTemplate(parentNode);
-
- public override INode Clone()
- {
- var clone = new ElementNode(XmlType, NamespaceURI, NamespaceResolver, LineNumber, LinePosition) {
- IgnorablePrefixes = IgnorablePrefixes
- };
- foreach (var kvp in Properties)
- clone.Properties.Add(kvp.Key, kvp.Value.Clone());
- foreach (var p in SkipProperties)
- clone.SkipProperties.Add(p);
- foreach (var p in CollectionItems)
- clone.CollectionItems.Add(p.Clone());
- return clone;
- }
- }
-
- abstract class RootNode : ElementNode
- {
- protected RootNode(XmlType xmlType, IXmlNamespaceResolver nsResolver) : base(xmlType, xmlType.NamespaceUri, nsResolver)
- {
- }
-
- public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
- {
- if (!SkipVisitNode(visitor, parentNode) && visitor.VisitingMode == TreeVisitingMode.TopDown)
- visitor.Visit(this, parentNode);
-
- if (!SkipChildren(visitor, this, parentNode)) {
- foreach (var node in Properties.Values.ToList())
- node.Accept(visitor, this);
- foreach (var node in CollectionItems)
- node.Accept(visitor, this);
- }
-
- if (!SkipVisitNode(visitor, parentNode) && visitor.VisitingMode == TreeVisitingMode.BottomUp)
- visitor.Visit(this, parentNode);
- }
- }
-
- class ListNode : BaseNode, IListNode, IValueNode
- {
- public ListNode(IList<INode> nodes, IXmlNamespaceResolver namespaceResolver, int linenumber = -1, int lineposition = -1)
- : base(namespaceResolver, linenumber, lineposition)
- {
- CollectionItems = nodes.ToList();
- }
-
- public XmlName XmlName { get; set; }
- public List<INode> CollectionItems { get; set; }
-
- public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
- {
- if (visitor.VisitingMode == TreeVisitingMode.TopDown)
- visitor.Visit(this, parentNode);
- foreach (var node in CollectionItems)
- node.Accept(visitor, this);
- if (visitor.VisitingMode == TreeVisitingMode.BottomUp)
- visitor.Visit(this, parentNode);
- }
-
- public override INode Clone()
- {
- var items = new List<INode>();
- foreach (var p in CollectionItems)
- items.Add(p.Clone());
- return new ListNode(items, NamespaceResolver, LineNumber, LinePosition) {
- IgnorablePrefixes = IgnorablePrefixes
- };
- }
- }
-
- static class INodeExtensions
- {
- public static bool SkipPrefix(this INode node, string prefix)
- {
- do {
- if (node.IgnorablePrefixes != null && node.IgnorablePrefixes.Contains(prefix))
- return true;
- node = node.Parent;
- } while (node != null);
- return false;
- }
- }
+ internal interface INode
+ {
+ List<string> IgnorablePrefixes { get; set; }
+
+ IXmlNamespaceResolver NamespaceResolver { get; }
+
+ INode Parent { get; set; }
+
+ void Accept(IXamlNodeVisitor visitor, INode parentNode);
+ INode Clone();
+ }
+
+ internal interface IValueNode : INode
+ {
+ }
+
+ internal interface IElementNode : INode, IListNode
+ {
+ Dictionary<XmlName, INode> Properties { get; }
+ List<XmlName> SkipProperties { get; }
+ INameScope Namescope { get; }
+ XmlType XmlType { get; }
+ string NamespaceURI { get; }
+ }
+
+ internal interface IListNode : INode
+ {
+ List<INode> CollectionItems { get; }
+ }
+
+ [DebuggerDisplay("{NamespaceUri}:{Name}")]
+ internal class XmlType
+ {
+ public XmlType(string namespaceUri, string name, IList<XmlType> typeArguments)
+ {
+ NamespaceUri = namespaceUri;
+ Name = name;
+ TypeArguments = typeArguments;
+ }
+
+ public string NamespaceUri { get; }
+ public string Name { get; }
+ public IList<XmlType> TypeArguments { get; }
+ }
+
+ internal abstract class BaseNode : IXmlLineInfo, INode
+ {
+ protected BaseNode(IXmlNamespaceResolver namespaceResolver, int linenumber = -1, int lineposition = -1)
+ {
+ NamespaceResolver = namespaceResolver;
+ LineNumber = linenumber;
+ LinePosition = lineposition;
+ }
+
+ public IXmlNamespaceResolver NamespaceResolver { get; }
+ public INode Parent { get; set; }
+ public List<string> IgnorablePrefixes { get; set; }
+ public int LineNumber { get; set; }
+ public int LinePosition { get; set; }
+
+ public bool HasLineInfo() => LineNumber >= 0 && LinePosition >= 0;
+
+ public abstract void Accept(IXamlNodeVisitor visitor, INode parentNode);
+ public abstract INode Clone();
+ }
+
+ [DebuggerDisplay("{Value}")]
+ internal class ValueNode : BaseNode, IValueNode
+ {
+ public ValueNode(object value, IXmlNamespaceResolver namespaceResolver, int linenumber = -1, int lineposition = -1)
+ : base(namespaceResolver, linenumber, lineposition)
+ {
+ Value = value;
+ }
+
+ public object Value { get; set; }
+
+ public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
+ {
+ visitor.Visit(this, parentNode);
+ }
+
+ public override INode Clone() => new ValueNode(Value, NamespaceResolver, LineNumber, LinePosition) {
+ IgnorablePrefixes = IgnorablePrefixes
+ };
+ }
+
+ [DebuggerDisplay("{MarkupString}")]
+ internal class MarkupNode : BaseNode, IValueNode
+ {
+ public MarkupNode(string markupString, IXmlNamespaceResolver namespaceResolver, int linenumber = -1, int lineposition = -1)
+ : base(namespaceResolver, linenumber, lineposition)
+ {
+ MarkupString = markupString;
+ }
+
+ public string MarkupString { get; }
+
+ public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
+ {
+ visitor.Visit(this, parentNode);
+ }
+
+ public override INode Clone() => new MarkupNode(MarkupString, NamespaceResolver, LineNumber, LinePosition) {
+ IgnorablePrefixes = IgnorablePrefixes
+ };
+ }
+
+ [DebuggerDisplay("{XmlType.Name}")]
+ internal class ElementNode : BaseNode, IValueNode, IElementNode
+ {
+ public ElementNode(XmlType type, string namespaceURI, IXmlNamespaceResolver namespaceResolver, int linenumber = -1,
+ int lineposition = -1)
+ : base(namespaceResolver, linenumber, lineposition)
+ {
+ Properties = new Dictionary<XmlName, INode>();
+ SkipProperties = new List<XmlName>();
+ CollectionItems = new List<INode>();
+ XmlType = type;
+ NamespaceURI = namespaceURI;
+ }
+
+ public Dictionary<XmlName, INode> Properties { get; }
+ public List<XmlName> SkipProperties { get; }
+ public List<INode> CollectionItems { get; }
+ public XmlType XmlType { get; }
+ public string NamespaceURI { get; }
+ public INameScope Namescope { get; set; }
+
+ public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
+ {
+ if (!SkipVisitNode(visitor, parentNode) && visitor.VisitingMode == TreeVisitingMode.TopDown)
+ visitor.Visit(this, parentNode);
+
+ if (!SkipChildren(visitor, this, parentNode)) {
+ foreach (var node in Properties.Values.ToList())
+ node.Accept(visitor, this);
+ foreach (var node in CollectionItems)
+ node.Accept(visitor, this);
+ }
+
+ if (!SkipVisitNode(visitor, parentNode) && visitor.VisitingMode == TreeVisitingMode.BottomUp)
+ visitor.Visit(this, parentNode);
+
+ }
+
+ bool IsDataTemplate(INode parentNode)
+ {
+ var parentElement = parentNode as IElementNode;
+ INode createContent;
+ if (parentElement != null &&
+ parentElement.Properties.TryGetValue(XmlName._CreateContent, out createContent) &&
+ createContent == this)
+ return true;
+ return false;
+ }
+
+ bool IsResourceDictionary() => XmlType.Name == "ResourceDictionary";
+
+ protected bool SkipChildren(IXamlNodeVisitor visitor, INode node, INode parentNode) =>
+ (visitor.StopOnDataTemplate && IsDataTemplate(parentNode))
+ || (visitor.StopOnResourceDictionary && IsResourceDictionary())
+ || visitor.SkipChildren(node, parentNode);
+
+ protected bool SkipVisitNode(IXamlNodeVisitor visitor, INode parentNode) =>
+ !visitor.VisitNodeOnDataTemplate && IsDataTemplate(parentNode);
+
+ public override INode Clone()
+ {
+ var clone = new ElementNode(XmlType, NamespaceURI, NamespaceResolver, LineNumber, LinePosition) {
+ IgnorablePrefixes = IgnorablePrefixes
+ };
+ foreach (var kvp in Properties)
+ clone.Properties.Add(kvp.Key, kvp.Value.Clone());
+ foreach (var p in SkipProperties)
+ clone.SkipProperties.Add(p);
+ foreach (var p in CollectionItems)
+ clone.CollectionItems.Add(p.Clone());
+ return clone;
+ }
+ }
+
+ internal abstract class RootNode : ElementNode
+ {
+ protected RootNode(XmlType xmlType, IXmlNamespaceResolver nsResolver) : base(xmlType, xmlType.NamespaceUri, nsResolver)
+ {
+ }
+
+ public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
+ {
+ if (!SkipVisitNode(visitor, parentNode) && visitor.VisitingMode == TreeVisitingMode.TopDown)
+ visitor.Visit(this, parentNode);
+
+ if (!SkipChildren(visitor, this, parentNode)) {
+ foreach (var node in Properties.Values.ToList())
+ node.Accept(visitor, this);
+ foreach (var node in CollectionItems)
+ node.Accept(visitor, this);
+ }
+
+ if (!SkipVisitNode(visitor, parentNode) && visitor.VisitingMode == TreeVisitingMode.BottomUp)
+ visitor.Visit(this, parentNode);
+ }
+ }
+
+ internal class ListNode : BaseNode, IListNode, IValueNode
+ {
+ public ListNode(IList<INode> nodes, IXmlNamespaceResolver namespaceResolver, int linenumber = -1, int lineposition = -1)
+ : base(namespaceResolver, linenumber, lineposition)
+ {
+ CollectionItems = nodes.ToList();
+ }
+
+ public XmlName XmlName { get; set; }
+ public List<INode> CollectionItems { get; set; }
+
+ public override void Accept(IXamlNodeVisitor visitor, INode parentNode)
+ {
+ if (visitor.VisitingMode == TreeVisitingMode.TopDown)
+ visitor.Visit(this, parentNode);
+ foreach (var node in CollectionItems)
+ node.Accept(visitor, this);
+ if (visitor.VisitingMode == TreeVisitingMode.BottomUp)
+ visitor.Visit(this, parentNode);
+ }
+
+ public override INode Clone()
+ {
+ var items = new List<INode>();
+ foreach (var p in CollectionItems)
+ items.Add(p.Clone());
+ return new ListNode(items, NamespaceResolver, LineNumber, LinePosition) {
+ IgnorablePrefixes = IgnorablePrefixes
+ };
+ }
+ }
+
+ internal static class INodeExtensions
+ {
+ public static bool SkipPrefix(this INode node, string prefix)
+ {
+ do {
+ if (node.IgnorablePrefixes != null && node.IgnorablePrefixes.Contains(prefix))
+ return true;
+ node = node.Parent;
+ } while (node != null);
+ return false;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- interface IXamlNodeVisitor
- {
- TreeVisitingMode VisitingMode { get; }
- bool StopOnDataTemplate { get; }
- bool VisitNodeOnDataTemplate { get; }
- bool StopOnResourceDictionary { get; }
+ internal interface IXamlNodeVisitor
+ {
+ TreeVisitingMode VisitingMode { get; }
+ bool StopOnDataTemplate { get; }
+ bool VisitNodeOnDataTemplate { get; }
+ bool StopOnResourceDictionary { get; }
- void Visit(ValueNode node, INode parentNode);
- void Visit(MarkupNode node, INode parentNode);
- void Visit(ElementNode node, INode parentNode);
- void Visit(RootNode node, INode parentNode);
- void Visit(ListNode node, INode parentNode);
- bool SkipChildren(INode node, INode parentNode);
- }
+ void Visit(ValueNode node, INode parentNode);
+ void Visit(MarkupNode node, INode parentNode);
+ void Visit(ElementNode node, INode parentNode);
+ void Visit(RootNode node, INode parentNode);
+ void Visit(ListNode node, INode parentNode);
+ bool SkipChildren(INode node, INode parentNode);
+ }
- enum TreeVisitingMode {
- TopDown,
- BottomUp
- }
+ internal enum TreeVisitingMode {
+ TopDown,
+ BottomUp
+ }
- class XamlNodeVisitor : IXamlNodeVisitor
- {
- readonly Action<INode, INode> action;
+ internal class XamlNodeVisitor : IXamlNodeVisitor
+ {
+ readonly Action<INode, INode> action;
- public XamlNodeVisitor(Action<INode, INode> action, TreeVisitingMode visitingMode = TreeVisitingMode.TopDown, bool stopOnDataTemplate = false, bool visitNodeOnDataTemplate = true)
- {
- this.action = action;
- VisitingMode = visitingMode;
- StopOnDataTemplate = stopOnDataTemplate;
- VisitNodeOnDataTemplate = visitNodeOnDataTemplate;
- }
+ public XamlNodeVisitor(Action<INode, INode> action, TreeVisitingMode visitingMode = TreeVisitingMode.TopDown, bool stopOnDataTemplate = false, bool visitNodeOnDataTemplate = true)
+ {
+ this.action = action;
+ VisitingMode = visitingMode;
+ StopOnDataTemplate = stopOnDataTemplate;
+ VisitNodeOnDataTemplate = visitNodeOnDataTemplate;
+ }
- public TreeVisitingMode VisitingMode { get; }
- public bool StopOnDataTemplate { get; }
- public bool StopOnResourceDictionary { get; }
- public bool VisitNodeOnDataTemplate { get; }
+ public TreeVisitingMode VisitingMode { get; }
+ public bool StopOnDataTemplate { get; }
+ public bool StopOnResourceDictionary { get; }
+ public bool VisitNodeOnDataTemplate { get; }
- public void Visit(ValueNode node, INode parentNode) => action(node, parentNode);
- public void Visit(MarkupNode node, INode parentNode) => action(node, parentNode);
- public void Visit(ElementNode node, INode parentNode) => action(node, parentNode);
- 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 void Visit(ValueNode node, INode parentNode) => action(node, parentNode);
+ public void Visit(MarkupNode node, INode parentNode) => action(node, parentNode);
+ public void Visit(ElementNode node, INode parentNode) => action(node, parentNode);
+ 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;
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal class XamlParseException : Exception
- {
- readonly string _unformattedMessage;
+ internal class XamlParseException : Exception
+ {
+ readonly string _unformattedMessage;
- public XamlParseException(string message, IXmlLineInfo xmlInfo, Exception innerException = null) : base(FormatMessage(message, xmlInfo), innerException)
- {
- _unformattedMessage = message;
- XmlInfo = xmlInfo;
- }
+ public XamlParseException(string message, IXmlLineInfo xmlInfo, Exception innerException = null) : base(FormatMessage(message, xmlInfo), innerException)
+ {
+ _unformattedMessage = message;
+ XmlInfo = xmlInfo;
+ }
- public IXmlLineInfo XmlInfo { get; private set; }
+ public IXmlLineInfo XmlInfo { get; private set; }
- internal string UnformattedMessage
- {
- get { return _unformattedMessage ?? Message; }
- }
+ internal string UnformattedMessage
+ {
+ get { return _unformattedMessage ?? Message; }
+ }
- static string FormatMessage(string message, IXmlLineInfo xmlinfo)
- {
- if (xmlinfo == null || !xmlinfo.HasLineInfo())
- return message;
- return string.Format("Position {0}:{1}. {2}", xmlinfo.LineNumber, xmlinfo.LinePosition, message);
- }
- }
+ static string FormatMessage(string message, IXmlLineInfo xmlinfo)
+ {
+ if (xmlinfo == null || !xmlinfo.HasLineInfo())
+ return message;
+ return string.Format("Position {0}:{1}. {2}", xmlinfo.LineNumber, xmlinfo.LinePosition, message);
+ }
+ }
}
\ No newline at end of file
using Tizen.NUI.Binding;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.UIComponents;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Xaml
{
- static class XamlParser
- {
- public const string XFUri = "http://xamarin.com/schemas/2014/forms";
- 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";
- public const string McUri = "http://schemas.openxmlformats.org/markup-compatibility/2006";
-
- public static void ParseXaml(RootNode rootNode, XmlReader reader)
- {
- IList<KeyValuePair<string, string>> xmlns;
- var attributes = ParseXamlAttributes(reader, out xmlns);
- var prefixes = PrefixesToIgnore(xmlns);
- (rootNode.IgnorablePrefixes ?? (rootNode.IgnorablePrefixes=new List<string>())).AddRange(prefixes);
- rootNode.Properties.AddRange(attributes);
- ParseXamlElementFor(rootNode, reader);
- }
-
- static void ParseXamlElementFor(IElementNode node, XmlReader reader)
- {
- Debug.Assert(reader.NodeType == XmlNodeType.Element);
-
- var elementName = reader.Name;
- var isEmpty = reader.IsEmptyElement;
-
- if (isEmpty)
- return;
-
- while (reader.Read())
- {
- switch (reader.NodeType)
- {
- case XmlNodeType.EndElement:
- Debug.Assert(reader.Name == elementName); //make sure we close the right element
- return;
- case XmlNodeType.Element:
- // 1. Property Element.
- if (reader.Name.Contains("."))
- {
- XmlName name;
- if (reader.Name.StartsWith(elementName + ".", StringComparison.Ordinal))
- name = new XmlName(reader.NamespaceURI, reader.Name.Substring(elementName.Length + 1));
- else //Attached DP
- name = new XmlName(reader.NamespaceURI, reader.LocalName);
-
- var prop = ReadNode(reader);
- if (prop != null)
- node.Properties.Add(name, prop);
- }
- // 2. Xaml2009 primitives, x:Arguments, ...
- else if (reader.NamespaceURI == X2009Uri && reader.LocalName == "Arguments")
- {
- var prop = ReadNode(reader);
- if (prop != null)
- node.Properties.Add(XmlName.xArguments, prop);
- }
- // 3. DataTemplate (should be handled by 4.)
- else if ((node.XmlType.NamespaceUri == XFUri || node.XmlType.NamespaceUri == NUI2018Uri) &&
- (node.XmlType.Name == "DataTemplate" || node.XmlType.Name == "ControlTemplate"))
- {
- var prop = ReadNode(reader, true);
- if (prop != null)
- node.Properties.Add(XmlName._CreateContent, prop);
- }
- // 4. Implicit content, implicit collection, or collection syntax. Add to CollectionItems, resolve case later.
- else
- {
- var item = ReadNode(reader, true);
- if (item != null)
- node.CollectionItems.Add(item);
- }
- break;
- case XmlNodeType.Whitespace:
- break;
- case XmlNodeType.Text:
- case XmlNodeType.CDATA:
- if (node.CollectionItems.Count == 1 && node.CollectionItems[0] is ValueNode)
- ((ValueNode)node.CollectionItems[0]).Value += reader.Value.Trim();
- else
- node.CollectionItems.Add(new ValueNode(reader.Value.Trim(), (IXmlNamespaceResolver)reader));
- break;
- default:
- Debug.WriteLine("Unhandled node {0} {1} {2}", reader.NodeType, reader.Name, reader.Value);
- break;
- }
- }
- }
-
- static INode ReadNode(XmlReader reader, bool nested = false)
- {
- var skipFirstRead = nested;
- Debug.Assert(reader.NodeType == XmlNodeType.Element);
- var name = reader.Name;
- List<INode> nodes = new List<INode>();
- INode node = null;
-
- while (skipFirstRead || reader.Read())
- {
- skipFirstRead = false;
-
- switch (reader.NodeType)
- {
- case XmlNodeType.EndElement:
- Debug.Assert(reader.Name == name);
- if (nodes.Count == 0) //Empty element
- return null;
- if (nodes.Count == 1)
- return nodes[0];
- return new ListNode(nodes, (IXmlNamespaceResolver)reader, ((IXmlLineInfo)reader).LineNumber,
- ((IXmlLineInfo)reader).LinePosition);
- case XmlNodeType.Element:
- var isEmpty = reader.IsEmptyElement && reader.Name == name;
- var elementName = reader.Name;
- var elementNsUri = reader.NamespaceURI;
- var elementXmlInfo = (IXmlLineInfo)reader;
- IList<KeyValuePair<string, string>> xmlns;
-
- var attributes = ParseXamlAttributes(reader, out xmlns);
- var prefixes = PrefixesToIgnore(xmlns);
-
- IList<XmlType> typeArguments = null;
- if (attributes.Any(kvp => kvp.Key == XmlName.xTypeArguments))
- {
- typeArguments =
- ((ValueNode)attributes.First(kvp => kvp.Key == XmlName.xTypeArguments).Value).Value as IList<XmlType>;
- }
-
- node = new ElementNode(new XmlType(elementNsUri, elementName, typeArguments), elementNsUri,
- reader as IXmlNamespaceResolver, elementXmlInfo.LineNumber, elementXmlInfo.LinePosition);
- ((IElementNode)node).Properties.AddRange(attributes);
- (node.IgnorablePrefixes ?? (node.IgnorablePrefixes = new List<string>())).AddRange(prefixes);
-
- ParseXamlElementFor((IElementNode)node, reader);
- nodes.Add(node);
- if (isEmpty || nested)
- return node;
- break;
- case XmlNodeType.Text:
- node = new ValueNode(reader.Value.Trim(), (IXmlNamespaceResolver)reader, ((IXmlLineInfo)reader).LineNumber,
- ((IXmlLineInfo)reader).LinePosition);
- nodes.Add(node);
- break;
- case XmlNodeType.Whitespace:
- break;
- default:
- Debug.WriteLine("Unhandled node {0} {1} {2}", reader.NodeType, reader.Name, reader.Value);
- break;
- }
- }
- throw new XamlParseException("Closing PropertyElement expected", (IXmlLineInfo)reader);
- }
-
- static IList<KeyValuePair<XmlName, INode>> ParseXamlAttributes(XmlReader reader, out IList<KeyValuePair<string,string>> xmlns)
- {
- Debug.Assert(reader.NodeType == XmlNodeType.Element);
- var attributes = new List<KeyValuePair<XmlName, INode>>();
- xmlns = new List<KeyValuePair<string, string>>();
- for (var i = 0; i < reader.AttributeCount; i++)
- {
- reader.MoveToAttribute(i);
-
- //skip xmlns
- if (reader.NamespaceURI == "http://www.w3.org/2000/xmlns/") {
- xmlns.Add(new KeyValuePair<string, string>(reader.LocalName, reader.Value));
- continue;
- }
-
- var namespaceUri = reader.NamespaceURI;
- if (reader.LocalName.Contains(".") && namespaceUri == "")
- namespaceUri = ((IXmlNamespaceResolver)reader).LookupNamespace("");
- var propertyName = new XmlName(namespaceUri, reader.LocalName);
-
- object value = reader.Value;
-
- if (reader.NamespaceURI == X2006Uri)
- {
- switch (reader.Name) {
- case "x:Key":
- propertyName = XmlName.xKey;
- break;
- case "x:Name":
- propertyName = XmlName.xName;
- break;
- case "x:Class":
- case "x:FieldModifier":
- continue;
- default:
- Debug.WriteLine("Unhandled attribute {0}", reader.Name);
- continue;
- }
+ internal static class XamlParser
+ {
+ public const string XFUri = "http://xamarin.com/schemas/2014/forms";
+ 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";
+ public const string McUri = "http://schemas.openxmlformats.org/markup-compatibility/2006";
+
+ public static void ParseXaml(RootNode rootNode, XmlReader reader)
+ {
+ IList<KeyValuePair<string, string>> xmlns;
+ var attributes = ParseXamlAttributes(reader, out xmlns);
+ var prefixes = PrefixesToIgnore(xmlns);
+ (rootNode.IgnorablePrefixes ?? (rootNode.IgnorablePrefixes=new List<string>())).AddRange(prefixes);
+ rootNode.Properties.AddRange(attributes);
+ ParseXamlElementFor(rootNode, reader);
+ }
+
+ static void ParseXamlElementFor(IElementNode node, XmlReader reader)
+ {
+ Debug.Assert(reader.NodeType == XmlNodeType.Element);
+
+ var elementName = reader.Name;
+ var isEmpty = reader.IsEmptyElement;
+
+ if (isEmpty)
+ return;
+
+ while (reader.Read())
+ {
+ switch (reader.NodeType)
+ {
+ case XmlNodeType.EndElement:
+ Debug.Assert(reader.Name == elementName); //make sure we close the right element
+ return;
+ case XmlNodeType.Element:
+ // 1. Property Element.
+ if (reader.Name.Contains("."))
+ {
+ XmlName name;
+ if (reader.Name.StartsWith(elementName + ".", StringComparison.Ordinal))
+ name = new XmlName(reader.NamespaceURI, reader.Name.Substring(elementName.Length + 1));
+ else //Attached DP
+ name = new XmlName(reader.NamespaceURI, reader.LocalName);
+
+ var prop = ReadNode(reader);
+ if (prop != null)
+ node.Properties.Add(name, prop);
+ }
+ // 2. Xaml2009 primitives, x:Arguments, ...
+ else if (reader.NamespaceURI == X2009Uri && reader.LocalName == "Arguments")
+ {
+ var prop = ReadNode(reader);
+ if (prop != null)
+ node.Properties.Add(XmlName.xArguments, prop);
+ }
+ // 3. DataTemplate (should be handled by 4.)
+ else if ((node.XmlType.NamespaceUri == XFUri || node.XmlType.NamespaceUri == NUI2018Uri) &&
+ (node.XmlType.Name == "DataTemplate" || node.XmlType.Name == "ControlTemplate"))
+ {
+ var prop = ReadNode(reader, true);
+ if (prop != null)
+ node.Properties.Add(XmlName._CreateContent, prop);
+ }
+ // 4. Implicit content, implicit collection, or collection syntax. Add to CollectionItems, resolve case later.
+ else
+ {
+ var item = ReadNode(reader, true);
+ if (item != null)
+ node.CollectionItems.Add(item);
+ }
+ break;
+ case XmlNodeType.Whitespace:
+ break;
+ case XmlNodeType.Text:
+ case XmlNodeType.CDATA:
+ if (node.CollectionItems.Count == 1 && node.CollectionItems[0] is ValueNode)
+ ((ValueNode)node.CollectionItems[0]).Value += reader.Value.Trim();
+ else
+ node.CollectionItems.Add(new ValueNode(reader.Value.Trim(), (IXmlNamespaceResolver)reader));
+ break;
+ default:
+ Debug.WriteLine("Unhandled node {0} {1} {2}", reader.NodeType, reader.Name, reader.Value);
+ break;
}
+ }
+ }
- if (reader.NamespaceURI == X2009Uri)
- {
- switch (reader.Name) {
- case "x:Key":
- propertyName = XmlName.xKey;
- break;
- case "x:Name":
- propertyName = XmlName.xName;
- break;
- case "x:TypeArguments":
- propertyName = XmlName.xTypeArguments;
- value = TypeArgumentsParser.ParseExpression((string)value, (IXmlNamespaceResolver)reader, (IXmlLineInfo)reader);
- break;
- case "x:DataType":
- propertyName = XmlName.xDataType;
- break;
- case "x:Class":
- case "x:FieldModifier":
- continue;
- case "x:FactoryMethod":
- propertyName = XmlName.xFactoryMethod;
- break;
- case "x:Arguments":
- propertyName = XmlName.xArguments;
- break;
- default:
- Debug.WriteLine("Unhandled attribute {0}", reader.Name);
- continue;
- }
- }
-
- var propertyNode = GetValueNode(value, reader);
- attributes.Add(new KeyValuePair<XmlName, INode>(propertyName, propertyNode));
- }
- reader.MoveToElement();
- return attributes;
- }
-
- static IList<string> PrefixesToIgnore(IList<KeyValuePair<string, string>> xmlns)
- {
- var prefixes = new List<string>();
- foreach (var kvp in xmlns) {
- var prefix = kvp.Key;
-
- string typeName = null, ns = null, asm = null, targetPlatform = null;
- XmlnsHelper.ParseXmlns(kvp.Value, out typeName, out ns, out asm, out targetPlatform);
- if (targetPlatform == null)
- continue;
- try {
- if (targetPlatform != Device.RuntimePlatform)
- {
- // Special case for Windows backward compatibility
- if (targetPlatform == "Windows" && Device.RuntimePlatform == Device.UWP)
- continue;
-
- prefixes.Add(prefix);
- }
- } catch (InvalidOperationException) {
- prefixes.Add(prefix);
- }
- }
- return prefixes;
- }
-
- static IValueNode GetValueNode(object value, XmlReader reader)
- {
- var valueString = value as string;
- if (valueString != null && valueString.Trim().StartsWith("{}", StringComparison.Ordinal))
- {
- return new ValueNode(valueString.Substring(2), (IXmlNamespaceResolver)reader, ((IXmlLineInfo)reader).LineNumber,
- ((IXmlLineInfo)reader).LinePosition);
- }
- if (valueString != null && valueString.Trim().StartsWith("{", StringComparison.Ordinal))
- {
- return new MarkupNode(valueString.Trim(), reader as IXmlNamespaceResolver, ((IXmlLineInfo)reader).LineNumber,
- ((IXmlLineInfo)reader).LinePosition);
- }
- return new ValueNode(value, (IXmlNamespaceResolver)reader, ((IXmlLineInfo)reader).LineNumber,
- ((IXmlLineInfo)reader).LinePosition);
- }
-
- static IList<XmlnsDefinitionAttribute> s_xmlnsDefinitions;
-
- static void GatherXmlnsDefinitionAttributes()
- {
- //this could be extended to look for [XmlnsDefinition] in all assemblies
- var assemblies = new [] {
- typeof(View).GetTypeInfo().Assembly,
- typeof(XamlLoader).GetTypeInfo().Assembly,
- };
-
- s_xmlnsDefinitions = new List<XmlnsDefinitionAttribute>();
-
- foreach (var assembly in assemblies)
- foreach (XmlnsDefinitionAttribute attribute in assembly.GetCustomAttributes(typeof(XmlnsDefinitionAttribute))) {
- s_xmlnsDefinitions.Add(attribute);
- attribute.AssemblyName = attribute.AssemblyName ?? assembly.FullName;
- }
- }
-
- public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly,
- out XamlParseException exception)
- {
- if (s_xmlnsDefinitions == null)
- GatherXmlnsDefinitionAttributes();
-
- var namespaceURI = xmlType.NamespaceUri;
- var elementName = xmlType.Name;
- var typeArguments = xmlType.TypeArguments;
- exception = null;
-
- var lookupAssemblies = new List<XmlnsDefinitionAttribute>();
- var lookupNames = new List<string>();
-
- foreach (var xmlnsDef in s_xmlnsDefinitions) {
- if (xmlnsDef.XmlNamespace != namespaceURI)
- continue;
- lookupAssemblies.Add(xmlnsDef);
- }
-
- if (lookupAssemblies.Count == 0) {
- string ns, asmstring, _;
- XmlnsHelper.ParseXmlns(namespaceURI, out _, out ns, out asmstring, out _);
- lookupAssemblies.Add(new XmlnsDefinitionAttribute(namespaceURI, ns) {
- AssemblyName = asmstring ?? currentAssembly.FullName
- });
- }
-
- lookupNames.Add(elementName);
- lookupNames.Add(elementName + "Extension");
-
- for (var i = 0; i < lookupNames.Count; i++)
- {
- var name = lookupNames[i];
- if (name.Contains(":"))
- name = name.Substring(name.LastIndexOf(':') + 1);
- if (typeArguments != null)
- name += "`" + typeArguments.Count; //this will return an open generic Type
- lookupNames[i] = name;
- }
-
- Type type = null;
- foreach (var asm in lookupAssemblies) {
- foreach (var name in lookupNames)
- if ((type = Type.GetType($"{asm.ClrNamespace}.{name}, {asm.AssemblyName}")) != null)
- break;
- if (type != null)
- break;
- }
+ static INode ReadNode(XmlReader reader, bool nested = false)
+ {
+ var skipFirstRead = nested;
+ Debug.Assert(reader.NodeType == XmlNodeType.Element);
+ var name = reader.Name;
+ List<INode> nodes = new List<INode>();
+ INode node = null;
- if (type == null)
+ while (skipFirstRead || reader.Read())
{
- List<Tuple<string, Assembly>> lookupAssemblies2 = new List<Tuple<string, Assembly>>();
- if (namespaceURI == NUI2018Uri)
+ skipFirstRead = false;
+
+ switch (reader.NodeType)
{
- // Got the type of Tizen.NUI wiedget here, then CreateValueVisitor will create the instance of Tizen.NUI widget
- lookupAssemblies2.Add(new Tuple<string, Assembly>("Tizen.NUI", typeof(Tizen.NUI.BaseComponents.View).GetTypeInfo().Assembly));
- lookupAssemblies2.Add(new Tuple<string, Assembly>("Tizen.NUI.BaseComponents", typeof(Tizen.NUI.BaseComponents.View).GetTypeInfo().Assembly));
- lookupAssemblies2.Add(new Tuple<string, Assembly>("Tizen.NUI.UIComponents", typeof(Tizen.NUI.BaseComponents.View).GetTypeInfo().Assembly));
- lookupAssemblies2.Add(new Tuple<string, Assembly>("Tizen.NUI.Xaml", typeof(XamlLoader).GetTypeInfo().Assembly));
- lookupAssemblies2.Add(new Tuple<string, Assembly>("Tizen.NUI.Binding", typeof(Tizen.NUI.BaseComponents.View).GetTypeInfo().Assembly));
+ case XmlNodeType.EndElement:
+ Debug.Assert(reader.Name == name);
+ if (nodes.Count == 0) //Empty element
+ return null;
+ if (nodes.Count == 1)
+ return nodes[0];
+ return new ListNode(nodes, (IXmlNamespaceResolver)reader, ((IXmlLineInfo)reader).LineNumber,
+ ((IXmlLineInfo)reader).LinePosition);
+ case XmlNodeType.Element:
+ var isEmpty = reader.IsEmptyElement && reader.Name == name;
+ var elementName = reader.Name;
+ var elementNsUri = reader.NamespaceURI;
+ var elementXmlInfo = (IXmlLineInfo)reader;
+ IList<KeyValuePair<string, string>> xmlns;
+
+ var attributes = ParseXamlAttributes(reader, out xmlns);
+ var prefixes = PrefixesToIgnore(xmlns);
+
+ IList<XmlType> typeArguments = null;
+ if (attributes.Any(kvp => kvp.Key == XmlName.xTypeArguments))
+ {
+ typeArguments =
+ ((ValueNode)attributes.First(kvp => kvp.Key == XmlName.xTypeArguments).Value).Value as IList<XmlType>;
+ }
+
+ node = new ElementNode(new XmlType(elementNsUri, elementName, typeArguments), elementNsUri,
+ reader as IXmlNamespaceResolver, elementXmlInfo.LineNumber, elementXmlInfo.LinePosition);
+ ((IElementNode)node).Properties.AddRange(attributes);
+ (node.IgnorablePrefixes ?? (node.IgnorablePrefixes = new List<string>())).AddRange(prefixes);
+
+ ParseXamlElementFor((IElementNode)node, reader);
+ nodes.Add(node);
+ if (isEmpty || nested)
+ return node;
+ break;
+ case XmlNodeType.Text:
+ node = new ValueNode(reader.Value.Trim(), (IXmlNamespaceResolver)reader, ((IXmlLineInfo)reader).LineNumber,
+ ((IXmlLineInfo)reader).LinePosition);
+ nodes.Add(node);
+ break;
+ case XmlNodeType.Whitespace:
+ break;
+ default:
+ Debug.WriteLine("Unhandled node {0} {1} {2}", reader.NodeType, reader.Name, reader.Value);
+ break;
}
- else if (namespaceURI == X2009Uri || namespaceURI == X2006Uri)
- {
- lookupAssemblies2.Add(new Tuple<string, Assembly>("Tizen.NUI.Xaml", typeof(XamlLoader).GetTypeInfo().Assembly));
- lookupAssemblies2.Add(new Tuple<string, Assembly>("System", typeof(object).GetTypeInfo().Assembly));
- lookupAssemblies2.Add(new Tuple<string, Assembly>("System", typeof(Uri).GetTypeInfo().Assembly)); //System.dll
+ }
+ throw new XamlParseException("Closing PropertyElement expected", (IXmlLineInfo)reader);
+ }
+
+ static IList<KeyValuePair<XmlName, INode>> ParseXamlAttributes(XmlReader reader, out IList<KeyValuePair<string,string>> xmlns)
+ {
+ Debug.Assert(reader.NodeType == XmlNodeType.Element);
+ var attributes = new List<KeyValuePair<XmlName, INode>>();
+ xmlns = new List<KeyValuePair<string, string>>();
+ for (var i = 0; i < reader.AttributeCount; i++)
+ {
+ reader.MoveToAttribute(i);
+
+ //skip xmlns
+ if (reader.NamespaceURI == "http://www.w3.org/2000/xmlns/") {
+ xmlns.Add(new KeyValuePair<string, string>(reader.LocalName, reader.Value));
+ continue;
}
- else
+
+ var namespaceUri = reader.NamespaceURI;
+ if (reader.LocalName.Contains(".") && namespaceUri == "")
+ namespaceUri = ((IXmlNamespaceResolver)reader).LookupNamespace("");
+ var propertyName = new XmlName(namespaceUri, reader.LocalName);
+
+ object value = reader.Value;
+
+ if (reader.NamespaceURI == X2006Uri)
{
- string ns;
- string typename;
- string asmstring;
- Assembly asm;
- XmlnsHelper.ParseXmlns(namespaceURI, out typename, out ns, out asmstring, out _);
- asm = asmstring == null ? currentAssembly : Assembly.Load(new AssemblyName(asmstring));
- lookupAssemblies2.Add(new Tuple<string, Assembly>(ns, asm));
+ switch (reader.Name) {
+ case "x:Key":
+ propertyName = XmlName.xKey;
+ break;
+ case "x:Name":
+ propertyName = XmlName.xName;
+ break;
+ case "x:Class":
+ case "x:FieldModifier":
+ continue;
+ default:
+ Debug.WriteLine("Unhandled attribute {0}", reader.Name);
+ continue;
+ }
}
- foreach (var asm in lookupAssemblies2)
+ if (reader.NamespaceURI == X2009Uri)
{
- if (type != null)
+ switch (reader.Name) {
+ case "x:Key":
+ propertyName = XmlName.xKey;
+ break;
+ case "x:Name":
+ propertyName = XmlName.xName;
+ break;
+ case "x:TypeArguments":
+ propertyName = XmlName.xTypeArguments;
+ value = TypeArgumentsParser.ParseExpression((string)value, (IXmlNamespaceResolver)reader, (IXmlLineInfo)reader);
+ break;
+ case "x:DataType":
+ propertyName = XmlName.xDataType;
+ break;
+ case "x:Class":
+ case "x:FieldModifier":
+ continue;
+ case "x:FactoryMethod":
+ propertyName = XmlName.xFactoryMethod;
+ break;
+ case "x:Arguments":
+ propertyName = XmlName.xArguments;
+ break;
+ default:
+ Debug.WriteLine("Unhandled attribute {0}", reader.Name);
+ continue;
+ }
+ }
+
+ var propertyNode = GetValueNode(value, reader);
+ attributes.Add(new KeyValuePair<XmlName, INode>(propertyName, propertyNode));
+ }
+ reader.MoveToElement();
+ return attributes;
+ }
+
+ static IList<string> PrefixesToIgnore(IList<KeyValuePair<string, string>> xmlns)
+ {
+ var prefixes = new List<string>();
+ foreach (var kvp in xmlns) {
+ var prefix = kvp.Key;
+
+ string typeName = null, ns = null, asm = null, targetPlatform = null;
+ XmlnsHelper.ParseXmlns(kvp.Value, out typeName, out ns, out asm, out targetPlatform);
+ if (targetPlatform == null)
+ continue;
+ try {
+ if (targetPlatform != Device.RuntimePlatform)
+ {
+ // Special case for Windows backward compatibility
+ if (targetPlatform == "Windows" && Device.RuntimePlatform == Device.UWP)
+ continue;
+
+ prefixes.Add(prefix);
+ }
+ } catch (InvalidOperationException) {
+ prefixes.Add(prefix);
+ }
+ }
+ return prefixes;
+ }
+
+ static IValueNode GetValueNode(object value, XmlReader reader)
+ {
+ var valueString = value as string;
+ if (valueString != null && valueString.Trim().StartsWith("{}", StringComparison.Ordinal))
+ {
+ return new ValueNode(valueString.Substring(2), (IXmlNamespaceResolver)reader, ((IXmlLineInfo)reader).LineNumber,
+ ((IXmlLineInfo)reader).LinePosition);
+ }
+ if (valueString != null && valueString.Trim().StartsWith("{", StringComparison.Ordinal))
+ {
+ return new MarkupNode(valueString.Trim(), reader as IXmlNamespaceResolver, ((IXmlLineInfo)reader).LineNumber,
+ ((IXmlLineInfo)reader).LinePosition);
+ }
+ return new ValueNode(value, (IXmlNamespaceResolver)reader, ((IXmlLineInfo)reader).LineNumber,
+ ((IXmlLineInfo)reader).LinePosition);
+ }
+
+ static IList<XmlnsDefinitionAttribute> s_xmlnsDefinitions;
+ public static IList<Assembly> s_assemblies = new List<Assembly>();// = new Assembly[]{};
+
+ static void GatherXmlnsDefinitionAttributes()
+ {
+ //this could be extended to look for [XmlnsDefinition] in all assemblies
+ // var assemblies = new [] {
+ // typeof(View).GetTypeInfo().Assembly,
+ // //typeof(XamlLoader).GetTypeInfo().Assembly,
+ // };
+ // s_assemblies = new Assembly[]{typeof(View).GetTypeInfo().Assembly};
+ s_assemblies.Add(typeof(View).GetTypeInfo().Assembly);
+
+ s_xmlnsDefinitions = new List<XmlnsDefinitionAttribute>();
+
+ foreach (var assembly in s_assemblies)
+ foreach (XmlnsDefinitionAttribute attribute in assembly.GetCustomAttributes(typeof(XmlnsDefinitionAttribute))) {
+ s_xmlnsDefinitions.Add(attribute);
+ attribute.AssemblyName = attribute.AssemblyName ?? assembly.FullName;
+ }
+ }
+
+ public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly,
+ out XamlParseException exception)
+ {
+ if (s_xmlnsDefinitions == null)
+ GatherXmlnsDefinitionAttributes();
+
+ var namespaceURI = xmlType.NamespaceUri;
+ var elementName = xmlType.Name;
+ var typeArguments = xmlType.TypeArguments;
+ exception = null;
+
+ var lookupAssemblies = new List<XmlnsDefinitionAttribute>();
+ var lookupNames = new List<string>();
+
+ foreach (var xmlnsDef in s_xmlnsDefinitions) {
+ if (xmlnsDef.XmlNamespace != namespaceURI)
+ continue;
+ lookupAssemblies.Add(xmlnsDef);
+ }
+
+ if (lookupAssemblies.Count == 0) {
+ string ns, asmstring, _;
+ XmlnsHelper.ParseXmlns(namespaceURI, out _, out ns, out asmstring, out _);
+ lookupAssemblies.Add(new XmlnsDefinitionAttribute(namespaceURI, ns) {
+ AssemblyName = asmstring ?? currentAssembly.FullName
+ });
+ }
+
+ lookupNames.Add(elementName);
+ lookupNames.Add(elementName + "Extension");
+
+ for (var i = 0; i < lookupNames.Count; i++)
+ {
+ var name = lookupNames[i];
+ if (name.Contains(":"))
+ name = name.Substring(name.LastIndexOf(':') + 1);
+ if (typeArguments != null)
+ name += "`" + typeArguments.Count; //this will return an open generic Type
+ lookupNames[i] = name;
+ }
+
+ Type type = null;
+ foreach (var asm in lookupAssemblies) {
+ foreach (var name in lookupNames)
+ if ((type = Type.GetType($"{asm.ClrNamespace}.{name}, {asm.AssemblyName}")) != null)
break;
- foreach (var name in lookupNames)
+ if (type != null)
+ break;
+ }
+
+ if (type != null && typeArguments != null)
+ {
+ XamlParseException innerexception = null;
+ var args = typeArguments.Select(delegate(XmlType xmltype)
+ {
+ XamlParseException xpe;
+ var t = GetElementType(xmltype, xmlInfo, currentAssembly, out xpe);
+ if (xpe != null)
{
- if (type != null)
- break;
- type = asm.Item2.GetType(asm.Item1 + "." + name);
+ innerexception = xpe;
+ return null;
}
+ return t;
+ }).ToArray();
+ if (innerexception != null)
+ {
+ exception = innerexception;
+ return null;
}
+ type = type.MakeGenericType(args);
}
- if (type != null && typeArguments != null)
- {
- XamlParseException innerexception = null;
- var args = typeArguments.Select(delegate(XmlType xmltype)
- {
- XamlParseException xpe;
- var t = GetElementType(xmltype, xmlInfo, currentAssembly, out xpe);
- if (xpe != null)
- {
- innerexception = xpe;
- return null;
- }
- return t;
- }).ToArray();
- if (innerexception != null)
- {
- exception = innerexception;
- return null;
- }
- type = type.MakeGenericType(args);
- }
-
- if (type == null)
- exception = new XamlParseException($"Type {elementName} not found in xmlns {namespaceURI}", xmlInfo);
-
- return type;
- }
- }
+ if (type == null)
+ exception = new XamlParseException($"Type {elementName} not found in xmlns {namespaceURI}", xmlInfo);
+
+ return type;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)]
- internal sealed class XamlResourceIdAttribute : Attribute
- {
- public string ResourceId { get; set; }
- public string Path { get; set; }
- public Type Type { get; set; }
+ [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)]
+ internal sealed class XamlResourceIdAttribute : Attribute
+ {
+ public string ResourceId { get; set; }
+ public string Path { get; set; }
+ public Type Type { get; set; }
- public XamlResourceIdAttribute(string resourceId, string path, Type type)
- {
- ResourceId = resourceId;
- Path = path;
- Type = type;
- }
+ public XamlResourceIdAttribute(string resourceId, string path, Type type)
+ {
+ ResourceId = resourceId;
+ Path = path;
+ Type = type;
+ }
- internal static string GetResourceIdForType(Type type)
- {
- var assembly = type.GetTypeInfo().Assembly;
- foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
- if (xria.Type == type)
- return xria.ResourceId;
- }
- return null;
- }
+ internal static string GetResourceIdForType(Type type)
+ {
+ var assembly = type.GetTypeInfo().Assembly;
+ foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
+ if (xria.Type == type)
+ return xria.ResourceId;
+ }
+ return null;
+ }
- internal static string GetPathForType(Type type)
- {
- var assembly = type.GetTypeInfo().Assembly;
- foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
- if (xria.Type == type)
- return xria.Path;
- }
- return null;
- }
+ internal static string GetPathForType(Type type)
+ {
+ var assembly = type.GetTypeInfo().Assembly;
+ foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
+ if (xria.Type == type)
+ return xria.Path;
+ }
+ return null;
+ }
- internal static string GetResourceIdForPath(Assembly assembly, string path)
- {
- foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
- if (xria.Path == path)
- return xria.ResourceId;
- }
- return null;
- }
+ internal static string GetResourceIdForPath(Assembly assembly, string path)
+ {
+ foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
+ if (xria.Path == path)
+ return xria.ResourceId;
+ }
+ return null;
+ }
- internal static Type GetTypeForResourceId(Assembly assembly, string resourceId)
- {
- foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
- if (xria.ResourceId == resourceId)
- return xria.Type;
- }
- return null;
- }
+ internal static Type GetTypeForResourceId(Assembly assembly, string resourceId)
+ {
+ foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
+ if (xria.ResourceId == resourceId)
+ return xria.Type;
+ }
+ return null;
+ }
- internal static Type GetTypeForPath(Assembly assembly, string path)
- {
- foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
- if (xria.Path == path)
- return xria.Type;
- }
- return null;
- }
- }
+ internal static Type GetTypeForPath(Assembly assembly, string path)
+ {
+ foreach (var xria in assembly.GetCustomAttributes<XamlResourceIdAttribute>()) {
+ if (xria.Path == path)
+ return xria.Type;
+ }
+ return null;
+ }
+ }
}
\ No newline at end of file
using System.Collections.Generic;
using System.Reflection;
using System.Xml;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Xaml
{
- internal class XamlServiceProvider : IServiceProvider
- {
- readonly Dictionary<Type, object> services = new Dictionary<Type, object>();
-
- internal XamlServiceProvider(INode node, HydrationContext context)
- {
- object targetObject;
- if (node != null && node.Parent != null && context.Values.TryGetValue(node.Parent, out targetObject))
- IProvideValueTarget = new XamlValueTargetProvider(targetObject, node, context, null);
- if (context != null)
- IRootObjectProvider = new XamlRootObjectProvider(context.RootElement);
- if (node != null)
- {
- IXamlTypeResolver = new XamlTypeResolver(node.NamespaceResolver, XamlParser.GetElementType,
- context?.RootElement.GetType().GetTypeInfo().Assembly);
-
- var enode = node;
- while (enode != null && !(enode is IElementNode))
- enode = enode.Parent;
- if (enode != null)
- INameScopeProvider = new NameScopeProvider { NameScope = (enode as IElementNode).Namescope };
- }
-
- var xmlLineInfo = node as IXmlLineInfo;
- if (xmlLineInfo != null)
- IXmlLineInfoProvider = new XmlLineInfoProvider(xmlLineInfo);
-
- IValueConverterProvider = new ValueConverterProvider();
- }
-
- public XamlServiceProvider()
- {
- IValueConverterProvider = new ValueConverterProvider();
- }
-
- internal IProvideValueTarget IProvideValueTarget
- {
- get { return (IProvideValueTarget)GetService(typeof (IProvideValueTarget)); }
- set { services[typeof (IProvideValueTarget)] = value; }
- }
-
- internal IXamlTypeResolver IXamlTypeResolver
- {
- get { return (IXamlTypeResolver)GetService(typeof (IXamlTypeResolver)); }
- set { services[typeof (IXamlTypeResolver)] = value; }
- }
-
- internal IRootObjectProvider IRootObjectProvider
- {
- get { return (IRootObjectProvider)GetService(typeof (IRootObjectProvider)); }
- set { services[typeof (IRootObjectProvider)] = value; }
- }
-
- internal IXmlLineInfoProvider IXmlLineInfoProvider
- {
- get { return (IXmlLineInfoProvider)GetService(typeof (IXmlLineInfoProvider)); }
- set { services[typeof (IXmlLineInfoProvider)] = value; }
- }
-
- internal INameScopeProvider INameScopeProvider
- {
- get { return (INameScopeProvider)GetService(typeof (INameScopeProvider)); }
- set { services[typeof (INameScopeProvider)] = value; }
- }
-
- internal IValueConverterProvider IValueConverterProvider
- {
- get { return (IValueConverterProvider)GetService(typeof (IValueConverterProvider)); }
- set { services[typeof (IValueConverterProvider)] = value; }
- }
-
- public object GetService(Type serviceType)
- {
- object service;
- return services.TryGetValue(serviceType, out service) ? service : null;
- }
-
- public void Add(Type type, object service)
- {
- services.Add(type, service);
- }
- }
-
- class XamlValueTargetProvider : IProvideParentValues, IProvideValueTarget
- {
- public XamlValueTargetProvider(object targetObject, INode node, HydrationContext context, object targetProperty)
- {
- Context = context;
- Node = node;
- TargetObject = targetObject;
- TargetProperty = targetProperty;
- }
-
- INode Node { get; }
-
- HydrationContext Context { get; }
- public object TargetObject { get; }
- public object TargetProperty { get; internal set; } = null;
-
- IEnumerable<object> IProvideParentValues.ParentObjects
- {
- get
- {
- if (Node == null || Context == null)
- yield break;
- var n = Node;
- object obj = null;
- var context = Context;
- while (n.Parent != null && context != null)
- {
- if (n.Parent is IElementNode)
- {
- if (context.Values.TryGetValue(n.Parent, out obj))
- yield return obj;
- else
- {
- context = context.ParentContext;
- continue;
- }
- }
- n = n.Parent;
- }
- }
- }
- }
-
- internal class SimpleValueTargetProvider : IProvideParentValues, IProvideValueTarget
- {
- readonly object[] objectAndParents;
- readonly object targetProperty;
-
- [Obsolete("SimpleValueTargetProvider(object[] objectAndParents) is obsolete as of version 2.3.4. Please use SimpleValueTargetProvider(object[] objectAndParents, object targetProperty) instead.")]
- public SimpleValueTargetProvider(object[] objectAndParents) : this (objectAndParents, null)
- {
- }
-
- public SimpleValueTargetProvider(object[] objectAndParents, object targetProperty)
- {
- if (objectAndParents == null)
- throw new ArgumentNullException(nameof(objectAndParents));
- if (objectAndParents.Length == 0)
- throw new ArgumentException();
-
- this.objectAndParents = objectAndParents;
- this.targetProperty = targetProperty;
- }
-
- IEnumerable<object> IProvideParentValues.ParentObjects
- {
- get { return objectAndParents; }
- }
-
- object IProvideValueTarget.TargetObject
- {
- get { return objectAndParents[0]; }
- }
-
- object IProvideValueTarget.TargetProperty
- {
- get { return targetProperty; }
- }
- }
-
- internal class XamlTypeResolver : IXamlTypeResolver
- {
- readonly Assembly currentAssembly;
- readonly GetTypeFromXmlName getTypeFromXmlName;
- readonly IXmlNamespaceResolver namespaceResolver;
-
- public XamlTypeResolver(IXmlNamespaceResolver namespaceResolver, Assembly currentAssembly)
- : this(namespaceResolver, XamlParser.GetElementType, currentAssembly)
- {
- }
-
- internal XamlTypeResolver(IXmlNamespaceResolver namespaceResolver, GetTypeFromXmlName getTypeFromXmlName,
- Assembly currentAssembly)
- {
- this.currentAssembly = currentAssembly;
- if (namespaceResolver == null)
- throw new ArgumentNullException();
- if (getTypeFromXmlName == null)
- throw new ArgumentNullException();
-
- this.namespaceResolver = namespaceResolver;
- this.getTypeFromXmlName = getTypeFromXmlName;
- }
-
- Type IXamlTypeResolver.Resolve(string qualifiedTypeName, IServiceProvider serviceProvider)
- {
- XamlParseException e;
- var type = Resolve(qualifiedTypeName, serviceProvider, out e);
- if (e != null)
- throw e;
- return type;
- }
-
- bool IXamlTypeResolver.TryResolve(string qualifiedTypeName, out Type type)
- {
- XamlParseException exception;
- type = Resolve(qualifiedTypeName, null, out exception);
- return exception == null;
- }
-
- Type Resolve(string qualifiedTypeName, IServiceProvider serviceProvider, out XamlParseException exception)
- {
- exception = null;
- var split = qualifiedTypeName.Split(':');
- if (split.Length > 2)
- return null;
-
- string prefix, name;
- if (split.Length == 2)
- {
- prefix = split[0];
- name = split[1];
- }
- else
- {
- prefix = "";
- name = split[0];
- }
-
- IXmlLineInfo xmlLineInfo = null;
- if (serviceProvider != null)
- {
- var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- if (lineInfoProvider != null)
- xmlLineInfo = lineInfoProvider.XmlLineInfo;
- }
-
- var namespaceuri = namespaceResolver.LookupNamespace(prefix);
- if (namespaceuri == null)
- {
- exception = new XamlParseException(string.Format("No xmlns declaration for prefix \"{0}\"", prefix), xmlLineInfo);
- return null;
- }
-
- return getTypeFromXmlName(new XmlType(namespaceuri, name, null), xmlLineInfo, currentAssembly, out exception);
- }
-
- internal delegate Type GetTypeFromXmlName(
- XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly, out XamlParseException exception);
- }
-
- class XamlRootObjectProvider : IRootObjectProvider
- {
- public XamlRootObjectProvider(object rootObject)
- {
- RootObject = rootObject;
- }
-
- public object RootObject { get; }
- }
-
- internal class XmlLineInfoProvider : IXmlLineInfoProvider
- {
- public XmlLineInfoProvider(IXmlLineInfo xmlLineInfo)
- {
- XmlLineInfo = xmlLineInfo;
- }
-
- public IXmlLineInfo XmlLineInfo { get; }
- }
-
- internal class NameScopeProvider : INameScopeProvider
- {
- public INameScope NameScope { get; set; }
- }
-
- internal class XmlNamespaceResolver : IXmlNamespaceResolver
- {
- readonly Dictionary<string, string> namespaces = new Dictionary<string, string>();
-
- public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
- {
- throw new NotImplementedException();
- }
-
- public string LookupNamespace(string prefix)
- {
- string result;
- if (namespaces.TryGetValue(prefix, out result))
- return result;
- return null;
- }
-
- public string LookupPrefix(string namespaceName)
- {
- throw new NotImplementedException();
- }
-
- public void Add(string prefix, string ns)
- {
- namespaces.Add(prefix, ns);
- }
- }
+ internal class XamlServiceProvider : IServiceProvider
+ {
+ readonly Dictionary<Type, object> services = new Dictionary<Type, object>();
+
+ internal XamlServiceProvider(INode node, HydrationContext context)
+ {
+ object targetObject;
+ if (node != null && node.Parent != null && context.Values.TryGetValue(node.Parent, out targetObject))
+ IProvideValueTarget = new XamlValueTargetProvider(targetObject, node, context, null);
+ if (context != null)
+ IRootObjectProvider = new XamlRootObjectProvider(context.RootElement);
+ if (node != null)
+ {
+ IXamlTypeResolver = new XamlTypeResolver(node.NamespaceResolver, XamlParser.GetElementType,
+ context?.RootElement.GetType().GetTypeInfo().Assembly);
+
+ var enode = node;
+ while (enode != null && !(enode is IElementNode))
+ enode = enode.Parent;
+ if (enode != null)
+ INameScopeProvider = new NameScopeProvider { NameScope = (enode as IElementNode).Namescope };
+ }
+
+ var xmlLineInfo = node as IXmlLineInfo;
+ if (xmlLineInfo != null)
+ IXmlLineInfoProvider = new XmlLineInfoProvider(xmlLineInfo);
+
+ IValueConverterProvider = new ValueConverterProvider();
+ }
+
+ public XamlServiceProvider()
+ {
+ IValueConverterProvider = new ValueConverterProvider();
+ }
+
+ internal IProvideValueTarget IProvideValueTarget
+ {
+ get { return (IProvideValueTarget)GetService(typeof (IProvideValueTarget)); }
+ set { services[typeof (IProvideValueTarget)] = value; }
+ }
+
+ internal IXamlTypeResolver IXamlTypeResolver
+ {
+ get { return (IXamlTypeResolver)GetService(typeof (IXamlTypeResolver)); }
+ set { services[typeof (IXamlTypeResolver)] = value; }
+ }
+
+ internal IRootObjectProvider IRootObjectProvider
+ {
+ get { return (IRootObjectProvider)GetService(typeof (IRootObjectProvider)); }
+ set { services[typeof (IRootObjectProvider)] = value; }
+ }
+
+ internal IXmlLineInfoProvider IXmlLineInfoProvider
+ {
+ get { return (IXmlLineInfoProvider)GetService(typeof (IXmlLineInfoProvider)); }
+ set { services[typeof (IXmlLineInfoProvider)] = value; }
+ }
+
+ internal INameScopeProvider INameScopeProvider
+ {
+ get { return (INameScopeProvider)GetService(typeof (INameScopeProvider)); }
+ set { services[typeof (INameScopeProvider)] = value; }
+ }
+
+ internal IValueConverterProvider IValueConverterProvider
+ {
+ get { return (IValueConverterProvider)GetService(typeof (IValueConverterProvider)); }
+ set { services[typeof (IValueConverterProvider)] = value; }
+ }
+
+ public object GetService(Type serviceType)
+ {
+ object service;
+ return services.TryGetValue(serviceType, out service) ? service : null;
+ }
+
+ public void Add(Type type, object service)
+ {
+ services.Add(type, service);
+ }
+ }
+
+ internal class XamlValueTargetProvider : IProvideParentValues, IProvideValueTarget
+ {
+ public XamlValueTargetProvider(object targetObject, INode node, HydrationContext context, object targetProperty)
+ {
+ Context = context;
+ Node = node;
+ TargetObject = targetObject;
+ TargetProperty = targetProperty;
+ }
+
+ INode Node { get; }
+
+ HydrationContext Context { get; }
+ public object TargetObject { get; }
+ public object TargetProperty { get; internal set; } = null;
+
+ IEnumerable<object> IProvideParentValues.ParentObjects
+ {
+ get
+ {
+ if (Node == null || Context == null)
+ yield break;
+ var n = Node;
+ object obj = null;
+ var context = Context;
+ while (n.Parent != null && context != null)
+ {
+ if (n.Parent is IElementNode)
+ {
+ if (context.Values.TryGetValue(n.Parent, out obj))
+ yield return obj;
+ else
+ {
+ context = context.ParentContext;
+ continue;
+ }
+ }
+ n = n.Parent;
+ }
+ }
+ }
+ }
+
+ internal class SimpleValueTargetProvider : IProvideParentValues, IProvideValueTarget
+ {
+ readonly object[] objectAndParents;
+ readonly object targetProperty;
+
+ [Obsolete("SimpleValueTargetProvider(object[] objectAndParents) is obsolete as of version 2.3.4. Please use SimpleValueTargetProvider(object[] objectAndParents, object targetProperty) instead.")]
+ public SimpleValueTargetProvider(object[] objectAndParents) : this (objectAndParents, null)
+ {
+ }
+
+ public SimpleValueTargetProvider(object[] objectAndParents, object targetProperty)
+ {
+ if (objectAndParents == null)
+ throw new ArgumentNullException(nameof(objectAndParents));
+ if (objectAndParents.Length == 0)
+ throw new ArgumentException();
+
+ this.objectAndParents = objectAndParents;
+ this.targetProperty = targetProperty;
+ }
+
+ IEnumerable<object> IProvideParentValues.ParentObjects
+ {
+ get { return objectAndParents; }
+ }
+
+ object IProvideValueTarget.TargetObject
+ {
+ get { return objectAndParents[0]; }
+ }
+
+ object IProvideValueTarget.TargetProperty
+ {
+ get { return targetProperty; }
+ }
+ }
+
+ internal class XamlTypeResolver : IXamlTypeResolver
+ {
+ readonly Assembly currentAssembly;
+ readonly GetTypeFromXmlName getTypeFromXmlName;
+ readonly IXmlNamespaceResolver namespaceResolver;
+
+ public XamlTypeResolver(IXmlNamespaceResolver namespaceResolver, Assembly currentAssembly)
+ : this(namespaceResolver, XamlParser.GetElementType, currentAssembly)
+ {
+ }
+
+ internal XamlTypeResolver(IXmlNamespaceResolver namespaceResolver, GetTypeFromXmlName getTypeFromXmlName,
+ Assembly currentAssembly)
+ {
+ this.currentAssembly = currentAssembly;
+ if (namespaceResolver == null)
+ throw new ArgumentNullException();
+ if (getTypeFromXmlName == null)
+ throw new ArgumentNullException();
+
+ this.namespaceResolver = namespaceResolver;
+ this.getTypeFromXmlName = getTypeFromXmlName;
+ }
+
+ Type IXamlTypeResolver.Resolve(string qualifiedTypeName, IServiceProvider serviceProvider)
+ {
+ XamlParseException e;
+ var type = Resolve(qualifiedTypeName, serviceProvider, out e);
+ if (e != null)
+ throw e;
+ return type;
+ }
+
+ bool IXamlTypeResolver.TryResolve(string qualifiedTypeName, out Type type)
+ {
+ XamlParseException exception;
+ type = Resolve(qualifiedTypeName, null, out exception);
+ return exception == null;
+ }
+
+ Type Resolve(string qualifiedTypeName, IServiceProvider serviceProvider, out XamlParseException exception)
+ {
+ exception = null;
+ var split = qualifiedTypeName.Split(':');
+ if (split.Length > 2)
+ return null;
+
+ string prefix, name;
+ if (split.Length == 2)
+ {
+ prefix = split[0];
+ name = split[1];
+ }
+ else
+ {
+ prefix = "";
+ name = split[0];
+ }
+
+ IXmlLineInfo xmlLineInfo = null;
+ if (serviceProvider != null)
+ {
+ var lineInfoProvider = serviceProvider.GetService(typeof (IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ if (lineInfoProvider != null)
+ xmlLineInfo = lineInfoProvider.XmlLineInfo;
+ }
+
+ var namespaceuri = namespaceResolver.LookupNamespace(prefix);
+ if (namespaceuri == null)
+ {
+ exception = new XamlParseException(string.Format("No xmlns declaration for prefix \"{0}\"", prefix), xmlLineInfo);
+ return null;
+ }
+
+ return getTypeFromXmlName(new XmlType(namespaceuri, name, null), xmlLineInfo, currentAssembly, out exception);
+ }
+
+ internal delegate Type GetTypeFromXmlName(
+ XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly, out XamlParseException exception);
+ }
+
+ internal class XamlRootObjectProvider : IRootObjectProvider
+ {
+ public XamlRootObjectProvider(object rootObject)
+ {
+ RootObject = rootObject;
+ }
+
+ public object RootObject { get; }
+ }
+
+ internal class XmlLineInfoProvider : IXmlLineInfoProvider
+ {
+ public XmlLineInfoProvider(IXmlLineInfo xmlLineInfo)
+ {
+ XmlLineInfo = xmlLineInfo;
+ }
+
+ public IXmlLineInfo XmlLineInfo { get; }
+ }
+
+ internal class NameScopeProvider : INameScopeProvider
+ {
+ public INameScope NameScope { get; set; }
+ }
+
+ internal class XmlNamespaceResolver : IXmlNamespaceResolver
+ {
+ readonly Dictionary<string, string> namespaces = new Dictionary<string, string>();
+
+ public IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
+ {
+ throw new NotImplementedException();
+ }
+
+ public string LookupNamespace(string prefix)
+ {
+ string result;
+ if (namespaces.TryGetValue(prefix, out result))
+ return result;
+ return null;
+ }
+
+ public string LookupPrefix(string namespaceName)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Add(string prefix, string ns)
+ {
+ namespaces.Add(prefix, ns);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- internal class XmlLineInfo : IXmlLineInfo
- {
- readonly bool _hasLineInfo;
+ internal class XmlLineInfo : IXmlLineInfo
+ {
+ readonly bool _hasLineInfo;
- public XmlLineInfo()
- {
- }
+ public XmlLineInfo()
+ {
+ }
- public XmlLineInfo(int linenumber, int lineposition)
- {
- _hasLineInfo = true;
- LineNumber = linenumber;
- LinePosition = lineposition;
- }
+ public XmlLineInfo(int linenumber, int lineposition)
+ {
+ _hasLineInfo = true;
+ LineNumber = linenumber;
+ LinePosition = lineposition;
+ }
- public bool HasLineInfo()
- {
- return _hasLineInfo;
- }
+ public bool HasLineInfo()
+ {
+ return _hasLineInfo;
+ }
- public int LineNumber { get; }
+ public int LineNumber { get; }
- public int LinePosition { get; }
- }
+ public int LinePosition { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- [DebuggerDisplay("{NamespaceURI}:{LocalName}")]
- internal struct XmlName
- {
- public static readonly XmlName _CreateContent = new XmlName("_", "CreateContent");
- public static readonly XmlName xKey = new XmlName("x", "Key");
- public static readonly XmlName xName = new XmlName("x", "Name");
- public static readonly XmlName xTypeArguments = new XmlName("x", "TypeArguments");
- public static readonly XmlName xArguments = new XmlName("x", "Arguments");
- public static readonly XmlName xFactoryMethod = new XmlName("x", "FactoryMethod");
- public static readonly XmlName xDataType = new XmlName("x", "DataType");
- public static readonly XmlName Empty = new XmlName();
-
- public string NamespaceURI { get; }
- public string LocalName { get; }
-
- public XmlName(string namespaceUri, string localName)
- {
- NamespaceURI = namespaceUri;
- LocalName = localName;
- }
-
- public override bool Equals(object obj)
- {
- if (obj == null)
- return false;
- if (obj.GetType() != typeof (XmlName))
- return false;
- var other = (XmlName)obj;
- return NamespaceURI == other.NamespaceURI && LocalName == other.LocalName;
- }
-
- public bool Equals(string namespaceUri, string localName)
- => Equals(new XmlName(namespaceUri, localName));
-
- public override int GetHashCode()
- {
- unchecked
- {
- int hashCode = 0;
- if (NamespaceURI != null)
- hashCode = NamespaceURI.GetHashCode();
- if (LocalName != null)
- hashCode = (hashCode * 397) ^ LocalName.GetHashCode();
- return hashCode;
- }
- }
-
- public static bool operator ==(XmlName x1, XmlName x2)
- => x1.NamespaceURI == x2.NamespaceURI && x1.LocalName == x2.LocalName;
-
- public static bool operator !=(XmlName x1, XmlName x2)
- => !(x1 == x2);
- }
+ [DebuggerDisplay("{NamespaceURI}:{LocalName}")]
+ internal struct XmlName
+ {
+ public static readonly XmlName _CreateContent = new XmlName("_", "CreateContent");
+ public static readonly XmlName xKey = new XmlName("x", "Key");
+ public static readonly XmlName xName = new XmlName("x", "Name");
+ public static readonly XmlName xTypeArguments = new XmlName("x", "TypeArguments");
+ public static readonly XmlName xArguments = new XmlName("x", "Arguments");
+ public static readonly XmlName xFactoryMethod = new XmlName("x", "FactoryMethod");
+ public static readonly XmlName xDataType = new XmlName("x", "DataType");
+ public static readonly XmlName Empty = new XmlName();
+
+ public string NamespaceURI { get; }
+ public string LocalName { get; }
+
+ public XmlName(string namespaceUri, string localName)
+ {
+ NamespaceURI = namespaceUri;
+ LocalName = localName;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null)
+ return false;
+ if (obj.GetType() != typeof (XmlName))
+ return false;
+ var other = (XmlName)obj;
+ return NamespaceURI == other.NamespaceURI && LocalName == other.LocalName;
+ }
+
+ public bool Equals(string namespaceUri, string localName)
+ => Equals(new XmlName(namespaceUri, localName));
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = 0;
+ if (NamespaceURI != null)
+ hashCode = NamespaceURI.GetHashCode();
+ if (LocalName != null)
+ hashCode = (hashCode * 397) ^ LocalName.GetHashCode();
+ return hashCode;
+ }
+ }
+
+ public static bool operator ==(XmlName x1, XmlName x2)
+ => x1.NamespaceURI == x2.NamespaceURI && x1.LocalName == x2.LocalName;
+
+ public static bool operator !=(XmlName x1, XmlName x2)
+ => !(x1 == x2);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Xaml
{
- static class XmlnsHelper
- {
- public static string ParseNamespaceFromXmlns(string xmlns)
- {
- string typeName;
- string ns;
- string asm;
- string targetPlatform;
+ internal static class XmlnsHelper
+ {
+ public static string ParseNamespaceFromXmlns(string xmlns)
+ {
+ string typeName;
+ string ns;
+ string asm;
+ string targetPlatform;
- ParseXmlns(xmlns, out typeName, out ns, out asm, out targetPlatform);
+ ParseXmlns(xmlns, out typeName, out ns, out asm, out targetPlatform);
- return ns;
- }
+ return ns;
+ }
- public static void ParseXmlns(string xmlns, out string typeName, out string ns, out string asm, out string targetPlatform)
- {
- typeName = ns = asm = targetPlatform = null;
+ public static void ParseXmlns(string xmlns, out string typeName, out string ns, out string asm, out string targetPlatform)
+ {
+ typeName = ns = asm = targetPlatform = null;
- xmlns = xmlns.Trim();
+ xmlns = xmlns.Trim();
- if (xmlns.StartsWith("using:", StringComparison.Ordinal)) {
- ParseUsing(xmlns, out typeName, out ns, out asm, out targetPlatform);
- return;
- }
- ParseClrNamespace(xmlns, out typeName, out ns, out asm, out targetPlatform);
- }
+ if (xmlns.StartsWith("using:", StringComparison.Ordinal)) {
+ ParseUsing(xmlns, out typeName, out ns, out asm, out targetPlatform);
+ return;
+ }
+ ParseClrNamespace(xmlns, out typeName, out ns, out asm, out targetPlatform);
+ }
- static void ParseClrNamespace(string xmlns, out string typeName, out string ns, out string asm, out string targetPlatform)
- {
- typeName = ns = asm = targetPlatform = null;
+ static void ParseClrNamespace(string xmlns, out string typeName, out string ns, out string asm, out string targetPlatform)
+ {
+ typeName = ns = asm = targetPlatform = null;
- foreach (var decl in xmlns.Split(';'))
- {
- if (decl.StartsWith("clr-namespace:", StringComparison.Ordinal))
- {
- ns = decl.Substring(14, decl.Length - 14);
- continue;
- }
- if (decl.StartsWith("assembly=", StringComparison.Ordinal))
- {
- asm = decl.Substring(9, decl.Length - 9);
- continue;
- }
- if (decl.StartsWith("targetPlatform=", StringComparison.Ordinal)) {
- targetPlatform = decl.Substring(15, decl.Length - 15);
- continue;
- }
- var nsind = decl.LastIndexOf(".", StringComparison.Ordinal);
- if (nsind > 0)
- {
- ns = decl.Substring(0, nsind);
- typeName = decl.Substring(nsind + 1, decl.Length - nsind - 1);
- }
- else
- typeName = decl;
- }
- }
+ foreach (var decl in xmlns.Split(';'))
+ {
+ if (decl.StartsWith("clr-namespace:", StringComparison.Ordinal))
+ {
+ ns = decl.Substring(14, decl.Length - 14);
+ continue;
+ }
+ if (decl.StartsWith("assembly=", StringComparison.Ordinal))
+ {
+ asm = decl.Substring(9, decl.Length - 9);
+ continue;
+ }
+ if (decl.StartsWith("targetPlatform=", StringComparison.Ordinal)) {
+ targetPlatform = decl.Substring(15, decl.Length - 15);
+ continue;
+ }
+ var nsind = decl.LastIndexOf(".", StringComparison.Ordinal);
+ if (nsind > 0)
+ {
+ ns = decl.Substring(0, nsind);
+ typeName = decl.Substring(nsind + 1, decl.Length - nsind - 1);
+ }
+ else
+ typeName = decl;
+ }
+ }
- static void ParseUsing(string xmlns, out string typeName, out string ns, out string asm, out string targetPlatform)
- {
- typeName = ns = asm = targetPlatform = null;
+ static void ParseUsing(string xmlns, out string typeName, out string ns, out string asm, out string targetPlatform)
+ {
+ typeName = ns = asm = targetPlatform = null;
- foreach (var decl in xmlns.Split(';')) {
- if (decl.StartsWith("using:", StringComparison.Ordinal)) {
- ns = decl.Substring(6, decl.Length - 6);
- continue;
- }
- }
- }
- }
+ foreach (var decl in xmlns.Split(';')) {
+ if (decl.StartsWith("using:", StringComparison.Ordinal)) {
+ ns = decl.Substring(6, decl.Length - 6);
+ continue;
+ }
+ }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [System.ComponentModel.TypeConverter(typeof(AcceleratorTypeConverter))]
- internal class Accelerator
- {
- const char Separator = '+';
- string _text;
+ [System.ComponentModel.TypeConverter(typeof(AcceleratorTypeConverter))]
+ internal class Accelerator
+ {
+ const char Separator = '+';
+ string _text;
- internal Accelerator(string text)
- {
- if (string.IsNullOrEmpty(text))
- throw new ArgumentNullException(nameof(text));
- _text = text;
- }
+ internal Accelerator(string text)
+ {
+ if (string.IsNullOrEmpty(text))
+ throw new ArgumentNullException(nameof(text));
+ _text = text;
+ }
- [EditorBrowsable(EditorBrowsableState.Never)]
- public IEnumerable<string> Modifiers { get; set; }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public IEnumerable<string> Modifiers { get; set; }
- [EditorBrowsable(EditorBrowsableState.Never)]
- public IEnumerable<string> Keys { get; set; }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public IEnumerable<string> Keys { get; set; }
- public static Accelerator FromString(string text)
- {
- var accelarat = new Accelerator(text);
+ public static Accelerator FromString(string text)
+ {
+ var accelarat = new Accelerator(text);
- var acceleratorParts = text.Split(Separator);
+ var acceleratorParts = text.Split(Separator);
- if (acceleratorParts.Length > 1)
- {
- var modifiers = new List<string>();
- for (int i = 0; i < acceleratorParts.Length; i++)
- {
- var modifierMask = acceleratorParts[i];
- var modiferMaskLower = modifierMask.ToLower();
- switch (modiferMaskLower)
- {
- case "ctrl":
- case "cmd":
- case "alt":
- case "shift":
- case "fn":
- case "win":
- modifiers.Add(modiferMaskLower);
- text = text.Replace(modifierMask, "");
- break;
- }
- }
- accelarat.Modifiers = modifiers;
+ if (acceleratorParts.Length > 1)
+ {
+ var modifiers = new List<string>();
+ for (int i = 0; i < acceleratorParts.Length; i++)
+ {
+ var modifierMask = acceleratorParts[i];
+ var modiferMaskLower = modifierMask.ToLower();
+ switch (modiferMaskLower)
+ {
+ case "ctrl":
+ case "cmd":
+ case "alt":
+ case "shift":
+ case "fn":
+ case "win":
+ modifiers.Add(modiferMaskLower);
+ text = text.Replace(modifierMask, "");
+ break;
+ }
+ }
+ accelarat.Modifiers = modifiers;
- }
+ }
- var keys = text.Split(new char[] { Separator }, StringSplitOptions.RemoveEmptyEntries);
- accelarat.Keys = keys;
- return accelarat;
- }
+ var keys = text.Split(new char[] { Separator }, StringSplitOptions.RemoveEmptyEntries);
+ accelarat.Keys = keys;
+ return accelarat;
+ }
- public override string ToString()
- {
- return _text;
- }
+ public override string ToString()
+ {
+ return _text;
+ }
- public override bool Equals(object obj)
- {
- return obj != null && obj is Accelerator && Equals((Accelerator)obj);
- }
+ public override bool Equals(object obj)
+ {
+ return obj != null && obj is Accelerator && Equals((Accelerator)obj);
+ }
- bool Equals(Accelerator other)
- {
- return other.ToString() == ToString();
- }
+ bool Equals(Accelerator other)
+ {
+ return other.ToString() == ToString();
+ }
- public override int GetHashCode()
- {
- return ToString().GetHashCode();
- }
+ public override int GetHashCode()
+ {
+ return ToString().GetHashCode();
+ }
- public static implicit operator Accelerator(string accelerator)
- {
- return FromString(accelerator);
- }
- }
+ public static implicit operator Accelerator(string accelerator)
+ {
+ return FromString(accelerator);
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal class AcceleratorTypeConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- if (value == null)
- return null;
+ internal class AcceleratorTypeConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (value == null)
+ return null;
- return Accelerator.FromString(value);
- }
- }
+ return Accelerator.FromString(value);
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal class ActionSheetArguments
- {
- public ActionSheetArguments(string title, string cancel, string destruction, IEnumerable<string> buttons)
- {
- Title = title;
- Cancel = cancel;
- Destruction = destruction;
- Buttons = buttons;
- Result = new TaskCompletionSource<string>();
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class ActionSheetArguments
+ {
+ public ActionSheetArguments(string title, string cancel, string destruction, IEnumerable<string> buttons)
+ {
+ Title = title;
+ Cancel = cancel;
+ Destruction = destruction;
+ Buttons = buttons;
+ Result = new TaskCompletionSource<string>();
+ }
- /// <summary>
- /// Gets titles of any buttons on the action sheet that aren't <see cref="Cancel" /> or <see cref="Destruction" />. Can
- /// be <c>null</c>.
- /// </summary>
- public IEnumerable<string> Buttons { get; private set; }
+ /// <summary>
+ /// Gets titles of any buttons on the action sheet that aren't <see cref="Cancel" /> or <see cref="Destruction" />. Can
+ /// be <c>null</c>.
+ /// </summary>
+ public IEnumerable<string> Buttons { get; private set; }
- /// <summary>
- /// Gets the text for a cancel button. Can be null.
- /// </summary>
- public string Cancel { get; private set; }
+ /// <summary>
+ /// Gets the text for a cancel button. Can be null.
+ /// </summary>
+ public string Cancel { get; private set; }
- /// <summary>
- /// Gets the text for a destructive button. Can be null.
- /// </summary>
- public string Destruction { get; private set; }
+ /// <summary>
+ /// Gets the text for a destructive button. Can be null.
+ /// </summary>
+ public string Destruction { get; private set; }
- public TaskCompletionSource<string> Result { get; }
+ public TaskCompletionSource<string> Result { get; }
- /// <summary>
- /// Gets the title for the action sheet. Can be null.
- /// </summary>
- public string Title { get; private set; }
+ /// <summary>
+ /// Gets the title for the action sheet. Can be null.
+ /// </summary>
+ public string Title { get; private set; }
- public void SetResult(string result)
- {
- Result.TrySetResult(result);
- }
- }
+ public void SetResult(string result)
+ {
+ Result.TrySetResult(result);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal class AlertArguments
- {
- public AlertArguments(string title, string message, string accept, string cancel)
- {
- Title = title;
- Message = message;
- Accept = accept;
- Cancel = cancel;
- Result = new TaskCompletionSource<bool>();
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class AlertArguments
+ {
+ public AlertArguments(string title, string message, string accept, string cancel)
+ {
+ Title = title;
+ Message = message;
+ Accept = accept;
+ Cancel = cancel;
+ Result = new TaskCompletionSource<bool>();
+ }
- /// <summary>
- /// Gets the text for the accept button. Can be null.
- /// </summary>
- public string Accept { get; private set; }
+ /// <summary>
+ /// Gets the text for the accept button. Can be null.
+ /// </summary>
+ public string Accept { get; private set; }
- /// <summary>
- /// Gets the text of the cancel button.
- /// </summary>
- public string Cancel { get; private set; }
+ /// <summary>
+ /// Gets the text of the cancel button.
+ /// </summary>
+ public string Cancel { get; private set; }
- /// <summary>
- /// Gets the message for the alert. Can be null.
- /// </summary>
- public string Message { get; private set; }
+ /// <summary>
+ /// Gets the message for the alert. Can be null.
+ /// </summary>
+ public string Message { get; private set; }
- public TaskCompletionSource<bool> Result { get; }
+ public TaskCompletionSource<bool> Result { get; }
- /// <summary>
- /// Gets the title for the alert. Can be null.
- /// </summary>
- public string Title { get; private set; }
+ /// <summary>
+ /// Gets the title for the alert. Can be null.
+ /// </summary>
+ public string Title { get; private set; }
- public void SetResult(bool result)
- {
- Result.TrySetResult(result);
- }
- }
+ public void SetResult(bool result)
+ {
+ Result.TrySetResult(result);
+ }
+ }
}
\ No newline at end of file
using System.Threading;
using System.ComponentModel;
using System.Threading.Tasks;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- internal class Application : Element, IResourcesProvider, IApplicationController, IElementConfiguration<Application>
- {
- static Application s_current;
- Task<IDictionary<string, object>> _propertiesTask;
- readonly Lazy<PlatformConfigurationRegistry<Application>> _platformConfigurationRegistry;
-
- IAppIndexingProvider _appIndexProvider;
-
- ReadOnlyCollection<Element> _logicalChildren;
-
- Page _mainPage;
-
- static SemaphoreSlim SaveSemaphore = new SemaphoreSlim(1, 1);
-
- public Application()
- {
- // var f = false;
- // if (f)
- // Loader.Load();
- NavigationProxy = new NavigationImpl(this);
- SetCurrentApplication(this);
-
- SystemResources = DependencyService.Get<ISystemResourcesProvider>().GetSystemResources();
- SystemResources.ValuesChanged += OnParentResourcesChanged;
- _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Application>>(() => new PlatformConfigurationRegistry<Application>(this));
- }
-
- public void Quit()
- {
- Device.PlatformServices?.QuitApplication();
- }
-
- public IAppLinks AppLinks
- {
- get
- {
- 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");
- return _appIndexProvider.AppLinks;
- }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void SetCurrentApplication(Application value) => Current = value;
-
- public static Application Current
- {
- get { return s_current; }
- set
- {
- if (s_current == value)
- return;
- if (value == null)
- s_current = null; //Allow to reset current for unittesting
- s_current = value;
- }
- }
-
- public Page MainPage
- {
- get { return _mainPage; }
- set
- {
- if (value == null)
- throw new ArgumentNullException("value");
-
- if (_mainPage == value)
- return;
-
- OnPropertyChanging();
- if (_mainPage != null)
- {
- InternalChildren.Remove(_mainPage);
- _mainPage.Parent = null;
- }
-
- _mainPage = value;
-
- if (_mainPage != null)
- {
- _mainPage.Parent = this;
- _mainPage.NavigationProxy.Inner = NavigationProxy;
- InternalChildren.Add(_mainPage);
- }
- OnPropertyChanged();
- }
- }
-
- public IDictionary<string, object> Properties
- {
- get
- {
- if (_propertiesTask == null)
- {
- _propertiesTask = GetPropertiesAsync();
- }
-
- return _propertiesTask.Result;
- }
- }
-
- internal override ReadOnlyCollection<Element> LogicalChildrenInternal
- {
- get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public NavigationProxy NavigationProxy { get; }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public int PanGestureId { get; set; }
-
- internal IResourceDictionary SystemResources { get; }
-
- ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SetAppIndexingProvider(IAppIndexingProvider provider)
- {
- _appIndexProvider = provider;
- }
-
- ResourceDictionary _resources;
- bool IResourcesProvider.IsResourcesCreated => _resources != null;
-
- public ResourceDictionary Resources
- {
- get
- {
- if (_resources != null)
- return _resources;
-
- _resources = new ResourceDictionary();
- ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
- return _resources;
- }
- set
- {
- if (_resources == value)
- return;
- OnPropertyChanging();
- if (_resources != null)
- ((IResourceDictionary)_resources).ValuesChanged -= OnResourcesChanged;
- _resources = value;
- OnResourcesChanged(value);
- if (_resources != null)
- ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
- OnPropertyChanged();
- }
- }
-
- public event EventHandler<ModalPoppedEventArgs> ModalPopped;
-
- public event EventHandler<ModalPoppingEventArgs> ModalPopping;
-
- public event EventHandler<ModalPushedEventArgs> ModalPushed;
-
- public event EventHandler<ModalPushingEventArgs> ModalPushing;
-
- public event EventHandler<Page> PageAppearing;
-
- public event EventHandler<Page> PageDisappearing;
-
-
- async void SaveProperties()
- {
- try
- {
- await SetPropertiesAsync();
- }
- catch (Exception exc)
- {
- Console.WriteLine(nameof(Application), $"Exception while saving Application Properties: {exc}");
- }
- }
-
- public async Task SavePropertiesAsync()
- {
- if (Device.IsInvokeRequired)
- {
- Device.BeginInvokeOnMainThread(SaveProperties);
- }
- else
- {
- await SetPropertiesAsync();
- }
- }
-
- // Don't use this unless there really is no better option
- internal void SavePropertiesAsFireAndForget()
- {
- if (Device.IsInvokeRequired)
- {
- Device.BeginInvokeOnMainThread(SaveProperties);
- }
- else
- {
- SaveProperties();
- }
- }
-
- public IPlatformElementConfiguration<T, Application> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
-
- protected virtual void OnAppLinkRequestReceived(Uri uri)
- {
- }
-
- protected override void OnParentSet()
- {
- throw new InvalidOperationException("Setting a Parent on Application is invalid.");
- }
-
- protected virtual void OnResume()
- {
- }
-
- protected virtual void OnSleep()
- {
- }
-
- protected virtual void OnStart()
- {
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void ClearCurrent()
- {
- s_current = null;
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static bool IsApplicationOrNull(Element element)
- {
- return element == null || element is Application;
- }
-
- internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
- {
- if (!((IResourcesProvider)this).IsResourcesCreated || Resources.Count == 0)
- {
- base.OnParentResourcesChanged(values);
- return;
- }
-
- var innerKeys = new HashSet<string>();
- var changedResources = new List<KeyValuePair<string, object>>();
- foreach (KeyValuePair<string, object> c in Resources)
- innerKeys.Add(c.Key);
- foreach (KeyValuePair<string, object> value in values)
- {
- if (innerKeys.Add(value.Key))
- changedResources.Add(value);
- }
- OnResourcesChanged(changedResources);
- }
-
- internal event EventHandler PopCanceled;
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SendOnAppLinkRequestReceived(Uri uri)
- {
- OnAppLinkRequestReceived(uri);
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SendResume()
- {
- s_current = this;
- OnResume();
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SendSleep()
- {
- OnSleep();
- SavePropertiesAsFireAndForget();
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Task SendSleepAsync()
- {
- OnSleep();
- return SavePropertiesAsync();
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SendStart()
- {
- OnStart();
- }
-
- async Task<IDictionary<string, object>> GetPropertiesAsync()
- {
- var deserializer = DependencyService.Get<IDeserializer>();
- if (deserializer == null)
- {
- Console.WriteLine("Startup", "No IDeserialzier was found registered");
- return new Dictionary<string, object>(4);
- }
-
- IDictionary<string, object> properties = await deserializer.DeserializePropertiesAsync().ConfigureAwait(false);
- if (properties == null)
- properties = new Dictionary<string, object>(4);
-
- return properties;
- }
-
- internal void OnPageAppearing(Page page)
- => PageAppearing?.Invoke(this, page);
-
- internal void OnPageDisappearing(Page page)
- => PageDisappearing?.Invoke(this, page);
-
- void OnModalPopped(Page modalPage)
- => ModalPopped?.Invoke(this, new ModalPoppedEventArgs(modalPage));
-
- bool OnModalPopping(Page modalPage)
- {
- var args = new ModalPoppingEventArgs(modalPage);
- ModalPopping?.Invoke(this, args);
- return args.Cancel;
- }
-
- void OnModalPushed(Page modalPage)
- => ModalPushed?.Invoke(this, new ModalPushedEventArgs(modalPage));
-
- void OnModalPushing(Page modalPage)
- => ModalPushing?.Invoke(this, new ModalPushingEventArgs(modalPage));
-
- void OnPopCanceled()
- => PopCanceled?.Invoke(this, EventArgs.Empty);
-
- async Task SetPropertiesAsync()
- {
- await SaveSemaphore.WaitAsync();
- try
- {
- await DependencyService.Get<IDeserializer>().SerializePropertiesAsync(Properties);
- }
- finally
- {
- SaveSemaphore.Release();
- }
-
- }
-
- class NavigationImpl : NavigationProxy
- {
- readonly Application _owner;
-
- public NavigationImpl(Application owner)
- {
- _owner = owner;
- }
-
- protected override async Task<Page> OnPopModal(bool animated)
- {
- Page modal = ModalStack[ModalStack.Count - 1];
- if (_owner.OnModalPopping(modal))
- {
- _owner.OnPopCanceled();
- return null;
- }
- Page result = await base.OnPopModal(animated);
- result.Parent = null;
- _owner.OnModalPopped(result);
- return result;
- }
-
- protected override async Task OnPushModal(Page modal, bool animated)
- {
- _owner.OnModalPushing(modal);
-
- modal.Parent = _owner;
-
- if (modal.NavigationProxy.ModalStack.Count == 0)
- {
- modal.NavigationProxy.Inner = this;
- await base.OnPushModal(modal, animated);
- }
- else
- {
- await base.OnPushModal(modal, animated);
- modal.NavigationProxy.Inner = this;
- }
-
- _owner.OnModalPushed(modal);
- }
- }
- }
+ internal class Application : Element, IResourcesProvider, IApplicationController, IElementConfiguration<Application>
+ {
+ static Application s_current;
+ Task<IDictionary<string, object>> _propertiesTask;
+ readonly Lazy<PlatformConfigurationRegistry<Application>> _platformConfigurationRegistry;
+
+ IAppIndexingProvider _appIndexProvider;
+
+ ReadOnlyCollection<Element> _logicalChildren;
+
+ Page _mainPage;
+
+ static SemaphoreSlim SaveSemaphore = new SemaphoreSlim(1, 1);
+
+ public Application()
+ {
+ // var f = false;
+ // if (f)
+ // Loader.Load();
+ NavigationProxy = new NavigationImpl(this);
+ SetCurrentApplication(this);
+
+ SystemResources = DependencyService.Get<ISystemResourcesProvider>().GetSystemResources();
+ SystemResources.ValuesChanged += OnParentResourcesChanged;
+ _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Application>>(() => new PlatformConfigurationRegistry<Application>(this));
+ }
+
+ public void Quit()
+ {
+ Device.PlatformServices?.QuitApplication();
+ }
+
+ public IAppLinks AppLinks
+ {
+ get
+ {
+ 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");
+ return _appIndexProvider.AppLinks;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void SetCurrentApplication(Application value) => Current = value;
+
+ public static Application Current
+ {
+ get { return s_current; }
+ set
+ {
+ if (s_current == value)
+ return;
+ if (value == null)
+ s_current = null; //Allow to reset current for unittesting
+ s_current = value;
+ }
+ }
+
+ public Page MainPage
+ {
+ get { return _mainPage; }
+ set
+ {
+ if (value == null)
+ throw new ArgumentNullException("value");
+
+ if (_mainPage == value)
+ return;
+
+ OnPropertyChanging();
+ if (_mainPage != null)
+ {
+ InternalChildren.Remove(_mainPage);
+ _mainPage.Parent = null;
+ }
+
+ _mainPage = value;
+
+ if (_mainPage != null)
+ {
+ _mainPage.Parent = this;
+ _mainPage.NavigationProxy.Inner = NavigationProxy;
+ InternalChildren.Add(_mainPage);
+ }
+ OnPropertyChanged();
+ }
+ }
+
+ public IDictionary<string, object> Properties
+ {
+ get
+ {
+ if (_propertiesTask == null)
+ {
+ _propertiesTask = GetPropertiesAsync();
+ }
+
+ return _propertiesTask.Result;
+ }
+ }
+
+ internal override ReadOnlyCollection<Element> LogicalChildrenInternal
+ {
+ get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public NavigationProxy NavigationProxy { get; }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int PanGestureId { get; set; }
+
+ internal IResourceDictionary SystemResources { get; }
+
+ ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetAppIndexingProvider(IAppIndexingProvider provider)
+ {
+ _appIndexProvider = provider;
+ }
+
+ ResourceDictionary _resources;
+ bool IResourcesProvider.IsResourcesCreated => _resources != null;
+
+ public ResourceDictionary Resources
+ {
+ get
+ {
+ if (_resources != null)
+ return _resources;
+
+ _resources = new ResourceDictionary();
+ ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
+ return _resources;
+ }
+ set
+ {
+ if (_resources == value)
+ return;
+ OnPropertyChanging();
+ if (_resources != null)
+ ((IResourceDictionary)_resources).ValuesChanged -= OnResourcesChanged;
+ _resources = value;
+ OnResourcesChanged(value);
+ if (_resources != null)
+ ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
+ OnPropertyChanged();
+ }
+ }
+
+ public event EventHandler<ModalPoppedEventArgs> ModalPopped;
+
+ public event EventHandler<ModalPoppingEventArgs> ModalPopping;
+
+ public event EventHandler<ModalPushedEventArgs> ModalPushed;
+
+ public event EventHandler<ModalPushingEventArgs> ModalPushing;
+
+ public event EventHandler<Page> PageAppearing;
+
+ public event EventHandler<Page> PageDisappearing;
+
+
+ async void SaveProperties()
+ {
+ try
+ {
+ await SetPropertiesAsync();
+ }
+ catch (Exception exc)
+ {
+ Console.WriteLine(nameof(Application), $"Exception while saving Application Properties: {exc}");
+ }
+ }
+
+ public async Task SavePropertiesAsync()
+ {
+ if (Device.IsInvokeRequired)
+ {
+ Device.BeginInvokeOnMainThread(SaveProperties);
+ }
+ else
+ {
+ await SetPropertiesAsync();
+ }
+ }
+
+ // Don't use this unless there really is no better option
+ internal void SavePropertiesAsFireAndForget()
+ {
+ if (Device.IsInvokeRequired)
+ {
+ Device.BeginInvokeOnMainThread(SaveProperties);
+ }
+ else
+ {
+ SaveProperties();
+ }
+ }
+
+ public IPlatformElementConfiguration<T, Application> On<T>() where T : IConfigPlatform
+ {
+ return _platformConfigurationRegistry.Value.On<T>();
+ }
+
+ protected virtual void OnAppLinkRequestReceived(Uri uri)
+ {
+ }
+
+ protected override void OnParentSet()
+ {
+ throw new InvalidOperationException("Setting a Parent on Application is invalid.");
+ }
+
+ protected virtual void OnResume()
+ {
+ }
+
+ protected virtual void OnSleep()
+ {
+ }
+
+ protected virtual void OnStart()
+ {
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void ClearCurrent()
+ {
+ s_current = null;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static bool IsApplicationOrNull(Element element)
+ {
+ return element == null || element is Application;
+ }
+
+ internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
+ {
+ if (!((IResourcesProvider)this).IsResourcesCreated || Resources.Count == 0)
+ {
+ base.OnParentResourcesChanged(values);
+ return;
+ }
+
+ var innerKeys = new HashSet<string>();
+ var changedResources = new List<KeyValuePair<string, object>>();
+ foreach (KeyValuePair<string, object> c in Resources)
+ innerKeys.Add(c.Key);
+ foreach (KeyValuePair<string, object> value in values)
+ {
+ if (innerKeys.Add(value.Key))
+ changedResources.Add(value);
+ }
+ OnResourcesChanged(changedResources);
+ }
+
+ internal event EventHandler PopCanceled;
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendOnAppLinkRequestReceived(Uri uri)
+ {
+ OnAppLinkRequestReceived(uri);
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendResume()
+ {
+ s_current = this;
+ OnResume();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendSleep()
+ {
+ OnSleep();
+ SavePropertiesAsFireAndForget();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Task SendSleepAsync()
+ {
+ OnSleep();
+ return SavePropertiesAsync();
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendStart()
+ {
+ OnStart();
+ }
+
+ async Task<IDictionary<string, object>> GetPropertiesAsync()
+ {
+ var deserializer = DependencyService.Get<IDeserializer>();
+ if (deserializer == null)
+ {
+ Console.WriteLine("Startup", "No IDeserialzier was found registered");
+ return new Dictionary<string, object>(4);
+ }
+
+ IDictionary<string, object> properties = await deserializer.DeserializePropertiesAsync().ConfigureAwait(false);
+ if (properties == null)
+ properties = new Dictionary<string, object>(4);
+
+ return properties;
+ }
+
+ internal void OnPageAppearing(Page page)
+ => PageAppearing?.Invoke(this, page);
+
+ internal void OnPageDisappearing(Page page)
+ => PageDisappearing?.Invoke(this, page);
+
+ void OnModalPopped(Page modalPage)
+ => ModalPopped?.Invoke(this, new ModalPoppedEventArgs(modalPage));
+
+ bool OnModalPopping(Page modalPage)
+ {
+ var args = new ModalPoppingEventArgs(modalPage);
+ ModalPopping?.Invoke(this, args);
+ return args.Cancel;
+ }
+
+ void OnModalPushed(Page modalPage)
+ => ModalPushed?.Invoke(this, new ModalPushedEventArgs(modalPage));
+
+ void OnModalPushing(Page modalPage)
+ => ModalPushing?.Invoke(this, new ModalPushingEventArgs(modalPage));
+
+ void OnPopCanceled()
+ => PopCanceled?.Invoke(this, EventArgs.Empty);
+
+ async Task SetPropertiesAsync()
+ {
+ await SaveSemaphore.WaitAsync();
+ try
+ {
+ await DependencyService.Get<IDeserializer>().SerializePropertiesAsync(Properties);
+ }
+ finally
+ {
+ SaveSemaphore.Release();
+ }
+
+ }
+
+ class NavigationImpl : NavigationProxy
+ {
+ readonly Application _owner;
+
+ public NavigationImpl(Application owner)
+ {
+ _owner = owner;
+ }
+
+ protected override async Task<Page> OnPopModal(bool animated)
+ {
+ Page modal = ModalStack[ModalStack.Count - 1];
+ if (_owner.OnModalPopping(modal))
+ {
+ _owner.OnPopCanceled();
+ return null;
+ }
+ Page result = await base.OnPopModal(animated);
+ result.Parent = null;
+ _owner.OnModalPopped(result);
+ return result;
+ }
+
+ protected override async Task OnPushModal(Page modal, bool animated)
+ {
+ _owner.OnModalPushing(modal);
+
+ modal.Parent = _owner;
+
+ if (modal.NavigationProxy.ModalStack.Count == 0)
+ {
+ modal.NavigationProxy.Inner = this;
+ await base.OnPushModal(modal, animated);
+ }
+ else
+ {
+ await base.OnPushModal(modal, animated);
+ modal.NavigationProxy.Inner = this;
+ }
+
+ _owner.OnModalPushed(modal);
+ }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal abstract class BaseMenuItem : Element
- {
- }
+ internal abstract class BaseMenuItem : Element
+ {
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal static class BindableObjectExtensions
- {
- public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null,
- string stringFormat = null)
- {
- if (self == null)
- throw new ArgumentNullException("self");
- if (targetProperty == null)
- throw new ArgumentNullException("targetProperty");
+ internal static class BindableObjectExtensions
+ {
+ public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null,
+ string stringFormat = null)
+ {
+ if (self == null)
+ throw new ArgumentNullException("self");
+ if (targetProperty == null)
+ throw new ArgumentNullException("targetProperty");
- var binding = new Binding(path, mode, converter, stringFormat: stringFormat);
- self.SetBinding(targetProperty, binding);
- }
+ var binding = new Binding(path, mode, converter, stringFormat: stringFormat);
+ self.SetBinding(targetProperty, binding);
+ }
- [Obsolete]
- public static void SetBinding<TSource>(this BindableObject self, BindableProperty targetProperty, Expression<Func<TSource, object>> sourceProperty, BindingMode mode = BindingMode.Default,
- IValueConverter converter = null, string stringFormat = null)
- {
- if (self == null)
- throw new ArgumentNullException("self");
- if (targetProperty == null)
- throw new ArgumentNullException("targetProperty");
- if (sourceProperty == null)
- throw new ArgumentNullException("sourceProperty");
+ [Obsolete]
+ public static void SetBinding<TSource>(this BindableObject self, BindableProperty targetProperty, Expression<Func<TSource, object>> sourceProperty, BindingMode mode = BindingMode.Default,
+ IValueConverter converter = null, string stringFormat = null)
+ {
+ if (self == null)
+ throw new ArgumentNullException("self");
+ if (targetProperty == null)
+ throw new ArgumentNullException("targetProperty");
+ if (sourceProperty == null)
+ throw new ArgumentNullException("sourceProperty");
- Binding binding = Binding.Create(sourceProperty, mode, converter, stringFormat: stringFormat);
- self.SetBinding(targetProperty, binding);
- }
- }
+ Binding binding = Binding.Create(sourceProperty, mode, converter, stringFormat: stringFormat);
+ self.SetBinding(targetProperty, binding);
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq.Expressions;
+using System.Reflection;
+using System.ComponentModel;
+using Tizen.NUI.Binding.Internals;
+using Tizen.NUI.Xaml;
+
+namespace Tizen.NUI.Binding
+{
+ /// <summary>
+ /// A BindableProperty is a backing store for properties allowing bindings on BindableObject.
+ /// </summary>
+ [DebuggerDisplay("{PropertyName}")]
+ [TypeConverter(typeof(BindablePropertyConverter))]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public sealed class BindableProperty
+ {
+ /// <summary>
+ /// Delegate for BindableProperty.PropertyChanged.
+ /// </summary>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <param name="oldValue">The old property value.</param>
+ /// <param name="newValue">The new property value.</param>
+ public delegate void BindingPropertyChangedDelegate(BindableObject bindable, object oldValue, object newValue);
+
+ /// <summary>
+ /// Strongly-typed delegate for BindableProperty.PropertyChanged.
+ /// </summary>
+ /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <param name="oldValue">The old property value.</param>
+ /// <param name="newValue">The new property value.</param>
+ public delegate void BindingPropertyChangedDelegate<in TPropertyType>(BindableObject bindable, TPropertyType oldValue, TPropertyType newValue);
+
+ /// <summary>
+ /// Delegate for BindableProperty.PropertyChanging.
+ /// </summary>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <param name="oldValue">The old property value.</param>
+ /// <param name="newValue">The new property value.</param>
+ public delegate void BindingPropertyChangingDelegate(BindableObject bindable, object oldValue, object newValue);
+
+ /// <summary>
+ /// Strongly-typed delegate for BindableProperty.PropertyChanging.
+ /// </summary>
+ /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <param name="oldValue">The old property value.</param>
+ /// <param name="newValue">The new property value.</param>
+ public delegate void BindingPropertyChangingDelegate<in TPropertyType>(BindableObject bindable, TPropertyType oldValue, TPropertyType newValue);
+
+ /// <summary>
+ /// Delegate for BindableProperty.CoerceValue.
+ /// </summary>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <param name="value">The value to coerce.</param>
+ /// <returns>System.Object</returns>
+ public delegate object CoerceValueDelegate(BindableObject bindable, object value);
+
+ /// <summary>
+ /// Strongly-typed delegate for BindableProperty.CoerceValue.
+ /// </summary>
+ /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <param name="value">The value to coerce.</param>
+ /// <returns>TPropertyType</returns>
+ public delegate TPropertyType CoerceValueDelegate<TPropertyType>(BindableObject bindable, TPropertyType value);
+
+ /// <summary>
+ /// Delegate for BindableProperty.DefaultValueCreator.
+ /// </summary>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <returns>System.Object</returns>
+ public delegate object CreateDefaultValueDelegate(BindableObject bindable);
+
+ /// <summary>
+ /// Strongly-typed delegate for BindableProperty.DefaultValueCreator.
+ /// </summary>
+ /// <typeparam name="TDeclarer">The type of the object that delared the property.</typeparam>
+ /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <returns>TPropertyType</returns>
+ public delegate TPropertyType CreateDefaultValueDelegate<in TDeclarer, out TPropertyType>(TDeclarer bindable);
+
+ /// <summary>
+ /// Delegate for BindableProperty.ValidateValue.
+ /// </summary>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <param name="value">The default value.</param>
+ /// <returns>System.Boolean</returns>
+ public delegate bool ValidateValueDelegate(BindableObject bindable, object value);
+
+ /// <summary>
+ /// Strongly-typed delegate for BindableProperty.ValidateValue.
+ /// </summary>
+ /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
+ /// <param name="bindable">The bindable object that contains the property.</param>
+ /// <param name="value">The default value.</param>
+ /// <returns>System.Boolean</returns>
+ public delegate bool ValidateValueDelegate<in TPropertyType>(BindableObject bindable, TPropertyType value);
+
+ static readonly Dictionary<Type, TypeConverter> WellKnownConvertTypes = new Dictionary<Type,TypeConverter>
+ {
+ { typeof(Uri), new UriTypeConverter() },
+ { typeof(Color), new ColorTypeConverter() },
+ };
+
+ // more or less the encoding of this, without the need to reflect
+ // http://msdn.microsoft.com/en-us/library/y5b434w4.aspx
+ static readonly Dictionary<Type, Type[]> SimpleConvertTypes = new Dictionary<Type, Type[]>
+ {
+ { typeof(sbyte), new[] { typeof(string), typeof(short), typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal) } },
+ { typeof(byte), new[] { typeof(string), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(ulong), typeof(float), typeof(double), typeof(decimal) } },
+ { typeof(short), new[] { typeof(string), typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal) } },
+ { typeof(ushort), new[] { typeof(string), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal) } },
+ { typeof(int), new[] { typeof(string), typeof(long), typeof(float), typeof(double), typeof(decimal) } },
+ { typeof(uint), new[] { typeof(string), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal) } },
+ { typeof(long), new[] { typeof(string), typeof(float), typeof(double), typeof(decimal) } },
+ { typeof(char), new[] { typeof(string), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal) } },
+ { typeof(float), new[] { typeof(string), typeof(double) } },
+ { typeof(ulong), new[] { typeof(string), typeof(float), typeof(double), typeof(decimal) } }
+ };
+
+ BindableProperty(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode = BindingMode.OneWay,
+ ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
+ CoerceValueDelegate coerceValue = null, BindablePropertyBindingChanging bindingChanging = null, bool isReadOnly = false, CreateDefaultValueDelegate defaultValueCreator = null)
+ {
+ if (propertyName == null)
+ throw new ArgumentNullException("propertyName");
+ if (ReferenceEquals(returnType, null))
+ throw new ArgumentNullException("returnType");
+ if (ReferenceEquals(declaringType, null))
+ throw new ArgumentNullException("declaringType");
+
+ // don't use Enum.IsDefined as its redonkulously expensive for what it does
+ if (defaultBindingMode != BindingMode.Default && defaultBindingMode != BindingMode.OneWay && defaultBindingMode != BindingMode.OneWayToSource && defaultBindingMode != BindingMode.TwoWay && defaultBindingMode != BindingMode.OneTime)
+ throw new ArgumentException("Not a valid type of BindingMode", "defaultBindingMode");
+ if (defaultValue == null && Nullable.GetUnderlyingType(returnType) == null && returnType.GetTypeInfo().IsValueType)
+ throw new ArgumentException("Not a valid default value", "defaultValue");
+ if (defaultValue != null && !returnType.IsInstanceOfType(defaultValue))
+ throw new ArgumentException("Default value did not match return type", "defaultValue");
+ if (defaultBindingMode == BindingMode.Default)
+ defaultBindingMode = BindingMode.OneWay;
+
+ PropertyName = propertyName;
+ ReturnType = returnType;
+ ReturnTypeInfo = returnType.GetTypeInfo();
+ DeclaringType = declaringType;
+ DefaultValue = defaultValue;
+ DefaultBindingMode = defaultBindingMode;
+ PropertyChanged = propertyChanged;
+ PropertyChanging = propertyChanging;
+ ValidateValue = validateValue;
+ CoerceValue = coerceValue;
+ BindingChanging = bindingChanging;
+ IsReadOnly = isReadOnly;
+ DefaultValueCreator = defaultValueCreator;
+ }
+
+ /// <summary>
+ /// Gets the type declaring the BindableProperty.
+ /// </summary>
+ public Type DeclaringType { get; private set; }
+
+ /// <summary>
+ /// Gets the default BindingMode.
+ /// </summary>
+ public BindingMode DefaultBindingMode { get; private set; }
+
+ /// <summary>
+ /// Gets the default value for the BindableProperty.
+ /// </summary>
+ public object DefaultValue { get; }
+
+ /// <summary>
+ /// Gets a value indicating if the BindableProperty is created form a BindablePropertyKey.
+ /// </summary>
+ public bool IsReadOnly { get; private set; }
+
+ /// <summary>
+ /// Gets the property name.
+ /// </summary>
+ public string PropertyName { get; }
+
+ /// <summary>
+ /// Gets the type of the BindableProperty.
+ /// </summary>
+ public Type ReturnType { get; }
+
+ internal BindablePropertyBindingChanging BindingChanging { get; private set; }
+
+ internal CoerceValueDelegate CoerceValue { get; private set; }
+
+ internal CreateDefaultValueDelegate DefaultValueCreator { get; }
+
+ internal BindingPropertyChangedDelegate PropertyChanged { get; private set; }
+
+ internal BindingPropertyChangingDelegate PropertyChanging { get; private set; }
+
+ internal System.Reflection.TypeInfo ReturnTypeInfo { get; }
+
+ internal ValidateValueDelegate ValidateValue { get; private set; }
+
+ /// <summary>
+ /// Deprecated. Do not use.
+ /// </summary>
+ /// <typeparam name="TDeclarer">The type of the declaring object.</typeparam>
+ /// <typeparam name="TPropertyType">The type of the property.</typeparam>
+ /// <param name="getter">An expression identifying the getter for the property using this BindableProperty as backing store.</param>
+ /// <param name="defaultValue">The default value for the property.</param>
+ /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
+ /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
+ /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
+ /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
+ /// <returns>A newly created BindableProperty.</returns>
+ [Obsolete("Create<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
+ public static BindableProperty Create<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>> getter, TPropertyType defaultValue, BindingMode defaultBindingMode = BindingMode.OneWay,
+ ValidateValueDelegate<TPropertyType> validateValue = null, BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null,
+ BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null, CoerceValueDelegate<TPropertyType> coerceValue = null,
+ CreateDefaultValueDelegate<TDeclarer, TPropertyType> defaultValueCreator = null) where TDeclarer : BindableObject
+ {
+ return Create(getter, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, defaultValueCreator: defaultValueCreator);
+ }
+
+ /// <summary>
+ /// Creates a new instance of the BindableProperty class.
+ /// </summary>
+ /// <param name="propertyName">The name of the BindableProperty.</param>
+ /// <param name="returnType">The type of the property.</param>
+ /// <param name="declaringType">The type of the declaring object.</param>
+ /// <param name="defaultValue">The default value for the property.</param>
+ /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
+ /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
+ /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
+ /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
+ /// <returns>A newly created BindableProperty.</returns>
+ public static BindableProperty Create(string propertyName, Type returnType, Type declaringType, object defaultValue = null, BindingMode defaultBindingMode = BindingMode.OneWay,
+ ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
+ CoerceValueDelegate coerceValue = null, CreateDefaultValueDelegate defaultValueCreator = null)
+ {
+ return new BindableProperty(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue,
+ defaultValueCreator: defaultValueCreator);
+ }
+
+ /// <summary>
+ /// Deprecated. Do not use.
+ /// </summary>
+ /// <typeparam name="TDeclarer">The type of the declaring object.</typeparam>
+ /// <typeparam name="TPropertyType">The type of the property.</typeparam>
+ /// <param name="staticgetter">An expression identifying a static method returning the value of the property using this BindableProperty as backing store.</param>
+ /// <param name="defaultValue">The default value for the property.</param>
+ /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
+ /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
+ /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
+ /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
+ [Obsolete("CreateAttached<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
+ public static BindableProperty CreateAttached<TDeclarer, TPropertyType>(Expression<Func<BindableObject, TPropertyType>> staticgetter, TPropertyType defaultValue,
+ BindingMode defaultBindingMode = BindingMode.OneWay, ValidateValueDelegate<TPropertyType> validateValue = null, BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null,
+ BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null, CoerceValueDelegate<TPropertyType> coerceValue = null,
+ CreateDefaultValueDelegate<BindableObject, TPropertyType> defaultValueCreator = null)
+ {
+ return CreateAttached<TDeclarer, TPropertyType>(staticgetter, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null,
+ defaultValueCreator: defaultValueCreator);
+ }
+
+ /// <summary>
+ /// Creates a new instance of the BindableProperty class for an attached property.
+ /// </summary>
+ /// <param name="propertyName">The name of the BindableProperty.</param>
+ /// <param name="returnType">The type of the property.</param>
+ /// <param name="declaringType">The type of the declaring object.</param>
+ /// <param name="defaultValue">The default value for the property.</param>
+ /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
+ /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
+ /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
+ /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
+ /// <returns>A newly created BindableProperty.</returns>
+ public static BindableProperty CreateAttached(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode = BindingMode.OneWay,
+ ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
+ CoerceValueDelegate coerceValue = null, CreateDefaultValueDelegate defaultValueCreator = null)
+ {
+ return CreateAttached(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, false, defaultValueCreator);
+ }
+
+ /// <summary>
+ /// Deprecated. Do not use.
+ /// </summary>
+ /// <typeparam name="TDeclarer">The type of the declaring object.</typeparam>
+ /// <typeparam name="TPropertyType">The type of the property.</typeparam>
+ /// <param name="staticgetter">An expression identifying a static method returning the value of the property using this BindableProperty as backing store.</param>
+ /// <param name="defaultValue">The default value for the property.</param>
+ /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
+ /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
+ /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
+ /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
+ /// <returns>A newly created attached read-only BindablePropertyKey.</returns>
+ [Obsolete("CreateAttachedReadOnly<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
+ public static BindablePropertyKey CreateAttachedReadOnly<TDeclarer, TPropertyType>(Expression<Func<BindableObject, TPropertyType>> staticgetter, TPropertyType defaultValue,
+ BindingMode defaultBindingMode = BindingMode.OneWayToSource, ValidateValueDelegate<TPropertyType> validateValue = null,
+ BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null, BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null,
+ CoerceValueDelegate<TPropertyType> coerceValue = null, CreateDefaultValueDelegate<BindableObject, TPropertyType> defaultValueCreator = null)
+
+ {
+ return
+ new BindablePropertyKey(CreateAttached<TDeclarer, TPropertyType>(staticgetter, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, true,
+ defaultValueCreator));
+ }
+
+ /// <summary>
+ /// Creates a new instance of the BindableProperty class for attached read-only properties.
+ /// </summary>
+ /// <param name="propertyName">The name of the BindableProperty.</param>
+ /// <param name="returnType">The type of the property.</param>
+ /// <param name="declaringType">The type of the declaring object.</param>
+ /// <param name="defaultValue">The default value for the property.</param>
+ /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
+ /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
+ /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
+ /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
+ /// <returns>A newly created attached read-only BindablePropertyKey.</returns>
+ public static BindablePropertyKey CreateAttachedReadOnly(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode = BindingMode.OneWayToSource,
+ ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
+ CoerceValueDelegate coerceValue = null, CreateDefaultValueDelegate defaultValueCreator = null)
+ {
+ return
+ new BindablePropertyKey(CreateAttached(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, true,
+ defaultValueCreator));
+ }
+
+ /// <summary>
+ /// Deprecated. Do not use.
+ /// </summary>
+ /// <typeparam name="TDeclarer">The type of the declaring object.</typeparam>
+ /// <typeparam name="TPropertyType">The type of the property.</typeparam>
+ /// <param name="getter">An expression identifying the getter for the property using this BindableProperty as backing store.</param>
+ /// <param name="defaultValue">The default value for the property.</param>
+ /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
+ /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
+ /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
+ /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
+ /// <returns>A newly created BindablePropertyKey.</returns>
+ [Obsolete("CreateReadOnly<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
+ public static BindablePropertyKey CreateReadOnly<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>> getter, TPropertyType defaultValue,
+ BindingMode defaultBindingMode = BindingMode.OneWayToSource, ValidateValueDelegate<TPropertyType> validateValue = null,
+ BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null, BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null,
+ CoerceValueDelegate<TPropertyType> coerceValue = null, CreateDefaultValueDelegate<TDeclarer, TPropertyType> defaultValueCreator = null) where TDeclarer : BindableObject
+ {
+ return new BindablePropertyKey(Create(getter, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, true, defaultValueCreator));
+ }
+
+ /// <summary>
+ /// Creates a new instance of the BindablePropertyKey class.
+ /// </summary>
+ /// <param name="propertyName">The name of the BindableProperty.</param>
+ /// <param name="returnType">The type of the property.</param>
+ /// <param name="declaringType">The type of the declaring object.</param>
+ /// <param name="defaultValue">The default value for the property.</param>
+ /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
+ /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
+ /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
+ /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
+ /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
+ /// <returns>A newly created BindablePropertyKey.</returns>
+ public static BindablePropertyKey CreateReadOnly(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode = BindingMode.OneWayToSource,
+ ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
+ CoerceValueDelegate coerceValue = null, CreateDefaultValueDelegate defaultValueCreator = null)
+ {
+ return
+ new BindablePropertyKey(new BindableProperty(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue,
+ isReadOnly: true, defaultValueCreator: defaultValueCreator));
+ }
+
+ [Obsolete("Create<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
+ internal static BindableProperty Create<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>> getter, TPropertyType defaultValue, BindingMode defaultBindingMode,
+ ValidateValueDelegate<TPropertyType> validateValue, BindingPropertyChangedDelegate<TPropertyType> propertyChanged, BindingPropertyChangingDelegate<TPropertyType> propertyChanging,
+ CoerceValueDelegate<TPropertyType> coerceValue, BindablePropertyBindingChanging bindingChanging, bool isReadOnly = false,
+ CreateDefaultValueDelegate<TDeclarer, TPropertyType> defaultValueCreator = null) where TDeclarer : BindableObject
+ {
+ if (getter == null)
+ throw new ArgumentNullException("getter");
+
+ Expression expr = getter.Body;
+
+ var unary = expr as UnaryExpression;
+ if (unary != null)
+ expr = unary.Operand;
+
+ var member = expr as MemberExpression;
+ if (member == null)
+ throw new ArgumentException("getter must be a MemberExpression", "getter");
+
+ var property = (PropertyInfo)member.Member;
+
+ ValidateValueDelegate untypedValidateValue = null;
+ BindingPropertyChangedDelegate untypedBindingPropertyChanged = null;
+ BindingPropertyChangingDelegate untypedBindingPropertyChanging = null;
+ CoerceValueDelegate untypedCoerceValue = null;
+ CreateDefaultValueDelegate untypedDefaultValueCreator = null;
+ if (validateValue != null)
+ untypedValidateValue = (bindable, value) => validateValue(bindable, (TPropertyType)value);
+ if (propertyChanged != null)
+ untypedBindingPropertyChanged = (bindable, oldValue, newValue) => propertyChanged(bindable, (TPropertyType)oldValue, (TPropertyType)newValue);
+ if (propertyChanging != null)
+ untypedBindingPropertyChanging = (bindable, oldValue, newValue) => propertyChanging(bindable, (TPropertyType)oldValue, (TPropertyType)newValue);
+ if (coerceValue != null)
+ untypedCoerceValue = (bindable, value) => coerceValue(bindable, (TPropertyType)value);
+ if (defaultValueCreator != null)
+ untypedDefaultValueCreator = o => defaultValueCreator((TDeclarer)o);
+
+ return new BindableProperty(property.Name, property.PropertyType, typeof(TDeclarer), defaultValue, defaultBindingMode, untypedValidateValue, untypedBindingPropertyChanged,
+ untypedBindingPropertyChanging, untypedCoerceValue, bindingChanging, isReadOnly, untypedDefaultValueCreator);
+ }
+
+ internal static BindableProperty Create(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode, ValidateValueDelegate validateValue,
+ BindingPropertyChangedDelegate propertyChanged, BindingPropertyChangingDelegate propertyChanging, CoerceValueDelegate coerceValue, BindablePropertyBindingChanging bindingChanging,
+ CreateDefaultValueDelegate defaultValueCreator = null)
+ {
+ return new BindableProperty(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, bindingChanging,
+ defaultValueCreator: defaultValueCreator);
+ }
+
+ [Obsolete("CreateAttached<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
+ internal static BindableProperty CreateAttached<TDeclarer, TPropertyType>(Expression<Func<BindableObject, TPropertyType>> staticgetter, TPropertyType defaultValue, BindingMode defaultBindingMode,
+ ValidateValueDelegate<TPropertyType> validateValue, BindingPropertyChangedDelegate<TPropertyType> propertyChanged, BindingPropertyChangingDelegate<TPropertyType> propertyChanging,
+ CoerceValueDelegate<TPropertyType> coerceValue, BindablePropertyBindingChanging bindingChanging, bool isReadOnly = false,
+ CreateDefaultValueDelegate<BindableObject, TPropertyType> defaultValueCreator = null)
+ {
+ if (staticgetter == null)
+ throw new ArgumentNullException("staticgetter");
+
+ Expression expr = staticgetter.Body;
+
+ var unary = expr as UnaryExpression;
+ if (unary != null)
+ expr = unary.Operand;
+
+ var methodcall = expr as MethodCallExpression;
+ if (methodcall == null)
+ throw new ArgumentException("staticgetter must be a MethodCallExpression", "staticgetter");
+
+ MethodInfo method = methodcall.Method;
+ if (!method.Name.StartsWith("Get", StringComparison.Ordinal))
+ throw new ArgumentException("staticgetter name must start with Get", "staticgetter");
+
+ string propertyname = method.Name.Substring(3);
+
+ ValidateValueDelegate untypedValidateValue = null;
+ BindingPropertyChangedDelegate untypedBindingPropertyChanged = null;
+ BindingPropertyChangingDelegate untypedBindingPropertyChanging = null;
+ CoerceValueDelegate untypedCoerceValue = null;
+ CreateDefaultValueDelegate untypedDefaultValueCreator = null;
+ if (validateValue != null)
+ untypedValidateValue = (bindable, value) => validateValue(bindable, (TPropertyType)value);
+ if (propertyChanged != null)
+ untypedBindingPropertyChanged = (bindable, oldValue, newValue) => propertyChanged(bindable, (TPropertyType)oldValue, (TPropertyType)newValue);
+ if (propertyChanging != null)
+ untypedBindingPropertyChanging = (bindable, oldValue, newValue) => propertyChanging(bindable, (TPropertyType)oldValue, (TPropertyType)newValue);
+ if (coerceValue != null)
+ untypedCoerceValue = (bindable, value) => coerceValue(bindable, (TPropertyType)value);
+ if (defaultValueCreator != null)
+ untypedDefaultValueCreator = o => defaultValueCreator(o);
+
+ return new BindableProperty(propertyname, method.ReturnType, typeof(TDeclarer), defaultValue, defaultBindingMode, untypedValidateValue, untypedBindingPropertyChanged, untypedBindingPropertyChanging,
+ untypedCoerceValue, bindingChanging, isReadOnly, untypedDefaultValueCreator);
+ }
+
+ internal static BindableProperty CreateAttached(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode, ValidateValueDelegate validateValue,
+ BindingPropertyChangedDelegate propertyChanged, BindingPropertyChangingDelegate propertyChanging, CoerceValueDelegate coerceValue, BindablePropertyBindingChanging bindingChanging,
+ bool isReadOnly, CreateDefaultValueDelegate defaultValueCreator = null)
+ {
+ return new BindableProperty(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, bindingChanging, isReadOnly,
+ defaultValueCreator);
+ }
+
+ internal object GetDefaultValue(BindableObject bindable)
+ {
+ if (DefaultValueCreator != null)
+ return DefaultValueCreator(bindable);
+
+ return DefaultValue;
+ }
+
+ internal bool TryConvert(ref object value)
+ {
+ if (value == null)
+ {
+ return !ReturnTypeInfo.IsValueType || ReturnTypeInfo.IsGenericType && ReturnTypeInfo.GetGenericTypeDefinition() == typeof(Nullable<>);
+ }
+
+ Type valueType = value.GetType();
+ Type type = ReturnType;
+
+ // Dont support arbitrary IConvertible by limiting which types can use this
+ Type[] convertableTo;
+ TypeConverter typeConverterTo;
+ if (SimpleConvertTypes.TryGetValue(valueType, out convertableTo) && Array.IndexOf(convertableTo, type) != -1)
+ {
+ value = Convert.ChangeType(value, type);
+ }
+ else if (WellKnownConvertTypes.TryGetValue(type, out typeConverterTo) && typeConverterTo.CanConvertFrom(valueType))
+ {
+ value = typeConverterTo.ConvertFromInvariantString(value.ToString());
+ }
+ else if (!ReturnTypeInfo.IsAssignableFrom(valueType.GetTypeInfo()))
+ {
+ var cast = type.GetImplicitConversionOperator(fromType: valueType, toType: type)
+ ?? valueType.GetImplicitConversionOperator(fromType: valueType, toType: type);
+
+ if (cast == null)
+ return false;
+
+ value = cast.Invoke(null, new[] { value });
+ }
+
+ return true;
+ }
+
+ internal delegate void BindablePropertyBindingChanging(BindableObject bindable, BindingBase oldValue, BindingBase newValue);
+ }
+}
using System.Linq;
using System.Reflection;
using System.Xml;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI.Xaml;
namespace Tizen.NUI.Binding
{
- // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.BindablePropertyConverter")]
- [Xaml.TypeConversion(typeof(BindableProperty))]
- internal sealed class BindablePropertyConverter : TypeConverter, IExtendedTypeConverter
- {
- object IExtendedTypeConverter.ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider)
- {
- return ((IExtendedTypeConverter)this).ConvertFromInvariantString(value as string, serviceProvider);
- }
+ // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.BindablePropertyConverter")]
+ [Xaml.TypeConversion(typeof(BindableProperty))]
+ internal sealed class BindablePropertyConverter : TypeConverter, IExtendedTypeConverter
+ {
+ object IExtendedTypeConverter.ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider)
+ {
+ return ((IExtendedTypeConverter)this).ConvertFromInvariantString(value as string, serviceProvider);
+ }
- object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider)
- {
- if (string.IsNullOrWhiteSpace(value))
- return null;
- if (serviceProvider == null)
- return null;
- var parentValuesProvider = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideParentValues;
- var typeResolver = serviceProvider.GetService(typeof(IXamlTypeResolver)) as IXamlTypeResolver;
- if (typeResolver == null)
- return null;
- IXmlLineInfo lineinfo = null;
- var xmlLineInfoProvider = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- if (xmlLineInfoProvider != null)
- lineinfo = xmlLineInfoProvider.XmlLineInfo;
- string[] parts = value.Split('.');
- Type type = null;
- if (parts.Length == 1)
- {
- if (parentValuesProvider == null)
- {
- string msg = string.Format("Can't resolve {0}", parts[0]);
- throw new XamlParseException(msg, lineinfo);
- }
- object parent = parentValuesProvider.ParentObjects.Skip(1).FirstOrDefault();
- if (parentValuesProvider.TargetObject is Setter)
- {
- var style = parent as Style;
- var triggerBase = parent as TriggerBase;
- var visualState = parent as VisualState;
- if (style != null)
- type = style.TargetType;
- else if (triggerBase != null)
- type = triggerBase.TargetType;
- else if (visualState != null)
- type = FindTypeForVisualState(parentValuesProvider, lineinfo);
- }
- else if (parentValuesProvider.TargetObject is Trigger)
- type = (parentValuesProvider.TargetObject as Trigger).TargetType;
- else if (parentValuesProvider.TargetObject is PropertyCondition && (parent as TriggerBase) != null)
- type = (parent as TriggerBase).TargetType;
+ object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ return null;
+ if (serviceProvider == null)
+ return null;
+ var parentValuesProvider = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideParentValues;
+ var typeResolver = serviceProvider.GetService(typeof(IXamlTypeResolver)) as IXamlTypeResolver;
+ if (typeResolver == null)
+ return null;
+ IXmlLineInfo lineinfo = null;
+ var xmlLineInfoProvider = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ if (xmlLineInfoProvider != null)
+ lineinfo = xmlLineInfoProvider.XmlLineInfo;
+ string[] parts = value.Split('.');
+ Type type = null;
+ if (parts.Length == 1)
+ {
+ if (parentValuesProvider == null)
+ {
+ string msg = string.Format("Can't resolve {0}", parts[0]);
+ throw new XamlParseException(msg, lineinfo);
+ }
+ object parent = parentValuesProvider.ParentObjects.Skip(1).FirstOrDefault();
+ if (parentValuesProvider.TargetObject is Setter)
+ {
+ var style = parent as Style;
+ var triggerBase = parent as TriggerBase;
+ var visualState = parent as VisualState;
+ if (style != null)
+ type = style.TargetType;
+ else if (triggerBase != null)
+ type = triggerBase.TargetType;
+ else if (visualState != null)
+ type = FindTypeForVisualState(parentValuesProvider, lineinfo);
+ }
+ else if (parentValuesProvider.TargetObject is Trigger)
+ type = (parentValuesProvider.TargetObject as Trigger).TargetType;
+ else if (parentValuesProvider.TargetObject is XamlPropertyCondition && (parent as TriggerBase) != null)
+ type = (parent as TriggerBase).TargetType;
- if (type == null)
- throw new XamlParseException($"Can't resolve {parts [0]}", lineinfo);
+ if (type == null)
+ throw new XamlParseException($"Can't resolve {parts [0]}", lineinfo);
- return ConvertFrom(type, parts[0], lineinfo);
- }
- if (parts.Length == 2)
- {
- if (!typeResolver.TryResolve(parts[0], out type))
- {
- string msg = string.Format("Can't resolve {0}", parts[0]);
- throw new XamlParseException(msg, lineinfo);
- }
- return ConvertFrom(type, parts[1], lineinfo);
- }
- throw new XamlParseException($"Can't resolve {value}. Syntax is [[prefix:]Type.]PropertyName.", lineinfo);
- }
+ return ConvertFrom(type, parts[0], lineinfo);
+ }
+ if (parts.Length == 2)
+ {
+ if (!typeResolver.TryResolve(parts[0], out type))
+ {
+ string msg = string.Format("Can't resolve {0}", parts[0]);
+ throw new XamlParseException(msg, lineinfo);
+ }
+ return ConvertFrom(type, parts[1], lineinfo);
+ }
+ throw new XamlParseException($"Can't resolve {value}. Syntax is [[prefix:]Type.]PropertyName.", lineinfo);
+ }
- public override object ConvertFromInvariantString(string value)
- {
- if (string.IsNullOrWhiteSpace(value))
- return null;
- if (value.Contains(":"))
- {
- Console.WriteLine(null, "Can't resolve properties with xml namespace prefix.");
- return null;
- }
- string[] parts = value.Split('.');
- if (parts.Length != 2)
- {
- Console.WriteLine(null, $"Can't resolve {value}. Accepted syntax is Type.PropertyName.");
- return null;
- }
- Type type = Type.GetType("Tizen.NUI." + parts[0]);
- return ConvertFrom(type, parts[1], null);
- }
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ return null;
+ if (value.Contains(":"))
+ {
+ Console.WriteLine(null, "Can't resolve properties with xml namespace prefix.");
+ return null;
+ }
+ string[] parts = value.Split('.');
+ if (parts.Length != 2)
+ {
+ Console.WriteLine(null, $"Can't resolve {value}. Accepted syntax is Type.PropertyName.");
+ return null;
+ }
+ Type type = Type.GetType("Tizen.NUI." + parts[0]);
+ return ConvertFrom(type, parts[1], null);
+ }
- BindableProperty ConvertFrom(Type type, string propertyName, IXmlLineInfo lineinfo)
- {
- string name = propertyName + "Property";
- FieldInfo bpinfo = type.GetField(fi => fi.Name == name && fi.IsStatic && fi.IsPublic && fi.FieldType == typeof(BindableProperty));
- if (bpinfo == null)
- throw new XamlParseException($"Can't resolve {name} on {type.Name}", lineinfo);
- var bp = bpinfo.GetValue(null) as BindableProperty;
- var isObsolete = bpinfo.GetCustomAttribute<ObsoleteAttribute>() != null;
- if (bp.PropertyName != propertyName && !isObsolete)
- throw new XamlParseException($"The PropertyName of {type.Name}.{name} is not {propertyName}", lineinfo);
- return bp;
- }
+ BindableProperty ConvertFrom(Type type, string propertyName, IXmlLineInfo lineinfo)
+ {
+ string name = propertyName + "Property";
+ FieldInfo bpinfo = type.GetField(fi => fi.Name == name && fi.IsStatic && fi.IsPublic && fi.FieldType == typeof(BindableProperty));
+ if (bpinfo == null)
+ throw new XamlParseException($"Can't resolve {name} on {type.Name}", lineinfo);
+ var bp = bpinfo.GetValue(null) as BindableProperty;
+ var isObsolete = bpinfo.GetCustomAttribute<ObsoleteAttribute>() != null;
+ if (bp.PropertyName != propertyName && !isObsolete)
+ throw new XamlParseException($"The PropertyName of {type.Name}.{name} is not {propertyName}", lineinfo);
+ return bp;
+ }
- Type FindTypeForVisualState(IProvideParentValues parentValueProvider, IXmlLineInfo lineInfo)
- {
- var parents = parentValueProvider.ParentObjects.ToList();
+ Type FindTypeForVisualState(IProvideParentValues parentValueProvider, IXmlLineInfo lineInfo)
+ {
+ var parents = parentValueProvider.ParentObjects.ToList();
- // Skip 0; we would not be making this check if TargetObject were not a Setter
- // Skip 1; we would not be making this check if the immediate parent were not a VisualState
+ // Skip 0; we would not be making this check if TargetObject were not a Setter
+ // Skip 1; we would not be making this check if the immediate parent were not a VisualState
- // VisualStates must be in a VisualStateGroup
- if(!(parents[2] is VisualStateGroup)) {
- throw new XamlParseException($"Expected {nameof(VisualStateGroup)} but found {parents[2]}.", lineInfo);
- }
+ // VisualStates must be in a VisualStateGroup
+ if(!(parents[2] is VisualStateGroup)) {
+ throw new XamlParseException($"Expected {nameof(VisualStateGroup)} but found {parents[2]}.", lineInfo);
+ }
- var vsTarget = parents[3];
+ var vsTarget = parents[3];
- // Are these Visual States directly on a VisualElement?
- if (vsTarget is /*VisualElement*/BaseHandle)
- {
- return vsTarget.GetType();
- }
+ // Are these Visual States directly on a VisualElement?
+ if (vsTarget is /*VisualElement*/BaseHandle)
+ {
+ return vsTarget.GetType();
+ }
- if (!(parents[3] is VisualStateGroupList))
- {
- throw new XamlParseException($"Expected {nameof(VisualStateGroupList)} but found {parents[3]}.", lineInfo);
- }
+ if (!(parents[3] is VisualStateGroupList))
+ {
+ throw new XamlParseException($"Expected {nameof(VisualStateGroupList)} but found {parents[3]}.", lineInfo);
+ }
- if (!(parents[4] is Setter))
- {
- throw new XamlParseException($"Expected {nameof(Setter)} but found {parents[4]}.", lineInfo);
- }
+ if (!(parents[4] is Setter))
+ {
+ throw new XamlParseException($"Expected {nameof(Setter)} but found {parents[4]}.", lineInfo);
+ }
- // These must be part of a Style; verify that
- if (!(parents[5] is Style style))
- {
- throw new XamlParseException($"Expected {nameof(Style)} but found {parents[5]}.", lineInfo);
- }
+ // These must be part of a Style; verify that
+ if (!(parents[5] is Style style))
+ {
+ throw new XamlParseException($"Expected {nameof(Style)} but found {parents[5]}.", lineInfo);
+ }
- return style.TargetType;
- }
- }
+ return style.TargetType;
+ }
+ }
}
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class BindablePropertyKey
- {
- internal BindablePropertyKey(BindableProperty property)
- {
- if (property == null)
- throw new ArgumentNullException("property");
+ {
+ internal BindablePropertyKey(BindableProperty property)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
- BindableProperty = property;
- }
+ BindableProperty = property;
+ }
/// <summary>
/// Gets the BindableProperty.
/// </summary>
- public BindableProperty BindableProperty { get; private set; }
- }
+ public BindableProperty BindableProperty { get; private set; }
+ }
}
\ No newline at end of file
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- internal sealed class Binding : BindingBase
- {
- internal const string SelfPath = ".";
- IValueConverter _converter;
- object _converterParameter;
-
- BindingExpression _expression;
- string _path;
- object _source;
- string _updateSourceEventName;
-
- public Binding()
- {
- }
-
- public Binding(string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null, object converterParameter = null, string stringFormat = null, object source = null)
- {
- if (path == null)
- throw new ArgumentNullException("path");
- if (string.IsNullOrWhiteSpace(path))
- throw new ArgumentException("path can not be an empty string", "path");
-
- Path = path;
- Converter = converter;
- ConverterParameter = converterParameter;
- Mode = mode;
- StringFormat = stringFormat;
- Source = source;
- }
-
- public IValueConverter Converter
- {
- get { return _converter; }
- set
- {
- ThrowIfApplied();
-
- _converter = value;
- }
- }
-
- public object ConverterParameter
- {
- get { return _converterParameter; }
- set
- {
- ThrowIfApplied();
-
- _converterParameter = value;
- }
- }
-
- public string Path
- {
- get { return _path; }
- set
- {
- ThrowIfApplied();
-
- _path = value;
- _expression = new BindingExpression(this, !string.IsNullOrWhiteSpace(value) ? value : SelfPath);
- }
- }
-
- public object Source
- {
- get { return _source; }
- set
- {
- ThrowIfApplied();
- _source = value;
- }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string UpdateSourceEventName {
- get { return _updateSourceEventName; }
- set {
- ThrowIfApplied();
- _updateSourceEventName = value;
- }
- }
-
- [Obsolete]
- public static Binding Create<TSource>(Expression<Func<TSource, object>> propertyGetter, BindingMode mode = BindingMode.Default, IValueConverter converter = null, object converterParameter = null,
- string stringFormat = null)
- {
- if (propertyGetter == null)
- throw new ArgumentNullException("propertyGetter");
-
- string path = GetBindingPath(propertyGetter);
- return new Binding(path, mode, converter, converterParameter, stringFormat);
- }
-
- internal override void Apply(bool fromTarget)
- {
- base.Apply(fromTarget);
-
- if (_expression == null)
- _expression = new BindingExpression(this, SelfPath);
-
- _expression.Apply(fromTarget);
- }
-
- internal override void Apply(object newContext, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged = false)
- {
- object src = _source;
- var isApplied = IsApplied;
-
- base.Apply(src ?? newContext, bindObj, targetProperty, fromBindingContextChanged: fromBindingContextChanged);
-
- if (src != null && isApplied && fromBindingContextChanged)
- return;
-
- object bindingContext = src ?? Context ?? newContext;
- if (_expression == null && bindingContext != null)
- _expression = new BindingExpression(this, SelfPath);
-
- _expression?.Apply(bindingContext, bindObj, targetProperty);
- }
-
- internal override BindingBase Clone()
- {
- return new Binding(Path, Mode) { Converter = Converter, ConverterParameter = ConverterParameter, StringFormat = StringFormat, Source = Source, UpdateSourceEventName = UpdateSourceEventName };
- }
-
- internal override object GetSourceValue(object value, Type targetPropertyType)
- {
- if (Converter != null)
- value = Converter.Convert(value, targetPropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
-
- return base.GetSourceValue(value, targetPropertyType);
- }
-
- internal override object GetTargetValue(object value, Type sourcePropertyType)
- {
- if (Converter != null)
- value = Converter.ConvertBack(value, sourcePropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
-
- return base.GetTargetValue(value, sourcePropertyType);
- }
-
- internal override void Unapply(bool fromBindingContextChanged = false)
- {
- if (Source != null && fromBindingContextChanged && IsApplied)
- return;
-
- base.Unapply(fromBindingContextChanged: fromBindingContextChanged);
-
- if (_expression != null)
- _expression.Unapply();
- }
-
- [Obsolete]
- static string GetBindingPath<TSource>(Expression<Func<TSource, object>> propertyGetter)
- {
- Expression expr = propertyGetter.Body;
-
- var unary = expr as UnaryExpression;
- if (unary != null)
- expr = unary.Operand;
-
- var builder = new StringBuilder();
-
- var indexed = false;
-
- var member = expr as MemberExpression;
- if (member == null)
- {
- var methodCall = expr as MethodCallExpression;
- if (methodCall != null)
- {
- if (methodCall.Arguments.Count == 0)
- throw new ArgumentException("Method calls are not allowed in binding expression");
-
- var arguments = new List<string>(methodCall.Arguments.Count);
- foreach (Expression arg in methodCall.Arguments)
- {
- if (arg.NodeType != ExpressionType.Constant)
- throw new ArgumentException("Only constants can be used as indexer arguments");
-
- object value = ((ConstantExpression)arg).Value;
- arguments.Add(value != null ? value.ToString() : "null");
- }
-
- Type declarerType = methodCall.Method.DeclaringType;
- DefaultMemberAttribute defaultMember = declarerType.GetTypeInfo().GetCustomAttributes(typeof(DefaultMemberAttribute), true).OfType<DefaultMemberAttribute>().FirstOrDefault();
- string indexerName = defaultMember != null ? defaultMember.MemberName : "Item";
-
- MethodInfo getterInfo =
- declarerType.GetProperties().Where(pi => pi.Name == indexerName && pi.CanRead && pi.GetMethod.IsPublic && !pi.GetMethod.IsStatic).Select(pi => pi.GetMethod).FirstOrDefault();
- if (getterInfo != null)
- {
- if (getterInfo == methodCall.Method)
- {
- indexed = true;
- builder.Append("[");
-
- var first = true;
- foreach (string argument in arguments)
- {
- if (!first)
- builder.Append(",");
-
- builder.Append(argument);
- first = false;
- }
-
- builder.Append("]");
-
- member = methodCall.Object as MemberExpression;
- }
- else
- throw new ArgumentException("Method calls are not allowed in binding expressions");
- }
- else
- throw new ArgumentException("Public indexer not found");
- }
- else
- throw new ArgumentException("Invalid expression type");
- }
-
- while (member != null)
- {
- var property = (PropertyInfo)member.Member;
- if (builder.Length != 0)
- {
- if (!indexed)
- builder.Insert(0, ".");
- else
- indexed = false;
- }
-
- builder.Insert(0, property.Name);
-
- // member = member.Expression as MemberExpression ?? (member.Expression as UnaryExpression)?.Operand as MemberExpression;
- member = member.Expression as MemberExpression ?? (member.Expression is UnaryExpression ? (member.Expression as UnaryExpression).Operand as MemberExpression : null);
- }
-
- return builder.ToString();
- }
- }
+ internal sealed class Binding : BindingBase
+ {
+ internal const string SelfPath = ".";
+ IValueConverter _converter;
+ object _converterParameter;
+
+ BindingExpression _expression;
+ string _path;
+ object _source;
+ string _updateSourceEventName;
+
+ public Binding()
+ {
+ }
+
+ public Binding(string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null, object converterParameter = null, string stringFormat = null, object source = null)
+ {
+ if (path == null)
+ throw new ArgumentNullException("path");
+ if (string.IsNullOrWhiteSpace(path))
+ throw new ArgumentException("path can not be an empty string", "path");
+
+ Path = path;
+ Converter = converter;
+ ConverterParameter = converterParameter;
+ Mode = mode;
+ StringFormat = stringFormat;
+ Source = source;
+ }
+
+ public IValueConverter Converter
+ {
+ get { return _converter; }
+ set
+ {
+ ThrowIfApplied();
+
+ _converter = value;
+ }
+ }
+
+ public object ConverterParameter
+ {
+ get { return _converterParameter; }
+ set
+ {
+ ThrowIfApplied();
+
+ _converterParameter = value;
+ }
+ }
+
+ public string Path
+ {
+ get { return _path; }
+ set
+ {
+ ThrowIfApplied();
+
+ _path = value;
+ _expression = new BindingExpression(this, !string.IsNullOrWhiteSpace(value) ? value : SelfPath);
+ }
+ }
+
+ public object Source
+ {
+ get { return _source; }
+ set
+ {
+ ThrowIfApplied();
+ _source = value;
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string UpdateSourceEventName {
+ get { return _updateSourceEventName; }
+ set {
+ ThrowIfApplied();
+ _updateSourceEventName = value;
+ }
+ }
+
+ [Obsolete]
+ public static Binding Create<TSource>(Expression<Func<TSource, object>> propertyGetter, BindingMode mode = BindingMode.Default, IValueConverter converter = null, object converterParameter = null,
+ string stringFormat = null)
+ {
+ if (propertyGetter == null)
+ throw new ArgumentNullException("propertyGetter");
+
+ string path = GetBindingPath(propertyGetter);
+ return new Binding(path, mode, converter, converterParameter, stringFormat);
+ }
+
+ internal override void Apply(bool fromTarget)
+ {
+ base.Apply(fromTarget);
+
+ if (_expression == null)
+ _expression = new BindingExpression(this, SelfPath);
+
+ _expression.Apply(fromTarget);
+ }
+
+ internal override void Apply(object newContext, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged = false)
+ {
+ object src = _source;
+ var isApplied = IsApplied;
+
+ base.Apply(src ?? newContext, bindObj, targetProperty, fromBindingContextChanged: fromBindingContextChanged);
+
+ if (src != null && isApplied && fromBindingContextChanged)
+ return;
+
+ object bindingContext = src ?? Context ?? newContext;
+ if (_expression == null && bindingContext != null)
+ _expression = new BindingExpression(this, SelfPath);
+
+ _expression?.Apply(bindingContext, bindObj, targetProperty);
+ }
+
+ internal override BindingBase Clone()
+ {
+ return new Binding(Path, Mode) { Converter = Converter, ConverterParameter = ConverterParameter, StringFormat = StringFormat, Source = Source, UpdateSourceEventName = UpdateSourceEventName };
+ }
+
+ internal override object GetSourceValue(object value, Type targetPropertyType)
+ {
+ if (Converter != null)
+ value = Converter.Convert(value, targetPropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
+
+ return base.GetSourceValue(value, targetPropertyType);
+ }
+
+ internal override object GetTargetValue(object value, Type sourcePropertyType)
+ {
+ if (Converter != null)
+ value = Converter.ConvertBack(value, sourcePropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
+
+ return base.GetTargetValue(value, sourcePropertyType);
+ }
+
+ internal override void Unapply(bool fromBindingContextChanged = false)
+ {
+ if (Source != null && fromBindingContextChanged && IsApplied)
+ return;
+
+ base.Unapply(fromBindingContextChanged: fromBindingContextChanged);
+
+ if (_expression != null)
+ _expression.Unapply();
+ }
+
+ [Obsolete]
+ static string GetBindingPath<TSource>(Expression<Func<TSource, object>> propertyGetter)
+ {
+ Expression expr = propertyGetter.Body;
+
+ var unary = expr as UnaryExpression;
+ if (unary != null)
+ expr = unary.Operand;
+
+ var builder = new StringBuilder();
+
+ var indexed = false;
+
+ var member = expr as MemberExpression;
+ if (member == null)
+ {
+ var methodCall = expr as MethodCallExpression;
+ if (methodCall != null)
+ {
+ if (methodCall.Arguments.Count == 0)
+ throw new ArgumentException("Method calls are not allowed in binding expression");
+
+ var arguments = new List<string>(methodCall.Arguments.Count);
+ foreach (Expression arg in methodCall.Arguments)
+ {
+ if (arg.NodeType != ExpressionType.Constant)
+ throw new ArgumentException("Only constants can be used as indexer arguments");
+
+ object value = ((ConstantExpression)arg).Value;
+ arguments.Add(value != null ? value.ToString() : "null");
+ }
+
+ Type declarerType = methodCall.Method.DeclaringType;
+ DefaultMemberAttribute defaultMember = declarerType.GetTypeInfo().GetCustomAttributes(typeof(DefaultMemberAttribute), true).OfType<DefaultMemberAttribute>().FirstOrDefault();
+ string indexerName = defaultMember != null ? defaultMember.MemberName : "Item";
+
+ MethodInfo getterInfo =
+ declarerType.GetProperties().Where(pi => pi.Name == indexerName && pi.CanRead && pi.GetMethod.IsPublic && !pi.GetMethod.IsStatic).Select(pi => pi.GetMethod).FirstOrDefault();
+ if (getterInfo != null)
+ {
+ if (getterInfo == methodCall.Method)
+ {
+ indexed = true;
+ builder.Append("[");
+
+ var first = true;
+ foreach (string argument in arguments)
+ {
+ if (!first)
+ builder.Append(",");
+
+ builder.Append(argument);
+ first = false;
+ }
+
+ builder.Append("]");
+
+ member = methodCall.Object as MemberExpression;
+ }
+ else
+ throw new ArgumentException("Method calls are not allowed in binding expressions");
+ }
+ else
+ throw new ArgumentException("Public indexer not found");
+ }
+ else
+ throw new ArgumentException("Invalid expression type");
+ }
+
+ while (member != null)
+ {
+ var property = (PropertyInfo)member.Member;
+ if (builder.Length != 0)
+ {
+ if (!indexed)
+ builder.Insert(0, ".");
+ else
+ indexed = false;
+ }
+
+ builder.Insert(0, property.Name);
+
+ // member = member.Expression as MemberExpression ?? (member.Expression as UnaryExpression)?.Operand as MemberExpression;
+ member = member.Expression as MemberExpression ?? (member.Expression is UnaryExpression ? (member.Expression as UnaryExpression).Operand as MemberExpression : null);
+ }
+
+ return builder.ToString();
+ }
+ }
}
--- /dev/null
+using System;
+using System.Collections;
+using System.Runtime.CompilerServices;
+using System.ComponentModel;
+
+namespace Tizen.NUI.Binding
+{
+ /// <summary>
+ /// An abstract class that provides a BindingMode and a formatting option.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal abstract class BindingBase
+ {
+ static readonly ConditionalWeakTable<IEnumerable, CollectionSynchronizationContext> SynchronizedCollections = new ConditionalWeakTable<IEnumerable, CollectionSynchronizationContext>();
+
+ BindingMode _mode = BindingMode.Default;
+ string _stringFormat;
+
+ internal BindingBase()
+ {
+ }
+
+ /// <summary>
+ /// Gets or sets the mode for this binding.
+ /// </summary>
+ public BindingMode Mode
+ {
+ get { return _mode; }
+ set
+ {
+ if ( value != BindingMode.Default
+ && value != BindingMode.OneWay
+ && value != BindingMode.OneWayToSource
+ && value != BindingMode.TwoWay
+ && value != BindingMode.OneTime)
+ throw new ArgumentException("mode is not a valid BindingMode", "mode");
+
+ ThrowIfApplied();
+
+ _mode = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the string format for this binding.
+ /// </summary>
+ public string StringFormat
+ {
+ get { return _stringFormat; }
+ set
+ {
+ ThrowIfApplied();
+
+ _stringFormat = value;
+ }
+ }
+
+ internal bool AllowChaining { get; set; }
+
+ internal object Context { get; set; }
+
+ internal bool IsApplied { get; private set; }
+
+ /// <summary>
+ /// Stops synchronization on the collection.
+ /// </summary>
+ /// <param name="collection">The collection on which to stop synchronization.</param>
+ public static void DisableCollectionSynchronization(IEnumerable collection)
+ {
+ if (collection == null)
+ throw new ArgumentNullException(nameof(collection));
+
+ SynchronizedCollections.Remove(collection);
+ }
+
+ internal static void EnableCollectionSynchronization(IEnumerable collection, object context, CollectionSynchronizationCallback callback)
+ {
+ if (collection == null)
+ throw new ArgumentNullException(nameof(collection));
+ if (callback == null)
+ throw new ArgumentNullException(nameof(callback));
+
+ SynchronizedCollections.Add(collection, new CollectionSynchronizationContext(context, callback));
+ }
+
+ /// <summary>
+ /// Throws an InvalidOperationException if the binding has been applied.
+ /// </summary>
+ protected void ThrowIfApplied()
+ {
+ if (IsApplied)
+ throw new InvalidOperationException("Can not change a binding while it's applied");
+ }
+
+ internal virtual void Apply(bool fromTarget)
+ {
+ IsApplied = true;
+ }
+
+ internal virtual void Apply(object context, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged = false)
+ {
+ IsApplied = true;
+ }
+
+ internal abstract BindingBase Clone();
+
+ internal virtual object GetSourceValue(object value, Type targetPropertyType)
+ {
+ if (StringFormat != null)
+ return string.Format(StringFormat, value);
+
+ return value;
+ }
+
+ internal virtual object GetTargetValue(object value, Type sourcePropertyType)
+ {
+ return value;
+ }
+
+ internal static bool TryGetSynchronizedCollection(IEnumerable collection, out CollectionSynchronizationContext synchronizationContext)
+ {
+ if (collection == null)
+ throw new ArgumentNullException(nameof(collection));
+
+ return SynchronizedCollections.TryGetValue(collection, out synchronizationContext);
+ }
+
+ internal virtual void Unapply(bool fromBindingContextChanged = false)
+ {
+ IsApplied = false;
+ }
+ }
+}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- static class BindingBaseExtensions
- {
- public static BindingMode GetRealizedMode(this BindingBase self, BindableProperty property)
- {
- return self.Mode != BindingMode.Default ? self.Mode : property.DefaultBindingMode;
- }
- }
+ internal static class BindingBaseExtensions
+ {
+ public static BindingMode GetRealizedMode(this BindingBase self, BindableProperty property)
+ {
+ return self.Mode != BindingMode.Default ? self.Mode : property.DefaultBindingMode;
+ }
+ }
}
\ No newline at end of file
using System.Globalization;
using System.Linq;
using System.Reflection;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using System.Runtime.CompilerServices;
namespace Tizen.NUI.Binding
{
- internal class BindingExpression
- {
- internal const string PropertyNotFoundErrorMessage = "'{0}' property not found on '{1}', target property: '{2}.{3}'";
-
- readonly List<BindingExpressionPart> _parts = new List<BindingExpressionPart>();
-
- BindableProperty _targetProperty;
- WeakReference<object> _weakSource;
- WeakReference<BindableObject> _weakTarget;
-
- internal BindingExpression(BindingBase binding, string path)
- {
- if (binding == null)
- throw new ArgumentNullException(nameof(binding));
- if (path == null)
- throw new ArgumentNullException(nameof(path));
-
- Binding = binding;
- Path = path;
-
- ParsePath();
- }
-
- internal BindingBase Binding { get; }
-
- internal string Path { get; }
-
- /// <summary>
- /// Applies the binding expression to a previously set source and target.
- /// </summary>
- internal void Apply(bool fromTarget = false)
- {
- if (_weakSource == null || _weakTarget == null)
- return;
-
- BindableObject target;
- if (!_weakTarget.TryGetTarget(out target))
- {
- Unapply();
- return;
- }
-
- object source;
- if (_weakSource.TryGetTarget(out source) && _targetProperty != null)
- ApplyCore(source, target, _targetProperty, fromTarget);
- }
-
- /// <summary>
- /// Applies the binding expression to a new source or target.
- /// </summary>
- internal void Apply(object sourceObject, BindableObject target, BindableProperty property)
- {
- _targetProperty = property;
-
- BindableObject prevTarget;
- if (_weakTarget != null && _weakTarget.TryGetTarget(out prevTarget) && !ReferenceEquals(prevTarget, target))
- throw new InvalidOperationException("Binding instances can not be reused");
-
- object previousSource;
- if (_weakSource != null && _weakSource.TryGetTarget(out previousSource) && !ReferenceEquals(previousSource, sourceObject))
- throw new InvalidOperationException("Binding instances can not be reused");
-
- _weakSource = new WeakReference<object>(sourceObject);
- _weakTarget = new WeakReference<BindableObject>(target);
-
- ApplyCore(sourceObject, target, property);
- }
-
- internal void Unapply()
- {
- object sourceObject;
- if (_weakSource != null && _weakSource.TryGetTarget(out sourceObject))
- {
- for (var i = 0; i < _parts.Count - 1; i++)
- {
- BindingExpressionPart part = _parts[i];
-
- if (!part.IsSelf)
- {
- part.TryGetValue(sourceObject, out sourceObject);
- }
-
- part.Unsubscribe();
- }
- }
-
- _weakSource = null;
- _weakTarget = null;
- }
-
- /// <summary>
- /// Applies the binding expression to a previously set source or target.
- /// </summary>
- void ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget = false)
- {
- BindingMode mode = Binding.GetRealizedMode(_targetProperty);
- if ((mode == BindingMode.OneWay || mode == BindingMode.OneTime) && fromTarget)
- return;
-
- bool needsGetter = (mode == BindingMode.TwoWay && !fromTarget) || mode == BindingMode.OneWay || mode == BindingMode.OneTime;
- bool needsSetter = !needsGetter && ((mode == BindingMode.TwoWay && fromTarget) || mode == BindingMode.OneWayToSource);
-
- object current = sourceObject;
- object previous = null;
- BindingExpressionPart part = null;
-
- for (var i = 0; i < _parts.Count; i++)
- {
- part = _parts[i];
- bool isLast = i + 1 == _parts.Count;
-
- if (!part.IsSelf && current != null)
- {
- // Allow the object instance itself to provide its own TypeInfo
- var reflectable = current as IReflectableType;
- System.Reflection.TypeInfo currentType = reflectable != null ? reflectable.GetTypeInfo() : current.GetType().GetTypeInfo();
- if (part.LastGetter == null || !part.LastGetter.DeclaringType.GetTypeInfo().IsAssignableFrom(currentType))
- SetupPart(currentType, part);
-
- if (!isLast)
- part.TryGetValue(current, out current);
- }
-
- if (!part.IsSelf && current != null)
- {
- if ((needsGetter && part.LastGetter == null) || (needsSetter && part.NextPart == null && part.LastSetter == null))
- {
- Console.WriteLine("Binding", PropertyNotFoundErrorMessage, part.Content, current, target.GetType(), property.PropertyName);
- break;
- }
- }
-
- if (mode == BindingMode.OneWay || mode == BindingMode.TwoWay)
- {
- var inpc = current as INotifyPropertyChanged;
- if (inpc != null && !ReferenceEquals(current, previous))
- part.Subscribe(inpc);
- }
-
- previous = current;
- }
-
- Debug.Assert(part != null, "There should always be at least the self part in the expression.");
-
- if (needsGetter)
- {
- object value = property.DefaultValue;
- if (part.TryGetValue(current, out value) || part.IsSelf)
- {
- value = Binding.GetSourceValue(value, property.ReturnType);
- }
- else
- value = property.DefaultValue;
-
- if (!TryConvert(part, ref value, property.ReturnType, true))
- {
- Console.WriteLine("Binding", "{0} can not be converted to type '{1}'", value, property.ReturnType);
- return;
- }
-
- target.SetValueCore(property, value, SetValueFlags.ClearDynamicResource, BindableObject.SetValuePrivateFlags.Default | BindableObject.SetValuePrivateFlags.Converted);
- }
- else if (needsSetter && part.LastSetter != null && current != null)
- {
- object value = Binding.GetTargetValue(target.GetValue(property), part.SetterType);
-
- if (!TryConvert(part, ref value, part.SetterType, false))
- {
- Console.WriteLine("Binding", "{0} can not be converted to type '{1}'", value, part.SetterType);
- return;
- }
-
- object[] args;
- if (part.IsIndexer)
- {
- args = new object[part.Arguments.Length + 1];
- part.Arguments.CopyTo(args, 0);
- args[args.Length - 1] = value;
- }
- else if (part.IsBindablePropertySetter)
- {
- args = new[] { part.BindablePropertyField, value };
- }
- else
- {
- args = new[] { value };
- }
-
- part.LastSetter.Invoke(current, args);
- }
- }
-
- IEnumerable<BindingExpressionPart> GetPart(string part)
- {
- part = part.Trim();
- if (part == string.Empty)
- throw new FormatException("Path contains an empty part");
-
- BindingExpressionPart indexer = null;
-
- int lbIndex = part.IndexOf('[');
- if (lbIndex != -1)
- {
- int rbIndex = part.LastIndexOf(']');
- if (rbIndex == -1)
- throw new FormatException("Indexer did not contain closing bracket");
-
- int argLength = rbIndex - lbIndex - 1;
- if (argLength == 0)
- throw new FormatException("Indexer did not contain arguments");
-
- string argString = part.Substring(lbIndex + 1, argLength);
- indexer = new BindingExpressionPart(this, argString, true);
-
- part = part.Substring(0, lbIndex);
- part = part.Trim();
- }
-
- if (part.Length > 0)
- yield return new BindingExpressionPart(this, part);
- if (indexer != null)
- yield return indexer;
- }
-
- void ParsePath()
- {
- string p = Path.Trim();
-
- var last = new BindingExpressionPart(this, ".");
- _parts.Add(last);
-
- if (p[0] == '.')
- {
- if (p.Length == 1)
- return;
-
- p = p.Substring(1);
- }
-
- string[] pathParts = p.Split('.');
- for (var i = 0; i < pathParts.Length; i++)
- {
- foreach (BindingExpressionPart part in GetPart(pathParts[i]))
- {
- last.NextPart = part;
- _parts.Add(part);
- last = part;
- }
- }
- }
-
- void SetupPart(System.Reflection.TypeInfo sourceType, BindingExpressionPart part)
- {
- part.Arguments = null;
- part.LastGetter = null;
- part.LastSetter = null;
-
- PropertyInfo property = null;
- if (part.IsIndexer)
- {
- if (sourceType.IsArray)
- {
- int index;
- if (!int.TryParse(part.Content, out index))
- Console.WriteLine("Binding", "{0} could not be parsed as an index for a {1}", part.Content, sourceType);
- else
- part.Arguments = new object[] { index };
-
- part.LastGetter = sourceType.GetDeclaredMethod("Get");
- part.LastSetter = sourceType.GetDeclaredMethod("Set");
- part.SetterType = sourceType.GetElementType();
- }
-
- DefaultMemberAttribute defaultMember = sourceType.GetCustomAttributes(typeof(DefaultMemberAttribute), true).OfType<DefaultMemberAttribute>().FirstOrDefault();
- string indexerName = defaultMember != null ? defaultMember.MemberName : "Item";
-
- part.IndexerName = indexerName;
+ internal class BindingExpression
+ {
+ internal const string PropertyNotFoundErrorMessage = "'{0}' property not found on '{1}', target property: '{2}.{3}'";
+
+ readonly List<BindingExpressionPart> _parts = new List<BindingExpressionPart>();
+
+ BindableProperty _targetProperty;
+ WeakReference<object> _weakSource;
+ WeakReference<BindableObject> _weakTarget;
+
+ internal BindingExpression(BindingBase binding, string path)
+ {
+ if (binding == null)
+ throw new ArgumentNullException(nameof(binding));
+ if (path == null)
+ throw new ArgumentNullException(nameof(path));
+
+ Binding = binding;
+ Path = path;
+
+ ParsePath();
+ }
+
+ internal BindingBase Binding { get; }
+
+ internal string Path { get; }
+
+ /// <summary>
+ /// Applies the binding expression to a previously set source and target.
+ /// </summary>
+ internal void Apply(bool fromTarget = false)
+ {
+ if (_weakSource == null || _weakTarget == null)
+ return;
+
+ BindableObject target;
+ if (!_weakTarget.TryGetTarget(out target))
+ {
+ Unapply();
+ return;
+ }
+
+ object source;
+ if (_weakSource.TryGetTarget(out source) && _targetProperty != null)
+ ApplyCore(source, target, _targetProperty, fromTarget);
+ }
+
+ /// <summary>
+ /// Applies the binding expression to a new source or target.
+ /// </summary>
+ internal void Apply(object sourceObject, BindableObject target, BindableProperty property)
+ {
+ _targetProperty = property;
+
+ BindableObject prevTarget;
+ if (_weakTarget != null && _weakTarget.TryGetTarget(out prevTarget) && !ReferenceEquals(prevTarget, target))
+ throw new InvalidOperationException("Binding instances can not be reused");
+
+ object previousSource;
+ if (_weakSource != null && _weakSource.TryGetTarget(out previousSource) && !ReferenceEquals(previousSource, sourceObject))
+ throw new InvalidOperationException("Binding instances can not be reused");
+
+ _weakSource = new WeakReference<object>(sourceObject);
+ _weakTarget = new WeakReference<BindableObject>(target);
+
+ ApplyCore(sourceObject, target, property);
+ }
+
+ internal void Unapply()
+ {
+ object sourceObject;
+ if (_weakSource != null && _weakSource.TryGetTarget(out sourceObject))
+ {
+ for (var i = 0; i < _parts.Count - 1; i++)
+ {
+ BindingExpressionPart part = _parts[i];
+
+ if (!part.IsSelf)
+ {
+ part.TryGetValue(sourceObject, out sourceObject);
+ }
+
+ part.Unsubscribe();
+ }
+ }
+
+ _weakSource = null;
+ _weakTarget = null;
+ }
+
+ /// <summary>
+ /// Applies the binding expression to a previously set source or target.
+ /// </summary>
+ void ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget = false)
+ {
+ BindingMode mode = Binding.GetRealizedMode(_targetProperty);
+ if ((mode == BindingMode.OneWay || mode == BindingMode.OneTime) && fromTarget)
+ return;
+
+ bool needsGetter = (mode == BindingMode.TwoWay && !fromTarget) || mode == BindingMode.OneWay || mode == BindingMode.OneTime;
+ bool needsSetter = !needsGetter && ((mode == BindingMode.TwoWay && fromTarget) || mode == BindingMode.OneWayToSource);
+
+ object current = sourceObject;
+ object previous = null;
+ BindingExpressionPart part = null;
+
+ for (var i = 0; i < _parts.Count; i++)
+ {
+ part = _parts[i];
+ bool isLast = i + 1 == _parts.Count;
+
+ if (!part.IsSelf && current != null)
+ {
+ // Allow the object instance itself to provide its own TypeInfo
+ var reflectable = current as IReflectableType;
+ System.Reflection.TypeInfo currentType = reflectable != null ? reflectable.GetTypeInfo() : current.GetType().GetTypeInfo();
+ if (part.LastGetter == null || !part.LastGetter.DeclaringType.GetTypeInfo().IsAssignableFrom(currentType))
+ SetupPart(currentType, part);
+
+ if (!isLast)
+ part.TryGetValue(current, out current);
+ }
+
+ if (!part.IsSelf && current != null)
+ {
+ if ((needsGetter && part.LastGetter == null) || (needsSetter && part.NextPart == null && part.LastSetter == null))
+ {
+ Console.WriteLine("Binding", PropertyNotFoundErrorMessage, part.Content, current, target.GetType(), property.PropertyName);
+ break;
+ }
+ }
+
+ if (mode == BindingMode.OneWay || mode == BindingMode.TwoWay)
+ {
+ var inpc = current as INotifyPropertyChanged;
+ if (inpc != null && !ReferenceEquals(current, previous))
+ part.Subscribe(inpc);
+ }
+
+ previous = current;
+ }
+
+ Debug.Assert(part != null, "There should always be at least the self part in the expression.");
+
+ if (needsGetter)
+ {
+ object value = property.DefaultValue;
+ if (part.TryGetValue(current, out value) || part.IsSelf)
+ {
+ value = Binding.GetSourceValue(value, property.ReturnType);
+ }
+ else
+ value = property.DefaultValue;
+
+ if (!TryConvert(part, ref value, property.ReturnType, true))
+ {
+ Console.WriteLine("Binding", "{0} can not be converted to type '{1}'", value, property.ReturnType);
+ return;
+ }
+
+ target.SetValueCore(property, value, SetValueFlags.ClearDynamicResource, BindableObject.SetValuePrivateFlags.Default | BindableObject.SetValuePrivateFlags.Converted, false);
+ }
+ else if (needsSetter && part.LastSetter != null && current != null)
+ {
+ object value = Binding.GetTargetValue(target.GetValue(property), part.SetterType);
+
+ if (!TryConvert(part, ref value, part.SetterType, false))
+ {
+ Console.WriteLine("Binding", "{0} can not be converted to type '{1}'", value, part.SetterType);
+ return;
+ }
+
+ object[] args;
+ if (part.IsIndexer)
+ {
+ args = new object[part.Arguments.Length + 1];
+ part.Arguments.CopyTo(args, 0);
+ args[args.Length - 1] = value;
+ }
+ else if (part.IsBindablePropertySetter)
+ {
+ args = new[] { part.BindablePropertyField, value };
+ }
+ else
+ {
+ args = new[] { value };
+ }
+
+ part.LastSetter.Invoke(current, args);
+ }
+ }
+
+ IEnumerable<BindingExpressionPart> GetPart(string part)
+ {
+ part = part.Trim();
+ if (part == string.Empty)
+ throw new FormatException("Path contains an empty part");
+
+ BindingExpressionPart indexer = null;
+
+ int lbIndex = part.IndexOf('[');
+ if (lbIndex != -1)
+ {
+ int rbIndex = part.LastIndexOf(']');
+ if (rbIndex == -1)
+ throw new FormatException("Indexer did not contain closing bracket");
+
+ int argLength = rbIndex - lbIndex - 1;
+ if (argLength == 0)
+ throw new FormatException("Indexer did not contain arguments");
+
+ string argString = part.Substring(lbIndex + 1, argLength);
+ indexer = new BindingExpressionPart(this, argString, true);
+
+ part = part.Substring(0, lbIndex);
+ part = part.Trim();
+ }
+
+ if (part.Length > 0)
+ yield return new BindingExpressionPart(this, part);
+ if (indexer != null)
+ yield return indexer;
+ }
+
+ void ParsePath()
+ {
+ string p = Path.Trim();
+
+ var last = new BindingExpressionPart(this, ".");
+ _parts.Add(last);
+
+ if (p[0] == '.')
+ {
+ if (p.Length == 1)
+ return;
+
+ p = p.Substring(1);
+ }
+
+ string[] pathParts = p.Split('.');
+ for (var i = 0; i < pathParts.Length; i++)
+ {
+ foreach (BindingExpressionPart part in GetPart(pathParts[i]))
+ {
+ last.NextPart = part;
+ _parts.Add(part);
+ last = part;
+ }
+ }
+ }
+
+ void SetupPart(System.Reflection.TypeInfo sourceType, BindingExpressionPart part)
+ {
+ part.Arguments = null;
+ part.LastGetter = null;
+ part.LastSetter = null;
+
+ PropertyInfo property = null;
+ if (part.IsIndexer)
+ {
+ if (sourceType.IsArray)
+ {
+ int index;
+ if (!int.TryParse(part.Content, out index))
+ Console.WriteLine("Binding", "{0} could not be parsed as an index for a {1}", part.Content, sourceType);
+ else
+ part.Arguments = new object[] { index };
+
+ part.LastGetter = sourceType.GetDeclaredMethod("Get");
+ part.LastSetter = sourceType.GetDeclaredMethod("Set");
+ part.SetterType = sourceType.GetElementType();
+ }
+
+ DefaultMemberAttribute defaultMember = sourceType.GetCustomAttributes(typeof(DefaultMemberAttribute), true).OfType<DefaultMemberAttribute>().FirstOrDefault();
+ string indexerName = defaultMember != null ? defaultMember.MemberName : "Item";
+
+ part.IndexerName = indexerName;
#if NETSTANDARD2_0
- try {
- property = sourceType.GetDeclaredProperty(indexerName);
- }
- catch (AmbiguousMatchException) {
- // Get most derived instance of property
- foreach (var p in sourceType.GetProperties().Where(prop => prop.Name == indexerName)) {
- if (property == null || property.DeclaringType.IsAssignableFrom(property.DeclaringType))
- property = p;
- }
- }
+ try {
+ property = sourceType.GetDeclaredProperty(indexerName);
+ }
+ catch (AmbiguousMatchException) {
+ // Get most derived instance of property
+ foreach (var p in sourceType.GetProperties().Where(prop => prop.Name == indexerName)) {
+ if (property == null || property.DeclaringType.IsAssignableFrom(property.DeclaringType))
+ property = p;
+ }
+ }
#else
- property = sourceType.GetDeclaredProperty(indexerName);
+ property = sourceType.GetDeclaredProperty(indexerName);
#endif
- if (property == null) //is the indexer defined on the base class?
- property = sourceType.BaseType.GetProperty(indexerName);
- if (property == null) //is the indexer defined on implemented interface ?
- {
- foreach (var implementedInterface in sourceType.ImplementedInterfaces)
- {
- property = implementedInterface.GetProperty(indexerName);
- if (property != null)
- break;
- }
- }
-
- if (property != null)
- {
- ParameterInfo parameter = property.GetIndexParameters().FirstOrDefault();
- if (parameter != null)
- {
- try
- {
- object arg = Convert.ChangeType(part.Content, parameter.ParameterType, CultureInfo.InvariantCulture);
- part.Arguments = new[] { arg };
- }
- catch (FormatException)
- {
- }
- catch (InvalidCastException)
- {
- }
- catch (OverflowException)
- {
- }
- }
- }
- }
- else
- property = sourceType.GetDeclaredProperty(part.Content) ?? sourceType.BaseType?.GetProperty(part.Content);
-
- if (property != null)
- {
- if (property.CanRead && property.GetMethod.IsPublic && !property.GetMethod.IsStatic)
- part.LastGetter = property.GetMethod;
- if (property.CanWrite && property.SetMethod.IsPublic && !property.SetMethod.IsStatic)
- {
- part.LastSetter = property.SetMethod;
- part.SetterType = part.LastSetter.GetParameters().Last().ParameterType;
-
- if (Binding.AllowChaining)
- {
- FieldInfo bindablePropertyField = sourceType.GetDeclaredField(part.Content + "Property");
- if (bindablePropertyField != null && bindablePropertyField.FieldType == typeof(BindableProperty) && sourceType.ImplementedInterfaces.Contains(typeof(IElementController)))
- {
- MethodInfo setValueMethod = null;
+ if (property == null) //is the indexer defined on the base class?
+ property = sourceType.BaseType.GetProperty(indexerName);
+ if (property == null) //is the indexer defined on implemented interface ?
+ {
+ foreach (var implementedInterface in sourceType.ImplementedInterfaces)
+ {
+ property = implementedInterface.GetProperty(indexerName);
+ if (property != null)
+ break;
+ }
+ }
+
+ if (property != null)
+ {
+ ParameterInfo parameter = property.GetIndexParameters().FirstOrDefault();
+ if (parameter != null)
+ {
+ try
+ {
+ object arg = Convert.ChangeType(part.Content, parameter.ParameterType, CultureInfo.InvariantCulture);
+ part.Arguments = new[] { arg };
+ }
+ catch (FormatException)
+ {
+ }
+ catch (InvalidCastException)
+ {
+ }
+ catch (OverflowException)
+ {
+ }
+ }
+ }
+ }
+ else
+ property = sourceType.GetDeclaredProperty(part.Content) ?? sourceType.BaseType?.GetProperty(part.Content);
+
+ if (property != null)
+ {
+ if (property.CanRead && property.GetMethod.IsPublic && !property.GetMethod.IsStatic)
+ part.LastGetter = property.GetMethod;
+ if (property.CanWrite && property.SetMethod.IsPublic && !property.SetMethod.IsStatic)
+ {
+ part.LastSetter = property.SetMethod;
+ part.SetterType = part.LastSetter.GetParameters().Last().ParameterType;
+
+ if (Binding.AllowChaining)
+ {
+ FieldInfo bindablePropertyField = sourceType.GetDeclaredField(part.Content + "Property");
+ if (bindablePropertyField != null && bindablePropertyField.FieldType == typeof(BindableProperty) && sourceType.ImplementedInterfaces.Contains(typeof(IElementController)))
+ {
+ MethodInfo setValueMethod = null;
#if NETSTANDARD1_0
- foreach (MethodInfo m in sourceType.AsType().GetRuntimeMethods())
- {
- if (m.Name.EndsWith("IElementController.SetValueFromRenderer"))
- {
- ParameterInfo[] parameters = m.GetParameters();
- if (parameters.Length == 2 && parameters[0].ParameterType == typeof(BindableProperty))
- {
- setValueMethod = m;
- break;
- }
- }
- }
+ foreach (MethodInfo m in sourceType.AsType().GetRuntimeMethods())
+ {
+ if (m.Name.EndsWith("IElementController.SetValueFromRenderer"))
+ {
+ ParameterInfo[] parameters = m.GetParameters();
+ if (parameters.Length == 2 && parameters[0].ParameterType == typeof(BindableProperty))
+ {
+ setValueMethod = m;
+ break;
+ }
+ }
+ }
#else
- setValueMethod = typeof(IElementController).GetMethod("SetValueFromRenderer", new[] { typeof(BindableProperty), typeof(object) });
+ setValueMethod = typeof(IElementController).GetMethod("SetValueFromRenderer", new[] { typeof(BindableProperty), typeof(object) });
#endif
- if (setValueMethod != null)
- {
- part.LastSetter = setValueMethod;
- part.IsBindablePropertySetter = true;
- part.BindablePropertyField = bindablePropertyField.GetValue(null);
- }
- }
- }
- }
+ if (setValueMethod != null)
+ {
+ part.LastSetter = setValueMethod;
+ part.IsBindablePropertySetter = true;
+ part.BindablePropertyField = bindablePropertyField.GetValue(null);
+ }
+ }
+ }
+ }
#if !NETSTANDARD1_0
- TupleElementNamesAttribute tupleEltNames;
- if ( property != null
- && part.NextPart != null
- && property.PropertyType.IsGenericType
- && ( property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<>)
- || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,>)
- || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,>)
- || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,>)
- || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,,>)
- || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,,,>)
- || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,,,,>)
- || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,,,,,>))
- && (tupleEltNames = property.GetCustomAttribute(typeof(TupleElementNamesAttribute)) as TupleElementNamesAttribute) != null)
- {
- //modify the nextPart to access the tuple item via the ITuple indexer
- var nextPart = part.NextPart;
- var name = nextPart.Content;
- var index = tupleEltNames.TransformNames.IndexOf(name);
- if (index >= 0)
- {
- nextPart.IsIndexer = true;
- nextPart.Content = index.ToString();
- }
- }
+ //TupleElementNamesAttribute tupleEltNames;
+ //if (property != null
+ // && part.NextPart != null
+ // && property.PropertyType.IsGenericType
+ // && (property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<>)
+ // || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,>)
+ // || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,>)
+ // || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,>)
+ // || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,,>)
+ // || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,,,>)
+ // || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,,,,>)
+ // || property.PropertyType.GetGenericTypeDefinition() == typeof(ValueTuple<,,,,,,,>))
+ // && (tupleEltNames = property.GetCustomAttribute(typeof(TupleElementNamesAttribute)) as TupleElementNamesAttribute) != null)
+ //{
+ // modify the nextPart to access the tuple item via the ITuple indexer
+ // var nextPart = part.NextPart;
+ // var name = nextPart.Content;
+ // var index = tupleEltNames.TransformNames.IndexOf(name);
+ // if (index >= 0)
+ // {
+ // nextPart.IsIndexer = true;
+ // nextPart.Content = index.ToString();
+ // }
+ //}
#endif
- }
-
- }
- static Type[] DecimalTypes = new[] { typeof(float), typeof(decimal), typeof(double) };
-
- bool TryConvert(BindingExpressionPart part, ref object value, Type convertTo, bool toTarget)
- {
- if (value == null)
- return true;
- if ((toTarget && _targetProperty.TryConvert(ref value)) || (!toTarget && convertTo.IsInstanceOfType(value)))
- return true;
-
- object original = value;
- try
- {
- var stringValue = value as string ?? string.Empty;
- // see: https://bugzilla.xamarin.com/show_bug.cgi?id=32871
- // do not canonicalize "*.[.]"; "1." should not update bound BindableProperty
- if (stringValue.EndsWith(".") && DecimalTypes.Contains(convertTo))
- throw new FormatException();
-
- // do not canonicalize "-0"; user will likely enter a period after "-0"
- if (stringValue == "-0" && DecimalTypes.Contains(convertTo))
- throw new FormatException();
-
- value = Convert.ChangeType(value, convertTo, CultureInfo.InvariantCulture);
- return true;
- }
- catch (InvalidCastException)
- {
- value = original;
- return false;
- }
- catch (FormatException)
- {
- value = original;
- return false;
- }
- catch (OverflowException)
- {
- value = original;
- return false;
- }
- }
-
- class BindingPair
- {
- public BindingPair(BindingExpressionPart part, object source, bool isLast)
- {
- Part = part;
- Source = source;
- IsLast = isLast;
- }
-
- public bool IsLast { get; set; }
-
- public BindingExpressionPart Part { get; private set; }
-
- public object Source { get; private set; }
- }
-
- internal class WeakPropertyChangedProxy
- {
- readonly WeakReference<INotifyPropertyChanged> _source = new WeakReference<INotifyPropertyChanged>(null);
- readonly WeakReference<PropertyChangedEventHandler> _listener = new WeakReference<PropertyChangedEventHandler>(null);
- readonly PropertyChangedEventHandler _handler;
- readonly EventHandler _bchandler;
- internal WeakReference<INotifyPropertyChanged> Source => _source;
-
- public WeakPropertyChangedProxy()
- {
- _handler = new PropertyChangedEventHandler(OnPropertyChanged);
- _bchandler = new EventHandler(OnBCChanged);
- }
-
- public WeakPropertyChangedProxy(INotifyPropertyChanged source, PropertyChangedEventHandler listener) : this()
- {
- SubscribeTo(source, listener);
- }
-
- public void SubscribeTo(INotifyPropertyChanged source, PropertyChangedEventHandler listener)
- {
- source.PropertyChanged += _handler;
- var bo = source as BindableObject;
- if (bo != null)
- bo.BindingContextChanged += _bchandler;
- _source.SetTarget(source);
- _listener.SetTarget(listener);
- }
-
- public void Unsubscribe()
- {
- INotifyPropertyChanged source;
- if (_source.TryGetTarget(out source) && source != null)
- source.PropertyChanged -= _handler;
- var bo = source as BindableObject;
- if (bo != null)
- bo.BindingContextChanged -= _bchandler;
-
- _source.SetTarget(null);
- _listener.SetTarget(null);
- }
-
- void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- PropertyChangedEventHandler handler;
- if (_listener.TryGetTarget(out handler) && handler != null)
- handler(sender, e);
- else
- Unsubscribe();
- }
-
- void OnBCChanged(object sender, EventArgs e)
- {
- OnPropertyChanged(sender, new PropertyChangedEventArgs("BindingContext"));
- }
- }
-
- class BindingExpressionPart
- {
- readonly BindingExpression _expression;
- readonly PropertyChangedEventHandler _changeHandler;
- WeakPropertyChangedProxy _listener;
-
- public BindingExpressionPart(BindingExpression expression, string content, bool isIndexer = false)
- {
- _expression = expression;
- IsSelf = content == Tizen.NUI.Binding.Binding.SelfPath;
- Content = content;
- IsIndexer = isIndexer;
-
- _changeHandler = PropertyChanged;
- }
-
- public void Subscribe(INotifyPropertyChanged handler)
- {
- INotifyPropertyChanged source;
- if (_listener != null && _listener.Source.TryGetTarget(out source) && ReferenceEquals(handler, source))
- // Already subscribed
- return;
-
- // Clear out the old subscription if necessary
- Unsubscribe();
-
- _listener = new WeakPropertyChangedProxy(handler, _changeHandler);
- }
-
- public void Unsubscribe()
- {
- var listener = _listener;
- if (listener != null)
- {
- listener.Unsubscribe();
- _listener = null;
- }
- }
-
- public object[] Arguments { get; set; }
-
- public object BindablePropertyField { get; set; }
-
- public string Content { get; internal set; }
-
- public string IndexerName { get; set; }
-
- public bool IsBindablePropertySetter { get; set; }
-
- public bool IsIndexer { get; internal set; }
-
- public bool IsSelf { get; }
-
- public MethodInfo LastGetter { get; set; }
-
- public MethodInfo LastSetter { get; set; }
-
- public BindingExpressionPart NextPart { get; set; }
-
- public Type SetterType { get; set; }
-
- public void PropertyChanged(object sender, PropertyChangedEventArgs args)
- {
- BindingExpressionPart part = NextPart ?? this;
-
- string name = args.PropertyName;
-
- if (!string.IsNullOrEmpty(name))
- {
- if (part.IsIndexer)
- {
- if (name.Contains("["))
- {
- if (name != string.Format("{0}[{1}]", part.IndexerName, part.Content))
- return;
- }
- else if (name != part.IndexerName)
- return;
- }
- else if (name != part.Content)
- {
- return;
- }
- }
-
- Device.BeginInvokeOnMainThread(() => _expression.Apply());
- }
-
- public bool TryGetValue(object source, out object value)
- {
- value = source;
-
- if (LastGetter != null && value != null)
- {
- if (IsIndexer)
- {
- try
- {
- value = LastGetter.Invoke(value, Arguments);
- }
- catch (TargetInvocationException ex)
- {
- if (!(ex.InnerException is KeyNotFoundException))
- throw;
- value = null;
- }
- return true;
- }
- value = LastGetter.Invoke(value, Arguments);
- return true;
- }
-
- return false;
- }
- }
- }
+ }
+
+ }
+ static Type[] DecimalTypes = new[] { typeof(float), typeof(decimal), typeof(double) };
+
+ bool TryConvert(BindingExpressionPart part, ref object value, Type convertTo, bool toTarget)
+ {
+ if (value == null)
+ return true;
+ if ((toTarget && _targetProperty.TryConvert(ref value)) || (!toTarget && convertTo.IsInstanceOfType(value)))
+ return true;
+
+ object original = value;
+ try
+ {
+ var stringValue = value as string ?? string.Empty;
+ // see: https://bugzilla.xamarin.com/show_bug.cgi?id=32871
+ // do not canonicalize "*.[.]"; "1." should not update bound BindableProperty
+ if (stringValue.EndsWith(".") && DecimalTypes.Contains(convertTo))
+ throw new FormatException();
+
+ // do not canonicalize "-0"; user will likely enter a period after "-0"
+ if (stringValue == "-0" && DecimalTypes.Contains(convertTo))
+ throw new FormatException();
+
+ value = Convert.ChangeType(value, convertTo, CultureInfo.InvariantCulture);
+ return true;
+ }
+ catch (InvalidCastException)
+ {
+ value = original;
+ return false;
+ }
+ catch (FormatException)
+ {
+ value = original;
+ return false;
+ }
+ catch (OverflowException)
+ {
+ value = original;
+ return false;
+ }
+ }
+
+ class BindingPair
+ {
+ public BindingPair(BindingExpressionPart part, object source, bool isLast)
+ {
+ Part = part;
+ Source = source;
+ IsLast = isLast;
+ }
+
+ public bool IsLast { get; set; }
+
+ public BindingExpressionPart Part { get; private set; }
+
+ public object Source { get; private set; }
+ }
+
+ internal class WeakPropertyChangedProxy
+ {
+ readonly WeakReference<INotifyPropertyChanged> _source = new WeakReference<INotifyPropertyChanged>(null);
+ readonly WeakReference<PropertyChangedEventHandler> _listener = new WeakReference<PropertyChangedEventHandler>(null);
+ readonly PropertyChangedEventHandler _handler;
+ readonly EventHandler _bchandler;
+ internal WeakReference<INotifyPropertyChanged> Source => _source;
+
+ public WeakPropertyChangedProxy()
+ {
+ _handler = new PropertyChangedEventHandler(OnPropertyChanged);
+ _bchandler = new EventHandler(OnBCChanged);
+ }
+
+ public WeakPropertyChangedProxy(INotifyPropertyChanged source, PropertyChangedEventHandler listener) : this()
+ {
+ SubscribeTo(source, listener);
+ }
+
+ public void SubscribeTo(INotifyPropertyChanged source, PropertyChangedEventHandler listener)
+ {
+ source.PropertyChanged += _handler;
+ var bo = source as BindableObject;
+ if (bo != null)
+ bo.BindingContextChanged += _bchandler;
+ _source.SetTarget(source);
+ _listener.SetTarget(listener);
+ }
+
+ public void Unsubscribe()
+ {
+ INotifyPropertyChanged source;
+ if (_source.TryGetTarget(out source) && source != null)
+ source.PropertyChanged -= _handler;
+ var bo = source as BindableObject;
+ if (bo != null)
+ bo.BindingContextChanged -= _bchandler;
+
+ _source.SetTarget(null);
+ _listener.SetTarget(null);
+ }
+
+ void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ PropertyChangedEventHandler handler;
+ if (_listener.TryGetTarget(out handler) && handler != null)
+ handler(sender, e);
+ else
+ Unsubscribe();
+ }
+
+ void OnBCChanged(object sender, EventArgs e)
+ {
+ OnPropertyChanged(sender, new PropertyChangedEventArgs("BindingContext"));
+ }
+ }
+
+ class BindingExpressionPart
+ {
+ readonly BindingExpression _expression;
+ readonly PropertyChangedEventHandler _changeHandler;
+ WeakPropertyChangedProxy _listener;
+
+ public BindingExpressionPart(BindingExpression expression, string content, bool isIndexer = false)
+ {
+ _expression = expression;
+ IsSelf = content == Tizen.NUI.Binding.Binding.SelfPath;
+ Content = content;
+ IsIndexer = isIndexer;
+
+ _changeHandler = PropertyChanged;
+ }
+
+ public void Subscribe(INotifyPropertyChanged handler)
+ {
+ INotifyPropertyChanged source;
+ if (_listener != null && _listener.Source.TryGetTarget(out source) && ReferenceEquals(handler, source))
+ // Already subscribed
+ return;
+
+ // Clear out the old subscription if necessary
+ Unsubscribe();
+
+ _listener = new WeakPropertyChangedProxy(handler, _changeHandler);
+ }
+
+ public void Unsubscribe()
+ {
+ var listener = _listener;
+ if (listener != null)
+ {
+ listener.Unsubscribe();
+ _listener = null;
+ }
+ }
+
+ public object[] Arguments { get; set; }
+
+ public object BindablePropertyField { get; set; }
+
+ public string Content { get; internal set; }
+
+ public string IndexerName { get; set; }
+
+ public bool IsBindablePropertySetter { get; set; }
+
+ public bool IsIndexer { get; internal set; }
+
+ public bool IsSelf { get; }
+
+ public MethodInfo LastGetter { get; set; }
+
+ public MethodInfo LastSetter { get; set; }
+
+ public BindingExpressionPart NextPart { get; set; }
+
+ public Type SetterType { get; set; }
+
+ public void PropertyChanged(object sender, PropertyChangedEventArgs args)
+ {
+ BindingExpressionPart part = NextPart ?? this;
+
+ string name = args.PropertyName;
+
+ if (!string.IsNullOrEmpty(name))
+ {
+ if (part.IsIndexer)
+ {
+ if (name.Contains("["))
+ {
+ if (name != string.Format("{0}[{1}]", part.IndexerName, part.Content))
+ return;
+ }
+ else if (name != part.IndexerName)
+ return;
+ }
+ else if (name != part.Content)
+ {
+ return;
+ }
+ }
+
+ _expression.Apply();
+ // Device.BeginInvokeOnMainThread(() => _expression.Apply());
+ }
+
+ public bool TryGetValue(object source, out object value)
+ {
+ value = source;
+
+ if (LastGetter != null && value != null)
+ {
+ if (IsIndexer)
+ {
+ try
+ {
+ value = LastGetter.Invoke(value, Arguments);
+ }
+ catch (TargetInvocationException ex)
+ {
+ if (!(ex.InnerException is KeyNotFoundException))
+ throw;
+ value = null;
+ }
+ return true;
+ }
+ value = LastGetter.Invoke(value, Arguments);
+ return true;
+ }
+
+ return false;
+ }
+ }
+ }
}
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public enum BindingMode
- {
+ {
/// <summary>
/// When used in Bindings, indicates that the Binding should use the DefaultBindingMode. When used in BindableProperty declaration, defaults to BindingMode.OneWay.
/// </summary>
- Default,
+ Default,
/// <summary>
/// Indicates that the binding should propagates changes from source (usually the View Model) to target (the BindableObject) in both directions.
/// </summary>
- TwoWay,
+ TwoWay,
/// <summary>
/// Indicates that the binding should only propagate changes from source (usually the View Model) to target (the BindableObject). This is the default mode for most BindableProperty values.
/// </summary>
- OneWay,
+ OneWay,
/// <summary>
/// Indicates that the binding should only propagate changes from target (the BindableObject) to source (usually the View Model). This is mainly used for read-only BindableProperty values.
/// </summary>
- OneWayToSource,
+ OneWayToSource,
/// <summary>
/// Indicates that the binding will be applied only when the binding context changes and the value will not be monitored for changes with INotifyPropertyChanged.
/// </summary>
- OneTime,
- }
+ OneTime,
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.BindingTypeConverter")]
- [Xaml.TypeConversion(typeof(Binding))]
- internal sealed class BindingTypeConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- return new Binding(value);
- }
- }
+ // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.BindingTypeConverter")]
+ [Xaml.TypeConversion(typeof(Binding))]
+ internal sealed class BindingTypeConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ return new Binding(value);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal delegate void CollectionSynchronizationCallback(IEnumerable collection, object context, Action accessMethod, bool writeAccess);
+ internal delegate void CollectionSynchronizationCallback(IEnumerable collection, object context, Action accessMethod, bool writeAccess);
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal sealed class CollectionSynchronizationContext
- {
- internal CollectionSynchronizationContext(object context, CollectionSynchronizationCallback callback)
- {
- ContextReference = new WeakReference(context);
- Callback = callback;
- }
+ internal sealed class CollectionSynchronizationContext
+ {
+ internal CollectionSynchronizationContext(object context, CollectionSynchronizationCallback callback)
+ {
+ ContextReference = new WeakReference(context);
+ Callback = callback;
+ }
- internal CollectionSynchronizationCallback Callback { get; private set; }
+ internal CollectionSynchronizationCallback Callback { get; private set; }
- internal object Context
- {
- get { return ContextReference != null ? ContextReference.Target : null; }
- }
+ internal object Context
+ {
+ get { return ContextReference != null ? ContextReference.Target : null; }
+ }
- internal WeakReference ContextReference { get; }
- }
+ internal WeakReference ContextReference { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class Configuration<TPlatform, TElement> : IPlatformElementConfiguration<TPlatform, TElement>
- where TPlatform : IConfigPlatform
- where TElement : Element
+ internal class Configuration<TPlatform, TElement> : IPlatformElementConfiguration<TPlatform, TElement>
+ where TPlatform : IConfigPlatform
+ where TElement : Element
- {
- public Configuration(TElement element)
- {
- Element = element;
- }
+ {
+ public Configuration(TElement element)
+ {
+ Element = element;
+ }
- public TElement Element { get; }
+ public TElement Element { get; }
- public static Configuration<TPlatform, TElement> Create(TElement element)
- {
- return new Configuration<TPlatform, TElement>(element);
- }
- }
+ public static Configuration<TPlatform, TElement> Create(TElement element)
+ {
+ return new Configuration<TPlatform, TElement>(element);
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- [AttributeUsage(AttributeTargets.Class)]
- internal sealed class ContentPropertyAttribute : Attribute
- {
- internal static string[] ContentPropertyTypes = { "Tizen.NUI.Binding.ContentPropertyAttribute", "System.Windows.Markup.ContentPropertyAttribute" };
+ [AttributeUsage(AttributeTargets.Class)]
+ internal sealed class ContentPropertyAttribute : Attribute
+ {
+ internal static string[] ContentPropertyTypes = { "Tizen.NUI.Binding.ContentPropertyAttribute", "System.Windows.Markup.ContentPropertyAttribute" };
- public ContentPropertyAttribute(string name)
- {
- Name = name;
- }
+ public ContentPropertyAttribute(string name)
+ {
+ Name = name;
+ }
- public string Name { get; private set; }
- }
+ public string Name { get; private set; }
+ }
}
/// Template that specifies a group of styles and effects for controls.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class ControlTemplate : ElementTemplate
- {
+ internal class ControlTemplate : ElementTemplate
+ {
/// <summary>
/// For internal use only.
/// </summary>
- public ControlTemplate()
- {
- }
+ public ControlTemplate()
+ {
+ }
/// <summary>
/// Creates a new control template for the specified control type.
/// </summary>
/// <param name="type">The type of control for which to create a template.</param>
public ControlTemplate(Type type) : base(type)
- {
- }
- }
+ {
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal class DataTemplate : ElementTemplate
- {
- public DataTemplate()
- {
- }
-
- public DataTemplate(Type type) : base(type)
- {
- }
-
- public DataTemplate(Func<object> loadTemplate) : base(loadTemplate)
- {
- }
-
- public IDictionary<BindableProperty, BindingBase> Bindings { get; } = new Dictionary<BindableProperty, BindingBase>();
-
- public IDictionary<BindableProperty, object> Values { get; } = new Dictionary<BindableProperty, object>();
-
- public void SetBinding(BindableProperty property, BindingBase binding)
- {
- if (property == null)
- throw new ArgumentNullException("property");
- if (binding == null)
- throw new ArgumentNullException("binding");
-
- Values.Remove(property);
- Bindings[property] = binding;
- }
-
- public void SetValue(BindableProperty property, object value)
- {
- if (property == null)
- throw new ArgumentNullException("property");
-
- Bindings.Remove(property);
- Values[property] = value;
- }
-
- internal override void SetupContent(object item)
- {
- ApplyBindings(item);
- ApplyValues(item);
- }
-
- void ApplyBindings(object item)
- {
- if (Bindings == null)
- return;
-
- var bindable = item as BindableObject;
- if (bindable == null)
- return;
-
- foreach (KeyValuePair<BindableProperty, BindingBase> kvp in Bindings)
- {
- if (Values.ContainsKey(kvp.Key))
- throw new InvalidOperationException("Binding and Value found for " + kvp.Key.PropertyName);
-
- bindable.SetBinding(kvp.Key, kvp.Value.Clone());
- }
- }
-
- void ApplyValues(object item)
- {
- if (Values == null)
- return;
-
- var bindable = item as BindableObject;
- if (bindable == null)
- return;
- foreach (KeyValuePair<BindableProperty, object> kvp in Values)
- bindable.SetValue(kvp.Key, kvp.Value);
- }
- }
+ internal class DataTemplate : ElementTemplate
+ {
+ public DataTemplate()
+ {
+ }
+
+ public DataTemplate(Type type) : base(type)
+ {
+ }
+
+ public DataTemplate(Func<object> loadTemplate) : base(loadTemplate)
+ {
+ }
+
+ public IDictionary<BindableProperty, BindingBase> Bindings { get; } = new Dictionary<BindableProperty, BindingBase>();
+
+ public IDictionary<BindableProperty, object> Values { get; } = new Dictionary<BindableProperty, object>();
+
+ public void SetBinding(BindableProperty property, BindingBase binding)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
+ if (binding == null)
+ throw new ArgumentNullException("binding");
+
+ Values.Remove(property);
+ Bindings[property] = binding;
+ }
+
+ public void SetValue(BindableProperty property, object value)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
+
+ Bindings.Remove(property);
+ Values[property] = value;
+ }
+
+ internal override void SetupContent(object item)
+ {
+ ApplyBindings(item);
+ ApplyValues(item);
+ }
+
+ void ApplyBindings(object item)
+ {
+ if (Bindings == null)
+ return;
+
+ var bindable = item as BindableObject;
+ if (bindable == null)
+ return;
+
+ foreach (KeyValuePair<BindableProperty, BindingBase> kvp in Bindings)
+ {
+ if (Values.ContainsKey(kvp.Key))
+ throw new InvalidOperationException("Binding and Value found for " + kvp.Key.PropertyName);
+
+ bindable.SetBinding(kvp.Key, kvp.Value.Clone());
+ }
+ }
+
+ void ApplyValues(object item)
+ {
+ if (Values == null)
+ return;
+
+ var bindable = item as BindableObject;
+ if (bindable == null)
+ return;
+ foreach (KeyValuePair<BindableProperty, object> kvp in Values)
+ bindable.SetValue(kvp.Key, kvp.Value);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal static class DataTemplateExtensions
- {
- public static DataTemplate SelectDataTemplate(this DataTemplate self, object item, BindableObject container)
- {
- var selector = self as DataTemplateSelector;
- if (selector == null)
- return self;
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal static class DataTemplateExtensions
+ {
+ public static DataTemplate SelectDataTemplate(this DataTemplate self, object item, BindableObject container)
+ {
+ var selector = self as DataTemplateSelector;
+ if (selector == null)
+ return self;
- return selector.SelectTemplate(item, container);
- }
+ return selector.SelectTemplate(item, container);
+ }
- public static object CreateContent(this DataTemplate self, object item, BindableObject container)
- {
- return self.SelectDataTemplate(item, container).CreateContent();
- }
- }
+ public static object CreateContent(this DataTemplate self, object item, BindableObject container)
+ {
+ return self.SelectDataTemplate(item, container).CreateContent();
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal abstract class DataTemplateSelector : DataTemplate
- {
- Dictionary<Type, DataTemplate> _dataTemplates = new Dictionary<Type, DataTemplate>();
+ internal abstract class DataTemplateSelector : DataTemplate
+ {
+ Dictionary<Type, DataTemplate> _dataTemplates = new Dictionary<Type, DataTemplate>();
- public DataTemplate SelectTemplate(object item, BindableObject container)
- {
- // var listView = container as ListView;
+ public DataTemplate SelectTemplate(object item, BindableObject container)
+ {
+ // var listView = container as ListView;
- // var recycle = listView == null ? false :
- // (listView.CachingStrategy & ListViewCachingStrategy.RecycleElementAndDataTemplate) ==
- // ListViewCachingStrategy.RecycleElementAndDataTemplate;
+ // var recycle = listView == null ? false :
+ // (listView.CachingStrategy & ListViewCachingStrategy.RecycleElementAndDataTemplate) ==
+ // ListViewCachingStrategy.RecycleElementAndDataTemplate;
- DataTemplate dataTemplate = null;
- // if (recycle && _dataTemplates.TryGetValue(item.GetType(), out dataTemplate))
- // return dataTemplate;
+ DataTemplate dataTemplate = null;
+ // if (recycle && _dataTemplates.TryGetValue(item.GetType(), out dataTemplate))
+ // return dataTemplate;
- dataTemplate = OnSelectTemplate(item, container);
- if (dataTemplate is DataTemplateSelector)
- throw new NotSupportedException(
- "DataTemplateSelector.OnSelectTemplate must not return another DataTemplateSelector");
+ dataTemplate = OnSelectTemplate(item, container);
+ if (dataTemplate is DataTemplateSelector)
+ throw new NotSupportedException(
+ "DataTemplateSelector.OnSelectTemplate must not return another DataTemplateSelector");
- // if (recycle)
- // {
- // if (!dataTemplate.CanRecycle)
- // throw new NotSupportedException(
- // "RecycleElementAndDataTemplate requires DataTemplate activated with ctor taking a type.");
+ // if (recycle)
+ // {
+ // if (!dataTemplate.CanRecycle)
+ // throw new NotSupportedException(
+ // "RecycleElementAndDataTemplate requires DataTemplate activated with ctor taking a type.");
- // _dataTemplates[item.GetType()] = dataTemplate;
- // }
+ // _dataTemplates[item.GetType()] = dataTemplate;
+ // }
- return dataTemplate;
- }
+ return dataTemplate;
+ }
- protected abstract DataTemplate OnSelectTemplate(object item, BindableObject container);
- }
+ protected abstract DataTemplate OnSelectTemplate(object item, BindableObject container);
+ }
}
namespace Tizen.NUI.Binding
{
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
- internal class DependencyAttribute : Attribute
- {
- public DependencyAttribute(Type implementorType)
- {
- Implementor = implementorType;
- }
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+ internal class DependencyAttribute : Attribute
+ {
+ public DependencyAttribute(Type implementorType)
+ {
+ Implementor = implementorType;
+ }
- internal Type Implementor { get; private set; }
- }
+ internal Type Implementor { get; private set; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal enum DependencyFetchTarget
- {
- GlobalInstance,
- NewInstance
- }
+ internal enum DependencyFetchTarget
+ {
+ GlobalInstance,
+ NewInstance
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal static class DependencyResolver
- {
- static Func<Type, object[], object> Resolver { get; set; }
-
- public static void ResolveUsing(Func<Type, object[], object> resolver)
- {
- Resolver = resolver;
- }
-
- public static void ResolveUsing(Func<Type, object> resolver)
- {
- Resolver = (type, objects) => resolver.Invoke(type);
- }
-
- internal static object Resolve(Type type, params object[] args)
- {
- var result = Resolver?.Invoke(type, args);
-
- if (result != null)
- {
- if (!type.IsInstanceOfType(result))
- {
- throw new InvalidCastException("Resolved instance is not of the correct type.");
- }
- }
-
- return result;
- }
-
- internal static object ResolveOrCreate(Type type, params object[] args)
- {
- var result = Resolve(type, args);
-
- if (result != null) return result;
-
- if (args.Length > 0)
- {
- // This is by no means a general solution to matching with the correct constructor, but it'll
- // do for finding Android renderers which need Context (vs older custom renderers which may still use
- // parameterless constructors)
- if (type.GetTypeInfo().DeclaredConstructors.Any(info => info.GetParameters().Length == args.Length))
- {
- return Activator.CreateInstance(type, args);
- }
- }
-
- return Activator.CreateInstance(type);
- }
- }
+ internal static class DependencyResolver
+ {
+ static Func<Type, object[], object> Resolver { get; set; }
+
+ public static void ResolveUsing(Func<Type, object[], object> resolver)
+ {
+ Resolver = resolver;
+ }
+
+ public static void ResolveUsing(Func<Type, object> resolver)
+ {
+ Resolver = (type, objects) => resolver.Invoke(type);
+ }
+
+ internal static object Resolve(Type type, params object[] args)
+ {
+ var result = Resolver?.Invoke(type, args);
+
+ if (result != null)
+ {
+ if (!type.IsInstanceOfType(result))
+ {
+ throw new InvalidCastException("Resolved instance is not of the correct type.");
+ }
+ }
+
+ return result;
+ }
+
+ internal static object ResolveOrCreate(Type type, params object[] args)
+ {
+ var result = Resolve(type, args);
+
+ if (result != null) return result;
+
+ if (args.Length > 0)
+ {
+ // This is by no means a general solution to matching with the correct constructor, but it'll
+ // do for finding Android renderers which need Context (vs older custom renderers which may still use
+ // parameterless constructors)
+ if (type.GetTypeInfo().DeclaredConstructors.Any(info => info.GetParameters().Length == args.Length))
+ {
+ return Activator.CreateInstance(type, args);
+ }
+ }
+
+ return Activator.CreateInstance(type);
+ }
+ }
}
\ No newline at end of file
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
+using Tizen.NUI.Xaml;
namespace Tizen.NUI.Binding
{
- internal static class DependencyService
- {
- static bool s_initialized;
-
- static readonly List<Type> DependencyTypes = new List<Type>();
- static readonly Dictionary<Type, DependencyData> DependencyImplementations = new Dictionary<Type, DependencyData>();
-
- public static T Resolve<T>(DependencyFetchTarget fallbackFetchTarget = DependencyFetchTarget.GlobalInstance) where T : class
- {
- var result = DependencyResolver.Resolve(typeof(T)) as T;
-
- return result ?? Get<T>(fallbackFetchTarget);
- }
-
- public static T Get<T>(DependencyFetchTarget fetchTarget = DependencyFetchTarget.GlobalInstance) where T : class
- {
- Initialize();
-
- Type targetType = typeof(T);
-
- if (!DependencyImplementations.ContainsKey(targetType))
- {
- Type implementor = FindImplementor(targetType);
- DependencyImplementations[targetType] = implementor != null ? new DependencyData { ImplementorType = implementor } : null;
- }
-
- DependencyData dependencyImplementation = DependencyImplementations[targetType];
- if (dependencyImplementation == null)
- return null;
-
- if (fetchTarget == DependencyFetchTarget.GlobalInstance)
- {
- if (dependencyImplementation.GlobalInstance == null)
- {
- dependencyImplementation.GlobalInstance = Activator.CreateInstance(dependencyImplementation.ImplementorType);
- }
- return (T)dependencyImplementation.GlobalInstance;
- }
- return (T)Activator.CreateInstance(dependencyImplementation.ImplementorType);
- }
-
- public static void Register<T>() where T : class
- {
- Type type = typeof(T);
- if (!DependencyTypes.Contains(type))
- DependencyTypes.Add(type);
- }
-
- public static void Register<T, TImpl>() where T : class where TImpl : class, T
- {
- Type targetType = typeof(T);
- Type implementorType = typeof(TImpl);
- if (!DependencyTypes.Contains(targetType))
- DependencyTypes.Add(targetType);
-
- DependencyImplementations[targetType] = new DependencyData { ImplementorType = implementorType };
- }
-
- static Type FindImplementor(Type target)
- {
- return DependencyTypes.FirstOrDefault(t => target.IsAssignableFrom(t));
- }
-
- static void Initialize()
- {
- if (s_initialized)
- {
- return;
- }
-
- Assembly[] assemblies = Device.GetAssemblies();
- if (Tizen.NUI.Internals.Registrar.ExtraAssemblies != null)
- {
- assemblies = assemblies.Union(Tizen.NUI.Internals.Registrar.ExtraAssemblies).ToArray();
- }
-
- Initialize(assemblies);
- }
-
- internal static void Initialize(Assembly[] assemblies)
- {
- if (s_initialized || assemblies == null)
- {
- return;
- }
-
- Type targetAttrType = typeof(DependencyAttribute);
-
- // Don't use LINQ for performance reasons
- // Naive implementation can easily take over a second to run
- foreach (Assembly assembly in assemblies)
- {
- Attribute[] attributes;
- try
- {
- attributes = assembly.GetCustomAttributes(targetAttrType).ToArray();
- }
- catch (System.IO.FileNotFoundException)
- {
- // Sometimes the previewer doesn't actually have everything required for these loads to work
- Console.WriteLine(nameof(Registrar), "Could not load assembly: {0} for Attibute {1} | Some renderers may not be loaded", assembly.FullName, targetAttrType.FullName);
- continue;
- }
-
- if (attributes.Length == 0)
- continue;
-
- foreach (DependencyAttribute attribute in attributes)
- {
- if (!DependencyTypes.Contains(attribute.Implementor))
- {
- DependencyTypes.Add(attribute.Implementor);
- }
- }
- }
-
- s_initialized = true;
- }
-
- class DependencyData
- {
- public object GlobalInstance { get; set; }
-
- public Type ImplementorType { get; set; }
- }
- }
+ internal static class DependencyService
+ {
+ static bool s_initialized;
+
+ static readonly List<Type> DependencyTypes = new List<Type>();
+ static readonly Dictionary<Type, DependencyData> DependencyImplementations = new Dictionary<Type, DependencyData>();
+
+ public static T Resolve<T>(DependencyFetchTarget fallbackFetchTarget = DependencyFetchTarget.GlobalInstance) where T : class
+ {
+ var result = DependencyResolver.Resolve(typeof(T)) as T;
+
+ return result ?? Get<T>(fallbackFetchTarget);
+ }
+
+ public static T Get<T>(DependencyFetchTarget fetchTarget = DependencyFetchTarget.GlobalInstance) where T : class
+ {
+ Initialize();
+
+ Type targetType = typeof(T);
+
+ if (!DependencyImplementations.ContainsKey(targetType))
+ {
+ Type implementor = FindImplementor(targetType);
+ DependencyImplementations[targetType] = implementor != null ? new DependencyData { ImplementorType = implementor } : null;
+ }
+
+ DependencyData dependencyImplementation = DependencyImplementations[targetType];
+ if (dependencyImplementation == null)
+ return null;
+
+ if (fetchTarget == DependencyFetchTarget.GlobalInstance)
+ {
+ if (dependencyImplementation.GlobalInstance == null)
+ {
+ dependencyImplementation.GlobalInstance = Activator.CreateInstance(dependencyImplementation.ImplementorType);
+ }
+ return (T)dependencyImplementation.GlobalInstance;
+ }
+ return (T)Activator.CreateInstance(dependencyImplementation.ImplementorType);
+ }
+
+ public static void Register<T>() where T : class
+ {
+ Type type = typeof(T);
+ if (!DependencyTypes.Contains(type))
+ DependencyTypes.Add(type);
+ }
+
+ public static void Register<T, TImpl>() where T : class where TImpl : class, T
+ {
+ Type targetType = typeof(T);
+ Type implementorType = typeof(TImpl);
+ if (!DependencyTypes.Contains(targetType))
+ DependencyTypes.Add(targetType);
+
+ DependencyImplementations[targetType] = new DependencyData { ImplementorType = implementorType };
+ }
+
+ static Type FindImplementor(Type target)
+ {
+ return DependencyTypes.FirstOrDefault(t => target.IsAssignableFrom(t));
+ }
+
+ static void Initialize()
+ {
+ if (s_initialized)
+ {
+ return;
+ }
+
+ Assembly[] assemblies = Device.GetAssemblies();
+ if (Tizen.NUI.Binding.Internals.Registrar.ExtraAssemblies != null)
+ {
+ assemblies = assemblies.Union(Tizen.NUI.Binding.Internals.Registrar.ExtraAssemblies).ToArray();
+ }
+
+ Initialize(assemblies);
+ }
+
+ internal static void Initialize(Assembly[] assemblies)
+ {
+ if (s_initialized || assemblies == null)
+ {
+ return;
+ }
+ DependencyService.Register<IValueConverterProvider, ValueConverterProvider>();
+
+ Type targetAttrType = typeof(DependencyAttribute);
+
+ // Don't use LINQ for performance reasons
+ // Naive implementation can easily take over a second to run
+ foreach (Assembly assembly in assemblies)
+ {
+ Attribute[] attributes;
+ try
+ {
+ attributes = assembly.GetCustomAttributes(targetAttrType).ToArray();
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ // Sometimes the previewer doesn't actually have everything required for these loads to work
+ Console.WriteLine(nameof(Registrar), "Could not load assembly: {0} for Attibute {1} | Some renderers may not be loaded", assembly.FullName, targetAttrType.FullName);
+ continue;
+ }
+
+ if (attributes.Length == 0)
+ continue;
+
+ foreach (DependencyAttribute attribute in attributes)
+ {
+ if (!DependencyTypes.Contains(attribute.Implementor))
+ {
+ DependencyTypes.Add(attribute.Implementor);
+ }
+ }
+ }
+
+ s_initialized = true;
+ }
+
+ class DependencyData
+ {
+ public object GlobalInstance { get; set; }
+
+ public Type ImplementorType { get; set; }
+ }
+ }
}
\ No newline at end of file
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
public const string macOS = "macOS";
public const string GTK = "GTK";
public const string Tizen = "Tizen";
- public const string WPF = "WPF";
+ public const string WPF = "WPF";
[EditorBrowsable(EditorBrowsableState.Never)]
public static DeviceInfo info;
public static void SetIdiom(TargetIdiom value) => Idiom = value;
public static TargetIdiom Idiom { get; internal set; }
- //TODO: Why are there two of these? This is never used...?
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void SetTargetIdiom(TargetIdiom value) => Idiom = value;
+ //TODO: Why are there two of these? This is never used...?
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void SetTargetIdiom(TargetIdiom value) => Idiom = value;
[Obsolete("TargetPlatform is obsolete as of version 2.3.4. Please use RuntimePlatform instead.")]
#pragma warning disable 0618
}
#pragma warning restore 0618
- public static string RuntimePlatform => PlatformServices?.RuntimePlatform;
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static DeviceInfo Info
- {
- get
- {
- // if (info == null)
- // throw new InvalidOperationException("You MUST call Xamarin.Forms.Init(); prior to using it.");
- return info;
- }
- set { info = value; }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void SetFlowDirection(FlowDirection value) => FlowDirection = value;
- public static FlowDirection FlowDirection { get; internal set; }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static bool IsInvokeRequired
- {
- get { return PlatformServices.IsInvokeRequired; }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static IPlatformServices PlatformServices
- {
- get
- {
- // if (s_platformServices == null)
- // throw new InvalidOperationException("You MUST call Tizen.NUI.Init(); prior to using it.");
- return s_platformServices;
- }
- set { s_platformServices = value; }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static IReadOnlyList<string> Flags { get; private set; }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void SetFlags(IReadOnlyList<string> flags)
- {
- Flags = flags;
- }
-
- public static void BeginInvokeOnMainThread(Action action)
- {
- PlatformServices?.BeginInvokeOnMainThread(action);
- }
-
- public static double GetNamedSize(NamedSize size, Element targetElement)
+ public static string RuntimePlatform => PlatformServices?.RuntimePlatform;
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static DeviceInfo Info
{
- return GetNamedSize(size, targetElement.GetType());
+ get
+ {
+ // if (info == null)
+ // throw new InvalidOperationException("You MUST call Xamarin.Forms.Init(); prior to using it.");
+ return info;
+ }
+ set { info = value; }
}
- public static double GetNamedSize(NamedSize size, Type targetElementType)
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void SetFlowDirection(FlowDirection value) => FlowDirection = value;
+ public static FlowDirection FlowDirection { get; internal set; }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static bool IsInvokeRequired
{
- return GetNamedSize(size, targetElementType, false);
+ get { return PlatformServices.IsInvokeRequired; }
}
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static IPlatformServices PlatformServices
+ {
+ get
+ {
+ if (s_platformServices == null)
+ throw new InvalidOperationException("You MUST call Tizen.NUI.Init(); prior to using it.");
+ return s_platformServices;
+ }
+ set
+ {
+ s_platformServices = value;
+ Console.WriteLine("Device s_platformServices : " + s_platformServices );
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static IReadOnlyList<string> Flags { get; private set; }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void SetFlags(IReadOnlyList<string> flags)
+ {
+ Flags = flags;
+ }
+
+ public static void BeginInvokeOnMainThread(Action action)
+ {
+ PlatformServices?.BeginInvokeOnMainThread(action);
+ action();
+ Console.WriteLine("Device BeginInvokeOnMainThread action called");
+ }
+
+ // public static double GetNamedSize(NamedSize size, Element targetElement)
+ // {
+ // return GetNamedSize(size, targetElement.GetType());
+ // }
+
+ // public static double GetNamedSize(NamedSize size, Type targetElementType)
+ // {
+ // return GetNamedSize(size, targetElementType, false);
+ // }
+
[Obsolete("OnPlatform is obsolete as of version 2.3.4. Please use switch(RuntimePlatform) instead.")]
public static void OnPlatform(Action iOS = null, Action Android = null, Action WinPhone = null, Action Default = null)
{
public static void OpenUri(Uri uri)
{
- PlatformServices?.OpenUriAction(uri);
+ // PlatformServices?.OpenUriAction(uri);
}
public static void StartTimer(TimeSpan interval, Func<bool> callback)
{
- PlatformServices?.StartTimer(interval, callback);
+ PlatformServices.StartTimer(interval, callback);
}
[EditorBrowsable(EditorBrowsableState.Never)]
return PlatformServices?.GetAssemblies();
}
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes)
- {
- return PlatformServices.GetNamedSize(size, targetElementType, useOldSizes);
- }
+ // [EditorBrowsable(EditorBrowsableState.Never)]
+ // public static double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes)
+ // {
+ // return PlatformServices.GetNamedSize(size, targetElementType, useOldSizes);
+ // }
internal static Task<Stream> GetStreamAsync(Uri uri, CancellationToken cancellationToken)
{
{
public static readonly string TitleStyleKey = "TitleStyle";
- public static readonly string SubtitleStyleKey = "SubtitleStyle";
+ public static readonly string SubtitleStyleKey = "SubtitleStyle";
- public static readonly string BodyStyleKey = "BodyStyle";
+ public static readonly string BodyStyleKey = "BodyStyle";
- public static readonly string ListItemTextStyleKey = "ListItemTextStyle";
+ public static readonly string ListItemTextStyleKey = "ListItemTextStyle";
- public static readonly string ListItemDetailTextStyleKey = "ListItemDetailTextStyle";
+ public static readonly string ListItemDetailTextStyleKey = "ListItemDetailTextStyle";
- public static readonly string CaptionStyleKey = "CaptionStyle";
+ public static readonly string CaptionStyleKey = "CaptionStyle";
- public static readonly Style TitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = TitleStyleKey };
+ public static readonly Style TitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = TitleStyleKey };
- public static readonly Style SubtitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = SubtitleStyleKey };
+ public static readonly Style SubtitleStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = SubtitleStyleKey };
- public static readonly Style BodyStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = BodyStyleKey };
+ public static readonly Style BodyStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = BodyStyleKey };
- public static readonly Style ListItemTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemTextStyleKey };
+ public static readonly Style ListItemTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemTextStyleKey };
- public static readonly Style ListItemDetailTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemDetailTextStyleKey };
+ public static readonly Style ListItemDetailTextStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = ListItemDetailTextStyleKey };
- public static readonly Style CaptionStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = CaptionStyleKey };
- }
- }
+ public static readonly Style CaptionStyle = new Style(typeof(Tizen.NUI.BaseComponents.TextLabel)) { BaseResourceKey = CaptionStyleKey };
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal abstract class DeviceInfo : INotifyPropertyChanged, IDisposable
- {
- DeviceOrientation _currentOrientation;
- bool _disposed;
-
- public DeviceOrientation CurrentOrientation
- {
- get { return _currentOrientation; }
- set
- {
- if (Equals(_currentOrientation, value))
- return;
- _currentOrientation = value;
- OnPropertyChanged();
- }
- }
-
- public virtual double DisplayRound(double value) =>
- Math.Round(value);
-
- public abstract Size PixelScreenSize { get; }
-
- public abstract Size ScaledScreenSize { get; }
-
- public abstract double ScalingFactor { get; }
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- protected virtual void Dispose(bool disposing)
- {
- if (_disposed)
- return;
- _disposed = true;
- }
-
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal abstract class DeviceInfo : INotifyPropertyChanged, IDisposable
+ {
+ DeviceOrientation _currentOrientation;
+ bool _disposed;
+
+ public DeviceOrientation CurrentOrientation
+ {
+ get { return _currentOrientation; }
+ set
+ {
+ if (Equals(_currentOrientation, value))
+ return;
+ _currentOrientation = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public virtual double DisplayRound(double value) =>
+ Math.Round(value);
+
+ public abstract Size PixelScreenSize { get; }
+
+ public abstract Size ScaledScreenSize { get; }
+
+ public abstract double ScalingFactor { get; }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ }
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (_disposed)
+ return;
+ _disposed = true;
+ }
+
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
}
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal enum DeviceOrientation
- {
- Portrait,
- Landscape,
- PortraitUp,
- PortraitDown,
- LandscapeLeft,
- LandscapeRight,
- Other
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal enum DeviceOrientation
+ {
+ Portrait,
+ Landscape,
+ PortraitUp,
+ PortraitDown,
+ LandscapeLeft,
+ LandscapeRight,
+ Other
+ }
}
--- /dev/null
+using System;
+using System.ComponentModel;
+using Tizen.NUI.Binding.Internals;
+
+namespace Tizen.NUI.Binding
+{
+ /// <summary>
+ /// A collection of styles and properties that can be added to an element at run time.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal abstract class Effect
+ {
+ internal Effect()
+ {
+ }
+
+ /// <summary>
+ /// Gets the element to which the style is attached.
+ /// </summary>
+ public Element Element { get; internal set; }
+
+ /// <summary>
+ /// Gets a value that tells whether the effect is attached to an element.
+ /// </summary>
+ public bool IsAttached { get; private set; }
+
+ /// <summary>
+ /// Gets the ID that is used to resolve this effect at runtime.
+ /// </summary>
+ public string ResolveId { get; internal set; }
+
+ #region Statics
+ /// <summary>
+ /// Returns an Effect for the specified name, which is of the form ResolutionGroupName.ExportEffect.
+ /// </summary>
+ /// <param name="name">The name of the effect to get.</param>
+ /// <returns>The uniquely identified effect.</returns>
+ public static Effect Resolve(string name)
+ {
+ Effect result = null;
+ if (Tizen.NUI.Binding.Internals.Registrar.Effects.TryGetValue(name, out Type effectType))
+ {
+ result = (Effect)DependencyResolver.ResolveOrCreate(effectType);
+ }
+
+ if (result == null)
+ result = new NullEffect();
+ result.ResolveId = name;
+ return result;
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Method that is called after the effect is attached and made valid.
+ /// </summary>
+ protected abstract void OnAttached();
+
+ /// <summary>
+ /// Method that is called after the effect is detached and invalidated.
+ /// </summary>
+ protected abstract void OnDetached();
+
+ internal virtual void ClearEffect()
+ {
+ if (IsAttached)
+ SendDetached();
+ Element = null;
+ }
+
+ internal virtual void SendAttached()
+ {
+ if (IsAttached)
+ return;
+ OnAttached();
+ IsAttached = true;
+ }
+
+ internal virtual void SendDetached()
+ {
+ if (!IsAttached)
+ return;
+ OnDetached();
+ IsAttached = false;
+ }
+
+ internal virtual void SendOnElementPropertyChanged(PropertyChangedEventArgs args)
+ {
+ }
+ }
+}
namespace Tizen.NUI.Binding
{
- [Flags]
- internal enum EffectiveFlowDirection
- {
- RightToLeft = 1 << 0,
- Explicit = 1 << 1,
- }
+ [Flags]
+ internal enum EffectiveFlowDirection
+ {
+ RightToLeft = 1 << 0,
+ Explicit = 1 << 1,
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal static class EffectiveFlowDirectionExtensions
- {
- internal static EffectiveFlowDirection ToEffectiveFlowDirection(this FlowDirection self, bool isExplicit = false)
- {
- switch (self)
- {
- case FlowDirection.MatchParent:
- return default(EffectiveFlowDirection);
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal static class EffectiveFlowDirectionExtensions
+ {
+ internal static EffectiveFlowDirection ToEffectiveFlowDirection(this FlowDirection self, bool isExplicit = false)
+ {
+ switch (self)
+ {
+ case FlowDirection.MatchParent:
+ return default(EffectiveFlowDirection);
- case FlowDirection.LeftToRight:
- if (isExplicit)
- {
- return EffectiveFlowDirection.Explicit;
- }
- else
- {
- return default(EffectiveFlowDirection);
- }
+ case FlowDirection.LeftToRight:
+ if (isExplicit)
+ {
+ return EffectiveFlowDirection.Explicit;
+ }
+ else
+ {
+ return default(EffectiveFlowDirection);
+ }
- case FlowDirection.RightToLeft:
- if (isExplicit)
- {
- return EffectiveFlowDirection.RightToLeft | EffectiveFlowDirection.Explicit;
- }
- else
- {
- return EffectiveFlowDirection.RightToLeft;
- }
+ case FlowDirection.RightToLeft:
+ if (isExplicit)
+ {
+ return EffectiveFlowDirection.RightToLeft | EffectiveFlowDirection.Explicit;
+ }
+ else
+ {
+ return EffectiveFlowDirection.RightToLeft;
+ }
- default:
- throw new InvalidOperationException($"Cannot convert {self} to {nameof(EffectiveFlowDirection)}.");
- }
- }
+ default:
+ throw new InvalidOperationException($"Cannot convert {self} to {nameof(EffectiveFlowDirection)}.");
+ }
+ }
- internal static FlowDirection ToFlowDirection(this EffectiveFlowDirection self)
- {
- if (self.IsLeftToRight())
- return FlowDirection.LeftToRight;
- else
- return FlowDirection.RightToLeft;
+ internal static FlowDirection ToFlowDirection(this EffectiveFlowDirection self)
+ {
+ if (self.IsLeftToRight())
+ return FlowDirection.LeftToRight;
+ else
+ return FlowDirection.RightToLeft;
- throw new InvalidOperationException($"Cannot convert {self} to {nameof(FlowDirection)}.");
- }
+ throw new InvalidOperationException($"Cannot convert {self} to {nameof(FlowDirection)}.");
+ }
- public static bool IsRightToLeft(this EffectiveFlowDirection self)
- {
- return (self & EffectiveFlowDirection.RightToLeft) == EffectiveFlowDirection.RightToLeft;
- }
+ public static bool IsRightToLeft(this EffectiveFlowDirection self)
+ {
+ return (self & EffectiveFlowDirection.RightToLeft) == EffectiveFlowDirection.RightToLeft;
+ }
- public static bool IsLeftToRight(this EffectiveFlowDirection self)
- {
- return (self & EffectiveFlowDirection.RightToLeft) != EffectiveFlowDirection.RightToLeft;
- }
+ public static bool IsLeftToRight(this EffectiveFlowDirection self)
+ {
+ return (self & EffectiveFlowDirection.RightToLeft) != EffectiveFlowDirection.RightToLeft;
+ }
- public static bool IsImplicit(this EffectiveFlowDirection self)
- {
- return (self & EffectiveFlowDirection.Explicit) != EffectiveFlowDirection.Explicit;
- }
+ public static bool IsImplicit(this EffectiveFlowDirection self)
+ {
+ return (self & EffectiveFlowDirection.Explicit) != EffectiveFlowDirection.Explicit;
+ }
- public static bool IsExplicit(this EffectiveFlowDirection self)
- {
- return (self & EffectiveFlowDirection.Explicit) == EffectiveFlowDirection.Explicit;
- }
- }
+ public static bool IsExplicit(this EffectiveFlowDirection self)
+ {
+ return (self & EffectiveFlowDirection.Explicit) == EffectiveFlowDirection.Explicit;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class ElementCollection<T> : ObservableWrapper<Element, T> where T : Element
- {
- public ElementCollection(ObservableCollection<Element> list) : base(list)
- {
- }
- }
+ internal class ElementCollection<T> : ObservableWrapper<Element, T> where T : Element
+ {
+ public ElementCollection(ObservableCollection<Element> list) : base(list)
+ {
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class ElementEventArgs : EventArgs
- {
- public ElementEventArgs(Element element)
- {
- if (element == null)
- throw new ArgumentNullException("element");
+ internal class ElementEventArgs : EventArgs
+ {
+ public ElementEventArgs(Element element)
+ {
+ if (element == null)
+ throw new ArgumentNullException("element");
- Element = element;
- }
+ Element = element;
+ }
- public Element Element { get; private set; }
- }
+ public Element Element { get; private set; }
+ }
}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using Tizen.NUI.Binding.Internals;
+
+namespace Tizen.NUI.Binding
+{
+ /// <summary>
+ /// Base class for DataTemplate and ControlTemplate classes.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class ElementTemplate : IElement, IDataTemplate
+ {
+ List<Action<object, ResourcesChangedEventArgs>> _changeHandlers;
+ Element _parent;
+ bool _canRecycle; // aka IsDeclarative
+
+ internal ElementTemplate()
+ {
+ }
+
+ internal ElementTemplate(Type type) : this()
+ {
+ if (type == null)
+ throw new ArgumentNullException("type");
+
+ _canRecycle = true;
+
+ LoadTemplate = () => Activator.CreateInstance(type);
+ }
+
+ internal ElementTemplate(Func<object> loadTemplate) : this()
+ {
+ if (loadTemplate == null)
+ throw new ArgumentNullException("loadTemplate");
+
+ LoadTemplate = loadTemplate;
+ }
+
+ Func<object> LoadTemplate { get; set; }
+
+#pragma warning disable 0612
+ Func<object> IDataTemplate.LoadTemplate
+ {
+ get { return LoadTemplate; }
+ set { LoadTemplate = value; }
+ }
+#pragma warning restore 0612
+
+ void IElement.AddResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged)
+ {
+ _changeHandlers = _changeHandlers ?? new List<Action<object, ResourcesChangedEventArgs>>(1);
+ _changeHandlers.Add(onchanged);
+ }
+
+ internal bool CanRecycle => _canRecycle;
+ Element IElement.Parent
+ {
+ get { return _parent; }
+ set
+ {
+ if (_parent == value)
+ return;
+ if (_parent != null)
+ ((IElement)_parent).RemoveResourcesChangedListener(OnResourcesChanged);
+ _parent = value;
+ if (_parent != null)
+ ((IElement)_parent).AddResourcesChangedListener(OnResourcesChanged);
+ }
+ }
+
+ void IElement.RemoveResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged)
+ {
+ if (_changeHandlers == null)
+ return;
+ _changeHandlers.Remove(onchanged);
+ }
+
+ /// <summary>
+ /// Used by the XAML infrastructure to load data templates and set up the content of the resulting UI.
+ /// </summary>
+ /// <returns></returns>
+ public object CreateContent()
+ {
+ if (LoadTemplate == null)
+ throw new InvalidOperationException("LoadTemplate should not be null");
+ if (this is DataTemplateSelector)
+ throw new InvalidOperationException("Cannot call CreateContent directly on a DataTemplateSelector");
+
+ object item = LoadTemplate();
+ SetupContent(item);
+
+ return item;
+ }
+
+ internal virtual void SetupContent(object item)
+ {
+ }
+
+ void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
+ {
+ if (_changeHandlers == null)
+ return;
+ foreach (Action<object, ResourcesChangedEventArgs> handler in _changeHandlers)
+ handler(this, e);
+ }
+ }
+}
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal static class EnumerableExtensions
- {
- public static IEnumerable<T> GetGesturesFor<T>(this IEnumerable<IGestureRecognizer> gestures, Func<T, bool> predicate = null) where T : GestureRecognizer
- {
- if (gestures == null)
- yield break;
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal static class EnumerableExtensions
+ {
+ public static IEnumerable<T> GetGesturesFor<T>(this IEnumerable<IGestureRecognizer> gestures, Func<T, bool> predicate = null) where T : GestureRecognizer
+ {
+ if (gestures == null)
+ yield break;
- if (predicate == null)
- predicate = x => true;
+ if (predicate == null)
+ predicate = x => true;
- foreach (IGestureRecognizer item in gestures)
- {
- var gesture = item as T;
- if (gesture != null && predicate(gesture))
- {
- yield return gesture;
- }
- }
- }
+ foreach (IGestureRecognizer item in gestures)
+ {
+ var gesture = item as T;
+ if (gesture != null && predicate(gesture))
+ {
+ yield return gesture;
+ }
+ }
+ }
- internal static IEnumerable<T> Append<T>(this IEnumerable<T> enumerable, T item)
- {
- foreach (T x in enumerable)
- yield return x;
+ internal static IEnumerable<T> Append<T>(this IEnumerable<T> enumerable, T item)
+ {
+ foreach (T x in enumerable)
+ yield return x;
- yield return item;
- }
+ yield return item;
+ }
- public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action)
- {
- foreach (T item in enumeration)
- {
- action(item);
- }
- }
+ public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action)
+ {
+ foreach (T item in enumeration)
+ {
+ action(item);
+ }
+ }
- public static int IndexOf<T>(this IEnumerable<T> enumerable, T item)
- {
- if (enumerable == null)
- throw new ArgumentNullException("enumerable");
+ public static int IndexOf<T>(this IEnumerable<T> enumerable, T item)
+ {
+ if (enumerable == null)
+ throw new ArgumentNullException("enumerable");
- var i = 0;
- foreach (T element in enumerable)
- {
- if (Equals(element, item))
- return i;
+ var i = 0;
+ foreach (T element in enumerable)
+ {
+ if (Equals(element, item))
+ return i;
- i++;
- }
+ i++;
+ }
- return -1;
- }
+ return -1;
+ }
- public static int IndexOf<T>(this IEnumerable<T> enumerable, Func<T, bool> predicate)
- {
- var i = 0;
- foreach (T element in enumerable)
- {
- if (predicate(element))
- return i;
+ public static int IndexOf<T>(this IEnumerable<T> enumerable, Func<T, bool> predicate)
+ {
+ var i = 0;
+ foreach (T element in enumerable)
+ {
+ if (predicate(element))
+ return i;
- i++;
- }
+ i++;
+ }
- return -1;
- }
+ return -1;
+ }
- public static IEnumerable<T> Prepend<T>(this IEnumerable<T> enumerable, T item)
- {
- yield return item;
+ public static IEnumerable<T> Prepend<T>(this IEnumerable<T> enumerable, T item)
+ {
+ yield return item;
- foreach (T x in enumerable)
- yield return x;
- }
- }
+ foreach (T x in enumerable)
+ yield return x;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal class EventArg<T> : EventArgs
- {
- // Property variable
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class EventArg<T> : EventArgs
+ {
+ // Property variable
- // Constructor
- public EventArg(T data)
- {
- Data = data;
- }
+ // Constructor
+ public EventArg(T data)
+ {
+ Data = data;
+ }
- // Property for EventArgs argument
- public T Data { get; }
- }
+ // Property for EventArgs argument
+ public T Data { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
- internal class ExportEffectAttribute : Attribute
- {
- public ExportEffectAttribute(Type effectType, string uniqueName)
- {
- if (uniqueName.Contains("."))
- throw new ArgumentException("uniqueName must not contain a .");
- Type = effectType;
- Id = uniqueName;
- }
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+ internal class ExportEffectAttribute : Attribute
+ {
+ public ExportEffectAttribute(Type effectType, string uniqueName)
+ {
+ if (uniqueName.Contains("."))
+ throw new ArgumentException("uniqueName must not contain a .");
+ Type = effectType;
+ Id = uniqueName;
+ }
- internal string Id { get; private set; }
+ internal string Id { get; private set; }
- internal Type Type { get; private set; }
- }
+ internal Type Type { get; private set; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [TypeConverter(typeof(FileImageSourceConverter))]
- internal sealed class FileImageSource : ImageSource
- {
- public static readonly BindableProperty FileProperty = BindableProperty.Create("File", typeof(string), typeof(FileImageSource), default(string));
+ [TypeConverter(typeof(FileImageSourceConverter))]
+ internal sealed class FileImageSource : ImageSource
+ {
+ public static readonly BindableProperty FileProperty = BindableProperty.Create("File", typeof(string), typeof(FileImageSource), default(string));
- public string File
- {
- get { return (string)GetValue(FileProperty); }
- set { SetValue(FileProperty, value); }
- }
+ public string File
+ {
+ get { return (string)GetValue(FileProperty); }
+ set { SetValue(FileProperty, value); }
+ }
- public override Task<bool> Cancel()
- {
- return Task.FromResult(false);
- }
+ public override Task<bool> Cancel()
+ {
+ return Task.FromResult(false);
+ }
- public override string ToString()
- {
- return $"File: {File}";
- }
+ public override string ToString()
+ {
+ return $"File: {File}";
+ }
- public static implicit operator FileImageSource(string file)
- {
- return (FileImageSource)FromFile(file);
- }
+ public static implicit operator FileImageSource(string file)
+ {
+ return (FileImageSource)FromFile(file);
+ }
- public static implicit operator string(FileImageSource file)
- {
- return file != null ? file.File : null;
- }
+ public static implicit operator string(FileImageSource file)
+ {
+ return file != null ? file.File : null;
+ }
- protected override void OnPropertyChanged(string propertyName = null)
- {
- if (propertyName == FileProperty.PropertyName)
- OnSourceChanged();
- base.OnPropertyChanged(propertyName);
- }
- }
+ protected override void OnPropertyChanged(string propertyName = null)
+ {
+ if (propertyName == FileProperty.PropertyName)
+ OnSourceChanged();
+ base.OnPropertyChanged(propertyName);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [Xaml.TypeConversion(typeof(FileImageSource))]
- internal sealed class FileImageSourceConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- if (value != null)
- return (FileImageSource)ImageSource.FromFile(value);
+ [Xaml.TypeConversion(typeof(FileImageSource))]
+ internal sealed class FileImageSourceConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (value != null)
+ return (FileImageSource)ImageSource.FromFile(value);
- throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(FileImageSource)));
- }
- }
+ throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(FileImageSource)));
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [TypeConverter(typeof(FlowDirectionConverter))]
- internal enum FlowDirection
- {
- MatchParent = 0,
- LeftToRight = 1,
- RightToLeft = 2,
- }
+ [TypeConverter(typeof(FlowDirectionConverter))]
+ internal enum FlowDirection
+ {
+ MatchParent = 0,
+ LeftToRight = 1,
+ RightToLeft = 2,
+ }
- [Xaml.TypeConversion(typeof(FlowDirection))]
- internal class FlowDirectionConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- if (value != null) {
- if (Enum.TryParse(value, out FlowDirection direction))
- return direction;
+ [Xaml.TypeConversion(typeof(FlowDirection))]
+ internal class FlowDirectionConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (value != null) {
+ if (Enum.TryParse(value, out FlowDirection direction))
+ return direction;
- if (value.Equals("ltr", StringComparison.OrdinalIgnoreCase))
- return FlowDirection.LeftToRight;
- if (value.Equals("rtl", StringComparison.OrdinalIgnoreCase))
- return FlowDirection.RightToLeft;
- if (value.Equals("inherit", StringComparison.OrdinalIgnoreCase))
- return FlowDirection.MatchParent;
- }
- throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(FlowDirection)));
- }
- }
+ if (value.Equals("ltr", StringComparison.OrdinalIgnoreCase))
+ return FlowDirection.LeftToRight;
+ if (value.Equals("rtl", StringComparison.OrdinalIgnoreCase))
+ return FlowDirection.RightToLeft;
+ if (value.Equals("inherit", StringComparison.OrdinalIgnoreCase))
+ return FlowDirection.MatchParent;
+ }
+ throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(FlowDirection)));
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class GestureRecognizer : Element, IGestureRecognizer
- {
- internal GestureRecognizer()
- {
- }
- }
+ internal class GestureRecognizer : Element, IGestureRecognizer
+ {
+ internal GestureRecognizer()
+ {
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
- internal abstract class HandlerAttribute : Attribute
- {
- protected HandlerAttribute(Type handler, Type target)
- {
- TargetType = target;
- HandlerType = handler;
- }
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+ internal abstract class HandlerAttribute : Attribute
+ {
+ protected HandlerAttribute(Type handler, Type target)
+ {
+ TargetType = target;
+ HandlerType = handler;
+ }
- internal Type HandlerType { get; private set; }
+ internal Type HandlerType { get; private set; }
- internal Type TargetType { get; private set; }
+ internal Type TargetType { get; private set; }
- public virtual bool ShouldRegister()
- {
- return true;
- }
- }
+ public virtual bool ShouldRegister()
+ {
+ return true;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IAppIndexingProvider
- {
- IAppLinks AppLinks { get; }
- }
+ internal interface IAppIndexingProvider
+ {
+ IAppLinks AppLinks { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IAppLinkEntry
- {
- Uri AppLinkUri { get; set; }
+ internal interface IAppLinkEntry
+ {
+ Uri AppLinkUri { get; set; }
- string Description { get; set; }
+ string Description { get; set; }
- bool IsLinkActive { get; set; }
+ bool IsLinkActive { get; set; }
- IDictionary<string, string> KeyValues { get; }
+ IDictionary<string, string> KeyValues { get; }
- ImageSource Thumbnail { get; set; }
+ ImageSource Thumbnail { get; set; }
- string Title { get; set; }
- }
+ string Title { get; set; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IAppLinks
- {
- void DeregisterLink(IAppLinkEntry appLink);
- void DeregisterLink(Uri appLinkUri);
- void RegisterLink(IAppLinkEntry appLink);
- }
+ internal interface IAppLinks
+ {
+ void DeregisterLink(IAppLinkEntry appLink);
+ void DeregisterLink(Uri appLinkUri);
+ void RegisterLink(IAppLinkEntry appLink);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IApplicationController
- {
- void SetAppIndexingProvider(IAppIndexingProvider appIndexing);
- }
+ internal interface IApplicationController
+ {
+ void SetAppIndexingProvider(IAppIndexingProvider appIndexing);
+ }
}
\ No newline at end of file
/// </summary>
/// <typeparam name="T"></typeparam>
[EditorBrowsable(EditorBrowsableState.Never)]
- public interface IConfigElement<out T> where T : Element
- {
+ internal interface IConfigElement<out T> where T : Element
+ {
/// <summary>
/// For internal use
/// </summary>
- T Element { get; }
- }
+ T Element { get; }
+ }
}
/// Base interface for marker classes that identify target platforms for platform specific effects.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public interface IConfigPlatform { }
+ internal interface IConfigPlatform { }
}
namespace Tizen.NUI.Binding
{
- internal interface IControlTemplated
- {
- ControlTemplate ControlTemplate { get; set; }
+ internal interface IControlTemplated
+ {
+ // ControlTemplate ControlTemplate { get; set; }
- IList<Element> InternalChildren { get; }
+ IList<Element> InternalChildren { get; }
- void OnControlTemplateChanged(ControlTemplate oldValue, ControlTemplate newValue);
- }
+ void OnControlTemplateChanged(ControlTemplate oldValue, ControlTemplate newValue);
+ }
}
/// When implemented in a renderer, registers a platform-specific effect on an element.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public interface IEffectControlProvider
- {
+ internal interface IEffectControlProvider
+ {
/// <summary>
/// Registers the effect with the element by establishing the parent-child relations needed for rendering on the specific platform.
/// </summary>
/// <param name="effect">The effect to register.</param>
- void RegisterEffect(Effect effect);
- }
+ void RegisterEffect(Effect effect);
+ }
}
using System;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- internal interface IElement
- {
- Element Parent { get; set; }
+ internal interface IElement
+ {
+ Element Parent { get; set; }
- //Use these 2 instead of an event to avoid cloning way too much multicastdelegates on mono
- void AddResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged);
- void RemoveResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged);
- }
+ //Use these 2 instead of an event to avoid cloning way too much multicastdelegates on mono
+ void AddResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged);
+ void RemoveResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IElementConfiguration<out TElement> where TElement : Element
- {
- IPlatformElementConfiguration<T, TElement> On<T>() where T : IConfigPlatform;
- }
+ internal interface IElementConfiguration<out TElement> where TElement : Element
+ {
+ // IPlatformElementConfiguration<T, TElement> On<T>() where T : IConfigPlatform;
+ }
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- internal interface IElementController
- {
- IEffectControlProvider EffectControlProvider { get; set; }
+ internal interface IElementController
+ {
+ // IEffectControlProvider EffectControlProvider { get; set; }
- bool EffectIsAttached(string name);
+ // bool EffectIsAttached(string name);
- void SetValueFromRenderer(BindableProperty property, object value);
- void SetValueFromRenderer(BindablePropertyKey propertyKey, object value);
- ReadOnlyCollection<Element> LogicalChildren { get; }
- IPlatform Platform { get; set; }
- Element RealParent { get; }
- IEnumerable<Element> Descendants();
- event EventHandler PlatformSet;
- }
+ // void SetValueFromRenderer(BindableProperty property, object value);
+ // void SetValueFromRenderer(BindablePropertyKey propertyKey, object value);
+ // ReadOnlyCollection<Element> LogicalChildren { get; }
+ // IPlatform Platform { get; set; }
+ // Element RealParent { get; }
+ // IEnumerable<Element> Descendants();
+ // event EventHandler PlatformSet;
+ }
}
namespace Tizen.NUI.Binding
{
- internal interface IExtendedTypeConverter
- {
- [Obsolete("IExtendedTypeConverter.ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string, IServiceProvider) instead.")]
- object ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider);
+ internal interface IExtendedTypeConverter
+ {
+ [Obsolete("IExtendedTypeConverter.ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string, IServiceProvider) instead.")]
+ object ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider);
- object ConvertFromInvariantString(string value, IServiceProvider serviceProvider);
- }
+ object ConvertFromInvariantString(string value, IServiceProvider serviceProvider);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IGestureRecognizer : INotifyPropertyChanged
- {
- }
+ internal interface IGestureRecognizer : INotifyPropertyChanged
+ {
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal interface IIsolatedStorageFile
- {
- Task CreateDirectoryAsync(string path);
- Task<bool> GetDirectoryExistsAsync(string path);
- Task<bool> GetFileExistsAsync(string path);
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal interface IIsolatedStorageFile
+ {
+ Task CreateDirectoryAsync(string path);
+ Task<bool> GetDirectoryExistsAsync(string path);
+ Task<bool> GetFileExistsAsync(string path);
- Task<DateTimeOffset> GetLastWriteTimeAsync(string path);
+ Task<DateTimeOffset> GetLastWriteTimeAsync(string path);
- Task<Stream> OpenFileAsync(string path, FileMode mode, FileAccess access);
- Task<Stream> OpenFileAsync(string path, FileMode mode, FileAccess access, FileShare share);
- }
+ Task<Stream> OpenFileAsync(string path, FileMode mode, FileAccess access);
+ Task<Stream> OpenFileAsync(string path, FileMode mode, FileAccess access, FileShare share);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface ILayout
- {
- event EventHandler LayoutChanged;
- }
+ internal interface ILayout
+ {
+ event EventHandler LayoutChanged;
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface ILayoutController
- {
- IReadOnlyList<Element> Children { get; }
- }
+ internal interface ILayoutController
+ {
+ IReadOnlyList<Element> Children { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IMenuItemController
- {
- bool IsEnabled { get; set; }
- string IsEnabledPropertyName { get; }
+ internal interface IMenuItemController
+ {
+ bool IsEnabled { get; set; }
+ string IsEnabledPropertyName { get; }
- void Activate();
- }
+ void Activate();
+ }
}
namespace Tizen.NUI.Binding
{
- internal interface INativeBindingService
- {
- bool TrySetBinding(object target, string propertyName, BindingBase binding);
- bool TrySetBinding(object target, BindableProperty property, BindingBase binding);
- bool TrySetValue(object target, BindableProperty property, object value);
- }
+ internal interface INativeBindingService
+ {
+ bool TrySetBinding(object target, string propertyName, BindingBase binding);
+ bool TrySetBinding(object target, BindableProperty property, BindingBase binding);
+ bool TrySetValue(object target, BindableProperty property, object value);
+ }
}
\ No newline at end of file
/// Interface abstracting platform-specific navigation.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public interface INavigation
- {
+ internal interface INavigation
+ {
/// <summary>
/// Gets the modal navigation stack.
/// </summary>
/// <summary>
/// Gets the stack of pages in the navigation.
/// </summary>
- IReadOnlyList<Page> NavigationStack { get; }
+ IReadOnlyList<Page> NavigationStack { get; }
/// <summary>
/// Inserts a page in the navigation stack before an existing page in the stack.
/// </summary>
/// <param name="page">The page to add.</param>
/// <param name="before">The existing page, before which page will be inserted.</param>
- void InsertPageBefore(Page page, Page before);
+ void InsertPageBefore(Page page, Page before);
/// <summary>
/// Asynchronously removes the most recent Page from the navigation stack.
/// </summary>
/// <returns>The Page that had been at the top of the navigation stack.</returns>
- Task<Page> PopAsync();
+ Task<Page> PopAsync();
/// <summary>
/// Asynchronously removes the most recent Page from the navigation stack, with optional animation.
/// </summary>
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>The Page that had been at the top of the navigation stack.</returns>
- Task<Page> PopAsync(bool animated);
+ Task<Page> PopAsync(bool animated);
/// <summary>
/// Asynchronously dismisses the most recent modally presented Page.
/// </summary>
/// <returns>An awaitable instance, indicating the PopModalAsync completion. The Task.Result is the Page that has been popped.</returns>
- Task<Page> PopModalAsync();
+ Task<Page> PopModalAsync();
/// <summary>
/// Asynchronously dismisses the most recent modally presented Page, with optional animation.
/// </summary>
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>An awaitable, indicating the PopModalAsync completion. The Task.Result is the Page that has been popped.</returns>
- Task<Page> PopModalAsync(bool animated);
+ Task<Page> PopModalAsync(bool animated);
/// <summary>
/// Pops all but the root Page off the navigation stack.
/// </summary>
/// <returns>A task representing the asynchronous dismiss operation.</returns>
- Task PopToRootAsync();
+ Task PopToRootAsync();
/// <summary>
/// Pops all but the root Page off the navigation stack, with optional animation.
/// </summary>
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>A task representing the asynchronous dismiss operation.</returns>
- Task PopToRootAsync(bool animated);
+ Task PopToRootAsync(bool animated);
/// <summary>
/// Asynchronously adds a Page to the top of the navigation stack.
/// </summary>
/// <param name="page">The Page to be pushed on top of the navigation stack.</param>
/// <returns>A task that represents the asynchronous push operation.</returns>
- Task PushAsync(Page page);
+ Task PushAsync(Page page);
/// <summary>
/// Asynchronously adds a Page to the top of the navigation stack, with optional animation.
/// <param name="page">The page to push.</param>
/// <param name="animated">Whether to animate the push.</param>
/// <returns>A task that represents the asynchronous push operation.</returns>
- Task PushAsync(Page page, bool animated);
+ Task PushAsync(Page page, bool animated);
/// <summary>
/// Presents a Page modally.
/// </summary>
/// <param name="page">The Page to present modally.</param>
/// <returns>An awaitable Task, indicating the PushModal completion.</returns>
- Task PushModalAsync(Page page);
+ Task PushModalAsync(Page page);
/// <summary>
/// Presents a Page modally, with optional animation.
/// <param name="page">The page to push.</param>
/// <param name="animated">Whether to animate the push.</param>
/// <returns>An awaitable Task, indicating the PushModal completion.</returns>
- Task PushModalAsync(Page page, bool animated);
+ Task PushModalAsync(Page page, bool animated);
/// <summary>
/// Removes the specified page from the navigation stack.
/// </summary>
/// <param name="page">The page to remove.</param>
- void RemovePage(Page page);
- }
+ void RemovePage(Page page);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface INavigationMenuController : IViewController
- {
- void SendTargetSelected(Page target);
- }
+ internal interface INavigationMenuController : IViewController
+ {
+ void SendTargetSelected(Page target);
+ }
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- internal interface INavigationPageController
- {
- Task<Page> RemoveAsyncInner(Page page, bool animated, bool fast);
+ internal interface INavigationPageController
+ {
+ Task<Page> RemoveAsyncInner(Page page, bool animated, bool fast);
- Page Peek(int depth = 0);
+ Page Peek(int depth = 0);
- IEnumerable<Page> Pages { get; }
+ IEnumerable<Page> Pages { get; }
- int StackDepth { get; }
+ int StackDepth { get; }
- Task<Page> PopAsyncInner(bool animated, bool fast = false);
+ Task<Page> PopAsyncInner(bool animated, bool fast = false);
- event EventHandler<NavigationRequestedEventArgs> InsertPageBeforeRequested;
+ event EventHandler<NavigationRequestedEventArgs> InsertPageBeforeRequested;
- event EventHandler<NavigationRequestedEventArgs> PopRequested;
+ event EventHandler<NavigationRequestedEventArgs> PopRequested;
- event EventHandler<NavigationRequestedEventArgs> PopToRootRequested;
+ event EventHandler<NavigationRequestedEventArgs> PopToRootRequested;
- event EventHandler<NavigationRequestedEventArgs> PushRequested;
+ event EventHandler<NavigationRequestedEventArgs> PushRequested;
- event EventHandler<NavigationRequestedEventArgs> RemovePageRequested;
- }
+ event EventHandler<NavigationRequestedEventArgs> RemovePageRequested;
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- interface IPaddingElement
- {
- //note to implementor: implement this property publicly
- Thickness Padding { get; }
+ interface IPaddingElement
+ {
+ //note to implementor: implement this property publicly
+ // Thickness Padding { get; }
- //note to implementor: but implement this method explicitly
- void OnPaddingPropertyChanged(Thickness oldValue, Thickness newValue);
- Thickness PaddingDefaultValueCreator();
- }
+ //note to implementor: but implement this method explicitly
+ void OnPaddingPropertyChanged(Thickness oldValue, Thickness newValue);
+ Thickness PaddingDefaultValueCreator();
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IPageContainer<out T> where T : Page
- {
- T CurrentPage { get; }
- }
+ internal interface IPageContainer<out T> where T : Page
+ {
+ T CurrentPage { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IPageController
- {
- Rectangle ContainerArea { get; set; }
+ internal interface IPageController
+ {
+ Rectangle ContainerArea { get; set; }
- bool IgnoresContainerArea { get; set; }
+ bool IgnoresContainerArea { get; set; }
- ObservableCollection<Element> InternalChildren { get; }
+ ObservableCollection<Element> InternalChildren { get; }
- void SendAppearing();
+ void SendAppearing();
- void SendDisappearing();
- }
+ void SendDisappearing();
+ }
}
\ No newline at end of file
/// <summary>
/// For internal use.
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public interface IPlatform
- {
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal interface IPlatform
+ {
/// <summary>
/// Returns the native size.
/// </summary>
/// <param name="widthConstraint">The width constraint.</param>
/// <param name="heightConstraint">The height constraint.</param>
/// <returns>The native size.</returns>
- SizeRequest GetNativeSize(BaseHandle view, double widthConstraint, double heightConstraint);
- }
+ SizeRequest GetNativeSize(BaseHandle view, double widthConstraint, double heightConstraint);
+ }
}
/// <typeparam name="TPlatform">The platform type.</typeparam>
/// <typeparam name="TElement">The element type.</typeparam>
[EditorBrowsable(EditorBrowsableState.Never)]
- public interface IPlatformElementConfiguration<out TPlatform, out TElement> : IConfigElement<TElement>
- where TPlatform : IConfigPlatform
- where TElement : Element
- {
- }
+ internal interface IPlatformElementConfiguration<out TPlatform, out TElement> : IConfigElement<TElement>
+ where TPlatform : IConfigPlatform
+ where TElement : Element
+ {
+ }
}
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal interface IPlatformServices
- {
- bool IsInvokeRequired { get; }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal interface IPlatformServices
+ {
+ bool IsInvokeRequired { get; }
- void BeginInvokeOnMainThread(Action action);
+ void BeginInvokeOnMainThread(Action action);
- Ticker CreateTicker();
+ Ticker CreateTicker();
- Assembly[] GetAssemblies();
+ Assembly[] GetAssemblies();
- string GetMD5Hash(string input);
+ string GetMD5Hash(string input);
- double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes);
+ // double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes);
- Task<Stream> GetStreamAsync(Uri uri, CancellationToken cancellationToken);
+ Task<Stream> GetStreamAsync(Uri uri, CancellationToken cancellationToken);
- IIsolatedStorageFile GetUserStoreForApplication();
+ // IIsolatedStorageFile GetUserStoreForApplication();
- void OpenUriAction(Uri uri);
+ // void OpenUriAction(Uri uri);
- void StartTimer(TimeSpan interval, Func<bool> callback);
+ void StartTimer(TimeSpan interval, Func<bool> callback);
- string RuntimePlatform { get; }
+ string RuntimePlatform { get; }
- void QuitApplication();
- }
+ void QuitApplication();
+ }
}
namespace Tizen.NUI.Binding
{
- internal interface IRegisterable
- {
- }
+ internal interface IRegisterable
+ {
+ }
}
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal interface IResourceDictionary : IEnumerable<KeyValuePair<string, object>>
- {
- bool TryGetValue(string key, out object value);
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal interface IResourceDictionary : IEnumerable<KeyValuePair<string, object>>
+ {
+ bool TryGetValue(string key, out object value);
- event EventHandler<ResourcesChangedEventArgs> ValuesChanged;
- }
+ event EventHandler<ResourcesChangedEventArgs> ValuesChanged;
+ }
}
\ No newline at end of file
+++ /dev/null
-namespace Tizen.NUI.Binding
-{
- interface IResourcesProvider
- {
- bool IsResourcesCreated { get; }
- ResourceDictionary Resources { get; set; }
- }
-}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal interface ISystemResourcesProvider
- {
- IResourceDictionary GetSystemResources();
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal interface ISystemResourcesProvider
+ {
+ IResourceDictionary GetSystemResources();
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- //this will go once Timer is included in Pcl profiles
- internal interface ITimer
- {
- void Change(int dueTime, int period);
- void Change(long dueTime, long period);
- void Change(TimeSpan dueTime, TimeSpan period);
- void Change(uint dueTime, uint period);
- }
+ //this will go once Timer is included in Pcl profiles
+ internal interface ITimer
+ {
+ void Change(int dueTime, int period);
+ void Change(long dueTime, long period);
+ void Change(TimeSpan dueTime, TimeSpan period);
+ void Change(uint dueTime, uint period);
+ }
}
\ No newline at end of file
+++ /dev/null
-using System;
-using System.Globalization;
-
-namespace Tizen.NUI.Binding
-{
- internal interface IValueConverter
- {
- object Convert(object value, Type targetType, object parameter, CultureInfo culture);
- object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture);
- }
-}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IViewContainer<T> where T : /*VisualElement*/BaseHandle
- {
- IList<T> Children { get; }
- }
+ internal interface IViewContainer<T> where T : /*VisualElement*/BaseHandle
+ {
+ IList<T> Children { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IViewController : IVisualElementController
- {
- }
+ internal interface IViewController : IVisualElementController
+ {
+ }
}
\ No newline at end of file
using System;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- internal interface IVisualElementController : IElementController
- {
- void NativeSizeChanged();
- void InvalidateMeasure(InvalidationTrigger trigger);
- bool Batched { get; }
- bool DisableLayout { get; set; }
- EffectiveFlowDirection EffectiveFlowDirection { get; }
- bool IsInNativeLayout { get; set; }
- bool IsNativeStateConsistent { get; set; }
- bool IsPlatformEnabled { get; set; }
- NavigationProxy NavigationProxy { get; }
- event EventHandler<EventArg</*VisualElement*/BaseHandle>> BatchCommitted;
- event EventHandler<BaseHandle.FocusRequestArgs> FocusChangeRequested;
- }
+ internal interface IVisualElementController : IElementController
+ {
+ void NativeSizeChanged();
+ void InvalidateMeasure(InvalidationTrigger trigger);
+ bool Batched { get; }
+ bool DisableLayout { get; set; }
+ EffectiveFlowDirection EffectiveFlowDirection { get; }
+ bool IsInNativeLayout { get; set; }
+ bool IsNativeStateConsistent { get; set; }
+ bool IsPlatformEnabled { get; set; }
+ NavigationProxy NavigationProxy { get; }
+ event EventHandler<EventArg</*VisualElement*/BaseHandle>> BatchCommitted;
+ event EventHandler<BaseHandle.FocusRequestArgs> FocusChangeRequested;
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [TypeConverter(typeof(ImageSourceConverter))]
- internal abstract class ImageSource : Element
- {
- readonly object _synchandle = new object();
- CancellationTokenSource _cancellationTokenSource;
-
- TaskCompletionSource<bool> _completionSource;
-
- readonly WeakEventManager _weakEventManager = new WeakEventManager();
-
- protected ImageSource()
- {
- }
-
- protected CancellationTokenSource CancellationTokenSource
- {
- get { return _cancellationTokenSource; }
- private set
- {
- if (_cancellationTokenSource == value)
- return;
- if (_cancellationTokenSource != null)
- _cancellationTokenSource.Cancel();
- _cancellationTokenSource = value;
- }
- }
-
- bool IsLoading
- {
- get { return _cancellationTokenSource != null; }
- }
-
- public virtual Task<bool> Cancel()
- {
- if (!IsLoading)
- return Task.FromResult(false);
-
- var tcs = new TaskCompletionSource<bool>();
- TaskCompletionSource<bool> original = Interlocked.CompareExchange(ref _completionSource, tcs, null);
- if (original == null)
- {
- _cancellationTokenSource.Cancel();
- }
- else
- tcs = original;
-
- return tcs.Task;
- }
-
- public static ImageSource FromFile(string file)
- {
- return new FileImageSource { File = file };
- }
-
- public static ImageSource FromResource(string resource, Type resolvingType)
- {
- return FromResource(resource, resolvingType.GetTypeInfo().Assembly);
- }
-
- public static ImageSource FromResource(string resource, Assembly sourceAssembly = null)
- {
+ [TypeConverter(typeof(ImageSourceConverter))]
+ internal abstract class ImageSource : Element
+ {
+ readonly object _synchandle = new object();
+ CancellationTokenSource _cancellationTokenSource;
+
+ TaskCompletionSource<bool> _completionSource;
+
+ readonly WeakEventManager _weakEventManager = new WeakEventManager();
+
+ protected ImageSource()
+ {
+ }
+
+ protected CancellationTokenSource CancellationTokenSource
+ {
+ get { return _cancellationTokenSource; }
+ private set
+ {
+ if (_cancellationTokenSource == value)
+ return;
+ if (_cancellationTokenSource != null)
+ _cancellationTokenSource.Cancel();
+ _cancellationTokenSource = value;
+ }
+ }
+
+ bool IsLoading
+ {
+ get { return _cancellationTokenSource != null; }
+ }
+
+ public virtual Task<bool> Cancel()
+ {
+ if (!IsLoading)
+ return Task.FromResult(false);
+
+ var tcs = new TaskCompletionSource<bool>();
+ TaskCompletionSource<bool> original = Interlocked.CompareExchange(ref _completionSource, tcs, null);
+ if (original == null)
+ {
+ _cancellationTokenSource.Cancel();
+ }
+ else
+ tcs = original;
+
+ return tcs.Task;
+ }
+
+ public static ImageSource FromFile(string file)
+ {
+ return new FileImageSource { File = file };
+ }
+
+ public static ImageSource FromResource(string resource, Type resolvingType)
+ {
+ return FromResource(resource, resolvingType.GetTypeInfo().Assembly);
+ }
+
+ public static ImageSource FromResource(string resource, Assembly sourceAssembly = null)
+ {
#if NETSTANDARD2_0
- sourceAssembly = sourceAssembly ?? Assembly.GetCallingAssembly();
+ sourceAssembly = sourceAssembly ?? Assembly.GetCallingAssembly();
#else
- if (sourceAssembly == null)
- {
- MethodInfo callingAssemblyMethod = typeof(Assembly).GetTypeInfo().GetDeclaredMethod("GetCallingAssembly");
- if (callingAssemblyMethod != null)
- {
- sourceAssembly = (Assembly)callingAssemblyMethod.Invoke(null, new object[0]);
- }
- else
- {
- Internals.Log.Warning("Warning", "Can not find CallingAssembly, pass resolvingType to FromResource to ensure proper resolution");
- return null;
- }
- }
+ if (sourceAssembly == null)
+ {
+ MethodInfo callingAssemblyMethod = typeof(Assembly).GetTypeInfo().GetDeclaredMethod("GetCallingAssembly");
+ if (callingAssemblyMethod != null)
+ {
+ sourceAssembly = (Assembly)callingAssemblyMethod.Invoke(null, new object[0]);
+ }
+ else
+ {
+ Internals.Log.Warning("Warning", "Can not find CallingAssembly, pass resolvingType to FromResource to ensure proper resolution");
+ return null;
+ }
+ }
#endif
- return FromStream(() => sourceAssembly.GetManifestResourceStream(resource));
- }
-
- public static ImageSource FromStream(Func<Stream> stream)
- {
- // return new StreamImageSource { Stream = token => Task.Run(stream, token) };
- return null;
- }
-
- public static ImageSource FromUri(Uri uri)
- {
- if (!uri.IsAbsoluteUri)
- throw new ArgumentException("uri is relative");
- // return new UriImageSource { Uri = uri };
- return null;
- }
-
- public static implicit operator ImageSource(string source)
- {
- Uri uri;
- return Uri.TryCreate(source, UriKind.Absolute, out uri) && uri.Scheme != "file" ? FromUri(uri) : FromFile(source);
- }
-
- public static implicit operator ImageSource(Uri uri)
- {
- if (!uri.IsAbsoluteUri)
- throw new ArgumentException("uri is relative");
- return FromUri(uri);
- }
-
- protected void OnLoadingCompleted(bool cancelled)
- {
- if (!IsLoading || _completionSource == null)
- return;
-
- TaskCompletionSource<bool> tcs = Interlocked.Exchange(ref _completionSource, null);
- if (tcs != null)
- tcs.SetResult(cancelled);
-
- lock (_synchandle)
- {
- CancellationTokenSource = null;
- }
- }
-
- protected void OnLoadingStarted()
- {
- lock (_synchandle)
- {
- CancellationTokenSource = new CancellationTokenSource();
- }
- }
-
- protected void OnSourceChanged()
- {
- _weakEventManager.HandleEvent(this, EventArgs.Empty, nameof(SourceChanged));
- }
-
- internal event EventHandler SourceChanged
- {
- add { _weakEventManager.AddEventHandler(nameof(SourceChanged), value); }
- remove { _weakEventManager.RemoveEventHandler(nameof(SourceChanged), value); }
- }
- }
+ return FromStream(() => sourceAssembly.GetManifestResourceStream(resource));
+ }
+
+ public static ImageSource FromStream(Func<Stream> stream)
+ {
+ // return new StreamImageSource { Stream = token => Task.Run(stream, token) };
+ return null;
+ }
+
+ public static ImageSource FromUri(Uri uri)
+ {
+ if (!uri.IsAbsoluteUri)
+ throw new ArgumentException("uri is relative");
+ // return new UriImageSource { Uri = uri };
+ return null;
+ }
+
+ public static implicit operator ImageSource(string source)
+ {
+ Uri uri;
+ return Uri.TryCreate(source, UriKind.Absolute, out uri) && uri.Scheme != "file" ? FromUri(uri) : FromFile(source);
+ }
+
+ public static implicit operator ImageSource(Uri uri)
+ {
+ if (!uri.IsAbsoluteUri)
+ throw new ArgumentException("uri is relative");
+ return FromUri(uri);
+ }
+
+ protected void OnLoadingCompleted(bool cancelled)
+ {
+ if (!IsLoading || _completionSource == null)
+ return;
+
+ TaskCompletionSource<bool> tcs = Interlocked.Exchange(ref _completionSource, null);
+ if (tcs != null)
+ tcs.SetResult(cancelled);
+
+ lock (_synchandle)
+ {
+ CancellationTokenSource = null;
+ }
+ }
+
+ protected void OnLoadingStarted()
+ {
+ lock (_synchandle)
+ {
+ CancellationTokenSource = new CancellationTokenSource();
+ }
+ }
+
+ protected void OnSourceChanged()
+ {
+ _weakEventManager.HandleEvent(this, EventArgs.Empty, nameof(SourceChanged));
+ }
+
+ internal event EventHandler SourceChanged
+ {
+ add { _weakEventManager.AddEventHandler(nameof(SourceChanged), value); }
+ remove { _weakEventManager.RemoveEventHandler(nameof(SourceChanged), value); }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [Xaml.TypeConversion(typeof(ImageSource))]
- internal sealed class ImageSourceConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- if (value != null)
- {
- Uri uri;
- return Uri.TryCreate(value, UriKind.Absolute, out uri) && uri.Scheme != "file" ? ImageSource.FromUri(uri) : ImageSource.FromFile(value);
- }
+ [Xaml.TypeConversion(typeof(ImageSource))]
+ internal sealed class ImageSourceConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (value != null)
+ {
+ Uri uri;
+ return Uri.TryCreate(value, UriKind.Absolute, out uri) && uri.Scheme != "file" ? ImageSource.FromUri(uri) : ImageSource.FromFile(value);
+ }
- throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(ImageSource)));
- }
- }
+ throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(ImageSource)));
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class AttachedCollection<T> : ObservableCollection<T>, ICollection<T>, IAttachedObject where T : BindableObject, IAttachedObject
- {
- readonly List<WeakReference> _associatedObjects = new List<WeakReference>();
-
- public AttachedCollection()
- {
- }
-
- public AttachedCollection(IEnumerable<T> collection) : base(collection)
- {
- }
-
- public AttachedCollection(IList<T> list) : base(list)
- {
- }
-
- public void AttachTo(BindableObject bindable)
- {
- if (bindable == null)
- throw new ArgumentNullException("bindable");
- OnAttachedTo(bindable);
- }
-
- public void DetachFrom(BindableObject bindable)
- {
- OnDetachingFrom(bindable);
- }
-
- protected override void ClearItems()
- {
- foreach (WeakReference weakbindable in _associatedObjects)
- {
- foreach (T item in this)
- {
- var bindable = weakbindable.Target as BindableObject;
- if (bindable == null)
- continue;
- item.DetachFrom(bindable);
- }
- }
- base.ClearItems();
- }
-
- protected override void InsertItem(int index, T item)
- {
- base.InsertItem(index, item);
- foreach (WeakReference weakbindable in _associatedObjects)
- {
- var bindable = weakbindable.Target as BindableObject;
- if (bindable == null)
- continue;
- item.AttachTo(bindable);
- }
- }
-
- protected virtual void OnAttachedTo(BindableObject bindable)
- {
- lock (_associatedObjects)
- {
- _associatedObjects.Add(new WeakReference(bindable));
- }
- foreach (T item in this)
- item.AttachTo(bindable);
- }
-
- protected virtual void OnDetachingFrom(BindableObject bindable)
- {
- foreach (T item in this)
- item.DetachFrom(bindable);
- lock (_associatedObjects)
- {
- for (var i = 0; i < _associatedObjects.Count; i++)
- {
- object target = _associatedObjects[i].Target;
-
- if (target == null || target == bindable)
- {
- _associatedObjects.RemoveAt(i);
- i--;
- }
- }
- }
- }
-
- protected override void RemoveItem(int index)
- {
- T item = this[index];
- foreach (WeakReference weakbindable in _associatedObjects)
- {
- var bindable = weakbindable.Target as BindableObject;
- if (bindable == null)
- continue;
- item.DetachFrom(bindable);
- }
-
- base.RemoveItem(index);
- }
-
- protected override void SetItem(int index, T item)
- {
- T old = this[index];
- foreach (WeakReference weakbindable in _associatedObjects)
- {
- var bindable = weakbindable.Target as BindableObject;
- if (bindable == null)
- continue;
- old.DetachFrom(bindable);
- }
-
- base.SetItem(index, item);
-
- foreach (WeakReference weakbindable in _associatedObjects)
- {
- var bindable = weakbindable.Target as BindableObject;
- if (bindable == null)
- continue;
- item.AttachTo(bindable);
- }
- }
- }
+ internal class AttachedCollection<T> : ObservableCollection<T>, ICollection<T>, IAttachedObject where T : BindableObject, IAttachedObject
+ {
+ readonly List<WeakReference> _associatedObjects = new List<WeakReference>();
+
+ public AttachedCollection()
+ {
+ }
+
+ public AttachedCollection(IEnumerable<T> collection) : base(collection)
+ {
+ }
+
+ public AttachedCollection(IList<T> list) : base(list)
+ {
+ }
+
+ public void AttachTo(BindableObject bindable)
+ {
+ if (bindable == null)
+ throw new ArgumentNullException("bindable");
+ OnAttachedTo(bindable);
+ }
+
+ public void DetachFrom(BindableObject bindable)
+ {
+ OnDetachingFrom(bindable);
+ }
+
+ protected override void ClearItems()
+ {
+ foreach (WeakReference weakbindable in _associatedObjects)
+ {
+ foreach (T item in this)
+ {
+ var bindable = weakbindable.Target as BindableObject;
+ if (bindable == null)
+ continue;
+ item.DetachFrom(bindable);
+ }
+ }
+ base.ClearItems();
+ }
+
+ protected override void InsertItem(int index, T item)
+ {
+ base.InsertItem(index, item);
+ foreach (WeakReference weakbindable in _associatedObjects)
+ {
+ var bindable = weakbindable.Target as BindableObject;
+ if (bindable == null)
+ continue;
+ item.AttachTo(bindable);
+ }
+ }
+
+ protected virtual void OnAttachedTo(BindableObject bindable)
+ {
+ lock (_associatedObjects)
+ {
+ _associatedObjects.Add(new WeakReference(bindable));
+ }
+ foreach (T item in this)
+ item.AttachTo(bindable);
+ }
+
+ protected virtual void OnDetachingFrom(BindableObject bindable)
+ {
+ foreach (T item in this)
+ item.DetachFrom(bindable);
+ lock (_associatedObjects)
+ {
+ for (var i = 0; i < _associatedObjects.Count; i++)
+ {
+ object target = _associatedObjects[i].Target;
+
+ if (target == null || target == bindable)
+ {
+ _associatedObjects.RemoveAt(i);
+ i--;
+ }
+ }
+ }
+ }
+
+ protected override void RemoveItem(int index)
+ {
+ T item = this[index];
+ foreach (WeakReference weakbindable in _associatedObjects)
+ {
+ var bindable = weakbindable.Target as BindableObject;
+ if (bindable == null)
+ continue;
+ item.DetachFrom(bindable);
+ }
+
+ base.RemoveItem(index);
+ }
+
+ protected override void SetItem(int index, T item)
+ {
+ T old = this[index];
+ foreach (WeakReference weakbindable in _associatedObjects)
+ {
+ var bindable = weakbindable.Target as BindableObject;
+ if (bindable == null)
+ continue;
+ old.DetachFrom(bindable);
+ }
+
+ base.SetItem(index, item);
+
+ foreach (WeakReference weakbindable in _associatedObjects)
+ {
+ var bindable = weakbindable.Target as BindableObject;
+ if (bindable == null)
+ continue;
+ item.AttachTo(bindable);
+ }
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal abstract class Behavior : BindableObject, IAttachedObject
- {
- internal Behavior(Type associatedType)
- {
- if (associatedType == null)
- throw new ArgumentNullException("associatedType");
- AssociatedType = associatedType;
- }
+ internal abstract class Behavior : BindableObject, IAttachedObject
+ {
+ internal Behavior(Type associatedType)
+ {
+ if (associatedType == null)
+ throw new ArgumentNullException("associatedType");
+ AssociatedType = associatedType;
+ }
- protected Type AssociatedType { get; }
+ protected Type AssociatedType { get; }
- void IAttachedObject.AttachTo(BindableObject bindable)
- {
- if (bindable == null)
- throw new ArgumentNullException("bindable");
- if (!AssociatedType.IsInstanceOfType(bindable))
- throw new InvalidOperationException("bindable not an instance of AssociatedType");
- OnAttachedTo(bindable);
- }
+ void IAttachedObject.AttachTo(BindableObject bindable)
+ {
+ if (bindable == null)
+ throw new ArgumentNullException("bindable");
+ if (!AssociatedType.IsInstanceOfType(bindable))
+ throw new InvalidOperationException("bindable not an instance of AssociatedType");
+ OnAttachedTo(bindable);
+ }
- void IAttachedObject.DetachFrom(BindableObject bindable)
- {
- OnDetachingFrom(bindable);
- }
+ void IAttachedObject.DetachFrom(BindableObject bindable)
+ {
+ OnDetachingFrom(bindable);
+ }
- protected virtual void OnAttachedTo(BindableObject bindable)
- {
- }
+ protected virtual void OnAttachedTo(BindableObject bindable)
+ {
+ }
- protected virtual void OnDetachingFrom(BindableObject bindable)
- {
- }
- }
+ protected virtual void OnDetachingFrom(BindableObject bindable)
+ {
+ }
+ }
- internal abstract class Behavior<T> : Behavior where T : BindableObject
- {
- protected Behavior() : base(typeof(T))
- {
- }
+ internal abstract class Behavior<T> : Behavior where T : BindableObject
+ {
+ protected Behavior() : base(typeof(T))
+ {
+ }
- protected override void OnAttachedTo(BindableObject bindable)
- {
- base.OnAttachedTo(bindable);
- OnAttachedTo((T)bindable);
- }
+ protected override void OnAttachedTo(BindableObject bindable)
+ {
+ base.OnAttachedTo(bindable);
+ OnAttachedTo((T)bindable);
+ }
- protected virtual void OnAttachedTo(T bindable)
- {
- }
+ protected virtual void OnAttachedTo(T bindable)
+ {
+ }
- protected override void OnDetachingFrom(BindableObject bindable)
- {
- OnDetachingFrom((T)bindable);
- base.OnDetachingFrom(bindable);
- }
+ protected override void OnDetachingFrom(BindableObject bindable)
+ {
+ OnDetachingFrom((T)bindable);
+ base.OnDetachingFrom(bindable);
+ }
- protected virtual void OnDetachingFrom(T bindable)
- {
- }
- }
+ protected virtual void OnDetachingFrom(T bindable)
+ {
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- // [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")]
- [AcceptEmptyServiceProvider]
- internal sealed class BindingCondition : Condition, IValueProvider
- {
- readonly BindableProperty _boundProperty;
-
- BindingBase _binding;
- object _triggerValue;
-
- public BindingCondition()
- {
- _boundProperty = BindableProperty.CreateAttached("Bound", typeof(object), typeof(BindingCondition), null, propertyChanged: OnBoundPropertyChanged);
- }
-
- public BindingBase Binding
- {
- get { return _binding; }
- set
- {
- if (_binding == value)
- return;
- if (IsSealed)
- throw new InvalidOperationException("Can not change Binding once the Condition has been applied.");
- _binding = value;
- }
- }
-
- public object Value
- {
- get { return _triggerValue; }
- set
- {
- if (_triggerValue == value)
- return;
- if (IsSealed)
- throw new InvalidOperationException("Can not change Value once the Condition has been applied.");
- _triggerValue = value;
- }
- }
-
- object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
- {
- //This is no longer required
- return this;
- }
-
- internal override bool GetState(BindableObject bindable)
- {
- object newValue = bindable.GetValue(_boundProperty);
- return EqualsToValue(newValue);
- }
-
- internal override void SetUp(BindableObject bindable)
- {
- if (Binding != null)
- bindable.SetBinding(_boundProperty, Binding.Clone());
- }
-
- internal override void TearDown(BindableObject bindable)
- {
- bindable.RemoveBinding(_boundProperty);
- bindable.ClearValue(_boundProperty);
- }
-
- static IValueConverterProvider s_valueConverter = DependencyService.Get<IValueConverterProvider>();
-
- bool EqualsToValue(object other)
- {
- if ((other == Value) || (other != null && other.Equals(Value)))
- return true;
-
- object converted = null;
- if (s_valueConverter != null)
- converted = s_valueConverter.Convert(Value, other != null ? other.GetType() : typeof(object), null, null);
- else
- return false;
-
- return (other == converted) || (other != null && other.Equals(converted));
- }
-
- void OnBoundPropertyChanged(BindableObject bindable, object oldValue, object newValue)
- {
- bool oldState = EqualsToValue(oldValue);
- bool newState = EqualsToValue(newValue);
-
- if (newState == oldState)
- return;
-
- if (ConditionChanged != null)
- ConditionChanged(bindable, oldState, newState);
- }
- }
+ // [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")]
+ [AcceptEmptyServiceProvider]
+ internal sealed class BindingCondition : Condition, IValueProvider
+ {
+ readonly BindableProperty _boundProperty;
+
+ BindingBase _binding;
+ object _triggerValue;
+
+ public BindingCondition()
+ {
+ _boundProperty = BindableProperty.CreateAttached("Bound", typeof(object), typeof(BindingCondition), null, propertyChanged: OnBoundPropertyChanged);
+ }
+
+ public BindingBase Binding
+ {
+ get { return _binding; }
+ set
+ {
+ if (_binding == value)
+ return;
+ if (IsSealed)
+ throw new InvalidOperationException("Can not change Binding once the Condition has been applied.");
+ _binding = value;
+ }
+ }
+
+ public object Value
+ {
+ get { return _triggerValue; }
+ set
+ {
+ if (_triggerValue == value)
+ return;
+ if (IsSealed)
+ throw new InvalidOperationException("Can not change Value once the Condition has been applied.");
+ _triggerValue = value;
+ }
+ }
+
+ object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
+ {
+ //This is no longer required
+ return this;
+ }
+
+ internal override bool GetState(BindableObject bindable)
+ {
+ object newValue = bindable.GetValue(_boundProperty);
+ return EqualsToValue(newValue);
+ }
+
+ internal override void SetUp(BindableObject bindable)
+ {
+ if (Binding != null)
+ bindable.SetBinding(_boundProperty, Binding.Clone());
+ }
+
+ internal override void TearDown(BindableObject bindable)
+ {
+ bindable.RemoveBinding(_boundProperty);
+ bindable.ClearValue(_boundProperty);
+ }
+
+ static IValueConverterProvider s_valueConverter = DependencyService.Get<IValueConverterProvider>();
+
+ bool EqualsToValue(object other)
+ {
+ if ((other == Value) || (other != null && other.Equals(Value)))
+ return true;
+
+ object converted = null;
+ if (s_valueConverter != null)
+ converted = s_valueConverter.Convert(Value, other != null ? other.GetType() : typeof(object), null, null);
+ else
+ return false;
+
+ return (other == converted) || (other != null && other.Equals(converted));
+ }
+
+ void OnBoundPropertyChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ bool oldState = EqualsToValue(oldValue);
+ bool newState = EqualsToValue(newValue);
+
+ if (newState == oldState)
+ return;
+
+ if (ConditionChanged != null)
+ ConditionChanged(bindable, oldState, newState);
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal abstract class Condition
- {
- Action<BindableObject, bool, bool> _conditionChanged;
-
- bool _isSealed;
-
- internal Condition()
- {
- }
-
- internal Action<BindableObject, bool, bool> ConditionChanged
- {
- get { return _conditionChanged; }
- set
- {
- if (_conditionChanged == value)
- return;
- if (_conditionChanged != null)
- throw new InvalidOperationException("The same condition instance can not be reused");
- _conditionChanged = value;
- }
- }
-
- internal bool IsSealed
- {
- get { return _isSealed; }
- set
- {
- if (_isSealed == value)
- return;
- if (!value)
- throw new InvalidOperationException("What is sealed can not be unsealed.");
- _isSealed = value;
- OnSealed();
- }
- }
-
- internal abstract bool GetState(BindableObject bindable);
-
- internal virtual void OnSealed()
- {
- }
-
- internal abstract void SetUp(BindableObject bindable);
- internal abstract void TearDown(BindableObject bindable);
- }
+ internal abstract class Condition
+ {
+ Action<BindableObject, bool, bool> _conditionChanged;
+
+ bool _isSealed;
+
+ internal Condition()
+ {
+ }
+
+ internal Action<BindableObject, bool, bool> ConditionChanged
+ {
+ get { return _conditionChanged; }
+ set
+ {
+ if (_conditionChanged == value)
+ return;
+ if (_conditionChanged != null)
+ throw new InvalidOperationException("The same condition instance can not be reused");
+ _conditionChanged = value;
+ }
+ }
+
+ internal bool IsSealed
+ {
+ get { return _isSealed; }
+ set
+ {
+ if (_isSealed == value)
+ return;
+ if (!value)
+ throw new InvalidOperationException("What is sealed can not be unsealed.");
+ _isSealed = value;
+ OnSealed();
+ }
+ }
+
+ internal abstract bool GetState(BindableObject bindable);
+
+ internal virtual void OnSealed()
+ {
+ }
+
+ internal abstract void SetUp(BindableObject bindable);
+ internal abstract void TearDown(BindableObject bindable);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [ContentProperty("Setters")]
- // [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")]
- [AcceptEmptyServiceProvider]
- internal sealed class DataTrigger : TriggerBase, IValueProvider
- {
- public DataTrigger([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType) : base(new BindingCondition(), targetType)
- {
- }
+ [ContentProperty("Setters")]
+ // [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")]
+ [AcceptEmptyServiceProvider]
+ internal sealed class DataTrigger : TriggerBase, IValueProvider
+ {
+ public DataTrigger([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType) : base(new BindingCondition(), targetType)
+ {
+ }
- public BindingBase Binding
- {
- get { return ((BindingCondition)Condition).Binding; }
- set
- {
- if (((BindingCondition)Condition).Binding == value)
- return;
- if (IsSealed)
- throw new InvalidOperationException("Can not change Binding once the Trigger has been applied.");
- OnPropertyChanging();
- ((BindingCondition)Condition).Binding = value;
- OnPropertyChanged();
- }
- }
+ public BindingBase Binding
+ {
+ get { return ((BindingCondition)Condition).Binding; }
+ set
+ {
+ if (((BindingCondition)Condition).Binding == value)
+ return;
+ if (IsSealed)
+ throw new InvalidOperationException("Can not change Binding once the Trigger has been applied.");
+ OnPropertyChanging();
+ ((BindingCondition)Condition).Binding = value;
+ OnPropertyChanged();
+ }
+ }
- public new IList<Setter> Setters
- {
- get { return base.Setters; }
- }
+ public new IList<Setter> Setters
+ {
+ get { return base.Setters; }
+ }
- public object Value
- {
- get { return ((BindingCondition)Condition).Value; }
- set
- {
- if (((BindingCondition)Condition).Value == value)
- return;
- if (IsSealed)
- throw new InvalidOperationException("Can not change Value once the Trigger has been applied.");
- OnPropertyChanging();
- ((BindingCondition)Condition).Value = value;
- OnPropertyChanged();
- }
- }
+ public object Value
+ {
+ get { return ((BindingCondition)Condition).Value; }
+ set
+ {
+ if (((BindingCondition)Condition).Value == value)
+ return;
+ if (IsSealed)
+ throw new InvalidOperationException("Can not change Value once the Trigger has been applied.");
+ OnPropertyChanging();
+ ((BindingCondition)Condition).Value = value;
+ OnPropertyChanged();
+ }
+ }
- object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
- {
- //This is no longer required
- return this;
- }
- }
+ object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
+ {
+ //This is no longer required
+ return this;
+ }
+ }
}
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- [ContentProperty("Actions")]
- internal sealed class EventTrigger : TriggerBase
- {
- static readonly MethodInfo s_handlerinfo = typeof(EventTrigger).GetRuntimeMethods().Single(mi => mi.Name == "OnEventTriggered" && mi.IsPublic == false);
- readonly List<BindableObject> _associatedObjects = new List<BindableObject>();
+ [ContentProperty("Actions")]
+ internal sealed class EventTrigger : TriggerBase
+ {
+ static readonly MethodInfo s_handlerinfo = typeof(EventTrigger).GetRuntimeMethods().Single(mi => mi.Name == "OnEventTriggered" && mi.IsPublic == false);
+ readonly List<BindableObject> _associatedObjects = new List<BindableObject>();
- EventInfo _eventinfo;
+ EventInfo _eventinfo;
- string _eventname;
- Delegate _handlerdelegate;
+ string _eventname;
+ Delegate _handlerdelegate;
- public EventTrigger() : base(typeof(BindableObject))
- {
- Actions = new SealedList<TriggerAction>();
- }
+ public EventTrigger() : base(typeof(BindableObject))
+ {
+ Actions = new SealedList<TriggerAction>();
+ }
- public IList<TriggerAction> Actions { get; }
+ public IList<TriggerAction> Actions { get; }
- public string Event
- {
- get { return _eventname; }
- set
- {
- if (_eventname == value)
- return;
- if (IsSealed)
- throw new InvalidOperationException("Event cannot be changed once the Trigger has been applied");
- OnPropertyChanging();
- _eventname = value;
- OnPropertyChanged();
- }
- }
+ public string Event
+ {
+ get { return _eventname; }
+ set
+ {
+ if (_eventname == value)
+ return;
+ if (IsSealed)
+ throw new InvalidOperationException("Event cannot be changed once the Trigger has been applied");
+ OnPropertyChanging();
+ _eventname = value;
+ OnPropertyChanged();
+ }
+ }
- internal override void OnAttachedTo(BindableObject bindable)
- {
- base.OnAttachedTo(bindable);
- if (!string.IsNullOrEmpty(Event))
- AttachHandlerTo(bindable);
- _associatedObjects.Add(bindable);
- }
+ internal override void OnAttachedTo(BindableObject bindable)
+ {
+ base.OnAttachedTo(bindable);
+ if (!string.IsNullOrEmpty(Event))
+ AttachHandlerTo(bindable);
+ _associatedObjects.Add(bindable);
+ }
- internal override void OnDetachingFrom(BindableObject bindable)
- {
- _associatedObjects.Remove(bindable);
- DetachHandlerFrom(bindable);
- base.OnDetachingFrom(bindable);
- }
+ internal override void OnDetachingFrom(BindableObject bindable)
+ {
+ _associatedObjects.Remove(bindable);
+ DetachHandlerFrom(bindable);
+ base.OnDetachingFrom(bindable);
+ }
- internal override void OnSeal()
- {
- base.OnSeal();
- ((SealedList<TriggerAction>)Actions).IsReadOnly = true;
- }
+ internal override void OnSeal()
+ {
+ base.OnSeal();
+ ((SealedList<TriggerAction>)Actions).IsReadOnly = true;
+ }
- void AttachHandlerTo(BindableObject bindable)
- {
- try
- {
- _eventinfo = bindable.GetType().GetRuntimeEvent(Event);
- _handlerdelegate = s_handlerinfo.CreateDelegate(_eventinfo?.EventHandlerType, this);
- }
- catch (Exception)
- {
- Console.WriteLine("EventTrigger", "Can not attach EventTrigger to {0}.{1}. Check if the handler exists and if the signature is right.", bindable.GetType(), Event);
- }
- if (_eventinfo != null && _handlerdelegate != null)
- _eventinfo.AddEventHandler(bindable, _handlerdelegate);
- }
+ void AttachHandlerTo(BindableObject bindable)
+ {
+ try
+ {
+ _eventinfo = bindable.GetType().GetRuntimeEvent(Event);
+ _handlerdelegate = s_handlerinfo.CreateDelegate(_eventinfo?.EventHandlerType, this);
+ }
+ catch (Exception)
+ {
+ Console.WriteLine("EventTrigger", "Can not attach EventTrigger to {0}.{1}. Check if the handler exists and if the signature is right.", bindable.GetType(), Event);
+ }
+ if (_eventinfo != null && _handlerdelegate != null)
+ _eventinfo.AddEventHandler(bindable, _handlerdelegate);
+ }
- void DetachHandlerFrom(BindableObject bindable)
- {
- if (_eventinfo != null && _handlerdelegate != null)
- _eventinfo.RemoveEventHandler(bindable, _handlerdelegate);
- }
+ void DetachHandlerFrom(BindableObject bindable)
+ {
+ if (_eventinfo != null && _handlerdelegate != null)
+ _eventinfo.RemoveEventHandler(bindable, _handlerdelegate);
+ }
- // [Preserve]
- void OnEventTriggered(object sender, EventArgs e)
- {
- var bindable = (BindableObject)sender;
- foreach (TriggerAction action in Actions)
- action.DoInvoke(bindable);
- }
- }
+ // [Preserve]
+ void OnEventTriggered(object sender, EventArgs e)
+ {
+ var bindable = (BindableObject)sender;
+ foreach (TriggerAction action in Actions)
+ action.DoInvoke(bindable);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IAttachedObject
- {
- void AttachTo(BindableObject bindable);
- void DetachFrom(BindableObject bindable);
- }
+ internal interface IAttachedObject
+ {
+ void AttachTo(BindableObject bindable);
+ void DetachFrom(BindableObject bindable);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal sealed class MultiCondition : Condition
- {
- readonly BindableProperty _aggregatedStateProperty;
+ internal sealed class MultiCondition : Condition
+ {
+ readonly BindableProperty _aggregatedStateProperty;
- public MultiCondition()
- {
- _aggregatedStateProperty = BindableProperty.CreateAttached("AggregatedState", typeof(bool), typeof(MultiCondition), false, propertyChanged: OnAggregatedStatePropertyChanged);
- Conditions = new TriggerBase.SealedList<Condition>();
- }
+ public MultiCondition()
+ {
+ _aggregatedStateProperty = BindableProperty.CreateAttached("AggregatedState", typeof(bool), typeof(MultiCondition), false, propertyChanged: OnAggregatedStatePropertyChanged);
+ Conditions = new TriggerBase.SealedList<Condition>();
+ }
- public IList<Condition> Conditions { get; }
+ public IList<Condition> Conditions { get; }
- internal override bool GetState(BindableObject bindable)
- {
- return (bool)bindable.GetValue(_aggregatedStateProperty);
- }
+ internal override bool GetState(BindableObject bindable)
+ {
+ return (bool)bindable.GetValue(_aggregatedStateProperty);
+ }
- internal override void OnSealed()
- {
- ((TriggerBase.SealedList<Condition>)Conditions).IsReadOnly = true;
- foreach (Condition condition in Conditions)
- condition.ConditionChanged = OnConditionChanged;
- }
+ internal override void OnSealed()
+ {
+ ((TriggerBase.SealedList<Condition>)Conditions).IsReadOnly = true;
+ foreach (Condition condition in Conditions)
+ condition.ConditionChanged = OnConditionChanged;
+ }
- internal override void SetUp(BindableObject bindable)
- {
- foreach (Condition condition in Conditions)
- condition.SetUp(bindable);
- }
+ internal override void SetUp(BindableObject bindable)
+ {
+ foreach (Condition condition in Conditions)
+ condition.SetUp(bindable);
+ }
- internal override void TearDown(BindableObject bindable)
- {
- foreach (Condition condition in Conditions)
- condition.TearDown(bindable);
- }
+ internal override void TearDown(BindableObject bindable)
+ {
+ foreach (Condition condition in Conditions)
+ condition.TearDown(bindable);
+ }
- void OnAggregatedStatePropertyChanged(BindableObject bindable, object oldValue, object newValue)
- {
- if ((bool)oldValue == (bool)newValue)
- return;
+ void OnAggregatedStatePropertyChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ if ((bool)oldValue == (bool)newValue)
+ return;
- ConditionChanged?.Invoke(bindable, (bool)oldValue, (bool)newValue);
- }
+ ConditionChanged?.Invoke(bindable, (bool)oldValue, (bool)newValue);
+ }
- void OnConditionChanged(BindableObject bindable, bool oldValue, bool newValue)
- {
- var oldState = (bool)bindable.GetValue(_aggregatedStateProperty);
- var newState = true;
- foreach (Condition condition in Conditions)
- {
- if (!condition.GetState(bindable))
- {
- newState = false;
- break;
- }
- }
- if (newState != oldState)
- bindable.SetValue(_aggregatedStateProperty, newState);
- }
- }
+ void OnConditionChanged(BindableObject bindable, bool oldValue, bool newValue)
+ {
+ var oldState = (bool)bindable.GetValue(_aggregatedStateProperty);
+ var newState = true;
+ foreach (Condition condition in Conditions)
+ {
+ if (!condition.GetState(bindable))
+ {
+ newState = false;
+ break;
+ }
+ }
+ if (newState != oldState)
+ bindable.SetValue(_aggregatedStateProperty, newState);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [ContentProperty("Setters")]
- internal sealed class MultiTrigger : TriggerBase
- {
- public MultiTrigger([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType) : base(new MultiCondition(), targetType)
- {
- }
+ [ContentProperty("Setters")]
+ internal sealed class MultiTrigger : TriggerBase
+ {
+ public MultiTrigger([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType) : base(new MultiCondition(), targetType)
+ {
+ }
- public IList<Condition> Conditions
- {
- get { return ((MultiCondition)Condition).Conditions; }
- }
+ public IList<Condition> Conditions
+ {
+ get { return ((MultiCondition)Condition).Conditions; }
+ }
- public new IList<Setter> Setters
- {
- get { return base.Setters; }
- }
- }
+ public new IList<Setter> Setters
+ {
+ get { return base.Setters; }
+ }
+ }
}
\ No newline at end of file
+++ /dev/null
-using System;
-using System.ComponentModel;
-using System.Reflection;
-using Tizen.NUI.Xaml;
-
-namespace Tizen.NUI.Binding
-{
- // [ProvideCompiled("Tizen.NUI.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<MemberInfo> 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<MemberInfo> 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<IValueConverterProvider>();
-
- 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);
- }
- }
-}
namespace Tizen.NUI.Binding
{
- [ContentProperty("Setters")]
- // [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")]
- [AcceptEmptyServiceProvider]
- internal sealed class Trigger : TriggerBase, IValueProvider
- {
- public Trigger([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType) : base(new PropertyCondition(), targetType)
- {
- }
+ [ContentProperty("Setters")]
+ // [ProvideCompiled("Xamarin.Forms.Core.XamlC.PassthroughValueProvider")]
+ [AcceptEmptyServiceProvider]
+ internal sealed class Trigger : TriggerBase, IValueProvider
+ {
+ public Trigger([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType) : base(new XamlPropertyCondition(), targetType)
+ {
+ }
- public BindableProperty Property
- {
- get { return ((PropertyCondition)Condition).Property; }
- set
- {
- if (((PropertyCondition)Condition).Property == value)
- return;
- if (IsSealed)
- throw new InvalidOperationException("Can not change Property once the Trigger has been applied.");
- OnPropertyChanging();
- ((PropertyCondition)Condition).Property = value;
- OnPropertyChanged();
- }
- }
+ public BindableProperty Property
+ {
+ get { return ((XamlPropertyCondition)Condition).Property; }
+ set
+ {
+ if (((XamlPropertyCondition)Condition).Property == value)
+ return;
+ if (IsSealed)
+ throw new InvalidOperationException("Can not change Property once the Trigger has been applied.");
+ OnPropertyChanging();
+ ((XamlPropertyCondition)Condition).Property = value;
+ OnPropertyChanged();
+ }
+ }
- public new IList<Setter> Setters
- {
- get { return base.Setters; }
- }
+ public new IList<Setter> Setters
+ {
+ get { return base.Setters; }
+ }
- public object Value
- {
- get { return ((PropertyCondition)Condition).Value; }
- set
- {
- if (((PropertyCondition)Condition).Value == value)
- return;
- if (IsSealed)
- throw new InvalidOperationException("Can not change Value once the Trigger has been applied.");
- OnPropertyChanging();
- ((PropertyCondition)Condition).Value = value;
- OnPropertyChanged();
- }
- }
+ public object Value
+ {
+ get { return ((XamlPropertyCondition)Condition).Value; }
+ set
+ {
+ if (((XamlPropertyCondition)Condition).Value == value)
+ return;
+ if (IsSealed)
+ throw new InvalidOperationException("Can not change Value once the Trigger has been applied.");
+ OnPropertyChanging();
+ ((XamlPropertyCondition)Condition).Value = value;
+ OnPropertyChanged();
+ }
+ }
- object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
- {
- //This is no longer required
- return this;
- }
- }
+ object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
+ {
+ //This is no longer required
+ return this;
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal abstract class TriggerAction
- {
- internal TriggerAction(Type associatedType)
- {
- if (associatedType == null)
- throw new ArgumentNullException("associatedType");
- AssociatedType = associatedType;
- }
+ internal abstract class TriggerAction
+ {
+ internal TriggerAction(Type associatedType)
+ {
+ if (associatedType == null)
+ throw new ArgumentNullException("associatedType");
+ AssociatedType = associatedType;
+ }
- protected Type AssociatedType { get; private set; }
+ protected Type AssociatedType { get; private set; }
- protected abstract void Invoke(object sender);
+ protected abstract void Invoke(object sender);
- internal virtual void DoInvoke(object sender)
- {
- Invoke(sender);
- }
- }
+ internal virtual void DoInvoke(object sender)
+ {
+ Invoke(sender);
+ }
+ }
- internal abstract class TriggerAction<T> : TriggerAction where T : BindableObject
- {
- protected TriggerAction() : base(typeof(T))
- {
- }
+ internal abstract class TriggerAction<T> : TriggerAction where T : BindableObject
+ {
+ protected TriggerAction() : base(typeof(T))
+ {
+ }
- protected override void Invoke(object sender)
- {
- Invoke((T)sender);
- }
+ protected override void Invoke(object sender)
+ {
+ Invoke((T)sender);
+ }
- protected abstract void Invoke(T sender);
- }
+ protected abstract void Invoke(T sender);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal abstract class TriggerBase : BindableObject, IAttachedObject
- {
- bool _isSealed;
-
- internal TriggerBase(Type targetType)
- {
- if (targetType == null)
- throw new ArgumentNullException("targetType");
- TargetType = targetType;
-
- EnterActions = new SealedList<TriggerAction>();
- ExitActions = new SealedList<TriggerAction>();
- }
-
- internal TriggerBase(Condition condition, Type targetType) : this(targetType)
- {
- Setters = new SealedList<Setter>();
- Condition = condition;
- Condition.ConditionChanged = OnConditionChanged;
- }
-
- public IList<TriggerAction> EnterActions { get; }
-
- public IList<TriggerAction> ExitActions { get; }
-
- public bool IsSealed
- {
- get { return _isSealed; }
- private set
- {
- if (_isSealed == value)
- return;
- if (!value)
- throw new InvalidOperationException("What is sealed can not be unsealed.");
- _isSealed = value;
- OnSeal();
- }
- }
-
- public Type TargetType { get; }
-
- internal Condition Condition { get; }
-
- //Setters and Condition are used by Trigger, DataTrigger and MultiTrigger
- internal IList<Setter> Setters { get; }
-
- void IAttachedObject.AttachTo(BindableObject bindable)
- {
- IsSealed = true;
-
- if (bindable == null)
- throw new ArgumentNullException("bindable");
- if (!TargetType.IsInstanceOfType(bindable))
- throw new InvalidOperationException("bindable not an instance of AssociatedType");
- OnAttachedTo(bindable);
- }
-
- void IAttachedObject.DetachFrom(BindableObject bindable)
- {
- if (bindable == null)
- throw new ArgumentNullException("bindable");
- OnDetachingFrom(bindable);
- }
-
- internal virtual void OnAttachedTo(BindableObject bindable)
- {
- if (Condition != null)
- Condition.SetUp(bindable);
- }
-
- internal virtual void OnDetachingFrom(BindableObject bindable)
- {
- if (Condition != null)
- Condition.TearDown(bindable);
- }
-
- internal virtual void OnSeal()
- {
- ((SealedList<TriggerAction>)EnterActions).IsReadOnly = true;
- ((SealedList<TriggerAction>)ExitActions).IsReadOnly = true;
- if (Setters != null)
- ((SealedList<Setter>)Setters).IsReadOnly = true;
- if (Condition != null)
- Condition.IsSealed = true;
- }
-
- void OnConditionChanged(BindableObject bindable, bool oldValue, bool newValue)
- {
- if (newValue)
- {
- foreach (TriggerAction action in EnterActions)
- action.DoInvoke(bindable);
- foreach (Setter setter in Setters)
- setter.Apply(bindable);
- }
- else
- {
- foreach (Setter setter in Setters)
- setter.UnApply(bindable);
- foreach (TriggerAction action in ExitActions)
- action.DoInvoke(bindable);
- }
- }
-
- internal class SealedList<T> : IList<T>
- {
- readonly IList<T> _actual;
-
- bool _isReadOnly;
-
- public SealedList()
- {
- _actual = new List<T>();
- }
-
- public void Add(T item)
- {
- if (IsReadOnly)
- throw new InvalidOperationException("This list is ReadOnly");
- _actual.Add(item);
- }
-
- public void Clear()
- {
- if (IsReadOnly)
- throw new InvalidOperationException("This list is ReadOnly");
- _actual.Clear();
- }
-
- public bool Contains(T item)
- {
- return _actual.Contains(item);
- }
-
- public void CopyTo(T[] array, int arrayIndex)
- {
- _actual.CopyTo(array, arrayIndex);
- }
-
- public int Count
- {
- get { return _actual.Count; }
- }
-
- public bool IsReadOnly
- {
- get { return _isReadOnly; }
- set
- {
- if (_isReadOnly == value)
- return;
- if (!value)
- throw new InvalidOperationException("Can't change this back to non readonly");
- _isReadOnly = value;
- }
- }
-
- public bool Remove(T item)
- {
- if (IsReadOnly)
- throw new InvalidOperationException("This list is ReadOnly");
- return _actual.Remove(item);
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable)_actual).GetEnumerator();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- return _actual.GetEnumerator();
- }
-
- public int IndexOf(T item)
- {
- return _actual.IndexOf(item);
- }
-
- public void Insert(int index, T item)
- {
- if (IsReadOnly)
- throw new InvalidOperationException("This list is ReadOnly");
- _actual.Insert(index, item);
- }
-
- public T this[int index]
- {
- get { return _actual[index]; }
- set
- {
- if (IsReadOnly)
- throw new InvalidOperationException("This list is ReadOnly");
- _actual[index] = value;
- }
- }
-
- public void RemoveAt(int index)
- {
- if (IsReadOnly)
- throw new InvalidOperationException("This list is ReadOnly");
- _actual.RemoveAt(index);
- }
- }
- }
+ internal abstract class TriggerBase : BindableObject, IAttachedObject
+ {
+ bool _isSealed;
+
+ internal TriggerBase(Type targetType)
+ {
+ if (targetType == null)
+ throw new ArgumentNullException("targetType");
+ TargetType = targetType;
+
+ EnterActions = new SealedList<TriggerAction>();
+ ExitActions = new SealedList<TriggerAction>();
+ }
+
+ internal TriggerBase(Condition condition, Type targetType) : this(targetType)
+ {
+ Setters = new SealedList<Setter>();
+ Condition = condition;
+ Condition.ConditionChanged = OnConditionChanged;
+ }
+
+ public IList<TriggerAction> EnterActions { get; }
+
+ public IList<TriggerAction> ExitActions { get; }
+
+ public bool IsSealed
+ {
+ get { return _isSealed; }
+ private set
+ {
+ if (_isSealed == value)
+ return;
+ if (!value)
+ throw new InvalidOperationException("What is sealed can not be unsealed.");
+ _isSealed = value;
+ OnSeal();
+ }
+ }
+
+ public Type TargetType { get; }
+
+ internal Condition Condition { get; }
+
+ //Setters and Condition are used by Trigger, DataTrigger and MultiTrigger
+ internal IList<Setter> Setters { get; }
+
+ void IAttachedObject.AttachTo(BindableObject bindable)
+ {
+ IsSealed = true;
+
+ if (bindable == null)
+ throw new ArgumentNullException("bindable");
+ if (!TargetType.IsInstanceOfType(bindable))
+ throw new InvalidOperationException("bindable not an instance of AssociatedType");
+ OnAttachedTo(bindable);
+ }
+
+ void IAttachedObject.DetachFrom(BindableObject bindable)
+ {
+ if (bindable == null)
+ throw new ArgumentNullException("bindable");
+ OnDetachingFrom(bindable);
+ }
+
+ internal virtual void OnAttachedTo(BindableObject bindable)
+ {
+ if (Condition != null)
+ Condition.SetUp(bindable);
+ }
+
+ internal virtual void OnDetachingFrom(BindableObject bindable)
+ {
+ if (Condition != null)
+ Condition.TearDown(bindable);
+ }
+
+ internal virtual void OnSeal()
+ {
+ ((SealedList<TriggerAction>)EnterActions).IsReadOnly = true;
+ ((SealedList<TriggerAction>)ExitActions).IsReadOnly = true;
+ if (Setters != null)
+ ((SealedList<Setter>)Setters).IsReadOnly = true;
+ if (Condition != null)
+ Condition.IsSealed = true;
+ }
+
+ void OnConditionChanged(BindableObject bindable, bool oldValue, bool newValue)
+ {
+ if (newValue)
+ {
+ foreach (TriggerAction action in EnterActions)
+ action.DoInvoke(bindable);
+ foreach (Setter setter in Setters)
+ setter.Apply(bindable);
+ }
+ else
+ {
+ foreach (Setter setter in Setters)
+ setter.UnApply(bindable);
+ foreach (TriggerAction action in ExitActions)
+ action.DoInvoke(bindable);
+ }
+ }
+
+ internal class SealedList<T> : IList<T>
+ {
+ readonly IList<T> _actual;
+
+ bool _isReadOnly;
+
+ public SealedList()
+ {
+ _actual = new List<T>();
+ }
+
+ public void Add(T item)
+ {
+ if (IsReadOnly)
+ throw new InvalidOperationException("This list is ReadOnly");
+ _actual.Add(item);
+ }
+
+ public void Clear()
+ {
+ if (IsReadOnly)
+ throw new InvalidOperationException("This list is ReadOnly");
+ _actual.Clear();
+ }
+
+ public bool Contains(T item)
+ {
+ return _actual.Contains(item);
+ }
+
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ _actual.CopyTo(array, arrayIndex);
+ }
+
+ public int Count
+ {
+ get { return _actual.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return _isReadOnly; }
+ set
+ {
+ if (_isReadOnly == value)
+ return;
+ if (!value)
+ throw new InvalidOperationException("Can't change this back to non readonly");
+ _isReadOnly = value;
+ }
+ }
+
+ public bool Remove(T item)
+ {
+ if (IsReadOnly)
+ throw new InvalidOperationException("This list is ReadOnly");
+ return _actual.Remove(item);
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)_actual).GetEnumerator();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ return _actual.GetEnumerator();
+ }
+
+ public int IndexOf(T item)
+ {
+ return _actual.IndexOf(item);
+ }
+
+ public void Insert(int index, T item)
+ {
+ if (IsReadOnly)
+ throw new InvalidOperationException("This list is ReadOnly");
+ _actual.Insert(index, item);
+ }
+
+ public T this[int index]
+ {
+ get { return _actual[index]; }
+ set
+ {
+ if (IsReadOnly)
+ throw new InvalidOperationException("This list is ReadOnly");
+ _actual[index] = value;
+ }
+ }
+
+ public void RemoveAt(int index)
+ {
+ if (IsReadOnly)
+ throw new InvalidOperationException("This list is ReadOnly");
+ _actual.RemoveAt(index);
+ }
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+using System;
+using System.ComponentModel;
+using System.Reflection;
+using Tizen.NUI.Xaml;
+
+namespace Tizen.NUI.Binding
+{
+ // [ProvideCompiled("Tizen.NUI.Core.XamlC.PassthroughValueProvider")]
+ [AcceptEmptyServiceProvider]
+ internal sealed class XamlPropertyCondition : Condition, IValueProvider
+ {
+ readonly BindableProperty _stateProperty;
+
+ BindableProperty _property;
+ object _triggerValue;
+
+ public XamlPropertyCondition()
+ {
+ _stateProperty = BindableProperty.CreateAttached("State", typeof(bool), typeof(XamlPropertyCondition), 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<MemberInfo> 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<MemberInfo> 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<IValueConverterProvider>();
+
+ 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);
+ }
+ }
+}
using System.ComponentModel;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal class DynamicResource
- {
- public DynamicResource(string key)
- {
- Key = key;
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class DynamicResource
+ {
+ public DynamicResource(string key)
+ {
+ Key = key;
+ }
- public string Key { get; private set; }
- }
+ public string Key { get; private set; }
+ }
}
\ No newline at end of file
using System;
using System.ComponentModel;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal interface IDataTemplate
- {
- Func<object> LoadTemplate { get; set; }
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal interface IDataTemplate
+ {
+ Func<object> LoadTemplate { get; set; }
+ }
}
\ No newline at end of file
using System.ComponentModel;
using System.Threading.Tasks;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal interface IDeserializer
- {
- Task<IDictionary<string, object>> DeserializePropertiesAsync();
- Task SerializePropertiesAsync(IDictionary<string, object> properties);
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal interface IDeserializer
+ {
+ Task<IDictionary<string, object>> DeserializePropertiesAsync();
+ Task SerializePropertiesAsync(IDictionary<string, object> properties);
+ }
}
\ No newline at end of file
using System.ComponentModel;
using Tizen.NUI.Binding;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal interface IDynamicResourceHandler
- {
- void SetDynamicResource(BindableProperty property, string key);
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal interface IDynamicResourceHandler
+ {
+ void SetDynamicResource(BindableProperty property, string key);
+ }
}
using System.ComponentModel;
using System.Xml;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal interface INameScope
- {
- object FindByName(string name);
- void RegisterName(string name, object scopedElement);
- void UnregisterName(string name);
- [Obsolete]void RegisterName(string name, object scopedElement, IXmlLineInfo xmlLineInfo);
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal interface INameScope
+ {
+ object FindByName(string name);
+ void RegisterName(string name, object scopedElement);
+ void UnregisterName(string name);
+ [Obsolete]void RegisterName(string name, object scopedElement, IXmlLineInfo xmlLineInfo);
+ }
}
using System;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- interface INameScopeProvider
- {
- INameScope NameScope { get; }
- }
+ interface INameScopeProvider
+ {
+ INameScope NameScope { get; }
+ }
}
\ No newline at end of file
using System;
using System.ComponentModel;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- [Flags]
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal enum InvalidationTrigger
- {
- Undefined = 0,
- MeasureChanged = 1 << 0,
- HorizontalOptionsChanged = 1 << 1,
- VerticalOptionsChanged = 1 << 2,
- SizeRequestChanged = 1 << 3,
- RendererReady = 1 << 4,
- MarginChanged = 1 << 5
- }
+ [Flags]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal enum InvalidationTrigger
+ {
+ Undefined = 0,
+ MeasureChanged = 1 << 0,
+ HorizontalOptionsChanged = 1 << 1,
+ VerticalOptionsChanged = 1 << 2,
+ SizeRequestChanged = 1 << 3,
+ RendererReady = 1 << 4,
+ MarginChanged = 1 << 5
+ }
}
\ No newline at end of file
using Tizen.NUI.Binding;
using Tizen.NUI.Xaml;
-namespace Tizen.NUI.Internals
+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));
-
- readonly Dictionary<string, object> _names = new Dictionary<string, object>();
-
- object INameScope.FindByName(string name)
- {
- if (_names.ContainsKey(name))
- return _names[name];
- return null;
- }
-
- void INameScope.RegisterName(string name, object scopedElement)
- {
- if (_names.ContainsKey(name))
- throw new ArgumentException("An element with the same key already exists in NameScope", "name");
-
- _names[name] = scopedElement;
- }
-
- [Obsolete]
- void INameScope.RegisterName(string name, object scopedElement, IXmlLineInfo xmlLineInfo)
- {
- try
- {
- ((INameScope)this).RegisterName(name, scopedElement);
- }
- catch (ArgumentException)
- {
- throw new XamlParseException(string.Format("An element with the name \"{0}\" already exists in this NameScope", name), xmlLineInfo);
- }
- }
-
- void INameScope.UnregisterName(string name)
- {
- _names.Remove(name);
- }
-
- public static INameScope GetNameScope(BindableObject bindable)
- {
- return (INameScope)bindable.GetValue(NameScopeProperty);
- }
-
- public static void SetNameScope(BindableObject bindable, INameScope value)
- {
- bindable.SetValue(NameScopeProperty, value);
- }
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class NameScope : INameScope
+ {
+ public static readonly BindableProperty NameScopeProperty = BindableProperty.CreateAttached("NameScope", typeof(INameScope), typeof(NameScope), default(INameScope));
+
+ readonly Dictionary<string, object> _names = new Dictionary<string, object>();
+
+ object INameScope.FindByName(string name)
+ {
+ if (_names.ContainsKey(name))
+ return _names[name];
+ return null;
+ }
+
+ void INameScope.RegisterName(string name, object scopedElement)
+ {
+ if (_names.ContainsKey(name))
+ throw new ArgumentException("An element with the same key already exists in NameScope", "name");
+
+ _names[name] = scopedElement;
+ }
+
+ [Obsolete]
+ void INameScope.RegisterName(string name, object scopedElement, IXmlLineInfo xmlLineInfo)
+ {
+ try
+ {
+ ((INameScope)this).RegisterName(name, scopedElement);
+ }
+ catch (ArgumentException)
+ {
+ throw new XamlParseException(string.Format("An element with the name \"{0}\" already exists in this NameScope", name), xmlLineInfo);
+ }
+ }
+
+ void INameScope.UnregisterName(string name)
+ {
+ _names.Remove(name);
+ }
+
+ public static INameScope GetNameScope(BindableObject bindable)
+ {
+ return (INameScope)bindable.GetValue(NameScopeProperty);
+ }
+
+ public static void SetNameScope(BindableObject bindable, INameScope value)
+ {
+ bindable.SetValue(NameScopeProperty, value);
+ }
+ }
}
--- /dev/null
+using System;
+using System.ComponentModel;
+
+namespace Tizen.NUI.Binding.Internals
+{
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal static class NumericExtensions
+ {
+
+ public static double Clamp(this double self, double min, double max)
+ {
+ return Math.Min(max, Math.Max(self, min));
+ }
+
+ public static float Clamp(this float self, float min, float max)
+ {
+ return Math.Min(max, Math.Max(self, min));
+ }
+
+ public static int Clamp(this int self, int min, int max)
+ {
+ return Math.Min(max, Math.Max(self, min));
+ }
+ }
+}
\ No newline at end of file
using System;
+using System.IO;
using System.Reflection;
using Tizen.NUI.Xaml;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- internal static class ResourceLoader
- {
- static Func<AssemblyName, string, string> resourceProvider;
+ internal static class ResourceLoader
+ {
+ static Func<AssemblyName, string, string> resourceProvider = (asmName, path) =>
+ {
+ string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+ path = resource + path;
- //takes a resource path, returns string content
- public static Func<AssemblyName, string, string> ResourceProvider {
- get => resourceProvider;
- internal set {
- DesignMode.IsDesignModeEnabled = true;
- resourceProvider = value;
- }
- }
+ string ret = File.ReadAllText(path);
+ return ret;
+ };
- internal static Action<Exception> ExceptionHandler { get; set; }
- }
+ //takes a resource path, returns string content
+ public static Func<AssemblyName, string, string> ResourceProvider {
+ get => resourceProvider;
+ internal set {
+ DesignMode.IsDesignModeEnabled = true;
+ resourceProvider = value;
+ }
+ }
+
+ internal static Action<Exception> ExceptionHandler { get; set; }
+ }
}
\ No newline at end of file
using System.Linq;
using Tizen.NUI.Binding;
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal abstract class Ticker
- {
- static Ticker s_ticker;
- readonly Stopwatch _stopwatch;
- readonly List<Tuple<int, Func<long, bool>>> _timeouts;
-
- int _count;
- bool _enabled;
-
- protected Ticker()
- {
- _count = 0;
- _timeouts = new List<Tuple<int, Func<long, bool>>>();
-
- _stopwatch = new Stopwatch();
- }
-
- public static void SetDefault(Ticker ticker) => Default = ticker;
- public static Ticker Default
- {
- internal set { s_ticker = value; }
- get { return s_ticker ?? (s_ticker = Device.PlatformServices.CreateTicker()); }
- }
-
- public virtual int Insert(Func<long, bool> timeout)
- {
- _count++;
- _timeouts.Add(new Tuple<int, Func<long, bool>>(_count, timeout));
-
- if (!_enabled)
- {
- _enabled = true;
- Enable();
- }
-
- return _count;
- }
-
- public virtual void Remove(int handle)
- {
- // Device.BeginInvokeOnMainThread(() =>
- // {
- // _timeouts.RemoveAll(t => t.Item1 == handle);
-
- // if (!_timeouts.Any())
- // {
- // _enabled = false;
- // Disable();
- // }
- // });
- }
-
- protected abstract void DisableTimer();
-
- protected abstract void EnableTimer();
-
- protected void SendSignals(int timestep = -1)
- {
- long step = timestep >= 0 ? timestep : _stopwatch.ElapsedMilliseconds;
- _stopwatch.Reset();
- _stopwatch.Start();
-
- var localCopy = new List<Tuple<int, Func<long, bool>>>(_timeouts);
- foreach (Tuple<int, Func<long, bool>> timeout in localCopy)
- {
- bool remove = !timeout.Item2(step);
- if (remove)
- _timeouts.RemoveAll(t => t.Item1 == timeout.Item1);
- }
-
- if (!_timeouts.Any())
- {
- _enabled = false;
- Disable();
- }
- }
-
- void Disable()
- {
- _stopwatch.Reset();
- DisableTimer();
- }
-
- void Enable()
- {
- _stopwatch.Start();
- EnableTimer();
- }
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal abstract class Ticker
+ {
+ static Ticker s_ticker;
+ readonly Stopwatch _stopwatch;
+ readonly List<Tuple<int, Func<long, bool>>> _timeouts;
+
+ int _count;
+ bool _enabled;
+
+ protected Ticker()
+ {
+ _count = 0;
+ _timeouts = new List<Tuple<int, Func<long, bool>>>();
+
+ _stopwatch = new Stopwatch();
+ }
+
+ public static void SetDefault(Ticker ticker) => Default = ticker;
+ public static Ticker Default
+ {
+ internal set { s_ticker = value; }
+ get { return s_ticker ?? (s_ticker = Device.PlatformServices.CreateTicker()); }
+ }
+
+ public virtual int Insert(Func<long, bool> timeout)
+ {
+ _count++;
+ _timeouts.Add(new Tuple<int, Func<long, bool>>(_count, timeout));
+
+ if (!_enabled)
+ {
+ _enabled = true;
+ Enable();
+ }
+
+ return _count;
+ }
+
+ public virtual void Remove(int handle)
+ {
+ Device.BeginInvokeOnMainThread(() =>
+ {
+ _timeouts.RemoveAll(t => t.Item1 == handle);
+
+ if (!_timeouts.Any())
+ {
+ _enabled = false;
+ Disable();
+ }
+ });
+ }
+
+ protected abstract void DisableTimer();
+
+ protected abstract void EnableTimer();
+
+ protected void SendSignals(int timestep = -1)
+ {
+ long step = timestep >= 0 ? timestep : _stopwatch.ElapsedMilliseconds;
+ _stopwatch.Reset();
+ _stopwatch.Start();
+
+ var localCopy = new List<Tuple<int, Func<long, bool>>>(_timeouts);
+ foreach (Tuple<int, Func<long, bool>> timeout in localCopy)
+ {
+ bool remove = !timeout.Item2(step);
+ if (remove)
+ _timeouts.RemoveAll(t => t.Item1 == timeout.Item1);
+ }
+
+ if (!_timeouts.Any())
+ {
+ _enabled = false;
+ Disable();
+ }
+ }
+
+ void Disable()
+ {
+ _stopwatch.Reset();
+ DisableTimer();
+ }
+
+ void Enable()
+ {
+ _stopwatch.Start();
+ EnableTimer();
+ }
+ }
}
using System.Collections.Generic;
using Tizen.NUI.Binding;
-namespace Tizen.NUI.Internals
+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;
- object _converterParameter;
- object _source;
- string _updateSourceEventName;
-
- public IValueConverter Converter {
- get { return _converter; }
- set {
- ThrowIfApplied();
- _converter = value;
- }
- }
-
- public object ConverterParameter {
- get { return _converterParameter; }
- set {
- ThrowIfApplied();
- _converterParameter = value;
- }
- }
-
- public object Source {
- get { return _source; }
- set {
- ThrowIfApplied();
- _source = value;
- }
- }
-
- internal string UpdateSourceEventName {
- get { return _updateSourceEventName; }
- set {
- ThrowIfApplied();
- _updateSourceEventName = value;
- }
- }
-
- internal TypedBindingBase()
- {
- }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal sealed class TypedBinding<TSource, TProperty> : TypedBindingBase
- {
- readonly Func<TSource, TProperty> _getter;
- readonly Action<TSource, TProperty> _setter;
- readonly PropertyChangedProxy [] _handlers;
-
- public TypedBinding(Func<TSource, TProperty> getter, Action<TSource, TProperty> setter, Tuple<Func<TSource, object>, string> [] handlers)
- {
- if (getter == null)
- throw new ArgumentNullException(nameof(getter));
-
- _getter = getter;
- _setter = setter;
-
- if (handlers == null)
- return;
-
- _handlers = new PropertyChangedProxy [handlers.Length];
- for (var i = 0; i < handlers.Length; i++)
- _handlers [i] = new PropertyChangedProxy(handlers [i].Item1, handlers [i].Item2, this);
- }
-
- readonly WeakReference<object> _weakSource = new WeakReference<object>(null);
- readonly WeakReference<BindableObject> _weakTarget = new WeakReference<BindableObject>(null);
- BindableProperty _targetProperty;
-
- // Applies the binding to a previously set source and target.
- internal override void Apply(bool fromTarget = false)
- {
- base.Apply(fromTarget);
-
- BindableObject target;
+ //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;
+ object _converterParameter;
+ object _source;
+ string _updateSourceEventName;
+
+ public IValueConverter Converter {
+ get { return _converter; }
+ set {
+ ThrowIfApplied();
+ _converter = value;
+ }
+ }
+
+ public object ConverterParameter {
+ get { return _converterParameter; }
+ set {
+ ThrowIfApplied();
+ _converterParameter = value;
+ }
+ }
+
+ public object Source {
+ get { return _source; }
+ set {
+ ThrowIfApplied();
+ _source = value;
+ }
+ }
+
+ internal string UpdateSourceEventName {
+ get { return _updateSourceEventName; }
+ set {
+ ThrowIfApplied();
+ _updateSourceEventName = value;
+ }
+ }
+
+ internal TypedBindingBase()
+ {
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal sealed class TypedBinding<TSource, TProperty> : TypedBindingBase
+ {
+ readonly Func<TSource, TProperty> _getter;
+ readonly Action<TSource, TProperty> _setter;
+ readonly PropertyChangedProxy [] _handlers;
+
+ public TypedBinding(Func<TSource, TProperty> getter, Action<TSource, TProperty> setter, Tuple<Func<TSource, object>, string> [] handlers)
+ {
+ if (getter == null)
+ throw new ArgumentNullException(nameof(getter));
+
+ _getter = getter;
+ _setter = setter;
+
+ if (handlers == null)
+ return;
+
+ _handlers = new PropertyChangedProxy [handlers.Length];
+ for (var i = 0; i < handlers.Length; i++)
+ _handlers [i] = new PropertyChangedProxy(handlers [i].Item1, handlers [i].Item2, this);
+ }
+
+ readonly WeakReference<object> _weakSource = new WeakReference<object>(null);
+ readonly WeakReference<BindableObject> _weakTarget = new WeakReference<BindableObject>(null);
+ BindableProperty _targetProperty;
+
+ // Applies the binding to a previously set source and target.
+ internal override void Apply(bool fromTarget = false)
+ {
+ base.Apply(fromTarget);
+
+ BindableObject target;
#if DO_NOT_CHECK_FOR_BINDING_REUSE
- if (!_weakTarget.TryGetTarget(out target))
- throw new InvalidOperationException();
+ if (!_weakTarget.TryGetTarget(out target))
+ throw new InvalidOperationException();
#else
- if (!_weakTarget.TryGetTarget(out target) || target == null) {
- Unapply();
- return;
- }
+ if (!_weakTarget.TryGetTarget(out target) || target == null) {
+ Unapply();
+ return;
+ }
#endif
- object source;
- if (_weakSource.TryGetTarget(out source) && source != null)
- ApplyCore(source, target, _targetProperty, fromTarget);
- }
-
- // Applies the binding to a new source or target.
- internal override void Apply(object context, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged = false)
- {
- _targetProperty = targetProperty;
- var source = Source ?? Context ?? context;
- var isApplied = IsApplied;
-
- if (Source != null && isApplied && fromBindingContextChanged)
- return;
-
- base.Apply(source, bindObj, targetProperty, fromBindingContextChanged);
-
+ object source;
+ if (_weakSource.TryGetTarget(out source) && source != null)
+ ApplyCore(source, target, _targetProperty, fromTarget);
+ }
+
+ // Applies the binding to a new source or target.
+ internal override void Apply(object context, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged = false)
+ {
+ _targetProperty = targetProperty;
+ var source = Source ?? Context ?? context;
+ var isApplied = IsApplied;
+
+ if (Source != null && isApplied && fromBindingContextChanged)
+ return;
+
+ base.Apply(source, bindObj, targetProperty, fromBindingContextChanged);
+
#if (!DO_NOT_CHECK_FOR_BINDING_REUSE)
- BindableObject prevTarget;
- if (_weakTarget.TryGetTarget(out prevTarget) && !ReferenceEquals(prevTarget, bindObj))
- throw new InvalidOperationException("Binding instances can not be reused");
+ BindableObject prevTarget;
+ if (_weakTarget.TryGetTarget(out prevTarget) && !ReferenceEquals(prevTarget, bindObj))
+ throw new InvalidOperationException("Binding instances can not be reused");
- object previousSource;
- if (_weakSource.TryGetTarget(out previousSource) && !ReferenceEquals(previousSource, source))
- throw new InvalidOperationException("Binding instances can not be reused");
+ object previousSource;
+ if (_weakSource.TryGetTarget(out previousSource) && !ReferenceEquals(previousSource, source))
+ throw new InvalidOperationException("Binding instances can not be reused");
#endif
- _weakSource.SetTarget(source);
- _weakTarget.SetTarget(bindObj);
-
- ApplyCore(source, bindObj, targetProperty);
- }
-
- internal override BindingBase Clone()
- {
- Tuple<Func<TSource, object>, string> [] handlers = _handlers == null ? null : new Tuple<Func<TSource, object>, string> [_handlers.Length];
- if (handlers != null) {
- for (var i = 0; i < _handlers.Length; i++)
- handlers [i] = new Tuple<Func<TSource, object>, string>(_handlers [i].PartGetter, _handlers [i].PropertyName);
- }
- return new TypedBinding<TSource, TProperty>(_getter, _setter, handlers) {
- Mode = Mode,
- Converter = Converter,
- ConverterParameter = ConverterParameter,
- StringFormat = StringFormat,
- Source = Source,
- UpdateSourceEventName = UpdateSourceEventName,
- };
- }
-
- internal override object GetSourceValue(object value, Type targetPropertyType)
- {
- if (Converter != null)
- value = Converter.Convert(value, targetPropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
-
- //return base.GetSourceValue(value, targetPropertyType);
- if (StringFormat != null)
- return string.Format(StringFormat, value);
-
- return value;
- }
-
- internal override object GetTargetValue(object value, Type sourcePropertyType)
- {
- if (Converter != null)
- value = Converter.ConvertBack(value, sourcePropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
-
- //return base.GetTargetValue(value, sourcePropertyType);
- return value;
- }
-
- internal override void Unapply(bool fromBindingContextChanged = false)
- {
- if (Source != null && fromBindingContextChanged && IsApplied)
- return;
+ _weakSource.SetTarget(source);
+ _weakTarget.SetTarget(bindObj);
+
+ ApplyCore(source, bindObj, targetProperty);
+ }
+
+ internal override BindingBase Clone()
+ {
+ Tuple<Func<TSource, object>, string> [] handlers = _handlers == null ? null : new Tuple<Func<TSource, object>, string> [_handlers.Length];
+ if (handlers != null) {
+ for (var i = 0; i < _handlers.Length; i++)
+ handlers [i] = new Tuple<Func<TSource, object>, string>(_handlers [i].PartGetter, _handlers [i].PropertyName);
+ }
+ return new TypedBinding<TSource, TProperty>(_getter, _setter, handlers) {
+ Mode = Mode,
+ Converter = Converter,
+ ConverterParameter = ConverterParameter,
+ StringFormat = StringFormat,
+ Source = Source,
+ UpdateSourceEventName = UpdateSourceEventName,
+ };
+ }
+
+ internal override object GetSourceValue(object value, Type targetPropertyType)
+ {
+ if (Converter != null)
+ value = Converter.Convert(value, targetPropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
+
+ //return base.GetSourceValue(value, targetPropertyType);
+ if (StringFormat != null)
+ return string.Format(StringFormat, value);
+
+ return value;
+ }
+
+ internal override object GetTargetValue(object value, Type sourcePropertyType)
+ {
+ if (Converter != null)
+ value = Converter.ConvertBack(value, sourcePropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
+
+ //return base.GetTargetValue(value, sourcePropertyType);
+ return value;
+ }
+
+ internal override void Unapply(bool fromBindingContextChanged = false)
+ {
+ if (Source != null && fromBindingContextChanged && IsApplied)
+ return;
#if (!DO_NOT_CHECK_FOR_BINDING_REUSE)
- base.Unapply(fromBindingContextChanged:fromBindingContextChanged);
+ base.Unapply(fromBindingContextChanged:fromBindingContextChanged);
#endif
- if (_handlers != null)
- Unsubscribe();
-
+ if (_handlers != null)
+ Unsubscribe();
+
#if (!DO_NOT_CHECK_FOR_BINDING_REUSE)
- _weakSource.SetTarget(null);
- _weakTarget.SetTarget(null);
+ _weakSource.SetTarget(null);
+ _weakTarget.SetTarget(null);
#endif
- }
-
- // ApplyCore is as slim as it should be:
- // Setting 100000 values : 17ms.
- // ApplyCore 100000 (w/o INPC, w/o unnapply) : 20ms.
- internal void ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget = false)
- {
- var isTSource = sourceObject != null && sourceObject is TSource;
- var mode = this.GetRealizedMode(property);
- if ((mode == BindingMode.OneWay || mode == BindingMode.OneTime) && fromTarget)
- return;
-
- var needsGetter = (mode == BindingMode.TwoWay && !fromTarget) || mode == BindingMode.OneWay || mode == BindingMode.OneTime;
-
- if (isTSource && (mode == BindingMode.OneWay || mode == BindingMode.TwoWay) && _handlers != null)
- Subscribe((TSource)sourceObject);
-
- if (needsGetter) {
- var value = property.DefaultValue;
- if (isTSource) {
- try {
- value = GetSourceValue(_getter((TSource)sourceObject), property.ReturnType);
- } catch (Exception ex) when (ex is NullReferenceException || ex is KeyNotFoundException) {
- }
- }
- if (!TryConvert(ref value, property, property.ReturnType, true)) {
- // Log.Warning("Binding", "{0} can not be converted to type '{1}'", value, property.ReturnType);
- return;
- }
- target.SetValueCore(property, value, SetValueFlags.ClearDynamicResource, BindableObject.SetValuePrivateFlags.Default | BindableObject.SetValuePrivateFlags.Converted);
- return;
- }
-
- var needsSetter = (mode == BindingMode.TwoWay && fromTarget) || mode == BindingMode.OneWayToSource;
- if (needsSetter && _setter != null && isTSource) {
- var value = GetTargetValue(target.GetValue(property), typeof(TProperty));
- if (!TryConvert(ref value, property, typeof(TProperty), false)) {
- // Log.Warning("Binding", "{0} can not be converted to type '{1}'", value, typeof(TProperty));
- return;
- }
- _setter((TSource)sourceObject, (TProperty)value);
- }
- }
-
- static bool TryConvert(ref object value, BindableProperty targetProperty, Type convertTo, bool toTarget)
- {
- if (value == null)
- return true;
- if ((toTarget && targetProperty.TryConvert(ref value)) || (!toTarget && convertTo.IsInstanceOfType(value)))
- return true;
-
- object original = value;
- try {
- value = Convert.ChangeType(value, convertTo, CultureInfo.InvariantCulture);
- return true;
- } catch (Exception ex ) when (ex is InvalidCastException || ex is FormatException||ex is OverflowException) {
- value = original;
- return false;
- }
- }
-
- class PropertyChangedProxy
- {
- public Func<TSource, object> PartGetter { get; }
- public string PropertyName { get; }
- public BindingExpression.WeakPropertyChangedProxy Listener { get; }
- WeakReference<INotifyPropertyChanged> _weakPart = new WeakReference<INotifyPropertyChanged>(null);
- readonly BindingBase _binding;
-
- public INotifyPropertyChanged Part {
- get {
- INotifyPropertyChanged target;
- if (_weakPart.TryGetTarget(out target))
- return target;
- return null;
- }
- set {
- _weakPart.SetTarget(value);
- Listener.SubscribeTo(value, OnPropertyChanged);
- }
- }
-
- public PropertyChangedProxy(Func<TSource, object> partGetter, string propertyName, BindingBase binding)
- {
- PartGetter = partGetter;
- PropertyName = propertyName;
- _binding = binding;
- Listener = new BindingExpression.WeakPropertyChangedProxy();
- }
-
- void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (!string.IsNullOrEmpty(e.PropertyName) && string.CompareOrdinal(e.PropertyName, PropertyName) != 0)
- return;
- Device.BeginInvokeOnMainThread(() => _binding.Apply(false));
- }
- }
-
- void Subscribe(TSource sourceObject)
- {
- for (var i = 0; i < _handlers.Length; i++) {
- var part = _handlers [i].PartGetter(sourceObject);
- if (part == null)
- break;
- var inpc = part as INotifyPropertyChanged;
- if (inpc == null)
- continue;
- _handlers [i].Part = (inpc);
- }
- }
-
- void Unsubscribe()
- {
- for (var i = 0; i < _handlers.Length; i++)
- _handlers [i].Listener.Unsubscribe();
- }
- }
+ }
+
+ // ApplyCore is as slim as it should be:
+ // Setting 100000 values : 17ms.
+ // ApplyCore 100000 (w/o INPC, w/o unnapply) : 20ms.
+ internal void ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget = false)
+ {
+ var isTSource = sourceObject != null && sourceObject is TSource;
+ var mode = this.GetRealizedMode(property);
+ if ((mode == BindingMode.OneWay || mode == BindingMode.OneTime) && fromTarget)
+ return;
+
+ var needsGetter = (mode == BindingMode.TwoWay && !fromTarget) || mode == BindingMode.OneWay || mode == BindingMode.OneTime;
+
+ if (isTSource && (mode == BindingMode.OneWay || mode == BindingMode.TwoWay) && _handlers != null)
+ Subscribe((TSource)sourceObject);
+
+ if (needsGetter) {
+ var value = property.DefaultValue;
+ if (isTSource) {
+ try {
+ value = GetSourceValue(_getter((TSource)sourceObject), property.ReturnType);
+ } catch (Exception ex) when (ex is NullReferenceException || ex is KeyNotFoundException) {
+ }
+ }
+ if (!TryConvert(ref value, property, property.ReturnType, true)) {
+ // Log.Warning("Binding", "{0} can not be converted to type '{1}'", value, property.ReturnType);
+ return;
+ }
+ target.SetValueCore(property, value, SetValueFlags.ClearDynamicResource, BindableObject.SetValuePrivateFlags.Default | BindableObject.SetValuePrivateFlags.Converted, false);
+ return;
+ }
+
+ var needsSetter = (mode == BindingMode.TwoWay && fromTarget) || mode == BindingMode.OneWayToSource;
+ if (needsSetter && _setter != null && isTSource) {
+ var value = GetTargetValue(target.GetValue(property), typeof(TProperty));
+ if (!TryConvert(ref value, property, typeof(TProperty), false)) {
+ // Log.Warning("Binding", "{0} can not be converted to type '{1}'", value, typeof(TProperty));
+ return;
+ }
+ _setter((TSource)sourceObject, (TProperty)value);
+ }
+ }
+
+ static bool TryConvert(ref object value, BindableProperty targetProperty, Type convertTo, bool toTarget)
+ {
+ if (value == null)
+ return true;
+ if ((toTarget && targetProperty.TryConvert(ref value)) || (!toTarget && convertTo.IsInstanceOfType(value)))
+ return true;
+
+ object original = value;
+ try {
+ value = Convert.ChangeType(value, convertTo, CultureInfo.InvariantCulture);
+ return true;
+ } catch (Exception ex ) when (ex is InvalidCastException || ex is FormatException||ex is OverflowException) {
+ value = original;
+ return false;
+ }
+ }
+
+ class PropertyChangedProxy
+ {
+ public Func<TSource, object> PartGetter { get; }
+ public string PropertyName { get; }
+ public BindingExpression.WeakPropertyChangedProxy Listener { get; }
+ WeakReference<INotifyPropertyChanged> _weakPart = new WeakReference<INotifyPropertyChanged>(null);
+ readonly BindingBase _binding;
+
+ public INotifyPropertyChanged Part {
+ get {
+ INotifyPropertyChanged target;
+ if (_weakPart.TryGetTarget(out target))
+ return target;
+ return null;
+ }
+ set {
+ _weakPart.SetTarget(value);
+ Listener.SubscribeTo(value, OnPropertyChanged);
+ }
+ }
+
+ public PropertyChangedProxy(Func<TSource, object> partGetter, string propertyName, BindingBase binding)
+ {
+ PartGetter = partGetter;
+ PropertyName = propertyName;
+ _binding = binding;
+ Listener = new BindingExpression.WeakPropertyChangedProxy();
+ }
+
+ void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ if (!string.IsNullOrEmpty(e.PropertyName) && string.CompareOrdinal(e.PropertyName, PropertyName) != 0)
+ return;
+ Device.BeginInvokeOnMainThread(() => _binding.Apply(false));
+ }
+ }
+
+ void Subscribe(TSource sourceObject)
+ {
+ for (var i = 0; i < _handlers.Length; i++) {
+ var part = _handlers [i].PartGetter(sourceObject);
+ if (part == null)
+ break;
+ var inpc = part as INotifyPropertyChanged;
+ if (inpc == null)
+ continue;
+ _handlers [i].Part = (inpc);
+ }
+ }
+
+ void Unsubscribe()
+ {
+ for (var i = 0; i < _handlers.Length; i++)
+ _handlers [i].Listener.Unsubscribe();
+ }
+ }
}
\ No newline at end of file
+++ /dev/null
-using System;
-using System.Diagnostics;
-
-
-namespace Tizen.NUI.Internals
-{
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
- [DebuggerDisplay("{XmlNamespace}, {ClrNamespace}, {AssemblyName}")]
- sealed class XmlnsDefinitionAttribute : Attribute
- {
- public string XmlNamespace { get; }
- public string ClrNamespace { get; }
- public string AssemblyName { get; set; }
-
- public XmlnsDefinitionAttribute(string xmlNamespace, string clrNamespace)
- {
- if (xmlNamespace == null)
- throw new ArgumentNullException(nameof(xmlNamespace));
- if (clrNamespace == null)
- throw new ArgumentNullException(nameof(clrNamespace));
-
- ClrNamespace = clrNamespace;
- XmlNamespace = xmlNamespace;
- }
- }
-}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class InvalidNavigationException : Exception
- {
- public InvalidNavigationException(string message) : base(message)
- {
- }
- }
+ internal class InvalidNavigationException : Exception
+ {
+ public InvalidNavigationException(string message) : base(message)
+ {
+ }
+ }
}
\ No newline at end of file
using System;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- internal class InvalidationEventArgs : EventArgs
- {
- public InvalidationEventArgs(InvalidationTrigger trigger)
- {
- Trigger = trigger;
- }
+ internal class InvalidationEventArgs : EventArgs
+ {
+ public InvalidationEventArgs(InvalidationTrigger trigger)
+ {
+ Trigger = trigger;
+ }
- public InvalidationTrigger Trigger { get; private set; }
- }
+ public InvalidationTrigger Trigger { get; private set; }
+ }
}
\ No newline at end of file
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI.BaseComponents;
namespace Tizen.NUI.Binding
{
- [ContentProperty("Children")]
- internal abstract class Layout<T> : Layout, IViewContainer<T> where T : View
- {
- readonly ElementCollection<T> _children;
-
- protected Layout()
- {
- _children = new ElementCollection<T>(InternalChildren);
- }
-
- public new IList<T> Children
- {
- get { return _children; }
- }
-
- protected virtual void OnAdded(T view)
- {
- }
-
- protected override void OnChildAdded(Element child)
- {
- base.OnChildAdded(child);
-
- var typedChild = child as T;
- if (typedChild != null)
- OnAdded(typedChild);
- }
-
- protected override void OnChildRemoved(Element child)
- {
- base.OnChildRemoved(child);
-
- var typedChild = child as T;
- if (typedChild != null)
- OnRemoved(typedChild);
- }
-
- protected virtual void OnRemoved(T view)
- {
- }
- }
-
- internal abstract class Layout : View, ILayout, ILayoutController, IPaddingElement
- {
- public static readonly BindableProperty IsClippedToBoundsProperty = BindableProperty.Create("IsClippedToBounds", typeof(bool), typeof(Layout), false);
-
- public static readonly BindableProperty CascadeInputTransparentProperty = BindableProperty.Create(
- nameof(CascadeInputTransparent), typeof(bool), typeof(Layout), true);
-
- public static readonly BindableProperty PaddingProperty = PaddingElement.PaddingProperty;
-
- static IList<KeyValuePair<Layout, int>> s_resolutionList = new List<KeyValuePair<Layout, int>>();
- static bool s_relayoutInProgress;
- //bool _allocatedFlag;
-
- bool _hasDoneLayout;
- Size _lastLayoutSize = new Size(-1, -1, 0);
-
- ReadOnlyCollection<Element> _logicalChildren;
-
- protected Layout()
- {
- //if things were added in base ctor (through implicit styles), the items added aren't properly parented
- if (InternalChildren.Count > 0)
- InternalChildrenOnCollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, InternalChildren));
-
- InternalChildren.CollectionChanged += InternalChildrenOnCollectionChanged;
- }
-
- public bool IsClippedToBounds
- {
- get { return (bool)GetValue(IsClippedToBoundsProperty); }
- set { SetValue(IsClippedToBoundsProperty, value); }
- }
-
-
- public new Thickness Padding
- {
- get { return (Thickness)GetValue(PaddingElement.PaddingProperty); }
- set { SetValue(PaddingElement.PaddingProperty, value); }
- }
-
- public bool CascadeInputTransparent
- {
- get { return (bool)GetValue(CascadeInputTransparentProperty); }
- set { SetValue(CascadeInputTransparentProperty, value); }
- }
-
- Thickness IPaddingElement.PaddingDefaultValueCreator()
- {
- return default(Thickness);
- }
-
- void IPaddingElement.OnPaddingPropertyChanged(Thickness oldValue, Thickness newValue)
- {
- UpdateChildrenLayout();
- }
-
- internal ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
-
- internal override ReadOnlyCollection<Element> LogicalChildrenInternal
- {
- get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
- }
-
- /// <summary>
- /// Raised when the layout of the Page has changed.
- /// </summary>
- public event EventHandler LayoutChanged;
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new IReadOnlyList<Element> Children
- {
- get { return InternalChildren; }
- }
-
- public void ForceLayout()
- {
- //SizeAllocated(Width, Height);
- }
-
- [Obsolete("OnSizeRequest is obsolete as of version 2.2.0. Please use OnMeasure instead.")]
- // public sealed override SizeRequest GetSizeRequest(double widthConstraint, double heightConstraint)
- // {
- // SizeRequest size = base.GetSizeRequest(widthConstraint - Padding.HorizontalThickness, heightConstraint - Padding.VerticalThickness);
- // return new SizeRequest(new Size(size.Request.Width + Padding.HorizontalThickness, size.Request.Height + Padding.VerticalThickness, 0),
- // new Size(size.Minimum.Width + Padding.HorizontalThickness, size.Minimum.Height + Padding.VerticalThickness, 0));
- // }
-
- public static void LayoutChildIntoBoundingRegion(/*VisualElement*/BaseHandle child, Rectangle region)
- {
- //var parent = child.Parent as IFlowDirectionController;
- //bool isRightToLeft = false;
- //if (parent != null && (isRightToLeft = parent.EffectiveFlowDirection.IsRightToLeft()))
- //region = new Rectangle(parent.Width - region.Right, region.Y, region.Width, region.Height);
-
- var view = child as View;
- if (view == null)
- {
- //child.Layout(region);
- return;
- }
-
- //LayoutOptions horizontalOptions = view.HorizontalOptions;
- // if (horizontalOptions.Alignment != LayoutAlignment.Fill)
- // {
- // SizeRequest request = child.Measure(region.Width, region.Height, MeasureFlags.IncludeMargins);
- // double diff = Math.Max(0, region.Width - request.Request.Width);
- // double horizontalAlign = horizontalOptions.Alignment.ToDouble();
- // if (isRightToLeft)
- // horizontalAlign = 1 - horizontalAlign;
- // region.X += (int)(diff * horizontalAlign);
- // region.Width -= diff;
- // }
-
- // LayoutOptions verticalOptions = view.VerticalOptions;
- // if (verticalOptions.Alignment != LayoutAlignment.Fill)
- // {
- // SizeRequest request = child.Measure(region.Width, region.Height, MeasureFlags.IncludeMargins);
- // double diff = Math.Max(0, region.Height - request.Request.Height);
- // region.Y += (int)(diff * verticalOptions.Alignment.ToDouble());
- // region.Height -= diff;
- // }
-
- // Thickness margin = view.Margin;
- // region.X += margin.Left;
- // region.Width -= margin.HorizontalThickness;
- // region.Y += margin.Top;
- // region.Height -= margin.VerticalThickness;
-
- // child.Layout(region);
- }
-
- public void LowerChild(View view)
- {
- if (!InternalChildren.Contains(view) || (InternalChildren.First() as BaseHandle) == view)
- return;
-
- InternalChildren.Move(InternalChildren.IndexOf(view), 0);
- // OnChildrenReordered();
- }
-
- public void RaiseChild(View view)
- {
- if (!InternalChildren.Contains(view) || (InternalChildren.Last() as BaseHandle) == view)
- return;
-
- InternalChildren.Move(InternalChildren.IndexOf(view), InternalChildren.Count - 1);
- // OnChildrenReordered();
- }
-
- protected virtual void InvalidateLayout()
- {
- _hasDoneLayout = false;
- // InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
- if (!_hasDoneLayout)
- ForceLayout();
- }
-
- protected abstract void LayoutChildren(double x, double y, double width, double height);
-
- protected void OnChildMeasureInvalidated(object sender, EventArgs e)
- {
- InvalidationTrigger trigger = (e as InvalidationEventArgs)?.Trigger ?? InvalidationTrigger.Undefined;
- OnChildMeasureInvalidated((/*VisualElement*/BaseHandle)sender, trigger);
- OnChildMeasureInvalidated();
- }
-
- protected virtual void OnChildMeasureInvalidated()
- {
- }
-
- // protected override void OnSizeAllocated(double width, double height)
- // {
- // _allocatedFlag = true;
- // base.OnSizeAllocated(width, height);
- // UpdateChildrenLayout();
- // }
-
- protected virtual bool ShouldInvalidateOnChildAdded(View child)
- {
- return true;
- }
-
- protected virtual bool ShouldInvalidateOnChildRemoved(View child)
- {
- return true;
- }
-
- protected void UpdateChildrenLayout()
- {
- _hasDoneLayout = true;
-
- if (!ShouldLayoutChildren())
- return;
-
- var oldBounds = new Rectangle[LogicalChildrenInternal.Count];
- for (var index = 0; index < oldBounds.Length; index++)
- {
- var c = (/*VisualElement*/BaseHandle)LogicalChildrenInternal[index];
- // oldBounds[index] = c.Bounds;
- }
-
- // double width = Width;
- // double height = Height;
-
- // double x = Padding.Left;
- // double y = Padding.Top;
- // double w = Math.Max(0, width - Padding.HorizontalThickness);
- // double h = Math.Max(0, height - Padding.VerticalThickness);
-
- // var isHeadless = CompressedLayout.GetIsHeadless(this);
- // var headlessOffset = CompressedLayout.GetHeadlessOffset(this);
- // for (var i = 0; i < LogicalChildrenInternal.Count; i++)
- // CompressedLayout.SetHeadlessOffset((/*VisualElement*/BaseHandle)LogicalChildrenInternal[i], isHeadless ? new Point(headlessOffset.X + Bounds.X, headlessOffset.Y + Bounds.Y) : new Point());
-
- // LayoutChildren(x, y, w, h);
-
- // for (var i = 0; i < oldBounds.Length; i++)
- // {
- // Rectangle oldBound = oldBounds[i];
- // Rectangle newBound = ((/*VisualElement*/BaseHandle)LogicalChildrenInternal[i]).Bounds;
- // if (oldBound != newBound)
- // {
- // LayoutChanged?.Invoke(this, EventArgs.Empty);
- // return;
- // }
- // }
-
- // _lastLayoutSize = new Size((float)width, (float)height, 0);
- }
-
- internal static void LayoutChildIntoBoundingRegion(View child, Rectangle region, SizeRequest childSizeRequest)
- {
- // var parent = child.Parent as IFlowDirectionController;
- // bool isRightToLeft = false;
- // if (parent != null && (isRightToLeft = parent.EffectiveFlowDirection.IsRightToLeft()))
- // region = new Rectangle(parent.Width - region.Right, region.Y, region.Width, region.Height);
-
- // if (region.Size != childSizeRequest.Request)
- // {
- // bool canUseAlreadyDoneRequest = region.Width >= childSizeRequest.Request.Width && region.Height >= childSizeRequest.Request.Height;
-
- // LayoutOptions horizontalOptions = child.HorizontalOptions;
- // if (horizontalOptions.Alignment != LayoutAlignment.Fill)
- // {
- // SizeRequest request = canUseAlreadyDoneRequest ? childSizeRequest : child.Measure(region.Width, region.Height, MeasureFlags.IncludeMargins);
- // double diff = Math.Max(0, region.Width - request.Request.Width);
- // double horizontalAlign = horizontalOptions.Alignment.ToDouble();
- // if (isRightToLeft)
- // horizontalAlign = 1 - horizontalAlign;
- // region.X += (int)(diff * horizontalAlign);
- // region.Width -= diff;
- // }
-
- // LayoutOptions verticalOptions = child.VerticalOptions;
- // if (verticalOptions.Alignment != LayoutAlignment.Fill)
- // {
- // SizeRequest request = canUseAlreadyDoneRequest ? childSizeRequest : child.Measure(region.Width, region.Height, MeasureFlags.IncludeMargins);
- // double diff = Math.Max(0, region.Height - request.Request.Height);
- // region.Y += (int)(diff * verticalOptions.Alignment.ToDouble());
- // region.Height -= diff;
- // }
- // }
-
- // Thickness margin = child.Margin;
- // region.X += margin.Left;
- // region.Width -= margin.HorizontalThickness;
- // region.Y += margin.Top;
- // region.Height -= margin.VerticalThickness;
-
- // child.Layout(region);
- }
-
- internal virtual void OnChildMeasureInvalidated(/*VisualElement*/BaseHandle child, InvalidationTrigger trigger)
- {
- ReadOnlyCollection<Element> children = LogicalChildrenInternal;
- int count = children.Count;
- for (var index = 0; index < count; index++)
- {
- var v = LogicalChildrenInternal[index] as /*VisualElement*/BaseHandle;
- if (v != null /*&& v.IsVisible && (!v.IsPlatformEnabled || !v.IsNativeStateConsistent)*/)
- return;
- }
-
- var view = child as View;
- if (view != null)
- {
- // we can ignore the request if we are either fully constrained or when the size request changes and we were already fully constrainted
- // if ((trigger == InvalidationTrigger.MeasureChanged && view.Constraint == LayoutConstraint.Fixed) ||
- // (trigger == InvalidationTrigger.SizeRequestChanged && view.ComputedConstraint == LayoutConstraint.Fixed))
- // {
- // return;
- // }
- // if (trigger == InvalidationTrigger.HorizontalOptionsChanged || trigger == InvalidationTrigger.VerticalOptionsChanged)
- // {
- // ComputeConstraintForView(view);
- // }
- }
-
- //_allocatedFlag = false;
- if (trigger == InvalidationTrigger.RendererReady)
- {
- // InvalidateMeasureInternal(InvalidationTrigger.RendererReady);
- }
- else
- {
- // InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
- }
-
- s_resolutionList.Add(new KeyValuePair<Layout, int>(this, GetElementDepth(this)));
- if (!s_relayoutInProgress)
- {
- s_relayoutInProgress = true;
- Device.BeginInvokeOnMainThread(() =>
- {
- // if thread safety mattered we would need to lock this and compareexchange above
- IList<KeyValuePair<Layout, int>> copy = s_resolutionList;
- s_resolutionList = new List<KeyValuePair<Layout, int>>();
- s_relayoutInProgress = false;
-
- foreach (KeyValuePair<Layout, int> kvp in copy.OrderBy(kvp => kvp.Value))
- {
- Layout layout = kvp.Key;
- // double width = layout.Width, height = layout.Height;
- // if (!layout._allocatedFlag && width >= 0 && height >= 0)
- // {
- // layout.SizeAllocated(width, height);
- // }
- }
- });
- }
- }
-
- // internal override void OnIsVisibleChanged(bool oldValue, bool newValue)
- // {
- // base.OnIsVisibleChanged(oldValue, newValue);
- // if (newValue)
- // {
- // if (_lastLayoutSize != new Size(Width, Height))
- // {
- // UpdateChildrenLayout();
- // }
- // }
- // }
-
- static int GetElementDepth(Element view)
- {
- var result = 0;
- while (view.Parent != null)
- {
- result++;
- view = view.Parent;
- }
- return result;
- }
-
- void InternalChildrenOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- if (e.Action == NotifyCollectionChangedAction.Move)
- {
- return;
- }
-
- if (e.OldItems != null)
- {
- foreach (object item in e.OldItems)
- {
- var v = item as View;
- if (v == null)
- continue;
-
- OnInternalRemoved(v);
- }
- }
-
- if (e.NewItems != null)
- {
- foreach (object item in e.NewItems)
- {
- var v = item as View;
- if (v == null)
- continue;
-
- if ((item as BaseHandle) == this)
- throw new InvalidOperationException("Can not add self to own child collection.");
-
- OnInternalAdded(v);
- }
- }
- }
-
- void OnInternalAdded(View view)
- {
- var parent = view.Parent as Layout;
- parent?.InternalChildren.Remove(view);
-
- OnChildAdded(view);
- if (ShouldInvalidateOnChildAdded(view))
- InvalidateLayout();
-
- // view.MeasureInvalidated += OnChildMeasureInvalidated;
- }
-
- void OnInternalRemoved(View view)
- {
- // view.MeasureInvalidated -= OnChildMeasureInvalidated;
-
- OnChildRemoved(view);
- if (ShouldInvalidateOnChildRemoved(view))
- InvalidateLayout();
- }
-
- bool ShouldLayoutChildren()
- {
- // if (Width <= 0 || Height <= 0 || !LogicalChildrenInternal.Any() || !IsVisible || !IsNativeStateConsistent || DisableLayout)
- // return false;
-
- // foreach (Element element in VisibleDescendants())
- // {
- // var visual = element as /*VisualElement*/BaseHandle;
- // if (visual == null || !visual.IsVisible)
- // continue;
-
- // if (!visual.IsPlatformEnabled || !visual.IsNativeStateConsistent)
- // {
- // return false;
- // }
- // }
- return true;
- }
- }
+ [ContentProperty("Children")]
+ internal abstract class Layout<T> : Layout, IViewContainer<T> where T : View
+ {
+ readonly ElementCollection<T> _children;
+
+ protected Layout()
+ {
+ _children = new ElementCollection<T>(InternalChildren);
+ }
+
+ public new IList<T> Children
+ {
+ get { return _children; }
+ }
+
+ protected virtual void OnAdded(T view)
+ {
+ }
+
+ protected override void OnChildAdded(Element child)
+ {
+ base.OnChildAdded(child);
+
+ var typedChild = child as T;
+ if (typedChild != null)
+ OnAdded(typedChild);
+ }
+
+ protected override void OnChildRemoved(Element child)
+ {
+ base.OnChildRemoved(child);
+
+ var typedChild = child as T;
+ if (typedChild != null)
+ OnRemoved(typedChild);
+ }
+
+ protected virtual void OnRemoved(T view)
+ {
+ }
+ }
+
+ internal abstract class Layout : View, ILayout, ILayoutController, IPaddingElement
+ {
+ public static readonly BindableProperty IsClippedToBoundsProperty = BindableProperty.Create("IsClippedToBounds", typeof(bool), typeof(Layout), false);
+
+ public static readonly BindableProperty CascadeInputTransparentProperty = BindableProperty.Create(
+ nameof(CascadeInputTransparent), typeof(bool), typeof(Layout), true);
+
+ public static readonly BindableProperty PaddingProperty = PaddingElement.PaddingProperty;
+
+ static IList<KeyValuePair<Layout, int>> s_resolutionList = new List<KeyValuePair<Layout, int>>();
+ static bool s_relayoutInProgress;
+ bool _allocatedFlag;
+
+ bool _hasDoneLayout;
+ Size _lastLayoutSize = new Size(-1, -1, 0);
+
+ ReadOnlyCollection<Element> _logicalChildren;
+
+ protected Layout()
+ {
+ //if things were added in base ctor (through implicit styles), the items added aren't properly parented
+ if (InternalChildren.Count > 0)
+ InternalChildrenOnCollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, InternalChildren));
+
+ InternalChildren.CollectionChanged += InternalChildrenOnCollectionChanged;
+ }
+
+ public bool IsClippedToBounds
+ {
+ get { return (bool)GetValue(IsClippedToBoundsProperty); }
+ set { SetValue(IsClippedToBoundsProperty, value); }
+ }
+
+ public Thickness Padding
+ {
+ get { return (Thickness)GetValue(PaddingElement.PaddingProperty); }
+ set { SetValue(PaddingElement.PaddingProperty, value); }
+ }
+
+ public bool CascadeInputTransparent
+ {
+ get { return (bool)GetValue(CascadeInputTransparentProperty); }
+ set { SetValue(CascadeInputTransparentProperty, value); }
+ }
+
+ Thickness IPaddingElement.PaddingDefaultValueCreator()
+ {
+ return default(Thickness);
+ }
+
+ void IPaddingElement.OnPaddingPropertyChanged(Thickness oldValue, Thickness newValue)
+ {
+ UpdateChildrenLayout();
+ }
+
+ internal ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
+
+ internal override ReadOnlyCollection<Element> LogicalChildrenInternal
+ {
+ get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
+ }
+
+ public event EventHandler LayoutChanged;
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public IReadOnlyList<Element> Children
+ {
+ get { return InternalChildren; }
+ }
+
+ public void ForceLayout()
+ {
+ //SizeAllocated(Width, Height);
+ }
+
+ [Obsolete("OnSizeRequest is obsolete as of version 2.2.0. Please use OnMeasure instead.")]
+ // public sealed override SizeRequest GetSizeRequest(double widthConstraint, double heightConstraint)
+ // {
+ // SizeRequest size = base.GetSizeRequest(widthConstraint - Padding.HorizontalThickness, heightConstraint - Padding.VerticalThickness);
+ // return new SizeRequest(new Size(size.Request.Width + Padding.HorizontalThickness, size.Request.Height + Padding.VerticalThickness, 0),
+ // new Size(size.Minimum.Width + Padding.HorizontalThickness, size.Minimum.Height + Padding.VerticalThickness, 0));
+ // }
+
+ public static void LayoutChildIntoBoundingRegion(/*VisualElement*/BaseHandle child, Rectangle region)
+ {
+ //var parent = child.Parent as IFlowDirectionController;
+ bool isRightToLeft = false;
+ //if (parent != null && (isRightToLeft = parent.EffectiveFlowDirection.IsRightToLeft()))
+ //region = new Rectangle(parent.Width - region.Right, region.Y, region.Width, region.Height);
+
+ var view = child as View;
+ if (view == null)
+ {
+ //child.Layout(region);
+ return;
+ }
+
+ //LayoutOptions horizontalOptions = view.HorizontalOptions;
+ // if (horizontalOptions.Alignment != LayoutAlignment.Fill)
+ // {
+ // SizeRequest request = child.Measure(region.Width, region.Height, MeasureFlags.IncludeMargins);
+ // double diff = Math.Max(0, region.Width - request.Request.Width);
+ // double horizontalAlign = horizontalOptions.Alignment.ToDouble();
+ // if (isRightToLeft)
+ // horizontalAlign = 1 - horizontalAlign;
+ // region.X += (int)(diff * horizontalAlign);
+ // region.Width -= diff;
+ // }
+
+ // LayoutOptions verticalOptions = view.VerticalOptions;
+ // if (verticalOptions.Alignment != LayoutAlignment.Fill)
+ // {
+ // SizeRequest request = child.Measure(region.Width, region.Height, MeasureFlags.IncludeMargins);
+ // double diff = Math.Max(0, region.Height - request.Request.Height);
+ // region.Y += (int)(diff * verticalOptions.Alignment.ToDouble());
+ // region.Height -= diff;
+ // }
+
+ // Thickness margin = view.Margin;
+ // region.X += margin.Left;
+ // region.Width -= margin.HorizontalThickness;
+ // region.Y += margin.Top;
+ // region.Height -= margin.VerticalThickness;
+
+ // child.Layout(region);
+ }
+
+ public void LowerChild(View view)
+ {
+ if (!InternalChildren.Contains(view) || InternalChildren.First() == view)
+ return;
+
+ InternalChildren.Move(InternalChildren.IndexOf(view), 0);
+ // OnChildrenReordered();
+ }
+
+ public void RaiseChild(View view)
+ {
+ if (!InternalChildren.Contains(view) || InternalChildren.Last() == view)
+ return;
+
+ InternalChildren.Move(InternalChildren.IndexOf(view), InternalChildren.Count - 1);
+ // OnChildrenReordered();
+ }
+
+ protected virtual void InvalidateLayout()
+ {
+ _hasDoneLayout = false;
+ // InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
+ if (!_hasDoneLayout)
+ ForceLayout();
+ }
+
+ protected abstract void LayoutChildren(double x, double y, double width, double height);
+
+ protected void OnChildMeasureInvalidated(object sender, EventArgs e)
+ {
+ InvalidationTrigger trigger = (e as InvalidationEventArgs)?.Trigger ?? InvalidationTrigger.Undefined;
+ OnChildMeasureInvalidated((/*VisualElement*/BaseHandle)sender, trigger);
+ OnChildMeasureInvalidated();
+ }
+
+ protected virtual void OnChildMeasureInvalidated()
+ {
+ }
+
+ // protected override void OnSizeAllocated(double width, double height)
+ // {
+ // _allocatedFlag = true;
+ // base.OnSizeAllocated(width, height);
+ // UpdateChildrenLayout();
+ // }
+
+ protected virtual bool ShouldInvalidateOnChildAdded(View child)
+ {
+ return true;
+ }
+
+ protected virtual bool ShouldInvalidateOnChildRemoved(View child)
+ {
+ return true;
+ }
+
+ protected void UpdateChildrenLayout()
+ {
+ _hasDoneLayout = true;
+
+ if (!ShouldLayoutChildren())
+ return;
+
+ var oldBounds = new Rectangle[LogicalChildrenInternal.Count];
+ for (var index = 0; index < oldBounds.Length; index++)
+ {
+ var c = (/*VisualElement*/BaseHandle)LogicalChildrenInternal[index];
+ // oldBounds[index] = c.Bounds;
+ }
+
+ // double width = Width;
+ // double height = Height;
+
+ // double x = Padding.Left;
+ // double y = Padding.Top;
+ // double w = Math.Max(0, width - Padding.HorizontalThickness);
+ // double h = Math.Max(0, height - Padding.VerticalThickness);
+
+ // var isHeadless = CompressedLayout.GetIsHeadless(this);
+ // var headlessOffset = CompressedLayout.GetHeadlessOffset(this);
+ // for (var i = 0; i < LogicalChildrenInternal.Count; i++)
+ // CompressedLayout.SetHeadlessOffset((/*VisualElement*/BaseHandle)LogicalChildrenInternal[i], isHeadless ? new Point(headlessOffset.X + Bounds.X, headlessOffset.Y + Bounds.Y) : new Point());
+
+ // LayoutChildren(x, y, w, h);
+
+ // for (var i = 0; i < oldBounds.Length; i++)
+ // {
+ // Rectangle oldBound = oldBounds[i];
+ // Rectangle newBound = ((/*VisualElement*/BaseHandle)LogicalChildrenInternal[i]).Bounds;
+ // if (oldBound != newBound)
+ // {
+ // LayoutChanged?.Invoke(this, EventArgs.Empty);
+ // return;
+ // }
+ // }
+
+ // _lastLayoutSize = new Size((float)width, (float)height, 0);
+ }
+
+ internal static void LayoutChildIntoBoundingRegion(View child, Rectangle region, SizeRequest childSizeRequest)
+ {
+ // var parent = child.Parent as IFlowDirectionController;
+ bool isRightToLeft = false;
+ // if (parent != null && (isRightToLeft = parent.EffectiveFlowDirection.IsRightToLeft()))
+ // region = new Rectangle(parent.Width - region.Right, region.Y, region.Width, region.Height);
+
+ // if (region.Size != childSizeRequest.Request)
+ // {
+ // bool canUseAlreadyDoneRequest = region.Width >= childSizeRequest.Request.Width && region.Height >= childSizeRequest.Request.Height;
+
+ // LayoutOptions horizontalOptions = child.HorizontalOptions;
+ // if (horizontalOptions.Alignment != LayoutAlignment.Fill)
+ // {
+ // SizeRequest request = canUseAlreadyDoneRequest ? childSizeRequest : child.Measure(region.Width, region.Height, MeasureFlags.IncludeMargins);
+ // double diff = Math.Max(0, region.Width - request.Request.Width);
+ // double horizontalAlign = horizontalOptions.Alignment.ToDouble();
+ // if (isRightToLeft)
+ // horizontalAlign = 1 - horizontalAlign;
+ // region.X += (int)(diff * horizontalAlign);
+ // region.Width -= diff;
+ // }
+
+ // LayoutOptions verticalOptions = child.VerticalOptions;
+ // if (verticalOptions.Alignment != LayoutAlignment.Fill)
+ // {
+ // SizeRequest request = canUseAlreadyDoneRequest ? childSizeRequest : child.Measure(region.Width, region.Height, MeasureFlags.IncludeMargins);
+ // double diff = Math.Max(0, region.Height - request.Request.Height);
+ // region.Y += (int)(diff * verticalOptions.Alignment.ToDouble());
+ // region.Height -= diff;
+ // }
+ // }
+
+ // Thickness margin = child.Margin;
+ // region.X += margin.Left;
+ // region.Width -= margin.HorizontalThickness;
+ // region.Y += margin.Top;
+ // region.Height -= margin.VerticalThickness;
+
+ // child.Layout(region);
+ }
+
+ internal virtual void OnChildMeasureInvalidated(/*VisualElement*/BaseHandle child, InvalidationTrigger trigger)
+ {
+ ReadOnlyCollection<Element> children = LogicalChildrenInternal;
+ int count = children.Count;
+ for (var index = 0; index < count; index++)
+ {
+ var v = LogicalChildrenInternal[index] as /*VisualElement*/BaseHandle;
+ // if (v != null && v.IsVisible && (!v.IsPlatformEnabled || !v.IsNativeStateConsistent))
+ return;
+ }
+
+ var view = child as View;
+ if (view != null)
+ {
+ // we can ignore the request if we are either fully constrained or when the size request changes and we were already fully constrainted
+ // if ((trigger == InvalidationTrigger.MeasureChanged && view.Constraint == LayoutConstraint.Fixed) ||
+ // (trigger == InvalidationTrigger.SizeRequestChanged && view.ComputedConstraint == LayoutConstraint.Fixed))
+ // {
+ // return;
+ // }
+ // if (trigger == InvalidationTrigger.HorizontalOptionsChanged || trigger == InvalidationTrigger.VerticalOptionsChanged)
+ // {
+ // ComputeConstraintForView(view);
+ // }
+ }
+
+ _allocatedFlag = false;
+ if (trigger == InvalidationTrigger.RendererReady)
+ {
+ // InvalidateMeasureInternal(InvalidationTrigger.RendererReady);
+ }
+ else
+ {
+ // InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
+ }
+
+ s_resolutionList.Add(new KeyValuePair<Layout, int>(this, GetElementDepth(this)));
+ if (!s_relayoutInProgress)
+ {
+ s_relayoutInProgress = true;
+ Device.BeginInvokeOnMainThread(() =>
+ {
+ // if thread safety mattered we would need to lock this and compareexchange above
+ IList<KeyValuePair<Layout, int>> copy = s_resolutionList;
+ s_resolutionList = new List<KeyValuePair<Layout, int>>();
+ s_relayoutInProgress = false;
+
+ foreach (KeyValuePair<Layout, int> kvp in copy.OrderBy(kvp => kvp.Value))
+ {
+ Layout layout = kvp.Key;
+ // double width = layout.Width, height = layout.Height;
+ // if (!layout._allocatedFlag && width >= 0 && height >= 0)
+ // {
+ // layout.SizeAllocated(width, height);
+ // }
+ }
+ });
+ }
+ }
+
+ // internal override void OnIsVisibleChanged(bool oldValue, bool newValue)
+ // {
+ // base.OnIsVisibleChanged(oldValue, newValue);
+ // if (newValue)
+ // {
+ // if (_lastLayoutSize != new Size(Width, Height))
+ // {
+ // UpdateChildrenLayout();
+ // }
+ // }
+ // }
+
+ static int GetElementDepth(Element view)
+ {
+ var result = 0;
+ while (view.Parent != null)
+ {
+ result++;
+ view = view.Parent;
+ }
+ return result;
+ }
+
+ void InternalChildrenOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ if (e.Action == NotifyCollectionChangedAction.Move)
+ {
+ return;
+ }
+
+ if (e.OldItems != null)
+ {
+ foreach (object item in e.OldItems)
+ {
+ var v = item as View;
+ if (v == null)
+ continue;
+
+ OnInternalRemoved(v);
+ }
+ }
+
+ if (e.NewItems != null)
+ {
+ foreach (object item in e.NewItems)
+ {
+ var v = item as View;
+ if (v == null)
+ continue;
+
+ if (item == this)
+ throw new InvalidOperationException("Can not add self to own child collection.");
+
+ OnInternalAdded(v);
+ }
+ }
+ }
+
+ void OnInternalAdded(View view)
+ {
+ var parent = view.Parent as Layout;
+ parent?.InternalChildren.Remove(view);
+
+ OnChildAdded(view);
+ if (ShouldInvalidateOnChildAdded(view))
+ InvalidateLayout();
+
+ // view.MeasureInvalidated += OnChildMeasureInvalidated;
+ }
+
+ void OnInternalRemoved(View view)
+ {
+ // view.MeasureInvalidated -= OnChildMeasureInvalidated;
+
+ OnChildRemoved(view);
+ if (ShouldInvalidateOnChildRemoved(view))
+ InvalidateLayout();
+ }
+
+ bool ShouldLayoutChildren()
+ {
+ // if (Width <= 0 || Height <= 0 || !LogicalChildrenInternal.Any() || !IsVisible || !IsNativeStateConsistent || DisableLayout)
+ // return false;
+
+ // foreach (Element element in VisibleDescendants())
+ // {
+ // var visual = element as /*VisualElement*/BaseHandle;
+ // if (visual == null || !visual.IsVisible)
+ // continue;
+
+ // if (!visual.IsPlatformEnabled || !visual.IsNativeStateConsistent)
+ // {
+ // return false;
+ // }
+ // }
+ return true;
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- [Flags]
- internal enum LayoutAlignment
- {
- Start = 0,
- Center = 1,
- End = 2,
- Fill = 3
- }
+ [Flags]
+ internal enum LayoutAlignment
+ {
+ Start = 0,
+ Center = 1,
+ End = 2,
+ Fill = 3
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [Flags]
- internal enum LayoutExpandFlag
- {
- Expand = 4
- }
+ [Flags]
+ internal enum LayoutExpandFlag
+ {
+ Expand = 4
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [TypeConverter(typeof(LayoutOptionsConverter))]
- internal struct LayoutOptions
- {
- int _flags;
+ [TypeConverter(typeof(LayoutOptionsConverter))]
+ internal struct LayoutOptions
+ {
+ int _flags;
- public static readonly LayoutOptions Start = new LayoutOptions(LayoutAlignment.Start, false);
- public static readonly LayoutOptions Center = new LayoutOptions(LayoutAlignment.Center, false);
- public static readonly LayoutOptions End = new LayoutOptions(LayoutAlignment.End, false);
- public static readonly LayoutOptions Fill = new LayoutOptions(LayoutAlignment.Fill, false);
- public static readonly LayoutOptions StartAndExpand = new LayoutOptions(LayoutAlignment.Start, true);
- public static readonly LayoutOptions CenterAndExpand = new LayoutOptions(LayoutAlignment.Center, true);
- public static readonly LayoutOptions EndAndExpand = new LayoutOptions(LayoutAlignment.End, true);
- public static readonly LayoutOptions FillAndExpand = new LayoutOptions(LayoutAlignment.Fill, true);
+ public static readonly LayoutOptions Start = new LayoutOptions(LayoutAlignment.Start, false);
+ public static readonly LayoutOptions Center = new LayoutOptions(LayoutAlignment.Center, false);
+ public static readonly LayoutOptions End = new LayoutOptions(LayoutAlignment.End, false);
+ public static readonly LayoutOptions Fill = new LayoutOptions(LayoutAlignment.Fill, false);
+ public static readonly LayoutOptions StartAndExpand = new LayoutOptions(LayoutAlignment.Start, true);
+ public static readonly LayoutOptions CenterAndExpand = new LayoutOptions(LayoutAlignment.Center, true);
+ public static readonly LayoutOptions EndAndExpand = new LayoutOptions(LayoutAlignment.End, true);
+ public static readonly LayoutOptions FillAndExpand = new LayoutOptions(LayoutAlignment.Fill, true);
- public LayoutOptions(LayoutAlignment alignment, bool expands)
- {
- var a = (int)alignment;
- if (a < 0 || a > 3)
- throw new ArgumentOutOfRangeException();
- _flags = (int)alignment | (expands ? (int)LayoutExpandFlag.Expand : 0);
- }
+ public LayoutOptions(LayoutAlignment alignment, bool expands)
+ {
+ var a = (int)alignment;
+ if (a < 0 || a > 3)
+ throw new ArgumentOutOfRangeException();
+ _flags = (int)alignment | (expands ? (int)LayoutExpandFlag.Expand : 0);
+ }
- public LayoutAlignment Alignment
- {
- get { return (LayoutAlignment)(_flags & 3); }
- set { _flags = (_flags & ~3) | (int)value; }
- }
+ public LayoutAlignment Alignment
+ {
+ get { return (LayoutAlignment)(_flags & 3); }
+ set { _flags = (_flags & ~3) | (int)value; }
+ }
- public bool Expands
- {
- get { return (_flags & (int)LayoutExpandFlag.Expand) != 0; }
- set { _flags = (_flags & 3) | (value ? (int)LayoutExpandFlag.Expand : 0); }
- }
- }
+ public bool Expands
+ {
+ get { return (_flags & (int)LayoutExpandFlag.Expand) != 0; }
+ set { _flags = (_flags & 3) | (value ? (int)LayoutExpandFlag.Expand : 0); }
+ }
+ }
}
\ No newline at end of file
using System;
using System.Linq;
using System.Reflection;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI;
namespace Tizen.NUI.Binding
{
- // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.LayoutOptionsConverter")]
- [Xaml.TypeConversion(typeof(LayoutOptions))]
- internal sealed class LayoutOptionsConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- if (value != null) {
- var parts = value.Split('.');
- if (parts.Length > 2 || (parts.Length == 2 && parts [0] != "LayoutOptions"))
- throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(LayoutOptions)}");
- value = parts [parts.Length - 1];
- switch (value) {
- case "Start": return LayoutOptions.Start;
- case "Center": return LayoutOptions.Center;
- case "End": return LayoutOptions.End;
- case "Fill": return LayoutOptions.Fill;
- case "StartAndExpand": return LayoutOptions.StartAndExpand;
- case "CenterAndExpand": return LayoutOptions.CenterAndExpand;
- case "EndAndExpand": return LayoutOptions.EndAndExpand;
- case "FillAndExpand": return LayoutOptions.FillAndExpand;
- }
- FieldInfo field = typeof(LayoutOptions).GetFields().FirstOrDefault(fi => fi.IsStatic && fi.Name == value);
- if (field != null)
- return (LayoutOptions)field.GetValue(null);
- }
+ // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.LayoutOptionsConverter")]
+ [Xaml.TypeConversion(typeof(LayoutOptions))]
+ internal sealed class LayoutOptionsConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (value != null) {
+ var parts = value.Split('.');
+ if (parts.Length > 2 || (parts.Length == 2 && parts [0] != "LayoutOptions"))
+ throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(LayoutOptions)}");
+ value = parts [parts.Length - 1];
+ switch (value) {
+ case "Start": return LayoutOptions.Start;
+ case "Center": return LayoutOptions.Center;
+ case "End": return LayoutOptions.End;
+ case "Fill": return LayoutOptions.Fill;
+ case "StartAndExpand": return LayoutOptions.StartAndExpand;
+ case "CenterAndExpand": return LayoutOptions.CenterAndExpand;
+ case "EndAndExpand": return LayoutOptions.EndAndExpand;
+ case "FillAndExpand": return LayoutOptions.FillAndExpand;
+ }
+ FieldInfo field = typeof(LayoutOptions).GetFields().FirstOrDefault(fi => fi.IsStatic && fi.Name == value);
+ if (field != null)
+ return (LayoutOptions)field.GetValue(null);
+ }
- throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(LayoutOptions)}");
- }
- }
+ throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(LayoutOptions)}");
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- // [Xaml.ProvideCompiled("Tizen.NUI.Core.XamlC.ListStringTypeConverter")]
- [Xaml.TypeConversion(typeof(List<string>))]
- internal class ListStringTypeConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- if (value == null)
- return null;
-
- return value.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList();
- }
- }
+ // [Xaml.ProvideCompiled("Tizen.NUI.Core.XamlC.ListStringTypeConverter")]
+ [Xaml.TypeConversion(typeof(List<string>))]
+ internal class ListStringTypeConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (value == null)
+ return null;
+
+ return value.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList();
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class MenuItem : BaseMenuItem, IMenuItemController
- {
- public static readonly BindableProperty AcceleratorProperty = BindableProperty.CreateAttached(nameof(Accelerator), typeof(Accelerator), typeof(MenuItem), null);
-
- public static Accelerator GetAccelerator(BindableObject bindable) => (Accelerator)bindable.GetValue(AcceleratorProperty);
-
- public static void SetAccelerator(BindableObject bindable, Accelerator value) => bindable.SetValue(AcceleratorProperty, value);
-
- public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(MenuItem), null);
-
- public static readonly BindableProperty CommandProperty = BindableProperty.Create("Command", typeof(ICommand), typeof(MenuItem), null,
- propertyChanging: (bo, o, n) => ((MenuItem)bo).OnCommandChanging(), propertyChanged: (bo, o, n) => ((MenuItem)bo).OnCommandChanged());
-
- public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create("CommandParameter", typeof(object), typeof(MenuItem), null,
- propertyChanged: (bo, o, n) => ((MenuItem)bo).OnCommandParameterChanged());
-
- public static readonly BindableProperty IsDestructiveProperty = BindableProperty.Create("IsDestructive", typeof(bool), typeof(MenuItem), false);
-
- public static readonly BindableProperty IconProperty = BindableProperty.Create("Icon", typeof(FileImageSource), typeof(MenuItem), default(FileImageSource));
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create("IsEnabled", typeof(bool), typeof(ToolbarItem), true);
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string IsEnabledPropertyName
- {
- get
- {
- return IsEnabledProperty.PropertyName;
- }
- }
-
- public ICommand Command
- {
- get { return (ICommand)GetValue(CommandProperty); }
- set { SetValue(CommandProperty, value); }
- }
-
- public object CommandParameter
- {
- get { return GetValue(CommandParameterProperty); }
- set { SetValue(CommandParameterProperty, value); }
- }
-
- public FileImageSource Icon
- {
- get { return (FileImageSource)GetValue(IconProperty); }
- set { SetValue(IconProperty, value); }
- }
-
- public bool IsDestructive
- {
- get { return (bool)GetValue(IsDestructiveProperty); }
- set { SetValue(IsDestructiveProperty, value); }
- }
-
- public string Text
- {
- get { return (string)GetValue(TextProperty); }
- set { SetValue(TextProperty, value); }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool IsEnabled
- {
- get { return (bool)GetValue(IsEnabledProperty); }
- set { SetValue(IsEnabledProperty, value); }
- }
-
- bool IsEnabledCore
- {
- set { SetValueCore(IsEnabledProperty, value); }
- }
-
- public event EventHandler Clicked;
-
- protected virtual void OnClicked()
- => Clicked?.Invoke(this, EventArgs.Empty);
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void Activate()
- {
- if (Command != null)
- {
- if (IsEnabled)
- Command.Execute(CommandParameter);
- }
-
- OnClicked();
- }
-
- void OnCommandCanExecuteChanged(object sender, EventArgs eventArgs)
- {
- IsEnabledCore = Command.CanExecute(CommandParameter);
- }
-
- void OnCommandChanged()
- {
- if (Command == null)
- {
- IsEnabledCore = true;
- return;
- }
-
- IsEnabledCore = Command.CanExecute(CommandParameter);
-
- Command.CanExecuteChanged += OnCommandCanExecuteChanged;
- }
-
- void OnCommandChanging()
- {
- if (Command == null)
- return;
-
- Command.CanExecuteChanged -= OnCommandCanExecuteChanged;
- }
-
- void OnCommandParameterChanged()
- {
- if (Command == null)
- return;
-
- IsEnabledCore = Command.CanExecute(CommandParameter);
- }
- }
+ internal class MenuItem : BaseMenuItem, IMenuItemController
+ {
+ public static readonly BindableProperty AcceleratorProperty = BindableProperty.CreateAttached(nameof(Accelerator), typeof(Accelerator), typeof(MenuItem), null);
+
+ public static Accelerator GetAccelerator(BindableObject bindable) => (Accelerator)bindable.GetValue(AcceleratorProperty);
+
+ public static void SetAccelerator(BindableObject bindable, Accelerator value) => bindable.SetValue(AcceleratorProperty, value);
+
+ public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(MenuItem), null);
+
+ public static readonly BindableProperty CommandProperty = BindableProperty.Create("Command", typeof(ICommand), typeof(MenuItem), null,
+ propertyChanging: (bo, o, n) => ((MenuItem)bo).OnCommandChanging(), propertyChanged: (bo, o, n) => ((MenuItem)bo).OnCommandChanged());
+
+ public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create("CommandParameter", typeof(object), typeof(MenuItem), null,
+ propertyChanged: (bo, o, n) => ((MenuItem)bo).OnCommandParameterChanged());
+
+ public static readonly BindableProperty IsDestructiveProperty = BindableProperty.Create("IsDestructive", typeof(bool), typeof(MenuItem), false);
+
+ public static readonly BindableProperty IconProperty = BindableProperty.Create("Icon", typeof(FileImageSource), typeof(MenuItem), default(FileImageSource));
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create("IsEnabled", typeof(bool), typeof(ToolbarItem), true);
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string IsEnabledPropertyName
+ {
+ get
+ {
+ return IsEnabledProperty.PropertyName;
+ }
+ }
+
+ public ICommand Command
+ {
+ get { return (ICommand)GetValue(CommandProperty); }
+ set { SetValue(CommandProperty, value); }
+ }
+
+ public object CommandParameter
+ {
+ get { return GetValue(CommandParameterProperty); }
+ set { SetValue(CommandParameterProperty, value); }
+ }
+
+ public FileImageSource Icon
+ {
+ get { return (FileImageSource)GetValue(IconProperty); }
+ set { SetValue(IconProperty, value); }
+ }
+
+ public bool IsDestructive
+ {
+ get { return (bool)GetValue(IsDestructiveProperty); }
+ set { SetValue(IsDestructiveProperty, value); }
+ }
+
+ public string Text
+ {
+ get { return (string)GetValue(TextProperty); }
+ set { SetValue(TextProperty, value); }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool IsEnabled
+ {
+ get { return (bool)GetValue(IsEnabledProperty); }
+ set { SetValue(IsEnabledProperty, value); }
+ }
+
+ bool IsEnabledCore
+ {
+ set { SetValueCore(IsEnabledProperty, value); }
+ }
+
+ public event EventHandler Clicked;
+
+ protected virtual void OnClicked()
+ => Clicked?.Invoke(this, EventArgs.Empty);
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Activate()
+ {
+ if (Command != null)
+ {
+ if (IsEnabled)
+ Command.Execute(CommandParameter);
+ }
+
+ OnClicked();
+ }
+
+ void OnCommandCanExecuteChanged(object sender, EventArgs eventArgs)
+ {
+ IsEnabledCore = Command.CanExecute(CommandParameter);
+ }
+
+ void OnCommandChanged()
+ {
+ if (Command == null)
+ {
+ IsEnabledCore = true;
+ return;
+ }
+
+ IsEnabledCore = Command.CanExecute(CommandParameter);
+
+ Command.CanExecuteChanged += OnCommandCanExecuteChanged;
+ }
+
+ void OnCommandChanging()
+ {
+ if (Command == null)
+ return;
+
+ Command.CanExecuteChanged -= OnCommandCanExecuteChanged;
+ }
+
+ void OnCommandParameterChanged()
+ {
+ if (Command == null)
+ return;
+
+ IsEnabledCore = Command.CanExecute(CommandParameter);
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using Tizen.NUI.StyleSheets;
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI.Binding
+{
+ internal sealed class MergedStyle : IStyle
+ {
+ ////If the base type is one of these, stop registering dynamic resources further
+ ////The last one (typeof(Element)) is a safety guard as we might be creating VisualElement directly in internal code
+ static readonly IList<Type> s_stopAtTypes = new List<Type> { typeof(View), typeof(Layout<>), typeof(Element) };
+
+ IList<BindableProperty> _classStyleProperties;
+
+ readonly List<BindableProperty> _implicitStyles = new List<BindableProperty>();
+
+ IList<Style> _classStyles;
+
+ IStyle _implicitStyle;
+
+ IStyle _style;
+
+ IList<string> _styleClass;
+
+ public MergedStyle(Type targetType, BindableObject target)
+ {
+ Target = target;
+ TargetType = targetType;
+ RegisterImplicitStyles();
+ Apply(Target);
+ }
+
+ public IStyle Style
+ {
+ get { return _style; }
+ set { SetStyle(ImplicitStyle, ClassStyles, value); }
+ }
+
+ public IList<string> StyleClass
+ {
+ get { return _styleClass; }
+ set
+ {
+ if (_styleClass == value)
+ return;
+
+ if (_styleClass != null && _classStyles != null)
+ foreach (var classStyleProperty in _classStyleProperties)
+ Target.RemoveDynamicResource(classStyleProperty);
+
+ _styleClass = value;
+
+ if (_styleClass != null) {
+ _classStyleProperties = new List<BindableProperty> ();
+ foreach (var styleClass in _styleClass) {
+ var classStyleProperty = BindableProperty.Create ("ClassStyle", typeof(IList<Style>), typeof(View), default(IList<Style>),
+ propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable)._mergedStyle.OnClassStyleChanged());
+ _classStyleProperties.Add (classStyleProperty);
+ Target.OnSetDynamicResource (classStyleProperty, Tizen.NUI.Binding.Style.StyleClassPrefix + styleClass);
+ }
+ }
+ }
+ }
+
+ public BindableObject Target { get; }
+
+ IList<Style> ClassStyles
+ {
+ get { return _classStyles; }
+ set { SetStyle(ImplicitStyle, value, Style); }
+ }
+
+ IStyle ImplicitStyle
+ {
+ get { return _implicitStyle; }
+ set { SetStyle(value, ClassStyles, Style); }
+ }
+
+ public void Apply(BindableObject bindable)
+ {
+ ImplicitStyle?.Apply(bindable);
+ if (ClassStyles != null)
+ foreach (var classStyle in ClassStyles)
+ ((IStyle)classStyle)?.Apply(bindable);
+ Style?.Apply(bindable);
+ }
+
+ public Type TargetType { get; }
+
+ public void UnApply(BindableObject bindable)
+ {
+ Style?.UnApply(bindable);
+ if (ClassStyles != null)
+ foreach (var classStyle in ClassStyles)
+ ((IStyle)classStyle)?.UnApply(bindable);
+ ImplicitStyle?.UnApply(bindable);
+ }
+
+ void OnClassStyleChanged()
+ {
+ ClassStyles = _classStyleProperties.Select (p => (Target.GetValue (p) as IList<Style>)?.FirstOrDefault (s => s.CanBeAppliedTo (TargetType))).ToList ();
+ }
+
+ void OnImplicitStyleChanged()
+ {
+ var first = true;
+ foreach (BindableProperty implicitStyleProperty in _implicitStyles)
+ {
+ var implicitStyle = (Style)Target.GetValue(implicitStyleProperty);
+ if (implicitStyle != null)
+ {
+ if (first || implicitStyle.ApplyToDerivedTypes)
+ {
+ ImplicitStyle = implicitStyle;
+ return;
+ }
+ }
+ first = false;
+ }
+ }
+
+ void RegisterImplicitStyles()
+ {
+ Type type = TargetType;
+ while (true) {
+ BindableProperty implicitStyleProperty = BindableProperty.Create("ImplicitStyle", typeof(Style), typeof(View), default(Style),
+ propertyChanged: (bindable, oldvalue, newvalue) => OnImplicitStyleChanged());
+ _implicitStyles.Add(implicitStyleProperty);
+ Target.SetDynamicResource(implicitStyleProperty, type.FullName);
+ type = type.GetTypeInfo().BaseType;
+ if (s_stopAtTypes.Contains(type))
+ return;
+ }
+ }
+
+ void SetStyle(IStyle implicitStyle, IList<Style> classStyles, IStyle style)
+ {
+ bool shouldReApplyStyle = implicitStyle != ImplicitStyle || classStyles != ClassStyles || Style != style;
+ bool shouldReApplyClassStyle = implicitStyle != ImplicitStyle || classStyles != ClassStyles;
+ bool shouldReApplyImplicitStyle = implicitStyle != ImplicitStyle && (Style as Style == null || ((Style)Style).CanCascade);
+
+ if (shouldReApplyStyle)
+ Style?.UnApply(Target);
+ if (shouldReApplyClassStyle && ClassStyles != null)
+ foreach (var classStyle in ClassStyles)
+ ((IStyle)classStyle)?.UnApply(Target);
+ if (shouldReApplyImplicitStyle)
+ ImplicitStyle?.UnApply(Target);
+
+ _implicitStyle = implicitStyle;
+ _classStyles = classStyles;
+ _style = style;
+
+ if (shouldReApplyImplicitStyle)
+ ImplicitStyle?.Apply(Target);
+ if (shouldReApplyClassStyle && ClassStyles != null)
+ foreach (var classStyle in ClassStyles)
+ ((IStyle)classStyle)?.Apply(Target);
+ if (shouldReApplyStyle)
+ Style?.Apply(Target);
+ }
+ }
+}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal interface IMessagingCenter
- {
- void Send<TSender, TArgs>(TSender sender, string message, TArgs args) where TSender : class;
-
- void Send<TSender>(TSender sender, string message) where TSender : class;
-
- void Subscribe<TSender, TArgs>(object subscriber, string message, Action<TSender, TArgs> callback, TSender source = null) where TSender : class;
-
- void Subscribe<TSender>(object subscriber, string message, Action<TSender> callback, TSender source = null) where TSender : class;
-
- void Unsubscribe<TSender, TArgs>(object subscriber, string message) where TSender : class;
-
- void Unsubscribe<TSender>(object subscriber, string message) where TSender : class;
- }
-
- internal class MessagingCenter : IMessagingCenter
- {
- public static IMessagingCenter Instance { get; } = new MessagingCenter();
-
- class Sender : Tuple<string, Type, Type>
- {
- public Sender(string message, Type senderType, Type argType) : base(message, senderType, argType)
- {
- }
- }
-
- delegate bool Filter(object sender);
-
- class MaybeWeakReference
- {
- WeakReference DelegateWeakReference { get; }
- object DelegateStrongReference { get; }
-
- readonly bool _isStrongReference;
-
- public MaybeWeakReference(object subscriber, object delegateSource)
- {
- if (subscriber.Equals(delegateSource))
- {
- // The target is the subscriber; we can use a weakreference
- DelegateWeakReference = new WeakReference(delegateSource);
- _isStrongReference = false;
- }
- else
- {
- DelegateStrongReference = delegateSource;
- _isStrongReference = true;
- }
- }
-
- public object Target => _isStrongReference ? DelegateStrongReference : DelegateWeakReference.Target;
- public bool IsAlive => _isStrongReference || DelegateWeakReference.IsAlive;
- }
-
- class Subscription : Tuple<WeakReference, MaybeWeakReference, MethodInfo, Filter>
- {
- public Subscription(object subscriber, object delegateSource, MethodInfo methodInfo, Filter filter)
- : base(new WeakReference(subscriber), new MaybeWeakReference(subscriber, delegateSource), methodInfo, filter)
- {
- }
-
- public WeakReference Subscriber => Item1;
- MaybeWeakReference DelegateSource => Item2;
- MethodInfo MethodInfo => Item3;
- Filter Filter => Item4;
-
- public void InvokeCallback(object sender, object args)
- {
- if (!Filter(sender))
- {
- return;
- }
-
- if (MethodInfo.IsStatic)
- {
- MethodInfo.Invoke(null, MethodInfo.GetParameters().Length == 1 ? new[] { sender } : new[] { sender, args });
- return;
- }
-
- var target = DelegateSource.Target;
-
- if (target == null)
- {
- return; // Collected
- }
-
- MethodInfo.Invoke(target, MethodInfo.GetParameters().Length == 1 ? new[] { sender } : new[] { sender, args });
- }
-
- public bool CanBeRemoved()
- {
- return !Subscriber.IsAlive || !DelegateSource.IsAlive;
- }
- }
-
- readonly Dictionary<Sender, List<Subscription>> _subscriptions =
- new Dictionary<Sender, List<Subscription>>();
-
- public static void Send<TSender, TArgs>(TSender sender, string message, TArgs args) where TSender : class
- {
- Instance.Send(sender, message, args);
- }
-
- void IMessagingCenter.Send<TSender, TArgs>(TSender sender, string message, TArgs args)
- {
- if (sender == null)
- throw new ArgumentNullException(nameof(sender));
- InnerSend(message, typeof(TSender), typeof(TArgs), sender, args);
- }
-
- public static void Send<TSender>(TSender sender, string message) where TSender : class
- {
- Instance.Send(sender, message);
- }
-
- void IMessagingCenter.Send<TSender>(TSender sender, string message)
- {
- if (sender == null)
- throw new ArgumentNullException(nameof(sender));
- InnerSend(message, typeof(TSender), null, sender, null);
- }
-
- public static void Subscribe<TSender, TArgs>(object subscriber, string message, Action<TSender, TArgs> callback, TSender source = null) where TSender : class
- {
- Instance.Subscribe(subscriber, message, callback, source);
- }
-
- void IMessagingCenter.Subscribe<TSender, TArgs>(object subscriber, string message, Action<TSender, TArgs> callback, TSender source)
- {
- if (subscriber == null)
- throw new ArgumentNullException(nameof(subscriber));
- if (callback == null)
- throw new ArgumentNullException(nameof(callback));
-
- var target = callback.Target;
-
- Filter filter = sender =>
- {
- var send = (TSender)sender;
- return (source == null || send == source);
- };
-
- InnerSubscribe(subscriber, message, typeof(TSender), typeof(TArgs), target, callback.GetMethodInfo(), filter);
- }
-
- public static void Subscribe<TSender>(object subscriber, string message, Action<TSender> callback, TSender source = null) where TSender : class
- {
- Instance.Subscribe(subscriber, message, callback, source);
- }
-
- void IMessagingCenter.Subscribe<TSender>(object subscriber, string message, Action<TSender> callback, TSender source)
- {
- if (subscriber == null)
- throw new ArgumentNullException(nameof(subscriber));
- if (callback == null)
- throw new ArgumentNullException(nameof(callback));
-
- var target = callback.Target;
-
- Filter filter = sender =>
- {
- var send = (TSender)sender;
- return (source == null || send == source);
- };
-
- InnerSubscribe(subscriber, message, typeof(TSender), null, target, callback.GetMethodInfo(), filter);
- }
-
- public static void Unsubscribe<TSender, TArgs>(object subscriber, string message) where TSender : class
- {
- Instance.Unsubscribe<TSender, TArgs>(subscriber, message);
- }
-
- void IMessagingCenter.Unsubscribe<TSender, TArgs>(object subscriber, string message)
- {
- InnerUnsubscribe(message, typeof(TSender), typeof(TArgs), subscriber);
- }
-
- public static void Unsubscribe<TSender>(object subscriber, string message) where TSender : class
- {
- Instance.Unsubscribe<TSender>(subscriber, message);
- }
-
- void IMessagingCenter.Unsubscribe<TSender>(object subscriber, string message)
- {
- InnerUnsubscribe(message, typeof(TSender), null, subscriber);
- }
-
- void InnerSend(string message, Type senderType, Type argType, object sender, object args)
- {
- if (message == null)
- throw new ArgumentNullException(nameof(message));
- var key = new Sender(message, senderType, argType);
- if (!_subscriptions.ContainsKey(key))
- return;
- List<Subscription> subcriptions = _subscriptions[key];
- if (subcriptions == null || !subcriptions.Any())
- return; // should not be reachable
-
- // ok so this code looks a bit funky but here is the gist of the problem. It is possible that in the course
- // of executing the callbacks for this message someone will subscribe/unsubscribe from the same message in
- // the callback. This would invalidate the enumerator. To work around this we make a copy. However if you unsubscribe
- // from a message you can fairly reasonably expect that you will therefor not receive a call. To fix this we then
- // check that the item we are about to send the message to actually exists in the live list.
- List<Subscription> subscriptionsCopy = subcriptions.ToList();
- foreach (Subscription subscription in subscriptionsCopy)
- {
- if (subscription.Subscriber.Target != null && subcriptions.Contains(subscription))
- {
- subscription.InvokeCallback(sender, args);
- }
- }
- }
-
- void InnerSubscribe(object subscriber, string message, Type senderType, Type argType, object target, MethodInfo methodInfo, Filter filter)
- {
- if (message == null)
- throw new ArgumentNullException(nameof(message));
- var key = new Sender(message, senderType, argType);
- var value = new Subscription(subscriber, target, methodInfo, filter);
- if (_subscriptions.ContainsKey(key))
- {
- _subscriptions[key].Add(value);
- }
- else
- {
- var list = new List<Subscription> { value };
- _subscriptions[key] = list;
- }
- }
-
- void InnerUnsubscribe(string message, Type senderType, Type argType, object subscriber)
- {
- if (subscriber == null)
- throw new ArgumentNullException(nameof(subscriber));
- if (message == null)
- throw new ArgumentNullException(nameof(message));
-
- var key = new Sender(message, senderType, argType);
- if (!_subscriptions.ContainsKey(key))
- return;
- _subscriptions[key].RemoveAll(sub => sub.CanBeRemoved() || sub.Subscriber.Target == subscriber);
- if (!_subscriptions[key].Any())
- _subscriptions.Remove(key);
- }
-
- // This is a bit gross; it only exists to support the unit tests in PageTests
- // because the implementations of ActionSheet, Alert, and IsBusy are all very
- // tightly coupled to the MessagingCenter singleton
- internal static void ClearSubscribers()
- {
- (Instance as MessagingCenter)?._subscriptions.Clear();
- }
- }
+ internal interface IMessagingCenter
+ {
+ void Send<TSender, TArgs>(TSender sender, string message, TArgs args) where TSender : class;
+
+ void Send<TSender>(TSender sender, string message) where TSender : class;
+
+ void Subscribe<TSender, TArgs>(object subscriber, string message, Action<TSender, TArgs> callback, TSender source = null) where TSender : class;
+
+ void Subscribe<TSender>(object subscriber, string message, Action<TSender> callback, TSender source = null) where TSender : class;
+
+ void Unsubscribe<TSender, TArgs>(object subscriber, string message) where TSender : class;
+
+ void Unsubscribe<TSender>(object subscriber, string message) where TSender : class;
+ }
+
+ internal class MessagingCenter : IMessagingCenter
+ {
+ public static IMessagingCenter Instance { get; } = new MessagingCenter();
+
+ class Sender : Tuple<string, Type, Type>
+ {
+ public Sender(string message, Type senderType, Type argType) : base(message, senderType, argType)
+ {
+ }
+ }
+
+ delegate bool Filter(object sender);
+
+ class MaybeWeakReference
+ {
+ WeakReference DelegateWeakReference { get; }
+ object DelegateStrongReference { get; }
+
+ readonly bool _isStrongReference;
+
+ public MaybeWeakReference(object subscriber, object delegateSource)
+ {
+ if (subscriber.Equals(delegateSource))
+ {
+ // The target is the subscriber; we can use a weakreference
+ DelegateWeakReference = new WeakReference(delegateSource);
+ _isStrongReference = false;
+ }
+ else
+ {
+ DelegateStrongReference = delegateSource;
+ _isStrongReference = true;
+ }
+ }
+
+ public object Target => _isStrongReference ? DelegateStrongReference : DelegateWeakReference.Target;
+ public bool IsAlive => _isStrongReference || DelegateWeakReference.IsAlive;
+ }
+
+ class Subscription : Tuple<WeakReference, MaybeWeakReference, MethodInfo, Filter>
+ {
+ public Subscription(object subscriber, object delegateSource, MethodInfo methodInfo, Filter filter)
+ : base(new WeakReference(subscriber), new MaybeWeakReference(subscriber, delegateSource), methodInfo, filter)
+ {
+ }
+
+ public WeakReference Subscriber => Item1;
+ MaybeWeakReference DelegateSource => Item2;
+ MethodInfo MethodInfo => Item3;
+ Filter Filter => Item4;
+
+ public void InvokeCallback(object sender, object args)
+ {
+ if (!Filter(sender))
+ {
+ return;
+ }
+
+ if (MethodInfo.IsStatic)
+ {
+ MethodInfo.Invoke(null, MethodInfo.GetParameters().Length == 1 ? new[] { sender } : new[] { sender, args });
+ return;
+ }
+
+ var target = DelegateSource.Target;
+
+ if (target == null)
+ {
+ return; // Collected
+ }
+
+ MethodInfo.Invoke(target, MethodInfo.GetParameters().Length == 1 ? new[] { sender } : new[] { sender, args });
+ }
+
+ public bool CanBeRemoved()
+ {
+ return !Subscriber.IsAlive || !DelegateSource.IsAlive;
+ }
+ }
+
+ readonly Dictionary<Sender, List<Subscription>> _subscriptions =
+ new Dictionary<Sender, List<Subscription>>();
+
+ public static void Send<TSender, TArgs>(TSender sender, string message, TArgs args) where TSender : class
+ {
+ Instance.Send(sender, message, args);
+ }
+
+ void IMessagingCenter.Send<TSender, TArgs>(TSender sender, string message, TArgs args)
+ {
+ if (sender == null)
+ throw new ArgumentNullException(nameof(sender));
+ InnerSend(message, typeof(TSender), typeof(TArgs), sender, args);
+ }
+
+ public static void Send<TSender>(TSender sender, string message) where TSender : class
+ {
+ Instance.Send(sender, message);
+ }
+
+ void IMessagingCenter.Send<TSender>(TSender sender, string message)
+ {
+ if (sender == null)
+ throw new ArgumentNullException(nameof(sender));
+ InnerSend(message, typeof(TSender), null, sender, null);
+ }
+
+ public static void Subscribe<TSender, TArgs>(object subscriber, string message, Action<TSender, TArgs> callback, TSender source = null) where TSender : class
+ {
+ Instance.Subscribe(subscriber, message, callback, source);
+ }
+
+ void IMessagingCenter.Subscribe<TSender, TArgs>(object subscriber, string message, Action<TSender, TArgs> callback, TSender source)
+ {
+ if (subscriber == null)
+ throw new ArgumentNullException(nameof(subscriber));
+ if (callback == null)
+ throw new ArgumentNullException(nameof(callback));
+
+ var target = callback.Target;
+
+ Filter filter = sender =>
+ {
+ var send = (TSender)sender;
+ return (source == null || send == source);
+ };
+
+ InnerSubscribe(subscriber, message, typeof(TSender), typeof(TArgs), target, callback.GetMethodInfo(), filter);
+ }
+
+ public static void Subscribe<TSender>(object subscriber, string message, Action<TSender> callback, TSender source = null) where TSender : class
+ {
+ Instance.Subscribe(subscriber, message, callback, source);
+ }
+
+ void IMessagingCenter.Subscribe<TSender>(object subscriber, string message, Action<TSender> callback, TSender source)
+ {
+ if (subscriber == null)
+ throw new ArgumentNullException(nameof(subscriber));
+ if (callback == null)
+ throw new ArgumentNullException(nameof(callback));
+
+ var target = callback.Target;
+
+ Filter filter = sender =>
+ {
+ var send = (TSender)sender;
+ return (source == null || send == source);
+ };
+
+ InnerSubscribe(subscriber, message, typeof(TSender), null, target, callback.GetMethodInfo(), filter);
+ }
+
+ public static void Unsubscribe<TSender, TArgs>(object subscriber, string message) where TSender : class
+ {
+ Instance.Unsubscribe<TSender, TArgs>(subscriber, message);
+ }
+
+ void IMessagingCenter.Unsubscribe<TSender, TArgs>(object subscriber, string message)
+ {
+ InnerUnsubscribe(message, typeof(TSender), typeof(TArgs), subscriber);
+ }
+
+ public static void Unsubscribe<TSender>(object subscriber, string message) where TSender : class
+ {
+ Instance.Unsubscribe<TSender>(subscriber, message);
+ }
+
+ void IMessagingCenter.Unsubscribe<TSender>(object subscriber, string message)
+ {
+ InnerUnsubscribe(message, typeof(TSender), null, subscriber);
+ }
+
+ void InnerSend(string message, Type senderType, Type argType, object sender, object args)
+ {
+ if (message == null)
+ throw new ArgumentNullException(nameof(message));
+ var key = new Sender(message, senderType, argType);
+ if (!_subscriptions.ContainsKey(key))
+ return;
+ List<Subscription> subcriptions = _subscriptions[key];
+ if (subcriptions == null || !subcriptions.Any())
+ return; // should not be reachable
+
+ // ok so this code looks a bit funky but here is the gist of the problem. It is possible that in the course
+ // of executing the callbacks for this message someone will subscribe/unsubscribe from the same message in
+ // the callback. This would invalidate the enumerator. To work around this we make a copy. However if you unsubscribe
+ // from a message you can fairly reasonably expect that you will therefor not receive a call. To fix this we then
+ // check that the item we are about to send the message to actually exists in the live list.
+ List<Subscription> subscriptionsCopy = subcriptions.ToList();
+ foreach (Subscription subscription in subscriptionsCopy)
+ {
+ if (subscription.Subscriber.Target != null && subcriptions.Contains(subscription))
+ {
+ subscription.InvokeCallback(sender, args);
+ }
+ }
+ }
+
+ void InnerSubscribe(object subscriber, string message, Type senderType, Type argType, object target, MethodInfo methodInfo, Filter filter)
+ {
+ if (message == null)
+ throw new ArgumentNullException(nameof(message));
+ var key = new Sender(message, senderType, argType);
+ var value = new Subscription(subscriber, target, methodInfo, filter);
+ if (_subscriptions.ContainsKey(key))
+ {
+ _subscriptions[key].Add(value);
+ }
+ else
+ {
+ var list = new List<Subscription> { value };
+ _subscriptions[key] = list;
+ }
+ }
+
+ void InnerUnsubscribe(string message, Type senderType, Type argType, object subscriber)
+ {
+ if (subscriber == null)
+ throw new ArgumentNullException(nameof(subscriber));
+ if (message == null)
+ throw new ArgumentNullException(nameof(message));
+
+ var key = new Sender(message, senderType, argType);
+ if (!_subscriptions.ContainsKey(key))
+ return;
+ _subscriptions[key].RemoveAll(sub => sub.CanBeRemoved() || sub.Subscriber.Target == subscriber);
+ if (!_subscriptions[key].Any())
+ _subscriptions.Remove(key);
+ }
+
+ // This is a bit gross; it only exists to support the unit tests in PageTests
+ // because the implementations of ActionSheet, Alert, and IsBusy are all very
+ // tightly coupled to the MessagingCenter singleton
+ internal static void ClearSubscribers()
+ {
+ (Instance as MessagingCenter)?._subscriptions.Clear();
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal abstract class ModalEventArgs : EventArgs
- {
- protected ModalEventArgs(Page modal)
- {
- Modal = modal;
- }
+ internal abstract class ModalEventArgs : EventArgs
+ {
+ protected ModalEventArgs(Page modal)
+ {
+ Modal = modal;
+ }
- public Page Modal { get; private set; }
- }
+ public Page Modal { get; private set; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class ModalPoppedEventArgs : ModalEventArgs
- {
- public ModalPoppedEventArgs(Page modal) : base(modal)
- {
- }
- }
+ internal class ModalPoppedEventArgs : ModalEventArgs
+ {
+ public ModalPoppedEventArgs(Page modal) : base(modal)
+ {
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class ModalPoppingEventArgs : ModalEventArgs
- {
- public ModalPoppingEventArgs(Page modal) : base(modal)
- {
- }
+ internal class ModalPoppingEventArgs : ModalEventArgs
+ {
+ public ModalPoppingEventArgs(Page modal) : base(modal)
+ {
+ }
- public bool Cancel { get; set; }
- }
+ public bool Cancel { get; set; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class ModalPushedEventArgs : ModalEventArgs
- {
- public ModalPushedEventArgs(Page modal) : base(modal)
- {
- }
- }
+ internal class ModalPushedEventArgs : ModalEventArgs
+ {
+ public ModalPushedEventArgs(Page modal) : base(modal)
+ {
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class ModalPushingEventArgs : ModalEventArgs
- {
- public ModalPushingEventArgs(Page modal) : base(modal)
- {
- }
- }
+ internal class ModalPushingEventArgs : ModalEventArgs
+ {
+ public ModalPushingEventArgs(Page modal) : base(modal)
+ {
+ }
+ }
}
\ No newline at end of file
+++ /dev/null
-using Tizen.NUI.Internals;
-
-namespace Tizen.NUI.Binding
-{
- internal static class NameScopeExtensions
- {
- public static T FindByName<T>(this Element element, string name)
- {
- return ((INameScope)element).FindByName<T>(name);
- }
-
- internal static T FindByName<T>(this INameScope namescope, string name)
- {
- return (T)namescope.FindByName(name);
- }
- }
-}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal enum NamedSize
- {
- Default = 0,
- Micro = 1,
- Small = 2,
- Medium = 3,
- Large = 4
- }
+ internal enum NamedSize
+ {
+ Default = 0,
+ Micro = 1,
+ Small = 2,
+ Medium = 3,
+ Large = 4
+ }
}
\ No newline at end of file
/// EventArgs for the NavigationPage's navigation events.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class NavigationEventArgs : EventArgs
- {
+ internal class NavigationEventArgs : EventArgs
+ {
/// <summary>
/// Create a NavigationEventArgs instance.
/// </summary>
/// <param name="page">The page that was popped or is newly visible.</param>
- public NavigationEventArgs(Page page)
- {
- if (page == null)
- throw new ArgumentNullException("page");
+ public NavigationEventArgs(Page page)
+ {
+ if (page == null)
+ throw new ArgumentNullException("page");
- Page = page;
- }
+ Page = page;
+ }
/// <summary>
/// Gets the page that was removed or is newly visible.
/// </summary>
- public Page Page { get; private set; }
- }
+ public Page Page { get; private set; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- // Mark as internal until renderers are ready for release after 1.0
- // [RenderWith(typeof(_NavigationMenuRenderer))]
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal class NavigationMenu : View, /*INavigationMenuController,*/ IElementConfiguration<NavigationMenu>
- {
- readonly List<Page> _targets = new List<Page>();
+ // Mark as internal until renderers are ready for release after 1.0
+ // [RenderWith(typeof(_NavigationMenuRenderer))]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class NavigationMenu : View, /*INavigationMenuController,*/ IElementConfiguration<NavigationMenu>
+ {
+ readonly List<Page> _targets = new List<Page>();
- readonly Lazy<PlatformConfigurationRegistry<NavigationMenu>> _platformConfigurationRegistry;
+ readonly Lazy<PlatformConfigurationRegistry<NavigationMenu>> _platformConfigurationRegistry;
- public NavigationMenu()
- {
- _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<NavigationMenu>>(() => new PlatformConfigurationRegistry<NavigationMenu>(this));
- }
+ public NavigationMenu()
+ {
+ _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<NavigationMenu>>(() => new PlatformConfigurationRegistry<NavigationMenu>(this));
+ }
- public IEnumerable<Page> Targets
- {
- get { return _targets; }
- set
- {
- if (_targets.AsEnumerable().SequenceEqual(value))
- return;
+ public IEnumerable<Page> Targets
+ {
+ get { return _targets; }
+ set
+ {
+ if (_targets.AsEnumerable().SequenceEqual(value))
+ return;
- foreach (Page page in value)
- {
- VerifyTarget(page);
- }
+ foreach (Page page in value)
+ {
+ VerifyTarget(page);
+ }
- OnPropertyChanging();
- _targets.Clear();
- _targets.AddRange(value);
- OnPropertyChanged();
- }
- }
+ OnPropertyChanging();
+ _targets.Clear();
+ _targets.AddRange(value);
+ OnPropertyChanged();
+ }
+ }
- public void Add(Page target)
- {
- if (_targets.Contains(target))
- return;
- VerifyTarget(target);
+ public void Add(Page target)
+ {
+ if (_targets.Contains(target))
+ return;
+ VerifyTarget(target);
- OnPropertyChanging("Targets");
- _targets.Add(target);
- OnPropertyChanged("Targets");
- }
+ OnPropertyChanging("Targets");
+ _targets.Add(target);
+ OnPropertyChanged("Targets");
+ }
- public void Remove(Page target)
- {
- if (_targets.Contains(target))
- {
- OnPropertyChanging("Targets");
- if (_targets.Remove(target))
- OnPropertyChanged("Targets");
- }
- }
+ public void Remove(Page target)
+ {
+ if (_targets.Contains(target))
+ {
+ OnPropertyChanging("Targets");
+ if (_targets.Remove(target))
+ OnPropertyChanged("Targets");
+ }
+ }
- public IPlatformElementConfiguration<T, NavigationMenu> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
+ public IPlatformElementConfiguration<T, NavigationMenu> On<T>() where T : IConfigPlatform
+ {
+ return _platformConfigurationRegistry.Value.On<T>();
+ }
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SendTargetSelected(Page target)
- {
- Navigation.PushAsync(target);
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SendTargetSelected(Page target)
+ {
+ Navigation.PushAsync(target);
+ }
- void VerifyTarget(Page target)
- {
- if (target.Icon == null || string.IsNullOrWhiteSpace(target.Icon.File))
- throw new Exception("Icon must be set for each page before adding them to a Navigation Menu");
- }
- }
+ void VerifyTarget(Page target)
+ {
+ if (target.Icon == null || string.IsNullOrWhiteSpace(target.Icon.File))
+ throw new Exception("Icon must be set for each page before adding them to a Navigation Menu");
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal class NavigationModel
- {
- readonly List<Page> _modalStack = new List<Page>();
- readonly List<List<Page>> _navTree = new List<List<Page>>();
-
- public Page CurrentPage
- {
- get
- {
- if (_navTree.Any())
- return _navTree.Last().Last();
- return null;
- }
- }
-
- public IEnumerable<Page> Modals
- {
- get { return _modalStack; }
- }
-
- public IEnumerable<Page> Roots
- {
- get
- {
- foreach (List<Page> list in _navTree)
- {
- yield return list[0];
- }
- }
- }
-
- public IReadOnlyList<IReadOnlyList<Page>> Tree
- {
- get { return _navTree; }
- }
-
- public void Clear()
- {
- _navTree.Clear();
- _modalStack.Clear();
- }
-
- public void InsertPageBefore(Page page, Page before)
- {
- List<Page> currentStack = _navTree.Last();
- int index = currentStack.IndexOf(before);
-
- if (index == -1)
- throw new ArgumentException("before must be in the current navigation context");
-
- currentStack.Insert(index, page);
- }
-
- public Page Pop(Page ancestralNav)
- {
- ancestralNav = AncestorToRoot(ancestralNav);
- foreach (List<Page> stack in _navTree)
- {
- if (stack.Contains(ancestralNav))
- {
- if (stack.Count <= 1)
- throw new InvalidNavigationException("Can not pop final item in stack");
- Page result = stack.Last();
- stack.Remove(result);
- return result;
- }
- }
-
- throw new InvalidNavigationException("Popped from unpushed item?");
- }
-
- public Page PopModal()
- {
- if (_navTree.Count <= 1)
- throw new InvalidNavigationException("Can't pop modal without any modals pushed");
- Page modal = _navTree.Last().First();
- _modalStack.Remove(modal);
- _navTree.Remove(_navTree.Last());
- return modal;
- }
-
- public Page PopTopPage()
- {
- Page itemToRemove;
- if (_navTree.Count == 1)
- {
- if (_navTree[0].Count > 1)
- {
- itemToRemove = _navTree[0].Last();
- _navTree[0].Remove(itemToRemove);
- return itemToRemove;
- }
- return null;
- }
- itemToRemove = _navTree.Last().Last();
- _navTree.Last().Remove(itemToRemove);
- if (!_navTree.Last().Any())
- {
- _navTree.RemoveAt(_navTree.Count - 1);
- }
- return itemToRemove;
- }
-
- public void PopToRoot(Page ancestralNav)
- {
- ancestralNav = AncestorToRoot(ancestralNav);
- foreach (List<Page> stack in _navTree)
- {
- if (stack.Contains(ancestralNav))
- {
- if (stack.Count <= 1)
- throw new InvalidNavigationException("Can not pop final item in stack");
- stack.RemoveRange(1, stack.Count - 1);
- return;
- }
- }
-
- throw new InvalidNavigationException("Popped from unpushed item?");
- }
-
- public void Push(Page page, Page ancestralNav)
- {
- if (ancestralNav == null)
- {
- if (_navTree.Any())
- throw new InvalidNavigationException("Ancestor must be provided for all pushes except first");
- _navTree.Add(new List<Page> { page });
- return;
- }
-
- ancestralNav = AncestorToRoot(ancestralNav);
-
- foreach (List<Page> stack in _navTree)
- {
- if (stack.Contains(ancestralNav))
- {
- stack.Add(page);
- return;
- }
- }
-
- throw new InvalidNavigationException("Invalid ancestor passed");
- }
-
- public void PushModal(Page page)
- {
- _navTree.Add(new List<Page> { page });
- _modalStack.Add(page);
- }
-
- public bool RemovePage(Page page)
- {
- bool found;
- List<Page> currentStack = _navTree.Last();
- var i = 0;
- while (!(found = currentStack.Remove(page)) && i < _navTree.Count - 1)
- {
- currentStack = _navTree[i++];
- }
-
- return found;
- }
-
- Page AncestorToRoot(Page ancestor)
- {
- Page result = ancestor;
- // while (!Application.IsApplicationOrNull(result.RealParent))
- result = (Page)result.RealParent;
- return result;
- }
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class NavigationModel
+ {
+ readonly List<Page> _modalStack = new List<Page>();
+ readonly List<List<Page>> _navTree = new List<List<Page>>();
+
+ public Page CurrentPage
+ {
+ get
+ {
+ if (_navTree.Any())
+ return _navTree.Last().Last();
+ return null;
+ }
+ }
+
+ public IEnumerable<Page> Modals
+ {
+ get { return _modalStack; }
+ }
+
+ public IEnumerable<Page> Roots
+ {
+ get
+ {
+ foreach (List<Page> list in _navTree)
+ {
+ yield return list[0];
+ }
+ }
+ }
+
+ public IReadOnlyList<IReadOnlyList<Page>> Tree
+ {
+ get { return _navTree; }
+ }
+
+ public void Clear()
+ {
+ _navTree.Clear();
+ _modalStack.Clear();
+ }
+
+ public void InsertPageBefore(Page page, Page before)
+ {
+ List<Page> currentStack = _navTree.Last();
+ int index = currentStack.IndexOf(before);
+
+ if (index == -1)
+ throw new ArgumentException("before must be in the current navigation context");
+
+ currentStack.Insert(index, page);
+ }
+
+ public Page Pop(Page ancestralNav)
+ {
+ ancestralNav = AncestorToRoot(ancestralNav);
+ foreach (List<Page> stack in _navTree)
+ {
+ if (stack.Contains(ancestralNav))
+ {
+ if (stack.Count <= 1)
+ throw new InvalidNavigationException("Can not pop final item in stack");
+ Page result = stack.Last();
+ stack.Remove(result);
+ return result;
+ }
+ }
+
+ throw new InvalidNavigationException("Popped from unpushed item?");
+ }
+
+ public Page PopModal()
+ {
+ if (_navTree.Count <= 1)
+ throw new InvalidNavigationException("Can't pop modal without any modals pushed");
+ Page modal = _navTree.Last().First();
+ _modalStack.Remove(modal);
+ _navTree.Remove(_navTree.Last());
+ return modal;
+ }
+
+ public Page PopTopPage()
+ {
+ Page itemToRemove;
+ if (_navTree.Count == 1)
+ {
+ if (_navTree[0].Count > 1)
+ {
+ itemToRemove = _navTree[0].Last();
+ _navTree[0].Remove(itemToRemove);
+ return itemToRemove;
+ }
+ return null;
+ }
+ itemToRemove = _navTree.Last().Last();
+ _navTree.Last().Remove(itemToRemove);
+ if (!_navTree.Last().Any())
+ {
+ _navTree.RemoveAt(_navTree.Count - 1);
+ }
+ return itemToRemove;
+ }
+
+ public void PopToRoot(Page ancestralNav)
+ {
+ ancestralNav = AncestorToRoot(ancestralNav);
+ foreach (List<Page> stack in _navTree)
+ {
+ if (stack.Contains(ancestralNav))
+ {
+ if (stack.Count <= 1)
+ throw new InvalidNavigationException("Can not pop final item in stack");
+ stack.RemoveRange(1, stack.Count - 1);
+ return;
+ }
+ }
+
+ throw new InvalidNavigationException("Popped from unpushed item?");
+ }
+
+ public void Push(Page page, Page ancestralNav)
+ {
+ if (ancestralNav == null)
+ {
+ if (_navTree.Any())
+ throw new InvalidNavigationException("Ancestor must be provided for all pushes except first");
+ _navTree.Add(new List<Page> { page });
+ return;
+ }
+
+ ancestralNav = AncestorToRoot(ancestralNav);
+
+ foreach (List<Page> stack in _navTree)
+ {
+ if (stack.Contains(ancestralNav))
+ {
+ stack.Add(page);
+ return;
+ }
+ }
+
+ throw new InvalidNavigationException("Invalid ancestor passed");
+ }
+
+ public void PushModal(Page page)
+ {
+ _navTree.Add(new List<Page> { page });
+ _modalStack.Add(page);
+ }
+
+ public bool RemovePage(Page page)
+ {
+ bool found;
+ List<Page> currentStack = _navTree.Last();
+ var i = 0;
+ while (!(found = currentStack.Remove(page)) && i < _navTree.Count - 1)
+ {
+ currentStack = _navTree[i++];
+ }
+
+ return found;
+ }
+
+ Page AncestorToRoot(Page ancestor)
+ {
+ Page result = ancestor;
+ // while (!Application.IsApplicationOrNull(result.RealParent))
+ result = (Page)result.RealParent;
+ return result;
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Tizen.NUI.Binding.Internals;
+using Tizen.NUI.Binding;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// A Page that manages the navigation and user-experience of a stack of other pages.
+ /// </summary>
+ // [RenderWith(typeof(_NavigationPageRenderer))]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class NavigationPage : Page, IPageContainer<Page>, INavigationPageController, IElementConfiguration<NavigationPage>
+ {
+ /// <summary>
+ /// Identifies the property associated with the title of the back button.
+ /// </summary>
+ public static readonly BindableProperty BackButtonTitleProperty = BindableProperty.CreateAttached("BackButtonTitle", typeof(string), typeof(Page), null);
+
+ /// <summary>
+ /// Backing store for the HasNavigationBar property.
+ /// </summary>
+ public static readonly BindableProperty HasNavigationBarProperty = BindableProperty.CreateAttached("HasNavigationBar", typeof(bool), typeof(Page), true);
+
+ /// <summary>
+ /// Backing store for the HasBackButton property.
+ /// </summary>
+ public static readonly BindableProperty HasBackButtonProperty = BindableProperty.CreateAttached("HasBackButton", typeof(bool), typeof(NavigationPage), true);
+
+ /// <summary>
+ /// Identifies the Tint bindable property.
+ /// </summary>
+ [Obsolete("TintProperty is obsolete as of version 1.2.0. Please use BarBackgroundColorProperty and BarTextColorProperty to change NavigationPage bar color properties.")]
+ public static readonly BindableProperty TintProperty = BindableProperty.Create("Tint", typeof(Color), typeof(NavigationPage), /*Color.Default*/Color.Black);
+
+ /// <summary>
+ /// Identifies the property associated with the color of the NavigationPage's bar background color.
+ /// </summary>
+ public static readonly BindableProperty BarBackgroundColorProperty = BindableProperty.Create("BarBackgroundColor", typeof(Color), typeof(NavigationPage), /*Color.Default*/Color.Black);
+
+ /// <summary>
+ /// Identifies the property associated with the color of the NavigationPage's bar text color.
+ /// </summary>
+ public static readonly BindableProperty BarTextColorProperty = BindableProperty.Create("BarTextColor", typeof(Color), typeof(NavigationPage), /*Color.Default*/Color.Black);
+
+ /// <summary>
+ /// Indicates the NavigationPage.SetTitleIcon/NavigationPage.GetTitleIcon property.
+ /// </summary>
+ public static readonly BindableProperty TitleIconProperty = BindableProperty.CreateAttached("TitleIcon", typeof(FileImageSource), typeof(NavigationPage), default(FileImageSource));
+
+ static readonly BindablePropertyKey CurrentPagePropertyKey = BindableProperty.CreateReadOnly("CurrentPage", typeof(Page), typeof(NavigationPage), null);
+
+ /// <summary>
+ /// Identifies the property associated with NavigationPage.CurrentPage
+ /// </summary>
+ public static readonly BindableProperty CurrentPageProperty = CurrentPagePropertyKey.BindableProperty;
+
+ static readonly BindablePropertyKey RootPagePropertyKey = BindableProperty.CreateReadOnly(nameof(RootPage), typeof(Page), typeof(NavigationPage), null);
+ /// <summary>
+ /// Identifies the property associated with NavigationPage.RootPage
+ /// </summary>
+ public static readonly BindableProperty RootPageProperty = RootPagePropertyKey.BindableProperty;
+
+ /// <summary>
+ /// Initializes a new NavigationPage object.
+ /// </summary>
+ public NavigationPage()
+ {
+ _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<NavigationPage>>(() => new PlatformConfigurationRegistry<NavigationPage>(this));
+
+ Navigation = new NavigationImpl(this);
+ }
+
+ /// <summary>
+ /// Creates a new NavigationPage element with root as its root element.
+ /// </summary>
+ /// <param name="root">The root page.</param>
+ public NavigationPage(Page root) : this()
+ {
+ PushPage(root);
+ }
+
+ /// <summary>
+ /// Gets or sets the background color for the bar at the top of the NavigationPage.
+ /// </summary>
+ public Color BarBackgroundColor
+ {
+ get { return (Color)GetValue(BarBackgroundColorProperty); }
+ set { SetValue(BarBackgroundColorProperty, value); }
+ }
+
+ /// <summary>
+ /// Gets or sets the text that appears on the bar at the top of the NavigationPage.
+ /// </summary>
+ public Color BarTextColor
+ {
+ get { return (Color)GetValue(BarTextColorProperty); }
+ set { SetValue(BarTextColorProperty, value); }
+ }
+
+ /// <summary>
+ /// The color to be used as the Tint of the NavigationPage.
+ /// </summary>
+ [Obsolete("Tint is obsolete as of version 1.2.0. Please use BarBackgroundColor and BarTextColor to change NavigationPage bar color properties.")]
+ public Color Tint
+ {
+ get { return (Color)GetValue(TintProperty); }
+ set { SetValue(TintProperty, value); }
+ }
+
+ internal Task CurrentNavigationTask { get; set; }
+
+ /// <summary>
+ /// For internal use
+ /// </summary>
+ /// <param name="depth">The depth</param>
+ /// <returns>The page instance</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Page Peek(int depth)
+ {
+ if (depth < 0)
+ {
+ return null;
+ }
+
+ if (InternalChildren.Count <= depth)
+ {
+ return null;
+ }
+
+ return (Page)InternalChildren[InternalChildren.Count - depth - 1];
+ }
+
+ /// <summary>
+ /// For internal use.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public IEnumerable<Page> Pages => InternalChildren.Cast<Page>();
+
+ /// <summary>
+ /// For internal use
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public int StackDepth
+ {
+ get { return InternalChildren.Count; }
+ }
+
+ /// <summary>
+ /// The Page that is currently top-most on the navigation stack.
+ /// </summary>
+ public Page CurrentPage
+ {
+ get { return (Page)GetValue(CurrentPageProperty); }
+ private set { SetValue(CurrentPagePropertyKey, value); }
+ }
+
+ /// <summary>
+ /// The Page that is the root of the navigation stack.
+ /// </summary>
+ public Page RootPage
+ {
+ get { return (Page)GetValue(RootPageProperty); }
+ private set { SetValue(RootPagePropertyKey, value); }
+ }
+
+ /// <summary>
+ /// The title of the back button for the specified page.
+ /// </summary>
+ /// <param name="page">The Page whose back-button's title is being requested.</param>
+ /// <returns>The title of the back button that would be shown if the specified page were the Xamarin.Forms.CurrentPage.</returns>
+ public static string GetBackButtonTitle(BindableObject page)
+ {
+ return (string)page.GetValue(BackButtonTitleProperty);
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether page has a back button.
+ /// </summary>
+ /// <param name="page">The page to be checked</param>
+ /// <returns>true if the page has a back button.</returns>
+ public static bool GetHasBackButton(Page page)
+ {
+ if (page == null)
+ throw new ArgumentNullException("page");
+ return (bool)page.GetValue(HasBackButtonProperty);
+ }
+
+ /// <summary>
+ /// Returns a value that indicates whether the page has a navigation bar.
+ /// </summary>
+ /// <param name="page">The Page being queried.</param>
+ /// <returns>true if page would display a navigation bar were it the CurrentPage.</returns>
+ public static bool GetHasNavigationBar(BindableObject page)
+ {
+ return (bool)page.GetValue(HasNavigationBarProperty);
+ }
+
+ internal static FileImageSource GetTitleIcon(BindableObject bindable)
+ {
+ return (FileImageSource)bindable.GetValue(TitleIconProperty);
+ }
+
+ /// <summary>
+ /// Asynchronously removes the top Page from the navigation stack.
+ /// </summary>
+ /// <returns>The Page that had been at the top of the navigation stack.</returns>
+ public Task<Page> PopAsync()
+ {
+ return PopAsync(true);
+ }
+
+ /// <summary>
+ /// Asynchronously removes the top Page from the navigation stack, with optional animation.
+ /// </summary>
+ /// <param name="animated">Whether to animate the pop.</param>
+ /// <returns>The Page that had been at the top of the navigation stack.</returns>
+ public async Task<Page> PopAsync(bool animated)
+ {
+ var tcs = new TaskCompletionSource<bool>();
+ if (CurrentNavigationTask != null && !CurrentNavigationTask.IsCompleted)
+ {
+ var oldTask = CurrentNavigationTask;
+ CurrentNavigationTask = tcs.Task;
+ await oldTask;
+ }
+ else
+ CurrentNavigationTask = tcs.Task;
+
+ var result = await PopAsyncInner(animated, false);
+ tcs.SetResult(true);
+ return result;
+ }
+
+ /// <summary>
+ /// Event that is raised after a page is popped from this NavigationPage element.
+ /// </summary>
+ public event EventHandler<NavigationEventArgs> Popped;
+
+ /// <summary>
+ /// Event that is raised when the last nonroot element is popped from this NavigationPage element.
+ /// </summary>
+ public event EventHandler<NavigationEventArgs> PoppedToRoot;
+
+ /// <summary>
+ /// Pops all but the root Page off the navigation stack.
+ /// </summary>
+ /// <returns>A task that represents the asynchronous dismiss operation.</returns>
+ public Task PopToRootAsync()
+ {
+ return PopToRootAsync(true);
+ }
+
+ /// <summary>
+ /// A task for asynchronously popping all pages off of the navigation stack.
+ /// </summary>
+ /// <param name="animated">Whether to animate the pop.</param>
+ /// <returns>A task that represents the asynchronous dismiss operation.</returns>
+ public async Task PopToRootAsync(bool animated)
+ {
+ if (CurrentNavigationTask != null && !CurrentNavigationTask.IsCompleted)
+ {
+ var tcs = new TaskCompletionSource<bool>();
+ Task oldTask = CurrentNavigationTask;
+ CurrentNavigationTask = tcs.Task;
+ await oldTask;
+
+ await PopToRootAsyncInner(animated);
+ tcs.SetResult(true);
+ return;
+ }
+
+ Task result = PopToRootAsyncInner(animated);
+ CurrentNavigationTask = result;
+ await result;
+ }
+
+ /// <summary>
+ /// Presents a Page modally.
+ /// </summary>
+ /// <param name="page">The Page to present modally.</param>
+ /// <returns>An awaitable Task, indicating the PushModal completion.</returns>
+ public Task PushAsync(Page page)
+ {
+ return PushAsync(page, true);
+ }
+
+ /// <summary>
+ /// A task for asynchronously pushing a page onto the navigation stack, with optional animation.
+ /// </summary>
+ /// <param name="page">The Page to present modally.</param>
+ /// <param name="animated">Whether to animate the pop.</param>
+ /// <returns>An awaitable Task, indicating the PushModal completion.</returns>
+ public async Task PushAsync(Page page, bool animated)
+ {
+ if (CurrentNavigationTask != null && !CurrentNavigationTask.IsCompleted)
+ {
+ var tcs = new TaskCompletionSource<bool>();
+ Task oldTask = CurrentNavigationTask;
+ CurrentNavigationTask = tcs.Task;
+ await oldTask;
+
+ await PushAsyncInner(page, animated);
+ tcs.SetResult(true);
+ return;
+ }
+
+ CurrentNavigationTask = PushAsyncInner(page, animated);
+ await CurrentNavigationTask;
+ }
+
+ /// <summary>
+ /// Event that is raised when a page is pushed onto this NavigationPage element.
+ /// </summary>
+ public event EventHandler<NavigationEventArgs> Pushed;
+
+ /// <summary>
+ /// Sets the title that appears on the back button for page.
+ /// </summary>
+ /// <param name="page">The BindableObject object.</param>
+ /// <param name="value">The value to set.</param>
+ public static void SetBackButtonTitle(BindableObject page, string value)
+ {
+ page.SetValue(BackButtonTitleProperty, value);
+ }
+
+ /// <summary>
+ /// Adds or removes a back button to page, with optional animation.
+ /// </summary>
+ /// <param name="page">The page object.</param>
+ /// <param name="value">The value to set.</param>
+ public static void SetHasBackButton(Page page, bool value)
+ {
+ if (page == null)
+ throw new ArgumentNullException("page");
+ page.SetValue(HasBackButtonProperty, value);
+ }
+
+ /// <summary>
+ /// Sets a value that indicates whether or not this NavigationPage element has a navigation bar.
+ /// </summary>
+ /// <param name="page">The BindableObject object</param>
+ /// <param name="value">The value to set</param>
+ public static void SetHasNavigationBar(BindableObject page, bool value)
+ {
+ page.SetValue(HasNavigationBarProperty, value);
+ }
+
+ internal static void SetTitleIcon(BindableObject bindable, FileImageSource value)
+ {
+ bindable.SetValue(TitleIconProperty, value);
+ }
+
+ /// <summary>
+ /// Event that is raised when the hardware back button is pressed.
+ /// </summary>
+ /// <returns>true if consumed</returns>
+ protected override bool OnBackButtonPressed()
+ {
+ if (CurrentPage.SendBackButtonPressed())
+ return true;
+
+ if (StackDepth > 1)
+ {
+ SafePop();
+ return true;
+ }
+
+ return base.OnBackButtonPressed();
+ }
+
+ /// <summary>
+ /// For internal use
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler<NavigationRequestedEventArgs> InsertPageBeforeRequested;
+
+ /// <summary>
+ /// For internal use
+ /// </summary>
+ /// <param name="animated">Whether animate the pop.</param>
+ /// <param name="fast"></param>
+ /// <returns>A task that represents the asynchronous dismiss operation.</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public async Task<Page> PopAsyncInner(bool animated, bool fast)
+ {
+ if (StackDepth == 1)
+ {
+ return null;
+ }
+
+ var page = (Page)InternalChildren.Last();
+
+ return await (this as INavigationPageController).RemoveAsyncInner(page, animated, fast);
+ }
+
+ async Task<Page> INavigationPageController.RemoveAsyncInner(Page page, bool animated, bool fast)
+ {
+ if (StackDepth == 1)
+ {
+ return null;
+ }
+
+ var args = new NavigationRequestedEventArgs(page, animated);
+
+ var removed = true;
+
+ EventHandler<NavigationRequestedEventArgs> requestPop = PopRequested;
+ if (requestPop != null)
+ {
+ requestPop(this, args);
+
+ if (args.Task != null && !fast)
+ removed = await args.Task;
+ }
+
+ if (!removed && !fast)
+ return CurrentPage;
+
+ InternalChildren.Remove(page);
+
+ CurrentPage = (Page)InternalChildren.Last();
+
+ if (Popped != null)
+ Popped(this, args);
+
+ return page;
+ }
+
+ /// <summary>
+ /// For internal use.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler<NavigationRequestedEventArgs> PopRequested;
+
+ /// <summary>
+ /// For internal use.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler<NavigationRequestedEventArgs> PopToRootRequested;
+
+ /// <summary>
+ /// For internal use.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler<NavigationRequestedEventArgs> PushRequested;
+
+ /// <summary>
+ /// For internal use.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler<NavigationRequestedEventArgs> RemovePageRequested;
+
+ void InsertPageBefore(Page page, Page before)
+ {
+ if (page == null)
+ throw new ArgumentNullException($"{nameof(page)} cannot be null.");
+
+ if (before == null)
+ throw new ArgumentNullException($"{nameof(before)} cannot be null.");
+
+ if (!InternalChildren.Contains(before))
+ throw new ArgumentException($"{nameof(before)} must be a child of the NavigationPage", nameof(before));
+
+ if (InternalChildren.Contains(page))
+ throw new ArgumentException("Cannot insert page which is already in the navigation stack");
+
+ EventHandler<NavigationRequestedEventArgs> handler = InsertPageBeforeRequested;
+ handler?.Invoke(this, new NavigationRequestedEventArgs(page, before, false));
+
+ int index = InternalChildren.IndexOf(before);
+ InternalChildren.Insert(index, page);
+
+ if (index == 0)
+ RootPage = page;
+
+ // Shouldn't be required?
+ // if (Width > 0 && Height > 0)
+ ForceLayout();
+ }
+
+ async Task PopToRootAsyncInner(bool animated)
+ {
+ if (StackDepth == 1)
+ return;
+
+ Element[] childrenToRemove = InternalChildren.Skip(1).ToArray();
+ foreach (Element child in childrenToRemove)
+ InternalChildren.Remove(child);
+
+ CurrentPage = RootPage;
+
+ var args = new NavigationRequestedEventArgs(RootPage, animated);
+
+ EventHandler<NavigationRequestedEventArgs> requestPopToRoot = PopToRootRequested;
+ if (requestPopToRoot != null)
+ {
+ requestPopToRoot(this, args);
+
+ if (args.Task != null)
+ await args.Task;
+ }
+
+ // PoppedToRoot?.Invoke(this, new PoppedToRootEventArgs(RootPage, childrenToRemove.OfType<Page>().ToList()));
+ }
+
+ async Task PushAsyncInner(Page page, bool animated)
+ {
+ if (InternalChildren.Contains(page))
+ return;
+
+ PushPage(page);
+
+ var args = new NavigationRequestedEventArgs(page, animated);
+
+ EventHandler<NavigationRequestedEventArgs> requestPush = PushRequested;
+ if (requestPush != null)
+ {
+ requestPush(this, args);
+
+ if (args.Task != null)
+ await args.Task;
+ }
+
+ Pushed?.Invoke(this, args);
+ }
+
+ void PushPage(Page page)
+ {
+ InternalChildren.Add(page);
+
+ if (InternalChildren.Count == 1)
+ RootPage = page;
+
+ CurrentPage = page;
+ }
+
+ void RemovePage(Page page)
+ {
+ if (page == null)
+ throw new ArgumentNullException($"{nameof(page)} cannot be null.");
+
+ if (page == CurrentPage && CurrentPage == RootPage)
+ throw new InvalidOperationException("Cannot remove root page when it is also the currently displayed page.");
+ if (page == CurrentPage)
+ {
+ // Log.Warning("NavigationPage", "RemovePage called for CurrentPage object. This can result in undesired behavior, consider calling PopAsync instead.");
+ PopAsync();
+ return;
+ }
+
+ if (!InternalChildren.Contains(page))
+ throw new ArgumentException("Page to remove must be contained on this Navigation Page");
+
+ EventHandler<NavigationRequestedEventArgs> handler = RemovePageRequested;
+ handler?.Invoke(this, new NavigationRequestedEventArgs(page, true));
+
+ InternalChildren.Remove(page);
+ if (RootPage == page)
+ RootPage = (Page)InternalChildren.First();
+ }
+
+ void SafePop()
+ {
+ PopAsync(true).ContinueWith(t =>
+ {
+ if (t.IsFaulted)
+ throw t.Exception;
+ });
+ }
+
+ class NavigationImpl : NavigationProxy
+ {
+ // readonly Lazy<ReadOnlyCastingList<Page, Element>> _castingList;
+
+ public NavigationImpl(NavigationPage owner)
+ {
+ Owner = owner;
+ // _castingList = new Lazy<ReadOnlyCastingList<Page, Element>>(() => new ReadOnlyCastingList<Page, Element>(Owner.InternalChildren));
+ }
+
+ NavigationPage Owner { get; }
+
+ protected override IReadOnlyList<Page> GetNavigationStack()
+ {
+ // return _castingList.Value;
+ return null;
+ }
+
+ protected override void OnInsertPageBefore(Page page, Page before)
+ {
+ Owner.InsertPageBefore(page, before);
+ }
+
+ protected override Task<Page> OnPopAsync(bool animated)
+ {
+ return Owner.PopAsync(animated);
+ }
+
+ protected override Task OnPopToRootAsync(bool animated)
+ {
+ return Owner.PopToRootAsync(animated);
+ }
+
+ protected override Task OnPushAsync(Page root, bool animated)
+ {
+ return Owner.PushAsync(root, animated);
+ }
+
+ protected override void OnRemovePage(Page page)
+ {
+ Owner.RemovePage(page);
+ }
+ }
+
+ readonly Lazy<PlatformConfigurationRegistry<NavigationPage>> _platformConfigurationRegistry;
+
+ /// <summary>
+ /// Returns the platform-specific instance of this NavigationPage, on which a platform-specific method may be called.
+ /// </summary>
+ /// <typeparam name="T">The platform for which to return an instance.</typeparam>
+ /// <returns>The platform-specific instance of this NavigationPage</returns>
+ public new IPlatformElementConfiguration<T, NavigationPage> On<T>() where T : IConfigPlatform
+ {
+ return _platformConfigurationRegistry.Value.On<T>();
+ }
+ }
+}
/// <summary>
/// For internal use.
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class NavigationProxy : INavigation
- {
- INavigation _inner;
- Lazy<List<Page>> _modalStack = new Lazy<List<Page>>(() => new List<Page>());
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class NavigationProxy : INavigation
+ {
+ INavigation _inner;
+ Lazy<List<Page>> _modalStack = new Lazy<List<Page>>(() => new List<Page>());
- Lazy<List<Page>> _pushStack = new Lazy<List<Page>>(() => new List<Page>());
+ Lazy<List<Page>> _pushStack = new Lazy<List<Page>>(() => new List<Page>());
- internal INavigation Inner
- {
- get { return _inner; }
- set
- {
- if (_inner == value)
- return;
- _inner = value;
- // reverse so that things go into the new stack in the same order
- // null out to release memory that will likely never be needed again
+ internal INavigation Inner
+ {
+ get { return _inner; }
+ set
+ {
+ if (_inner == value)
+ return;
+ _inner = value;
+ // reverse so that things go into the new stack in the same order
+ // null out to release memory that will likely never be needed again
- if (ReferenceEquals(_inner, null))
- {
- _pushStack = new Lazy<List<Page>>(() => new List<Page>());
- _modalStack = new Lazy<List<Page>>(() => new List<Page>());
- }
- else
- {
- if (_pushStack != null && _pushStack.IsValueCreated)
- {
- foreach (Page page in _pushStack.Value)
- {
- _inner.PushAsync(page);
- }
- }
+ if (ReferenceEquals(_inner, null))
+ {
+ _pushStack = new Lazy<List<Page>>(() => new List<Page>());
+ _modalStack = new Lazy<List<Page>>(() => new List<Page>());
+ }
+ else
+ {
+ if (_pushStack != null && _pushStack.IsValueCreated)
+ {
+ foreach (Page page in _pushStack.Value)
+ {
+ _inner.PushAsync(page);
+ }
+ }
- if (_modalStack != null && _modalStack.IsValueCreated)
- {
- foreach (Page page in _modalStack.Value)
- {
- _inner.PushModalAsync(page);
- }
- }
+ if (_modalStack != null && _modalStack.IsValueCreated)
+ {
+ foreach (Page page in _modalStack.Value)
+ {
+ _inner.PushModalAsync(page);
+ }
+ }
- _pushStack = null;
- _modalStack = null;
- }
- }
- }
+ _pushStack = null;
+ _modalStack = null;
+ }
+ }
+ }
/// <summary>
/// Inserts a page in the navigation stack before an existing page in the stack.
/// <param name="page">The page to add.</param>
/// <param name="before">The existing page, before which page will be inserted.</param>
public void InsertPageBefore(Page page, Page before)
- {
- OnInsertPageBefore(page, before);
- }
+ {
+ OnInsertPageBefore(page, before);
+ }
/// <summary>
/// Gets the modal navigation stack.
/// </summary>
public IReadOnlyList<Page> ModalStack
- {
- get { return GetModalStack(); }
- }
+ {
+ get { return GetModalStack(); }
+ }
/// <summary>
/// Gets the stack of pages in the navigation.
/// </summary>
public IReadOnlyList<Page> NavigationStack
- {
- get { return GetNavigationStack(); }
- }
+ {
+ get { return GetNavigationStack(); }
+ }
/// <summary>
/// Asynchronously removes the most recent Page from the navigation stack.
/// </summary>
/// <returns>The Page that had been at the top of the navigation stack.</returns>
public Task<Page> PopAsync()
- {
- return OnPopAsync(true);
- }
+ {
+ return OnPopAsync(true);
+ }
/// <summary>
/// Asynchronously removes the top Page from the navigation stack, with optional animation.
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>The Page that had been at the top of the navigation stack.</returns>
public Task<Page> PopAsync(bool animated)
- {
- return OnPopAsync(animated);
- }
+ {
+ return OnPopAsync(animated);
+ }
/// <summary>
/// Asynchronously dismisses the most recent modally presented Page.
/// </summary>
/// <returns>An awaitable instance, indicating the PopModalAsync completion. The Task.Result is the Page that has been popped.</returns>
- public Task<Page> PopModalAsync()
- {
- return OnPopModal(true);
- }
+ public Task<Page> PopModalAsync()
+ {
+ return OnPopModal(true);
+ }
/// <summary>
/// Asynchronously removes the top Page from the navigation stack, with optional animation.
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>The Page that had been at the top of the navigation stack.</returns>
public Task<Page> PopModalAsync(bool animated)
- {
- return OnPopModal(animated);
- }
+ {
+ return OnPopModal(animated);
+ }
/// <summary>
/// Pops all but the root Page off the navigation stack.
/// </summary>
/// <returns>A task representing the asynchronous dismiss operation.</returns>
public Task PopToRootAsync()
- {
- return OnPopToRootAsync(true);
- }
+ {
+ return OnPopToRootAsync(true);
+ }
/// <summary>
/// Pops all but the root Page off the navigation stack, with optional animation.
/// </summary>
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>A task representing the asynchronous dismiss operation.</returns>
- public Task PopToRootAsync(bool animated)
- {
- return OnPopToRootAsync(animated);
- }
+ public Task PopToRootAsync(bool animated)
+ {
+ return OnPopToRootAsync(animated);
+ }
/// <summary>
/// Asynchronously adds a Page to the top of the navigation stack.
/// <param name="root">The Page to be pushed on top of the navigation stack.</param>
/// <returns>A task that represents the asynchronous push operation.</returns>
public Task PushAsync(Page root)
- {
- return PushAsync(root, true);
- }
+ {
+ return PushAsync(root, true);
+ }
/// <summary>
/// Asynchronously adds a Page to the top of the navigation stack, with optional animation.
/// <param name="root">The page to push.</param>
/// <param name="animated">Whether to animate the push.</param>
/// <returns>A task that represents the asynchronous push operation.</returns>
- public Task PushAsync(Page root, bool animated)
- {
- if (root.RealParent != null)
- throw new InvalidOperationException("Page must not already have a parent.");
- return OnPushAsync(root, animated);
- }
+ public Task PushAsync(Page root, bool animated)
+ {
+ if (root.RealParent != null)
+ throw new InvalidOperationException("Page must not already have a parent.");
+ return OnPushAsync(root, animated);
+ }
/// <summary>
/// Presents a Page modally.
/// <param name="modal">The Page to present modally.</param>
/// <returns>An awaitable Task, indicating the PushModal completion.</returns>
public Task PushModalAsync(Page modal)
- {
- return PushModalAsync(modal, true);
- }
+ {
+ return PushModalAsync(modal, true);
+ }
/// <summary>
/// Presents a Page modally, with optional animation.
/// <param name="animated">Whether to animate the push.</param>
/// <returns>An awaitable Task, indicating the PushModal completion.</returns>
public Task PushModalAsync(Page modal, bool animated)
- {
- if (modal.RealParent != null)
- throw new InvalidOperationException("Page must not already have a parent.");
- return OnPushModal(modal, animated);
- }
+ {
+ if (modal.RealParent != null)
+ throw new InvalidOperationException("Page must not already have a parent.");
+ return OnPushModal(modal, animated);
+ }
/// <summary>
/// Removes the specified page from the navigation stack.
/// </summary>
/// <param name="page">The page to remove.</param>
public void RemovePage(Page page)
- {
- OnRemovePage(page);
- }
+ {
+ OnRemovePage(page);
+ }
/// <summary>
/// For internal use. Returns the modal navigation stack.
/// </summary>
/// <returns>The modal navigation stack.</returns>
- protected virtual IReadOnlyList<Page> GetModalStack()
- {
- INavigation currentInner = Inner;
- return currentInner == null ? _modalStack.Value : currentInner.ModalStack;
- }
+ protected virtual IReadOnlyList<Page> GetModalStack()
+ {
+ INavigation currentInner = Inner;
+ return currentInner == null ? _modalStack.Value : currentInner.ModalStack;
+ }
/// <summary>
/// For internal use. Returns the stack of pages in the navigation.
/// </summary>
/// <returns>The stack of pages in the navigation.</returns>
- protected virtual IReadOnlyList<Page> GetNavigationStack()
- {
- INavigation currentInner = Inner;
- return currentInner == null ? _pushStack.Value : currentInner.NavigationStack;
- }
+ protected virtual IReadOnlyList<Page> GetNavigationStack()
+ {
+ INavigation currentInner = Inner;
+ return currentInner == null ? _pushStack.Value : currentInner.NavigationStack;
+ }
/// <summary>
/// The method called when insert a page in the navigation stack before an existing page in the stack.
/// </summary>
/// <param name="page">The page to add.</param>
/// <param name="before">The existing page, before which page will be inserted.</param>
- protected virtual void OnInsertPageBefore(Page page, Page before)
- {
- INavigation currentInner = Inner;
- if (currentInner == null)
- {
- int index = _pushStack.Value.IndexOf(before);
- if (index == -1)
- throw new ArgumentException("before must be in the pushed stack of the current context");
- _pushStack.Value.Insert(index, page);
- }
- else
- {
- currentInner.InsertPageBefore(page, before);
- }
- }
+ protected virtual void OnInsertPageBefore(Page page, Page before)
+ {
+ INavigation currentInner = Inner;
+ if (currentInner == null)
+ {
+ int index = _pushStack.Value.IndexOf(before);
+ if (index == -1)
+ throw new ArgumentException("before must be in the pushed stack of the current context");
+ _pushStack.Value.Insert(index, page);
+ }
+ else
+ {
+ currentInner.InsertPageBefore(page, before);
+ }
+ }
/// <summary>
/// This method calls when removes the top Page from the navigation stack
/// </summary>
/// <param name="animated">Whether to animate the pop.</param>
/// <returns></returns>
- protected virtual Task<Page> OnPopAsync(bool animated)
- {
- INavigation inner = Inner;
- return inner == null ? Task.FromResult(Pop()) : inner.PopAsync(animated);
- }
+ protected virtual Task<Page> OnPopAsync(bool animated)
+ {
+ INavigation inner = Inner;
+ return inner == null ? Task.FromResult(Pop()) : inner.PopAsync(animated);
+ }
/// <summary>
/// This method calls when removes the top Page from the navigation stack
/// </summary>
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>An awaitable instance, indicating the PopModalAsync completion</returns>
- protected virtual Task<Page> OnPopModal(bool animated)
- {
- INavigation innerNav = Inner;
- return innerNav == null ? Task.FromResult(PopModal()) : innerNav.PopModalAsync(animated);
- }
+ protected virtual Task<Page> OnPopModal(bool animated)
+ {
+ INavigation innerNav = Inner;
+ return innerNav == null ? Task.FromResult(PopModal()) : innerNav.PopModalAsync(animated);
+ }
/// <summary>
/// This method calls when Pops all but the root Page off the navigation stack.
/// </summary>
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>A task representing the asynchronous dismiss operation.</returns>
- protected virtual Task OnPopToRootAsync(bool animated)
- {
- INavigation currentInner = Inner;
- if (currentInner == null)
- {
- Page root = _pushStack.Value.Last();
- _pushStack.Value.Clear();
- _pushStack.Value.Add(root);
- return Task.FromResult(root);
- }
- return currentInner.PopToRootAsync(animated);
- }
+ protected virtual Task OnPopToRootAsync(bool animated)
+ {
+ INavigation currentInner = Inner;
+ if (currentInner == null)
+ {
+ Page root = _pushStack.Value.Last();
+ _pushStack.Value.Clear();
+ _pushStack.Value.Add(root);
+ return Task.FromResult(root);
+ }
+ return currentInner.PopToRootAsync(animated);
+ }
/// <summary>
/// This method calls when adds a Page to the top of the navigation stack, with optional animation.
/// <param name="page">The page to add</param>
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>A task that represents the asynchronous push operation.</returns>
- protected virtual Task OnPushAsync(Page page, bool animated)
- {
- INavigation currentInner = Inner;
- if (currentInner == null)
- {
- _pushStack.Value.Add(page);
- return Task.FromResult(page);
- }
- return currentInner.PushAsync(page, animated);
- }
+ protected virtual Task OnPushAsync(Page page, bool animated)
+ {
+ INavigation currentInner = Inner;
+ if (currentInner == null)
+ {
+ _pushStack.Value.Add(page);
+ return Task.FromResult(page);
+ }
+ return currentInner.PushAsync(page, animated);
+ }
/// <summary>
/// This method calls when Presents a Page modally, with optional animation.
/// <param name="modal">The page to push.</param>
/// <param name="animated">Whether to animate the pop.</param>
/// <returns>An awaitable Task, indicating the PushModal completion.</returns>
- protected virtual Task OnPushModal(Page modal, bool animated)
- {
- INavigation currentInner = Inner;
- if (currentInner == null)
- {
- _modalStack.Value.Add(modal);
- return Task.FromResult<object>(null);
- }
- return currentInner.PushModalAsync(modal, animated);
- }
+ protected virtual Task OnPushModal(Page modal, bool animated)
+ {
+ INavigation currentInner = Inner;
+ if (currentInner == null)
+ {
+ _modalStack.Value.Add(modal);
+ return Task.FromResult<object>(null);
+ }
+ return currentInner.PushModalAsync(modal, animated);
+ }
/// <summary>
/// This method calls when Removes the specified page from the navigation stack.
/// </summary>
/// <param name="page">The page to add.</param>
- protected virtual void OnRemovePage(Page page)
- {
- INavigation currentInner = Inner;
- if (currentInner == null)
- {
- _pushStack.Value.Remove(page);
- }
- else
- {
- currentInner.RemovePage(page);
- }
- }
+ protected virtual void OnRemovePage(Page page)
+ {
+ INavigation currentInner = Inner;
+ if (currentInner == null)
+ {
+ _pushStack.Value.Remove(page);
+ }
+ else
+ {
+ currentInner.RemovePage(page);
+ }
+ }
- Page Pop()
- {
- List<Page> list = _pushStack.Value;
- Page result = list[list.Count - 1];
- list.RemoveAt(list.Count - 1);
- return result;
- }
+ Page Pop()
+ {
+ List<Page> list = _pushStack.Value;
+ Page result = list[list.Count - 1];
+ list.RemoveAt(list.Count - 1);
+ return result;
+ }
- Page PopModal()
- {
- List<Page> list = _modalStack.Value;
- Page result = list[list.Count - 1];
- list.RemoveAt(list.Count - 1);
- return result;
- }
- }
+ Page PopModal()
+ {
+ List<Page> list = _modalStack.Value;
+ Page result = list[list.Count - 1];
+ list.RemoveAt(list.Count - 1);
+ return result;
+ }
+ }
}
\ No newline at end of file
/// <summary>
/// For internal use.
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class NavigationRequestedEventArgs : NavigationEventArgs
- {
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class NavigationRequestedEventArgs : NavigationEventArgs
+ {
/// <summary>
/// Constructor.
/// </summary>
/// <param name="page"></param>
/// <param name="animated"></param>
/// <param name="realize"></param>
- public NavigationRequestedEventArgs(Page page, bool animated, bool realize = true) : base(page)
- {
- Animated = animated;
- Realize = realize;
- }
+ public NavigationRequestedEventArgs(Page page, bool animated, bool realize = true) : base(page)
+ {
+ Animated = animated;
+ Realize = realize;
+ }
/// <summary>
/// Constructor.
/// <param name="page"></param>
/// <param name="before"></param>
/// <param name="animated"></param>
- public NavigationRequestedEventArgs(Page page, Page before, bool animated) : this(page, animated)
- {
- BeforePage = before;
- }
+ public NavigationRequestedEventArgs(Page page, Page before, bool animated) : this(page, animated)
+ {
+ BeforePage = before;
+ }
/// <summary>
/// Gets or Sets the whether animate.
/// </summary>
- public bool Animated { get; set; }
+ public bool Animated { get; set; }
/// <summary>
/// Gets or Sets the before page.
/// </summary>
- public Page BeforePage { get; set; }
+ public Page BeforePage { get; set; }
/// <summary>
/// Gets or Sets the realize.
/// </summary>
- public bool Realize { get; set; }
+ public bool Realize { get; set; }
/// <summary>
/// Gets or Sets the Task.
/// </summary>
- public Task<bool> Task { get; set; }
- }
+ public Task<bool> Task { get; set; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class NullEffect : Effect
- {
- protected override void OnAttached()
- {
- }
+ internal class NullEffect : Effect
+ {
+ protected override void OnAttached()
+ {
+ }
- protected override void OnDetached()
- {
- }
- }
+ protected override void OnDetached()
+ {
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal class ObservableWrapper<TTrack, TRestrict> : IList<TRestrict>, INotifyCollectionChanged where TTrack : Element where TRestrict : TTrack
- {
- readonly ObservableCollection<TTrack> _list;
-
- public ObservableWrapper(ObservableCollection<TTrack> list)
- {
- if (list == null)
- throw new ArgumentNullException("list");
-
- _list = list;
-
- list.CollectionChanged += ListOnCollectionChanged;
- }
-
- public void Add(TRestrict item)
- {
- if (item == null)
- throw new ArgumentNullException("item");
- if (IsReadOnly)
- throw new NotSupportedException("The collection is read-only.");
-
- if (_list.Contains(item))
- return;
-
- item.Owned = true;
- _list.Add(item);
- }
-
- public void Clear()
- {
- if (IsReadOnly)
- throw new NotSupportedException("The collection is read-only.");
-
- foreach (TRestrict item in _list.OfType<TRestrict>().ToArray())
- {
- _list.Remove(item);
- item.Owned = false;
- }
- }
-
- public bool Contains(TRestrict item)
- {
- return item.Owned && _list.Contains(item);
- }
-
- public void CopyTo(TRestrict[] array, int destIndex)
- {
- if (array.Length - destIndex < Count)
- throw new ArgumentException("Destination array was not long enough. Check destIndex and length, and the array's lower bounds.");
- foreach (TRestrict item in this)
- {
- array[destIndex] = item;
- destIndex++;
- }
- }
-
- public int Count
- {
- get { return _list.Where(i => i.Owned).OfType<TRestrict>().Count(); }
- }
-
- public bool IsReadOnly { get; internal set; }
-
- public bool Remove(TRestrict item)
- {
- if (item == null)
- throw new ArgumentNullException("item");
- if (IsReadOnly)
- throw new NotSupportedException("The collection is read-only.");
-
- if (!item.Owned)
- return false;
-
- if (_list.Remove(item))
- {
- item.Owned = false;
- return true;
- }
- return false;
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- public IEnumerator<TRestrict> GetEnumerator()
- {
- return _list.Where(i => i.Owned).OfType<TRestrict>().GetEnumerator();
- }
-
- public int IndexOf(TRestrict value)
- {
- int innerIndex = _list.IndexOf(value);
- if (innerIndex == -1)
- return -1;
- return ToOuterIndex(innerIndex);
- }
-
- public void Insert(int index, TRestrict item)
- {
- if (item == null)
- throw new ArgumentNullException("item");
- if (IsReadOnly)
- throw new NotSupportedException("The collection is read-only.");
-
- item.Owned = true;
- _list.Insert(ToInnerIndex(index), item);
- }
-
- public TRestrict this[int index]
- {
- get { return (TRestrict)_list[ToInnerIndex(index)]; }
- set
- {
- int innerIndex = ToInnerIndex(index);
- if (value != null)
- value.Owned = true;
- TTrack old = _list[innerIndex];
- _list[innerIndex] = value;
-
- if (old != null)
- old.Owned = false;
- }
- }
-
- public void RemoveAt(int index)
- {
- if (IsReadOnly)
- throw new NotSupportedException("The collection is read-only");
- int innerIndex = ToInnerIndex(index);
- TTrack item = _list[innerIndex];
- if (item.Owned)
- {
- _list.RemoveAt(innerIndex);
- item.Owned = false;
- }
- }
-
- public event NotifyCollectionChangedEventHandler CollectionChanged;
-
- void ListOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- NotifyCollectionChangedEventHandler handler = CollectionChanged;
- if (handler == null)
- return;
-
- switch (e.Action)
- {
- case NotifyCollectionChangedAction.Add:
- if (e.NewStartingIndex == -1 || e.NewItems.Count > 1)
- goto case NotifyCollectionChangedAction.Reset;
-
- var newItem = e.NewItems[0] as TRestrict;
- if (newItem == null || !newItem.Owned)
- break;
-
- int outerIndex = ToOuterIndex(e.NewStartingIndex);
- handler(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, e.NewItems, outerIndex));
- break;
- case NotifyCollectionChangedAction.Move:
- if (e.NewStartingIndex == -1 || e.OldStartingIndex == -1 || e.NewItems.Count > 1)
- goto case NotifyCollectionChangedAction.Reset;
-
- var movedItem = e.NewItems[0] as TRestrict;
- if (movedItem == null || !movedItem.Owned)
- break;
-
- int outerOldIndex = ToOuterIndex(e.OldStartingIndex);
- int outerNewIndex = ToOuterIndex(e.NewStartingIndex);
- handler(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, e.NewItems, outerNewIndex, outerOldIndex));
- break;
- case NotifyCollectionChangedAction.Remove:
- if (e.OldStartingIndex == -1 || e.OldItems?.Count > 1)
- goto case NotifyCollectionChangedAction.Reset;
-
- var removedItem = e.OldItems[0] as TRestrict;
- if (removedItem == null || !removedItem.Owned)
- break;
-
- int outerRemovedIndex = ToOuterIndex(e.OldStartingIndex);
- var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removedItem, outerRemovedIndex);
- handler(this, args);
- break;
- case NotifyCollectionChangedAction.Replace:
- if (e.NewStartingIndex == -1 || e.OldStartingIndex == -1 || e.NewItems?.Count > 1)
- goto case NotifyCollectionChangedAction.Reset;
-
- var newReplaceItem = e.NewItems[0] as TRestrict;
- var oldReplaceItem = e.OldItems?[0] as TRestrict;
-
- if ((newReplaceItem == null || !newReplaceItem.Owned) && (oldReplaceItem == null || !oldReplaceItem.Owned))
- {
- break;
- }
- if (newReplaceItem == null || !newReplaceItem.Owned || oldReplaceItem == null || !oldReplaceItem.Owned)
- {
- goto case NotifyCollectionChangedAction.Reset;
- }
-
- int index = ToOuterIndex(e.NewStartingIndex);
-
- var replaceArgs = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, newReplaceItem, oldReplaceItem, index);
- handler(this, replaceArgs);
- break;
- case NotifyCollectionChangedAction.Reset:
- handler(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
- }
-
- int ToInnerIndex(int outterIndex)
- {
- var outerIndex = 0;
- int innerIndex;
- for (innerIndex = 0; innerIndex < _list.Count; innerIndex++)
- {
- TTrack item = _list[innerIndex];
- if (item is TRestrict && item.Owned)
- {
- if (outerIndex == outterIndex)
- return innerIndex;
- outerIndex++;
- }
- }
-
- return innerIndex;
- }
-
- int ToOuterIndex(int innerIndex)
- {
- var outerIndex = 0;
- for (var index = 0; index < innerIndex; index++)
- {
- TTrack item = _list[index];
- if (item is TRestrict && item.Owned)
- {
- outerIndex++;
- }
- }
-
- return outerIndex;
- }
- }
+ internal class ObservableWrapper<TTrack, TRestrict> : IList<TRestrict>, INotifyCollectionChanged where TTrack : Element where TRestrict : TTrack
+ {
+ readonly ObservableCollection<TTrack> _list;
+
+ public ObservableWrapper(ObservableCollection<TTrack> list)
+ {
+ if (list == null)
+ throw new ArgumentNullException("list");
+
+ _list = list;
+
+ list.CollectionChanged += ListOnCollectionChanged;
+ }
+
+ public void Add(TRestrict item)
+ {
+ if (item == null)
+ throw new ArgumentNullException("item");
+ if (IsReadOnly)
+ throw new NotSupportedException("The collection is read-only.");
+
+ if (_list.Contains(item))
+ return;
+
+ item.Owned = true;
+ _list.Add(item);
+ }
+
+ public void Clear()
+ {
+ if (IsReadOnly)
+ throw new NotSupportedException("The collection is read-only.");
+
+ foreach (TRestrict item in _list.OfType<TRestrict>().ToArray())
+ {
+ _list.Remove(item);
+ item.Owned = false;
+ }
+ }
+
+ public bool Contains(TRestrict item)
+ {
+ return item.Owned && _list.Contains(item);
+ }
+
+ public void CopyTo(TRestrict[] array, int destIndex)
+ {
+ if (array.Length - destIndex < Count)
+ throw new ArgumentException("Destination array was not long enough. Check destIndex and length, and the array's lower bounds.");
+ foreach (TRestrict item in this)
+ {
+ array[destIndex] = item;
+ destIndex++;
+ }
+ }
+
+ public int Count
+ {
+ get { return _list.Where(i => i.Owned).OfType<TRestrict>().Count(); }
+ }
+
+ public bool IsReadOnly { get; internal set; }
+
+ public bool Remove(TRestrict item)
+ {
+ if (item == null)
+ throw new ArgumentNullException("item");
+ if (IsReadOnly)
+ throw new NotSupportedException("The collection is read-only.");
+
+ if (!item.Owned)
+ return false;
+
+ if (_list.Remove(item))
+ {
+ item.Owned = false;
+ return true;
+ }
+ return false;
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ public IEnumerator<TRestrict> GetEnumerator()
+ {
+ return _list.Where(i => i.Owned).OfType<TRestrict>().GetEnumerator();
+ }
+
+ public int IndexOf(TRestrict value)
+ {
+ int innerIndex = _list.IndexOf(value);
+ if (innerIndex == -1)
+ return -1;
+ return ToOuterIndex(innerIndex);
+ }
+
+ public void Insert(int index, TRestrict item)
+ {
+ if (item == null)
+ throw new ArgumentNullException("item");
+ if (IsReadOnly)
+ throw new NotSupportedException("The collection is read-only.");
+
+ item.Owned = true;
+ _list.Insert(ToInnerIndex(index), item);
+ }
+
+ public TRestrict this[int index]
+ {
+ get { return (TRestrict)_list[ToInnerIndex(index)]; }
+ set
+ {
+ int innerIndex = ToInnerIndex(index);
+ if (value != null)
+ value.Owned = true;
+ TTrack old = _list[innerIndex];
+ _list[innerIndex] = value;
+
+ if (old != null)
+ old.Owned = false;
+ }
+ }
+
+ public void RemoveAt(int index)
+ {
+ if (IsReadOnly)
+ throw new NotSupportedException("The collection is read-only");
+ int innerIndex = ToInnerIndex(index);
+ TTrack item = _list[innerIndex];
+ if (item.Owned)
+ {
+ _list.RemoveAt(innerIndex);
+ item.Owned = false;
+ }
+ }
+
+ public event NotifyCollectionChangedEventHandler CollectionChanged;
+
+ void ListOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ NotifyCollectionChangedEventHandler handler = CollectionChanged;
+ if (handler == null)
+ return;
+
+ switch (e.Action)
+ {
+ case NotifyCollectionChangedAction.Add:
+ if (e.NewStartingIndex == -1 || e.NewItems.Count > 1)
+ goto case NotifyCollectionChangedAction.Reset;
+
+ var newItem = e.NewItems[0] as TRestrict;
+ if (newItem == null || !newItem.Owned)
+ break;
+
+ int outerIndex = ToOuterIndex(e.NewStartingIndex);
+ handler(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, e.NewItems, outerIndex));
+ break;
+ case NotifyCollectionChangedAction.Move:
+ if (e.NewStartingIndex == -1 || e.OldStartingIndex == -1 || e.NewItems.Count > 1)
+ goto case NotifyCollectionChangedAction.Reset;
+
+ var movedItem = e.NewItems[0] as TRestrict;
+ if (movedItem == null || !movedItem.Owned)
+ break;
+
+ int outerOldIndex = ToOuterIndex(e.OldStartingIndex);
+ int outerNewIndex = ToOuterIndex(e.NewStartingIndex);
+ handler(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, e.NewItems, outerNewIndex, outerOldIndex));
+ break;
+ case NotifyCollectionChangedAction.Remove:
+ if (e.OldStartingIndex == -1 || e.OldItems?.Count > 1)
+ goto case NotifyCollectionChangedAction.Reset;
+
+ var removedItem = e.OldItems[0] as TRestrict;
+ if (removedItem == null || !removedItem.Owned)
+ break;
+
+ int outerRemovedIndex = ToOuterIndex(e.OldStartingIndex);
+ var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removedItem, outerRemovedIndex);
+ handler(this, args);
+ break;
+ case NotifyCollectionChangedAction.Replace:
+ if (e.NewStartingIndex == -1 || e.OldStartingIndex == -1 || e.NewItems?.Count > 1)
+ goto case NotifyCollectionChangedAction.Reset;
+
+ var newReplaceItem = e.NewItems[0] as TRestrict;
+ var oldReplaceItem = e.OldItems?[0] as TRestrict;
+
+ if ((newReplaceItem == null || !newReplaceItem.Owned) && (oldReplaceItem == null || !oldReplaceItem.Owned))
+ {
+ break;
+ }
+ if (newReplaceItem == null || !newReplaceItem.Owned || oldReplaceItem == null || !oldReplaceItem.Owned)
+ {
+ goto case NotifyCollectionChangedAction.Reset;
+ }
+
+ int index = ToOuterIndex(e.NewStartingIndex);
+
+ var replaceArgs = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, newReplaceItem, oldReplaceItem, index);
+ handler(this, replaceArgs);
+ break;
+ case NotifyCollectionChangedAction.Reset:
+ handler(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ int ToInnerIndex(int outterIndex)
+ {
+ var outerIndex = 0;
+ int innerIndex;
+ for (innerIndex = 0; innerIndex < _list.Count; innerIndex++)
+ {
+ TTrack item = _list[innerIndex];
+ if (item is TRestrict && item.Owned)
+ {
+ if (outerIndex == outterIndex)
+ return innerIndex;
+ outerIndex++;
+ }
+ }
+
+ return innerIndex;
+ }
+
+ int ToOuterIndex(int innerIndex)
+ {
+ var outerIndex = 0;
+ for (var index = 0; index < innerIndex; index++)
+ {
+ TTrack item = _list[index];
+ if (item is TRestrict && item.Owned)
+ {
+ outerIndex++;
+ }
+ }
+
+ return outerIndex;
+ }
+ }
}
\ No newline at end of file
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
- internal class OnIdiom<T>
- {
- public T Phone { get; set; }
+ internal class OnIdiom<T>
+ {
+ public T Phone { get; set; }
- public T Tablet { get; set; }
-
- public T Desktop { get; set; }
+ public T Tablet { get; set; }
+
+ public T Desktop { get; set; }
- public T TV { get; set; }
+ public T TV { get; set; }
- public T Watch { get; set; }
+ public T Watch { get; set; }
- public static implicit operator T(OnIdiom<T> onIdiom)
- {
- switch (Device.Idiom)
- {
- default:
- case TargetIdiom.Phone:
- return onIdiom.Phone;
- case TargetIdiom.Tablet:
- return onIdiom.Tablet;
- case TargetIdiom.Desktop:
- return onIdiom.Desktop;
- case TargetIdiom.TV:
- return onIdiom.TV;
- case TargetIdiom.Watch:
- return onIdiom.Watch;
- }
- }
- }
+ public static implicit operator T(OnIdiom<T> onIdiom)
+ {
+ switch (Device.Idiom)
+ {
+ default:
+ case TargetIdiom.Phone:
+ return onIdiom.Phone;
+ case TargetIdiom.Tablet:
+ return onIdiom.Tablet;
+ case TargetIdiom.Desktop:
+ return onIdiom.Desktop;
+ case TargetIdiom.TV:
+ return onIdiom.TV;
+ case TargetIdiom.Watch:
+ return onIdiom.Watch;
+ }
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- [ContentProperty("Platforms")]
- internal class OnPlatform<T>
- {
- public OnPlatform()
- {
- Platforms = new List<On>();
- }
+ [ContentProperty("Platforms")]
+ internal class OnPlatform<T>
+ {
+ public OnPlatform()
+ {
+ Platforms = new List<On>();
+ }
- bool useLegacyFallback;
- T android;
- [Obsolete]
- public T Android {
- get { return android; }
- set {
- useLegacyFallback = true;
- android = value;
- }
- }
+ bool useLegacyFallback;
+ T android;
+ [Obsolete]
+ public T Android {
+ get { return android; }
+ set {
+ useLegacyFallback = true;
+ android = value;
+ }
+ }
- T ios;
- [Obsolete]
- public T iOS {
- get { return ios; }
- set {
- useLegacyFallback = true;
- ios = value;
- }
- }
+ T ios;
+ [Obsolete]
+ public T iOS {
+ get { return ios; }
+ set {
+ useLegacyFallback = true;
+ ios = value;
+ }
+ }
- T winPhone;
- [Obsolete]
- public T WinPhone {
- get { return winPhone; }
- set {
- useLegacyFallback = true;
- winPhone = value;
- }
- }
+ T winPhone;
+ [Obsolete]
+ public T WinPhone {
+ get { return winPhone; }
+ set {
+ useLegacyFallback = true;
+ winPhone = value;
+ }
+ }
- bool hasDefault;
- T @default;
- public T Default {
- get { return @default; }
- set {
- hasDefault = true;
- @default = value;
- }
- }
+ bool hasDefault;
+ T @default;
+ public T Default {
+ get { return @default; }
+ set {
+ hasDefault = true;
+ @default = value;
+ }
+ }
- public IList<On> Platforms { get; private set; }
+ public IList<On> Platforms { get; private set; }
#pragma warning disable RECS0108 // Warns about static fields in generic types
- static readonly IValueConverterProvider s_valueConverter = DependencyService.Get<IValueConverterProvider>();
+ static readonly IValueConverterProvider s_valueConverter = DependencyService.Get<IValueConverterProvider>();
#pragma warning restore RECS0108 // Warns about static fields in generic types
- public static implicit operator T(OnPlatform<T> onPlatform)
- {
- foreach (var onPlat in onPlatform.Platforms) {
- if (onPlat.Platform == null)
- continue;
- if (!onPlat.Platform.Contains(Device.RuntimePlatform))
- continue;
- if (s_valueConverter == null)
- continue;
- return (T)s_valueConverter.Convert(onPlat.Value, typeof(T), null, null);
- }
+ public static implicit operator T(OnPlatform<T> onPlatform)
+ {
+ foreach (var onPlat in onPlatform.Platforms) {
+ if (onPlat.Platform == null)
+ continue;
+ if (!onPlat.Platform.Contains(Device.RuntimePlatform))
+ continue;
+ if (s_valueConverter == null)
+ continue;
+ return (T)s_valueConverter.Convert(onPlat.Value, typeof(T), null, null);
+ }
- if (!onPlatform.useLegacyFallback)
- return onPlatform.hasDefault ? onPlatform.@default : default(T);
+ if (!onPlatform.useLegacyFallback)
+ return onPlatform.hasDefault ? onPlatform.@default : default(T);
- //legacy fallback
+ //legacy fallback
#pragma warning disable 0618, 0612
- return Device.OnPlatform(iOS: onPlatform.iOS, Android: onPlatform.Android, WinPhone: onPlatform.WinPhone);
+ return Device.OnPlatform(iOS: onPlatform.iOS, Android: onPlatform.Android, WinPhone: onPlatform.WinPhone);
#pragma warning restore 0618, 0612
- }
- }
+ }
+ }
- [ContentProperty("Value")]
- internal class On
- {
- [TypeConverter(typeof(ListStringTypeConverter))]
- public IList<string> Platform { get; set; }
- public object Value { get; set; }
- }
+ [ContentProperty("Value")]
+ internal class On
+ {
+ [TypeConverter(typeof(ListStringTypeConverter))]
+ public IList<string> Platform { get; set; }
+ public object Value { get; set; }
+ }
}
namespace Tizen.NUI.Binding
{
- static class PaddingElement
- {
- public static readonly BindableProperty PaddingProperty =
- BindableProperty.Create(nameof(IPaddingElement.Padding), typeof(Thickness), typeof(IPaddingElement), default(Thickness),
- propertyChanged: OnPaddingPropertyChanged,
- defaultValueCreator: PaddingDefaultValueCreator);
+ internal static class PaddingElement
+ {
+ internal static readonly BindableProperty PaddingProperty =
+ BindableProperty.Create("Padding", typeof(Thickness), typeof(IPaddingElement), default(Thickness),
+ propertyChanged: OnPaddingPropertyChanged,
+ defaultValueCreator: PaddingDefaultValueCreator);
- static void OnPaddingPropertyChanged(BindableObject bindable, object oldValue, object newValue)
- {
- ((IPaddingElement)bindable).OnPaddingPropertyChanged((Thickness)oldValue, (Thickness)newValue);
- }
+ static void OnPaddingPropertyChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ ((IPaddingElement)bindable).OnPaddingPropertyChanged((Thickness)oldValue, (Thickness)newValue);
+ }
- static object PaddingDefaultValueCreator(BindableObject bindable)
- {
- return ((IPaddingElement)bindable).PaddingDefaultValueCreator();
- }
+ static object PaddingDefaultValueCreator(BindableObject bindable)
+ {
+ return ((IPaddingElement)bindable).PaddingDefaultValueCreator();
+ }
- public static readonly BindableProperty PaddingLeftProperty =
- BindableProperty.Create("PaddingLeft", typeof(double), typeof(IPaddingElement), default(double),
- propertyChanged: OnPaddingLeftChanged);
+ public static readonly BindableProperty PaddingLeftProperty =
+ BindableProperty.Create("PaddingLeft", typeof(double), typeof(IPaddingElement), default(double),
+ propertyChanged: OnPaddingLeftChanged);
- static void OnPaddingLeftChanged(BindableObject bindable, object oldValue, object newValue)
- {
- var padding = (Thickness)bindable.GetValue(PaddingProperty);
- padding.Left = (double)newValue;
- bindable.SetValue(PaddingProperty, padding);
- }
+ static void OnPaddingLeftChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ var padding = (Thickness)bindable.GetValue(PaddingProperty);
+ padding.Left = (double)newValue;
+ bindable.SetValue(PaddingProperty, padding);
+ }
- public static readonly BindableProperty PaddingTopProperty =
- BindableProperty.Create("PaddingTop", typeof(double), typeof(IPaddingElement), default(double),
- propertyChanged: OnPaddingTopChanged);
+ public static readonly BindableProperty PaddingTopProperty =
+ BindableProperty.Create("PaddingTop", typeof(double), typeof(IPaddingElement), default(double),
+ propertyChanged: OnPaddingTopChanged);
- static void OnPaddingTopChanged(BindableObject bindable, object oldValue, object newValue)
- {
- var padding = (Thickness)bindable.GetValue(PaddingProperty);
- padding.Top = (double)newValue;
- bindable.SetValue(PaddingProperty, padding);
- }
+ static void OnPaddingTopChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ var padding = (Thickness)bindable.GetValue(PaddingProperty);
+ padding.Top = (double)newValue;
+ bindable.SetValue(PaddingProperty, padding);
+ }
- public static readonly BindableProperty PaddingRightProperty =
- BindableProperty.Create("PaddingRight", typeof(double), typeof(IPaddingElement), default(double),
- propertyChanged: OnPaddingRightChanged);
+ public static readonly BindableProperty PaddingRightProperty =
+ BindableProperty.Create("PaddingRight", typeof(double), typeof(IPaddingElement), default(double),
+ propertyChanged: OnPaddingRightChanged);
- static void OnPaddingRightChanged(BindableObject bindable, object oldValue, object newValue)
- {
- var padding = (Thickness)bindable.GetValue(PaddingProperty);
- padding.Right = (double)newValue;
- bindable.SetValue(PaddingProperty, padding);
- }
+ static void OnPaddingRightChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ var padding = (Thickness)bindable.GetValue(PaddingProperty);
+ padding.Right = (double)newValue;
+ bindable.SetValue(PaddingProperty, padding);
+ }
- public static readonly BindableProperty PaddingBottomProperty =
- BindableProperty.Create("PaddingBottom", typeof(double), typeof(IPaddingElement), default(double),
- propertyChanged: OnPaddingBottomChanged);
+ public static readonly BindableProperty PaddingBottomProperty =
+ BindableProperty.Create("PaddingBottom", typeof(double), typeof(IPaddingElement), default(double),
+ propertyChanged: OnPaddingBottomChanged);
- static void OnPaddingBottomChanged(BindableObject bindable, object oldValue, object newValue)
- {
- var padding = (Thickness)bindable.GetValue(PaddingProperty);
- padding.Bottom = (double)newValue;
- bindable.SetValue(PaddingProperty, padding);
- }
- }
+ static void OnPaddingBottomChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ var padding = (Thickness)bindable.GetValue(PaddingProperty);
+ padding.Bottom = (double)newValue;
+ bindable.SetValue(PaddingProperty, padding);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [AttributeUsage(AttributeTargets.Parameter)]
- internal sealed class ParameterAttribute : Attribute
- {
- public ParameterAttribute(string name)
- {
- Name = name;
- }
+ [AttributeUsage(AttributeTargets.Parameter)]
+ internal sealed class ParameterAttribute : Attribute
+ {
+ public ParameterAttribute(string name)
+ {
+ Name = name;
+ }
- public string Name { get; }
- }
+ public string Name { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- /// <summary>
- /// Helper that handles storing and lookup of platform specifics implementations
- /// </summary>
- /// <typeparam name="TElement">The Element type</typeparam>
- internal class PlatformConfigurationRegistry<TElement> : IElementConfiguration<TElement>
- where TElement : Element
- {
- readonly TElement _element;
- readonly Dictionary<Type, object> _platformSpecifics = new Dictionary<Type, object>();
+ /// <summary>
+ /// Helper that handles storing and lookup of platform specifics implementations
+ /// </summary>
+ /// <typeparam name="TElement">The Element type</typeparam>
+ internal class PlatformConfigurationRegistry<TElement> : IElementConfiguration<TElement>
+ where TElement : Element
+ {
+ readonly TElement _element;
+ readonly Dictionary<Type, object> _platformSpecifics = new Dictionary<Type, object>();
- internal PlatformConfigurationRegistry(TElement element)
- {
- _element = element;
- }
+ internal PlatformConfigurationRegistry(TElement element)
+ {
+ _element = element;
+ }
- public IPlatformElementConfiguration<T, TElement> On<T>() where T : IConfigPlatform
- {
- if (_platformSpecifics.ContainsKey(typeof(T)))
- {
- return (IPlatformElementConfiguration<T, TElement>)_platformSpecifics[typeof(T)];
- }
+ public IPlatformElementConfiguration<T, TElement> On<T>() where T : IConfigPlatform
+ {
+ if (_platformSpecifics.ContainsKey(typeof(T)))
+ {
+ return (IPlatformElementConfiguration<T, TElement>)_platformSpecifics[typeof(T)];
+ }
- var emptyConfig = Configuration<T, TElement>.Create(_element);
+ var emptyConfig = Configuration<T, TElement>.Create(_element);
- _platformSpecifics.Add(typeof(T), emptyConfig);
+ _platformSpecifics.Add(typeof(T), emptyConfig);
- return emptyConfig;
- }
- }
+ return emptyConfig;
+ }
+ }
}
using System;
using System.Linq;
using System.Reflection;
+using System.Globalization;
using Tizen.NUI;
return ParentOrigin.BottomRight;
}
}
+
+ parts = value.Split(',');
+ if (parts.Length == 3)
+ {
+ return new Position(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture));
+ }
}
throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Position)}");
{
public override object ConvertFromInvariantString(string value)
{
- if (value != null)
- {
- string[] parts = value.Split(',');
- if (parts.Length == 2)
- {
- return new Position2D(int.Parse(parts[0].Trim()), int.Parse(parts[1].Trim()));
- }
- }
-
- throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Position2D)}");
+ return Position2D.ConvertFromString(value);
}
}
}
namespace Tizen.NUI.Binding
{
- // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.RectangleTypeConverter")]
- [Xaml.TypeConversion(typeof(Rectangle))]
- internal class RectangleTypeConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- if (value != null)
- {
- double x, y, w, h;
- string[] xywh = value.Split(',');
- if (xywh.Length == 4 && double.TryParse(xywh[0], NumberStyles.Number, CultureInfo.InvariantCulture, out x) && double.TryParse(xywh[1], NumberStyles.Number, CultureInfo.InvariantCulture, out y) &&
- double.TryParse(xywh[2], NumberStyles.Number, CultureInfo.InvariantCulture, out w) && double.TryParse(xywh[3], NumberStyles.Number, CultureInfo.InvariantCulture, out h))
- return new Rectangle((int)x, (int)y, (int)w, (int)h);
- }
+ // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.RectangleTypeConverter")]
+ [Xaml.TypeConversion(typeof(Rectangle))]
+ internal class RectangleTypeConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (value != null)
+ {
+ double x, y, w, h;
+ string[] xywh = value.Split(',');
+ if (xywh.Length == 4 && double.TryParse(xywh[0], NumberStyles.Number, CultureInfo.InvariantCulture, out x) && double.TryParse(xywh[1], NumberStyles.Number, CultureInfo.InvariantCulture, out y) &&
+ double.TryParse(xywh[2], NumberStyles.Number, CultureInfo.InvariantCulture, out w) && double.TryParse(xywh[3], NumberStyles.Number, CultureInfo.InvariantCulture, out h))
+ return new Rectangle((int)x, (int)y, (int)w, (int)h);
+ }
- throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(Rectangle)));
- }
- }
+ throw new InvalidOperationException(string.Format("Cannot convert \"{0}\" into {1}", value, typeof(Rectangle)));
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- // Previewer uses reflection to bind to this method; Removal or modification of visibility will break previewer.
- internal static class Registrar
- {
- internal static void RegisterAll(Type[] attrTypes) => Internals.Registrar.RegisterAll(attrTypes);
- }
+ // Previewer uses reflection to bind to this method; Removal or modification of visibility will break previewer.
+ internal static class Registrar
+ {
+ internal static void RegisterAll(Type[] attrTypes) => Internals.Registrar.RegisterAll(attrTypes);
+ }
}
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
/// <summary>
/// For internal use.
/// </summary>
/// <typeparam name="TRegistrable"></typeparam>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class Registrar<TRegistrable> where TRegistrable : class
- {
- readonly Dictionary<Type, Type> _handlers = new Dictionary<Type, Type>();
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class Registrar<TRegistrable> where TRegistrable : class
+ {
+ readonly Dictionary<Type, Type> _handlers = new Dictionary<Type, Type>();
/// <summary>
/// Register.
/// </summary>
/// <param name="tview">The type of the view</param>
/// <param name="trender">The type of the render.</param>
- public void Register(Type tview, Type trender)
- {
- //avoid caching null renderers
- if (trender == null)
- return;
- _handlers[tview] = trender;
- }
-
- internal TRegistrable GetHandler(Type type)
- {
- Type handlerType = GetHandlerType(type);
- if (handlerType == null)
- return null;
-
- object handler = DependencyResolver.ResolveOrCreate(handlerType);
-
- return (TRegistrable)handler;
- }
-
- internal TRegistrable GetHandler(Type type, params object[] args)
- {
- if (args.Length == 0)
- {
- return GetHandler(type);
- }
-
- Type handlerType = GetHandlerType(type);
- if (handlerType == null)
- return null;
-
- return (TRegistrable)DependencyResolver.ResolveOrCreate(handlerType, args);
- }
+ public void Register(Type tview, Type trender)
+ {
+ //avoid caching null renderers
+ if (trender == null)
+ return;
+ _handlers[tview] = trender;
+ }
+
+ internal TRegistrable GetHandler(Type type)
+ {
+ Type handlerType = GetHandlerType(type);
+ if (handlerType == null)
+ return null;
+
+ object handler = DependencyResolver.ResolveOrCreate(handlerType);
+
+ return (TRegistrable)handler;
+ }
+
+ internal TRegistrable GetHandler(Type type, params object[] args)
+ {
+ if (args.Length == 0)
+ {
+ return GetHandler(type);
+ }
+
+ Type handlerType = GetHandlerType(type);
+ if (handlerType == null)
+ return null;
+
+ return (TRegistrable)DependencyResolver.ResolveOrCreate(handlerType, args);
+ }
/// <summary>
/// For internal use. Returns handler.
/// <typeparam name="TOut">The type of the handler</typeparam>
/// <param name="type">The type.</param>
/// <returns>The handler instance.</returns>
- public TOut GetHandler<TOut>(Type type) where TOut : TRegistrable
- {
- return (TOut)GetHandler(type);
- }
+ public TOut GetHandler<TOut>(Type type) where TOut : TRegistrable
+ {
+ return (TOut)GetHandler(type);
+ }
/// <summary>
/// For internal use. Returns handler.
/// <param name="type">The type.</param>
/// <param name="args">The args of the type</param>
/// <returns>The handler instance.</returns>
- public TOut GetHandler<TOut>(Type type, params object[] args) where TOut : TRegistrable
- {
- return (TOut)GetHandler(type, args);
- }
+ public TOut GetHandler<TOut>(Type type, params object[] args) where TOut : TRegistrable
+ {
+ return (TOut)GetHandler(type, args);
+ }
/// <summary>
/// For internal use. Return the handler of the object.
/// <typeparam name="TOut">Thetype</typeparam>
/// <param name="obj">The object instance.</param>
/// <returns>The handle of the obj.</returns>
- public TOut GetHandlerForObject<TOut>(object obj) where TOut : TRegistrable
- {
- if (obj == null)
- throw new ArgumentNullException(nameof(obj));
+ public TOut GetHandlerForObject<TOut>(object obj) where TOut : TRegistrable
+ {
+ if (obj == null)
+ throw new ArgumentNullException(nameof(obj));
- var reflectableType = obj as IReflectableType;
- var type = reflectableType != null ? reflectableType.GetTypeInfo().AsType() : obj.GetType();
+ var reflectableType = obj as IReflectableType;
+ var type = reflectableType != null ? reflectableType.GetTypeInfo().AsType() : obj.GetType();
- return (TOut)GetHandler(type);
- }
+ return (TOut)GetHandler(type);
+ }
/// <summary>
/// For inetrnal use. Return the handler of the object.
/// <param name="obj">The object instance</param>
/// <param name="args">The args of the type</param>
/// <returns>The handler of the object.</returns>
- public TOut GetHandlerForObject<TOut>(object obj, params object[] args) where TOut : TRegistrable
- {
- if (obj == null)
- throw new ArgumentNullException(nameof(obj));
+ public TOut GetHandlerForObject<TOut>(object obj, params object[] args) where TOut : TRegistrable
+ {
+ if (obj == null)
+ throw new ArgumentNullException(nameof(obj));
- var reflectableType = obj as IReflectableType;
- var type = reflectableType != null ? reflectableType.GetTypeInfo().AsType() : obj.GetType();
+ var reflectableType = obj as IReflectableType;
+ var type = reflectableType != null ? reflectableType.GetTypeInfo().AsType() : obj.GetType();
- return (TOut)GetHandler(type, args);
- }
+ return (TOut)GetHandler(type, args);
+ }
/// <summary>
/// For internal use. Returns the handle type.
/// </summary>
/// <param name="viewType">The view type.</param>
/// <returns>The type of the handle.</returns>
- public Type GetHandlerType(Type viewType)
- {
- Type type;
- if (LookupHandlerType(viewType, out type))
- return type;
-
- // lazy load render-view association with RenderWithAttribute (as opposed to using ExportRenderer)
- var attribute = viewType.GetTypeInfo().GetCustomAttribute<RenderWithAttribute>();
- if (attribute == null)
- {
- Register(viewType, null); // Cache this result so we don't have to do GetCustomAttribute again
- return null;
- }
-
- type = attribute.Type;
-
- if (type.Name.StartsWith("_", StringComparison.Ordinal))
- {
- // TODO: Remove attribute2 once renderer names have been unified across all platforms
- var attribute2 = type.GetTypeInfo().GetCustomAttribute<RenderWithAttribute>();
- if (attribute2 != null)
- type = attribute2.Type;
-
- if (type.Name.StartsWith("_", StringComparison.Ordinal))
- {
- Register(viewType, null); // Cache this result so we don't work through this chain again
- return null;
- }
- }
-
- Register(viewType, type); // Register this so we don't have to look for the RenderWith Attibute again in the future
-
- return type;
- }
+ public Type GetHandlerType(Type viewType)
+ {
+ Type type;
+ if (LookupHandlerType(viewType, out type))
+ return type;
+
+ // lazy load render-view association with RenderWithAttribute (as opposed to using ExportRenderer)
+ var attribute = viewType.GetTypeInfo().GetCustomAttribute<RenderWithAttribute>();
+ if (attribute == null)
+ {
+ Register(viewType, null); // Cache this result so we don't have to do GetCustomAttribute again
+ return null;
+ }
+
+ type = attribute.Type;
+
+ if (type.Name.StartsWith("_", StringComparison.Ordinal))
+ {
+ // TODO: Remove attribute2 once renderer names have been unified across all platforms
+ var attribute2 = type.GetTypeInfo().GetCustomAttribute<RenderWithAttribute>();
+ if (attribute2 != null)
+ type = attribute2.Type;
+
+ if (type.Name.StartsWith("_", StringComparison.Ordinal))
+ {
+ Register(viewType, null); // Cache this result so we don't work through this chain again
+ return null;
+ }
+ }
+
+ Register(viewType, type); // Register this so we don't have to look for the RenderWith Attibute again in the future
+
+ return type;
+ }
/// <summary>
/// For internal use. Return the handle type of the object
/// </summary>
/// <param name="obj">The object instance.</param>
/// <returns>The type of the handler.</returns>
- public Type GetHandlerTypeForObject(object obj)
- {
- if (obj == null)
- throw new ArgumentNullException(nameof(obj));
+ public Type GetHandlerTypeForObject(object obj)
+ {
+ if (obj == null)
+ throw new ArgumentNullException(nameof(obj));
- var reflectableType = obj as IReflectableType;
- var type = reflectableType != null ? reflectableType.GetTypeInfo().AsType() : obj.GetType();
+ var reflectableType = obj as IReflectableType;
+ var type = reflectableType != null ? reflectableType.GetTypeInfo().AsType() : obj.GetType();
- return GetHandlerType(type);
- }
+ return GetHandlerType(type);
+ }
- bool LookupHandlerType(Type viewType, out Type handlerType)
- {
- Type type = viewType;
+ bool LookupHandlerType(Type viewType, out Type handlerType)
+ {
+ Type type = viewType;
- while (type != null)
- {
- if (_handlers.ContainsKey(type))
- {
- handlerType = _handlers[type];
- return true;
- }
+ while (type != null)
+ {
+ if (_handlers.ContainsKey(type))
+ {
+ handlerType = _handlers[type];
+ return true;
+ }
- type = type.GetTypeInfo().BaseType;
- }
+ type = type.GetTypeInfo().BaseType;
+ }
- handlerType = null;
- return false;
- }
- }
+ handlerType = null;
+ return false;
+ }
+ }
/// <summary>
/// For internal use
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal static class Registrar
- {
- static Registrar()
- {
- Registered = new Registrar<IRegisterable>();
- }
-
- internal static Dictionary<string, Type> Effects { get; } = new Dictionary<string, Type>();
- internal static Dictionary<string, StyleSheets.StylePropertyAttribute> StyleProperties { get; } = new Dictionary<string, StyleSheets.StylePropertyAttribute>();
-
- public static IEnumerable<Assembly> ExtraAssemblies { get; set; }
-
- public static Registrar<IRegisterable> Registered { get; internal set; }
-
- public static void RegisterAll(Type[] attrTypes)
- {
- Assembly[] assemblies = Device.GetAssemblies();
- if (ExtraAssemblies != null)
- assemblies = assemblies.Union(ExtraAssemblies).ToArray();
-
- Assembly defaultRendererAssembly = Device.PlatformServices.GetType().GetTypeInfo().Assembly;
- int indexOfExecuting = Array.IndexOf(assemblies, defaultRendererAssembly);
-
- if (indexOfExecuting > 0)
- {
- assemblies[indexOfExecuting] = assemblies[0];
- assemblies[0] = defaultRendererAssembly;
- }
-
- // Don't use LINQ for performance reasons
- // Naive implementation can easily take over a second to run
- foreach (Assembly assembly in assemblies)
- {
- foreach (Type attrType in attrTypes)
- {
- Attribute[] attributes;
- try
- {
- attributes = assembly.GetCustomAttributes(attrType).ToArray();
- }
- catch (System.IO.FileNotFoundException)
- {
- // Sometimes the previewer doesn't actually have everything required for these loads to work
- Console.WriteLine(nameof(Registrar), "Could not load assembly: {0} for Attibute {1} | Some renderers may not be loaded", assembly.FullName, attrType.FullName);
- continue;
- }
- var length = attributes.Length;
- for (var i = 0; i < length;i++)
- {
- var attribute = (HandlerAttribute)attributes[i];
- if (attribute.ShouldRegister())
- Registered.Register(attribute.HandlerType, attribute.TargetType);
- }
- }
-
- string resolutionName = assembly.FullName;
- var resolutionNameAttribute = (ResolutionGroupNameAttribute)assembly.GetCustomAttribute(typeof(ResolutionGroupNameAttribute));
- if (resolutionNameAttribute != null)
- resolutionName = resolutionNameAttribute.ShortName;
-
- Attribute[] effectAttributes = assembly.GetCustomAttributes(typeof(ExportEffectAttribute)).ToArray();
- var exportEffectsLength = effectAttributes.Length;
- for (var i = 0; i < exportEffectsLength;i++)
- {
- var effect = (ExportEffectAttribute)effectAttributes[i];
- Effects [resolutionName + "." + effect.Id] = effect.Type;
- }
-
- Attribute[] styleAttributes = assembly.GetCustomAttributes(typeof(StyleSheets.StylePropertyAttribute)).ToArray();
- var stylePropertiesLength = styleAttributes.Length;
- for (var i = 0; i < stylePropertiesLength; i++)
- {
- var attribute = (StyleSheets.StylePropertyAttribute)styleAttributes[i];
- StyleProperties[attribute.CssPropertyName] = attribute;
- }
- }
-
- DependencyService.Initialize(assemblies);
- }
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal static class Registrar
+ {
+ static Registrar()
+ {
+ Registered = new Registrar<IRegisterable>();
+ }
+
+ internal static Dictionary<string, Type> Effects { get; } = new Dictionary<string, Type>();
+ internal static Dictionary<string, StyleSheets.StylePropertyAttribute> StyleProperties { get; } = new Dictionary<string, StyleSheets.StylePropertyAttribute>();
+
+ public static IEnumerable<Assembly> ExtraAssemblies { get; set; }
+
+ public static Registrar<IRegisterable> Registered { get; internal set; }
+
+ public static void RegisterAll(Type[] attrTypes)
+ {
+ Assembly[] assemblies = Device.GetAssemblies();
+ if (ExtraAssemblies != null)
+ assemblies = assemblies.Union(ExtraAssemblies).ToArray();
+
+ Assembly defaultRendererAssembly = Device.PlatformServices.GetType().GetTypeInfo().Assembly;
+ int indexOfExecuting = Array.IndexOf(assemblies, defaultRendererAssembly);
+
+ if (indexOfExecuting > 0)
+ {
+ assemblies[indexOfExecuting] = assemblies[0];
+ assemblies[0] = defaultRendererAssembly;
+ }
+
+ // Don't use LINQ for performance reasons
+ // Naive implementation can easily take over a second to run
+ foreach (Assembly assembly in assemblies)
+ {
+ foreach (Type attrType in attrTypes)
+ {
+ Attribute[] attributes;
+ try
+ {
+ attributes = assembly.GetCustomAttributes(attrType).ToArray();
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ // Sometimes the previewer doesn't actually have everything required for these loads to work
+ Console.WriteLine(nameof(Registrar), "Could not load assembly: {0} for Attibute {1} | Some renderers may not be loaded", assembly.FullName, attrType.FullName);
+ continue;
+ }
+ var length = attributes.Length;
+ for (var i = 0; i < length;i++)
+ {
+ var attribute = (HandlerAttribute)attributes[i];
+ if (attribute.ShouldRegister())
+ Registered.Register(attribute.HandlerType, attribute.TargetType);
+ }
+ }
+
+ string resolutionName = assembly.FullName;
+ var resolutionNameAttribute = (ResolutionGroupNameAttribute)assembly.GetCustomAttribute(typeof(ResolutionGroupNameAttribute));
+ if (resolutionNameAttribute != null)
+ resolutionName = resolutionNameAttribute.ShortName;
+
+ Attribute[] effectAttributes = assembly.GetCustomAttributes(typeof(ExportEffectAttribute)).ToArray();
+ var exportEffectsLength = effectAttributes.Length;
+ for (var i = 0; i < exportEffectsLength;i++)
+ {
+ var effect = (ExportEffectAttribute)effectAttributes[i];
+ Effects [resolutionName + "." + effect.Id] = effect.Type;
+ }
+
+ Attribute[] styleAttributes = assembly.GetCustomAttributes(typeof(StyleSheets.StylePropertyAttribute)).ToArray();
+ var stylePropertiesLength = styleAttributes.Length;
+ for (var i = 0; i < stylePropertiesLength; i++)
+ {
+ var attribute = (StyleSheets.StylePropertyAttribute)styleAttributes[i];
+ StyleProperties[attribute.CssPropertyName] = attribute;
+ }
+ }
+
+ DependencyService.Initialize(assemblies);
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- [AttributeUsage(AttributeTargets.Class)]
- internal sealed class RenderWithAttribute : Attribute
- {
- public RenderWithAttribute(Type type)
- {
- Type = type;
- }
+ [AttributeUsage(AttributeTargets.Class)]
+ internal sealed class RenderWithAttribute : Attribute
+ {
+ public RenderWithAttribute(Type type)
+ {
+ Type = type;
+ }
- public Type Type { get; }
- }
+ public Type Type { get; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [AttributeUsage(AttributeTargets.Assembly)]
- internal class ResolutionGroupNameAttribute : Attribute
- {
- public ResolutionGroupNameAttribute(string name)
- {
- ShortName = name;
- }
+ [AttributeUsage(AttributeTargets.Assembly)]
+ internal class ResolutionGroupNameAttribute : Attribute
+ {
+ public ResolutionGroupNameAttribute(string name)
+ {
+ ShortName = name;
+ }
- internal string ShortName { get; private set; }
- }
+ internal string ShortName { get; private set; }
+ }
}
\ No newline at end of file
+++ /dev/null
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Collections.Specialized;
-using System.ComponentModel;
-using System.Globalization;
-using System.Linq;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-
-using Tizen.NUI.Internals;
-using Tizen.NUI.Xaml;
-
-namespace Tizen.NUI.Binding
-{
- internal class ResourceDictionary : IResourceDictionary, IDictionary<string, object>
- {
- static ConditionalWeakTable<Type, ResourceDictionary> s_instances = new ConditionalWeakTable<Type, ResourceDictionary>();
- readonly Dictionary<string, object> _innerDictionary = new Dictionary<string, object>();
- ResourceDictionary _mergedInstance;
- Type _mergedWith;
- Uri _source;
-
- [TypeConverter(typeof(TypeTypeConverter))]
- [Obsolete("Use Source")]
- public Type MergedWith {
- get { return _mergedWith; }
- set {
- if (_mergedWith == value)
- return;
-
- if (_source != null)
- throw new ArgumentException("MergedWith can not be used with Source");
-
- if (!typeof(ResourceDictionary).GetTypeInfo().IsAssignableFrom(value.GetTypeInfo()))
- throw new ArgumentException("MergedWith should inherit from ResourceDictionary");
-
- _mergedWith = value;
- if (_mergedWith == null)
- return;
-
- _mergedInstance = s_instances.GetValue(_mergedWith, (key) => (ResourceDictionary)Activator.CreateInstance(key));
- OnValuesChanged(_mergedInstance.ToArray());
- }
- }
-
- [TypeConverter(typeof(RDSourceTypeConverter))]
- public Uri Source {
- get { return _source; }
- set {
- if (_source == value)
- return;
- throw new InvalidOperationException("Source can only be set from XAML."); //through the RDSourceTypeConverter
- }
- }
-
- //Used by the XamlC compiled converter
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SetAndLoadSource(Uri value, string resourcePath, Assembly assembly, System.Xml.IXmlLineInfo lineInfo)
- {
- _source = value;
- if (_mergedWith != null)
- throw new ArgumentException("Source can not be used with MergedWith");
-
- //this will return a type if the RD as an x:Class element, and codebehind
- var type = XamlResourceIdAttribute.GetTypeForPath(assembly, resourcePath);
- if (type != null)
- _mergedInstance = s_instances.GetValue(type, (key) => (ResourceDictionary)Activator.CreateInstance(key));
- else
- _mergedInstance = DependencyService.Get<IResourcesLoader>().CreateFromResource<ResourceDictionary>(resourcePath, assembly, lineInfo);
- OnValuesChanged(_mergedInstance.ToArray());
- }
-
- ICollection<ResourceDictionary> _mergedDictionaries;
- public ICollection<ResourceDictionary> MergedDictionaries {
- get {
- if (_mergedDictionaries == null) {
- var col = new ObservableCollection<ResourceDictionary>();
- col.CollectionChanged += MergedDictionaries_CollectionChanged;
- _mergedDictionaries = col;
- }
- return _mergedDictionaries;
- }
- }
-
- internal IList<StyleSheets.StyleSheet> StyleSheets { get; set; }
-
- void StyleSheetsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- switch (e.Action) {
- case NotifyCollectionChangedAction.Add:
- ValuesChanged?.Invoke(this, ResourcesChangedEventArgs.StyleSheets);
- break;
- }
- }
- IList<ResourceDictionary> _collectionTrack;
-
- void MergedDictionaries_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- // Move() isn't exposed by ICollection
- if (e.Action == NotifyCollectionChangedAction.Move)
- return;
-
- _collectionTrack = _collectionTrack ?? new List<ResourceDictionary>();
- // Collection has been cleared
- if (e.Action == NotifyCollectionChangedAction.Reset) {
- foreach (var dictionary in _collectionTrack)
- dictionary.ValuesChanged -= Item_ValuesChanged;
-
- _collectionTrack.Clear();
- return;
- }
-
- // New Items
- if (e.NewItems != null)
- {
- foreach (var item in e.NewItems)
- {
- var rd = (ResourceDictionary)item;
- _collectionTrack.Add(rd);
- rd.ValuesChanged += Item_ValuesChanged;
- OnValuesChanged(rd.ToArray());
- }
- }
-
- // Old Items
- if (e.OldItems != null)
- {
- foreach (var item in e.OldItems)
- {
- var rd = (ResourceDictionary)item;
- rd.ValuesChanged -= Item_ValuesChanged;
- _collectionTrack.Remove(rd);
- }
- }
- }
-
- void Item_ValuesChanged(object sender, ResourcesChangedEventArgs e)
- {
- OnValuesChanged(e.Values.ToArray());
- }
-
- void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)
- {
- ((ICollection<KeyValuePair<string, object>>)_innerDictionary).Add(item);
- OnValuesChanged(item);
- }
-
- public void Clear()
- {
- _innerDictionary.Clear();
- }
-
- bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item)
- {
- return ((ICollection<KeyValuePair<string, object>>)_innerDictionary).Contains(item)
- || (_mergedInstance != null && _mergedInstance.Contains(item));
- }
-
- void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
- {
- ((ICollection<KeyValuePair<string, object>>)_innerDictionary).CopyTo(array, arrayIndex);
- }
-
- public int Count
- {
- get { return _innerDictionary.Count; }
- }
-
- bool ICollection<KeyValuePair<string, object>>.IsReadOnly
- {
- get { return ((ICollection<KeyValuePair<string, object>>)_innerDictionary).IsReadOnly; }
- }
-
- bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)
- {
- return ((ICollection<KeyValuePair<string, object>>)_innerDictionary).Remove(item);
- }
-
- public void Add(string key, object value)
- {
- if (ContainsKey(key))
- throw new ArgumentException($"A resource with the key '{key}' is already present in the ResourceDictionary.");
- _innerDictionary.Add(key, value);
- OnValueChanged(key, value);
- }
-
- public bool ContainsKey(string key)
- {
- return _innerDictionary.ContainsKey(key);
- }
-
- [IndexerName("Item")]
- public object this[string index]
- {
- get
- {
- if (_innerDictionary.ContainsKey(index))
- return _innerDictionary[index];
- if (_mergedInstance != null && _mergedInstance.ContainsKey(index))
- return _mergedInstance[index];
- if (MergedDictionaries != null)
- foreach (var dict in MergedDictionaries.Reverse())
- if (dict.ContainsKey(index))
- return dict[index];
- throw new KeyNotFoundException($"The resource '{index}' is not present in the dictionary.");
- }
- set
- {
- _innerDictionary[index] = value;
- OnValueChanged(index, value);
- }
- }
-
- public ICollection<string> Keys
- {
- get { return _innerDictionary.Keys; }
- }
-
- public bool Remove(string key)
- {
- return _innerDictionary.Remove(key);
- }
-
- public ICollection<object> Values
- {
- get { return _innerDictionary.Values; }
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
- {
- return _innerDictionary.GetEnumerator();
- }
-
- internal IEnumerable<KeyValuePair<string, object>> MergedResources {
- get {
- if (MergedDictionaries != null)
- foreach (var r in MergedDictionaries.Reverse().SelectMany(x => x.MergedResources))
- yield return r;
- if (_mergedInstance != null)
- foreach (var r in _mergedInstance.MergedResources)
- yield return r;
- foreach (var r in _innerDictionary)
- yield return r;
- }
- }
-
- public bool TryGetValue(string key, out object value)
- {
- return _innerDictionary.TryGetValue(key, out value)
- || (_mergedInstance != null && _mergedInstance.TryGetValue(key, out value))
- || (MergedDictionaries != null && TryGetMergedDictionaryValue(key, out value));
- }
-
- bool TryGetMergedDictionaryValue(string key, out object value)
- {
- foreach (var dictionary in MergedDictionaries.Reverse())
- if (dictionary.TryGetValue(key, out value))
- return true;
-
- value = null;
- return false;
- }
-
- event EventHandler<ResourcesChangedEventArgs> IResourceDictionary.ValuesChanged
- {
- add { ValuesChanged += value; }
- remove { ValuesChanged -= value; }
- }
-
- public void Add(Style style)
- {
- if (string.IsNullOrEmpty(style.Class))
- Add(style.TargetType.FullName, style);
- else
- {
- IList<Style> classes;
- object outclasses;
- if (!TryGetValue(Style.StyleClassPrefix + style.Class, out outclasses) || (classes = outclasses as IList<Style>) == null)
- classes = new List<Style>();
- classes.Add(style);
- this[Style.StyleClassPrefix + style.Class] = classes;
- }
- }
-
- public void Add(ResourceDictionary mergedResourceDictionary)
- {
- MergedDictionaries.Add(mergedResourceDictionary);
- }
-
- public void Add(StyleSheets.StyleSheet styleSheet)
- {
- StyleSheets = StyleSheets ?? new List<StyleSheets.StyleSheet>(2);
- StyleSheets.Add(styleSheet);
- ValuesChanged?.Invoke(this, ResourcesChangedEventArgs.StyleSheets);
- }
-
- void OnValueChanged(string key, object value)
- {
- OnValuesChanged(new KeyValuePair<string, object>(key, value));
- }
-
- void OnValuesChanged(params KeyValuePair<string, object>[] values)
- {
- if (values == null || values.Length == 0)
- return;
- ValuesChanged?.Invoke(this, new ResourcesChangedEventArgs(values));
- }
-
- event EventHandler<ResourcesChangedEventArgs> ValuesChanged;
-
- // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.RDSourceTypeConverter")]
- public class RDSourceTypeConverter : TypeConverter, IExtendedTypeConverter
- {
- object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider)
- {
- if (serviceProvider == null)
- throw new ArgumentNullException(nameof(serviceProvider));
-
- var targetRD = (serviceProvider.GetService(typeof(Xaml.IProvideValueTarget)) as Xaml.IProvideValueTarget)?.TargetObject as ResourceDictionary;
- if (targetRD == null)
- return null;
-
- var rootObjectType = (serviceProvider.GetService(typeof(Xaml.IRootObjectProvider)) as Xaml.IRootObjectProvider)?.RootObject.GetType();
- if (rootObjectType == null)
- return null;
-
- var lineInfo = (serviceProvider.GetService(typeof(Xaml.IXmlLineInfoProvider)) as Xaml.IXmlLineInfoProvider)?.XmlLineInfo;
- var rootTargetPath = XamlResourceIdAttribute.GetPathForType(rootObjectType);
- var uri = new Uri(value, UriKind.Relative); //we don't want file:// uris, even if they start with '/'
- var resourcePath = GetResourcePath(uri, rootTargetPath);
-
- targetRD.SetAndLoadSource(uri, resourcePath, rootObjectType.GetTypeInfo().Assembly, lineInfo);
- return uri;
- }
-
- internal static string GetResourcePath(Uri uri, string rootTargetPath)
- {
- //need a fake scheme so it's not seen as file:// uri, and the forward slashes are valid on all plats
- var resourceUri = uri.OriginalString.StartsWith("/", StringComparison.Ordinal)
- ? new Uri($"pack://{uri.OriginalString}", UriKind.Absolute)
- : new Uri($"pack:///{rootTargetPath}/../{uri.OriginalString}", UriKind.Absolute);
-
- //drop the leading '/'
- return resourceUri.AbsolutePath.Substring(1);
- }
-
- object IExtendedTypeConverter.ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider)
- {
- throw new NotImplementedException();
- }
-
- public override object ConvertFromInvariantString(string value)
- {
- throw new NotImplementedException();
- }
- }
- }
-}
namespace Tizen.NUI.Binding
{
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal class ResourcesChangedEventArgs : EventArgs
- {
- public static readonly ResourcesChangedEventArgs StyleSheets = new ResourcesChangedEventArgs(null);
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal class ResourcesChangedEventArgs : EventArgs
+ {
+ public static readonly ResourcesChangedEventArgs StyleSheets = new ResourcesChangedEventArgs(null);
- public ResourcesChangedEventArgs(IEnumerable<KeyValuePair<string, object>> values)
- {
- Values = values;
- }
+ public ResourcesChangedEventArgs(IEnumerable<KeyValuePair<string, object>> values)
+ {
+ Values = values;
+ }
- public IEnumerable<KeyValuePair<string, object>> Values { get; private set; }
- }
+ public IEnumerable<KeyValuePair<string, object>> Values { get; private set; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- static class ResourcesExtensions
- {
- public static IEnumerable<KeyValuePair<string, object>> GetMergedResources(this IElement element)
- {
- Dictionary<string, object> resources = null;
- while (element != null)
- {
- var ve = element as IResourcesProvider;
- if (ve != null && ve.IsResourcesCreated)
- {
- resources = resources ?? new Dictionary<string, object>();
- foreach (KeyValuePair<string, object> res in ve.Resources.MergedResources)
- if (!resources.ContainsKey(res.Key))
- resources.Add(res.Key, res.Value);
- else if (res.Key.StartsWith(Style.StyleClassPrefix, StringComparison.Ordinal))
- {
- var mergedClassStyles = new List<Style>(resources[res.Key] as List<Style>);
- mergedClassStyles.AddRange(res.Value as List<Style>);
- resources[res.Key] = mergedClassStyles;
- }
- }
- var app = element as Application;
- if (app != null && app.SystemResources != null)
- {
- resources = resources ?? new Dictionary<string, object>(8);
- foreach (KeyValuePair<string, object> res in app.SystemResources)
- if (!resources.ContainsKey(res.Key))
- resources.Add(res.Key, res.Value);
- else if (res.Key.StartsWith(Style.StyleClassPrefix, StringComparison.Ordinal))
- {
- var mergedClassStyles = new List<Style>(resources[res.Key] as List<Style>);
- mergedClassStyles.AddRange(res.Value as List<Style>);
- resources[res.Key] = mergedClassStyles;
- }
- }
- element = element.Parent;
- }
- return resources;
- }
+ internal static class ResourcesExtensions
+ {
+ public static IEnumerable<KeyValuePair<string, object>> GetMergedResources(this IElement element)
+ {
+ Dictionary<string, object> resources = null;
+ while (element != null)
+ {
+ var ve = element as IResourcesProvider;
+ if (ve != null && ve.IsResourcesCreated)
+ {
+ resources = resources ?? new Dictionary<string, object>();
+ foreach (KeyValuePair<string, object> res in ve.Resources.MergedResources)
+ if (!resources.ContainsKey(res.Key))
+ resources.Add(res.Key, res.Value);
+ else if (res.Key.StartsWith(Style.StyleClassPrefix, StringComparison.Ordinal))
+ {
+ var mergedClassStyles = new List<Style>(resources[res.Key] as List<Style>);
+ mergedClassStyles.AddRange(res.Value as List<Style>);
+ resources[res.Key] = mergedClassStyles;
+ }
+ }
+ var app = element as Application;
+ if (app != null && app.SystemResources != null)
+ {
+ resources = resources ?? new Dictionary<string, object>(8);
+ foreach (KeyValuePair<string, object> res in app.SystemResources)
+ if (!resources.ContainsKey(res.Key))
+ resources.Add(res.Key, res.Value);
+ else if (res.Key.StartsWith(Style.StyleClassPrefix, StringComparison.Ordinal))
+ {
+ var mergedClassStyles = new List<Style>(resources[res.Key] as List<Style>);
+ mergedClassStyles.AddRange(res.Value as List<Style>);
+ resources[res.Key] = mergedClassStyles;
+ }
+ }
+ element = element.Parent;
+ }
+ return resources;
+ }
- public static bool TryGetResource(this IElement element, string key, out object value)
- {
- while (element != null)
- {
- var ve = element as IResourcesProvider;
- if (ve != null && ve.IsResourcesCreated && ve.Resources.TryGetValue(key, out value))
- return true;
- var app = element as Application;
- if (app != null && app.SystemResources != null && app.SystemResources.TryGetValue(key, out value))
- return true;
- element = element.Parent;
- }
+ public static bool TryGetResource(this IElement element, string key, out object value)
+ {
+ while (element != null)
+ {
+ var ve = element as IResourcesProvider;
+ if (ve != null && ve.IsResourcesCreated && ve.Resources.TryGetValue(key, out value))
+ return true;
+ var app = element as Application;
+ if (app != null && app.SystemResources != null && app.SystemResources.TryGetValue(key, out value))
+ return true;
+ element = element.Parent;
+ }
- //Fallback for the XF previewer
- if (Application.Current != null && ((IResourcesProvider)Application.Current).IsResourcesCreated && Application.Current.Resources.TryGetValue(key, out value))
- return true;
+ //Fallback for the XF previewer
+ if (Application.Current != null && ((IResourcesProvider)Application.Current).IsResourcesCreated && Application.Current.Resources.TryGetValue(key, out value))
+ return true;
- value = null;
- return false;
- }
- }
+ value = null;
+ return false;
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal class RoutingEffect : Effect
- {
- internal readonly Effect Inner;
-
- protected RoutingEffect(string effectId)
- {
- Inner = Resolve(effectId);
- }
-
- protected override void OnAttached()
- {
- }
-
- protected override void OnDetached()
- {
- }
-
- internal override void ClearEffect()
- {
- Inner?.ClearEffect();
- }
-
- internal override void SendAttached()
- {
- Inner?.SendAttached();
- }
-
- internal override void SendDetached()
- {
- Inner?.SendDetached();
- }
-
- internal override void SendOnElementPropertyChanged(PropertyChangedEventArgs args)
- {
- Inner?.SendOnElementPropertyChanged(args);
- }
- }
+ internal class RoutingEffect : Effect
+ {
+ internal readonly Effect Inner;
+
+ protected RoutingEffect(string effectId)
+ {
+ Inner = Resolve(effectId);
+ }
+
+ protected override void OnAttached()
+ {
+ }
+
+ protected override void OnDetached()
+ {
+ }
+
+ internal override void ClearEffect()
+ {
+ Inner?.ClearEffect();
+ }
+
+ internal override void SendAttached()
+ {
+ Inner?.SendAttached();
+ }
+
+ internal override void SendDetached()
+ {
+ Inner?.SendDetached();
+ }
+
+ internal override void SendOnElementPropertyChanged(PropertyChangedEventArgs args)
+ {
+ Inner?.SendOnElementPropertyChanged(args);
+ }
+ }
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Xml;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI.Xaml;
namespace Tizen.NUI.Binding
{
- [ContentProperty("Value")]
- // [ProvideCompiled("Tizen.NUI.Core.XamlC.SetterValueProvider")]
- internal sealed class Setter : IValueProvider
- {
- readonly ConditionalWeakTable<BindableObject, object> _originalValues = new ConditionalWeakTable<BindableObject, object>();
+ [ContentProperty("Value")]
+ // [ProvideCompiled("Tizen.NUI.Core.XamlC.SetterValueProvider")]
+ internal sealed class Setter : IValueProvider
+ {
+ readonly ConditionalWeakTable<BindableObject, object> _originalValues = new ConditionalWeakTable<BindableObject, object>();
- public BindableProperty Property { get; set; }
+ public BindableProperty Property { get; set; }
- public object Value { get; set; }
+ public object Value { get; set; }
- object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
- {
- if (Property == null)
- {
- var lineInfoProvider = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider;
- IXmlLineInfo lineInfo = lineInfoProvider != null ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
- throw new XamlParseException("Property not set", lineInfo);
- }
- var valueconverter = serviceProvider.GetService(typeof(IValueConverterProvider)) as IValueConverterProvider;
+ object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
+ {
+ if (Property == null)
+ {
+ var lineInfoProvider = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider;
+ IXmlLineInfo lineInfo = lineInfoProvider != null ? lineInfoProvider.XmlLineInfo : new XmlLineInfo();
+ throw new XamlParseException("Property not set", lineInfo);
+ }
+ var valueconverter = serviceProvider.GetService(typeof(IValueConverterProvider)) as IValueConverterProvider;
- Func<MemberInfo> minforetriever =
- () =>
- (MemberInfo)Property.DeclaringType.GetRuntimeProperty(Property.PropertyName) ?? (MemberInfo)Property.DeclaringType.GetRuntimeMethod("Get" + Property.PropertyName, new[] { typeof(BindableObject) });
+ Func<MemberInfo> minforetriever =
+ () =>
+ (MemberInfo)Property.DeclaringType.GetRuntimeProperty(Property.PropertyName) ?? (MemberInfo)Property.DeclaringType.GetRuntimeMethod("Get" + Property.PropertyName, new[] { typeof(BindableObject) });
- object value = valueconverter.Convert(Value, Property.ReturnType, minforetriever, serviceProvider);
- Value = value;
- return this;
- }
+ object value = valueconverter.Convert(Value, Property.ReturnType, minforetriever, serviceProvider);
+ Value = value;
+ return this;
+ }
- internal void Apply(BindableObject target, bool fromStyle = false)
- {
- if (target == null)
- throw new ArgumentNullException("target");
- if (Property == null)
- return;
+ internal void Apply(BindableObject target, bool fromStyle = false)
+ {
+ if (target == null)
+ throw new ArgumentNullException("target");
+ if (Property == null)
+ return;
- object originalValue = target.GetValue(Property);
- if (!Equals(originalValue, Property.DefaultValue))
- {
- _originalValues.Remove(target);
- _originalValues.Add(target, originalValue);
- }
+ object originalValue = target.GetValue(Property);
+ if (!Equals(originalValue, Property.DefaultValue))
+ {
+ _originalValues.Remove(target);
+ _originalValues.Add(target, originalValue);
+ }
- var dynamicResource = Value as DynamicResource;
- var binding = Value as BindingBase;
- if (binding != null)
- target.SetBinding(Property, binding.Clone(), fromStyle);
- else if (dynamicResource != null)
- target.SetDynamicResource(Property, dynamicResource.Key, fromStyle);
- else
- {
- if (Value is IList<VisualStateGroup> visualStateGroupCollection)
- target.SetValue(Property, visualStateGroupCollection.Clone(), fromStyle);
- else
- target.SetValue(Property, Value, fromStyle);
- }
- }
+ var dynamicResource = Value as DynamicResource;
+ var binding = Value as BindingBase;
+ if (binding != null)
+ target.SetBinding(Property, binding.Clone(), fromStyle);
+ else if (dynamicResource != null)
+ target.SetDynamicResource(Property, dynamicResource.Key, fromStyle);
+ else
+ {
+ if (Value is IList<VisualStateGroup> visualStateGroupCollection)
+ target.SetValue(Property, visualStateGroupCollection.Clone(), fromStyle);
+ else
+ target.SetValue(Property, Value, fromStyle);
+ }
+ }
- internal void UnApply(BindableObject target, bool fromStyle = false)
- {
- if (target == null)
- throw new ArgumentNullException(nameof(target));
- if (Property == null)
- return;
+ internal void UnApply(BindableObject target, bool fromStyle = false)
+ {
+ if (target == null)
+ throw new ArgumentNullException(nameof(target));
+ if (Property == null)
+ return;
- object actual = target.GetValue(Property);
- if (!Equals(actual, Value) && !(Value is Tizen.NUI.Binding.Binding) && !(Value is DynamicResource))
- {
- //Do not reset default value if the value has been changed
- _originalValues.Remove(target);
- return;
- }
+ object actual = target.GetValue(Property);
+ if (!Equals(actual, Value) && !(Value is Tizen.NUI.Binding.Binding) && !(Value is DynamicResource))
+ {
+ //Do not reset default value if the value has been changed
+ _originalValues.Remove(target);
+ return;
+ }
- object defaultValue;
- if (_originalValues.TryGetValue(target, out defaultValue))
- {
- //reset default value, unapply bindings and dynamicResource
- target.SetValue(Property, defaultValue, fromStyle);
- _originalValues.Remove(target);
- }
- else
- target.ClearValue(Property);
- }
- }
+ object defaultValue;
+ if (_originalValues.TryGetValue(target, out defaultValue))
+ {
+ //reset default value, unapply bindings and dynamicResource
+ target.SetValue(Property, defaultValue, fromStyle);
+ _originalValues.Remove(target);
+ }
+ else
+ target.ClearValue(Property);
+ }
+ }
}
/// <summary>
/// Struct that defines minimum and maximum Sizes.
/// </summary>
- [DebuggerDisplay("Request={Request.Width}x{Request.Height}, Minimum={Minimum.Width}x{Minimum.Height}")]
+ [DebuggerDisplay("Request={Request.Width}x{Request.Height}, Minimum={Minimum.Width}x{Minimum.Height}")]
[EditorBrowsable(EditorBrowsableState.Never)]
- public struct SizeRequest
- {
+ internal struct SizeRequest
+ {
/// <summary>
/// The requested size.
/// </summary>
- public Size Request { get; set; }
+ public Size Request { get; set; }
/// <summary>
/// The minimum acceptable size.
/// </summary>
- public Size Minimum { get; set; }
+ public Size Minimum { get; set; }
/// <summary>
/// Creates a new SizeRequest object that requests at least the size minimum, but preferably the size request.
/// </summary>
/// <param name="request">The size of the request.</param>
/// <param name="minimum">The minimum size for the request.</param>
- public SizeRequest(Size request, Size minimum)
- {
- Request = request;
- Minimum = minimum;
- }
+ public SizeRequest(Size request, Size minimum)
+ {
+ Request = request;
+ Minimum = minimum;
+ }
/// <summary>
/// Creates a new SizeRequest with the specified request size.
/// </summary>
/// <param name="request">The size of the request.</param>
- public SizeRequest(Size request)
- {
- Request = request;
- Minimum = request;
- }
+ public SizeRequest(Size request)
+ {
+ Request = request;
+ Minimum = request;
+ }
/// <summary>
/// Returns a string representation of the size request.
/// </summary>
/// <returns>a string representation of the size request.</returns>
- public override string ToString()
- {
- return string.Format("{{Request={0} Minimum={1}}}", Request, Minimum);
- }
- }
+ public override string ToString()
+ {
+ return string.Format("{{Request={0} Minimum={1}}}", Request, Minimum);
+ }
+ }
}
using System;
using System.Linq;
using System.Reflection;
+using System.Globalization;
using Tizen.NUI;
string[] parts = value.Split(',');
if (parts.Length == 3)
{
- return new Size(float.Parse(parts[0].Trim()), float.Parse(parts[1].Trim()), float.Parse(parts[2].Trim()));
+ return new Size(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture));
}
}
string[] parts = value.Split(',');
if (parts.Length == 2)
{
- return new Size2D(int.Parse(parts[0].Trim()), int.Parse(parts[1].Trim()));
+ return new Size2D(Int32.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
+ Int32.Parse(parts[1].Trim(), CultureInfo.InvariantCulture));
}
}
namespace Tizen.NUI.Binding
{
- [ContentProperty("Setters")]
- internal sealed class Style : IStyle
- {
- internal const string StyleClassPrefix = "Xamarin.Forms.StyleClass.";
-
- readonly BindableProperty _basedOnResourceProperty = BindableProperty.CreateAttached("BasedOnResource", typeof(Style), typeof(Style), default(Style),
- propertyChanged: OnBasedOnResourceChanged);
-
- readonly List<WeakReference<BindableObject>> _targets = new List<WeakReference<BindableObject>>(4);
-
- Style _basedOnStyle;
-
- string _baseResourceKey;
-
- IList<Behavior> _behaviors;
-
- IList<TriggerBase> _triggers;
-
- public Style([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType)
- {
- if (targetType == null)
- throw new ArgumentNullException("targetType");
-
- TargetType = targetType;
- Setters = new List<Setter>();
- }
-
- public bool ApplyToDerivedTypes { get; set; }
-
- public Style BasedOn
- {
- get { return _basedOnStyle; }
- set
- {
- if (_basedOnStyle == value)
- return;
- if (!ValidateBasedOn(value))
- throw new ArgumentException("BasedOn.TargetType is not compatible with TargetType");
- Style oldValue = _basedOnStyle;
- _basedOnStyle = value;
- BasedOnChanged(oldValue, value);
- if (value != null)
- BaseResourceKey = null;
- }
- }
-
- public string BaseResourceKey
- {
- get { return _baseResourceKey; }
- set
- {
- if (_baseResourceKey == value)
- return;
- _baseResourceKey = value;
- //update all DynamicResources
- foreach (WeakReference<BindableObject> bindableWr in _targets)
- {
- BindableObject target;
- if (!bindableWr.TryGetTarget(out target))
- continue;
- target.RemoveDynamicResource(_basedOnResourceProperty);
- if (value != null)
- target.SetDynamicResource(_basedOnResourceProperty, value);
- }
- if (value != null)
- BasedOn = null;
- }
- }
-
- public IList<Behavior> Behaviors
- {
- get { return _behaviors ?? (_behaviors = new AttachedCollection<Behavior>()); }
- }
-
- public bool CanCascade { get; set; }
-
- public string Class { get; set; }
-
- public IList<Setter> Setters { get; }
-
- public IList<TriggerBase> Triggers
- {
- get { return _triggers ?? (_triggers = new AttachedCollection<TriggerBase>()); }
- }
-
- void IStyle.Apply(BindableObject bindable)
- {
- _targets.Add(new WeakReference<BindableObject>(bindable));
- if (BaseResourceKey != null)
- bindable.SetDynamicResource(_basedOnResourceProperty, BaseResourceKey);
- ApplyCore(bindable, BasedOn ?? GetBasedOnResource(bindable));
- }
-
- public Type TargetType { get; }
-
- void IStyle.UnApply(BindableObject bindable)
- {
- UnApplyCore(bindable, BasedOn ?? GetBasedOnResource(bindable));
- bindable.RemoveDynamicResource(_basedOnResourceProperty);
- _targets.RemoveAll(wr =>
- {
- BindableObject target;
- return wr.TryGetTarget(out target) && target == bindable;
- });
- }
-
- internal bool CanBeAppliedTo(Type targetType)
- {
- if (TargetType == targetType)
- return true;
- if (!ApplyToDerivedTypes)
- return false;
- do
- {
- targetType = targetType.GetTypeInfo().BaseType;
- if (TargetType == targetType)
- return true;
- } while (targetType != typeof(Element));
- return false;
- }
-
- void ApplyCore(BindableObject bindable, Style basedOn)
- {
- if (basedOn != null)
- ((IStyle)basedOn).Apply(bindable);
-
- foreach (Setter setter in Setters)
- setter.Apply(bindable, true);
- ((AttachedCollection<Behavior>)Behaviors).AttachTo(bindable);
- ((AttachedCollection<TriggerBase>)Triggers).AttachTo(bindable);
- }
-
- void BasedOnChanged(Style oldValue, Style newValue)
- {
- foreach (WeakReference<BindableObject> bindableRef in _targets)
- {
- BindableObject bindable;
- if (!bindableRef.TryGetTarget(out bindable))
- continue;
-
- UnApplyCore(bindable, oldValue);
- ApplyCore(bindable, newValue);
- }
- }
-
- Style GetBasedOnResource(BindableObject bindable)
- {
- return (Style)bindable.GetValue(_basedOnResourceProperty);
- }
-
- static void OnBasedOnResourceChanged(BindableObject bindable, object oldValue, object newValue)
- {
- // Style style = (bindable as /*VisualElement*/BaseHandle).Style;
- // if (style == null)
- // return;
- // style.UnApplyCore(bindable, (Style)oldValue);
- // style.ApplyCore(bindable, (Style)newValue);
- }
-
- void UnApplyCore(BindableObject bindable, Style basedOn)
- {
- ((AttachedCollection<TriggerBase>)Triggers).DetachFrom(bindable);
- ((AttachedCollection<Behavior>)Behaviors).DetachFrom(bindable);
- foreach (Setter setter in Setters)
- setter.UnApply(bindable, true);
-
- if (basedOn != null)
- ((IStyle)basedOn).UnApply(bindable);
- }
-
- bool ValidateBasedOn(Style value)
- {
- if (value == null)
- return true;
- return value.TargetType.IsAssignableFrom(TargetType);
- }
- }
+ [ContentProperty("Setters")]
+ internal sealed class Style : IStyle
+ {
+ internal const string StyleClassPrefix = "Xamarin.Forms.StyleClass.";
+
+ readonly BindableProperty _basedOnResourceProperty = BindableProperty.CreateAttached("BasedOnResource", typeof(Style), typeof(Style), default(Style),
+ propertyChanged: OnBasedOnResourceChanged);
+
+ readonly List<WeakReference<BindableObject>> _targets = new List<WeakReference<BindableObject>>(4);
+
+ Style _basedOnStyle;
+
+ string _baseResourceKey;
+
+ IList<Behavior> _behaviors;
+
+ IList<TriggerBase> _triggers;
+
+ public Style([TypeConverter(typeof(TypeTypeConverter))] [Parameter("TargetType")] Type targetType)
+ {
+ if (targetType == null)
+ throw new ArgumentNullException("targetType");
+
+ TargetType = targetType;
+ Setters = new List<Setter>();
+ }
+
+ public bool ApplyToDerivedTypes { get; set; }
+
+ public Style BasedOn
+ {
+ get { return _basedOnStyle; }
+ set
+ {
+ if (_basedOnStyle == value)
+ return;
+ if (!ValidateBasedOn(value))
+ throw new ArgumentException("BasedOn.TargetType is not compatible with TargetType");
+ Style oldValue = _basedOnStyle;
+ _basedOnStyle = value;
+ BasedOnChanged(oldValue, value);
+ if (value != null)
+ BaseResourceKey = null;
+ }
+ }
+
+ public string BaseResourceKey
+ {
+ get { return _baseResourceKey; }
+ set
+ {
+ if (_baseResourceKey == value)
+ return;
+ _baseResourceKey = value;
+ //update all DynamicResources
+ foreach (WeakReference<BindableObject> bindableWr in _targets)
+ {
+ BindableObject target;
+ if (!bindableWr.TryGetTarget(out target))
+ continue;
+ target.RemoveDynamicResource(_basedOnResourceProperty);
+ if (value != null)
+ target.SetDynamicResource(_basedOnResourceProperty, value);
+ }
+ if (value != null)
+ BasedOn = null;
+ }
+ }
+
+ public IList<Behavior> Behaviors
+ {
+ get { return _behaviors ?? (_behaviors = new AttachedCollection<Behavior>()); }
+ }
+
+ public bool CanCascade { get; set; }
+
+ public string Class { get; set; }
+
+ public IList<Setter> Setters { get; }
+
+ public IList<TriggerBase> Triggers
+ {
+ get { return _triggers ?? (_triggers = new AttachedCollection<TriggerBase>()); }
+ }
+
+ void IStyle.Apply(BindableObject bindable)
+ {
+ _targets.Add(new WeakReference<BindableObject>(bindable));
+ if (BaseResourceKey != null)
+ bindable.SetDynamicResource(_basedOnResourceProperty, BaseResourceKey);
+ ApplyCore(bindable, BasedOn ?? GetBasedOnResource(bindable));
+ }
+
+ public Type TargetType { get; }
+
+ void IStyle.UnApply(BindableObject bindable)
+ {
+ UnApplyCore(bindable, BasedOn ?? GetBasedOnResource(bindable));
+ bindable.RemoveDynamicResource(_basedOnResourceProperty);
+ _targets.RemoveAll(wr =>
+ {
+ BindableObject target;
+ return wr.TryGetTarget(out target) && target == bindable;
+ });
+ }
+
+ internal bool CanBeAppliedTo(Type targetType)
+ {
+ if (TargetType == targetType)
+ return true;
+ if (!ApplyToDerivedTypes)
+ return false;
+ do
+ {
+ targetType = targetType.GetTypeInfo().BaseType;
+ if (TargetType == targetType)
+ return true;
+ } while (targetType != typeof(Element));
+ return false;
+ }
+
+ void ApplyCore(BindableObject bindable, Style basedOn)
+ {
+ if (basedOn != null)
+ ((IStyle)basedOn).Apply(bindable);
+
+ foreach (Setter setter in Setters)
+ setter.Apply(bindable, true);
+ ((AttachedCollection<Behavior>)Behaviors).AttachTo(bindable);
+ ((AttachedCollection<TriggerBase>)Triggers).AttachTo(bindable);
+ }
+
+ void BasedOnChanged(Style oldValue, Style newValue)
+ {
+ foreach (WeakReference<BindableObject> bindableRef in _targets)
+ {
+ BindableObject bindable;
+ if (!bindableRef.TryGetTarget(out bindable))
+ continue;
+
+ UnApplyCore(bindable, oldValue);
+ ApplyCore(bindable, newValue);
+ }
+ }
+
+ Style GetBasedOnResource(BindableObject bindable)
+ {
+ return (Style)bindable.GetValue(_basedOnResourceProperty);
+ }
+
+ static void OnBasedOnResourceChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ // Style style = (bindable as /*VisualElement*/BaseHandle).Style;
+ // if (style == null)
+ // return;
+ // style.UnApplyCore(bindable, (Style)oldValue);
+ // style.ApplyCore(bindable, (Style)newValue);
+ }
+
+ void UnApplyCore(BindableObject bindable, Style basedOn)
+ {
+ ((AttachedCollection<TriggerBase>)Triggers).DetachFrom(bindable);
+ ((AttachedCollection<Behavior>)Behaviors).DetachFrom(bindable);
+ foreach (Setter setter in Setters)
+ setter.UnApply(bindable, true);
+
+ if (basedOn != null)
+ ((IStyle)basedOn).UnApply(bindable);
+ }
+
+ bool ValidateBasedOn(Style value)
+ {
+ if (value == null)
+ return true;
+ return value.TargetType.IsAssignableFrom(TargetType);
+ }
+ }
}
namespace Tizen.NUI.StyleSheets
{
- static class CharExtensions
- {
- //w [ \t\r\n\f]*
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool IsW(this char c)
- {
- return c == ' '
- || c == '\t'
- || c == '\r'
- || c == '\n'
- || c == '\f';
- }
+ internal static class CharExtensions
+ {
+ //w [ \t\r\n\f]*
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsW(this char c)
+ {
+ return c == ' '
+ || c == '\t'
+ || c == '\r'
+ || c == '\n'
+ || c == '\f';
+ }
- //nmstart [_a-z]|{nonascii}|{escape}
- //escape {unicode}|\\[^\n\r\f0-9a-f]
- //nonascii [^\0-\237]
- // TODO support escape and nonascii
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool IsNmStart(this char c)
- {
- return c == '_' || char.IsLetter(c);
- }
+ //nmstart [_a-z]|{nonascii}|{escape}
+ //escape {unicode}|\\[^\n\r\f0-9a-f]
+ //nonascii [^\0-\237]
+ // TODO support escape and nonascii
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsNmStart(this char c)
+ {
+ return c == '_' || char.IsLetter(c);
+ }
- //nmchar [_a-z0-9-]|{nonascii}|{escape}
- //unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
- //escape {unicode}|\\[^\n\r\f0-9a-f]
- //nonascii [^\0-\237]
- //TODO support escape, nonascii and unicode
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool IsNmChar(this char c)
- {
- return c == '_'
- || c == '-'
- || char.IsLetterOrDigit(c);
- }
- }
+ //nmchar [_a-z0-9-]|{nonascii}|{escape}
+ //unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
+ //escape {unicode}|\\[^\n\r\f0-9a-f]
+ //nonascii [^\0-\237]
+ //TODO support escape, nonascii and unicode
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool IsNmChar(this char c)
+ {
+ return c == '_'
+ || c == '-'
+ || char.IsLetterOrDigit(c);
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.StyleSheets
{
- sealed class CssReader : TextReader
- {
- readonly TextReader _reader;
+ internal sealed class CssReader : TextReader
+ {
+ readonly TextReader _reader;
- public CssReader(TextReader reader)
- {
- if (reader == null)
- throw new ArgumentNullException(nameof(reader));
+ public CssReader(TextReader reader)
+ {
+ if (reader == null)
+ throw new ArgumentNullException(nameof(reader));
- _reader = reader;
- }
+ _reader = reader;
+ }
- readonly Queue<char> _cache = new Queue<char>();
+ readonly Queue<char> _cache = new Queue<char>();
- //skip comments
- //TODO unescape escaped sequences
- public override int Peek()
- {
- if (_cache.Count > 0)
- return _cache.Peek();
+ //skip comments
+ //TODO unescape escaped sequences
+ public override int Peek()
+ {
+ if (_cache.Count > 0)
+ return _cache.Peek();
- int p = _reader.Peek();
- if (p <= 0)
- return p;
- if (unchecked((char)p) != '/')
- return p;
+ int p = _reader.Peek();
+ if (p <= 0)
+ return p;
+ if (unchecked((char)p) != '/')
+ return p;
- _cache.Enqueue(unchecked((char)_reader.Read()));
- p = _reader.Peek();
- if (p <= 0)
- return _cache.Peek();
- if (unchecked((char)p) != '*')
- return _cache.Peek();
+ _cache.Enqueue(unchecked((char)_reader.Read()));
+ p = _reader.Peek();
+ if (p <= 0)
+ return _cache.Peek();
+ if (unchecked((char)p) != '*')
+ return _cache.Peek();
- _cache.Clear();
- _reader.Read(); //consume the '*'
+ _cache.Clear();
+ _reader.Read(); //consume the '*'
- bool hasStar = false;
- while (true) {
- var next = _reader.Read();
- if (next <= 0)
- return next;
- if (unchecked((char)next) == '*')
- hasStar = true;
- else if (hasStar && unchecked((char)next) == '/')
- return Peek(); //recursively call self for comments following comments
- else
- hasStar = false;
- }
- }
+ bool hasStar = false;
+ while (true) {
+ var next = _reader.Read();
+ if (next <= 0)
+ return next;
+ if (unchecked((char)next) == '*')
+ hasStar = true;
+ else if (hasStar && unchecked((char)next) == '/')
+ return Peek(); //recursively call self for comments following comments
+ else
+ hasStar = false;
+ }
+ }
- //skip comments
- //TODO unescape escaped sequences
- public override int Read()
- {
- if (_cache.Count > 0)
- return _cache.Dequeue();
+ //skip comments
+ //TODO unescape escaped sequences
+ public override int Read()
+ {
+ if (_cache.Count > 0)
+ return _cache.Dequeue();
- int p = _reader.Read();
- if (p <= 0)
- return p;
- var c = unchecked((char)p);
- if (c != '/')
- return p;
+ int p = _reader.Read();
+ if (p <= 0)
+ return p;
+ var c = unchecked((char)p);
+ if (c != '/')
+ return p;
- _cache.Enqueue(c);
- p = _reader.Read();
- if (p <= 0)
- return _cache.Dequeue();
- c = unchecked((char)p);
- if (c != '*')
- return _cache.Dequeue();
+ _cache.Enqueue(c);
+ p = _reader.Read();
+ if (p <= 0)
+ return _cache.Dequeue();
+ c = unchecked((char)p);
+ if (c != '*')
+ return _cache.Dequeue();
- _cache.Clear();
- _reader.Read(); //consume the '*'
+ _cache.Clear();
+ _reader.Read(); //consume the '*'
- bool hasStar = false;
- while (true) {
- var next = _reader.Read();
- if (next <= 0)
- return next;
- if (unchecked((char)next) == '*')
- hasStar = true;
- else if (hasStar && unchecked((char)next) == '/')
- return Read(); //recursively call self for comments following comments
- else
- hasStar = false;
- }
- }
- }
+ bool hasStar = false;
+ while (true) {
+ var next = _reader.Read();
+ if (next <= 0)
+ return next;
+ if (unchecked((char)next) == '*')
+ hasStar = true;
+ else if (hasStar && unchecked((char)next) == '/')
+ return Read(); //recursively call self for comments following comments
+ else
+ hasStar = false;
+ }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.StyleSheets
{
- interface IStyle
- {
- Type TargetType { get; }
+ internal interface IStyle
+ {
+ Type TargetType { get; }
- void Apply(BindableObject bindable);
- void UnApply(BindableObject bindable);
- }
+ void Apply(BindableObject bindable);
+ void UnApply(BindableObject bindable);
+ }
}
namespace Tizen.NUI.StyleSheets
{
- interface IStyleSelectable
- {
- string[] NameAndBases { get; }
- string Id { get; }
- IStyleSelectable Parent { get; }
- IList<string> Classes { get; }
- IEnumerable<IStyleSelectable> Children { get; }
- }
+ internal interface IStyleSelectable
+ {
+ string[] NameAndBases { get; }
+ string Id { get; }
+ IStyleSelectable Parent { get; }
+ IList<string> Classes { get; }
+ IEnumerable<IStyleSelectable> Children { get; }
+ }
- interface IStylable
- {
- BindableProperty GetProperty(string key, bool inheriting);
- }
+ internal interface IStylable
+ {
+ BindableProperty GetProperty(string key, bool inheriting);
+ }
}
\ No newline at end of file
namespace Tizen.NUI.StyleSheets
{
- abstract class Selector
- {
- Selector()
- {
- }
-
- public static Selector Parse(CssReader reader, char stopChar = '\0')
- {
- Selector root = All, workingRoot = All;
- Operator workingRootParent = null;
- Action<Operator, Selector> setCurrentSelector = (op, sel) => SetCurrentSelector(ref root, ref workingRoot, ref workingRootParent, op, sel);
-
- int p;
- reader.SkipWhiteSpaces();
- while ((p = reader.Peek()) > 0) {
- switch (unchecked((char)p)) {
- case '*':
- setCurrentSelector(new And(), All);
- reader.Read();
- break;
- case '.':
- reader.Read();
- var className = reader.ReadIdent();
- if (className == null)
- return Invalid;
- setCurrentSelector(new And(), new Class(className));
- break;
- case '#':
- reader.Read();
- var id = reader.ReadName();
- if (id == null)
- return Invalid;
- setCurrentSelector(new And(), new Id(id));
- break;
- case '[':
- throw new NotImplementedException("Attributes not implemented");
- case ',':
- reader.Read();
- setCurrentSelector(new Or(), All);
- reader.SkipWhiteSpaces();
- break;
- case '+':
- reader.Read();
- setCurrentSelector(new Adjacent(), All);
- reader.SkipWhiteSpaces();
- break;
- case '~':
- reader.Read();
- setCurrentSelector(new Sibling(), All);
- reader.SkipWhiteSpaces();
- break;
- case '>':
- reader.Read();
- setCurrentSelector(new Child(), All);
- reader.SkipWhiteSpaces();
- break;
- case '^': //not in CSS spec
- reader.Read();
- var element = reader.ReadIdent();
- if (element == null) return Invalid;
- setCurrentSelector(new And(), new Base(element));
- break;
- case ' ':
- case '\t':
- case '\n':
- case '\r':
- case '\f':
- reader.Read();
- bool processWs = false;
- while ((p = reader.Peek()) > 0) {
- var c = unchecked((char)p);
- if (char.IsWhiteSpace(c)) {
- reader.Read();
- continue;
- }
- processWs = (c != '+'
- && c != '>'
- && c != ','
- && c != '~'
- && c != '^'
- && c != stopChar);
- break;
- }
- if (!processWs)
- break;
- setCurrentSelector(new Descendent(), All);
- reader.SkipWhiteSpaces();
- break;
- default:
- if (unchecked((char)p) == stopChar)
- return root;
-
- var elementName = reader.ReadIdent();
- if (elementName == null)
- return Invalid;
- setCurrentSelector(new And(), new Element(elementName));
- break;
- }
- }
- return root;
- }
-
- static void SetCurrentSelector(ref Selector root, ref Selector workingRoot, ref Operator workingRootParent, Operator op, Selector sel)
- {
- var updateRoot = root == workingRoot;
-
- op.Left = workingRoot;
- op.Right = sel;
- workingRoot = op;
- if (workingRootParent != null)
- workingRootParent.Right = workingRoot;
-
- if (updateRoot)
- root = workingRoot;
-
- if (workingRoot is Or) {
- workingRootParent = (Operator)workingRoot;
- workingRoot = sel;
- }
- }
-
- public abstract bool Matches(IStyleSelectable styleable);
-
- internal static Selector Invalid = new Generic(s => false);
- internal static Selector All = new Generic(s => true);
-
- abstract class UnarySelector : Selector
- {
- }
-
- abstract class Operator : Selector
- {
- public Selector Left { get; set; } = Invalid;
- public Selector Right { get; set; } = Invalid;
- }
-
- sealed class Generic : UnarySelector
- {
- readonly Func<IStyleSelectable, bool> func;
- public Generic(Func<IStyleSelectable, bool> func)
- {
- this.func = func;
- }
-
- public override bool Matches(IStyleSelectable styleable) => func(styleable);
- }
-
- sealed class Class : UnarySelector
- {
- public Class(string className)
- {
- ClassName = className;
- }
-
- public string ClassName { get; }
- public override bool Matches(IStyleSelectable styleable)
- => styleable.Classes != null && styleable.Classes.Contains(ClassName);
- }
-
- sealed class Id : UnarySelector
- {
- public Id(string id)
- {
- IdName = id;
- }
-
- public string IdName { get; }
- public override bool Matches(IStyleSelectable styleable) => styleable.Id == IdName;
- }
-
- sealed class Or : Operator
- {
- public override bool Matches(IStyleSelectable styleable) => Right.Matches(styleable) || Left.Matches(styleable);
- }
-
- sealed class And : Operator
- {
- public override bool Matches(IStyleSelectable styleable) => Right.Matches(styleable) && Left.Matches(styleable);
- }
-
- sealed class Element : UnarySelector
- {
- public Element(string elementName)
- {
- ElementName = elementName;
- }
-
- public string ElementName { get; }
- public override bool Matches(IStyleSelectable styleable) =>
- string.Equals(styleable.NameAndBases[0], ElementName, StringComparison.OrdinalIgnoreCase);
- }
-
- sealed class Base : UnarySelector
- {
- public Base(string elementName)
- {
- ElementName = elementName;
- }
-
- public string ElementName { get; }
- public override bool Matches(IStyleSelectable styleable) {
- for (var i = 0; i < styleable.NameAndBases.Length; i++)
- if (string.Equals(styleable.NameAndBases[i], ElementName, StringComparison.OrdinalIgnoreCase))
- return true;
- return false;
- }
- }
-
- sealed class Child : Operator
- {
- public override bool Matches(IStyleSelectable styleable) =>
- Right.Matches(styleable) && styleable.Parent != null && Left.Matches(styleable.Parent);
- }
-
- sealed class Descendent : Operator
- {
- public override bool Matches(IStyleSelectable styleable)
- {
- if (!Right.Matches(styleable))
- return false;
- var parent = styleable.Parent;
- while (parent != null) {
- if (Left.Matches(parent))
- return true;
- parent = parent.Parent;
- }
- return false;
- }
- }
-
- sealed class Adjacent : Operator
- {
- public override bool Matches(IStyleSelectable styleable)
- {
- if (!Right.Matches(styleable))
- return false;
- if (styleable.Parent == null)
- return false;
-
- IStyleSelectable prev = null;
- foreach (var elem in styleable.Parent.Children) {
- if (elem == styleable && prev != null)
- return Left.Matches(prev);
- prev = elem;
- }
- return false;
- //var index = styleable.Parent.Children.IndexOf(styleable);
- //if (index == 0)
- // return false;
- //var adjacent = styleable.Parent.Children[index - 1];
- //return Left.Matches(adjacent);
- }
- }
-
- sealed class Sibling : Operator
- {
- public override bool Matches(IStyleSelectable styleable)
- {
- if (!Right.Matches(styleable))
- return false;
- if (styleable.Parent == null)
- return false;
-
- int selfIndex = 0;
- bool foundSelfInParent = false;
- foreach (var elem in styleable.Parent.Children) {
- if (elem == styleable) {
- foundSelfInParent = true;
- break;
- }
- ++selfIndex;
- }
-
- if (!foundSelfInParent)
- return false;
-
- int index = 0;
- foreach (var elem in styleable.Parent.Children) {
- if (index >= selfIndex)
- return false;
- if (Left.Matches(elem))
- return true;
- ++index;
- }
-
- return false;
-
- //var index = styleable.Parent.Children.IndexOf(styleable);
- //if (index == 0)
- // return false;
- //int siblingIndex = -1;
- //for (var i = 0; i < index; i++)
- // if (Left.Matches(styleable.Parent.Children[i])) {
- // siblingIndex = i;
- // break;
- // }
- //return siblingIndex != -1;
- }
- }
- }
+ internal abstract class Selector
+ {
+ Selector()
+ {
+ }
+
+ public static Selector Parse(CssReader reader, char stopChar = '\0')
+ {
+ Selector root = All, workingRoot = All;
+ Operator workingRootParent = null;
+ Action<Operator, Selector> setCurrentSelector = (op, sel) => SetCurrentSelector(ref root, ref workingRoot, ref workingRootParent, op, sel);
+
+ int p;
+ reader.SkipWhiteSpaces();
+ while ((p = reader.Peek()) > 0) {
+ switch (unchecked((char)p)) {
+ case '*':
+ setCurrentSelector(new And(), All);
+ reader.Read();
+ break;
+ case '.':
+ reader.Read();
+ var className = reader.ReadIdent();
+ if (className == null)
+ return Invalid;
+ setCurrentSelector(new And(), new Class(className));
+ break;
+ case '#':
+ reader.Read();
+ var id = reader.ReadName();
+ if (id == null)
+ return Invalid;
+ setCurrentSelector(new And(), new Id(id));
+ break;
+ case '[':
+ throw new NotImplementedException("Attributes not implemented");
+ case ',':
+ reader.Read();
+ setCurrentSelector(new Or(), All);
+ reader.SkipWhiteSpaces();
+ break;
+ case '+':
+ reader.Read();
+ setCurrentSelector(new Adjacent(), All);
+ reader.SkipWhiteSpaces();
+ break;
+ case '~':
+ reader.Read();
+ setCurrentSelector(new Sibling(), All);
+ reader.SkipWhiteSpaces();
+ break;
+ case '>':
+ reader.Read();
+ setCurrentSelector(new Child(), All);
+ reader.SkipWhiteSpaces();
+ break;
+ case '^': //not in CSS spec
+ reader.Read();
+ var element = reader.ReadIdent();
+ if (element == null) return Invalid;
+ setCurrentSelector(new And(), new Base(element));
+ break;
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ case '\f':
+ reader.Read();
+ bool processWs = false;
+ while ((p = reader.Peek()) > 0) {
+ var c = unchecked((char)p);
+ if (char.IsWhiteSpace(c)) {
+ reader.Read();
+ continue;
+ }
+ processWs = (c != '+'
+ && c != '>'
+ && c != ','
+ && c != '~'
+ && c != '^'
+ && c != stopChar);
+ break;
+ }
+ if (!processWs)
+ break;
+ setCurrentSelector(new Descendent(), All);
+ reader.SkipWhiteSpaces();
+ break;
+ default:
+ if (unchecked((char)p) == stopChar)
+ return root;
+
+ var elementName = reader.ReadIdent();
+ if (elementName == null)
+ return Invalid;
+ setCurrentSelector(new And(), new Element(elementName));
+ break;
+ }
+ }
+ return root;
+ }
+
+ static void SetCurrentSelector(ref Selector root, ref Selector workingRoot, ref Operator workingRootParent, Operator op, Selector sel)
+ {
+ var updateRoot = root == workingRoot;
+
+ op.Left = workingRoot;
+ op.Right = sel;
+ workingRoot = op;
+ if (workingRootParent != null)
+ workingRootParent.Right = workingRoot;
+
+ if (updateRoot)
+ root = workingRoot;
+
+ if (workingRoot is Or) {
+ workingRootParent = (Operator)workingRoot;
+ workingRoot = sel;
+ }
+ }
+
+ public abstract bool Matches(IStyleSelectable styleable);
+
+ internal static Selector Invalid = new Generic(s => false);
+ internal static Selector All = new Generic(s => true);
+
+ abstract class UnarySelector : Selector
+ {
+ }
+
+ abstract class Operator : Selector
+ {
+ public Selector Left { get; set; } = Invalid;
+ public Selector Right { get; set; } = Invalid;
+ }
+
+ sealed class Generic : UnarySelector
+ {
+ readonly Func<IStyleSelectable, bool> func;
+ public Generic(Func<IStyleSelectable, bool> func)
+ {
+ this.func = func;
+ }
+
+ public override bool Matches(IStyleSelectable styleable) => func(styleable);
+ }
+
+ sealed class Class : UnarySelector
+ {
+ public Class(string className)
+ {
+ ClassName = className;
+ }
+
+ public string ClassName { get; }
+ public override bool Matches(IStyleSelectable styleable)
+ => styleable.Classes != null && styleable.Classes.Contains(ClassName);
+ }
+
+ sealed class Id : UnarySelector
+ {
+ public Id(string id)
+ {
+ IdName = id;
+ }
+
+ public string IdName { get; }
+ public override bool Matches(IStyleSelectable styleable) => styleable.Id == IdName;
+ }
+
+ sealed class Or : Operator
+ {
+ public override bool Matches(IStyleSelectable styleable) => Right.Matches(styleable) || Left.Matches(styleable);
+ }
+
+ sealed class And : Operator
+ {
+ public override bool Matches(IStyleSelectable styleable) => Right.Matches(styleable) && Left.Matches(styleable);
+ }
+
+ sealed class Element : UnarySelector
+ {
+ public Element(string elementName)
+ {
+ ElementName = elementName;
+ }
+
+ public string ElementName { get; }
+ public override bool Matches(IStyleSelectable styleable) =>
+ string.Equals(styleable.NameAndBases[0], ElementName, StringComparison.OrdinalIgnoreCase);
+ }
+
+ sealed class Base : UnarySelector
+ {
+ public Base(string elementName)
+ {
+ ElementName = elementName;
+ }
+
+ public string ElementName { get; }
+ public override bool Matches(IStyleSelectable styleable) {
+ for (var i = 0; i < styleable.NameAndBases.Length; i++)
+ if (string.Equals(styleable.NameAndBases[i], ElementName, StringComparison.OrdinalIgnoreCase))
+ return true;
+ return false;
+ }
+ }
+
+ sealed class Child : Operator
+ {
+ public override bool Matches(IStyleSelectable styleable) =>
+ Right.Matches(styleable) && styleable.Parent != null && Left.Matches(styleable.Parent);
+ }
+
+ sealed class Descendent : Operator
+ {
+ public override bool Matches(IStyleSelectable styleable)
+ {
+ if (!Right.Matches(styleable))
+ return false;
+ var parent = styleable.Parent;
+ while (parent != null) {
+ if (Left.Matches(parent))
+ return true;
+ parent = parent.Parent;
+ }
+ return false;
+ }
+ }
+
+ sealed class Adjacent : Operator
+ {
+ public override bool Matches(IStyleSelectable styleable)
+ {
+ if (!Right.Matches(styleable))
+ return false;
+ if (styleable.Parent == null)
+ return false;
+
+ IStyleSelectable prev = null;
+ foreach (var elem in styleable.Parent.Children) {
+ if (elem == styleable && prev != null)
+ return Left.Matches(prev);
+ prev = elem;
+ }
+ return false;
+ //var index = styleable.Parent.Children.IndexOf(styleable);
+ //if (index == 0)
+ // return false;
+ //var adjacent = styleable.Parent.Children[index - 1];
+ //return Left.Matches(adjacent);
+ }
+ }
+
+ sealed class Sibling : Operator
+ {
+ public override bool Matches(IStyleSelectable styleable)
+ {
+ if (!Right.Matches(styleable))
+ return false;
+ if (styleable.Parent == null)
+ return false;
+
+ int selfIndex = 0;
+ bool foundSelfInParent = false;
+ foreach (var elem in styleable.Parent.Children) {
+ if (elem == styleable) {
+ foundSelfInParent = true;
+ break;
+ }
+ ++selfIndex;
+ }
+
+ if (!foundSelfInParent)
+ return false;
+
+ int index = 0;
+ foreach (var elem in styleable.Parent.Children) {
+ if (index >= selfIndex)
+ return false;
+ if (Left.Matches(elem))
+ return true;
+ ++index;
+ }
+
+ return false;
+
+ //var index = styleable.Parent.Children.IndexOf(styleable);
+ //if (index == 0)
+ // return false;
+ //int siblingIndex = -1;
+ //for (var i = 0; i < index; i++)
+ // if (Left.Matches(styleable.Parent.Children[i])) {
+ // siblingIndex = i;
+ // break;
+ // }
+ //return siblingIndex != -1;
+ }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.StyleSheets
{
- sealed class Style
- {
- Style()
- {
- }
+ internal sealed class Style
+ {
+ Style()
+ {
+ }
- public IDictionary<string, string> Declarations { get; set; } = new Dictionary<string, string>();
- Dictionary<KeyValuePair<string, string>, object> convertedValues = new Dictionary<KeyValuePair<string, string>, object>();
+ public IDictionary<string, string> Declarations { get; set; } = new Dictionary<string, string>();
+ Dictionary<KeyValuePair<string, string>, object> convertedValues = new Dictionary<KeyValuePair<string, string>, object>();
- public static Style Parse(CssReader reader, char stopChar = '\0')
- {
- Style style = new Style();
- string propertyName = null, propertyValue = null;
+ public static Style Parse(CssReader reader, char stopChar = '\0')
+ {
+ Style style = new Style();
+ string propertyName = null, propertyValue = null;
- int p;
- reader.SkipWhiteSpaces();
- bool readingName = true;
- while ((p = reader.Peek()) > 0) {
- switch (unchecked((char)p)) {
- case ':':
- reader.Read();
- readingName = false;
- reader.SkipWhiteSpaces();
- break;
- case ';':
- reader.Read();
- if (!string.IsNullOrEmpty(propertyName) && !string.IsNullOrEmpty(propertyValue))
- style.Declarations.Add(propertyName, propertyValue);
- propertyName = propertyValue = null;
- readingName = true;
- reader.SkipWhiteSpaces();
- break;
- default:
- if ((char)p == stopChar)
- return style;
+ int p;
+ reader.SkipWhiteSpaces();
+ bool readingName = true;
+ while ((p = reader.Peek()) > 0) {
+ switch (unchecked((char)p)) {
+ case ':':
+ reader.Read();
+ readingName = false;
+ reader.SkipWhiteSpaces();
+ break;
+ case ';':
+ reader.Read();
+ if (!string.IsNullOrEmpty(propertyName) && !string.IsNullOrEmpty(propertyValue))
+ style.Declarations.Add(propertyName, propertyValue);
+ propertyName = propertyValue = null;
+ readingName = true;
+ reader.SkipWhiteSpaces();
+ break;
+ default:
+ if ((char)p == stopChar)
+ return style;
- if (readingName) {
- propertyName = reader.ReadIdent();
- if (propertyName == null)
- throw new Exception();
- } else
- propertyValue = reader.ReadUntil(stopChar, ';', ':');
- break;
- }
- }
- return style;
- }
+ if (readingName) {
+ propertyName = reader.ReadIdent();
+ if (propertyName == null)
+ throw new Exception();
+ } else
+ propertyValue = reader.ReadUntil(stopChar, ';', ':');
+ break;
+ }
+ }
+ return style;
+ }
- public void Apply(/*VisualElement*/BaseHandle styleable, bool inheriting = false)
- {
- if (styleable == null)
- throw new ArgumentNullException(nameof(styleable));
+ public void Apply(/*VisualElement*/BaseHandle styleable, bool inheriting = false)
+ {
+ if (styleable == null)
+ throw new ArgumentNullException(nameof(styleable));
- foreach (var decl in Declarations) {
- var property = ((IStylable)styleable).GetProperty(decl.Key, inheriting);
- if (property == null)
- continue;
- if (string.Equals(decl.Value, "initial", StringComparison.OrdinalIgnoreCase))
- styleable.ClearValue(property, fromStyle: true);
- else {
- object value;
- if (!convertedValues.TryGetValue(decl, out value))
- convertedValues[decl] = (value = Convert(styleable, decl.Value, property));
- styleable.SetValue(property, value, fromStyle: true);
- }
- }
+ foreach (var decl in Declarations) {
+ var property = ((IStylable)styleable).GetProperty(decl.Key, inheriting);
+ if (property == null)
+ continue;
+ if (string.Equals(decl.Value, "initial", StringComparison.OrdinalIgnoreCase))
+ styleable.ClearValue(property, fromStyle: true);
+ else {
+ object value;
+ if (!convertedValues.TryGetValue(decl, out value))
+ convertedValues[decl] = (value = Convert(styleable, decl.Value, property));
+ styleable.SetValue(property, value, fromStyle: true);
+ }
+ }
- foreach (var child in styleable.LogicalChildrenInternal) {
- var ve = child as /*VisualElement*/BaseHandle;
- if (ve == null)
- continue;
- Apply(ve, inheriting: true);
- }
- }
+ foreach (var child in styleable.LogicalChildrenInternal) {
+ var ve = child as /*VisualElement*/BaseHandle;
+ if (ve == null)
+ continue;
+ Apply(ve, inheriting: true);
+ }
+ }
- // [MethodImpl(MethodImplOptions.AggressiveInlining)]
- static object Convert(object target, object value, BindableProperty property)
- {
- Func<MemberInfo> minforetriever = () => property.DeclaringType.GetRuntimeProperty(property.PropertyName) as MemberInfo
- ?? property.DeclaringType.GetRuntimeMethod("Get" + property.PropertyName, new[] { typeof(BindableObject) }) as MemberInfo;
- var serviceProvider = new StyleSheetServiceProvider(target, property);
- // return value.ConvertTo(property.ReturnType, minforetriever, serviceProvider);
- return null;
- }
+ // [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static object Convert(object target, object value, BindableProperty property)
+ {
+ Func<MemberInfo> minforetriever = () => property.DeclaringType.GetRuntimeProperty(property.PropertyName) as MemberInfo
+ ?? property.DeclaringType.GetRuntimeMethod("Get" + property.PropertyName, new[] { typeof(BindableObject) }) as MemberInfo;
+ var serviceProvider = new StyleSheetServiceProvider(target, property);
+ // return value.ConvertTo(property.ReturnType, minforetriever, serviceProvider);
+ return null;
+ }
- public void UnApply(IStylable styleable)
- {
- throw new NotImplementedException();
- }
- }
+ public void UnApply(IStylable styleable)
+ {
+ throw new NotImplementedException();
+ }
+ }
}
namespace Tizen.NUI.StyleSheets
{
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = true)]
- sealed class StylePropertyAttribute : Attribute
- {
- public string CssPropertyName { get; }
- public string BindablePropertyName { get; }
- public Type TargetType { get; }
- public Type PropertyOwnerType { get; set; }
- public BindableProperty BindableProperty { get; set; }
- public bool Inherited { get; set; } = false;
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = true)]
+ internal sealed class StylePropertyAttribute : Attribute
+ {
+ public string CssPropertyName { get; }
+ public string BindablePropertyName { get; }
+ public Type TargetType { get; }
+ public Type PropertyOwnerType { get; set; }
+ public BindableProperty BindableProperty { get; set; }
+ public bool Inherited { get; set; } = false;
- public StylePropertyAttribute(string cssPropertyName, Type targetType, string bindablePropertyName)
- {
- CssPropertyName = cssPropertyName;
- BindablePropertyName = bindablePropertyName;
- TargetType = targetType;
- }
- }
+ public StylePropertyAttribute(string cssPropertyName, Type targetType, string bindablePropertyName)
+ {
+ CssPropertyName = cssPropertyName;
+ BindablePropertyName = bindablePropertyName;
+ TargetType = targetType;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.StyleSheets
{
- internal sealed class StyleSheet : IStyle
- {
- StyleSheet()
- {
- }
+ internal sealed class StyleSheet : IStyle
+ {
+ StyleSheet()
+ {
+ }
- internal IDictionary<Selector, Style> Styles { get; set; } = new Dictionary<Selector, Style>();
+ internal IDictionary<Selector, Style> Styles { get; set; } = new Dictionary<Selector, Style>();
- public static StyleSheet FromAssemblyResource(Assembly assembly, string resourceId, IXmlLineInfo lineInfo = null)
- {
- using (var stream = assembly.GetManifestResourceStream(resourceId)) {
- if (stream == null)
- throw new XamlParseException($"No resource found for '{resourceId}'.", lineInfo);
- using (var reader = new StreamReader(stream)) {
- return FromReader(reader);
- }
- }
- }
+ public static StyleSheet FromAssemblyResource(Assembly assembly, string resourceId, IXmlLineInfo lineInfo = null)
+ {
+ using (var stream = assembly.GetManifestResourceStream(resourceId)) {
+ if (stream == null)
+ throw new XamlParseException($"No resource found for '{resourceId}'.", lineInfo);
+ using (var reader = new StreamReader(stream)) {
+ return FromReader(reader);
+ }
+ }
+ }
- //used by code generated by XamlC. Has to stay public
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static StyleSheet FromString(string stylesheet)
- {
- if (stylesheet == null)
- throw new ArgumentNullException(nameof(stylesheet));
- using (var reader = new StringReader(stylesheet))
- return FromReader(reader);
- }
+ //used by code generated by XamlC. Has to stay public
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static StyleSheet FromString(string stylesheet)
+ {
+ if (stylesheet == null)
+ throw new ArgumentNullException(nameof(stylesheet));
+ using (var reader = new StringReader(stylesheet))
+ return FromReader(reader);
+ }
- public static StyleSheet FromReader(TextReader reader)
- {
- if (reader == null)
- throw new ArgumentNullException(nameof(reader));
+ public static StyleSheet FromReader(TextReader reader)
+ {
+ if (reader == null)
+ throw new ArgumentNullException(nameof(reader));
- return Parse(new CssReader(reader));
- }
+ return Parse(new CssReader(reader));
+ }
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- static StyleSheet Parse(CssReader reader)
- {
- var sheet = new StyleSheet();
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ static StyleSheet Parse(CssReader reader)
+ {
+ var sheet = new StyleSheet();
- Style style = null;
- var selector = Selector.All;
+ Style style = null;
+ var selector = Selector.All;
- int p;
- bool inStyle = false;
- reader.SkipWhiteSpaces();
- while ((p = reader.Peek()) > 0) {
- switch ((char)p) {
- case '@':
- throw new NotSupportedException("AT-rules not supported");
- case '{':
- reader.Read();
- style = Style.Parse(reader, '}');
- inStyle = true;
- break;
- case '}':
- reader.Read();
- if (!inStyle)
- throw new Exception();
- inStyle = false;
- sheet.Styles.Add(selector, style);
- style = null;
- selector = Selector.All;
- break;
- default:
- selector = Selector.Parse(reader, '{');
- break;
- }
- }
- return sheet;
- }
+ int p;
+ bool inStyle = false;
+ reader.SkipWhiteSpaces();
+ while ((p = reader.Peek()) > 0) {
+ switch ((char)p) {
+ case '@':
+ throw new NotSupportedException("AT-rules not supported");
+ case '{':
+ reader.Read();
+ style = Style.Parse(reader, '}');
+ inStyle = true;
+ break;
+ case '}':
+ reader.Read();
+ if (!inStyle)
+ throw new Exception();
+ inStyle = false;
+ sheet.Styles.Add(selector, style);
+ style = null;
+ selector = Selector.All;
+ break;
+ default:
+ selector = Selector.Parse(reader, '{');
+ break;
+ }
+ }
+ return sheet;
+ }
- Type IStyle.TargetType
- => typeof(/*VisualElement*/BaseHandle);
+ Type IStyle.TargetType
+ => typeof(/*VisualElement*/BaseHandle);
- void IStyle.Apply(BindableObject bindable)
- {
- var styleable = bindable as Element;
- if (styleable == null)
- return;
- Apply(styleable);
- }
+ void IStyle.Apply(BindableObject bindable)
+ {
+ var styleable = bindable as Element;
+ if (styleable == null)
+ return;
+ Apply(styleable);
+ }
- void Apply(Element styleable)
- {
- ApplyCore(styleable);
- foreach (var child in styleable.LogicalChildrenInternal)
- ((IStyle)this).Apply(child);
- }
+ void Apply(Element styleable)
+ {
+ ApplyCore(styleable);
+ foreach (var child in styleable.LogicalChildrenInternal)
+ ((IStyle)this).Apply(child);
+ }
- void ApplyCore(Element styleable)
- {
- var visualStylable = styleable as /*VisualElement*/BaseHandle;
- if (visualStylable == null)
- return;
- foreach (var kvp in Styles) {
- var selector = kvp.Key;
- var style = kvp.Value;
- // if (!selector.Matches(styleable))
- // continue;
- style.Apply(visualStylable);
- }
- }
+ void ApplyCore(Element styleable)
+ {
+ var visualStylable = styleable as /*VisualElement*/BaseHandle;
+ if (visualStylable == null)
+ return;
+ foreach (var kvp in Styles) {
+ var selector = kvp.Key;
+ var style = kvp.Value;
+ // if (!selector.Matches(styleable))
+ // continue;
+ style.Apply(visualStylable);
+ }
+ }
- void IStyle.UnApply(BindableObject bindable)
- {
- throw new NotImplementedException();
- }
- }
+ void IStyle.UnApply(BindableObject bindable)
+ {
+ throw new NotImplementedException();
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.StyleSheets
{
- static class StyleSheetExtensions
- {
- public static IEnumerable<StyleSheet> GetStyleSheets(this IResourcesProvider resourcesProvider)
- {
- if (!resourcesProvider.IsResourcesCreated)
- yield break;
- if (resourcesProvider.Resources.StyleSheets == null)
- yield break;
- foreach (var styleSheet in resourcesProvider.Resources.StyleSheets)
- yield return styleSheet;
- }
- }
+ internal static class StyleSheetExtensions
+ {
+ public static IEnumerable<StyleSheet> GetStyleSheets(this IResourcesProvider resourcesProvider)
+ {
+ if (!resourcesProvider.IsResourcesCreated)
+ yield break;
+ if (resourcesProvider.Resources.StyleSheets == null)
+ yield break;
+ foreach (var styleSheet in resourcesProvider.Resources.StyleSheets)
+ yield return styleSheet;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.StyleSheets
{
- class StyleSheetServiceProvider : IServiceProvider
- {
- IProvideValueTarget vtProvider;
- IConverterOptions convOptions => new ConverterOptions();
+ internal class StyleSheetServiceProvider : IServiceProvider
+ {
+ IProvideValueTarget vtProvider;
+ IConverterOptions convOptions => new ConverterOptions();
- public StyleSheetServiceProvider(object targetObject, object targetProperty)
- {
- vtProvider = new ValueTargetProvider {
- TargetObject = targetObject,
- TargetProperty = targetProperty
- };
- }
+ public StyleSheetServiceProvider(object targetObject, object targetProperty)
+ {
+ vtProvider = new ValueTargetProvider {
+ TargetObject = targetObject,
+ TargetProperty = targetProperty
+ };
+ }
- public object GetService(Type serviceType)
- {
- if (serviceType == typeof(IProvideValueTarget))
- return vtProvider;
- if (serviceType == typeof(IConverterOptions))
- return convOptions;
- return null;
- }
+ public object GetService(Type serviceType)
+ {
+ if (serviceType == typeof(IProvideValueTarget))
+ return vtProvider;
+ if (serviceType == typeof(IConverterOptions))
+ return convOptions;
+ return null;
+ }
- class ValueTargetProvider : IProvideValueTarget
- {
- public object TargetObject { get; set; }
- public object TargetProperty { get; set; }
- }
+ class ValueTargetProvider : IProvideValueTarget
+ {
+ public object TargetObject { get; set; }
+ public object TargetProperty { get; set; }
+ }
- class ConverterOptions : IConverterOptions
- {
- public bool IgnoreCase => true;
- }
- }
+ class ConverterOptions : IConverterOptions
+ {
+ public bool IgnoreCase => true;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.StyleSheets
{
- static class TextReaderExtensions
- {
- //ident [-]?{nmstart}{nmchar}*
- public static string ReadIdent(this TextReader reader)
- {
- var sb = new StringBuilder();
- bool first = true;
- bool hasLeadingDash = false;
- int p;
- while ((p = reader.Peek()) > 0) {
- var c = unchecked((char)p);
- if (first && !hasLeadingDash && c == '-') {
- sb.Append((char)reader.Read());
- hasLeadingDash = true;
- } else if (first && c.IsNmStart()) {
- sb.Append((char)reader.Read());
- first = false;
- } else if (first) { //a nmstart is expected
- throw new Exception();
- } else if (c.IsNmChar())
- sb.Append((char)reader.Read());
- else
- break;
- }
- return sb.ToString();
- }
+ internal static class TextReaderExtensions
+ {
+ //ident [-]?{nmstart}{nmchar}*
+ public static string ReadIdent(this TextReader reader)
+ {
+ var sb = new StringBuilder();
+ bool first = true;
+ bool hasLeadingDash = false;
+ int p;
+ while ((p = reader.Peek()) > 0) {
+ var c = unchecked((char)p);
+ if (first && !hasLeadingDash && c == '-') {
+ sb.Append((char)reader.Read());
+ hasLeadingDash = true;
+ } else if (first && c.IsNmStart()) {
+ sb.Append((char)reader.Read());
+ first = false;
+ } else if (first) { //a nmstart is expected
+ throw new Exception();
+ } else if (c.IsNmChar())
+ sb.Append((char)reader.Read());
+ else
+ break;
+ }
+ return sb.ToString();
+ }
- //name {nmchar}+
- public static string ReadName(this TextReader reader)
- {
- var sb = new StringBuilder();
- int p;
- while ((p = reader.Peek()) > 0) {
- var c = unchecked((char)p);
- if (c.IsNmChar())
- sb.Append((char)reader.Read());
- else
- break;
- }
- return sb.ToString();
- }
+ //name {nmchar}+
+ public static string ReadName(this TextReader reader)
+ {
+ var sb = new StringBuilder();
+ int p;
+ while ((p = reader.Peek()) > 0) {
+ var c = unchecked((char)p);
+ if (c.IsNmChar())
+ sb.Append((char)reader.Read());
+ else
+ break;
+ }
+ return sb.ToString();
+ }
- public static string ReadUntil(this TextReader reader, params char[] limit)
- {
- var sb = new StringBuilder();
- int p;
- while ((p = reader.Peek()) > 0) {
- var c = unchecked((char)p);
- if (limit != null && limit.Contains(c))
- break;
- reader.Read();
- sb.Append(c);
- }
- return sb.ToString();
- }
+ public static string ReadUntil(this TextReader reader, params char[] limit)
+ {
+ var sb = new StringBuilder();
+ int p;
+ while ((p = reader.Peek()) > 0) {
+ var c = unchecked((char)p);
+ if (limit != null && limit.Contains(c))
+ break;
+ reader.Read();
+ sb.Append(c);
+ }
+ return sb.ToString();
+ }
- //w [ \t\r\n\f]*
- public static void SkipWhiteSpaces(this TextReader reader)
- {
- int p;
- while ((p = reader.Peek()) > 0) {
- var c = unchecked((char)p);
- if (!c.IsW())
- break;
- reader.Read();
- }
- }
- }
+ //w [ \t\r\n\f]*
+ public static void SkipWhiteSpaces(this TextReader reader)
+ {
+ int p;
+ while ((p = reader.Peek()) > 0) {
+ var c = unchecked((char)p);
+ if (!c.IsW())
+ break;
+ reader.Read();
+ }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class SynchronizedList<T> : IList<T>, IReadOnlyList<T>
- {
- readonly List<T> _list = new List<T>();
- ReadOnlyCollection<T> _snapshot;
-
- public void Add(T item)
- {
- lock (_list)
- {
- _list.Add(item);
- _snapshot = null;
- }
- }
-
- public void Clear()
- {
- lock (_list)
- {
- _list.Clear();
- _snapshot = null;
- }
- }
-
- public bool Contains(T item)
- {
- lock (_list)
- return _list.Contains(item);
- }
-
- public void CopyTo(T[] array, int arrayIndex)
- {
- lock (_list)
- _list.CopyTo(array, arrayIndex);
- }
-
- public int Count
- {
- get { return _list.Count; }
- }
-
- bool ICollection<T>.IsReadOnly
- {
- get { return false; }
- }
-
- public bool Remove(T item)
- {
- lock (_list)
- {
- if (_list.Remove(item))
- {
- _snapshot = null;
- return true;
- }
-
- return false;
- }
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- public IEnumerator<T> GetEnumerator()
- {
- ReadOnlyCollection<T> snap = _snapshot;
- if (snap == null)
- {
- lock (_list)
- _snapshot = snap = new ReadOnlyCollection<T>(_list.ToList());
- }
-
- return snap?.GetEnumerator();
- }
-
- public int IndexOf(T item)
- {
- lock (_list)
- return _list.IndexOf(item);
- }
-
- public void Insert(int index, T item)
- {
- lock (_list)
- {
- _list.Insert(index, item);
- _snapshot = null;
- }
- }
-
- public T this[int index]
- {
- get
- {
- ReadOnlyCollection<T> snap = _snapshot;
- if (snap != null)
- return snap[index];
-
- lock (_list)
- return _list[index];
- }
-
- set
- {
- lock (_list)
- {
- _list[index] = value;
- _snapshot = null;
- }
- }
- }
-
- public void RemoveAt(int index)
- {
- lock (_list)
- {
- _list.RemoveAt(index);
- _snapshot = null;
- }
- }
- }
+ internal class SynchronizedList<T> : IList<T>, IReadOnlyList<T>
+ {
+ readonly List<T> _list = new List<T>();
+ ReadOnlyCollection<T> _snapshot;
+
+ public void Add(T item)
+ {
+ lock (_list)
+ {
+ _list.Add(item);
+ _snapshot = null;
+ }
+ }
+
+ public void Clear()
+ {
+ lock (_list)
+ {
+ _list.Clear();
+ _snapshot = null;
+ }
+ }
+
+ public bool Contains(T item)
+ {
+ lock (_list)
+ return _list.Contains(item);
+ }
+
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ lock (_list)
+ _list.CopyTo(array, arrayIndex);
+ }
+
+ public int Count
+ {
+ get { return _list.Count; }
+ }
+
+ bool ICollection<T>.IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public bool Remove(T item)
+ {
+ lock (_list)
+ {
+ if (_list.Remove(item))
+ {
+ _snapshot = null;
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ public IEnumerator<T> GetEnumerator()
+ {
+ ReadOnlyCollection<T> snap = _snapshot;
+ if (snap == null)
+ {
+ lock (_list)
+ _snapshot = snap = new ReadOnlyCollection<T>(_list.ToList());
+ }
+
+ return snap?.GetEnumerator();
+ }
+
+ public int IndexOf(T item)
+ {
+ lock (_list)
+ return _list.IndexOf(item);
+ }
+
+ public void Insert(int index, T item)
+ {
+ lock (_list)
+ {
+ _list.Insert(index, item);
+ _snapshot = null;
+ }
+ }
+
+ public T this[int index]
+ {
+ get
+ {
+ ReadOnlyCollection<T> snap = _snapshot;
+ if (snap != null)
+ return snap[index];
+
+ lock (_list)
+ return _list[index];
+ }
+
+ set
+ {
+ lock (_list)
+ {
+ _list[index] = value;
+ _snapshot = null;
+ }
+ }
+ }
+
+ public void RemoveAt(int index)
+ {
+ lock (_list)
+ {
+ _list.RemoveAt(index);
+ _snapshot = null;
+ }
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal enum TargetIdiom
- {
- Unsupported,
- Phone,
- Tablet,
- Desktop,
- TV,
- Watch
- }
+ internal enum TargetIdiom
+ {
+ Unsupported,
+ Phone,
+ Tablet,
+ Desktop,
+ TV,
+ Watch
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [Obsolete]
- internal enum TargetPlatform
- {
- Other,
- iOS,
- Android,
- WinPhone,
- Windows
- }
+ [Obsolete]
+ internal enum TargetPlatform
+ {
+ Other,
+ iOS,
+ Android,
+ WinPhone,
+ Windows
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class TemplateBinding : BindingBase
- {
- internal const string SelfPath = ".";
- IValueConverter _converter;
- object _converterParameter;
-
- BindingExpression _expression;
- string _path;
-
- public TemplateBinding()
- {
- }
-
- public TemplateBinding(string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null, object converterParameter = null, string stringFormat = null)
- {
- if (path == null)
- throw new ArgumentNullException("path");
- if (string.IsNullOrWhiteSpace(path))
- throw new ArgumentException("path can not be an empty string", "path");
-
- AllowChaining = true;
- Path = path;
- Converter = converter;
- ConverterParameter = converterParameter;
- Mode = mode;
- StringFormat = stringFormat;
- }
-
- public IValueConverter Converter
- {
- get { return _converter; }
- set
- {
- ThrowIfApplied();
-
- _converter = value;
- }
- }
-
- public object ConverterParameter
- {
- get { return _converterParameter; }
- set
- {
- ThrowIfApplied();
-
- _converterParameter = value;
- }
- }
-
- public string Path
- {
- get { return _path; }
- set
- {
- ThrowIfApplied();
-
- _path = value;
- _expression = GetBindingExpression(value);
- }
- }
-
- internal override void Apply(bool fromTarget)
- {
- base.Apply(fromTarget);
-
- if (_expression == null)
- _expression = new BindingExpression(this, SelfPath);
-
- _expression.Apply(fromTarget);
- }
-
- internal override async void Apply(object newContext, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged = false)
- {
- var view = bindObj as Element;
- if (view == null)
- throw new InvalidOperationException();
-
- base.Apply(newContext, bindObj, targetProperty, fromBindingContextChanged);
-
- Element templatedParent = await TemplateUtilities.FindTemplatedParentAsync(view);
- ApplyInner(templatedParent, bindObj, targetProperty);
- }
-
- internal override BindingBase Clone()
- {
- return new TemplateBinding(Path, Mode) { Converter = Converter, ConverterParameter = ConverterParameter, StringFormat = StringFormat };
- }
-
- internal override object GetSourceValue(object value, Type targetPropertyType)
- {
- if (Converter != null)
- value = Converter.Convert(value, targetPropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
-
- return base.GetSourceValue(value, targetPropertyType);
- }
-
- internal override object GetTargetValue(object value, Type sourcePropertyType)
- {
- if (Converter != null)
- value = Converter.ConvertBack(value, sourcePropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
-
- return base.GetTargetValue(value, sourcePropertyType);
- }
-
- internal override void Unapply(bool fromBindingContextChanged = false)
- {
- base.Unapply(fromBindingContextChanged: fromBindingContextChanged);
-
- if (_expression != null)
- _expression.Unapply();
- }
-
- void ApplyInner(Element templatedParent, BindableObject bindableObject, BindableProperty targetProperty)
- {
- if (_expression == null && templatedParent != null)
- _expression = new BindingExpression(this, SelfPath);
-
- _expression?.Apply(templatedParent, bindableObject, targetProperty);
- }
-
- BindingExpression GetBindingExpression(string path)
- {
- return new BindingExpression(this, !string.IsNullOrWhiteSpace(path) ? path : SelfPath);
- }
- }
+ internal class TemplateBinding : BindingBase
+ {
+ internal const string SelfPath = ".";
+ IValueConverter _converter;
+ object _converterParameter;
+
+ BindingExpression _expression;
+ string _path;
+
+ public TemplateBinding()
+ {
+ }
+
+ public TemplateBinding(string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null, object converterParameter = null, string stringFormat = null)
+ {
+ if (path == null)
+ throw new ArgumentNullException("path");
+ if (string.IsNullOrWhiteSpace(path))
+ throw new ArgumentException("path can not be an empty string", "path");
+
+ AllowChaining = true;
+ Path = path;
+ Converter = converter;
+ ConverterParameter = converterParameter;
+ Mode = mode;
+ StringFormat = stringFormat;
+ }
+
+ public IValueConverter Converter
+ {
+ get { return _converter; }
+ set
+ {
+ ThrowIfApplied();
+
+ _converter = value;
+ }
+ }
+
+ public object ConverterParameter
+ {
+ get { return _converterParameter; }
+ set
+ {
+ ThrowIfApplied();
+
+ _converterParameter = value;
+ }
+ }
+
+ public string Path
+ {
+ get { return _path; }
+ set
+ {
+ ThrowIfApplied();
+
+ _path = value;
+ _expression = GetBindingExpression(value);
+ }
+ }
+
+ internal override void Apply(bool fromTarget)
+ {
+ base.Apply(fromTarget);
+
+ if (_expression == null)
+ _expression = new BindingExpression(this, SelfPath);
+
+ _expression.Apply(fromTarget);
+ }
+
+ internal override async void Apply(object newContext, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged = false)
+ {
+ var view = bindObj as Element;
+ if (view == null)
+ throw new InvalidOperationException();
+
+ base.Apply(newContext, bindObj, targetProperty, fromBindingContextChanged);
+
+ Element templatedParent = await TemplateUtilities.FindTemplatedParentAsync(view);
+ ApplyInner(templatedParent, bindObj, targetProperty);
+ }
+
+ internal override BindingBase Clone()
+ {
+ return new TemplateBinding(Path, Mode) { Converter = Converter, ConverterParameter = ConverterParameter, StringFormat = StringFormat };
+ }
+
+ internal override object GetSourceValue(object value, Type targetPropertyType)
+ {
+ if (Converter != null)
+ value = Converter.Convert(value, targetPropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
+
+ return base.GetSourceValue(value, targetPropertyType);
+ }
+
+ internal override object GetTargetValue(object value, Type sourcePropertyType)
+ {
+ if (Converter != null)
+ value = Converter.ConvertBack(value, sourcePropertyType, ConverterParameter, CultureInfo.CurrentUICulture);
+
+ return base.GetTargetValue(value, sourcePropertyType);
+ }
+
+ internal override void Unapply(bool fromBindingContextChanged = false)
+ {
+ base.Unapply(fromBindingContextChanged: fromBindingContextChanged);
+
+ if (_expression != null)
+ _expression.Unapply();
+ }
+
+ void ApplyInner(Element templatedParent, BindableObject bindableObject, BindableProperty targetProperty)
+ {
+ if (_expression == null && templatedParent != null)
+ _expression = new BindingExpression(this, SelfPath);
+
+ _expression?.Apply(templatedParent, bindableObject, targetProperty);
+ }
+
+ BindingExpression GetBindingExpression(string path)
+ {
+ return new BindingExpression(this, !string.IsNullOrWhiteSpace(path) ? path : SelfPath);
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal static class TemplateUtilities
- {
- public static async Task<Element> FindTemplatedParentAsync(Element element)
- {
- if (element.RealParent is Application)
- return null;
-
- var skipCount = 0;
- element = await GetRealParentAsync(element);
- while (!Application.IsApplicationOrNull(element))
- {
- var controlTemplated = element as IControlTemplated;
- if (controlTemplated?.ControlTemplate != null)
- {
- if (skipCount == 0)
- return element;
- skipCount--;
- }
- // if (element is ContentPresenter)
- // skipCount++;
- element = await GetRealParentAsync(element);
- }
-
- return null;
- }
-
- public static Task<Element> GetRealParentAsync(Element element)
- {
- Element parent = element.RealParent;
- if (parent is Application)
- return Task.FromResult<Element>(null);
-
- if (parent != null)
- return Task.FromResult(parent);
-
- var tcs = new TaskCompletionSource<Element>();
- EventHandler handler = null;
- handler = (sender, args) =>
- {
- tcs.TrySetResult(element.RealParent);
- element.ParentSet -= handler;
- };
- element.ParentSet += handler;
-
- return tcs.Task;
- }
-
- public static void OnContentChanged(BindableObject bindable, object oldValue, object 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);
- }
- }
- }
-
- public static void OnControlTemplateChanged(BindableObject bindable, object oldValue, object newValue)
- {
- var self = (IControlTemplated)bindable;
-
- // First make sure any old ContentPresenters are no longer bound up. This MUST be
- // done before we attempt to make the new template.
- if (oldValue != null)
- {
- var queue = new Queue<Element>(16);
- queue.Enqueue((Element)self);
-
- while (queue.Count > 0)
- {
- ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildrenInternal;
- for (var i = 0; i < children.Count; i++)
- {
- Element child = children[i];
- var controlTemplated = child as IControlTemplated;
-
- // var presenter = child as ContentPresenter;
- // if (presenter != null)
- // presenter.Clear();
- // else if (controlTemplated == null || controlTemplated.ControlTemplate == null)
- // queue.Enqueue(child);
- }
- }
- }
-
- // Now remove all remnants of any other children just to be sure
- while (self.InternalChildren.Count > 0)
- {
- self.InternalChildren.RemoveAt(self.InternalChildren.Count - 1);
- }
-
- ControlTemplate template = self.ControlTemplate;
- if (template == null)
- {
- // do nothing for now
- }
- else
- {
- var content = template.CreateContent() as View;
- if (content == null)
- {
- throw new NotSupportedException("ControlTemplate must return a type derived from View.");
- }
-
- self.InternalChildren.Add(content);
- ((IControlTemplated)bindable).OnControlTemplateChanged((ControlTemplate)oldValue, (ControlTemplate)newValue);
- }
- }
- }
+ internal static class TemplateUtilities
+ {
+ public static async Task<Element> FindTemplatedParentAsync(Element element)
+ {
+ if (element.RealParent is Application)
+ return null;
+
+ var skipCount = 0;
+ element = await GetRealParentAsync(element);
+ while (!Application.IsApplicationOrNull(element))
+ {
+ var controlTemplated = element as IControlTemplated;
+ //if (controlTemplated?.ControlTemplate != null)
+ //{
+ // if (skipCount == 0)
+ // return element;
+ // skipCount--;
+ //}
+ // if (element is ContentPresenter)
+ // skipCount++;
+ element = await GetRealParentAsync(element);
+ }
+
+ return null;
+ }
+
+ public static Task<Element> GetRealParentAsync(Element element)
+ {
+ Element parent = element.RealParent;
+ if (parent is Application)
+ return Task.FromResult<Element>(null);
+
+ if (parent != null)
+ return Task.FromResult(parent);
+
+ var tcs = new TaskCompletionSource<Element>();
+ EventHandler handler = null;
+ handler = (sender, args) =>
+ {
+ tcs.TrySetResult(element.RealParent);
+ element.ParentSet -= handler;
+ };
+ element.ParentSet += handler;
+
+ return tcs.Task;
+ }
+
+ public static void OnContentChanged(BindableObject bindable, object oldValue, object 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);
+ // }
+ //}
+ }
+
+ public static void OnControlTemplateChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ var self = (IControlTemplated)bindable;
+
+ // First make sure any old ContentPresenters are no longer bound up. This MUST be
+ // done before we attempt to make the new template.
+ if (oldValue != null)
+ {
+ var queue = new Queue<Element>(16);
+ queue.Enqueue((Element)self);
+
+ while (queue.Count > 0)
+ {
+ ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildrenInternal;
+ for (var i = 0; i < children.Count; i++)
+ {
+ Element child = children[i];
+ var controlTemplated = child as IControlTemplated;
+
+ // var presenter = child as ContentPresenter;
+ // if (presenter != null)
+ // presenter.Clear();
+ // else if (controlTemplated == null || controlTemplated.ControlTemplate == null)
+ // queue.Enqueue(child);
+ }
+ }
+ }
+
+ // Now remove all remnants of any other children just to be sure
+ while (self.InternalChildren.Count > 0)
+ {
+ self.InternalChildren.RemoveAt(self.InternalChildren.Count - 1);
+ }
+
+ //ControlTemplate template = self.ControlTemplate;
+ //if (template == null)
+ //{
+ // // do nothing for now
+ //}
+ //else
+ //{
+ // var content = template.CreateContent() as View;
+ // if (content == null)
+ // {
+ // throw new NotSupportedException("ControlTemplate must return a type derived from View.");
+ // }
+
+ // self.InternalChildren.Add(content);
+ // ((IControlTemplated)bindable).OnControlTemplateChanged((ControlTemplate)oldValue, (ControlTemplate)newValue);
+ //}
+ }
+ }
}
/// <summary>
/// Struct defining thickness around the edges of a Rectangle using doubles.
/// </summary>
- [DebuggerDisplay("Left={Left}, Top={Top}, Right={Right}, Bottom={Bottom}, HorizontalThickness={HorizontalThickness}, VerticalThickness={VerticalThickness}")]
- [TypeConverter(typeof(ThicknessTypeConverter))]
+ [DebuggerDisplay("Left={Left}, Top={Top}, Right={Right}, Bottom={Bottom}, HorizontalThickness={HorizontalThickness}, VerticalThickness={VerticalThickness}")]
+ [TypeConverter(typeof(ThicknessTypeConverter))]
[EditorBrowsable(EditorBrowsableState.Never)]
- public struct Thickness
- {
+ internal struct Thickness
+ {
/// <summary>
/// The thickness of the left side of a rectangle.
/// </summary>
- public double Left { get; set; }
+ public double Left { get; set; }
/// <summary>
/// The thickness of the top of a rectangle.
/// </summary>
- public double Top { get; set; }
+ public double Top { get; set; }
/// <summary>
/// The thickness of the right side of a rectangle.
/// </summary>
- public double Right { get; set; }
+ public double Right { get; set; }
/// <summary>
/// The thickness of the bottom of a rectangle.
/// </summary>
- public double Bottom { get; set; }
+ public double Bottom { get; set; }
/// <summary>
/// The sum of Left and Right.
/// </summary>
- public double HorizontalThickness
- {
- get { return Left + Right; }
- }
+ public double HorizontalThickness
+ {
+ get { return Left + Right; }
+ }
/// <summary>
/// The sum of Top and Bottom.
/// </summary>
- public double VerticalThickness
- {
- get { return Top + Bottom; }
- }
+ public double VerticalThickness
+ {
+ get { return Top + Bottom; }
+ }
- internal bool IsDefault
- {
- get { return Left == 0 && Top == 0 && Right == 0 && Bottom == 0; }
- }
+ internal bool IsDefault
+ {
+ get { return Left == 0 && Top == 0 && Right == 0 && Bottom == 0; }
+ }
/// <summary>
/// Creates a new Thickness object that represents a uniform thickness of size uniformSize.
/// </summary>
/// <param name="uniformSize">The uniform size of all edges in the new thickness.</param>
- public Thickness(double uniformSize) : this(uniformSize, uniformSize, uniformSize, uniformSize)
- {
- }
+ public Thickness(double uniformSize) : this(uniformSize, uniformSize, uniformSize, uniformSize)
+ {
+ }
/// <summary>
/// Creates a new Thickness object that has a horizontal thickness of horizontalSize and a vertical thickness of verticalSize.
/// </summary>
/// <param name="horizontalSize">The width of the left and right thicknesses.</param>
/// <param name="verticalSize">The height of the top and bottom thicknesses.</param>
- public Thickness(double horizontalSize, double verticalSize) : this(horizontalSize, verticalSize, horizontalSize, verticalSize)
- {
- }
+ public Thickness(double horizontalSize, double verticalSize) : this(horizontalSize, verticalSize, horizontalSize, verticalSize)
+ {
+ }
/// <summary>
/// Creates a new Thickness object with thicknesses defined by left, top, right, and bottom.
/// <param name="top">The height of the top thickness.</param>
/// <param name="right">The width of the right thickness.</param>
/// <param name="bottom">The height of the bottom thickness.</param>
- public Thickness(double left, double top, double right, double bottom) : this()
- {
- Left = left;
- Top = top;
- Right = right;
- Bottom = bottom;
- }
+ public Thickness(double left, double top, double right, double bottom) : this()
+ {
+ Left = left;
+ Top = top;
+ Right = right;
+ Bottom = bottom;
+ }
/// <summary>
/// Converts a Size into a Thickness.
/// </summary>
/// <param name="size">A Size to convert to a Thickness</param>
- public static implicit operator Thickness(Size size)
- {
- return new Thickness(size.Width, size.Height, size.Width, size.Height);
- }
+ public static implicit operator Thickness(Size size)
+ {
+ return new Thickness(size.Width, size.Height, size.Width, size.Height);
+ }
/// <summary>
/// Implicit cast operator from Double.
/// </summary>
/// <param name="uniformSize">The value for the uniform Thickness.</param>
- public static implicit operator Thickness(double uniformSize)
- {
- return new Thickness(uniformSize);
- }
+ public static implicit operator Thickness(double uniformSize)
+ {
+ return new Thickness(uniformSize);
+ }
/// <summary>
/// Whether the other has equivalent values.
/// </summary>
/// <param name="other">A Thickness to be compared.</param>
/// <returns>true if other has equivalent values.</returns>
- bool Equals(Thickness other)
- {
- return Left.Equals(other.Left) && Top.Equals(other.Top) && Right.Equals(other.Right) && Bottom.Equals(other.Bottom);
- }
+ bool Equals(Thickness other)
+ {
+ return Left.Equals(other.Left) && Top.Equals(other.Top) && Right.Equals(other.Right) && Bottom.Equals(other.Bottom);
+ }
/// <summary>
/// Whether the obj has equivalent values.
/// </summary>
/// <param name="obj">A Thickness to be compared.</param>
/// <returns>true if obj is a Thickness and has equivalent values.</returns>
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj))
- return false;
- return obj is Thickness && Equals((Thickness)obj);
- }
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj))
+ return false;
+ return obj is Thickness && Equals((Thickness)obj);
+ }
/// <summary>
/// A hash value for this Thickness.
/// </summary>
/// <returns>The hash value</returns>
- public override int GetHashCode()
- {
- unchecked
- {
- int hashCode = Left.GetHashCode();
- hashCode = (hashCode * 397) ^ Top.GetHashCode();
- hashCode = (hashCode * 397) ^ Right.GetHashCode();
- hashCode = (hashCode * 397) ^ Bottom.GetHashCode();
- return hashCode;
- }
- }
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hashCode = Left.GetHashCode();
+ hashCode = (hashCode * 397) ^ Top.GetHashCode();
+ hashCode = (hashCode * 397) ^ Right.GetHashCode();
+ hashCode = (hashCode * 397) ^ Bottom.GetHashCode();
+ return hashCode;
+ }
+ }
/// <summary>
/// Whether two Thicknesses have identical values.
/// <param name="left">A Thickness to be compared.</param>
/// <param name="right">A Thickness to be compared.</param>
/// <returns>true if left and right have identical values for Left,Right, Top, and Bottom.</returns>
- public static bool operator ==(Thickness left, Thickness right)
- {
- return left.Equals(right);
- }
+ public static bool operator ==(Thickness left, Thickness right)
+ {
+ return left.Equals(right);
+ }
/// <summary>
/// Whether the values of two Thickness's have at least one difference.
/// <param name="left">A Thickness to be compared.</param>
/// <param name="right">A Thickness to be compared.</param>
/// <returns>true if any of the Left,Right, Top, and Bottom values differ between left and right.</returns>
- public static bool operator !=(Thickness left, Thickness right)
- {
- return !left.Equals(right);
- }
+ public static bool operator !=(Thickness left, Thickness right)
+ {
+ return !left.Equals(right);
+ }
/// <summary>
/// Stores the components of the thickness in the corresponding arguments.
/// <param name="top">Variable in which to store the top thickness of thickness object.</param>
/// <param name="right">Variable in which to store the right thickness of thickness object.</param>
/// <param name="bottom">Variable in which to store the bottom thickness of thickness object.</param>
- public void Deconstruct(out double left, out double top, out double right, out double bottom)
- {
- left = Left;
- top = Top;
- right = Right;
- bottom = Bottom;
- }
- }
+ public void Deconstruct(out double left, out double top, out double right, out double bottom)
+ {
+ left = Left;
+ top = Top;
+ right = Right;
+ bottom = Bottom;
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.ThicknessTypeConverter")]
- [Xaml.TypeConversion(typeof(Thickness))]
- internal class ThicknessTypeConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- if (value != null) {
- value = value.Trim();
- if (value.Contains(",")) { //Xaml
- var thickness = value.Split(',');
- switch (thickness.Length) {
- case 2:
- if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out double h)
- && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out double v))
- return new Thickness(h, v);
- break;
- case 4:
- if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out double l)
- && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out double t)
- && double.TryParse(thickness[2], NumberStyles.Number, CultureInfo.InvariantCulture, out double r)
- && double.TryParse(thickness[3], NumberStyles.Number, CultureInfo.InvariantCulture, out double b))
- return new Thickness(l, t, r, b);
- break;
- }
- }
- else if (value.Contains(" ")) { //CSS
- var thickness = value.Split(' ');
- switch (thickness.Length) {
- case 2:
- if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out double v)
- && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out double h))
- return new Thickness(h, v);
- break;
- case 3:
- if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out double t)
- && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out h)
- && double.TryParse(thickness[2], NumberStyles.Number, CultureInfo.InvariantCulture, out double b))
- return new Thickness(h, t, h, b);
- break;
- case 4:
- if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out t)
- && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out double r)
- && double.TryParse(thickness[2], NumberStyles.Number, CultureInfo.InvariantCulture, out b)
- && double.TryParse(thickness[3], NumberStyles.Number, CultureInfo.InvariantCulture, out double l))
- return new Thickness(l, t, r, b);
- break;
- }
- }
- else { //single uniform thickness
- if (double.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out double l))
- return new Thickness(l);
- }
- }
+ // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.ThicknessTypeConverter")]
+ [Xaml.TypeConversion(typeof(Thickness))]
+ internal class ThicknessTypeConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (value != null) {
+ value = value.Trim();
+ if (value.Contains(",")) { //Xaml
+ var thickness = value.Split(',');
+ switch (thickness.Length) {
+ case 2:
+ if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out double h)
+ && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out double v))
+ return new Thickness(h, v);
+ break;
+ case 4:
+ if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out double l)
+ && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out double t)
+ && double.TryParse(thickness[2], NumberStyles.Number, CultureInfo.InvariantCulture, out double r)
+ && double.TryParse(thickness[3], NumberStyles.Number, CultureInfo.InvariantCulture, out double b))
+ return new Thickness(l, t, r, b);
+ break;
+ }
+ }
+ else if (value.Contains(" ")) { //CSS
+ var thickness = value.Split(' ');
+ switch (thickness.Length) {
+ case 2:
+ if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out double v)
+ && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out double h))
+ return new Thickness(h, v);
+ break;
+ case 3:
+ if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out double t)
+ && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out h)
+ && double.TryParse(thickness[2], NumberStyles.Number, CultureInfo.InvariantCulture, out double b))
+ return new Thickness(h, t, h, b);
+ break;
+ case 4:
+ if ( double.TryParse(thickness[0], NumberStyles.Number, CultureInfo.InvariantCulture, out t)
+ && double.TryParse(thickness[1], NumberStyles.Number, CultureInfo.InvariantCulture, out double r)
+ && double.TryParse(thickness[2], NumberStyles.Number, CultureInfo.InvariantCulture, out b)
+ && double.TryParse(thickness[3], NumberStyles.Number, CultureInfo.InvariantCulture, out double l))
+ return new Thickness(l, t, r, b);
+ break;
+ }
+ }
+ else { //single uniform thickness
+ if (double.TryParse(value, NumberStyles.Number, CultureInfo.InvariantCulture, out double l))
+ return new Thickness(l);
+ }
+ }
- throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Thickness)}");
- }
- }
+ throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Thickness)}");
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+// using ElmSharp;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net.Http;
+using System.Reflection;
+using System.Security.Cryptography;
+using System.Threading;
+using System.Threading.Tasks;
+using Tizen.NUI.Binding.Internals;
+// using TAppControl = Tizen.Applications.AppControl;
+
+namespace Tizen.NUI.Binding
+{
+ internal class TizenPlatformServices : IPlatformServices
+ {
+ static MD5 checksum = MD5.Create();
+
+ static SynchronizationContext s_context;
+
+ public TizenPlatformServices()
+ {
+ s_context = SynchronizationContext.Current;
+ }
+
+ public class TizenTicker : Ticker
+ {
+ readonly System.Threading.Timer _timer;
+
+ public TizenTicker()
+ {
+ _timer = new System.Threading.Timer((object o) => HandleElapsed(o), this, Timeout.Infinite, Timeout.Infinite);
+ }
+
+ protected override void EnableTimer()
+ {
+ _timer.Change(16, 16);
+ }
+
+ protected override void DisableTimer()
+ {
+ _timer.Change(-1, -1);
+ }
+
+ void HandleElapsed(object state)
+ {
+ s_context.Post((o) => SendSignals(-1), null);
+ }
+ }
+ #region IPlatformServices implementation
+
+ // public double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes)
+ // {
+ // int pt;
+ // // Actual font size depends on the target idiom.
+ // switch (size)
+ // {
+ // case NamedSize.Micro:
+ // pt = Device.Idiom == TargetIdiom.TV || Device.Idiom == TargetIdiom.Watch ? 24 : 19;
+ // break;
+ // case NamedSize.Small:
+ // pt = Device.Idiom == TargetIdiom.TV ? 26 : (Device.Idiom == TargetIdiom.Watch ? 30 : 22);
+ // break;
+ // case NamedSize.Default:
+ // case NamedSize.Medium:
+ // pt = Device.Idiom == TargetIdiom.TV ? 28 : (Device.Idiom == TargetIdiom.Watch ? 32 : 25);
+ // break;
+ // case NamedSize.Large:
+ // pt = Device.Idiom == TargetIdiom.TV ? 84 : (Device.Idiom == TargetIdiom.Watch ? 36 : 31);
+ // break;
+ // default:
+ // throw new ArgumentOutOfRangeException();
+ // }
+ // return Forms.ConvertToDPFont(pt);
+ // }
+
+ // public void OpenUriAction(Uri uri)
+ // {
+ // if (uri == null || uri.AbsoluteUri == null)
+ // {
+ // throw new ArgumentNullException(nameof(uri));
+ // }
+ // TAppControl tAppControl = new TAppControl() { Operation = "%", Uri = uri.AbsoluteUri };
+ // var matchedApplications = TAppControl.GetMatchedApplicationIds(tAppControl);
+ // if (matchedApplications.Count() > 0)
+ // {
+ // TAppControl.SendLaunchRequest(tAppControl);
+ // return;
+ // }
+ // throw new PlatformNotSupportedException();
+ // }
+
+ public void BeginInvokeOnMainThread(Action action)
+ {
+ s_context.Post((o) => action(), null);
+ }
+
+ public Ticker CreateTicker()
+ {
+ return new TizenTicker();
+ }
+
+ public void StartTimer(TimeSpan interval, Func<bool> callback)
+ {
+ Console.WriteLine("TizenPlatformServices StartTimer ...");
+ System.Threading.Timer timer = null;
+ bool invoking = false;
+ TimerCallback onTimeout = o =>
+ {
+ if (!invoking)
+ {
+ invoking = true;
+ BeginInvokeOnMainThread(() =>
+ {
+ if (!callback())
+ {
+ timer.Dispose();
+ }
+ invoking = false;
+ }
+ );
+ }
+ };
+ timer = new System.Threading.Timer(onTimeout, null, Timeout.Infinite, Timeout.Infinite);
+ // set interval separarately to prevent calling onTimeout before `timer' is assigned
+ timer.Change(interval, interval);
+ }
+
+ public async Task<Stream> GetStreamAsync(Uri uri, CancellationToken cancellationToken)
+ {
+ using (var client = new HttpClient())
+ using (HttpResponseMessage response = await client.GetAsync(uri, cancellationToken))
+ return await response.Content.ReadAsStreamAsync();
+ }
+
+ public Assembly[] GetAssemblies()
+ {
+ return AppDomain.CurrentDomain.GetAssemblies();
+ }
+
+ // public IIsolatedStorageFile GetUserStoreForApplication()
+ // {
+ // return new TizenIsolatedStorageFile();
+ // }
+
+ static readonly char[] HexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+ public string GetMD5Hash(string input)
+ {
+ byte[] bin = checksum.ComputeHash(System.Text.Encoding.UTF8.GetBytes(input));
+ char[] hex = new char[32];
+ for (var i = 0; i < 16; ++i)
+ {
+ hex[2 * i] = HexDigits[bin[i] >> 4];
+ hex[2 * i + 1] = HexDigits[bin[i] & 0xf];
+ }
+ return new string(hex);
+ }
+
+ public void QuitApplication()
+ {
+ // Forms.Context.Exit();
+ Console.WriteLine("!!!!!!!!!!!! Exit !!!!!!!!!!!!!!");
+ }
+
+ public bool IsInvokeRequired
+ {
+ get
+ {
+ // return !EcoreMainloop.IsMainThread;
+ return true;
+ }
+ }
+
+ public string RuntimePlatform => Device.Tizen;
+
+ #endregion
+
+ // In .NETCore, AppDomain is not supported. The list of the assemblies should be generated manually.
+ internal class AppDomain
+ {
+ public static AppDomain CurrentDomain { get; private set; }
+
+ List<Assembly> _assemblies;
+
+ public static bool IsTizenSpecificAvailable { get; private set; }
+
+ static AppDomain()
+ {
+ CurrentDomain = new AppDomain();
+ }
+
+ AppDomain()
+ {
+ _assemblies = new List<Assembly>();
+
+ // Add this renderer assembly to the list
+ _assemblies.Add(GetType().GetTypeInfo().Assembly);
+ }
+
+ internal void RegisterAssemblyRecursively(Assembly asm)
+ {
+ if (_assemblies.Contains(asm))
+ return;
+
+ _assemblies.Add(asm);
+
+ foreach (var refName in asm.GetReferencedAssemblies())
+ {
+ if (!refName.Name.StartsWith("System.") && !refName.Name.StartsWith("Microsoft.") && !refName.Name.StartsWith("mscorlib"))
+ {
+ try
+ {
+ Assembly refAsm = Assembly.Load(refName);
+ RegisterAssemblyRecursively(refAsm);
+ if (refName.Name == "Xamarin.Forms.Core")
+ {
+ if (refAsm.GetType("Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement") != null)
+ {
+ IsTizenSpecificAvailable = true;
+ }
+ }
+ }
+ catch
+ {
+ Log.Warn("Reference Assembly can not be loaded. {0}", refName.FullName);
+ }
+ }
+ }
+ }
+
+ public Assembly[] GetAssemblies()
+ {
+ return _assemblies.ToArray();
+ }
+ }
+ }
+}
+
namespace Tizen.NUI.Binding
{
- internal class ToolbarItem : MenuItem
- {
- static readonly BindableProperty OrderProperty = BindableProperty.Create("Order", typeof(ToolbarItemOrder), typeof(ToolbarItem), ToolbarItemOrder.Default, validateValue: (bo, o) =>
- {
- var order = (ToolbarItemOrder)o;
- return order == ToolbarItemOrder.Default || order == ToolbarItemOrder.Primary || order == ToolbarItemOrder.Secondary;
- });
-
- static readonly BindableProperty PriorityProperty = BindableProperty.Create("Priority", typeof(int), typeof(ToolbarItem), 0);
-
- public ToolbarItem()
- {
- }
-
- public ToolbarItem(string name, string icon, Action activated, ToolbarItemOrder order = ToolbarItemOrder.Default, int priority = 0)
- {
- if (activated == null)
- throw new ArgumentNullException("activated");
-
- Text = name;
- Icon = icon;
- Clicked += (s, e) => activated();
- Order = order;
- Priority = priority;
- }
-
- [Obsolete("Name is obsolete as of version 1.3.0. Please use Text instead.")]
- public string Name
- {
- get { return Text; }
- set { Text = value; }
- }
-
- public ToolbarItemOrder Order
- {
- get { return (ToolbarItemOrder)GetValue(OrderProperty); }
- set { SetValue(OrderProperty, value); }
- }
-
- public int Priority
- {
- get { return (int)GetValue(PriorityProperty); }
- set { SetValue(PriorityProperty, value); }
- }
-
- [Obsolete("Activated is obsolete as of version 1.3.0. Please use Clicked instead.")]
- public event EventHandler Activated
- {
- add { Clicked += value; }
- remove { Clicked -= value; }
- }
- }
+ internal class ToolbarItem : MenuItem
+ {
+ static readonly BindableProperty OrderProperty = BindableProperty.Create("Order", typeof(ToolbarItemOrder), typeof(ToolbarItem), ToolbarItemOrder.Default, validateValue: (bo, o) =>
+ {
+ var order = (ToolbarItemOrder)o;
+ return order == ToolbarItemOrder.Default || order == ToolbarItemOrder.Primary || order == ToolbarItemOrder.Secondary;
+ });
+
+ static readonly BindableProperty PriorityProperty = BindableProperty.Create("Priority", typeof(int), typeof(ToolbarItem), 0);
+
+ public ToolbarItem()
+ {
+ }
+
+ public ToolbarItem(string name, string icon, Action activated, ToolbarItemOrder order = ToolbarItemOrder.Default, int priority = 0)
+ {
+ if (activated == null)
+ throw new ArgumentNullException("activated");
+
+ Text = name;
+ Icon = icon;
+ Clicked += (s, e) => activated();
+ Order = order;
+ Priority = priority;
+ }
+
+ [Obsolete("Name is obsolete as of version 1.3.0. Please use Text instead.")]
+ public string Name
+ {
+ get { return Text; }
+ set { Text = value; }
+ }
+
+ public ToolbarItemOrder Order
+ {
+ get { return (ToolbarItemOrder)GetValue(OrderProperty); }
+ set { SetValue(OrderProperty, value); }
+ }
+
+ public int Priority
+ {
+ get { return (int)GetValue(PriorityProperty); }
+ set { SetValue(PriorityProperty, value); }
+ }
+
+ [Obsolete("Activated is obsolete as of version 1.3.0. Please use Clicked instead.")]
+ public event EventHandler Activated
+ {
+ add { Clicked += value; }
+ remove { Clicked -= value; }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class ToolbarItemEventArgs : EventArgs
- {
- public ToolbarItemEventArgs(ToolbarItem item)
- {
- ToolbarItem = item;
- }
+ internal class ToolbarItemEventArgs : EventArgs
+ {
+ public ToolbarItemEventArgs(ToolbarItem item)
+ {
+ ToolbarItem = item;
+ }
- public ToolbarItem ToolbarItem { get; private set; }
- }
+ public ToolbarItem ToolbarItem { get; private set; }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal enum ToolbarItemOrder
- {
- Default,
- Primary,
- Secondary
- }
+ internal enum ToolbarItemOrder
+ {
+ Default,
+ Primary,
+ Secondary
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal class TrackableCollection<T> : ObservableCollection<T>
- {
- public event EventHandler Clearing;
+ internal class TrackableCollection<T> : ObservableCollection<T>
+ {
+ public event EventHandler Clearing;
- protected override void ClearItems()
- {
- Clearing?.Invoke(this, EventArgs.Empty);
- base.ClearItems();
- }
- }
+ protected override void ClearItems()
+ {
+ Clearing?.Invoke(this, EventArgs.Empty);
+ base.ClearItems();
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- internal abstract class TypeConverter
- {
- public virtual bool CanConvertFrom(Type sourceType)
- {
- if (sourceType == null)
- throw new ArgumentNullException(nameof(sourceType));
+ internal abstract class TypeConverter
+ {
+ public virtual bool CanConvertFrom(Type sourceType)
+ {
+ if (sourceType == null)
+ throw new ArgumentNullException(nameof(sourceType));
- return sourceType == typeof(string);
- }
+ return sourceType == typeof(string);
+ }
- [Obsolete("ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string) instead.")]
- public virtual object ConvertFrom(object o)
- {
- return null;
- }
+ [Obsolete("ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string) instead.")]
+ public virtual object ConvertFrom(object o)
+ {
+ return null;
+ }
- [Obsolete("ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string) instead.")]
- public virtual object ConvertFrom(CultureInfo culture, object o)
- {
- return null;
- }
+ [Obsolete("ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string) instead.")]
+ public virtual object ConvertFrom(CultureInfo culture, object o)
+ {
+ return null;
+ }
- public virtual object ConvertFromInvariantString(string value)
- {
+ public virtual object ConvertFromInvariantString(string value)
+ {
#pragma warning disable 0618 // retain until ConvertFrom removed
- return ConvertFrom(CultureInfo.InvariantCulture, value);
+ return ConvertFrom(CultureInfo.InvariantCulture, value);
#pragma warning restore
- }
- }
+ }
+ }
}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- [AttributeUsage(AttributeTargets.All)]
- internal sealed class TypeConverterAttribute : Attribute
- {
- internal static string[] TypeConvertersType = { "Tizen.NUI.Binding.TypeConverterAttribute", "System.ComponentModel.TypeConverterAttribute" };
+ [AttributeUsage(AttributeTargets.All)]
+ internal sealed class TypeConverterAttribute : Attribute
+ {
+ internal static string[] TypeConvertersType = { "Tizen.NUI.Binding.TypeConverterAttribute", "System.ComponentModel.TypeConverterAttribute" };
- public static readonly TypeConverterAttribute Default = new TypeConverterAttribute();
+ public static readonly TypeConverterAttribute Default = new TypeConverterAttribute();
- public TypeConverterAttribute()
- {
- ConverterTypeName = "";
- }
+ public TypeConverterAttribute()
+ {
+ ConverterTypeName = "";
+ }
- public TypeConverterAttribute(string typeName)
- {
- ConverterTypeName = typeName;
- }
+ public TypeConverterAttribute(string typeName)
+ {
+ ConverterTypeName = typeName;
+ }
- public TypeConverterAttribute(Type type)
- {
- ConverterTypeName = type.AssemblyQualifiedName;
- }
+ public TypeConverterAttribute(Type type)
+ {
+ ConverterTypeName = type.AssemblyQualifiedName;
+ }
- public string ConverterTypeName { get; }
+ public string ConverterTypeName { get; }
- public override bool Equals(object obj)
- {
- if (!(obj is TypeConverterAttribute))
- return false;
+ public override bool Equals(object obj)
+ {
+ if (!(obj is TypeConverterAttribute))
+ return false;
- return ((TypeConverterAttribute)obj).ConverterTypeName == ConverterTypeName;
- }
+ return ((TypeConverterAttribute)obj).ConverterTypeName == ConverterTypeName;
+ }
- public override int GetHashCode()
- {
- return ConverterTypeName.GetHashCode();
- }
- }
+ public override int GetHashCode()
+ {
+ return ConverterTypeName.GetHashCode();
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.TypeTypeConverter")]
- [Xaml.TypeConversion(typeof(Type))]
- internal sealed class TypeTypeConverter : TypeConverter, IExtendedTypeConverter
- {
- [Obsolete("IExtendedTypeConverter.ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string, IServiceProvider) instead.")]
- object IExtendedTypeConverter.ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider)
- {
- return ((IExtendedTypeConverter)this).ConvertFromInvariantString((string)value, serviceProvider);
- }
+ // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.TypeTypeConverter")]
+ [Xaml.TypeConversion(typeof(Type))]
+ internal sealed class TypeTypeConverter : TypeConverter, IExtendedTypeConverter
+ {
+ [Obsolete("IExtendedTypeConverter.ConvertFrom is obsolete as of version 2.2.0. Please use ConvertFromInvariantString (string, IServiceProvider) instead.")]
+ object IExtendedTypeConverter.ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider)
+ {
+ return ((IExtendedTypeConverter)this).ConvertFromInvariantString((string)value, serviceProvider);
+ }
- object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider)
- {
- if (serviceProvider == null)
- throw new ArgumentNullException("serviceProvider");
- var typeResolver = serviceProvider.GetService(typeof(IXamlTypeResolver)) as IXamlTypeResolver;
- if (typeResolver == null)
- throw new ArgumentException("No IXamlTypeResolver in IServiceProvider");
+ object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider)
+ {
+ if (serviceProvider == null)
+ throw new ArgumentNullException("serviceProvider");
+ var typeResolver = serviceProvider.GetService(typeof(IXamlTypeResolver)) as IXamlTypeResolver;
+ if (typeResolver == null)
+ throw new ArgumentException("No IXamlTypeResolver in IServiceProvider");
- return typeResolver.Resolve(value, serviceProvider);
- }
+ return typeResolver.Resolve(value, serviceProvider);
+ }
- public override object ConvertFromInvariantString(string value)
- {
- throw new NotImplementedException();
- }
- }
+ public override object ConvertFromInvariantString(string value)
+ {
+ throw new NotImplementedException();
+ }
+ }
}
namespace Tizen.NUI.Binding
{
- // [Xaml.ProvideCompiled("Tizen.NUI.Core.XamlC.UriTypeConverter")]
- [Xaml.TypeConversion(typeof(Uri))]
- internal class UriTypeConverter : TypeConverter
- {
- public override object ConvertFromInvariantString(string value)
- {
- if (string.IsNullOrWhiteSpace(value))
- return null;
- return new Uri(value, UriKind.RelativeOrAbsolute);
- }
+ // [Xaml.ProvideCompiled("Tizen.NUI.Core.XamlC.UriTypeConverter")]
+ [Xaml.TypeConversion(typeof(Uri))]
+ internal class UriTypeConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ return null;
+ return new Uri(value, UriKind.RelativeOrAbsolute);
+ }
- bool CanConvert(Type type)
- {
- if (type == typeof(string))
- return true;
- if (type == typeof(Uri))
- return true;
+ bool CanConvert(Type type)
+ {
+ if (type == typeof(string))
+ return true;
+ if (type == typeof(Uri))
+ return true;
- return false;
- }
- }
+ return false;
+ }
+ }
}
using System;
using System.Linq;
using System.Reflection;
+using System.Globalization;
using Tizen.NUI;
string[] parts = value.Split(',');
if (parts.Length == 2 )
{
- return new Vector2(float.Parse(parts[0].Trim()), float.Parse(parts[1].Trim()));
+ return new Vector2(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture));
}
}
string[] parts = value.Split(',');
if (parts.Length == 3 )
{
- return new Vector3(float.Parse(parts[0].Trim()), float.Parse(parts[1].Trim()), float.Parse(parts[2].Trim()));
+ return new Vector3(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture));
}
}
string[] parts = value.Split(',');
if (parts.Length == 4 )
{
- return new Vector4(float.Parse(parts[0].Trim()), float.Parse(parts[1].Trim()), float.Parse(parts[2].Trim()), float.Parse(parts[3].Trim()));
+ return new Vector4(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));
}
}
string[] parts = value.Split(',');
if (parts.Length == 2 )
{
- return new RelativeVector2(float.Parse(parts[0].Trim()), float.Parse(parts[1].Trim()));
+ return new RelativeVector2(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture));
}
}
string[] parts = value.Split(',');
if (parts.Length == 3 )
{
- return new RelativeVector3(float.Parse(parts[0].Trim()), float.Parse(parts[1].Trim()), float.Parse(parts[2].Trim()));
+ return new RelativeVector3(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture),
+ Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture));
}
}
string[] parts = value.Split(',');
if (parts.Length == 4 )
{
- return new RelativeVector4(float.Parse(parts[0].Trim()), float.Parse(parts[1].Trim()), float.Parse(parts[2].Trim()), float.Parse(parts[3].Trim()));
+ return new RelativeVector4(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));
}
}
namespace Tizen.NUI.Binding
{
- internal class WeakEventManager
- {
- readonly Dictionary<string, List<Subscription>> _eventHandlers =
- new Dictionary<string, List<Subscription>>();
-
- public void AddEventHandler<TEventArgs>(string eventName, EventHandler<TEventArgs> handler)
- where TEventArgs : EventArgs
- {
- if (IsNullOrEmpty(eventName))
- {
- throw new ArgumentNullException(nameof(eventName));
- }
-
- if (handler == null)
- {
- throw new ArgumentNullException(nameof(handler));
- }
-
- AddEventHandler(eventName, handler.Target, handler.GetMethodInfo());
- }
-
- public void AddEventHandler(string eventName, EventHandler handler)
- {
- if (IsNullOrEmpty(eventName))
- {
- throw new ArgumentNullException(nameof(eventName));
- }
-
- if (handler == null)
- {
- throw new ArgumentNullException(nameof(handler));
- }
-
- AddEventHandler(eventName, handler.Target, handler.GetMethodInfo());
- }
-
- public void HandleEvent(object sender, object args, string eventName)
- {
- var toRaise = new List<Tuple<object, MethodInfo>>();
- var toRemove = new List<Subscription>();
-
- List<Subscription> target;
- if (_eventHandlers.TryGetValue(eventName, out target))
- {
- foreach (Subscription subscription in target)
- {
- bool isStatic = subscription.Subscriber == null;
- if (isStatic)
- {
- // For a static method, we'll just pass null as the first parameter of MethodInfo.Invoke
- toRaise.Add(Tuple.Create<object, MethodInfo>(null, subscription.Handler));
- continue;
- }
-
- object subscriber = subscription.Subscriber.Target;
-
- if (subscriber == null)
- {
- // The subscriber was collected, so there's no need to keep this subscription around
- toRemove.Add(subscription);
- }
- else
- {
- toRaise.Add(Tuple.Create(subscriber, subscription.Handler));
- }
- }
-
- foreach (Subscription subscription in toRemove)
- {
- target.Remove(subscription);
- }
- }
-
- foreach (Tuple<object, MethodInfo> tuple in toRaise)
- {
- tuple.Item2.Invoke(tuple.Item1, new[] { sender, args });
- }
- }
-
- public void RemoveEventHandler<TEventArgs>(string eventName, EventHandler<TEventArgs> handler)
- where TEventArgs : EventArgs
- {
- if (IsNullOrEmpty(eventName))
- {
- throw new ArgumentNullException(nameof(eventName));
- }
-
- if (handler == null)
- {
- throw new ArgumentNullException(nameof(handler));
- }
-
- RemoveEventHandler(eventName, handler.Target, handler.GetMethodInfo());
- }
-
- public void RemoveEventHandler(string eventName, EventHandler handler)
- {
- if (IsNullOrEmpty(eventName))
- {
- throw new ArgumentNullException(nameof(eventName));
- }
-
- if (handler == null)
- {
- throw new ArgumentNullException(nameof(handler));
- }
-
- RemoveEventHandler(eventName, handler.Target, handler.GetMethodInfo());
- }
-
- void AddEventHandler(string eventName, object handlerTarget, MethodInfo methodInfo)
- {
- List<Subscription> targets;
- if (!_eventHandlers.TryGetValue(eventName, out targets))
- {
- targets = new List<Subscription>();
- _eventHandlers.Add(eventName, targets);
- }
-
- if (handlerTarget == null)
- {
- // This event handler is a static method
- targets.Add(new Subscription(null, methodInfo));
- return;
- }
-
- targets.Add(new Subscription(new WeakReference(handlerTarget), methodInfo));
- }
-
- void RemoveEventHandler(string eventName, object handlerTarget, MemberInfo methodInfo)
- {
- List<Subscription> subscriptions;
- if (!_eventHandlers.TryGetValue(eventName, out subscriptions))
- {
- return;
- }
-
- for (int n = subscriptions.Count; n > 0; n--)
- {
- Subscription current = subscriptions[n - 1];
-
- if (current.Subscriber != handlerTarget
- || current.Handler.Name != methodInfo.Name)
- {
- continue;
- }
-
- subscriptions.Remove(current);
- }
- }
-
- struct Subscription
- {
- public Subscription(WeakReference subscriber, MethodInfo handler)
- {
- if (handler == null)
- {
- throw new ArgumentNullException(nameof(handler));
- }
-
- Subscriber = subscriber;
- Handler = handler;
- }
-
- public readonly WeakReference Subscriber;
- public readonly MethodInfo Handler;
- }
- }
+ internal class WeakEventManager
+ {
+ readonly Dictionary<string, List<Subscription>> _eventHandlers =
+ new Dictionary<string, List<Subscription>>();
+
+ public void AddEventHandler<TEventArgs>(string eventName, EventHandler<TEventArgs> handler)
+ where TEventArgs : EventArgs
+ {
+ if (IsNullOrEmpty(eventName))
+ {
+ throw new ArgumentNullException(nameof(eventName));
+ }
+
+ if (handler == null)
+ {
+ throw new ArgumentNullException(nameof(handler));
+ }
+
+ AddEventHandler(eventName, handler.Target, handler.GetMethodInfo());
+ }
+
+ public void AddEventHandler(string eventName, EventHandler handler)
+ {
+ if (IsNullOrEmpty(eventName))
+ {
+ throw new ArgumentNullException(nameof(eventName));
+ }
+
+ if (handler == null)
+ {
+ throw new ArgumentNullException(nameof(handler));
+ }
+
+ AddEventHandler(eventName, handler.Target, handler.GetMethodInfo());
+ }
+
+ public void HandleEvent(object sender, object args, string eventName)
+ {
+ var toRaise = new List<Tuple<object, MethodInfo>>();
+ var toRemove = new List<Subscription>();
+
+ List<Subscription> target;
+ if (_eventHandlers.TryGetValue(eventName, out target))
+ {
+ foreach (Subscription subscription in target)
+ {
+ bool isStatic = subscription.Subscriber == null;
+ if (isStatic)
+ {
+ // For a static method, we'll just pass null as the first parameter of MethodInfo.Invoke
+ toRaise.Add(Tuple.Create<object, MethodInfo>(null, subscription.Handler));
+ continue;
+ }
+
+ object subscriber = subscription.Subscriber.Target;
+
+ if (subscriber == null)
+ {
+ // The subscriber was collected, so there's no need to keep this subscription around
+ toRemove.Add(subscription);
+ }
+ else
+ {
+ toRaise.Add(Tuple.Create(subscriber, subscription.Handler));
+ }
+ }
+
+ foreach (Subscription subscription in toRemove)
+ {
+ target.Remove(subscription);
+ }
+ }
+
+ foreach (Tuple<object, MethodInfo> tuple in toRaise)
+ {
+ tuple.Item2.Invoke(tuple.Item1, new[] { sender, args });
+ }
+ }
+
+ public void RemoveEventHandler<TEventArgs>(string eventName, EventHandler<TEventArgs> handler)
+ where TEventArgs : EventArgs
+ {
+ if (IsNullOrEmpty(eventName))
+ {
+ throw new ArgumentNullException(nameof(eventName));
+ }
+
+ if (handler == null)
+ {
+ throw new ArgumentNullException(nameof(handler));
+ }
+
+ RemoveEventHandler(eventName, handler.Target, handler.GetMethodInfo());
+ }
+
+ public void RemoveEventHandler(string eventName, EventHandler handler)
+ {
+ if (IsNullOrEmpty(eventName))
+ {
+ throw new ArgumentNullException(nameof(eventName));
+ }
+
+ if (handler == null)
+ {
+ throw new ArgumentNullException(nameof(handler));
+ }
+
+ RemoveEventHandler(eventName, handler.Target, handler.GetMethodInfo());
+ }
+
+ void AddEventHandler(string eventName, object handlerTarget, MethodInfo methodInfo)
+ {
+ List<Subscription> targets;
+ if (!_eventHandlers.TryGetValue(eventName, out targets))
+ {
+ targets = new List<Subscription>();
+ _eventHandlers.Add(eventName, targets);
+ }
+
+ if (handlerTarget == null)
+ {
+ // This event handler is a static method
+ targets.Add(new Subscription(null, methodInfo));
+ return;
+ }
+
+ targets.Add(new Subscription(new WeakReference(handlerTarget), methodInfo));
+ }
+
+ void RemoveEventHandler(string eventName, object handlerTarget, MemberInfo methodInfo)
+ {
+ List<Subscription> subscriptions;
+ if (!_eventHandlers.TryGetValue(eventName, out subscriptions))
+ {
+ return;
+ }
+
+ for (int n = subscriptions.Count; n > 0; n--)
+ {
+ Subscription current = subscriptions[n - 1];
+
+ if (current.Subscriber != handlerTarget
+ || current.Handler.Name != methodInfo.Name)
+ {
+ continue;
+ }
+
+ subscriptions.Remove(current);
+ }
+ }
+
+ struct Subscription
+ {
+ public Subscription(WeakReference subscriber, MethodInfo handler)
+ {
+ if (handler == null)
+ {
+ throw new ArgumentNullException(nameof(handler));
+ }
+
+ Subscriber = subscriber;
+ Handler = handler;
+ }
+
+ public readonly WeakReference Subscriber;
+ public readonly MethodInfo Handler;
+ }
+ }
}
\ No newline at end of file
using System.Runtime.InteropServices;
using Tizen.NUI.BaseComponents;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Reflection;
+ using System.Xml;
+ using Tizen.NUI.Binding.Internals;
+ using Tizen.NUI.Binding;
+ using System.Globalization;
+ using Tizen.NUI.Xaml.Internals;
+
/// <summary>
/// Animation can be used to animate the properties of any number of objects, typically view.<br />
/// If the "Finished" event is connected to a member function of an object, it must be disconnected before the object is destroyed.<br />
AnimateTo(_prop, val);
}
}
+ private string[] _properties = null;
+ public string[] Properties
+ {
+ get
+ {
+ return _properties;
+ }
+ set
+ {
+ _properties = value;
+ }
+ }
+
+ private string[] _destValue = null;
+ public string[] DestValue
+ {
+ get
+ {
+ return _destValue;
+ }
+ set
+ {
+ _destValue = value;
+ }
+ }
+
+ private int[] _startTime = null;
+ public int[] StartTime
+ {
+ get
+ {
+ return _startTime;
+ }
+ set
+ {
+ _startTime = value;
+ }
+ }
+
+ private int[] _endTime = null;
+ public int[] EndTime
+ {
+ get
+ {
+ return _endTime;
+ }
+ set
+ {
+ _endTime = value;
+ }
+ }
+
+ public void PlayAnimateTo(View target)
+ {
+ if (_properties.Length == _destValue.Length && _startTime.Length == _endTime.Length && _properties.Length == _startTime.Length)
+ {
+ int length = _properties.Length;
+ for (int index = 0; index < length; index++)
+ {
+ //object destinationValue = _destValue[index];
+ var elementType = target.GetType();
+ PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == _properties[index]);
+ //var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
+ if (propertyInfo != null)
+ {
+ object destinationValue = ConvertTo(_destValue[index], propertyInfo.PropertyType);
+
+ if(destinationValue != null)
+ {
+ AnimateTo(target, _properties[index], destinationValue, _startTime[index], _endTime[index]);
+ }
+ }
+ }
+ Play();
+ }
+ }
+
+ internal object ConvertTo(object value, Type toType)
+ {
+ Func<object> getConverter = () =>
+ {
+ MemberInfo memberInfo;
+
+ string converterTypeName = GetTypeConverterTypeName(toType.GetTypeInfo().CustomAttributes);
+ if (converterTypeName == null)
+ return null;
+
+ Type convertertype = Type.GetType(converterTypeName);
+ return Activator.CreateInstance(convertertype);
+ };
+
+ return ConvertTo(value, toType, getConverter);
+ }
+
+ internal object ConvertTo(object value, Type toType, Func<object> getConverter)
+ {
+ if (value == null)
+ return null;
+
+ var str = value as string;
+ if (str != null)
+ {
+ //If there's a [TypeConverter], use it
+ object converter = getConverter?.Invoke();
+ var xfTypeConverter = converter as TypeConverter;
+ 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 });
+ }
+
+ //If the type is nullable, as the value is not null, it's safe to assume we want the built-in conversion
+ if (toType.GetTypeInfo().IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>))
+ toType = Nullable.GetUnderlyingType(toType);
+
+ //Obvious Built-in conversions
+ if (toType.GetTypeInfo().IsEnum)
+ return Enum.Parse(toType, str, true);
+ if (toType == typeof(SByte))
+ return SByte.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Int16))
+ return Int16.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Int32))
+ return Int32.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Int64))
+ return Int64.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Byte))
+ return Byte.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(UInt16))
+ return UInt16.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(UInt32))
+ return UInt32.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(UInt64))
+ return UInt64.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Single))
+ return Single.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Double))
+ return Double.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Boolean))
+ return Boolean.Parse(str);
+ if (toType == typeof(TimeSpan))
+ return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(DateTime))
+ return DateTime.Parse(str, CultureInfo.InvariantCulture);
+ if (toType == typeof(Char))
+ {
+ char c = '\0';
+ Char.TryParse(str, out c);
+ return c;
+ }
+ if (toType == typeof(String) && str.StartsWith("{}", StringComparison.Ordinal))
+ return str.Substring(2);
+ if (toType == typeof(String))
+ return value;
+ if (toType == typeof(Decimal))
+ return Decimal.Parse(str, CultureInfo.InvariantCulture);
+ }
+
+ //if the value is not assignable and there's an implicit conversion, convert
+ if (value != null && !toType.IsAssignableFrom(value.GetType()))
+ {
+ var opImplicit = GetImplicitConversionOperator(value.GetType(), value.GetType(), toType)
+ ?? GetImplicitConversionOperator(toType, value.GetType(), toType);
+ //var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
+ // ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);
+
+ if (opImplicit != null)
+ {
+ value = opImplicit.Invoke(null, new[] { value });
+ return value;
+ }
+ }
+
+ var nativeValueConverterService = DependencyService.Get<INativeValueConverterService>();
+
+ object nativeValue = null;
+ if (nativeValueConverterService != null && nativeValueConverterService.ConvertTo(value, toType, out nativeValue))
+ return nativeValue;
+
+ return value;
+ }
+
+ internal string GetTypeConverterTypeName(IEnumerable<CustomAttributeData> attributes)
+ {
+ var converterAttribute =
+ attributes.FirstOrDefault(cad => TypeConverterAttribute.TypeConvertersType.Contains(cad.AttributeType.FullName));
+ if (converterAttribute == null)
+ return null;
+ if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(string))
+ return (string)converterAttribute.ConstructorArguments[0].Value;
+ if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(Type))
+ return ((Type)converterAttribute.ConstructorArguments[0].Value).AssemblyQualifiedName;
+ return null;
+ }
+
+ internal MethodInfo GetImplicitConversionOperator(Type onType, Type fromType, Type toType)
+ {
+#if NETSTANDARD1_0
+ var mi = onType.GetRuntimeMethod("op_Implicit", new[] { fromType });
+#else
+ var bindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
+ var mi = onType.GetMethod("op_Implicit", bindingFlags, null, new[] { fromType }, null);
+#endif
+ if (mi == null) return null;
+ if (!mi.IsSpecialName) return null;
+ if (!mi.IsPublic) return null;
+ if (!mi.IsStatic) return null;
+ if (!toType.IsAssignableFrom(mi.ReturnType)) return null;
+
+ return mi;
+ }
+
/// <summary>
/// Animates a property to a destination value.<br />
* limitations under the License.
*
*/
+using System.ComponentModel;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
/// <since_tizen> 3 </since_tizen>
public class CustomView : ViewWrapper
{
+ /// 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 FocusNavigationSupportProperty = BindableProperty.Create("FocusNavigationSupport", typeof(bool), typeof(CustomView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var customView = (CustomView)bindable;
+ if (newValue != null)
+ {
+ customView.SetKeyboardNavigationSupport((bool)newValue);
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var customView = (CustomView)bindable;
+ return customView.IsKeyboardNavigationSupported();
+ });
+ /// 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 FocusGroupProperty = BindableProperty.Create("FocusGroup", typeof(bool), typeof(CustomView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var customView = (CustomView)bindable;
+ if (newValue != null)
+ {
+ customView.SetAsKeyboardFocusGroup((bool)newValue);
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var customView = (CustomView)bindable;
+ return customView.IsKeyboardFocusGroup();
+ });
+
/// <summary>
/// Create an instance of customView.
/// </summary>
{
get
{
- return IsKeyboardNavigationSupported();
+ return (bool)GetValue(FocusNavigationSupportProperty);
}
set
{
- SetKeyboardNavigationSupport(value);
+ SetValue(FocusNavigationSupportProperty, value);
}
}
{
get
{
- return IsKeyboardFocusGroup();
+ return (bool)GetValue(FocusGroupProperty);
}
set
{
- SetAsKeyboardFocusGroup(value);
+ SetValue(FocusGroupProperty, value);
}
}
* limitations under the License.
*
*/
+using System;
+using System.ComponentModel;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
/// <since_tizen> 3 </since_tizen>
public class FlexContainer : View
{
+ /// 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 ContentDirectionProperty = BindableProperty.Create("ContentDirection", typeof(ContentDirectionType), typeof(FlexContainer), ContentDirectionType.Inherit, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.CONTENT_DIRECTION, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ Console.WriteLine("FlexContainer ContentDirectionProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.CONTENT_DIRECTION).Get(out temp);
+ return (ContentDirectionType)temp;
+ });
+ /// 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 FlexDirectionProperty = BindableProperty.Create("FlexDirection", typeof(FlexDirectionType), typeof(FlexContainer), FlexDirectionType.Column, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.FLEX_DIRECTION, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ Console.WriteLine("FlexContainer FlexDirectionProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.FLEX_DIRECTION).Get(out temp);
+ return (FlexDirectionType)temp;
+ });
+ /// 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 FlexWrapProperty = BindableProperty.Create("FlexWrap", typeof(WrapType), typeof(FlexContainer), WrapType.NoWrap, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.FLEX_WRAP, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ Console.WriteLine("FlexContainer FlexWrapProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.FLEX_WRAP).Get(out temp);
+ return (WrapType)temp;
+ });
+ /// 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 JustifyContentProperty = BindableProperty.Create("JustifyContent", typeof(Justification), typeof(FlexContainer), Justification.JustifyFlexStart, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.JUSTIFY_CONTENT, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ Console.WriteLine("FlexContainer JustifyContentProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.JUSTIFY_CONTENT).Get(out temp);
+ return (Justification)temp;
+ });
+ /// 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 AlignItemsProperty = BindableProperty.Create("AlignItems", typeof(Alignment), typeof(FlexContainer), Alignment.AlignAuto, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.ALIGN_ITEMS, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ Console.WriteLine("FlexContainer AlignItemsProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.ALIGN_ITEMS).Get(out temp);
+ return (Alignment)temp;
+ });
+ /// 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 AlignContentProperty = BindableProperty.Create("AlignContent", typeof(Alignment), typeof(FlexContainer), Alignment.AlignAuto, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(flexContainer.swigCPtr, FlexContainer.Property.ALIGN_CONTENT, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ Console.WriteLine("FlexContainer AlignContentProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ var flexContainer = (FlexContainer)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(flexContainer.swigCPtr, FlexContainer.Property.ALIGN_CONTENT).Get(out temp);
+ return (Alignment)temp;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal FlexContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.FlexContainer_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- int temp = 0;
- GetProperty(FlexContainer.Property.CONTENT_DIRECTION).Get(out temp);
- return (ContentDirectionType)temp;
+ return (ContentDirectionType)GetValue(ContentDirectionProperty);
}
set
{
- SetProperty(FlexContainer.Property.CONTENT_DIRECTION, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(ContentDirectionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(FlexContainer.Property.FLEX_DIRECTION).Get(out temp);
- return (FlexDirectionType)temp;
+ return (FlexDirectionType)GetValue(FlexDirectionProperty);
}
set
{
- SetProperty(FlexContainer.Property.FLEX_DIRECTION, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(FlexDirectionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(FlexContainer.Property.FLEX_WRAP).Get(out temp);
- return (WrapType)temp;
+ return (WrapType)GetValue(FlexWrapProperty);
}
set
{
- SetProperty(FlexContainer.Property.FLEX_WRAP, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(FlexWrapProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(FlexContainer.Property.JUSTIFY_CONTENT).Get(out temp);
- return (Justification)temp;
+ return (Justification)GetValue(JustifyContentProperty);
}
set
{
- SetProperty(FlexContainer.Property.JUSTIFY_CONTENT, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(JustifyContentProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(FlexContainer.Property.ALIGN_ITEMS).Get(out temp);
- return (Alignment)temp;
+ return (Alignment)GetValue(AlignItemsProperty);
}
set
{
- SetProperty(FlexContainer.Property.ALIGN_ITEMS, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(AlignItemsProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(FlexContainer.Property.ALIGN_CONTENT).Get(out temp);
- return (Alignment)temp;
+ return (Alignment)GetValue(AlignContentProperty);
}
set
{
- SetProperty(FlexContainer.Property.ALIGN_CONTENT, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(AlignContentProperty, value);
NotifyPropertyChanged();
}
}
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
/// An instance of ImageView can be created using a URL or an image instance.<br />
/// </summary>
/// <since_tizen> 3 </since_tizen>
+ [ContentProperty("ResourceUrl")]
public class ImageView : View
{
+ /// 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 ResourceUrlProperty = BindableProperty.Create("ResourceUrl", typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ imageView._url = (newValue == null? "" : (string)newValue);
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView ResourceUrlProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(out imageView._url);
+ return imageView._url;
+ });
+ /// 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 ImageProperty = BindableProperty.Create("Image", typeof(PropertyMap), typeof(ImageView), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ if (imageView._border == null)
+ {
+ Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ }
+ Console.WriteLine("ImageView ImageProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (imageView._border == null)
+ {
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(temp);
+ return temp;
+ }
+ else
+ {
+ return null;
+ }
+ });
+ /// 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 PreMultipliedAlphaProperty = BindableProperty.Create("PreMultipliedAlpha", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ Console.WriteLine("ImageView PreMultipliedAlphaProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
+ return temp;
+ });
+ /// 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 PixelAreaProperty = BindableProperty.Create("PixelArea", typeof(RelativeVector4), typeof(ImageView), new RelativeVector4(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
+ }
+ Console.WriteLine("ImageView PixelAreaProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA).Get(temp);
+ RelativeVector4 relativeTemp = new RelativeVector4(temp.X, temp.Y, temp.Z, temp.W);
+ return relativeTemp;
+ });
+ /// 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 BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), new Rectangle(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ imageView._border = (Rectangle)newValue;
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView BorderProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ return imageView._border;
+ });
+ /// 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 BorderOnlyProperty = BindableProperty.Create("BorderOnly", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ imageView._borderOnly = (bool)newValue;
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView BorderOnlyProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ return imageView._borderOnly ?? false;
+ });
+ /// 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 SynchronosLoadingProperty = BindableProperty.Create("SynchronosLoading", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ imageView._synchronousLoading = (bool)newValue;
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView SynchronosLoadingProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ return imageView._synchronousLoading ?? false;
+ });
+ /// 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 OrientationCorrectionProperty = BindableProperty.Create("OrientationCorrection", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var imageView = (ImageView)bindable;
+ if (newValue != null)
+ {
+ imageView._orientationCorrection = (bool)newValue;
+ imageView.UpdateImage();
+ }
+ Console.WriteLine("ImageView OrientationCorrectionProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var imageView = (ImageView)bindable;
+ return imageView._orientationCorrection ?? false;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
/// <since_tizen> 3 </since_tizen>
public ImageView() : this(NDalicPINVOKE.ImageView_New__SWIG_0(), true)
{
+ base.InitXamlResource();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
}
+
/// <summary>
/// Creates an initialized ImageView from a URL to an image resource.<br />
/// If the string is empty, ImageView will not display anything.<br />
{
get
{
- GetProperty(ImageView.Property.IMAGE).Get(out _url);
- return _url;
+ return (string)GetValue(ResourceUrlProperty);
}
set
{
- _url = (value == null? "" : value);
- UpdateImage();
+ SetValue(ResourceUrlProperty, value);
NotifyPropertyChanged();
}
}
{
if (_border == null)
{
- PropertyMap temp = new PropertyMap();
- GetProperty(ImageView.Property.IMAGE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(ImageProperty);
}
else
{
{
if (_border == null)
{
- if(_url != null) { value.Add("url", new PropertyValue(_url)); }
- SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(ImageProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
- return temp;
+ return (bool)GetValue(PreMultipliedAlphaProperty);
}
set
{
- SetProperty(ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue(value));
+ SetValue(PreMultipliedAlphaProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(ImageView.Property.PIXEL_AREA).Get(temp);
- return temp;
+ return (RelativeVector4)GetValue(PixelAreaProperty);
}
set
{
- SetProperty(ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue(value));
+ SetValue(PixelAreaProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- return _border;
+ return (Rectangle)GetValue(BorderProperty);
}
set
{
- _border = value;
- UpdateImage();
+ SetValue(BorderProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- return _borderOnly ?? false;
+ return (bool)GetValue(BorderOnlyProperty);
}
set
{
- _borderOnly = value;
- UpdateImage();
+ SetValue(BorderOnlyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- return _synchronousLoading ?? false;
+ return (bool)GetValue(SynchronosLoadingProperty);
}
set
{
- _synchronousLoading = value;
- UpdateImage();
+ SetValue(SynchronosLoadingProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- return _orientationCorrection ?? false;
+ return (bool)GetValue(OrientationCorrectionProperty);
}
set
{
- _orientationCorrection = value;
- UpdateImage();
+ SetValue(OrientationCorrectionProperty, value);
NotifyPropertyChanged();
}
}
* limitations under the License.
*
*/
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
-
- using System;
- using System.Runtime.InteropServices;
-
/// <summary>
/// Base class for derived Scrollables that contains actors that can be scrolled manually
/// (via touch) or automatically.
/// <since_tizen> 3 </since_tizen>
public class Scrollable : View
{
+ /// 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 OvershootEffectColorProperty = BindableProperty.Create("OvershootEffectColor", typeof(Vector4), typeof(Scrollable), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.OVERSHOOT_EFFECT_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.OVERSHOOT_EFFECT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 OvershootAnimationSpeedProperty = BindableProperty.Create("OvershootAnimationSpeed", typeof(float), typeof(Scrollable), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.OVERSHOOT_ANIMATION_SPEED, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.OVERSHOOT_ANIMATION_SPEED).Get(out temp);
+ return temp;
+ });
+ /// 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 OvershootEnabledProperty = BindableProperty.Create("OvershootEnabled", typeof(bool), typeof(Scrollable), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.OVERSHOOT_ENABLED, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.OVERSHOOT_ENABLED).Get(out temp);
+ return temp;
+ });
+ /// 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 OvershootSizeProperty = BindableProperty.Create("OvershootSize", typeof(Vector2), typeof(Scrollable), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.OVERSHOOT_SIZE, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.OVERSHOOT_SIZE).Get(temp);
+ return temp;
+ });
+ /// 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 ScrollToAlphaFunctionProperty = BindableProperty.Create("ScrollToAlphaFunction", typeof(int), typeof(Scrollable), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollRelativePositionProperty = BindableProperty.Create("ScrollRelativePosition", typeof(Vector2), typeof(Scrollable), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.SCROLL_RELATIVE_POSITION, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.SCROLL_RELATIVE_POSITION).Get(temp);
+ return temp;
+ });
+ /// 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 ScrollPositionMinProperty = BindableProperty.Create("ScrollPositionMin", typeof(Vector2), typeof(Scrollable), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.SCROLL_POSITION_MIN, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.SCROLL_POSITION_MIN).Get(temp);
+ return temp;
+ });
+ /// 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 ScrollPositionMaxProperty = BindableProperty.Create("ScrollPositionMax", typeof(Vector2), typeof(Scrollable), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.SCROLL_POSITION_MAX, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.SCROLL_POSITION_MAX).Get(temp);
+ return temp;
+ });
+ /// 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 CanScrollVerticalProperty = BindableProperty.Create("CanScrollVertical", typeof(bool), typeof(Scrollable), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.CAN_SCROLL_VERTICAL, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.CAN_SCROLL_VERTICAL).Get(out temp);
+ return temp;
+ });
+ /// 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 CanScrollHorizontalProperty = BindableProperty.Create("CanScrollHorizontal", typeof(bool), typeof(Scrollable), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollable.swigCPtr, Scrollable.Property.CAN_SCROLL_HORIZONTAL, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollable = (Scrollable)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(scrollable.swigCPtr, Scrollable.Property.CAN_SCROLL_HORIZONTAL).Get(out temp);
+ return temp;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal Scrollable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Scrollable_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(OvershootEffectColorProperty);
}
set
{
- SetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(OvershootEffectColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED).Get(out temp);
- return temp;
+ return (float)GetValue(OvershootAnimationSpeedProperty);
}
set
{
- SetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED, new Tizen.NUI.PropertyValue(value));
+ SetValue(OvershootAnimationSpeedProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(Scrollable.Property.OVERSHOOT_ENABLED).Get(out temp);
- return temp;
+ return (bool)GetValue(OvershootEnabledProperty);
}
set
{
- SetProperty(Scrollable.Property.OVERSHOOT_ENABLED, new Tizen.NUI.PropertyValue(value));
+ SetValue(OvershootEnabledProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(Scrollable.Property.OVERSHOOT_SIZE).Get(temp);
- return temp;
+ return (Vector2)GetValue(OvershootSizeProperty);
}
set
{
- SetProperty(Scrollable.Property.OVERSHOOT_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(OvershootSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION).Get(out temp);
- return temp;
+ return (int)GetValue(ScrollToAlphaFunctionProperty);
}
set
{
- SetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollToAlphaFunctionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollRelativePositionProperty);
}
set
{
- SetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollRelativePositionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(Scrollable.Property.SCROLL_POSITION_MIN).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollPositionMinProperty);
}
set
{
- SetProperty(Scrollable.Property.SCROLL_POSITION_MIN, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollPositionMinProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(Scrollable.Property.SCROLL_POSITION_MAX).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollPositionMaxProperty);
}
set
{
- SetProperty(Scrollable.Property.SCROLL_POSITION_MAX, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollPositionMaxProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL).Get(out temp);
- return temp;
+ return (bool)GetValue(CanScrollVerticalProperty);
}
set
{
- SetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(CanScrollVerticalProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL).Get(out temp);
- return temp;
+ return (bool)GetValue(CanScrollHorizontalProperty);
}
set
{
- SetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(CanScrollHorizontalProperty, value);
NotifyPropertyChanged();
}
}
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
/// <since_tizen> 3 </since_tizen>
public class TableView : View
{
+ /// 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 RowsProperty = BindableProperty.Create("Rows", typeof(int), typeof(TableView), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var tableView = (TableView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(tableView.swigCPtr, TableView.Property.ROWS, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var tableView = (TableView)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(tableView.swigCPtr, TableView.Property.ROWS).Get(out temp);
+ return temp;
+ });
+ /// 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 ColumnsProperty = BindableProperty.Create("Columns", typeof(int), typeof(TableView), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var tableView = (TableView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(tableView.swigCPtr, TableView.Property.COLUMNS, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var tableView = (TableView)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(tableView.swigCPtr, TableView.Property.COLUMNS).Get(out temp);
+ return temp;
+ });
+ /// 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 CellPaddingProperty = BindableProperty.Create("CellPadding", typeof(Vector2), typeof(TableView), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var tableView = (TableView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(tableView.swigCPtr, TableView.Property.CELL_PADDING, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var tableView = (TableView)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(tableView.swigCPtr, TableView.Property.CELL_PADDING).Get(temp);
+ return temp;
+ });
+ /// 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 LayoutRowsProperty = BindableProperty.Create("LayoutRows", typeof(PropertyMap), typeof(TableView), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var tableView = (TableView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(tableView.swigCPtr, TableView.Property.LAYOUT_ROWS, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var tableView = (TableView)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(tableView.swigCPtr, TableView.Property.LAYOUT_ROWS).Get(temp);
+ return temp;
+ });
+ /// 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 LayoutColumnsProperty = BindableProperty.Create("LayoutColumns", typeof(PropertyMap), typeof(TableView), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var tableView = (TableView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(tableView.swigCPtr, TableView.Property.LAYOUT_COLUMNS, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var tableView = (TableView)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(tableView.swigCPtr, TableView.Property.LAYOUT_COLUMNS).Get(temp);
+ return temp;
+ });
+
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal TableView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.TableView_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- int temp = 0;
- GetProperty(TableView.Property.ROWS).Get(out temp);
- return temp;
+ return (int)GetValue(RowsProperty);
}
set
{
- SetProperty(TableView.Property.ROWS, new Tizen.NUI.PropertyValue(value));
+ SetValue(RowsProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(TableView.Property.COLUMNS).Get(out temp);
- return temp;
+ return (int)GetValue(ColumnsProperty);
}
set
{
- SetProperty(TableView.Property.COLUMNS, new Tizen.NUI.PropertyValue(value));
+ SetValue(ColumnsProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(TableView.Property.CELL_PADDING).Get(temp);
- return temp;
+ return (Vector2)GetValue(CellPaddingProperty);
}
set
{
- SetProperty(TableView.Property.CELL_PADDING, new Tizen.NUI.PropertyValue(value));
+ SetValue(CellPaddingProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TableView.Property.LAYOUT_ROWS).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(LayoutRowsProperty);
}
set
{
- SetProperty(TableView.Property.LAYOUT_ROWS, new Tizen.NUI.PropertyValue(value));
+ SetValue(LayoutRowsProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TableView.Property.LAYOUT_COLUMNS).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(LayoutColumnsProperty);
}
set
{
- SetProperty(TableView.Property.LAYOUT_COLUMNS, new Tizen.NUI.PropertyValue(value));
+ SetValue(LayoutColumnsProperty, value);
NotifyPropertyChanged();
}
}
using System.Runtime.InteropServices;
using System.Globalization;
using System.ComponentModel;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
/// A control which provides a multi-line editable text editor.
/// </summary>
/// <since_tizen> 3 </since_tizen>
+ [ContentProperty("Text")]
public class TextEditor : View
{
+ /// 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 TextProperty = BindableProperty.Create("Text", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.TEXT, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.TEXT).Get(out temp);
+ return temp;
+ });
+ /// 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 TextColorProperty = BindableProperty.Create("TextColor", typeof(Vector4), typeof(TextEditor), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.TEXT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 FontFamilyProperty = BindableProperty.Create("FontFamily", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.FONT_FAMILY).Get(out temp);
+ return temp;
+ });
+ /// 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 FontStyleProperty = BindableProperty.Create("FontStyle", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.FONT_STYLE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.FONT_STYLE).Get(temp);
+ return temp;
+ });
+ /// 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 PointSizeProperty = BindableProperty.Create("PointSize", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.POINT_SIZE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.POINT_SIZE).Get(out temp);
+ return temp;
+ });
+ /// 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 HorizontalAlignmentProperty = BindableProperty.Create("HorizontalAlignment", typeof(HorizontalAlignment), typeof(TextEditor), HorizontalAlignment.Begin, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
+ {
+ NUILog.Error("HorizontalAlignment get error!");
+ }
+
+ switch (temp)
+ {
+ case "BEGIN":
+ return HorizontalAlignment.Begin;
+ case "CENTER":
+ return HorizontalAlignment.Center;
+ case "END":
+ return HorizontalAlignment.End;
+ default:
+ return HorizontalAlignment.Begin;
+ }
+ });
+ /// 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 ScrollThresholdProperty = BindableProperty.Create("ScrollThreshold", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SCROLL_THRESHOLD, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SCROLL_THRESHOLD).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollSpeedProperty = BindableProperty.Create("ScrollSpeed", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SCROLL_SPEED, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SCROLL_SPEED).Get(out temp);
+ return temp;
+ });
+ /// 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 PrimaryCursorColorProperty = BindableProperty.Create("PrimaryCursorColor", typeof(Vector4), typeof(TextEditor), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.PRIMARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.PRIMARY_CURSOR_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 SecondaryCursorColorProperty = BindableProperty.Create("SecondaryCursorColor", typeof(Vector4), typeof(TextEditor), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SECONDARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SECONDARY_CURSOR_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 EnableCursorBlinkProperty = BindableProperty.Create("EnableCursorBlink", typeof(bool), typeof(TextEditor), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_CURSOR_BLINK, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_CURSOR_BLINK).Get(out temp);
+ return temp;
+ });
+ /// 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 CursorBlinkIntervalProperty = BindableProperty.Create("CursorBlinkInterval", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.CURSOR_BLINK_INTERVAL, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.CURSOR_BLINK_INTERVAL).Get(out temp);
+ return temp;
+ });
+ /// 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 CursorBlinkDurationProperty = BindableProperty.Create("CursorBlinkDuration", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.CURSOR_BLINK_DURATION, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.CURSOR_BLINK_DURATION).Get(out temp);
+ return temp;
+ });
+ /// 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 CursorWidthProperty = BindableProperty.Create("CursorWidth", typeof(int), typeof(TextEditor), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.CURSOR_WIDTH, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.CURSOR_WIDTH).Get(out temp);
+ return temp;
+ });
+ /// 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 GrabHandleImageProperty = BindableProperty.Create("GrabHandleImage", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.GRAB_HANDLE_IMAGE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.GRAB_HANDLE_IMAGE).Get(out temp);
+ return temp;
+ });
+ /// 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 GrabHandlePressedImageProperty = BindableProperty.Create("GrabHandlePressedImage", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.GRAB_HANDLE_PRESSED_IMAGE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.GRAB_HANDLE_PRESSED_IMAGE).Get(out temp);
+ return temp;
+ });
+ /// 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 SelectionHandleImageLeftProperty = BindableProperty.Create("SelectionHandleImageLeft", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_IMAGE_LEFT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_IMAGE_LEFT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandleImageRightProperty = BindableProperty.Create("SelectionHandleImageRight", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_IMAGE_RIGHT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_IMAGE_RIGHT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandlePressedImageLeftProperty = BindableProperty.Create("SelectionHandlePressedImageLeft", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_PRESSED_IMAGE_LEFT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_PRESSED_IMAGE_LEFT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandlePressedImageRightProperty = BindableProperty.Create("SelectionHandlePressedImageRight", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_PRESSED_IMAGE_RIGHT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandleMarkerImageLeftProperty = BindableProperty.Create("SelectionHandleMarkerImageLeft", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_MARKER_IMAGE_LEFT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_MARKER_IMAGE_LEFT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandleMarkerImageRightProperty = BindableProperty.Create("SelectionHandleMarkerImageRight", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_MARKER_IMAGE_RIGHT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HANDLE_MARKER_IMAGE_RIGHT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHighlightColorProperty = BindableProperty.Create("SelectionHighlightColor", typeof(Vector4), typeof(TextEditor), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HIGHLIGHT_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SELECTION_HIGHLIGHT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 DecorationBoundingBoxProperty = BindableProperty.Create("DecorationBoundingBox", typeof(Rectangle), typeof(TextEditor), new Rectangle(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.DECORATION_BOUNDING_BOX, new Tizen.NUI.PropertyValue((Rectangle)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ Rectangle temp = new Rectangle(0, 0, 0, 0);
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.DECORATION_BOUNDING_BOX).Get(temp);
+ return temp;
+ });
+ /// 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 EnableMarkupProperty = BindableProperty.Create("EnableMarkup", typeof(bool), typeof(TextEditor), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_MARKUP).Get(out temp);
+ return temp;
+ });
+ /// 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 InputColorProperty = BindableProperty.Create("InputColor", typeof(Vector4), typeof(TextEditor), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 InputFontFamilyProperty = BindableProperty.Create("InputFontFamily", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_FONT_FAMILY, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_FONT_FAMILY).Get(out temp);
+ return temp;
+ });
+ /// 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 InputFontStyleProperty = BindableProperty.Create("InputFontStyle", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_FONT_STYLE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_FONT_STYLE).Get(temp);
+ return temp;
+ });
+ /// 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 InputPointSizeProperty = BindableProperty.Create("InputPointSize", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_POINT_SIZE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_POINT_SIZE).Get(out temp);
+ return temp;
+ });
+ /// 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 LineSpacingProperty = BindableProperty.Create("LineSpacing", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.LINE_SPACING, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.LINE_SPACING).Get(out temp);
+ return temp;
+ });
+ /// 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 InputLineSpacingProperty = BindableProperty.Create("InputLineSpacing", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_LINE_SPACING, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_LINE_SPACING).Get(out temp);
+ return temp;
+ });
+ /// 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 UnderlineProperty = BindableProperty.Create("Underline", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.UNDERLINE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.UNDERLINE).Get(temp);
+ return temp;
+ });
+ /// 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 InputUnderlineProperty = BindableProperty.Create("InputUnderline", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_UNDERLINE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_UNDERLINE).Get(out temp);
+ return temp;
+ });
+ /// 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 ShadowProperty = BindableProperty.Create("Shadow", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SHADOW, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SHADOW).Get(temp);
+ return temp;
+ });
+ /// 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 InputShadowProperty = BindableProperty.Create("InputShadow", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_SHADOW, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_SHADOW).Get(out temp);
+ return temp;
+ });
+ /// 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 EmbossProperty = BindableProperty.Create("Emboss", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.EMBOSS, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.EMBOSS).Get(out temp);
+ return temp;
+ });
+ /// 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 InputEmbossProperty = BindableProperty.Create("InputEmboss", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_EMBOSS, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_EMBOSS).Get(out temp);
+ return temp;
+ });
+ /// 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 OutlineProperty = BindableProperty.Create("Outline", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.OUTLINE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.OUTLINE).Get(temp);
+ return temp;
+ });
+ /// 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 InputOutlineProperty = BindableProperty.Create("InputOutline", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_OUTLINE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.INPUT_OUTLINE).Get(out temp);
+ return temp;
+ });
+ /// 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 SmoothScrollProperty = BindableProperty.Create("SmoothScroll", typeof(bool), typeof(TextEditor), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SMOOTH_SCROLL, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SMOOTH_SCROLL).Get(out temp);
+ return temp;
+ });
+ /// 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 SmoothScrollDurationProperty = BindableProperty.Create("SmoothScrollDuration", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SMOOTH_SCROLL_DURATION, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SMOOTH_SCROLL_DURATION).Get(out temp);
+ return temp;
+ });
+ /// 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 EnableScrollBarProperty = BindableProperty.Create("EnableScrollBar", typeof(bool), typeof(TextEditor), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_SCROLL_BAR, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_SCROLL_BAR).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollBarShowDurationProperty = BindableProperty.Create("ScrollBarShowDuration", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SCROLL_BAR_SHOW_DURATION, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SCROLL_BAR_SHOW_DURATION).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollBarFadeDurationProperty = BindableProperty.Create("ScrollBarFadeDuration", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.SCROLL_BAR_FADE_DURATION, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.SCROLL_BAR_FADE_DURATION).Get(out temp);
+ return temp;
+ });
+ /// 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 PixelSizeProperty = BindableProperty.Create("PixelSize", typeof(float), typeof(TextEditor), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.PIXEL_SIZE).Get(out temp);
+ return temp;
+ });
+ /// 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 PlaceholderTextProperty = BindableProperty.Create("PlaceholderText", typeof(string), typeof(TextEditor), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.PLACEHOLDER_TEXT, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.PLACEHOLDER_TEXT).Get(out temp);
+ return temp;
+ });
+ /// 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 PlaceholderTextColorProperty = BindableProperty.Create("PlaceholderTextColor", typeof(Color), typeof(TextEditor), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.PLACEHOLDER_TEXT_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.PLACEHOLDER_TEXT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 EnableSelectionProperty = BindableProperty.Create("EnableSelection", typeof(bool), typeof(TextEditor), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_SELECTION, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_SELECTION).Get(out temp);
+ return temp;
+ });
+ /// 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 PlaceholderProperty = BindableProperty.Create("Placeholder", typeof(PropertyMap), typeof(TextEditor), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.PLACEHOLDER, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.PLACEHOLDER).Get(temp);
+ return temp;
+ });
+ /// 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 LineWrapModeProperty = BindableProperty.Create("LineWrapMode", typeof(LineWrapMode), typeof(TextEditor), LineWrapMode.Word, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.LINE_WRAP_MODE, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ int temp;
+ if(Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.LINE_WRAP_MODE).Get(out temp) == false)
+ {
+ NUILog.Error("LineWrapMode get error!");
+ }
+ return (LineWrapMode)temp;
+ });
+ /// 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 EnableShiftSelectionProperty = BindableProperty.Create("EnableShiftSelection", typeof(bool), typeof(TextEditor), true, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_SHIFT_SELECTION, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textEditor = (TextEditor)bindable;
+ //textEditor.mShiftSelectionFlag(true);
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textEditor.swigCPtr, TextEditor.Property.ENABLE_SHIFT_SELECTION).Get(out temp);
+ return temp;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private string textEditorTextSid = null;
private string textEditorPlaceHolderTextSid = null;
public TextEditor() : this(NDalicPINVOKE.TextEditor_New(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
+ this.TextChanged += (obj, e) =>
+ {
+ this.Text = this.Text;
+ };
}
+
internal TextEditor(TextEditor handle) : this(NDalicPINVOKE.new_TextEditor__SWIG_1(TextEditor.getCPtr(handle)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
{
get
{
- string temp;
- GetProperty(TextEditor.Property.TEXT).Get(out temp);
- return temp;
+ return (string)GetValue(TextProperty);
}
set
{
- SetProperty(TextEditor.Property.TEXT, new Tizen.NUI.PropertyValue(value));
+ SetValueAndForceSendChangeSignal(TextProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextEditor.Property.TEXT_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(TextColorProperty);
}
set
{
- SetProperty(TextEditor.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(TextColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.FONT_FAMILY).Get(out temp);
- return temp;
+ return (string)GetValue(FontFamilyProperty);
}
set
{
- SetProperty(TextEditor.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
+ SetValue(FontFamilyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.FONT_STYLE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(FontStyleProperty);
}
set
{
- SetProperty(TextEditor.Property.FONT_STYLE, new Tizen.NUI.PropertyValue(value));
+ SetValue(FontStyleProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.POINT_SIZE).Get(out temp);
- return temp;
+ return (float)GetValue(PointSizeProperty);
}
set
{
- SetProperty(TextEditor.Property.POINT_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(PointSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(TextEditor.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
- {
- NUILog.Error("HorizontalAlignment get error!");
- }
-
- switch (temp)
- {
- case "BEGIN":
- return HorizontalAlignment.Begin;
- case "CENTER":
- return HorizontalAlignment.Center;
- case "END":
- return HorizontalAlignment.End;
- default:
- return HorizontalAlignment.Begin;
- }
+ return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case HorizontalAlignment.Begin:
- {
- valueToString = "BEGIN";
- break;
- }
- case HorizontalAlignment.Center:
- {
- valueToString = "CENTER";
- break;
- }
- case HorizontalAlignment.End:
- {
- valueToString = "END";
- break;
- }
- default:
- {
- valueToString = "BEGIN";
- break;
- }
- }
- SetProperty(TextEditor.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(HorizontalAlignmentProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.SCROLL_THRESHOLD).Get(out temp);
- return temp;
+ return (float)GetValue(ScrollThresholdProperty);
}
set
{
- SetProperty(TextEditor.Property.SCROLL_THRESHOLD, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollThresholdProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.SCROLL_SPEED).Get(out temp);
- return temp;
+ return (float)GetValue(ScrollSpeedProperty);
}
set
{
- SetProperty(TextEditor.Property.SCROLL_SPEED, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollSpeedProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextEditor.Property.PRIMARY_CURSOR_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(PrimaryCursorColorProperty);
}
set
{
- SetProperty(TextEditor.Property.PRIMARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(PrimaryCursorColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextEditor.Property.SECONDARY_CURSOR_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(SecondaryCursorColorProperty);
}
set
{
- SetProperty(TextEditor.Property.SECONDARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(SecondaryCursorColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextEditor.Property.ENABLE_CURSOR_BLINK).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableCursorBlinkProperty);
}
set
{
- SetProperty(TextEditor.Property.ENABLE_CURSOR_BLINK, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableCursorBlinkProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.CURSOR_BLINK_INTERVAL).Get(out temp);
- return temp;
+ return (float)GetValue(CursorBlinkIntervalProperty);
}
set
{
- SetProperty(TextEditor.Property.CURSOR_BLINK_INTERVAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(CursorBlinkIntervalProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.CURSOR_BLINK_DURATION).Get(out temp);
- return temp;
+ return (float)GetValue(CursorBlinkDurationProperty);
}
set
{
- SetProperty(TextEditor.Property.CURSOR_BLINK_DURATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(CursorBlinkDurationProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(TextEditor.Property.CURSOR_WIDTH).Get(out temp);
- return temp;
+ return (int)GetValue(CursorWidthProperty);
}
set
{
- SetProperty(TextEditor.Property.CURSOR_WIDTH, new Tizen.NUI.PropertyValue(value));
+ SetValue(CursorWidthProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.GRAB_HANDLE_IMAGE).Get(out temp);
- return temp;
+ return (string)GetValue(GrabHandleImageProperty);
}
set
{
- SetProperty(TextEditor.Property.GRAB_HANDLE_IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(GrabHandleImageProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.GRAB_HANDLE_PRESSED_IMAGE).Get(out temp);
- return temp;
+ return (string)GetValue(GrabHandlePressedImageProperty);
}
set
{
- SetProperty(TextEditor.Property.GRAB_HANDLE_PRESSED_IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(GrabHandlePressedImageProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.SELECTION_HANDLE_IMAGE_LEFT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandleImageLeftProperty);
}
set
{
- SetProperty(TextEditor.Property.SELECTION_HANDLE_IMAGE_LEFT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandleImageLeftProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.SELECTION_HANDLE_IMAGE_RIGHT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandleImageRightProperty);
}
set
{
- SetProperty(TextEditor.Property.SELECTION_HANDLE_IMAGE_RIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandleImageRightProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.SELECTION_HANDLE_PRESSED_IMAGE_LEFT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty);
}
set
{
- SetProperty(TextEditor.Property.SELECTION_HANDLE_PRESSED_IMAGE_LEFT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandlePressedImageLeftProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.SELECTION_HANDLE_PRESSED_IMAGE_RIGHT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty);
}
set
{
- SetProperty(TextEditor.Property.SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandlePressedImageRightProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.SELECTION_HANDLE_MARKER_IMAGE_LEFT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty);
}
set
{
- SetProperty(TextEditor.Property.SELECTION_HANDLE_MARKER_IMAGE_LEFT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandleMarkerImageLeftProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.SELECTION_HANDLE_MARKER_IMAGE_RIGHT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty);
}
set
{
- SetProperty(TextEditor.Property.SELECTION_HANDLE_MARKER_IMAGE_RIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandleMarkerImageRightProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextEditor.Property.SELECTION_HIGHLIGHT_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(SelectionHighlightColorProperty);
}
set
{
- SetProperty(TextEditor.Property.SELECTION_HIGHLIGHT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHighlightColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Rectangle temp = new Rectangle(0, 0, 0, 0);
- GetProperty(TextEditor.Property.DECORATION_BOUNDING_BOX).Get(temp);
- return temp;
+ return (Rectangle)GetValue(DecorationBoundingBoxProperty);
}
set
{
- SetProperty(TextEditor.Property.DECORATION_BOUNDING_BOX, new Tizen.NUI.PropertyValue(value));
+ SetValue(DecorationBoundingBoxProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextEditor.Property.ENABLE_MARKUP).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableMarkupProperty);
}
set
{
- SetProperty(TextEditor.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableMarkupProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextEditor.Property.INPUT_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(InputColorProperty);
}
set
{
- SetProperty(TextEditor.Property.INPUT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.INPUT_FONT_FAMILY).Get(out temp);
- return temp;
+ return (string)GetValue(InputFontFamilyProperty);
}
set
{
- SetProperty(TextEditor.Property.INPUT_FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputFontFamilyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.INPUT_FONT_STYLE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(InputFontStyleProperty);
}
set
{
- SetProperty(TextEditor.Property.INPUT_FONT_STYLE, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputFontStyleProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.INPUT_POINT_SIZE).Get(out temp);
- return temp;
+ return (float)GetValue(InputPointSizeProperty);
}
set
{
- SetProperty(TextEditor.Property.INPUT_POINT_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputPointSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.LINE_SPACING).Get(out temp);
- return temp;
+ return (float)GetValue(LineSpacingProperty);
}
set
{
- SetProperty(TextEditor.Property.LINE_SPACING, new Tizen.NUI.PropertyValue(value));
+ SetValue(LineSpacingProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.INPUT_LINE_SPACING).Get(out temp);
- return temp;
+ return (float)GetValue(InputLineSpacingProperty);
}
set
{
- SetProperty(TextEditor.Property.INPUT_LINE_SPACING, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputLineSpacingProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.UNDERLINE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(UnderlineProperty);
}
set
{
- SetProperty(TextEditor.Property.UNDERLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(UnderlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.INPUT_UNDERLINE).Get(out temp);
- return temp;
+ return (string)GetValue(InputUnderlineProperty);
}
set
{
- SetProperty(TextEditor.Property.INPUT_UNDERLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputUnderlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.SHADOW).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(ShadowProperty);
}
set
{
- SetProperty(TextEditor.Property.SHADOW, new Tizen.NUI.PropertyValue(value));
+ SetValue(ShadowProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.INPUT_SHADOW).Get(out temp);
- return temp;
+ return (string)GetValue(InputShadowProperty);
}
set
{
- SetProperty(TextEditor.Property.INPUT_SHADOW, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputShadowProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.EMBOSS).Get(out temp);
- return temp;
+ return (string)GetValue(EmbossProperty);
}
set
{
- SetProperty(TextEditor.Property.EMBOSS, new Tizen.NUI.PropertyValue(value));
+ SetValue(EmbossProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.INPUT_EMBOSS).Get(out temp);
- return temp;
+ return (string)GetValue(InputEmbossProperty);
}
set
{
- SetProperty(TextEditor.Property.INPUT_EMBOSS, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputEmbossProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextEditor.Property.OUTLINE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(OutlineProperty);
}
set
{
- SetProperty(TextEditor.Property.OUTLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(OutlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.INPUT_OUTLINE).Get(out temp);
- return temp;
+ return (string)GetValue(InputOutlineProperty);
}
set
{
- SetProperty(TextEditor.Property.INPUT_OUTLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputOutlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextEditor.Property.SMOOTH_SCROLL).Get(out temp);
- return temp;
+ return (bool)GetValue(SmoothScrollProperty);
}
set
{
- SetProperty(TextEditor.Property.SMOOTH_SCROLL, new Tizen.NUI.PropertyValue(value));
+ SetValue(SmoothScrollProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.SMOOTH_SCROLL_DURATION).Get(out temp);
- return temp;
+ return (float)GetValue(SmoothScrollDurationProperty);
}
set
{
- SetProperty(TextEditor.Property.SMOOTH_SCROLL_DURATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(SmoothScrollDurationProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextEditor.Property.ENABLE_SCROLL_BAR).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableScrollBarProperty);
}
set
{
- SetProperty(TextEditor.Property.ENABLE_SCROLL_BAR, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableScrollBarProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.SCROLL_BAR_SHOW_DURATION).Get(out temp);
- return temp;
+ return (float)GetValue(ScrollBarShowDurationProperty);
}
set
{
- SetProperty(TextEditor.Property.SCROLL_BAR_SHOW_DURATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollBarShowDurationProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.SCROLL_BAR_FADE_DURATION).Get(out temp);
- return temp;
+ return (float)GetValue(ScrollBarFadeDurationProperty);
}
set
{
- SetProperty(TextEditor.Property.SCROLL_BAR_FADE_DURATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollBarFadeDurationProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextEditor.Property.PIXEL_SIZE).Get(out temp);
- return temp;
+ return (float)GetValue(PixelSizeProperty);
}
set
{
- SetProperty(TextEditor.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(PixelSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextEditor.Property.PLACEHOLDER_TEXT).Get(out temp);
- return temp;
+ return (string)GetValue(PlaceholderTextProperty);
}
set
{
- SetProperty(TextEditor.Property.PLACEHOLDER_TEXT, new Tizen.NUI.PropertyValue(value));
+ SetValue(PlaceholderTextProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextEditor.Property.PLACEHOLDER_TEXT_COLOR).Get(temp);
- return temp;
+ return (Color)GetValue(PlaceholderTextColorProperty);
}
set
{
- SetProperty(TextEditor.Property.PLACEHOLDER_TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(PlaceholderTextColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextEditor.Property.ENABLE_SELECTION).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableSelectionProperty);
}
set
{
- SetProperty(TextEditor.Property.ENABLE_SELECTION, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableSelectionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(TextEditor.Property.PLACEHOLDER).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(PlaceholderProperty);
}
set
{
- SetProperty(TextEditor.Property.PLACEHOLDER, new Tizen.NUI.PropertyValue(value));
+ SetValue(PlaceholderProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp;
- if(GetProperty(TextEditor.Property.LINE_WRAP_MODE).Get(out temp) == false)
- {
- NUILog.Error("LineWrapMode get error!");
- }
- return (LineWrapMode)temp;
+ return (LineWrapMode)GetValue(LineWrapModeProperty);
}
set
{
- SetProperty(TextEditor.Property.LINE_WRAP_MODE, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(LineWrapModeProperty, value);
NotifyPropertyChanged();
}
}
/// Enables Text selection using Shift key.
/// </summary>
/// <since_tizen> 5 </since_tizen>
+ /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public bool EnableShiftSelection
{
get
{
- // mShiftSelectionFlag( true )
- bool temp = true;
- GetProperty(TextEditor.Property.ENABLE_SHIFT_SELECTION).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableShiftSelectionProperty);
}
set
{
- SetProperty(TextEditor.Property.ENABLE_SHIFT_SELECTION, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableShiftSelectionProperty, value);
NotifyPropertyChanged();
}
}
using System.Runtime.InteropServices;
using System.Globalization;
using System.ComponentModel;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
/// A control which provides a single line editable text field.
/// </summary>
/// <since_tizen> 3 </since_tizen>
+ [ContentProperty("Text")]
public class TextField : View
{
+ /// 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 TextProperty = BindableProperty.Create("Text", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.TEXT, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.TEXT).Get(out temp);
+ return temp;
+ });
+ /// 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 PlaceholderTextProperty = BindableProperty.Create("PlaceholderText", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER_TEXT, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER_TEXT).Get(out temp);
+ return temp;
+ });
+ /// 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 PlaceholderTextFocusedProperty = BindableProperty.Create("PlaceholderTextFocused", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER_TEXT_FOCUSED, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER_TEXT_FOCUSED).Get(out temp);
+ return temp;
+ });
+ /// 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 FontFamilyProperty = BindableProperty.Create("FontFamily", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.FONT_FAMILY).Get(out temp);
+ return temp;
+ });
+ /// 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 FontStyleProperty = BindableProperty.Create("FontStyle", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.FONT_STYLE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.FONT_STYLE).Get(temp);
+ return temp;
+ });
+ /// 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 PointSizeProperty = BindableProperty.Create("PointSize", typeof(float), typeof(TextField), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.POINT_SIZE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.POINT_SIZE).Get(out temp);
+ return temp;
+ });
+ /// 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 MaxLengthProperty = BindableProperty.Create("MaxLength", typeof(int), typeof(TextField), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.MAX_LENGTH, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.MAX_LENGTH).Get(out temp);
+ return temp;
+ });
+ /// 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 ExceedPolicyProperty = BindableProperty.Create("ExceedPolicy", typeof(int), typeof(TextField), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.EXCEED_POLICY, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.EXCEED_POLICY).Get(out temp);
+ return temp;
+ });
+ /// 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 HorizontalAlignmentProperty = BindableProperty.Create("HorizontalAlignment", typeof(HorizontalAlignment), typeof(TextField), HorizontalAlignment.Begin, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((HorizontalAlignment)newValue)
+ {
+ case HorizontalAlignment.Begin:
+ {
+ valueToString = "BEGIN";
+ break;
+ }
+ case HorizontalAlignment.Center:
+ {
+ valueToString = "CENTER";
+ break;
+ }
+ case HorizontalAlignment.End:
+ {
+ valueToString = "END";
+ break;
+ }
+ default:
+ {
+ valueToString = "BEGIN";
+ break;
+ }
+ }
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
+ {
+ NUILog.Error("HorizontalAlignment get error!");
+ }
+
+ switch (temp)
+ {
+ case "BEGIN": return HorizontalAlignment.Begin;
+ case "CENTER": return HorizontalAlignment.Center;
+ case "END": return HorizontalAlignment.End;
+ default: return HorizontalAlignment.Begin;
+ }
+ });
+ /// 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 VerticalAlignmentProperty = BindableProperty.Create("VerticalAlignment", typeof(VerticalAlignment), typeof(TextField), VerticalAlignment.Bottom, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((VerticalAlignment)newValue)
+ {
+ case VerticalAlignment.Top: { valueToString = "TOP"; break; }
+ case VerticalAlignment.Center: { valueToString = "CENTER"; break; }
+ case VerticalAlignment.Bottom: { valueToString = "BOTTOM"; break; }
+ default: { valueToString = "BOTTOM"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
+ {
+ NUILog.Error("VerticalAlignment get error!");
+ }
+
+ switch (temp)
+ {
+ case "TOP": return VerticalAlignment.Top;
+ case "CENTER": return VerticalAlignment.Center;
+ case "BOTTOM": return VerticalAlignment.Bottom;
+ default: return VerticalAlignment.Bottom;
+ }
+ });
+ /// 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 TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(TextField), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.TEXT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 PlaceholderTextColorProperty = BindableProperty.Create("PlaceholderTextColor", typeof(Vector4), typeof(TextField), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER_TEXT_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER_TEXT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 ShadowOffsetProperty = BindableProperty.Create("ShadowOffset", typeof(Vector2), typeof(TextField), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SHADOW_OFFSET).Get(temp);
+ return temp;
+ });
+ /// 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 ShadowColorProperty = BindableProperty.Create("ShadowColor", typeof(Vector4), typeof(TextField), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SHADOW_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 PrimaryCursorColorProperty = BindableProperty.Create("PrimaryCursorColor", typeof(Vector4), typeof(TextField), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PRIMARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.PRIMARY_CURSOR_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 SecondaryCursorColorProperty = BindableProperty.Create("SecondaryCursorColor", typeof(Vector4), typeof(TextField), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SECONDARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SECONDARY_CURSOR_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 EnableCursorBlinkProperty = BindableProperty.Create("EnableCursorBlink", typeof(bool), typeof(TextField), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.ENABLE_CURSOR_BLINK, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.ENABLE_CURSOR_BLINK).Get(out temp);
+ return temp;
+ });
+ /// 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 CursorBlinkIntervalProperty = BindableProperty.Create("CursorBlinkInterval", typeof(float), typeof(TextField), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.CURSOR_BLINK_INTERVAL, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.CURSOR_BLINK_INTERVAL).Get(out temp);
+ return temp;
+ });
+ /// 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 CursorBlinkDurationProperty = BindableProperty.Create("CursorBlinkDuration", typeof(float), typeof(TextField), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.CURSOR_BLINK_DURATION, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.CURSOR_BLINK_DURATION).Get(out temp);
+ return temp;
+ });
+ /// 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 CursorWidthProperty = BindableProperty.Create("CursorWidth", typeof(int), typeof(TextField), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.CURSOR_WIDTH, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.CURSOR_WIDTH).Get(out temp);
+ return temp;
+ });
+ /// 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 GrabHandleImageProperty = BindableProperty.Create("GrabHandleImage", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.GRAB_HANDLE_IMAGE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.GRAB_HANDLE_IMAGE).Get(out temp);
+ return temp;
+ });
+ /// 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 GrabHandlePressedImageProperty = BindableProperty.Create("GrabHandlePressedImage", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.GRAB_HANDLE_PRESSED_IMAGE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.GRAB_HANDLE_PRESSED_IMAGE).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollThresholdProperty = BindableProperty.Create("ScrollThreshold", typeof(float), typeof(TextField), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SCROLL_THRESHOLD, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SCROLL_THRESHOLD).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollSpeedProperty = BindableProperty.Create("ScrollSpeed", typeof(float), typeof(TextField), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SCROLL_SPEED, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SCROLL_SPEED).Get(out temp);
+ return temp;
+ });
+ /// 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 SelectionHandleImageLeftProperty = BindableProperty.Create("SelectionHandleImageLeft", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_IMAGE_LEFT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_IMAGE_LEFT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandleImageRightProperty = BindableProperty.Create("SelectionHandleImageRight", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_IMAGE_RIGHT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_IMAGE_RIGHT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandlePressedImageLeftProperty = BindableProperty.Create("SelectionHandlePressedImageLeft", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_PRESSED_IMAGE_LEFT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_PRESSED_IMAGE_LEFT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandlePressedImageRightProperty = BindableProperty.Create("SelectionHandlePressedImageRight", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_PRESSED_IMAGE_RIGHT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandleMarkerImageLeftProperty = BindableProperty.Create("SelectionHandleMarkerImageLeft", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_MARKER_IMAGE_LEFT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_MARKER_IMAGE_LEFT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHandleMarkerImageRightProperty = BindableProperty.Create("SelectionHandleMarkerImageRight", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_MARKER_IMAGE_RIGHT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SELECTION_HANDLE_MARKER_IMAGE_RIGHT).Get(temp);
+ return temp;
+ });
+ /// 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 SelectionHighlightColorProperty = BindableProperty.Create("SelectionHighlightColor", typeof(Vector4), typeof(TextField), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SELECTION_HIGHLIGHT_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SELECTION_HIGHLIGHT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 DecorationBoundingBoxProperty = BindableProperty.Create("DecorationBoundingBox", typeof(Rectangle), typeof(TextField), new Rectangle(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.DECORATION_BOUNDING_BOX, new Tizen.NUI.PropertyValue((Rectangle)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Rectangle temp = new Rectangle(0, 0, 0, 0);
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.DECORATION_BOUNDING_BOX).Get(temp);
+ return temp;
+ });
+ /// 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 InputMethodSettingsProperty = BindableProperty.Create("InputMethodSettings", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.INPUT_METHOD_SETTINGS, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.INPUT_METHOD_SETTINGS).Get(temp);
+ return temp;
+ });
+ /// 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 InputColorProperty = BindableProperty.Create("InputColor", typeof(Vector4), typeof(TextField), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.INPUT_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.INPUT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 EnableMarkupProperty = BindableProperty.Create("EnableMarkup", typeof(bool), typeof(TextField), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.ENABLE_MARKUP).Get(out temp);
+ return temp;
+ });
+ /// 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 InputFontFamilyProperty = BindableProperty.Create("InputFontFamily", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.INPUT_FONT_FAMILY, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.INPUT_FONT_FAMILY).Get(out temp);
+ return temp;
+ });
+ /// 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 InputFontStyleProperty = BindableProperty.Create("InputFontStyle", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.INPUT_FONT_STYLE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.INPUT_FONT_STYLE).Get(temp);
+ return temp;
+ });
+ /// 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 InputPointSizeProperty = BindableProperty.Create("InputPointSize", typeof(float), typeof(TextField), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.INPUT_POINT_SIZE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.INPUT_POINT_SIZE).Get(out temp);
+ return temp;
+ });
+ /// 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 UnderlineProperty = BindableProperty.Create("Underline", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.UNDERLINE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.UNDERLINE).Get(temp);
+ return temp;
+ });
+ /// 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 InputUnderlineProperty = BindableProperty.Create("InputUnderline", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.INPUT_UNDERLINE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.INPUT_UNDERLINE).Get(out temp);
+ return temp;
+ });
+ /// 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 ShadowProperty = BindableProperty.Create("Shadow", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.SHADOW, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.SHADOW).Get(temp);
+ return temp;
+ });
+ /// 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 InputShadowProperty = BindableProperty.Create("InputShadow", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.INPUT_SHADOW, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.INPUT_SHADOW).Get(out temp);
+ return temp;
+ });
+ /// 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 EmbossProperty = BindableProperty.Create("Emboss", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.EMBOSS, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.EMBOSS).Get(out temp);
+ return temp;
+ });
+ /// 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 InputEmbossProperty = BindableProperty.Create("InputEmboss", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.INPUT_EMBOSS, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.INPUT_EMBOSS).Get(out temp);
+ return temp;
+ });
+ /// 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 OutlineProperty = BindableProperty.Create("Outline", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.OUTLINE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.OUTLINE).Get(temp);
+ return temp;
+ });
+ /// 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 InputOutlineProperty = BindableProperty.Create("InputOutline", typeof(string), typeof(TextField), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.INPUT_OUTLINE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.INPUT_OUTLINE).Get(out temp);
+ return temp;
+ });
+ /// 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 HiddenInputSettingsProperty = BindableProperty.Create("HiddenInputSettings", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.HIDDEN_INPUT_SETTINGS, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.HIDDEN_INPUT_SETTINGS).Get(temp);
+ return temp;
+ });
+ /// 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 PixelSizeProperty = BindableProperty.Create("PixelSize", typeof(float), typeof(TextField), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.PIXEL_SIZE).Get(out temp);
+ return temp;
+ });
+ /// 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 EnableSelectionProperty = BindableProperty.Create("EnableSelection", typeof(bool), typeof(TextField), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.ENABLE_SELECTION, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.ENABLE_SELECTION).Get(out temp);
+ return temp;
+ });
+ /// 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 PlaceholderProperty = BindableProperty.Create("Placeholder", typeof(PropertyMap), typeof(TextField), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.PLACEHOLDER).Get(temp);
+ return temp;
+ });
+ /// 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 EllipsisProperty = BindableProperty.Create("Ellipsis", typeof(bool), typeof(TextField), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.ELLIPSIS, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.ELLIPSIS).Get(out temp);
+ return temp;
+ });
+ /// 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 EnableShiftSelectionProperty = BindableProperty.Create("EnableShiftSelection", typeof(bool), typeof(TextField), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textField = (TextField)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textField.swigCPtr, TextField.Property.ENABLE_SHIFT_SELECTION, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textField = (TextField)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.ENABLE_SHIFT_SELECTION).Get(out temp);
+ return temp;
+ });
+
+
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private string textFieldTextSid = null;
private string textFieldPlaceHolderTextSid = null;
public TextField() : this(NDalicPINVOKE.TextField_New(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
+ this.TextChanged += (obj, e) => {
+ this.Text = this.Text;
+ };
}
+
internal TextField(TextField handle) : this(NDalicPINVOKE.new_TextField__SWIG_1(TextField.getCPtr(handle)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
{
get
{
- string temp;
- GetProperty(TextField.Property.TEXT).Get(out temp);
- return temp;
+ return (string)GetValue(TextProperty);
}
set
{
- SetProperty(TextField.Property.TEXT, new Tizen.NUI.PropertyValue(value));
+ SetValueAndForceSendChangeSignal(TextProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.PLACEHOLDER_TEXT).Get(out temp);
- return temp;
+ return (string)GetValue(PlaceholderTextProperty);
+
}
set
{
- SetProperty(TextField.Property.PLACEHOLDER_TEXT, new Tizen.NUI.PropertyValue(value));
+ SetValue(PlaceholderTextProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.PLACEHOLDER_TEXT_FOCUSED).Get(out temp);
- return temp;
+ return (string)GetValue(PlaceholderTextFocusedProperty);
}
set
{
- SetProperty(TextField.Property.PLACEHOLDER_TEXT_FOCUSED, new Tizen.NUI.PropertyValue(value));
+ SetValue(PlaceholderTextFocusedProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.FONT_FAMILY).Get(out temp);
- return temp;
+ return (string)GetValue(FontFamilyProperty);
}
set
{
- SetProperty(TextField.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
+ SetValue(FontFamilyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.FONT_STYLE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(FontStyleProperty);
}
set
{
- SetProperty(TextField.Property.FONT_STYLE, new Tizen.NUI.PropertyValue(value));
+ SetValue(FontStyleProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextField.Property.POINT_SIZE).Get(out temp);
- return temp;
+ return (float)GetValue(PointSizeProperty);
}
set
{
- SetProperty(TextField.Property.POINT_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(PointSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(TextField.Property.MAX_LENGTH).Get(out temp);
- return temp;
+ return (int)GetValue(MaxLengthProperty);
}
set
{
- SetProperty(TextField.Property.MAX_LENGTH, new Tizen.NUI.PropertyValue(value));
+ SetValue(MaxLengthProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(TextField.Property.EXCEED_POLICY).Get(out temp);
- return temp;
+ return (int)GetValue(ExceedPolicyProperty);
}
set
{
- SetProperty(TextField.Property.EXCEED_POLICY, new Tizen.NUI.PropertyValue(value));
+ SetValue(ExceedPolicyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(TextField.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
- {
- NUILog.Error("HorizontalAlignment get error!");
- }
-
- switch (temp)
- {
- case "BEGIN":
- return HorizontalAlignment.Begin;
- case "CENTER":
- return HorizontalAlignment.Center;
- case "END":
- return HorizontalAlignment.End;
- default:
- return HorizontalAlignment.Begin;
- }
+ return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case HorizontalAlignment.Begin:
- {
- valueToString = "BEGIN";
- break;
- }
- case HorizontalAlignment.Center:
- {
- valueToString = "CENTER";
- break;
- }
- case HorizontalAlignment.End:
- {
- valueToString = "END";
- break;
- }
- default:
- {
- valueToString = "BEGIN";
- break;
- }
- }
- SetProperty(TextField.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(HorizontalAlignmentProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(TextField.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
- {
- NUILog.Error("VerticalAlignment get error!");
- }
-
- switch (temp)
- {
- case "TOP":
- return VerticalAlignment.Top;
- case "CENTER":
- return VerticalAlignment.Center;
- case "BOTTOM":
- return VerticalAlignment.Bottom;
- default:
- return VerticalAlignment.Bottom;
- }
+ return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case VerticalAlignment.Top:
- {
- valueToString = "TOP";
- break;
- }
- case VerticalAlignment.Center:
- {
- valueToString = "CENTER";
- break;
- }
- case VerticalAlignment.Bottom:
- {
- valueToString = "BOTTOM";
- break;
- }
- default:
- {
- valueToString = "BOTTOM";
- break;
- }
- }
- SetProperty(TextField.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(VerticalAlignmentProperty, value);
+ NotifyPropertyChanged();
NotifyPropertyChanged();
}
}
{
get
{
- Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextField.Property.TEXT_COLOR).Get(temp);
- return temp;
+ return (Color)GetValue(TextColorProperty);
}
set
{
- SetProperty(TextField.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(TextColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextField.Property.PLACEHOLDER_TEXT_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(PlaceholderTextColorProperty);
}
set
{
- SetProperty(TextField.Property.PLACEHOLDER_TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(PlaceholderTextColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(TextField.Property.SHADOW_OFFSET).Get(temp);
- return temp;
+ return (Vector2)GetValue(ShadowOffsetProperty);
}
set
{
- SetProperty(TextField.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue(value));
+ SetValue(ShadowOffsetProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextField.Property.SHADOW_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(ShadowColorProperty);
}
set
{
- SetProperty(TextField.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(ShadowColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextField.Property.PRIMARY_CURSOR_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(PrimaryCursorColorProperty);
}
set
{
- SetProperty(TextField.Property.PRIMARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(PrimaryCursorColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextField.Property.SECONDARY_CURSOR_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(SecondaryCursorColorProperty);
}
set
{
- SetProperty(TextField.Property.SECONDARY_CURSOR_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(SecondaryCursorColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextField.Property.ENABLE_CURSOR_BLINK).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableCursorBlinkProperty);
}
set
{
- SetProperty(TextField.Property.ENABLE_CURSOR_BLINK, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableCursorBlinkProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextField.Property.CURSOR_BLINK_INTERVAL).Get(out temp);
- return temp;
+ return (float)GetValue(CursorBlinkIntervalProperty);
}
set
{
- SetProperty(TextField.Property.CURSOR_BLINK_INTERVAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(CursorBlinkIntervalProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextField.Property.CURSOR_BLINK_DURATION).Get(out temp);
- return temp;
+ return (float)GetValue(CursorBlinkDurationProperty);
}
set
{
- SetProperty(TextField.Property.CURSOR_BLINK_DURATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(CursorBlinkDurationProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(TextField.Property.CURSOR_WIDTH).Get(out temp);
- return temp;
+ return (int)GetValue(CursorWidthProperty);
}
set
{
- SetProperty(TextField.Property.CURSOR_WIDTH, new Tizen.NUI.PropertyValue(value));
+ SetValue(CursorWidthProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.GRAB_HANDLE_IMAGE).Get(out temp);
- return temp;
+ return (string)GetValue(GrabHandleImageProperty);
}
set
{
- SetProperty(TextField.Property.GRAB_HANDLE_IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(GrabHandleImageProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.GRAB_HANDLE_PRESSED_IMAGE).Get(out temp);
- return temp;
+ return (string)GetValue(GrabHandlePressedImageProperty);
}
set
{
- SetProperty(TextField.Property.GRAB_HANDLE_PRESSED_IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(GrabHandlePressedImageProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextField.Property.SCROLL_THRESHOLD).Get(out temp);
- return temp;
+ return (float)GetValue(ScrollThresholdProperty);
}
set
{
- SetProperty(TextField.Property.SCROLL_THRESHOLD, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollThresholdProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextField.Property.SCROLL_SPEED).Get(out temp);
- return temp;
+ return (float)GetValue(ScrollSpeedProperty);
}
set
{
- SetProperty(TextField.Property.SCROLL_SPEED, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollSpeedProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.SELECTION_HANDLE_IMAGE_LEFT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandleImageLeftProperty);
}
set
{
- SetProperty(TextField.Property.SELECTION_HANDLE_IMAGE_LEFT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandleImageLeftProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.SELECTION_HANDLE_IMAGE_RIGHT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandleImageRightProperty);
}
set
{
- SetProperty(TextField.Property.SELECTION_HANDLE_IMAGE_RIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandleImageRightProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.SELECTION_HANDLE_PRESSED_IMAGE_LEFT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty);
}
set
{
- SetProperty(TextField.Property.SELECTION_HANDLE_PRESSED_IMAGE_LEFT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandlePressedImageLeftProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.SELECTION_HANDLE_PRESSED_IMAGE_RIGHT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty);
}
set
{
- SetProperty(TextField.Property.SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandlePressedImageRightProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.SELECTION_HANDLE_MARKER_IMAGE_LEFT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty);
}
set
{
- SetProperty(TextField.Property.SELECTION_HANDLE_MARKER_IMAGE_LEFT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandleMarkerImageLeftProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.SELECTION_HANDLE_MARKER_IMAGE_RIGHT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty);
}
set
{
- SetProperty(TextField.Property.SELECTION_HANDLE_MARKER_IMAGE_RIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHandleMarkerImageRightProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextField.Property.SELECTION_HIGHLIGHT_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(SelectionHighlightColorProperty);
}
set
{
- SetProperty(TextField.Property.SELECTION_HIGHLIGHT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectionHighlightColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Rectangle temp = new Rectangle(0, 0, 0, 0);
- GetProperty(TextField.Property.DECORATION_BOUNDING_BOX).Get(temp);
- return temp;
+ return (Rectangle)GetValue(DecorationBoundingBoxProperty);
}
set
{
- SetProperty(TextField.Property.DECORATION_BOUNDING_BOX, new Tizen.NUI.PropertyValue(value));
+ SetValue(DecorationBoundingBoxProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.INPUT_METHOD_SETTINGS).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(InputMethodSettingsProperty);
}
set
{
- SetProperty(TextField.Property.INPUT_METHOD_SETTINGS, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputMethodSettingsProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextField.Property.INPUT_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(InputColorProperty);
}
set
{
- SetProperty(TextField.Property.INPUT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextField.Property.ENABLE_MARKUP).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableMarkupProperty);
}
set
{
- SetProperty(TextField.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableMarkupProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.INPUT_FONT_FAMILY).Get(out temp);
- return temp;
+ return (string)GetValue(InputFontFamilyProperty);
}
set
{
- SetProperty(TextField.Property.INPUT_FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputFontFamilyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.INPUT_FONT_STYLE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(InputFontStyleProperty);
}
set
{
- SetProperty(TextField.Property.INPUT_FONT_STYLE, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputFontStyleProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextField.Property.INPUT_POINT_SIZE).Get(out temp);
- return temp;
+ return (float)GetValue(InputPointSizeProperty);
}
set
{
- SetProperty(TextField.Property.INPUT_POINT_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputPointSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.UNDERLINE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(UnderlineProperty);
}
set
{
- SetProperty(TextField.Property.UNDERLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(UnderlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.INPUT_UNDERLINE).Get(out temp);
- return temp;
+ return (string)GetValue(InputUnderlineProperty);
}
set
{
- SetProperty(TextField.Property.INPUT_UNDERLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputUnderlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.SHADOW).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(ShadowProperty);
}
set
{
- SetProperty(TextField.Property.SHADOW, new Tizen.NUI.PropertyValue(value));
+ SetValue(ShadowProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.INPUT_SHADOW).Get(out temp);
- return temp;
+ return (string)GetValue(InputShadowProperty);
}
set
{
- SetProperty(TextField.Property.INPUT_SHADOW, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputShadowProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.EMBOSS).Get(out temp);
- return temp;
+ return (string)GetValue(EmbossProperty);
}
set
{
- SetProperty(TextField.Property.EMBOSS, new Tizen.NUI.PropertyValue(value));
+ SetValue(EmbossProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.INPUT_EMBOSS).Get(out temp);
- return temp;
+ return (string)GetValue(InputEmbossProperty);
}
set
{
- SetProperty(TextField.Property.INPUT_EMBOSS, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputEmbossProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextField.Property.OUTLINE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(OutlineProperty);
}
set
{
- SetProperty(TextField.Property.OUTLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(OutlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextField.Property.INPUT_OUTLINE).Get(out temp);
- return temp;
+ return (string)GetValue(InputOutlineProperty);
}
set
{
- SetProperty(TextField.Property.INPUT_OUTLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(InputOutlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(TextField.Property.HIDDEN_INPUT_SETTINGS).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(HiddenInputSettingsProperty);
}
set
{
- SetProperty(TextField.Property.HIDDEN_INPUT_SETTINGS, new Tizen.NUI.PropertyValue(value));
+ SetValue(HiddenInputSettingsProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextField.Property.PIXEL_SIZE).Get(out temp);
- return temp;
+ return (float)GetValue(PixelSizeProperty);
}
set
{
- SetProperty(TextField.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(PixelSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextField.Property.ENABLE_SELECTION).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableSelectionProperty);
}
set
{
- SetProperty(TextField.Property.ENABLE_SELECTION, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableSelectionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(TextField.Property.PLACEHOLDER).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(PlaceholderProperty);
}
set
{
- SetProperty(TextField.Property.PLACEHOLDER, new Tizen.NUI.PropertyValue(value));
+ SetValue(PlaceholderProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextField.Property.ELLIPSIS).Get(out temp);
- return temp;
+ return (bool)GetValue(EllipsisProperty);
}
set
{
- SetProperty(TextField.Property.ELLIPSIS, new Tizen.NUI.PropertyValue(value));
+ SetValue(EllipsisProperty, value);
NotifyPropertyChanged();
}
}
/// Enables Text selection using Shift key.
/// </summary>
/// <since_tizen> 5 </since_tizen>
+ /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public bool EnableShiftSelection
{
get
{
- // mShiftSelectionFlag( true )
- bool temp = true;
- GetProperty(TextField.Property.ENABLE_SHIFT_SELECTION).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableShiftSelectionProperty);
}
set
{
- SetProperty(TextField.Property.ENABLE_SHIFT_SELECTION, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableShiftSelectionProperty, value);
NotifyPropertyChanged();
}
}
-
-
-
}
}
using System;
using System.Globalization;
using System.ComponentModel;
+using Tizen.NUI.Binding;
+
namespace Tizen.NUI.BaseComponents
{
/// Text labels are lightweight, non-editable, and do not respond to the user input.<br />
/// </summary>
/// <since_tizen> 3 </since_tizen>
+ [ContentProperty("Text")]
public class TextLabel : View
{
+ /// 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 TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(TextLabel), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.TEXT, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.TEXT).Get(out temp);
+ return temp;
+ });
+ /// 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 FontFamilyProperty = BindableProperty.Create("FontFamily", typeof(string), typeof(TextLabel), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.FONT_FAMILY).Get(out temp);
+ return temp;
+ });
+ /// 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 FontStyleProperty = BindableProperty.Create("FontStyle", typeof(PropertyMap), typeof(TextLabel), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.FONT_STYLE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.FONT_STYLE).Get(temp);
+ return temp;
+ });
+ /// 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 PointSizeProperty = BindableProperty.Create("PointSize", typeof(float), typeof(TextLabel), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.POINT_SIZE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.POINT_SIZE).Get(out temp);
+ return temp;
+ });
+ /// 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 MultiLineProperty = BindableProperty.Create("MultiLine", typeof(bool), typeof(TextLabel), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.MULTI_LINE, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.MULTI_LINE).Get(out temp);
+ return temp;
+ });
+ /// 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 HorizontalAlignmentProperty = BindableProperty.Create("HorizontalAlignment", typeof(HorizontalAlignment), typeof(TextLabel), HorizontalAlignment.Begin, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((HorizontalAlignment)newValue)
+ {
+ case HorizontalAlignment.Begin: { valueToString = "BEGIN"; break; }
+ case HorizontalAlignment.Center: { valueToString = "CENTER"; break; }
+ case HorizontalAlignment.End: { valueToString = "END"; break; }
+ default: { valueToString = "BEGIN"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
+ {
+ NUILog.Error("HorizontalAlignment get error!");
+ }
+ switch (temp)
+ {
+ case "BEGIN": return HorizontalAlignment.Begin;
+ case "CENTER": return HorizontalAlignment.Center;
+ case "END": return HorizontalAlignment.End;
+ default: return HorizontalAlignment.Begin;
+ }
+ });
+ /// 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 VerticalAlignmentProperty = BindableProperty.Create("VerticalAlignment", typeof(VerticalAlignment), typeof(TextLabel), VerticalAlignment.Bottom, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((VerticalAlignment)newValue)
+ {
+ case VerticalAlignment.Top: { valueToString = "TOP"; break; }
+ case VerticalAlignment.Center: { valueToString = "CENTER"; break; }
+ case VerticalAlignment.Bottom: { valueToString = "BOTTOM"; break; }
+ default: { valueToString = "BOTTOM"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
+ {
+ NUILog.Error("VerticalAlignment get error!");
+ }
+
+ switch (temp)
+ {
+ case "TOP": return VerticalAlignment.Top;
+ case "CENTER": return VerticalAlignment.Center;
+ case "BOTTOM": return VerticalAlignment.Bottom;
+ default: return VerticalAlignment.Bottom;
+ }
+ });
+ /// 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 TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(TextLabel), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.TEXT_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 ShadowOffsetProperty = BindableProperty.Create("ShadowOffset", typeof(Vector2), typeof(TextLabel), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.SHADOW_OFFSET).Get(temp);
+ return temp;
+ });
+ /// 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 ShadowColorProperty = BindableProperty.Create("ShadowColor", typeof(Vector4), typeof(TextLabel), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.SHADOW_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 UnderlineEnabledProperty = BindableProperty.Create("UnderlineEnabled", typeof(bool), typeof(TextLabel), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.UNDERLINE_ENABLED, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.UNDERLINE_ENABLED).Get(out temp);
+ return temp;
+ });
+ /// 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 UnderlineColorProperty = BindableProperty.Create("UnderlineColor", typeof(Vector4), typeof(TextLabel), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.UNDERLINE_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.UNDERLINE_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 UnderlineHeightProperty = BindableProperty.Create("UnderlineHeight", typeof(float), typeof(TextLabel), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.UNDERLINE_HEIGHT, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.UNDERLINE_HEIGHT).Get(out temp);
+ return temp;
+ });
+ /// 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 EnableMarkupProperty = BindableProperty.Create("EnableMarkup", typeof(bool), typeof(TextLabel), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.ENABLE_MARKUP).Get(out temp);
+ return temp;
+ });
+ /// 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 EnableAutoScrollProperty = BindableProperty.Create("EnableAutoScroll", typeof(bool), typeof(TextLabel), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.ENABLE_AUTO_SCROLL, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.ENABLE_AUTO_SCROLL).Get(out temp);
+ return temp;
+ });
+ /// 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 AutoScrollSpeedProperty = BindableProperty.Create("AutoScrollSpeed", typeof(int), typeof(TextLabel), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_SPEED, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_SPEED).Get(out temp);
+ return temp;
+ });
+ /// 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 AutoScrollLoopCountProperty = BindableProperty.Create("AutoScrollLoopCount", typeof(int), typeof(TextLabel), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_LOOP_COUNT, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_LOOP_COUNT).Get(out temp);
+ return temp;
+ });
+ /// 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 AutoScrollGapProperty = BindableProperty.Create("AutoScrollGap", typeof(float), typeof(TextLabel), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_GAP, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_GAP).Get(out temp);
+ return temp;
+ });
+ /// 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 LineSpacingProperty = BindableProperty.Create("LineSpacing", typeof(float), typeof(TextLabel), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.LINE_SPACING, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.LINE_SPACING).Get(out temp);
+ return temp;
+ });
+ /// 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 UnderlineProperty = BindableProperty.Create("Underline", typeof(PropertyMap), typeof(TextLabel), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.UNDERLINE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.UNDERLINE).Get(temp);
+ return temp;
+ });
+ /// 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 ShadowProperty = BindableProperty.Create("Shadow", typeof(PropertyMap), typeof(TextLabel), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.SHADOW, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.SHADOW).Get(temp);
+ return temp;
+ });
+ /// 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 EmbossProperty = BindableProperty.Create("Emboss", typeof(string), typeof(TextLabel), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.EMBOSS, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.EMBOSS).Get(out temp);
+ return temp;
+ });
+ /// 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 OutlineProperty = BindableProperty.Create("Outline", typeof(PropertyMap), typeof(TextLabel), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.OUTLINE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.OUTLINE).Get(temp);
+ return temp;
+ });
+ /// 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 PixelSizeProperty = BindableProperty.Create("PixelSize", typeof(float), typeof(TextLabel), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.PIXEL_SIZE).Get(out temp);
+ return temp;
+ });
+ /// 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 EllipsisProperty = BindableProperty.Create("Ellipsis", typeof(bool), typeof(TextLabel), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.ELLIPSIS, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.ELLIPSIS).Get(out temp);
+ return temp;
+ });
+ /// 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 AutoScrollLoopDelayProperty = BindableProperty.Create("AutoScrollLoopDelay", typeof(float), typeof(TextLabel), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_LOOP_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_LOOP_DELAY).Get(out temp);
+ return temp;
+ });
+ /// 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 AutoScrollStopModeProperty = BindableProperty.Create("AutoScrollStopMode", typeof(AutoScrollStopMode), typeof(TextLabel), AutoScrollStopMode.FinishLoop, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_STOP_MODE, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ string temp;
+ if(Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.AUTO_SCROLL_STOP_MODE).Get(out temp) == false)
+ {
+ NUILog.Error("AutoScrollStopMode get error!");
+ }
+ switch (temp)
+ {
+ case "FINISH_LOOP": return AutoScrollStopMode.FinishLoop;
+ case "IMMEDIATE": return AutoScrollStopMode.Immediate;
+ default: return AutoScrollStopMode.FinishLoop;
+ }
+ });
+ /// 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 LineWrapModeProperty = BindableProperty.Create("LineWrapMode", typeof(LineWrapMode), typeof(TextLabel), LineWrapMode.Word, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.LINE_WRAP_MODE, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ int temp;
+ if (false == Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.LINE_WRAP_MODE).Get(out temp))
+ {
+ NUILog.Error("LineWrapMode get error!");
+ }
+ return (LineWrapMode)temp;
+ });
+ /// 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 VerticalLineAlignmentProperty = BindableProperty.Create("VerticalLineAlignment", typeof(VerticalLineAlignment), typeof(TextLabel), VerticalLineAlignment.Bottom, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(textLabel.swigCPtr, TextLabel.Property.VERTICAL_LINE_ALIGNMENT, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var textLabel = (TextLabel)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.VERTICAL_LINE_ALIGNMENT).Get(out temp);
+ return (VerticalLineAlignment)temp;
+ });
+
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private string textLabelSid = null;
private bool systemlangTextFlag = false;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
+
internal TextLabel(TextLabel handle) : this(NDalicPINVOKE.new_TextLabel__SWIG_1(TextLabel.getCPtr(handle)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
+ protected override void OnBindingContextChanged()
+ {
+ base.OnBindingContextChanged();
+ }
+
/// <summary>
/// The TranslatableText property.<br />
/// The text can set the SID value.<br />
{
get
{
- string temp;
- GetProperty(TextLabel.Property.TEXT).Get(out temp);
- return temp;
+ return (string)GetValue(TextProperty);
}
set
{
- SetProperty(TextLabel.Property.TEXT, new Tizen.NUI.PropertyValue(value));
+ SetValue(TextProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextLabel.Property.FONT_FAMILY).Get(out temp);
- return temp;
+ return (string)GetValue(FontFamilyProperty);
}
set
{
- SetProperty(TextLabel.Property.FONT_FAMILY, new Tizen.NUI.PropertyValue(value));
+ SetValue(FontFamilyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextLabel.Property.FONT_STYLE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(FontStyleProperty);
}
set
{
- SetProperty(TextLabel.Property.FONT_STYLE, new Tizen.NUI.PropertyValue(value));
+ SetValue(FontStyleProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextLabel.Property.POINT_SIZE).Get(out temp);
- return temp;
+ return (float)GetValue(PointSizeProperty);
}
set
{
- SetProperty(TextLabel.Property.POINT_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(PointSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextLabel.Property.MULTI_LINE).Get(out temp);
- return temp;
+ return (bool)GetValue(MultiLineProperty);
}
set
{
- SetProperty(TextLabel.Property.MULTI_LINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(MultiLineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT).Get(out temp) == false)
- {
- NUILog.Error("HorizontalAlignment get error!");
- }
- switch (temp)
- {
- case "BEGIN":
- return HorizontalAlignment.Begin;
- case "CENTER":
- return HorizontalAlignment.Center;
- case "END":
- return HorizontalAlignment.End;
- default:
- return HorizontalAlignment.Begin;
- }
+ return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case HorizontalAlignment.Begin:
- {
- valueToString = "BEGIN";
- break;
- }
- case HorizontalAlignment.Center:
- {
- valueToString = "CENTER";
- break;
- }
- case HorizontalAlignment.End:
- {
- valueToString = "END";
- break;
- }
- default:
- {
- valueToString = "BEGIN";
- break;
- }
- }
- SetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(HorizontalAlignmentProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(TextLabel.Property.VERTICAL_ALIGNMENT).Get(out temp) == false)
- {
- NUILog.Error("VerticalAlignment get error!");
- }
-
- switch (temp)
- {
- case "TOP":
- return VerticalAlignment.Top;
- case "CENTER":
- return VerticalAlignment.Center;
- case "BOTTOM":
- return VerticalAlignment.Bottom;
- default:
- return VerticalAlignment.Bottom;
- }
+ return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case VerticalAlignment.Top:
- {
- valueToString = "TOP";
- break;
- }
- case VerticalAlignment.Center:
- {
- valueToString = "CENTER";
- break;
- }
- case VerticalAlignment.Bottom:
- {
- valueToString = "BOTTOM";
- break;
- }
- default:
- {
- valueToString = "BOTTOM";
- break;
- }
- }
- SetProperty(TextLabel.Property.VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(VerticalAlignmentProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextLabel.Property.TEXT_COLOR).Get(temp);
- return temp;
+ return (Color)GetValue(TextColorProperty);
}
set
{
- SetProperty(TextLabel.Property.TEXT_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(TextColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(TextLabel.Property.SHADOW_OFFSET).Get(temp);
- return temp;
+ return (Vector2)GetValue(ShadowOffsetProperty);
}
set
{
- SetProperty(TextLabel.Property.SHADOW_OFFSET, new Tizen.NUI.PropertyValue(value));
+ SetValue(ShadowOffsetProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextLabel.Property.SHADOW_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(ShadowColorProperty);
}
set
{
- SetProperty(TextLabel.Property.SHADOW_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(ShadowColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextLabel.Property.UNDERLINE_ENABLED).Get(out temp);
- return temp;
+ return (bool)GetValue(UnderlineEnabledProperty);
}
set
{
- SetProperty(TextLabel.Property.UNDERLINE_ENABLED, new Tizen.NUI.PropertyValue(value));
+ SetValue(UnderlineEnabledProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(TextLabel.Property.UNDERLINE_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(UnderlineColorProperty);
}
set
{
- SetProperty(TextLabel.Property.UNDERLINE_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(UnderlineColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextLabel.Property.UNDERLINE_HEIGHT).Get(out temp);
- return temp;
+ return (float)GetValue(UnderlineHeightProperty);
}
set
{
- SetProperty(TextLabel.Property.UNDERLINE_HEIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(UnderlineHeightProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextLabel.Property.ENABLE_MARKUP).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableMarkupProperty);
}
set
{
- SetProperty(TextLabel.Property.ENABLE_MARKUP, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableMarkupProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL).Get(out temp);
- return temp;
+ return (bool)GetValue(EnableAutoScrollProperty);
}
set
{
- SetProperty(TextLabel.Property.ENABLE_AUTO_SCROLL, new Tizen.NUI.PropertyValue(value));
+ SetValue(EnableAutoScrollProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(TextLabel.Property.AUTO_SCROLL_SPEED).Get(out temp);
- return temp;
+ return (int)GetValue(AutoScrollSpeedProperty);
}
set
{
- SetProperty(TextLabel.Property.AUTO_SCROLL_SPEED, new Tizen.NUI.PropertyValue(value));
+ SetValue(AutoScrollSpeedProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT).Get(out temp);
- return temp;
+ return (int)GetValue(AutoScrollLoopCountProperty);
}
set
{
- SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_COUNT, new Tizen.NUI.PropertyValue(value));
+ SetValue(AutoScrollLoopCountProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextLabel.Property.AUTO_SCROLL_GAP).Get(out temp);
- return temp;
+ return (float)GetValue(AutoScrollGapProperty);
}
set
{
- SetProperty(TextLabel.Property.AUTO_SCROLL_GAP, new Tizen.NUI.PropertyValue(value));
+ SetValue(AutoScrollGapProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextLabel.Property.LINE_SPACING).Get(out temp);
- return temp;
+ return (float)GetValue(LineSpacingProperty);
}
set
{
- SetProperty(TextLabel.Property.LINE_SPACING, new Tizen.NUI.PropertyValue(value));
+ SetValue(LineSpacingProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextLabel.Property.UNDERLINE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(UnderlineProperty);
}
set
{
- SetProperty(TextLabel.Property.UNDERLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(UnderlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextLabel.Property.SHADOW).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(ShadowProperty);
}
set
{
- SetProperty(TextLabel.Property.SHADOW, new Tizen.NUI.PropertyValue(value));
+ SetValue(ShadowProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TextLabel.Property.EMBOSS).Get( out temp);
- return temp;
+ return (string)GetValue(EmbossProperty);
}
set
{
- SetProperty(TextLabel.Property.EMBOSS, new Tizen.NUI.PropertyValue(value));
+ SetValue(EmbossProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(TextLabel.Property.OUTLINE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(OutlineProperty);
}
set
{
- SetProperty(TextLabel.Property.OUTLINE, new Tizen.NUI.PropertyValue(value));
+ SetValue(OutlineProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextLabel.Property.PIXEL_SIZE).Get(out temp);
- return temp;
+ return (float)GetValue(PixelSizeProperty);
}
set
{
- SetProperty(TextLabel.Property.PIXEL_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(PixelSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(TextLabel.Property.ELLIPSIS).Get(out temp);
- return temp;
+ return (bool)GetValue(EllipsisProperty);
}
set
{
- SetProperty(TextLabel.Property.ELLIPSIS, new Tizen.NUI.PropertyValue(value));
+ SetValue(EllipsisProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY).Get(out temp);
- return temp;
+ return (float)GetValue(AutoScrollLoopDelayProperty);
}
set
{
- SetProperty(TextLabel.Property.AUTO_SCROLL_LOOP_DELAY, new Tizen.NUI.PropertyValue(value));
+ SetValue(AutoScrollLoopDelayProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if(GetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE).Get(out temp) == false)
- {
- NUILog.Error("AutoScrollStopMode get error!");
- }
- switch (temp)
- {
- case "FINISH_LOOP":
- return AutoScrollStopMode.FinishLoop;
- case "IMMEDIATE":
- return AutoScrollStopMode.Immediate;
- default:
- return AutoScrollStopMode.FinishLoop;
- }
+ return (AutoScrollStopMode)GetValue(AutoScrollStopModeProperty);
}
set
{
- SetProperty(TextLabel.Property.AUTO_SCROLL_STOP_MODE, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(AutoScrollStopModeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp;
- if(GetProperty(TextLabel.Property.LINE_WRAP_MODE).Get(out temp) == false)
- {
- NUILog.Error("LineWrapMode get error!");
- }
- return (LineWrapMode)temp;
+ return (LineWrapMode)GetValue(LineWrapModeProperty);
}
set
{
- SetProperty(TextLabel.Property.LINE_WRAP_MODE, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(LineWrapModeProperty, value);
NotifyPropertyChanged();
}
}
/// The text direction.
/// </summary>
/// <since_tizen> 5 </since_tizen>
+ /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public TextDirection TextDirection
{
get
/// The text vertical line alignment.
/// </summary>
/// <since_tizen> 5 </since_tizen>
+ /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
public VerticalLineAlignment VerticalLineAlignment
{
get
{
- int temp = 0;
- GetProperty(TextLabel.Property.VERTICAL_LINE_ALIGNMENT).Get(out temp);
- return (VerticalLineAlignment)temp;
+ return (VerticalLineAlignment)GetValue(VerticalLineAlignmentProperty);
}
set
{
- SetProperty(TextLabel.Property.VERTICAL_LINE_ALIGNMENT, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(VerticalLineAlignmentProperty, value);
NotifyPropertyChanged();
}
}
-
}
}
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
/// VideoView is a control for video playback and display.
/// </summary>
/// <since_tizen> 3 </since_tizen>
+ [ContentProperty("ResourceUrl")]
public class VideoView : View
{
+ /// 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 VideoProperty = BindableProperty.Create("Video", typeof(PropertyMap), typeof(VideoView), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var videoView = (VideoView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var videoView = (VideoView)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.VIDEO).Get(temp);
+ return temp;
+ });
+ /// 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 LoopingProperty = BindableProperty.Create("Looping", typeof(bool), typeof(VideoView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var videoView = (VideoView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var videoView = (VideoView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.LOOPING).Get(out temp);
+ return temp;
+ });
+ /// 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 MutedProperty = BindableProperty.Create("Muted", typeof(bool), typeof(VideoView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var videoView = (VideoView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.MUTED, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var videoView = (VideoView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.MUTED).Get(out temp);
+ return temp;
+ });
+ /// 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 VolumeProperty = BindableProperty.Create("Volume", typeof(PropertyMap), typeof(VideoView), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var videoView = (VideoView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.VOLUME, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var videoView = (VideoView)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.VOLUME).Get(temp);
+ return temp;
+ });
+ /// 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 UnderlayProperty = BindableProperty.Create("Underlay", typeof(bool), typeof(VideoView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var videoView = (VideoView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.UNDERLAY, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var videoView = (VideoView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.UNDERLAY).Get(out temp);
+ return temp;
+ });
+ /// 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 ResourceUrlProperty = BindableProperty.Create("ResourceUrl", typeof(string), typeof(VideoView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var videoView = (VideoView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(videoView.swigCPtr, VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var videoView = (VideoView)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(videoView.swigCPtr, VideoView.Property.VIDEO).Get(out temp);
+ return temp;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal VideoView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.VideoView_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(VideoView.Property.VIDEO).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(VideoProperty);
}
set
{
- SetProperty(VideoView.Property.VIDEO, new Tizen.NUI.PropertyValue(value));
+ SetValue(VideoProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(VideoView.Property.LOOPING).Get(out temp);
- return temp;
+ return (bool)GetValue(LoopingProperty);
}
set
{
- SetProperty(VideoView.Property.LOOPING, new Tizen.NUI.PropertyValue(value));
+ SetValue(LoopingProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(VideoView.Property.MUTED).Get(out temp);
- return temp;
+ return (bool)GetValue(MutedProperty);
}
set
{
- SetProperty(VideoView.Property.MUTED, new Tizen.NUI.PropertyValue(value));
+ SetValue(MutedProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(VideoView.Property.VOLUME).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(VolumeProperty);
}
set
{
- SetProperty(VideoView.Property.VOLUME, new PropertyValue(value));
+ SetValue(VolumeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(VideoView.Property.UNDERLAY).Get(out temp);
- return temp;
+ return (bool)GetValue(UnderlayProperty);
}
set
{
- SetProperty(VideoView.Property.UNDERLAY, new PropertyValue(value));
+ SetValue(UnderlayProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string tmp;
- GetProperty(VideoView.Property.VIDEO).Get(out tmp);
- return tmp;
+ return (string)GetValue(ResourceUrlProperty);
}
set
{
- SetProperty(VideoView.Property.VIDEO, new PropertyValue(value));
+ SetValue(ResourceUrlProperty, value);
NotifyPropertyChanged();
}
}
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.BaseComponents
{
/// View is the base class for all views.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- public class View : Container
+ public class View : Container, IResourcesProvider
{
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+ /// 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 bool IsResourcesCreated
+ {
+ get
+ {
+ return Application.Current.IsResourcesCreated;
+ }
+ }
+
+ /// 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 ResourceDictionary Resources
+ {
+ get
+ {
+ return Application.Current.Resources;
+ }
+ set
+ {
+ Application.Current.Resources = value;
+ }
+ }
+
+ /// 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 StyleNameProperty = BindableProperty.Create("StyleName", typeof(string), typeof(View), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.STYLE_NAME, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.STYLE_NAME).Get(out temp);
+ return temp;
+ });
+ /// 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 BackgroundColorProperty = BindableProperty.Create("BackgroundColor", typeof(Color), typeof(View), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.BACKGROUND, new Tizen.NUI.PropertyValue((Color)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Color backgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+
+ Tizen.NUI.PropertyMap background = view.Background;
+ int visualType = 0;
+ background.Find(Visual.Property.Type)?.Get(out visualType);
+ if (visualType == (int)Visual.Type.Color)
+ {
+ background.Find(ColorVisualProperty.MixColor)?.Get(backgroundColor);
+ }
+
+ return backgroundColor;
+ });
+ /// 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 BackgroundImageProperty = BindableProperty.Create("BackgroundImage", typeof(string), typeof(View), default(string), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.BACKGROUND, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string backgroundImage = "";
+
+ Tizen.NUI.PropertyMap background = view.Background;
+ int visualType = 0;
+ background.Find(Visual.Property.Type)?.Get(out visualType);
+ if (visualType == (int)Visual.Type.Image)
+ {
+ background.Find(ImageVisualProperty.URL)?.Get(out backgroundImage);
+ }
+
+ return backgroundImage;
+ });
+ /// 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 BackgroundProperty = BindableProperty.Create("Background", typeof(PropertyMap), typeof(View), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.BACKGROUND, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.BACKGROUND).Get(temp);
+ return temp;
+ });
+ /// 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 StateProperty = BindableProperty.Create("State", typeof(States), typeof(View), States.Normal, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.STATE, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ int temp = 0;
+ if (Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.STATE).Get(out temp) == false)
+ {
+ NUILog.Error("State get error!");
+ }
+ switch (temp)
+ {
+ case 0: return States.Normal;
+ case 1: return States.Focused;
+ case 2: return States.Disabled;
+ default: return States.Normal;
+ }
+ });
+ /// 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 SubStateProperty = BindableProperty.Create("SubState", typeof(States), typeof(View), States.Normal, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((States)newValue)
+ {
+ case States.Normal: { valueToString = "NORMAL"; break; }
+ case States.Focused: { valueToString = "FOCUSED"; break; }
+ case States.Disabled: { valueToString = "DISABLED"; break; }
+ default: { valueToString = "NORMAL"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SUB_STATE, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SUB_STATE).Get(out temp) == false)
+ {
+ NUILog.Error("subState get error!");
+ }
+ switch (temp)
+ {
+ case "NORMAL": return States.Normal;
+ case "FOCUSED": return States.Focused;
+ case "DISABLED": return States.Disabled;
+ default: return States.Normal;
+ }
+ });
+ /// 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 TooltipProperty = BindableProperty.Create("Tooltip", typeof(PropertyMap), typeof(View), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.TOOLTIP, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.TOOLTIP).Get(temp);
+ return temp;
+ });
+ // public static readonly BindableProperty TooltipTextProperty = BindableProperty.Create("TooltipText", typeof(string), typeof(View), default(string), propertyChanged: (bindable, oldValue, newValue) =>
+ // {
+ // var view = (View)bindable;
+ // if (newValue != null)
+ // {
+ // Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.TOOLTIP, new Tizen.NUI.PropertyValue((string)newValue));
+ // }
+ // });
+ public static readonly BindableProperty FlexProperty = BindableProperty.Create("Flex", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, FlexContainer.ChildProperty.FLEX, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, FlexContainer.ChildProperty.FLEX).Get(out temp);
+ return temp;
+ });
+ /// 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 AlignSelfProperty = BindableProperty.Create("AlignSelf", typeof(int), typeof(View), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, FlexContainer.ChildProperty.ALIGN_SELF, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, FlexContainer.ChildProperty.ALIGN_SELF).Get(out temp);
+ return temp;
+ });
+ /// 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 FlexMarginProperty = BindableProperty.Create("FlexMargin", typeof(Vector4), typeof(View), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, FlexContainer.ChildProperty.FLEX_MARGIN, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, FlexContainer.ChildProperty.FLEX_MARGIN).Get(temp);
+ return temp;
+ });
+ /// 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 CellIndexProperty = BindableProperty.Create("CellIndex", typeof(Vector2), typeof(View), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, TableView.ChildProperty.CELL_INDEX, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, TableView.ChildProperty.CELL_INDEX).Get(temp);
+ return temp;
+ });
+ /// 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 RowSpanProperty = BindableProperty.Create("RowSpan", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, TableView.ChildProperty.ROW_SPAN, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, TableView.ChildProperty.ROW_SPAN).Get(out temp);
+ return temp;
+ });
+ /// 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 ColumnSpanProperty = BindableProperty.Create("ColumnSpan", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, TableView.ChildProperty.COLUMN_SPAN, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, TableView.ChildProperty.COLUMN_SPAN).Get(out temp);
+ return temp;
+ });
+ /// 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 CellHorizontalAlignmentProperty = BindableProperty.Create("CellHorizontalAlignment", typeof(HorizontalAlignmentType), typeof(View), HorizontalAlignmentType.Left, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ string valueToString = "";
+
+ if (newValue != null)
+ {
+ switch ((HorizontalAlignmentType)newValue)
+ {
+ case Tizen.NUI.HorizontalAlignmentType.Left: { valueToString = "left"; break; }
+ case Tizen.NUI.HorizontalAlignmentType.Center: { valueToString = "center"; break; }
+ case Tizen.NUI.HorizontalAlignmentType.Right: { valueToString = "right"; break; }
+ default: { valueToString = "left"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, TableView.ChildProperty.CELL_HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(view.swigCPtr, TableView.ChildProperty.CELL_HORIZONTAL_ALIGNMENT).Get(out temp) == false)
+ {
+ NUILog.Error("CellHorizontalAlignment get error!");
+ }
+
+ switch (temp)
+ {
+ case "left": return Tizen.NUI.HorizontalAlignmentType.Left;
+ case "center": return Tizen.NUI.HorizontalAlignmentType.Center;
+ case "right": return Tizen.NUI.HorizontalAlignmentType.Right;
+ default: return Tizen.NUI.HorizontalAlignmentType.Left;
+ }
+ });
+ /// 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 CellVerticalAlignmentProperty = BindableProperty.Create("CellVerticalAlignment", typeof(VerticalAlignmentType), typeof(View), VerticalAlignmentType.Top, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ string valueToString = "";
+
+ if (newValue != null)
+ {
+ switch ((VerticalAlignmentType)newValue)
+ {
+ case Tizen.NUI.VerticalAlignmentType.Top: { valueToString = "top"; break; }
+ case Tizen.NUI.VerticalAlignmentType.Center: { valueToString = "center"; break; }
+ case Tizen.NUI.VerticalAlignmentType.Bottom: { valueToString = "bottom"; break; }
+ default: { valueToString = "top"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT).Get(out temp);
+ {
+ NUILog.Error("CellVerticalAlignment get error!");
+ }
+
+ switch (temp)
+ {
+ case "top": return Tizen.NUI.VerticalAlignmentType.Top;
+ case "center": return Tizen.NUI.VerticalAlignmentType.Center;
+ case "bottom": return Tizen.NUI.VerticalAlignmentType.Bottom;
+ default: return Tizen.NUI.VerticalAlignmentType.Top;
+ }
+ });
+ /// 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 LeftFocusableViewProperty = BindableProperty.Create("LeftFocusableView", typeof(View), typeof(View), default(View), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null) { view.LeftFocusableViewId = (int)(newValue as View).GetId(); }
+ else { view.LeftFocusableViewId = -1; }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ if (view.LeftFocusableViewId >= 0) { return view.ConvertIdToView((uint)view.LeftFocusableViewId); }
+ return null;
+ });
+ /// 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 RightFocusableViewProperty = BindableProperty.Create("RightFocusableView", typeof(View), typeof(View), default(View), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null) { view.RightFocusableViewId = (int)(newValue as View).GetId(); }
+ else { view.RightFocusableViewId = -1; }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ if (view.RightFocusableViewId >= 0) { return view.ConvertIdToView((uint)view.RightFocusableViewId); }
+ return null;
+ });
+ /// 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 UpFocusableViewProperty = BindableProperty.Create("UpFocusableView", typeof(View), typeof(View), default(View), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null) { view.UpFocusableViewId = (int)(newValue as View).GetId(); }
+ else { view.UpFocusableViewId = -1; }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ if (view.UpFocusableViewId >= 0) { return view.ConvertIdToView((uint)view.UpFocusableViewId); }
+ return null;
+ });
+ /// 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 DownFocusableViewProperty = BindableProperty.Create("DownFocusableView", typeof(View), typeof(View), default(View), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null) { view.DownFocusableViewId = (int)(newValue as View).GetId(); }
+ else { view.DownFocusableViewId = -1; }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ if (view.DownFocusableViewId >= 0) { return view.ConvertIdToView((uint)view.DownFocusableViewId); }
+ return null;
+ });
+ /// 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 FocusableProperty = BindableProperty.Create("Focusable", typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null) { view.SetKeyboardFocusable((bool)newValue); }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ return view.IsKeyboardFocusable();
+ });
+ /// 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 Size2DProperty = BindableProperty.Create("Size2D", typeof(Size2D), typeof(View), new Size2D(0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE, new Tizen.NUI.PropertyValue( new Size((Size2D)newValue)));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Size temp = new Size(0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SIZE).Get(temp);
+ Size2D size = new Size2D((int)temp.Width, (int)temp.Height);
+ Console.WriteLine($"View Size2DProperty get width: {size.Width} height: {size.Height}");
+ return size;
+ });
+ /// 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 OpacityProperty = BindableProperty.Create("Opacity", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.OPACITY, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.OPACITY).Get(out temp);
+ return temp;
+ });
+ /// 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 Position2DProperty = BindableProperty.Create("Position2D", typeof(Position2D), typeof(View), new Position2D(0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.POSITION, new Tizen.NUI.PropertyValue( new Position((Position2D)newValue) ));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Position temp = new Position(0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.POSITION).Get(temp);
+ return new Position2D(temp);
+ });
+ /// 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 PositionUsesPivotPointProperty = BindableProperty.Create("PositionUsesPivotPoint", typeof(bool), typeof(View), true, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.POSITION_USES_ANCHOR_POINT, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ Console.WriteLine("View PositionUsesPivotPointProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.POSITION_USES_ANCHOR_POINT).Get(out temp);
+ return temp;
+ });
+ /// 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 SiblingOrderProperty = BindableProperty.Create("SiblingOrder", typeof(int), typeof(View), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ int value;
+ if (newValue != null)
+ {
+ value = (int)newValue;
+ if(value < 0)
+ {
+ NUILog.Error("SiblingOrder should be bigger than 0 or equal to 0.");
+ return;
+ }
+ var siblings = view.GetParent()?.Children;
+ if (siblings != null)
+ {
+ int currentOrder = siblings.IndexOf(view);
+ if (value != currentOrder)
+ {
+ if (value == 0) { view.LowerToBottom(); }
+ else if (value < siblings.Count - 1)
+ {
+ if (value > currentOrder) { view.RaiseAbove(siblings[value]); }
+ else { view.LowerBelow(siblings[value]); }
+ }
+ else { view.RaiseToTop(); }
+ }
+ }
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ var parentChildren = view.GetParent()?.Children;
+ int currentOrder = 0;
+ if (parentChildren != null)
+ {
+ currentOrder = parentChildren.IndexOf(view);
+ if (currentOrder < 0) { return 0; }
+ else if (currentOrder < parentChildren.Count) { return currentOrder; }
+ }
+
+ return 0;
+ });
+ /// 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 ParentOriginProperty = BindableProperty.Create("ParentOrigin", typeof(Position), typeof(View), Position.ParentOriginTopLeft, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.PARENT_ORIGIN, new Tizen.NUI.PropertyValue((Position)newValue));
+ }
+ Console.WriteLine("View ParentOriginProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Position temp = new Position(0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.PARENT_ORIGIN).Get(temp);
+ return temp;
+ }
+ );
+ /// 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 PivotPointProperty = BindableProperty.Create("PivotPoint", typeof(Position), typeof(View), Position.PivotPointTopLeft, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.ANCHOR_POINT, new Tizen.NUI.PropertyValue((Position)newValue));
+ }
+ Console.WriteLine("View PivotPointProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Position temp = new Position(0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.ANCHOR_POINT).Get(temp);
+ return temp;
+ });
+ /// 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 SizeWidthProperty = BindableProperty.Create("SizeWidth", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ Console.WriteLine("View SizeWidthProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SIZE_WIDTH).Get(out temp);
+ Console.WriteLine($"View SizeWidthProperty get Value: {temp}");
+ return temp;
+ });
+ /// 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 SizeHeightProperty = BindableProperty.Create("SizeHeight", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ Console.WriteLine("View SizeHeightProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SIZE_HEIGHT).Get(out temp);
+ Console.WriteLine($"View SizeHeightProperty get Value: {temp}");
+ return temp;
+ });
+ /// 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 PositionProperty = BindableProperty.Create("Position", typeof(Position), typeof(View), Position.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.POSITION, new Tizen.NUI.PropertyValue((Position)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Position temp = new Position(0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.POSITION).Get(temp);
+ return temp;
+ });
+ /// 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 PositionXProperty = BindableProperty.Create("PositionX", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.POSITION_X, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.POSITION_X).Get(out temp);
+ return temp;
+ });
+ /// 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 PositionYProperty = BindableProperty.Create("PositionY", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.POSITION_Y, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.POSITION_Y).Get(out temp);
+ return temp;
+ });
+ /// 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 PositionZProperty = BindableProperty.Create("PositionZ", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.POSITION_Z, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.POSITION_Z).Get(out temp);
+ return temp;
+ });
+ /// 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 OrientationProperty = BindableProperty.Create("Orientation", typeof(Rotation), typeof(View), new Rotation(new Radian(0), Vector3.ZAxis), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.ORIENTATION, new Tizen.NUI.PropertyValue((Rotation)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Rotation temp = new Rotation();
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.ORIENTATION).Get(temp);
+ return temp;
+ });
+ /// 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 ScaleProperty = BindableProperty.Create("Scale", typeof(Vector3), typeof(View), Vector3.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SCALE, new Tizen.NUI.PropertyValue((Vector3)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SCALE).Get(temp);
+ return temp;
+ });
+ /// 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 ScaleXProperty = BindableProperty.Create("ScaleX", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SCALE_X, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SCALE_X).Get(out temp);
+ return temp;
+ });
+ /// 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 ScaleYProperty = BindableProperty.Create("ScaleY", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SCALE_Y, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SCALE_Y).Get(out temp);
+ return temp;
+ });
+ /// 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 ScaleZProperty = BindableProperty.Create("ScaleZ", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SCALE_Z, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SCALE_Z).Get(out temp);
+ return temp;
+ });
+ /// 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 NameProperty = BindableProperty.Create("Name", typeof(string), typeof(View), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.NAME, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.NAME).Get(out temp);
+ return temp;
+ });
+ /// 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 SensitiveProperty = BindableProperty.Create("Sensitive", typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SENSITIVE, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SENSITIVE).Get(out temp);
+ return temp;
+ });
+ /// 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 LeaveRequiredProperty = BindableProperty.Create("LeaveRequired", typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.LEAVE_REQUIRED, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.LEAVE_REQUIRED).Get(out temp);
+ return temp;
+ });
+ /// 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 InheritOrientationProperty = BindableProperty.Create("InheritOrientation", typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.INHERIT_ORIENTATION, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.INHERIT_ORIENTATION).Get(out temp);
+ return temp;
+ });
+ /// 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 InheritScaleProperty = BindableProperty.Create("InheritScale", typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.INHERIT_SCALE, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.INHERIT_SCALE).Get(out temp);
+ return temp;
+ });
+ /// 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 DrawModeProperty = BindableProperty.Create("DrawMode", typeof(DrawModeType), typeof(View), DrawModeType.Normal, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.DRAW_MODE, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.DRAW_MODE).Get(out temp) == false)
+ {
+ NUILog.Error("DrawMode get error!");
+ }
+ switch (temp)
+ {
+ case "NORMAL": return DrawModeType.Normal;
+ case "OVERLAY_2D": return DrawModeType.Overlay2D;
+ case "STENCIL": return DrawModeType.Stencil;
+ default: return DrawModeType.Normal;
+ }
+ });
+ /// 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 SizeModeFactorProperty = BindableProperty.Create("SizeModeFactor", typeof(Vector3), typeof(View), Vector3.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE_MODE_FACTOR, new Tizen.NUI.PropertyValue((Vector3)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SIZE_MODE_FACTOR).Get(temp);
+ return temp;
+ });
+ /// 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 WidthResizePolicyProperty = BindableProperty.Create("WidthResizePolicy", typeof(ResizePolicyType), typeof(View), ResizePolicyType.Fixed, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.WIDTH_RESIZE_POLICY, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.WIDTH_RESIZE_POLICY).Get(out temp) == false)
+ {
+ NUILog.Error("WidthResizePolicy get error!");
+ }
+ switch (temp)
+ {
+ case "FIXED": return ResizePolicyType.Fixed;
+ case "USE_NATURAL_SIZE": return ResizePolicyType.UseNaturalSize;
+ case "FILL_TO_PARENT": return ResizePolicyType.FillToParent;
+ case "SIZE_RELATIVE_TO_PARENT": return ResizePolicyType.SizeRelativeToParent;
+ case "SIZE_FIXED_OFFSET_FROM_PARENT": return ResizePolicyType.SizeFixedOffsetFromParent;
+ case "FIT_TO_CHILDREN": return ResizePolicyType.FitToChildren;
+ case "DIMENSION_DEPENDENCY": return ResizePolicyType.DimensionDependency;
+ case "USE_ASSIGNED_SIZE": return ResizePolicyType.UseAssignedSize;
+ default: return ResizePolicyType.Fixed;
+ }
+ });
+ /// 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 HeightResizePolicyProperty = BindableProperty.Create("HeightResizePolicy", typeof(ResizePolicyType), typeof(View), ResizePolicyType.Fixed, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.HEIGHT_RESIZE_POLICY, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.HEIGHT_RESIZE_POLICY).Get(out temp) == false)
+ {
+ NUILog.Error("HeightResizePolicy get error!");
+ }
+ switch (temp)
+ {
+ case "FIXED": return ResizePolicyType.Fixed;
+ case "USE_NATURAL_SIZE": return ResizePolicyType.UseNaturalSize;
+ case "FILL_TO_PARENT": return ResizePolicyType.FillToParent;
+ case "SIZE_RELATIVE_TO_PARENT": return ResizePolicyType.SizeRelativeToParent;
+ case "SIZE_FIXED_OFFSET_FROM_PARENT": return ResizePolicyType.SizeFixedOffsetFromParent;
+ case "FIT_TO_CHILDREN": return ResizePolicyType.FitToChildren;
+ case "DIMENSION_DEPENDENCY": return ResizePolicyType.DimensionDependency;
+ case "USE_ASSIGNED_SIZE": return ResizePolicyType.UseAssignedSize;
+ default: return ResizePolicyType.Fixed;
+ }
+ });
+ /// 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 SizeScalePolicyProperty = BindableProperty.Create("SizeScalePolicy", typeof(SizeScalePolicyType), typeof(View), SizeScalePolicyType.UseSizeSet, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((SizeScalePolicyType)newValue)
+ {
+ case SizeScalePolicyType.UseSizeSet: { valueToString = "USE_SIZE_SET"; break; }
+ case SizeScalePolicyType.FitWithAspectRatio: { valueToString = "FIT_WITH_ASPECT_RATIO"; break; }
+ case SizeScalePolicyType.FillWithAspectRatio: { valueToString = "FILL_WITH_ASPECT_RATIO"; break; }
+ default: { valueToString = "USE_SIZE_SET"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE_SCALE_POLICY, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SIZE_SCALE_POLICY).Get(out temp) == false)
+ {
+ NUILog.Error("SizeScalePolicy get error!");
+ }
+ switch (temp)
+ {
+ case "USE_SIZE_SET": return SizeScalePolicyType.UseSizeSet;
+ case "FIT_WITH_ASPECT_RATIO": return SizeScalePolicyType.FitWithAspectRatio;
+ case "FILL_WITH_ASPECT_RATIO": return SizeScalePolicyType.FillWithAspectRatio;
+ default: return SizeScalePolicyType.UseSizeSet;
+ }
+ });
+ /// 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 WidthForHeightProperty = BindableProperty.Create("WidthForHeight", typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.WIDTH_FOR_HEIGHT, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.WIDTH_FOR_HEIGHT).Get(out temp);
+ return temp;
+ });
+ /// 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 HeightForWidthProperty = BindableProperty.Create("HeightForWidth", typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.HEIGHT_FOR_WIDTH, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.HEIGHT_FOR_WIDTH).Get(out temp);
+ return temp;
+ });
+ /// 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 PaddingProperty = BindableProperty.Create("Padding", typeof(Extents), typeof(View), new Extents(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.PADDING, new Tizen.NUI.PropertyValue((Extents)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Extents temp = new Extents(0, 0, 0, 0);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.PADDING).Get(temp);
+ return temp;
+ });
+ /// 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 SizeProperty = BindableProperty.Create("Size", typeof(Size), typeof(View), new Size(0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SIZE, new Tizen.NUI.PropertyValue((Size)newValue));
+ }
+ },
+ defaultValueCreator: (bindable) => {
+ var view = (View)bindable;
+ Size temp = new Size(0, 0, 0);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SIZE).Get(temp);
+ return temp;
+ });
+ /// 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 MinimumSizeProperty = BindableProperty.Create("MinimumSize", typeof(Size2D), typeof(View), new Size2D(0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.MINIMUM_SIZE, new Tizen.NUI.PropertyValue((Size2D)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Size2D temp = new Size2D(0, 0);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.MINIMUM_SIZE).Get(temp);
+ return temp;
+ });
+ /// 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 MaximumSizeProperty = BindableProperty.Create("MaximumSize", typeof(Size2D), typeof(View), new Size2D(0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.MAXIMUM_SIZE, new Tizen.NUI.PropertyValue((Size2D)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Size2D temp = new Size2D(0, 0);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.MAXIMUM_SIZE).Get(temp);
+ return temp;
+ });
+ /// 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 InheritPositionProperty = BindableProperty.Create("InheritPosition", typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.INHERIT_POSITION, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.INHERIT_POSITION).Get(out temp);
+ return temp;
+ });
+ /// 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 ClippingModeProperty = BindableProperty.Create("ClippingMode", typeof(ClippingModeType), typeof(View), ClippingModeType.Disabled, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.CLIPPING_MODE, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.CLIPPING_MODE).Get(out temp) == false)
+ {
+ NUILog.Error("ClippingMode get error!");
+ }
+ switch (temp)
+ {
+ case "DISABLED": return ClippingModeType.Disabled;
+ case "CLIP_CHILDREN": return ClippingModeType.ClipChildren;
+ case "CLIP_TO_BOUNDING_BOX": return ClippingModeType.ClipToBoundingBox;
+ default: return ClippingModeType.Disabled;
+ }
+ });
+ /// 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 InheritLayoutDirectionProperty = BindableProperty.Create("InheritLayoutDirection", typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.INHERIT_LAYOUT_DIRECTION, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.INHERIT_LAYOUT_DIRECTION).Get(out temp);
+ return temp;
+ });
+ /// 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 LayoutDirectionProperty = BindableProperty.Create("LayoutDirection", typeof(ViewLayoutDirectionType), typeof(View), ViewLayoutDirectionType.LTR, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.LAYOUT_DIRECTION, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ int temp;
+ if (false == Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.LAYOUT_DIRECTION).Get(out temp))
+ {
+ NUILog.Error("LAYOUT_DIRECTION get error!");
+ }
+ return (ViewLayoutDirectionType)temp;
+ });
+ /// 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 MarginProperty = BindableProperty.Create("Margin", typeof(Extents), typeof(View), new Extents(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var view = (View)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.MARGIN, new Tizen.NUI.PropertyValue((Extents)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var view = (View)bindable;
+ Extents temp = new Extents(0, 0, 0, 0);
+ Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.MARGIN).Get(temp);
+ return temp;
+ });
+ /// 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 StyleProperty = BindableProperty.Create("Style", typeof(Style), typeof(View), default(Style),
+ propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable)._mergedStyle.Style = (Style)newvalue);
+
+
+ private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal View(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.View_SWIGUpcast(cPtr), cMemoryOwn)
{
{
PositionUsesPivotPoint = false;
}
+ _mergedStyle = new MergedStyle(GetType(), this);
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj)
Added = child
};
ChildAdded(this, e);
+ }
}
}
- }
/// <summary>
/// Event argument passed through ChildRemoved event
e.Type = type;
if (_layoutDirectionChangedEventHandler != null)
- {
- _layoutDirectionChangedEventHandler(this, e);
- }
- }
-
-
-
-
-
-
+ {
+ _layoutDirectionChangedEventHandler(this, e);
+ }
+ }
// Resource Ready Signal
PageDown
}
+ protected void InitXamlResource()
+ {
+ if (null != Application.Current)
+ {
+ Application.AddResourceChangedCallback(this, OnResourcesChanged);
+ }
+ }
+
/// <summary>
/// Creates a new instance of a view.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public View() : this(NDalicPINVOKE.View_New(), true)
{
+ InitXamlResource();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
}
internal View(View uiControl) : this(NDalicPINVOKE.new_View__SWIG_1(View.getCPtr(uiControl)), true)
{
+ InitXamlResource();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
{
get
{
- string temp;
- GetProperty(View.Property.STYLE_NAME).Get(out temp);
- return temp;
+ return (string)GetValue(StyleNameProperty);
}
set
{
- SetProperty(View.Property.STYLE_NAME, new Tizen.NUI.PropertyValue(value));
+ SetValue(StyleNameProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Color backgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
-
- Tizen.NUI.PropertyMap background = Background;
- int visualType = 0;
- background.Find(Visual.Property.Type)?.Get(out visualType);
- if (visualType == (int)Visual.Type.Color)
- {
- background.Find(ColorVisualProperty.MixColor)?.Get(backgroundColor);
- }
-
- return backgroundColor;
+ return (Color)GetValue(BackgroundColorProperty);
}
set
{
- SetProperty(View.Property.BACKGROUND, new Tizen.NUI.PropertyValue(value));
+ SetValue(BackgroundColorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string backgroundImage = "";
-
- Tizen.NUI.PropertyMap background = Background;
- int visualType = 0;
- background.Find(Visual.Property.Type)?.Get(out visualType);
- if (visualType == (int)Visual.Type.Image)
- {
- background.Find(ImageVisualProperty.URL)?.Get(out backgroundImage);
- }
-
- return backgroundImage;
+ return (string)GetValue(BackgroundImageProperty);
}
set
{
- SetProperty(View.Property.BACKGROUND, new Tizen.NUI.PropertyValue(value));
+ SetValue(BackgroundImageProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(View.Property.BACKGROUND).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(BackgroundProperty);
}
set
{
- SetProperty(View.Property.BACKGROUND, new Tizen.NUI.PropertyValue(value));
+ SetValue(BackgroundProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- if (GetProperty(View.Property.STATE).Get(out temp) == false)
- {
- NUILog.Error("State get error!");
- }
- switch (temp)
- {
- case 0:
- {
- return States.Normal;
- }
- case 1:
- {
- return States.Focused;
- }
- case 2:
- {
- return States.Disabled;
- }
- default:
- {
- return States.Normal;
- }
- }
+ return (States)GetValue(StateProperty);
}
set
{
- SetProperty(View.Property.STATE, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(StateProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(View.Property.SUB_STATE).Get(out temp) == false)
- {
- NUILog.Error("subState get error!");
- }
- switch (temp)
- {
- case "NORMAL":
- return States.Normal;
- case "FOCUSED":
- return States.Focused;
- case "DISABLED":
- return States.Disabled;
- default:
- return States.Normal;
- }
+ return (States)GetValue(SubStateProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case States.Normal:
- {
- valueToString = "NORMAL";
- break;
- }
- case States.Focused:
- {
- valueToString = "FOCUSED";
- break;
- }
- case States.Disabled:
- {
- valueToString = "DISABLED";
- break;
- }
- default:
- {
- valueToString = "NORMAL";
- break;
- }
- }
- SetProperty(View.Property.SUB_STATE, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(SubStateProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(View.Property.TOOLTIP).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(TooltipProperty);
}
set
{
- SetProperty(View.Property.TOOLTIP, new Tizen.NUI.PropertyValue(value));
+ SetValue(TooltipProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(FlexContainer.ChildProperty.FLEX).Get(out temp);
- return temp;
+ return (float)GetValue(FlexProperty);
}
set
{
- SetProperty(FlexContainer.ChildProperty.FLEX, new Tizen.NUI.PropertyValue(value));
+ SetValue(FlexProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp = 0;
- GetProperty(FlexContainer.ChildProperty.ALIGN_SELF).Get(out temp);
- return temp;
+ return (int)GetValue(AlignSelfProperty);
}
set
{
- SetProperty(FlexContainer.ChildProperty.ALIGN_SELF, new Tizen.NUI.PropertyValue(value));
+ SetValue(AlignSelfProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(FlexContainer.ChildProperty.FLEX_MARGIN).Get(temp);
- return temp;
+ return (Vector4)GetValue(FlexMarginProperty);
}
set
{
- SetProperty(FlexContainer.ChildProperty.FLEX_MARGIN, new Tizen.NUI.PropertyValue(value));
+ SetValue(FlexMarginProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(TableView.ChildProperty.CELL_INDEX).Get(temp);
- return temp;
+ return (Vector2)GetValue(CellIndexProperty);
}
set
{
- SetProperty(TableView.ChildProperty.CELL_INDEX, new Tizen.NUI.PropertyValue(value));
+ SetValue(CellIndexProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TableView.ChildProperty.ROW_SPAN).Get(out temp);
- return temp;
+ return (float)GetValue(RowSpanProperty);
}
set
{
- SetProperty(TableView.ChildProperty.ROW_SPAN, new Tizen.NUI.PropertyValue(value));
+ SetValue(RowSpanProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(TableView.ChildProperty.COLUMN_SPAN).Get(out temp);
- return temp;
+ return (float)GetValue(ColumnSpanProperty);
}
set
{
- SetProperty(TableView.ChildProperty.COLUMN_SPAN, new Tizen.NUI.PropertyValue(value));
+ SetValue(ColumnSpanProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(TableView.ChildProperty.CELL_HORIZONTAL_ALIGNMENT).Get(out temp) == false)
- {
- NUILog.Error("CellHorizontalAlignment get error!");
- }
-
- switch (temp)
- {
- case "left":
- return Tizen.NUI.HorizontalAlignmentType.Left;
- case "center":
- return Tizen.NUI.HorizontalAlignmentType.Center;
- case "right":
- return Tizen.NUI.HorizontalAlignmentType.Right;
- default:
- return Tizen.NUI.HorizontalAlignmentType.Left;
- }
+ return (HorizontalAlignmentType)GetValue(CellHorizontalAlignmentProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case Tizen.NUI.HorizontalAlignmentType.Left:
- {
- valueToString = "left";
- break;
- }
- case Tizen.NUI.HorizontalAlignmentType.Center:
- {
- valueToString = "center";
- break;
- }
- case Tizen.NUI.HorizontalAlignmentType.Right:
- {
- valueToString = "right";
- break;
- }
- default:
- {
- valueToString = "left";
- break;
- }
- }
- SetProperty(TableView.ChildProperty.CELL_HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(CellHorizontalAlignmentProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT).Get(out temp);
- {
- NUILog.Error("CellVerticalAlignment get error!");
- }
-
- switch (temp)
- {
- case "top":
- return Tizen.NUI.VerticalAlignmentType.Top;
- case "center":
- return Tizen.NUI.VerticalAlignmentType.Center;
- case "bottom":
- return Tizen.NUI.VerticalAlignmentType.Bottom;
- default:
- return Tizen.NUI.VerticalAlignmentType.Top;
- }
+ return (VerticalAlignmentType)GetValue(CellVerticalAlignmentProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case Tizen.NUI.VerticalAlignmentType.Top:
- {
- valueToString = "top";
- break;
- }
- case Tizen.NUI.VerticalAlignmentType.Center:
- {
- valueToString = "center";
- break;
- }
- case Tizen.NUI.VerticalAlignmentType.Bottom:
- {
- valueToString = "bottom";
- break;
- }
- default:
- {
- valueToString = "top";
- break;
- }
- }
- SetProperty(TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(CellVerticalAlignmentProperty, value);
NotifyPropertyChanged();
}
}
// As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
get
{
- if (LeftFocusableViewId >= 0)
- {
- return ConvertIdToView((uint)LeftFocusableViewId);
- }
- return null;
+ return (View)GetValue(LeftFocusableViewProperty);
}
set
{
- if (value)
- {
- LeftFocusableViewId = (int)value.GetId();
- }
- else
- {
- LeftFocusableViewId = -1;
- }
+ SetValue(LeftFocusableViewProperty, value);
NotifyPropertyChanged();
}
}
// As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
get
{
- if (RightFocusableViewId >= 0)
- {
- return ConvertIdToView((uint)RightFocusableViewId);
- }
- return null;
+ return (View)GetValue(RightFocusableViewProperty);
}
set
{
- if (value)
- {
- RightFocusableViewId = (int)value.GetId();
- }
- else
- {
- RightFocusableViewId = -1;
- }
+ SetValue(RightFocusableViewProperty, value);
NotifyPropertyChanged();
}
}
// As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
get
{
- if (UpFocusableViewId >= 0)
- {
- return ConvertIdToView((uint)UpFocusableViewId);
- }
- return null;
+ return (View)GetValue(UpFocusableViewProperty);
}
set
{
- if (value)
- {
- UpFocusableViewId = (int)value.GetId();
- }
- else
- {
- UpFocusableViewId = -1;
- }
+ SetValue(UpFocusableViewProperty, value);
NotifyPropertyChanged();
}
}
// As native side will be only storing IDs so need a logic to convert View to ID and vice-versa.
get
{
- if (DownFocusableViewId >= 0)
- {
- return ConvertIdToView((uint)DownFocusableViewId);
- }
- return null;
+ return (View)GetValue(DownFocusableViewProperty);
}
set
{
- if (value)
- {
- DownFocusableViewId = (int)value.GetId();
- }
- else
- {
- DownFocusableViewId = -1;
- }
+ SetValue(DownFocusableViewProperty, value);
NotifyPropertyChanged();
}
}
{
set
{
- SetKeyboardFocusable(value);
+ SetValue(FocusableProperty, value);
NotifyPropertyChanged();
}
get
{
- return IsKeyboardFocusable();
+ return (bool)GetValue(FocusableProperty);
}
}
{
get
{
- Size temp = new Size(0.0f, 0.0f, 0.0f);
- GetProperty(View.Property.SIZE).Get(temp);
- Size2D size = new Size2D((int)temp.Width, (int)temp.Height);
- return size;
+ return (Size2D)GetValue(Size2DProperty);
}
set
{
- SetProperty(View.Property.SIZE, new Tizen.NUI.PropertyValue(new Size(value)));
+ SetValue(Size2DProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(View.Property.OPACITY).Get(out temp);
- return temp;
+ return (float)GetValue(OpacityProperty);
}
set
{
- SetProperty(View.Property.OPACITY, new Tizen.NUI.PropertyValue(value));
+ SetValue(OpacityProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Position temp = new Position(0.0f, 0.0f, 0.0f);
- GetProperty(View.Property.POSITION).Get(temp);
- return new Position2D(temp);
+ return (Position2D)GetValue(Position2DProperty);
}
set
{
- SetProperty(View.Property.POSITION, new Tizen.NUI.PropertyValue(new Position(value)));
+ SetValue(Position2DProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(View.Property.POSITION_USES_ANCHOR_POINT).Get(out temp);
- return temp;
+ return (bool)GetValue(PositionUsesPivotPointProperty);
}
set
{
- SetProperty(View.Property.POSITION_USES_ANCHOR_POINT, new Tizen.NUI.PropertyValue(value));
+ SetValue(PositionUsesPivotPointProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- var parentChildren = GetParent()?.Children;
- int currentOrder = 0;
- if (parentChildren != null)
- {
- currentOrder = parentChildren.IndexOf(this);
-
- if (currentOrder < 0)
- {
- return 0;
- }
- else if (currentOrder < parentChildren.Count)
- {
- return currentOrder;
- }
- }
-
- return 0;
+ return (int)GetValue(SiblingOrderProperty);
}
set
{
- if (value < 0)
- {
- NUILog.Error("SiblingOrder should be bigger than 0 or equal to 0.");
- return;
- }
- var siblings = GetParent()?.Children;
- if (siblings != null)
- {
- int currentOrder = siblings.IndexOf(this);
- if (value != currentOrder)
- {
- if (value == 0)
- {
- LowerToBottom();
- }
- else if (value < siblings.Count - 1)
- {
- if (value > currentOrder)
- {
- RaiseAbove(siblings[value]);
- }
- else
- {
- LowerBelow(siblings[value]);
- }
- }
- else
- {
- RaiseToTop();
- }
- }
- }
- NotifyPropertyChanged();
+ SetValue(SiblingOrderProperty, value);
+ NotifyPropertyChanged();
}
}
{
get
{
- Position temp = new Position(0.0f, 0.0f, 0.0f);
- GetProperty(View.Property.PARENT_ORIGIN).Get(temp);
- return temp;
+ return (Position)GetValue(ParentOriginProperty);
}
set
{
- SetProperty(View.Property.PARENT_ORIGIN, new Tizen.NUI.PropertyValue(value));
+ SetValue(ParentOriginProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Position temp = new Position(0.0f, 0.0f, 0.0f);
- GetProperty(View.Property.ANCHOR_POINT).Get(temp);
- return temp;
+ return (Position)GetValue(PivotPointProperty);
}
set
{
- SetProperty(View.Property.ANCHOR_POINT, new Tizen.NUI.PropertyValue(value));
+ SetValue(PivotPointProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(View.Property.SIZE_WIDTH).Get(out temp);
- return temp;
+ return (float)GetValue(SizeWidthProperty);
}
set
{
- SetProperty(View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue(value));
+ SetValue(SizeWidthProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(View.Property.SIZE_HEIGHT).Get(out temp);
- return temp;
+ return (float)GetValue(SizeHeightProperty);
}
set
{
- SetProperty(View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(SizeHeightProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
- GetProperty(View.Property.POSITION).Get(temp);
- return temp;
+ return (Position)GetValue(PositionProperty);
}
set
{
- SetProperty(View.Property.POSITION, new Tizen.NUI.PropertyValue(value));
+ SetValue(PositionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(View.Property.POSITION_X).Get(out temp);
- return temp;
+ return (float)GetValue(PositionXProperty);
}
set
{
- SetProperty(View.Property.POSITION_X, new Tizen.NUI.PropertyValue(value));
+ SetValue(PositionXProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(View.Property.POSITION_Y).Get(out temp);
- return temp;
+ return (float)GetValue(PositionYProperty);
}
set
{
- SetProperty(View.Property.POSITION_Y, new Tizen.NUI.PropertyValue(value));
+ SetValue(PositionYProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(View.Property.POSITION_Z).Get(out temp);
- return temp;
+ return (float)GetValue(PositionZProperty);
}
set
{
- SetProperty(View.Property.POSITION_Z, new Tizen.NUI.PropertyValue(value));
+ SetValue(PositionZProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Rotation temp = new Rotation();
- GetProperty(View.Property.ORIENTATION).Get(temp);
- return temp;
+ return (Rotation)GetValue(OrientationProperty);
}
set
{
- SetProperty(View.Property.ORIENTATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(OrientationProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
- GetProperty(View.Property.SCALE).Get(temp);
- return temp;
+ return (Vector3)GetValue(ScaleProperty);
}
set
{
- SetProperty(View.Property.SCALE, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScaleProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(View.Property.SCALE_X).Get(out temp);
- return temp;
+ return (float)GetValue(ScaleXProperty);
}
set
{
- SetProperty(View.Property.SCALE_X, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScaleXProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(View.Property.SCALE_Y).Get(out temp);
- return temp;
+ return (float)GetValue(ScaleYProperty);
}
set
{
- SetProperty(View.Property.SCALE_Y, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScaleYProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(View.Property.SCALE_Z).Get(out temp);
- return temp;
+ return (float)GetValue(ScaleZProperty);
}
set
{
- SetProperty(View.Property.SCALE_Z, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScaleZProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- GetProperty(View.Property.NAME).Get(out temp);
- return temp;
+ return (string)GetValue(NameProperty);
}
set
{
- SetProperty(View.Property.NAME, new Tizen.NUI.PropertyValue(value));
+ SetValue(NameProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(View.Property.SENSITIVE).Get(out temp);
- return temp;
+ return (bool)GetValue(SensitiveProperty);
}
set
{
- SetProperty(View.Property.SENSITIVE, new Tizen.NUI.PropertyValue(value));
+ SetValue(SensitiveProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(View.Property.LEAVE_REQUIRED).Get(out temp);
- return temp;
+ return (bool)GetValue(LeaveRequiredProperty);
}
set
{
- SetProperty(View.Property.LEAVE_REQUIRED, new Tizen.NUI.PropertyValue(value));
+ SetValue(LeaveRequiredProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(View.Property.INHERIT_ORIENTATION).Get(out temp);
- return temp;
+ return (bool)GetValue(InheritOrientationProperty);
}
set
{
- SetProperty(View.Property.INHERIT_ORIENTATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(InheritOrientationProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(View.Property.INHERIT_SCALE).Get(out temp);
- return temp;
+ return (bool)GetValue(InheritScaleProperty);
}
set
{
- SetProperty(View.Property.INHERIT_SCALE, new Tizen.NUI.PropertyValue(value));
+ SetValue(InheritScaleProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(View.Property.DRAW_MODE).Get(out temp) == false)
- {
- NUILog.Error("DrawMode get error!");
- }
- switch (temp)
- {
- case "NORMAL":
- return DrawModeType.Normal;
- case "OVERLAY_2D":
- return DrawModeType.Overlay2D;
- case "STENCIL":
- return DrawModeType.Stencil;
- default:
- return DrawModeType.Normal;
- }
+ return (DrawModeType)GetValue(DrawModeProperty);
}
set
{
- SetProperty(View.Property.DRAW_MODE, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(DrawModeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
- GetProperty(View.Property.SIZE_MODE_FACTOR).Get(temp);
- return temp;
+ return (Vector3)GetValue(SizeModeFactorProperty);
}
set
{
- SetProperty(View.Property.SIZE_MODE_FACTOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(SizeModeFactorProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(View.Property.WIDTH_RESIZE_POLICY).Get(out temp) == false)
- {
- NUILog.Error("WidthResizePolicy get error!");
- }
- switch (temp)
- {
- case "FIXED":
- return ResizePolicyType.Fixed;
- case "USE_NATURAL_SIZE":
- return ResizePolicyType.UseNaturalSize;
- case "FILL_TO_PARENT":
- return ResizePolicyType.FillToParent;
- case "SIZE_RELATIVE_TO_PARENT":
- return ResizePolicyType.SizeRelativeToParent;
- case "SIZE_FIXED_OFFSET_FROM_PARENT":
- return ResizePolicyType.SizeFixedOffsetFromParent;
- case "FIT_TO_CHILDREN":
- return ResizePolicyType.FitToChildren;
- case "DIMENSION_DEPENDENCY":
- return ResizePolicyType.DimensionDependency;
- case "USE_ASSIGNED_SIZE":
- return ResizePolicyType.UseAssignedSize;
- default:
- return ResizePolicyType.Fixed;
- }
+ return (ResizePolicyType)GetValue(WidthResizePolicyProperty);
}
set
{
- SetProperty(View.Property.WIDTH_RESIZE_POLICY, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(WidthResizePolicyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(View.Property.HEIGHT_RESIZE_POLICY).Get(out temp) == false)
- {
- NUILog.Error("HeightResizePolicy get error!");
- }
- switch (temp)
- {
- case "FIXED":
- return ResizePolicyType.Fixed;
- case "USE_NATURAL_SIZE":
- return ResizePolicyType.UseNaturalSize;
- case "FILL_TO_PARENT":
- return ResizePolicyType.FillToParent;
- case "SIZE_RELATIVE_TO_PARENT":
- return ResizePolicyType.SizeRelativeToParent;
- case "SIZE_FIXED_OFFSET_FROM_PARENT":
- return ResizePolicyType.SizeFixedOffsetFromParent;
- case "FIT_TO_CHILDREN":
- return ResizePolicyType.FitToChildren;
- case "DIMENSION_DEPENDENCY":
- return ResizePolicyType.DimensionDependency;
- case "USE_ASSIGNED_SIZE":
- return ResizePolicyType.UseAssignedSize;
- default:
- return ResizePolicyType.Fixed;
- }
+ return (ResizePolicyType)GetValue(HeightResizePolicyProperty);
}
set
{
- SetProperty(View.Property.HEIGHT_RESIZE_POLICY, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(HeightResizePolicyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(View.Property.SIZE_SCALE_POLICY).Get(out temp) == false)
- {
- NUILog.Error("SizeScalePolicy get error!");
- }
- switch (temp)
- {
- case "USE_SIZE_SET":
- return SizeScalePolicyType.UseSizeSet;
- case "FIT_WITH_ASPECT_RATIO":
- return SizeScalePolicyType.FitWithAspectRatio;
- case "FILL_WITH_ASPECT_RATIO":
- return SizeScalePolicyType.FillWithAspectRatio;
- default:
- return SizeScalePolicyType.UseSizeSet;
- }
+ return (SizeScalePolicyType)GetValue(SizeScalePolicyProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case SizeScalePolicyType.UseSizeSet:
- {
- valueToString = "USE_SIZE_SET";
- break;
- }
- case SizeScalePolicyType.FitWithAspectRatio:
- {
- valueToString = "FIT_WITH_ASPECT_RATIO";
- break;
- }
- case SizeScalePolicyType.FillWithAspectRatio:
- {
- valueToString = "FILL_WITH_ASPECT_RATIO";
- break;
- }
- default:
- {
- valueToString = "USE_SIZE_SET";
- break;
- }
- }
- SetProperty(View.Property.SIZE_SCALE_POLICY, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(SizeScalePolicyProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(View.Property.WIDTH_FOR_HEIGHT).Get(out temp);
- return temp;
+ return (bool)GetValue(WidthForHeightProperty);
}
set
{
- SetProperty(View.Property.WIDTH_FOR_HEIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(WidthForHeightProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(View.Property.HEIGHT_FOR_WIDTH).Get(out temp);
- return temp;
+ return (bool)GetValue(HeightForWidthProperty);
}
set
{
- SetProperty(View.Property.HEIGHT_FOR_WIDTH, new Tizen.NUI.PropertyValue(value));
+ SetValue(HeightForWidthProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Extents temp = new Extents(0, 0, 0, 0);
- GetProperty(View.Property.PADDING).Get(temp);
- return temp;
+ return (Extents)GetValue(PaddingProperty);
}
set
{
- SetProperty(View.Property.PADDING, new Tizen.NUI.PropertyValue(value));
+ SetValue(PaddingProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Size2D temp = new Size2D(0, 0);
- GetProperty(View.Property.MINIMUM_SIZE).Get(temp);
- return temp;
+ return (Size2D)GetValue(MinimumSizeProperty);
}
set
{
- SetProperty(View.Property.MINIMUM_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(MinimumSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Size2D temp = new Size2D(0, 0);
- GetProperty(View.Property.MAXIMUM_SIZE).Get(temp);
- return temp;
+ return (Size2D)GetValue(MaximumSizeProperty);
}
set
{
- SetProperty(View.Property.MAXIMUM_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(MaximumSizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(View.Property.INHERIT_POSITION).Get(out temp);
- return temp;
+ return (bool)GetValue(InheritPositionProperty);
}
set
{
- SetProperty(View.Property.INHERIT_POSITION, new Tizen.NUI.PropertyValue(value));
+ SetValue(InheritPositionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- string temp;
- if (GetProperty(View.Property.CLIPPING_MODE).Get(out temp) == false)
- {
- NUILog.Error("ClippingMode get error!");
- }
- switch (temp)
- {
- case "DISABLED":
- return ClippingModeType.Disabled;
- case "CLIP_CHILDREN":
- return ClippingModeType.ClipChildren;
- case "CLIP_TO_BOUNDING_BOX":
- return ClippingModeType.ClipToBoundingBox;
- default:
- return ClippingModeType.Disabled;
- }
+ return (ClippingModeType)GetValue(ClippingModeProperty);
}
set
{
- SetProperty(View.Property.CLIPPING_MODE, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(ClippingModeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Size temp = new Size(0.0f, 0.0f, 0.0f);
- GetProperty(View.Property.SIZE).Get(temp);
- return temp;
+ return (Size)GetValue(SizeProperty);
}
set
{
- SetProperty(View.Property.SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(SizeProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- bool temp = false;
- GetProperty(View.Property.INHERIT_LAYOUT_DIRECTION).Get(out temp);
- return temp;
+ return (bool)GetValue(InheritLayoutDirectionProperty);
}
set
{
- SetProperty(View.Property.INHERIT_LAYOUT_DIRECTION, new Tizen.NUI.PropertyValue(value));
+ SetValue(InheritLayoutDirectionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- int temp;
- if (GetProperty(View.Property.LAYOUT_DIRECTION).Get(out temp) == false)
- {
- NUILog.Error("LAYOUT_DIRECTION get error!");
- }
- return (ViewLayoutDirectionType)temp;
+ return (ViewLayoutDirectionType)GetValue(LayoutDirectionProperty);
}
set
{
- SetProperty(View.Property.LAYOUT_DIRECTION, new Tizen.NUI.PropertyValue((int)value));
+ SetValue(LayoutDirectionProperty, value);
NotifyPropertyChanged();
}
}
{
get
{
- Extents temp = new Extents(0, 0, 0, 0);
- GetProperty(View.Property.MARGIN).Get(temp);
- return temp;
+ return (Extents)GetValue(MarginProperty);
}
set
{
- SetProperty(View.Property.MARGIN, new Tizen.NUI.PropertyValue(value));
+ SetValue(MarginProperty, value);
NotifyPropertyChanged();
}
}
+ internal Style Style
+ {
+ get
+ {
+ return (Style)GetValue(StyleProperty);
+ }
+ set
+ {
+ SetValue(StyleProperty, value);
+ }
+ }
+
/// <summary>
/// [Obsolete("Please do not use! this will be deprecated")]
/// </summary>
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
+ internal readonly MergedStyle _mergedStyle;
+
/// 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 WidthSpecificationFixed
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Tizen.NUI.Binding;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI
{
/// <summary>
/// Backing store for the Navigation property.
/// </summary>
- public static readonly BindableProperty NavigationProperty = NavigationPropertyKey.BindableProperty;
+ internal static readonly BindableProperty NavigationProperty = NavigationPropertyKey.BindableProperty;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
/// <summary>
/// <param name="info">The type information.</param>
/// <returns>True If get the type info.</returns>
/// <since_tizen> 3 </since_tizen>
- public bool GetTypeInfo(TypeInfo info)
+ public bool GetTypeInfo(Tizen.NUI.TypeInfo info)
{
- bool ret = NDalicPINVOKE.BaseHandle_GetTypeInfo(swigCPtr, TypeInfo.getCPtr(info));
+ bool ret = NDalicPINVOKE.BaseHandle_GetTypeInfo(swigCPtr, Tizen.NUI.TypeInfo.getCPtr(info));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
/// For internal use.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public NavigationProxy NavigationProxy
+ internal NavigationProxy NavigationProxy
{
get { return Navigation as NavigationProxy; }
}
/// <summary>
/// Gets the navigation.
/// </summary>
- public INavigation Navigation
+ internal INavigation Navigation
{
get { return (INavigation)GetValue(NavigationProperty); }
- internal set { SetValue(NavigationPropertyKey, value); }
+ set { SetValue(NavigationPropertyKey, value); }
}
/// <summary>
public override void OnInitialize()
{
// Initialize the propertiesControl
- //_arrowImage = "/home/tengxb/Workspace/nui-debug/examples/res/images/arrow.png";
_arrowImage = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
_textBackgroundColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
_currentValue = 0;
}
}
-
/// <summary>
/// Removes a child view from this layer. If the view was not a child of this layer, this is a no-op.
/// </summary>
using System;
using System.ComponentModel;
using System.Threading;
+using System.Reflection;
using Tizen.Applications;
using Tizen.Applications.CoreBackend;
+using Tizen.NUI.Binding;
+using Tizen.NUI.Xaml;
namespace Tizen.NUI
{
protected override void OnCreate()
{
base.OnCreate();
+ Device.PlatformServices = new TizenPlatformServices();
}
/// <summary>
}
/// <summary>
+ /// Register the assembly to XAML.
+ /// </summary>
+ /// <since_tizen> 5 </since_tizen>
+ /// 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 void RegisterAssembly(Assembly assembly)
+ {
+ XamlParser.s_assemblies.Add(assembly);
+ }
+
+ /// <summary>
/// Gets the window instance.
/// </summary>
/// <since_tizen> 3 </since_tizen>
}
/// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ Position position = obj as Position;
+ bool equal = false;
+ if (X == position?.X && Y == position?.Y && Z == position?.Z)
+ {
+ equal = true;
+ }
+ return equal;
+ }
+
+ /// <summary>
/// Compares if rhs is equal to.
/// </summary>
/// <param name="rhs">The vector to compare.</param>
[Tizen.NUI.Binding.TypeConverter(typeof(Position2DTypeConverter))]
public class Position2D : global::System.IDisposable
{
+ static public Position2D ConvertFromString(System.String value)
+ {
+ if (value != null)
+ {
+ string[] parts = value.Split(',');
+ if (parts.Length == 2)
+ {
+ return new Position2D(int.Parse(parts[0].Trim()), int.Parse(parts[1].Trim()));
+ }
+ }
+
+ throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Position2D)}");
+ }
+
+ public static implicit operator Position2D(System.String value)
+ {
+ return ConvertFromString(value);
+ }
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
/// <summary>
/// swigCMemOwn
}
/// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ Position2D position2D = obj as Position2D;
+ bool equal = false;
+ if (X == position2D?.X && Y == position2D?.Y)
+ {
+ equal = true;
+ }
+ return equal;
+ }
+
+ /// <summary>
/// Compares if the rhs is equal to.
/// </summary>
/// <param name="rhs">The vector to compare</param>
}
/// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ RelativeVector2 relativeRector2 = obj as RelativeVector2;
+ bool equal = false;
+ if (X == relativeRector2?.X && Y == relativeRector2?.Y)
+ {
+ equal = true;
+ }
+ return equal;
+ }
+
+ /// <summary>
/// Compares if the rhs is equal to.
/// </summary>
/// <param name="rhs">The vector to compare.</param>
}
/// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ RelativeVector3 relativeVector3 = obj as RelativeVector3;
+ bool equal = false;
+ if (X == relativeVector3?.X && Y == relativeVector3?.Y && Z == relativeVector3?.Z)
+ {
+ equal = true;
+ }
+ return equal;
+ }
+
+ /// <summary>
/// Compares if the rhs is equal to.
/// </summary>
/// <param name="rhs">The vector to compare.</param>
}
/// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ RelativeVector4 relativeVector4 = obj as RelativeVector4;
+ bool equal = false;
+ if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
+ {
+ equal = true;
+ }
+ return equal;
+ }
+
+ /// <summary>
/// Compares if the rhs is equal to.
/// </summary>
/// <param name="rhs">The vector to compare.</param>
Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Subtract__SWIG_1(swigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
+ }
+
+ /// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ Size2D size2D = obj as Size2D;
+ bool equal = false;
+ if (Width == size2D?.Width && Height == size2D?.Height)
+ {
+ equal = true;
+ }
+ return equal;
}
/// <summary>
* limitations under the License.
*
*/
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.UIComponents
{
-
- using System;
- using System.Runtime.InteropServices;
- using Tizen.NUI.BaseComponents;
-
/// <summary>
/// The Button class is a base class for different kinds of buttons.<br />
/// This class provides the disabled property and the clicked signal.<br />
/// When the button is disabled, the background button and the selected visuals are replaced by their disabled visuals.<br />
/// </summary>
/// <since_tizen> 3 </since_tizen>
+ [ContentProperty("LabelText")]
public class Button : View
{
+ /// 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 UnselectedVisualProperty = BindableProperty.Create("UnselectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 SelectedVisualProperty = BindableProperty.Create("SelectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 DisabledSelectedVisualProperty = BindableProperty.Create("DisabledSelectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 DisabledUnselectedVisualProperty = BindableProperty.Create("DisabledUnselectedVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 UnselectedBackgroundVisualProperty = BindableProperty.Create("UnselectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_BACKGROUND_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 SelectedBackgroundVisualProperty = BindableProperty.Create("SelectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_BACKGROUND_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 DisabledUnselectedBackgroundVisualProperty = BindableProperty.Create("DisabledUnselectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 DisabledSelectedBackgroundVisualProperty = BindableProperty.Create("DisabledSelectedBackgroundVisual", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 LabelRelativeAlignmentProperty = BindableProperty.Create("LabelRelativeAlignment", typeof(Align), typeof(Button), Align.End, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((Align)newValue)
+ {
+ case Align.Begin: { valueToString = "BEGIN"; break; }
+ case Align.End: { valueToString = "END"; break; }
+ case Align.Top: { valueToString = "TOP"; break; }
+ case Align.Bottom: { valueToString = "BOTTOM"; break; }
+ default: { valueToString = "END"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL_RELATIVE_ALIGNMENT).Get(out temp) == false)
+ {
+ NUILog.Error("LabelRelativeAlignment get error!");
+ }
+ switch (temp)
+ {
+ case "BEGIN": return Align.Begin;
+ case "END": return Align.End;
+ case "TOP": return Align.Top;
+ case "BOTTOM": return Align.Bottom;
+ default: return Align.End;
+ }
+ });
+ /// 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 LabelPaddingProperty = BindableProperty.Create("LabelPadding", typeof(Vector4), typeof(Button), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL_PADDING).Get(temp);
+ return temp;
+ });
+ /// 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 ForegroundVisualPaddingProperty = BindableProperty.Create("ForegroundVisualPadding", typeof(Vector4), typeof(Button), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.FOREGROUND_VISUAL_PADDING, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.FOREGROUND_VISUAL_PADDING).Get(temp);
+ return temp;
+ });
+ /// 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 AutoRepeatingProperty = BindableProperty.Create("AutoRepeating", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.AUTO_REPEATING).Get(out temp);
+ return temp;
+ });
+ /// 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 InitialAutoRepeatingDelayProperty = BindableProperty.Create("InitialAutoRepeatingDelay", typeof(float), typeof(Button), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.INITIAL_AUTO_REPEATING_DELAY).Get(out temp);
+ return temp;
+ });
+ /// 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 NextAutoRepeatingDelayProperty = BindableProperty.Create("NextAutoRepeatingDelay", typeof(float), typeof(Button), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.NEXT_AUTO_REPEATING_DELAY).Get(out temp);
+ return temp;
+ });
+ /// 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 TogglableProperty = BindableProperty.Create("Togglable", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.TOGGLABLE, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.TOGGLABLE).Get(out temp);
+ return temp;
+ });
+ /// 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 SelectedProperty = BindableProperty.Create("Selected", typeof(bool), typeof(Button), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED).Get(out temp);
+ return temp;
+ });
+ /// 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 UnselectedColorProperty = BindableProperty.Create("UnselectedColor", typeof(Color), typeof(Button), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.UNSELECTED_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.UNSELECTED_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 SelectedColorProperty = BindableProperty.Create("SelectedColor", typeof(Color), typeof(Button), Color.Transparent, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.SELECTED_COLOR, new Tizen.NUI.PropertyValue((Color)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.SELECTED_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 LabelProperty = BindableProperty.Create("Label", typeof(PropertyMap), typeof(Button), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(temp);
+ return temp;
+ });
+ /// 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 LabelTextProperty = BindableProperty.Create("LabelText", typeof(string), typeof(Button), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var button = (Button)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(button.swigCPtr, Button.Property.LABEL, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var button = (Button)bindable;
+ Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(button.swigCPtr, Button.Property.LABEL).Get(map);
+ Tizen.NUI.PropertyValue value = map.Find( TextVisualProperty.Text, "Text");
+ string str = "";
+ value?.Get(out str);
+ return str;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal Button(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Button_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(Button.Property.UNSELECTED_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(UnselectedVisualProperty);
}
set
{
- SetProperty(Button.Property.UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(UnselectedVisualProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(Button.Property.SELECTED_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectedVisualProperty);
}
set
{
- SetProperty(Button.Property.SELECTED_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectedVisualProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(Button.Property.DISABLED_SELECTED_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(DisabledSelectedVisualProperty);
}
set
{
- SetProperty(Button.Property.DISABLED_SELECTED_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(DisabledSelectedVisualProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(Button.Property.DISABLED_UNSELECTED_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(DisabledUnselectedVisualProperty);
}
set
{
- SetProperty(Button.Property.DISABLED_UNSELECTED_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(DisabledUnselectedVisualProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(Button.Property.UNSELECTED_BACKGROUND_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(UnselectedBackgroundVisualProperty);
}
set
{
- SetProperty(Button.Property.UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(UnselectedBackgroundVisualProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(Button.Property.SELECTED_BACKGROUND_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SelectedBackgroundVisualProperty);
}
set
{
- SetProperty(Button.Property.SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectedBackgroundVisualProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(DisabledUnselectedBackgroundVisualProperty);
}
set
{
- SetProperty(Button.Property.DISABLED_UNSELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(DisabledUnselectedBackgroundVisualProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(DisabledSelectedBackgroundVisualProperty);
}
set
{
- SetProperty(Button.Property.DISABLED_SELECTED_BACKGROUND_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(DisabledSelectedBackgroundVisualProperty, value);
}
}
{
get
{
- string temp;
- if (GetProperty(Button.Property.LABEL_RELATIVE_ALIGNMENT).Get(out temp) == false)
- {
- NUILog.Error("LabelRelativeAlignment get error!");
- }
- switch (temp)
- {
- case "BEGIN":
- return Align.Begin;
- case "END":
- return Align.End;
- case "TOP":
- return Align.Top;
- case "BOTTOM":
- return Align.Bottom;
- default:
- return Align.End;
- }
+ return (Align)GetValue(LabelRelativeAlignmentProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case Align.Begin:
- {
- valueToString = "BEGIN";
- break;
- }
- case Align.End:
- {
- valueToString = "END";
- break;
- }
- case Align.Top:
- {
- valueToString = "TOP";
- break;
- }
- case Align.Bottom:
- {
- valueToString = "BOTTOM";
- break;
- }
- default:
- {
- valueToString = "END";
- break;
- }
- }
- SetProperty(Button.Property.LABEL_RELATIVE_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(LabelRelativeAlignmentProperty, value);
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(Button.Property.LABEL_PADDING).Get(temp);
- return temp;
+ return (Vector4)GetValue(LabelPaddingProperty);
}
set
{
- SetProperty(Button.Property.LABEL_PADDING, new Tizen.NUI.PropertyValue(value));
+ SetValue(LabelPaddingProperty, value);
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(Button.Property.FOREGROUND_VISUAL_PADDING).Get(temp);
- return temp;
+ return (Vector4)GetValue(ForegroundVisualPaddingProperty);
}
set
{
- SetProperty(Button.Property.FOREGROUND_VISUAL_PADDING, new Tizen.NUI.PropertyValue(value));
+ SetValue(ForegroundVisualPaddingProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(Button.Property.AUTO_REPEATING).Get(out temp);
- return temp;
+ return (bool)GetValue(AutoRepeatingProperty);
}
set
{
- SetProperty(Button.Property.AUTO_REPEATING, new Tizen.NUI.PropertyValue(value));
+ SetValue(AutoRepeatingProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(Button.Property.INITIAL_AUTO_REPEATING_DELAY).Get(out temp);
- return temp;
+ return (float)GetValue(InitialAutoRepeatingDelayProperty);
}
set
{
- SetProperty(Button.Property.INITIAL_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue(value));
+ SetValue(InitialAutoRepeatingDelayProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(Button.Property.NEXT_AUTO_REPEATING_DELAY).Get(out temp);
- return temp;
+ return (float)GetValue(NextAutoRepeatingDelayProperty);
}
set
{
- SetProperty(Button.Property.NEXT_AUTO_REPEATING_DELAY, new Tizen.NUI.PropertyValue(value));
+ SetValue(NextAutoRepeatingDelayProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(Button.Property.TOGGLABLE).Get(out temp);
- return temp;
+ return (bool)GetValue(TogglableProperty);
}
set
{
- SetProperty(Button.Property.TOGGLABLE, new Tizen.NUI.PropertyValue(value));
+ SetValue(TogglableProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(Button.Property.SELECTED).Get(out temp);
- return temp;
+ return (bool)GetValue(SelectedProperty);
}
set
{
- SetProperty(Button.Property.SELECTED, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectedProperty, value);
}
}
{
get
{
- Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(Button.Property.UNSELECTED_COLOR).Get(temp);
- return temp;
+ return (Color)GetValue(UnselectedColorProperty);
}
set
{
- SetProperty(Button.Property.UNSELECTED_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(UnselectedColorProperty, value);
}
}
{
get
{
- Color temp = new Color(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(Button.Property.SELECTED_COLOR).Get(temp);
- return temp;
+ return (Color)GetValue(SelectedColorProperty);
}
set
{
- SetProperty(Button.Property.SELECTED_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(SelectedColorProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(Button.Property.LABEL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(LabelProperty);
}
set
{
- SetProperty(Button.Property.LABEL, new Tizen.NUI.PropertyValue(value));
+ SetValue(LabelProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyMap map = new Tizen.NUI.PropertyMap();
- GetProperty( Button.Property.LABEL).Get(map);
- Tizen.NUI.PropertyValue value = map.Find( TextVisualProperty.Text, "Text");
- string str = "";
- value?.Get(out str);
- return str;
+ return (string)GetValue(LabelTextProperty);
}
set
{
- SetProperty( Button.Property.LABEL, new Tizen.NUI.PropertyValue( value ) );
+ SetValue(LabelTextProperty, value);
}
}
using System.ComponentModel;
using System.Runtime.InteropServices;
using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.UIComponents
{
/// <since_tizen> 3 </since_tizen>
public class Popup : View
{
+ /// 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 TitleProperty = BindableProperty.Create("Title", typeof(PropertyMap), typeof(Popup), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.TITLE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.TITLE).Get(temp);
+ return temp;
+ });
+ /// 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("Content", typeof(PropertyMap), typeof(Popup), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.CONTENT, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.CONTENT).Get(temp);
+ return temp;
+ });
+ /// 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 FooterProperty = BindableProperty.Create("Footer", typeof(PropertyMap), typeof(Popup), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.FOOTER, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.FOOTER).Get(temp);
+ return temp;
+ });
+ /// 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 DisplayStateProperty = BindableProperty.Create("DisplayState", typeof(DisplayStateType), typeof(Popup), DisplayStateType.Hidden, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((DisplayStateType)newValue)
+ {
+ case DisplayStateType.Showing:
+ {
+ valueToString = "SHOWING";
+ break;
+ }
+ case DisplayStateType.Shown:
+ {
+ valueToString = "SHOWN";
+ break;
+ }
+ case DisplayStateType.Hiding:
+ {
+ valueToString = "HIDING";
+ break;
+ }
+ case DisplayStateType.Hidden:
+ {
+ valueToString = "HIDDEN";
+ break;
+ }
+ default:
+ {
+ valueToString = "HIDDEN";
+ break;
+ }
+ }
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.DISPLAY_STATE, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.DISPLAY_STATE).Get(out temp) == false)
+ {
+ NUILog.Error("DisplayState get error!");
+ }
+ switch (temp)
+ {
+ case "SHOWING":
+ return DisplayStateType.Showing;
+ case "SHOWN":
+ return DisplayStateType.Shown;
+ case "HIDING":
+ return DisplayStateType.Hiding;
+ case "HIDDEN":
+ return DisplayStateType.Hidden;
+ default:
+ return DisplayStateType.Hidden;
+ }
+ });
+ /// 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 TouchTransparentProperty = BindableProperty.Create("TouchTransparent", typeof(bool), typeof(Popup), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.TOUCH_TRANSPARENT, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.TOUCH_TRANSPARENT).Get(out temp);
+ return temp;
+ });
+ /// 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 TailVisibilityProperty = BindableProperty.Create("TailVisibility", typeof(bool), typeof(Popup), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.TAIL_VISIBILITY, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.TAIL_VISIBILITY).Get(out temp);
+ return temp;
+ });
+ /// 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 TailPositionProperty = BindableProperty.Create("TailPosition", typeof(Vector3), typeof(Popup), Vector3.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.TAIL_POSITION, new Tizen.NUI.PropertyValue((Vector3)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.TAIL_POSITION).Get(temp);
+ return temp;
+ });
+ /// 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 ContextualModeProperty = BindableProperty.Create("ContextualMode", typeof(ContextualModeType), typeof(Popup), ContextualModeType.Below, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((ContextualModeType)newValue)
+ {
+ case ContextualModeType.NonContextual:
+ {
+ valueToString = "NON_CONTEXTUAL";
+ break;
+ }
+ case ContextualModeType.Above:
+ {
+ valueToString = "ABOVE";
+ break;
+ }
+ case ContextualModeType.Rright:
+ {
+ valueToString = "RIGHT";
+ break;
+ }
+ case ContextualModeType.Below:
+ {
+ valueToString = "BELOW";
+ break;
+ }
+ case ContextualModeType.Left:
+ {
+ valueToString = "LEFT";
+ break;
+ }
+ default:
+ {
+ valueToString = "BELOW";
+ break;
+ }
+ }
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.CONTEXTUAL_MODE, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.CONTEXTUAL_MODE).Get(out temp) == false)
+ {
+ NUILog.Error("ContextualMode get error!");
+ }
+ switch (temp)
+ {
+ case "NON_CONTEXTUAL":
+ return ContextualModeType.NonContextual;
+ case "ABOVE":
+ return ContextualModeType.Above;
+ case "RIGHT":
+ return ContextualModeType.Rright;
+ case "BELOW":
+ return ContextualModeType.Below;
+ case "LEFT":
+ return ContextualModeType.Left;
+ default:
+ return ContextualModeType.Below;
+ }
+ });
+ /// 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 AnimationDurationProperty = BindableProperty.Create("AnimationDuration", typeof(float), typeof(Popup), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.ANIMATION_DURATION, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.ANIMATION_DURATION).Get(out temp);
+ return temp;
+ });
+ /// 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 AnimationModeProperty = BindableProperty.Create("AnimationMode", typeof(AnimationModeType), typeof(Popup), AnimationModeType.Fade, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((AnimationModeType)newValue)
+ {
+ case AnimationModeType.None:
+ {
+ valueToString = "NONE";
+ break;
+ }
+ case AnimationModeType.Zoom:
+ {
+ valueToString = "ZOOM";
+ break;
+ }
+ case AnimationModeType.Fade:
+ {
+ valueToString = "FADE";
+ break;
+ }
+ case AnimationModeType.Custom:
+ {
+ valueToString = "CUSTOM";
+ break;
+ }
+ default:
+ {
+ valueToString = "FADE";
+ break;
+ }
+ }
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.ANIMATION_MODE, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.ANIMATION_MODE).Get(out temp) == false)
+ {
+ NUILog.Error("AnimationMode get error!");
+ }
+ switch (temp)
+ {
+ case "NONE":
+ return AnimationModeType.None;
+ case "ZOOM":
+ return AnimationModeType.Zoom;
+ case "FADE":
+ return AnimationModeType.Fade;
+ case "CUSTOM":
+ return AnimationModeType.Custom;
+ default:
+ return AnimationModeType.Fade;
+ }
+ });
+ /// 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 EntryAnimationProperty = BindableProperty.Create("EntryAnimation", typeof(PropertyMap), typeof(Popup), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.ENTRY_ANIMATION, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.ENTRY_ANIMATION).Get(temp);
+ return temp;
+ });
+ /// 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 ExitAnimationProperty = BindableProperty.Create("ExitAnimation", typeof(PropertyMap), typeof(Popup), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.EXIT_ANIMATION, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.EXIT_ANIMATION).Get(temp);
+ return temp;
+ });
+ /// 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 AutoHideDelayProperty = BindableProperty.Create("AutoHideDelay", typeof(int), typeof(Popup), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.AUTO_HIDE_DELAY, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.AUTO_HIDE_DELAY).Get(out temp);
+ return temp;
+ });
+ /// 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 BackingEnabledProperty = BindableProperty.Create("BackingEnabled", typeof(bool), typeof(Popup), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.BACKING_ENABLED, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.BACKING_ENABLED).Get(out temp);
+ return temp;
+ });
+ /// 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 BackingColorProperty = BindableProperty.Create("BackingColor", typeof(Vector4), typeof(Popup), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.BACKING_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.BACKING_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 PopupBackgroundImageProperty = BindableProperty.Create("PopupBackgroundImage", typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.POPUP_BACKGROUND_IMAGE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.POPUP_BACKGROUND_IMAGE).Get(out temp);
+ return temp;
+ });
+ /// 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 PopupBackgroundBorderProperty = BindableProperty.Create("PopupBackgroundBorder", typeof(Rectangle), typeof(Popup), new Rectangle(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.POPUP_BACKGROUND_BORDER, new Tizen.NUI.PropertyValue((Rectangle)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ Rectangle temp = new Rectangle(0, 0, 0, 0);
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.POPUP_BACKGROUND_BORDER).Get(temp);
+ return temp;
+ });
+ /// 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 TailUpImageProperty = BindableProperty.Create("TailUpImage", typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.TAIL_UP_IMAGE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.TAIL_UP_IMAGE).Get(out temp);
+ return temp;
+ });
+ /// 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 TailDownImageProperty = BindableProperty.Create("TailDownImage", typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.TAIL_DOWN_IMAGE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.TAIL_DOWN_IMAGE).Get(out temp);
+ return temp;
+ });
+ /// 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 TailLeftImageProperty = BindableProperty.Create("TailLeftImage", typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.TAIL_LEFT_IMAGE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.TAIL_LEFT_IMAGE).Get(out temp);
+ return temp;
+ });
+ /// 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 TailRightImageProperty = BindableProperty.Create("TailRightImage", typeof(string), typeof(Popup), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var popup = (Popup)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(popup.swigCPtr, Popup.Property.TAIL_RIGHT_IMAGE, new Tizen.NUI.PropertyValue((string)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var popup = (Popup)bindable;
+ string temp;
+ Tizen.NUI.Object.GetProperty(popup.swigCPtr, Popup.Property.TAIL_RIGHT_IMAGE).Get(out temp);
+ return temp;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal Popup(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Popup_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Popup.Property.TITLE).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(TitleProperty);
}
set
{
- SetProperty(Popup.Property.TITLE, new Tizen.NUI.PropertyValue(value));
+ SetValue(TitleProperty, value);
}
}
/// <summary>
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Popup.Property.CONTENT).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(ContentProperty);
}
set
{
- SetProperty(Popup.Property.CONTENT, new Tizen.NUI.PropertyValue(value));
+ SetValue(ContentProperty, value);
}
}
/// <summary>
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Popup.Property.FOOTER).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(FooterProperty);
}
set
{
- SetProperty(Popup.Property.FOOTER, new Tizen.NUI.PropertyValue(value));
+ SetValue(FooterProperty, value);
}
}
/// <summary>
{
get
{
- string temp;
- if (GetProperty(Popup.Property.DISPLAY_STATE).Get(out temp) == false)
- {
- NUILog.Error("DisplayState get error!");
- }
- switch (temp)
- {
- case "SHOWING":
- return DisplayStateType.Showing;
- case "SHOWN":
- return DisplayStateType.Shown;
- case "HIDING":
- return DisplayStateType.Hiding;
- case "HIDDEN":
- return DisplayStateType.Hidden;
- default:
- return DisplayStateType.Hidden;
- }
+ return (DisplayStateType)GetValue(DisplayStateProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case DisplayStateType.Showing:
- {
- valueToString = "SHOWING";
- break;
- }
- case DisplayStateType.Shown:
- {
- valueToString = "SHOWN";
- break;
- }
- case DisplayStateType.Hiding:
- {
- valueToString = "HIDING";
- break;
- }
- case DisplayStateType.Hidden:
- {
- valueToString = "HIDDEN";
- break;
- }
- default:
- {
- valueToString = "HIDDEN";
- break;
- }
- }
- SetProperty(Popup.Property.DISPLAY_STATE, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(DisplayStateProperty, value);
}
}
/// <summary>
{
get
{
- bool temp = false;
- GetProperty(Popup.Property.TOUCH_TRANSPARENT).Get(out temp);
- return temp;
+ return (bool)GetValue(TouchTransparentProperty);
}
set
{
- SetProperty(Popup.Property.TOUCH_TRANSPARENT, new Tizen.NUI.PropertyValue(value));
+ SetValue(TouchTransparentProperty, value);
}
}
/// <summary>
{
get
{
- bool temp = false;
- GetProperty(Popup.Property.TAIL_VISIBILITY).Get(out temp);
- return temp;
+ return (bool)GetValue(TailVisibilityProperty);
}
set
{
- SetProperty(Popup.Property.TAIL_VISIBILITY, new Tizen.NUI.PropertyValue(value));
+ SetValue(TailVisibilityProperty, value);
}
}
/// <summary>
{
get
{
- Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
- GetProperty(Popup.Property.TAIL_POSITION).Get(temp);
- return temp;
+ return (Vector3)GetValue(TailPositionProperty);
}
set
{
- SetProperty(Popup.Property.TAIL_POSITION, new Tizen.NUI.PropertyValue(value));
+ SetValue(TailPositionProperty, value);
}
}
/// <summary>
{
get
{
- string temp;
- if (GetProperty(Popup.Property.CONTEXTUAL_MODE).Get(out temp) == false)
- {
- NUILog.Error("ContextualMode get error!");
- }
- switch (temp)
- {
- case "NON_CONTEXTUAL":
- return ContextualModeType.NonContextual;
- case "ABOVE":
- return ContextualModeType.Above;
- case "RIGHT":
- return ContextualModeType.Rright;
- case "BELOW":
- return ContextualModeType.Below;
- case "LEFT":
- return ContextualModeType.Left;
- default:
- return ContextualModeType.Below;
- }
+ return (ContextualModeType)GetValue(ContextualModeProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case ContextualModeType.NonContextual:
- {
- valueToString = "NON_CONTEXTUAL";
- break;
- }
- case ContextualModeType.Above:
- {
- valueToString = "ABOVE";
- break;
- }
- case ContextualModeType.Rright:
- {
- valueToString = "RIGHT";
- break;
- }
- case ContextualModeType.Below:
- {
- valueToString = "BELOW";
- break;
- }
- case ContextualModeType.Left:
- {
- valueToString = "LEFT";
- break;
- }
- default:
- {
- valueToString = "BELOW";
- break;
- }
- }
- SetProperty(Popup.Property.CONTEXTUAL_MODE, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(ContextualModeProperty, value);
}
}
/// <summary>
{
get
{
- float temp = 0.0f;
- GetProperty(Popup.Property.ANIMATION_DURATION).Get(out temp);
- return temp;
+ return (float)GetValue(AnimationDurationProperty);
}
set
{
- SetProperty(Popup.Property.ANIMATION_DURATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(AnimationDurationProperty, value);
}
}
/// <summary>
{
get
{
- string temp;
- if (GetProperty(Popup.Property.ANIMATION_MODE).Get(out temp) == false)
- {
- NUILog.Error("AnimationMode get error!");
- }
- switch (temp)
- {
- case "NONE":
- return AnimationModeType.None;
- case "ZOOM":
- return AnimationModeType.Zoom;
- case "FADE":
- return AnimationModeType.Fade;
- case "CUSTOM":
- return AnimationModeType.Custom;
- default:
- return AnimationModeType.Fade;
- }
+ return (AnimationModeType)GetValue(AnimationModeProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case AnimationModeType.None:
- {
- valueToString = "NONE";
- break;
- }
- case AnimationModeType.Zoom:
- {
- valueToString = "ZOOM";
- break;
- }
- case AnimationModeType.Fade:
- {
- valueToString = "FADE";
- break;
- }
- case AnimationModeType.Custom:
- {
- valueToString = "CUSTOM";
- break;
- }
- default:
- {
- valueToString = "FADE";
- break;
- }
- }
- SetProperty(Popup.Property.ANIMATION_MODE, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(AnimationModeProperty, value);
}
}
/// <summary>
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Popup.Property.ENTRY_ANIMATION).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(EntryAnimationProperty);
}
set
{
- SetProperty(Popup.Property.ENTRY_ANIMATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(EntryAnimationProperty, value);
}
}
/// <summary>
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Popup.Property.EXIT_ANIMATION).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(ExitAnimationProperty);
}
set
{
- SetProperty(Popup.Property.EXIT_ANIMATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(ExitAnimationProperty, value);
}
}
/// <summary>
{
get
{
- int temp = 0;
- GetProperty(Popup.Property.AUTO_HIDE_DELAY).Get(out temp);
- return temp;
+ return (int)GetValue(AutoHideDelayProperty);
}
set
{
- SetProperty(Popup.Property.AUTO_HIDE_DELAY, new Tizen.NUI.PropertyValue(value));
+ SetValue(AutoHideDelayProperty, value);
}
}
/// <summary>
{
get
{
- bool temp = false;
- GetProperty(Popup.Property.BACKING_ENABLED).Get(out temp);
- return temp;
+ return (bool)GetValue(BackingEnabledProperty);
}
set
{
- SetProperty(Popup.Property.BACKING_ENABLED, new Tizen.NUI.PropertyValue(value));
+ SetValue(BackingEnabledProperty, value);
}
}
/// <summary>
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(Popup.Property.BACKING_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(BackingColorProperty);
}
set
{
- SetProperty(Popup.Property.BACKING_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(BackingColorProperty, value);
}
}
/// <summary>
{
get
{
- string temp;
- GetProperty(Popup.Property.POPUP_BACKGROUND_IMAGE).Get(out temp);
- return temp;
+ return (string)GetValue(PopupBackgroundImageProperty);
}
set
{
- SetProperty(Popup.Property.POPUP_BACKGROUND_IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(PopupBackgroundImageProperty, value);
}
}
/// <summary>
{
get
{
- Rectangle temp = new Rectangle(0, 0, 0, 0);
- GetProperty(Popup.Property.POPUP_BACKGROUND_BORDER).Get(temp);
- return temp;
+ return (Rectangle)GetValue(PopupBackgroundBorderProperty);
}
set
{
- SetProperty(Popup.Property.POPUP_BACKGROUND_BORDER, new Tizen.NUI.PropertyValue(value));
+ SetValue(PopupBackgroundBorderProperty, value);
}
}
/// <summary>
{
get
{
- string temp;
- GetProperty(Popup.Property.TAIL_UP_IMAGE).Get(out temp);
- return temp;
+ return (string)GetValue(TailUpImageProperty);
}
set
{
- SetProperty(Popup.Property.TAIL_UP_IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(TailUpImageProperty, value);
}
}
/// <summary>
{
get
{
- string temp;
- GetProperty(Popup.Property.TAIL_DOWN_IMAGE).Get(out temp);
- return temp;
+ return (string)GetValue(TailDownImageProperty);
}
set
{
- SetProperty(Popup.Property.TAIL_DOWN_IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(TailDownImageProperty, value);
}
}
/// <summary>
{
get
{
- string temp;
- GetProperty(Popup.Property.TAIL_LEFT_IMAGE).Get(out temp);
- return temp;
+ return (string)GetValue(TailLeftImageProperty);
}
set
{
- SetProperty(Popup.Property.TAIL_LEFT_IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(TailLeftImageProperty, value);
}
}
/// <summary>
{
get
{
- string temp;
- GetProperty(Popup.Property.TAIL_RIGHT_IMAGE).Get(out temp);
- return temp;
+ return (string)GetValue(TailRightImageProperty);
}
set
{
- SetProperty(Popup.Property.TAIL_RIGHT_IMAGE, new Tizen.NUI.PropertyValue(value));
+ SetValue(TailRightImageProperty, value);
}
}
}
-}
\ No newline at end of file
+}
* limitations under the License.
*
*/
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.UIComponents
{
-
- using System;
- using System.Runtime.InteropServices;
- using Tizen.NUI.BaseComponents;
-
/// <summary>
/// The ProgressBar is a control to give the user an indication of the progress of an operation.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public class ProgressBar : View
{
+ /// 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 ProgressValueProperty = BindableProperty.Create("ProgressValue", typeof(float), typeof(ProgressBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.PROGRESS_VALUE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.PROGRESS_VALUE).Get(out temp);
+ return temp;
+ });
+ /// 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 SecondaryProgressValueProperty = BindableProperty.Create("SecondaryProgressValue", typeof(float), typeof(ProgressBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.SECONDARY_PROGRESS_VALUE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.SECONDARY_PROGRESS_VALUE).Get(out temp);
+ return temp;
+ });
+ /// 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 IndeterminateProperty = BindableProperty.Create("Indeterminate", typeof(bool), typeof(ProgressBar), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE).Get(out temp);
+ return temp;
+ });
+ /// 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 TrackVisualProperty = BindableProperty.Create("TrackVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.TRACK_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.TRACK_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 ProgressVisualProperty = BindableProperty.Create("ProgressVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.PROGRESS_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.PROGRESS_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 SecondaryProgressVisualProperty = BindableProperty.Create("SecondaryProgressVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.SECONDARY_PROGRESS_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.SECONDARY_PROGRESS_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 IndeterminateVisualProperty = BindableProperty.Create("IndeterminateVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 IndeterminateVisualAnimationProperty = BindableProperty.Create("IndeterminateVisualAnimation", typeof(PropertyArray), typeof(ProgressBar), new PropertyArray(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE_VISUAL_ANIMATION, new Tizen.NUI.PropertyValue((PropertyArray)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
+ Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE_VISUAL_ANIMATION).Get(temp);
+ return temp;
+ });
+ /// 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 LabelVisualProperty = BindableProperty.Create("LabelVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.LABEL_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var progressBar = (ProgressBar)bindable;
+ Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
+ Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.LABEL_VISUAL).Get(temp);
+ return temp;
+ });
+
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal ProgressBar(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ProgressBar_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- float temp = 0.0f;
- GetProperty(ProgressBar.Property.PROGRESS_VALUE).Get(out temp);
- return temp;
+ return (float)GetValue(ProgressValueProperty);
}
set
{
- SetProperty(ProgressBar.Property.PROGRESS_VALUE, new Tizen.NUI.PropertyValue(value));
+ SetValue(ProgressValueProperty, value);
}
}
+
/// <summary>
/// The secondary progress value of the progress bar, the secondary progress runs from 0 to 1.<br />
/// Optional. If not supplied, the default is 0.<br />
{
get
{
- float temp = 0.0f;
- GetProperty(ProgressBar.Property.SECONDARY_PROGRESS_VALUE).Get(out temp);
- return temp;
+ return (float)GetValue(SecondaryProgressValueProperty);
}
set
{
- SetProperty(ProgressBar.Property.SECONDARY_PROGRESS_VALUE, new Tizen.NUI.PropertyValue(value));
+ SetValue(SecondaryProgressValueProperty, value);
}
}
+
/// <summary>
/// Sets the progress bar as \e indeterminate state.
/// </summary>
{
get
{
- bool temp = false;
- GetProperty(ProgressBar.Property.INDETERMINATE).Get(out temp);
- return temp;
+ return (bool)GetValue(IndeterminateProperty);
}
set
{
- SetProperty(ProgressBar.Property.INDETERMINATE, new Tizen.NUI.PropertyValue(value));
+ SetValue(IndeterminateProperty, value);
}
}
+
/// <summary>
/// The track visual value of progress bar, it's full progress area, and it's shown behind the PROGRESS_VISUAL.<br />
/// Optional. If not supplied, the default track visual will be shown.<br />
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(ProgressBar.Property.TRACK_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(TrackVisualProperty);
}
set
{
- SetProperty(ProgressBar.Property.TRACK_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(TrackVisualProperty, value);
}
}
+
/// <summary>
/// The progress visual value of the progress bar, the size of the progress visual is changed based on the PROGRESS_VALUE.<br />
/// Optional. If not supplied, then the default progress visual will be shown.<br />
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(ProgressBar.Property.PROGRESS_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(ProgressVisualProperty);
}
set
{
- SetProperty(ProgressBar.Property.PROGRESS_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(ProgressVisualProperty, value);
}
}
+
/// <summary>
/// The secondary progress visual of the progress bar, the size of the secondary progress visual is changed based on the SECONDARY_PROGRESS_VALUE.<br />
/// Optional. If not supplied, then the secondary progress visual will not be shown.<br />
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(ProgressBar.Property.SECONDARY_PROGRESS_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(SecondaryProgressVisualProperty);
}
set
{
- SetProperty(ProgressBar.Property.SECONDARY_PROGRESS_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(SecondaryProgressVisualProperty, value);
}
}
+
/// <summary>
/// The indeterminate visual of the progress bar.<br />
/// Optional. If not supplied, then the default indeterminate visual will be shown.<br />
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(ProgressBar.Property.INDETERMINATE_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(IndeterminateVisualProperty);
}
set
{
- SetProperty(ProgressBar.Property.INDETERMINATE_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(IndeterminateVisualProperty, value);
}
}
+
/// <summary>
/// The transition data for the indeterminate visual animation.<br />
/// Optional. If not supplied, then the default animation will be played.<br />
{
get
{
- Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
- GetProperty(ProgressBar.Property.INDETERMINATE_VISUAL_ANIMATION).Get(temp);
- return temp;
+ return (PropertyArray)GetValue(IndeterminateVisualAnimationProperty);
}
set
{
- SetProperty(ProgressBar.Property.INDETERMINATE_VISUAL_ANIMATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(IndeterminateVisualAnimationProperty, value);
}
}
+
/// <summary>
/// The label visual of the progress bar.
/// </summary>
{
get
{
- Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
- GetProperty(ProgressBar.Property.LABEL_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(LabelVisualProperty);
}
set
{
- SetProperty(ProgressBar.Property.LABEL_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(LabelVisualProperty, value);
}
}
using System;
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
+using System.Windows.Input;
+using System.Collections.Generic;
namespace Tizen.NUI.UIComponents
{
-
/// <summary>
/// The PushButton changes its appearance when it is pressed, and returns to its original when it is released.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public class PushButton : Button
{
+ /// 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 CommandProperty = BindableProperty.Create("Command", typeof(ICommand), typeof(PushButton), null,
+ BindingMode.OneWay, null, null, null, null, null as BindableProperty.CreateDefaultValueDelegate);
+ /// 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 CommandParameterProperty = BindableProperty.Create("CommandParameter", typeof(object), typeof(PushButton), null,
+ BindingMode.OneWay, null, null, null, null, null as BindableProperty.CreateDefaultValueDelegate);
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal PushButton(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PushButton_SWIGUpcast(cPtr), cMemoryOwn)
public PushButton() : this(NDalicPINVOKE.PushButton_New(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ this.Clicked += (sender, e) =>
+ {
+ ICommand command = this.Command;
+ if (command != null)
+ {
+ command.Execute(this.CommandParameter);
+ }
+ return true;
+ };
+ }
+
+ /// 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 ICommand Command
+ {
+ get
+ {
+ return (ICommand)base.GetValue(PushButton.CommandProperty);
+ }
+ set
+ {
+ base.SetValue(PushButton.CommandProperty, value);
+ }
+ }
+ /// 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 object CommandParameter
+ {
+ get
+ {
+ return base.GetValue(PushButton.CommandParameterProperty);
+ }
+ set
+ {
+ base.SetValue(PushButton.CommandParameterProperty, value);
+ }
}
}
}
\ No newline at end of file
using System.ComponentModel;
using System.Runtime.InteropServices;
using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.UIComponents
{
/// <since_tizen> 3 </since_tizen>
public class ScrollBar : View
{
+ /// 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 ScrollDirectionProperty = BindableProperty.Create("ScrollDirection", typeof(Direction), typeof(ScrollBar), Direction.Vertical, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((Direction)newValue)
+ {
+ case Direction.Vertical: { valueToString = "Vertical"; break; }
+ case Direction.Horizontal: { valueToString = "Horizontal"; break; }
+ default: { valueToString = "Vertical"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(scrollBar.swigCPtr, ScrollBar.Property.SCROLL_DIRECTION, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(scrollBar.swigCPtr, ScrollBar.Property.SCROLL_DIRECTION).Get(out temp) == false)
+ {
+ NUILog.Error("ScrollDirection get error!");
+ }
+
+ switch (temp)
+ {
+ case "Vertical": return Direction.Vertical;
+ case "Horizontal": return Direction.Horizontal;
+ default: return Direction.Vertical;
+ }
+ });
+ /// 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 IndicatorHeightPolicyProperty = BindableProperty.Create("IndicatorHeightPolicy", typeof(IndicatorHeightPolicyType), typeof(ScrollBar), IndicatorHeightPolicyType.Variable, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ string valueToString = "";
+ if (newValue != null)
+ {
+ switch ((IndicatorHeightPolicyType)newValue)
+ {
+ case IndicatorHeightPolicyType.Variable:{ valueToString = "Variable"; break; }
+ case IndicatorHeightPolicyType.Fixed: { valueToString = "Fixed"; break; }
+ default: { valueToString = "Variable"; break; }
+ }
+ Tizen.NUI.Object.SetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_HEIGHT_POLICY, new Tizen.NUI.PropertyValue(valueToString));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ string temp;
+ if (Tizen.NUI.Object.GetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_HEIGHT_POLICY).Get(out temp) == false)
+ {
+ NUILog.Error("IndicatorHeightPolicy get error!");
+ }
+
+ switch (temp)
+ {
+ case "Variable": return IndicatorHeightPolicyType.Variable;
+ case "Fixed": return IndicatorHeightPolicyType.Fixed;
+ default: return IndicatorHeightPolicyType.Variable;
+ }
+ });
+ /// 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 IndicatorFixedHeightProperty = BindableProperty.Create("IndicatorFixedHeight", typeof(float), typeof(ScrollBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_FIXED_HEIGHT, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_FIXED_HEIGHT).Get(out temp);
+ return temp;
+ });
+ /// 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 IndicatorShowDurationProperty = BindableProperty.Create("IndicatorShowDuration", typeof(float), typeof(ScrollBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_SHOW_DURATION, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_SHOW_DURATION).Get(out temp);
+ return temp;
+ });
+ /// 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 IndicatorHideDurationProperty = BindableProperty.Create("IndicatorHideDuration", typeof(float), typeof(ScrollBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_HIDE_DURATION, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_HIDE_DURATION).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollPositionIntervalsProperty = BindableProperty.Create("ScrollPositionIntervals", typeof(PropertyArray), typeof(ScrollBar), new PropertyArray(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollBar.swigCPtr, ScrollBar.Property.SCROLL_POSITION_INTERVALS, new Tizen.NUI.PropertyValue((PropertyArray)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
+ Tizen.NUI.Object.GetProperty(scrollBar.swigCPtr, ScrollBar.Property.SCROLL_POSITION_INTERVALS).Get(temp);
+ return temp;
+ });
+ /// 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 IndicatorMinimumHeightProperty = BindableProperty.Create("IndicatorMinimumHeight", typeof(float), typeof(ScrollBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_MINIMUM_HEIGHT, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_MINIMUM_HEIGHT).Get(out temp);
+ return temp;
+ });
+ /// 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 IndicatorStartPaddingProperty = BindableProperty.Create("IndicatorStartPadding", typeof(float), typeof(ScrollBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_START_PADDING, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_START_PADDING).Get(out temp);
+ return temp;
+ });
+ /// 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 IndicatorEndPaddingProperty = BindableProperty.Create("IndicatorEndPadding", typeof(float), typeof(ScrollBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_END_PADDING, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollBar = (ScrollBar)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(scrollBar.swigCPtr, ScrollBar.Property.INDICATOR_END_PADDING).Get(out temp);
+ return temp;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal ScrollBar(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ScrollBar_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- string temp;
- if (GetProperty(ScrollBar.Property.SCROLL_DIRECTION).Get(out temp) == false)
- {
- NUILog.Error("ScrollDirection get error!");
- }
- switch (temp)
- {
- case "Vertical":
- return Direction.Vertical;
- case "Horizontal":
- return Direction.Horizontal;
- default:
- return Direction.Vertical;
- }
+ return (Direction)GetValue(ScrollDirectionProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case Direction.Vertical:
- {
- valueToString = "Vertical";
- break;
- }
- case Direction.Horizontal:
- {
- valueToString = "Horizontal";
- break;
- }
- default:
- {
- valueToString = "Vertical";
- break;
- }
- }
- SetProperty(ScrollBar.Property.SCROLL_DIRECTION, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(ScrollDirectionProperty, value);
}
}
{
get
{
- string temp;
- if (GetProperty(ScrollBar.Property.INDICATOR_HEIGHT_POLICY).Get(out temp) == false)
- {
- NUILog.Error("IndicatorHeightPolicy get error!");
- }
-
- switch (temp)
- {
- case "Variable":
- return IndicatorHeightPolicyType.Variable;
- case "Fixed":
- return IndicatorHeightPolicyType.Fixed;
- default:
- return IndicatorHeightPolicyType.Variable;
- }
+ return (IndicatorHeightPolicyType)GetValue(IndicatorHeightPolicyProperty);
}
set
{
- string valueToString = "";
- switch (value)
- {
- case IndicatorHeightPolicyType.Variable:
- {
- valueToString = "Variable";
- break;
- }
- case IndicatorHeightPolicyType.Fixed:
- {
- valueToString = "Fixed";
- break;
- }
- default:
- {
- valueToString = "Variable";
- break;
- }
- }
- SetProperty(ScrollBar.Property.INDICATOR_HEIGHT_POLICY, new Tizen.NUI.PropertyValue(valueToString));
+ SetValue(IndicatorHeightPolicyProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(ScrollBar.Property.INDICATOR_FIXED_HEIGHT).Get(out temp);
- return temp;
+ return (float)GetValue(IndicatorFixedHeightProperty);
}
set
{
- SetProperty(ScrollBar.Property.INDICATOR_FIXED_HEIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(IndicatorFixedHeightProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(ScrollBar.Property.INDICATOR_SHOW_DURATION).Get(out temp);
- return temp;
+ return (float)GetValue(IndicatorShowDurationProperty);
}
set
{
- SetProperty(ScrollBar.Property.INDICATOR_SHOW_DURATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(IndicatorShowDurationProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(ScrollBar.Property.INDICATOR_HIDE_DURATION).Get(out temp);
- return temp;
+ return (float)GetValue(IndicatorHideDurationProperty);
}
set
{
- SetProperty(ScrollBar.Property.INDICATOR_HIDE_DURATION, new Tizen.NUI.PropertyValue(value));
+ SetValue(IndicatorHideDurationProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
- GetProperty(ScrollBar.Property.SCROLL_POSITION_INTERVALS).Get(temp);
- return temp;
+ return (PropertyArray)GetValue(ScrollPositionIntervalsProperty);
}
set
{
- SetProperty(ScrollBar.Property.SCROLL_POSITION_INTERVALS, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollPositionIntervalsProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(ScrollBar.Property.INDICATOR_MINIMUM_HEIGHT).Get(out temp);
- return temp;
+ return (float)GetValue(IndicatorMinimumHeightProperty);
}
set
{
- SetProperty(ScrollBar.Property.INDICATOR_MINIMUM_HEIGHT, new Tizen.NUI.PropertyValue(value));
+ SetValue(IndicatorMinimumHeightProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(ScrollBar.Property.INDICATOR_START_PADDING).Get(out temp);
- return temp;
+ return (float)GetValue(IndicatorStartPaddingProperty);
}
set
{
- SetProperty(ScrollBar.Property.INDICATOR_START_PADDING, new Tizen.NUI.PropertyValue(value));
+ SetValue(IndicatorStartPaddingProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(ScrollBar.Property.INDICATOR_END_PADDING).Get(out temp);
- return temp;
+ return (float)GetValue(IndicatorEndPaddingProperty);
}
set
{
- SetProperty(ScrollBar.Property.INDICATOR_END_PADDING, new Tizen.NUI.PropertyValue(value));
+ SetValue(IndicatorEndPaddingProperty, value);
}
}
}
-}
\ No newline at end of file
+}
* limitations under the License.
*
*/
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
namespace Tizen.NUI
{
-
- using System;
- using System.Runtime.InteropServices;
- using Tizen.NUI.BaseComponents;
-
/// <summary>
/// ScrollView contains views that can be scrolled manually (via touch).
/// </summary>
/// <since_tizen> 3 </since_tizen>
public class ScrollView : Scrollable
{
+ /// 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 WrapEnabledProperty = BindableProperty.Create("WrapEnabled", typeof(bool), typeof(ScrollView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.WRAP_ENABLED, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.WRAP_ENABLED).Get(out temp);
+ return temp;
+ });
+ /// 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 PanningEnabledProperty = BindableProperty.Create("PanningEnabled", typeof(bool), typeof(ScrollView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.PANNING_ENABLED, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.PANNING_ENABLED).Get(out temp);
+ return temp;
+ });
+ /// 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 AxisAutoLockEnabledProperty = BindableProperty.Create("AxisAutoLockEnabled", typeof(bool), typeof(ScrollView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.AXIS_AUTO_LOCK_ENABLED, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.AXIS_AUTO_LOCK_ENABLED).Get(out temp);
+ return temp;
+ });
+ /// 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 WheelScrollDistanceStepProperty = BindableProperty.Create("WheelScrollDistanceStep", typeof(Vector2), typeof(ScrollView), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.WHEEL_SCROLL_DISTANCE_STEP, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.WHEEL_SCROLL_DISTANCE_STEP).Get(temp);
+ return temp;
+ });
+ /// 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 ScrollPositionProperty = BindableProperty.Create("ScrollPosition", typeof(Vector2), typeof(ScrollView), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_POSITION, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_POSITION).Get(temp);
+ return temp;
+ });
+ /// 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 ScrollPrePositionProperty = BindableProperty.Create("ScrollPrePosition", typeof(Vector2), typeof(ScrollView), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_PRE_POSITION, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_PRE_POSITION).Get(temp);
+ return temp;
+ });
+ /// 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 ScrollPrePositionMaxProperty = BindableProperty.Create("ScrollPrePositionMax", typeof(Vector2), typeof(ScrollView), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_PRE_POSITION_MAX, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_PRE_POSITION_MAX).Get(temp);
+ return temp;
+ });
+ /// 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 OvershootXProperty = BindableProperty.Create("OvershootX", typeof(float), typeof(ScrollView), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.OVERSHOOT_X, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.OVERSHOOT_X).Get(out temp);
+ return temp;
+ });
+ /// 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 OvershootYProperty = BindableProperty.Create("OvershootY", typeof(float), typeof(ScrollView), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.OVERSHOOT_Y, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.OVERSHOOT_Y).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollFinalProperty = BindableProperty.Create("ScrollFinal", typeof(Vector2), typeof(ScrollView), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_FINAL, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_FINAL).Get(temp);
+ return temp;
+ });
+ /// 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 WrapProperty = BindableProperty.Create("Wrap", typeof(bool), typeof(ScrollView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.WRAP, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.WRAP).Get(out temp);
+ return temp;
+ });
+ /// 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 PanningProperty = BindableProperty.Create("Panning", typeof(bool), typeof(ScrollView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.PANNING, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.PANNING).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollingProperty = BindableProperty.Create("Scrolling", typeof(bool), typeof(ScrollView), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLLING, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLLING).Get(out temp);
+ return temp;
+ });
+ /// 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 ScrollDomainSizeProperty = BindableProperty.Create("ScrollDomainSize", typeof(Vector2), typeof(ScrollView), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_DOMAIN_SIZE, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_DOMAIN_SIZE).Get(temp);
+ return temp;
+ });
+ /// 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 ScrollDomainOffsetProperty = BindableProperty.Create("ScrollDomainOffset", typeof(Vector2), typeof(ScrollView), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_DOMAIN_OFFSET, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_DOMAIN_OFFSET).Get(temp);
+ return temp;
+ });
+ /// 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 ScrollPositionDeltaProperty = BindableProperty.Create("ScrollPositionDelta", typeof(Vector2), typeof(ScrollView), Vector2.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_POSITION_DELTA, new Tizen.NUI.PropertyValue((Vector2)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ Vector2 temp = new Vector2(0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_POSITION_DELTA).Get(temp);
+ return temp;
+ });
+ /// 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 StartPagePositionProperty = BindableProperty.Create("StartPagePosition", typeof(Vector3), typeof(ScrollView), Vector3.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.START_PAGE_POSITION, new Tizen.NUI.PropertyValue((Vector3)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.START_PAGE_POSITION).Get(temp);
+ return temp;
+ });
+ /// 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 ScrollModeProperty = BindableProperty.Create("ScrollMode", typeof(PropertyMap), typeof(ScrollView), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_MODE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var scrollView = (ScrollView)bindable;
+ PropertyValue value = Tizen.NUI.Object.GetProperty(scrollView.swigCPtr, ScrollView.Property.SCROLL_MODE );
+ PropertyMap map = new PropertyMap();
+ value.Get( map );
+ return map;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal ScrollView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ScrollView_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- bool temp = false;
- GetProperty(ScrollView.Property.WRAP_ENABLED).Get(out temp);
- return temp;
+ return (bool)GetValue(WrapEnabledProperty);
}
set
{
- SetProperty(ScrollView.Property.WRAP_ENABLED, new Tizen.NUI.PropertyValue(value));
+ SetValue(WrapEnabledProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(ScrollView.Property.PANNING_ENABLED).Get(out temp);
- return temp;
+ return (bool)GetValue(PanningEnabledProperty);
}
set
{
- SetProperty(ScrollView.Property.PANNING_ENABLED, new Tizen.NUI.PropertyValue(value));
+ SetValue(PanningEnabledProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(ScrollView.Property.AXIS_AUTO_LOCK_ENABLED).Get(out temp);
- return temp;
+ return (bool)GetValue(AxisAutoLockEnabledProperty);
}
set
{
- SetProperty(ScrollView.Property.AXIS_AUTO_LOCK_ENABLED, new Tizen.NUI.PropertyValue(value));
+ SetValue(AxisAutoLockEnabledProperty, value);
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(ScrollView.Property.WHEEL_SCROLL_DISTANCE_STEP).Get(temp);
- return temp;
+ return (Vector2)GetValue(WheelScrollDistanceStepProperty);
}
set
{
- SetProperty(ScrollView.Property.WHEEL_SCROLL_DISTANCE_STEP, new Tizen.NUI.PropertyValue(value));
+ SetValue(WheelScrollDistanceStepProperty, value);
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(ScrollView.Property.SCROLL_POSITION).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollPositionProperty);
}
set
{
- SetProperty(ScrollView.Property.SCROLL_POSITION, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollPositionProperty, value);
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(ScrollView.Property.SCROLL_PRE_POSITION).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollPrePositionProperty);
}
set
{
- SetProperty(ScrollView.Property.SCROLL_PRE_POSITION, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollPrePositionProperty, value);
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(ScrollView.Property.SCROLL_PRE_POSITION_MAX).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollPrePositionMaxProperty);
}
set
{
- SetProperty(ScrollView.Property.SCROLL_PRE_POSITION_MAX, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollPrePositionMaxProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(ScrollView.Property.OVERSHOOT_X).Get(out temp);
- return temp;
+ return (float)GetValue(OvershootXProperty);
}
set
{
- SetProperty(ScrollView.Property.OVERSHOOT_X, new Tizen.NUI.PropertyValue(value));
+ SetValue(OvershootXProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(ScrollView.Property.OVERSHOOT_Y).Get(out temp);
- return temp;
+ return (float)GetValue(OvershootYProperty);
}
set
{
- SetProperty(ScrollView.Property.OVERSHOOT_Y, new Tizen.NUI.PropertyValue(value));
+ SetValue(OvershootYProperty, value);
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(ScrollView.Property.SCROLL_FINAL).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollFinalProperty);
}
set
{
- SetProperty(ScrollView.Property.SCROLL_FINAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollFinalProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(ScrollView.Property.WRAP).Get(out temp);
- return temp;
+ return (bool)GetValue(WrapProperty);
}
set
{
- SetProperty(ScrollView.Property.WRAP, new Tizen.NUI.PropertyValue(value));
+ SetValue(WrapProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(ScrollView.Property.PANNING).Get(out temp);
- return temp;
+ return (bool)GetValue(PanningProperty);
}
set
{
- SetProperty(ScrollView.Property.PANNING, new Tizen.NUI.PropertyValue(value));
+ SetValue(PanningProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(ScrollView.Property.SCROLLING).Get(out temp);
- return temp;
+ return (bool)GetValue(ScrollingProperty);
}
set
{
- SetProperty(ScrollView.Property.SCROLLING, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollingProperty, value);
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(ScrollView.Property.SCROLL_DOMAIN_SIZE).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollDomainSizeProperty);
}
set
{
- SetProperty(ScrollView.Property.SCROLL_DOMAIN_SIZE, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollDomainSizeProperty, value);
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(ScrollView.Property.SCROLL_DOMAIN_OFFSET).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollDomainOffsetProperty);
}
set
{
- SetProperty(ScrollView.Property.SCROLL_DOMAIN_OFFSET, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollDomainOffsetProperty, value);
}
}
{
get
{
- Vector2 temp = new Vector2(0.0f, 0.0f);
- GetProperty(ScrollView.Property.SCROLL_POSITION_DELTA).Get(temp);
- return temp;
+ return (Vector2)GetValue(ScrollPositionDeltaProperty);
}
set
{
- SetProperty(ScrollView.Property.SCROLL_POSITION_DELTA, new Tizen.NUI.PropertyValue(value));
+ SetValue(ScrollPositionDeltaProperty, value);
}
}
{
get
{
- Vector3 temp = new Vector3(0.0f, 0.0f, 0.0f);
- GetProperty(ScrollView.Property.START_PAGE_POSITION).Get(temp);
- return temp;
+ return (Vector3)GetValue(StartPagePositionProperty);
}
set
{
- SetProperty(ScrollView.Property.START_PAGE_POSITION, new Tizen.NUI.PropertyValue(value));
+ SetValue(StartPagePositionProperty, value);
}
}
{
get
{
- PropertyValue value = GetProperty( ScrollView.Property.SCROLL_MODE );
- PropertyMap map = new PropertyMap();
- value.Get( map );
- return map;
+ return (PropertyMap)GetValue(ScrollModeProperty);
}
set
{
- SetProperty( ScrollView.Property.SCROLL_MODE, new PropertyValue( value ) );
+ SetValue(ScrollModeProperty, value);
}
}
}
-}
\ No newline at end of file
+}
* limitations under the License.
*
*/
+using System;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.UIComponents
{
-
- using System;
- using System.Runtime.InteropServices;
- using Tizen.NUI.BaseComponents;
-
/// <summary>
/// The slider is a control to enable sliding an indicator between two values.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public class Slider : View
{
+ /// 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 LowerBoundProperty = BindableProperty.Create("LowerBound", typeof(float), typeof(Slider), 0.0f, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.LOWER_BOUND, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ Console.WriteLine("Slider LowerBoundProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.LOWER_BOUND).Get(out temp);
+ return temp;
+ });
+ /// 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 UpperBoundProperty = BindableProperty.Create("UpperBound", typeof(float), typeof(Slider), 1.0f, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.UPPER_BOUND, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ Console.WriteLine("Slider UpperBoundProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.UPPER_BOUND).Get(out temp);
+ return temp;
+ });
+ /// 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 ValueProperty = BindableProperty.Create("Value", typeof(float), typeof(Slider), default(float), BindingMode.TwoWay, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ Console.WriteLine("Slider ValueProperty Changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.VALUE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.VALUE).Get(out temp);
+ return temp;
+ });
+ /// 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 TrackVisualProperty = BindableProperty.Create("TrackVisual", typeof(PropertyMap), typeof(Slider), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.TRACK_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ Console.WriteLine("Slider TrackVisualProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.TRACK_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 HandleVisualProperty = BindableProperty.Create("HandleVisual", typeof(PropertyMap), typeof(Slider), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.HANDLE_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ Console.WriteLine("Slider HandleVisualProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.HANDLE_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 ProgressVisualProperty = BindableProperty.Create("ProgressVisual", typeof(PropertyMap), typeof(Slider), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.PROGRESS_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ Console.WriteLine("Slider ProgressVisualProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.PROGRESS_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 PopupVisualProperty = BindableProperty.Create("PopupVisual", typeof(PropertyMap), typeof(Slider), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.POPUP_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ Console.WriteLine("Slider PopupVisualProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.POPUP_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 PopupArrowVisualProperty = BindableProperty.Create("PopupArrowVisual", typeof(PropertyMap), typeof(Slider), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.POPUP_ARROW_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
+ }
+ Console.WriteLine("Slider PopupArrowVisualProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ PropertyMap temp = new PropertyMap();
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.POPUP_ARROW_VISUAL).Get(temp);
+ return temp;
+ });
+ /// 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 DisabledColorProperty = BindableProperty.Create("DisabledColor", typeof(Vector4), typeof(Slider), Vector4.Zero, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.DISABLED_COLOR, new Tizen.NUI.PropertyValue((Vector4)newValue));
+ }
+ Console.WriteLine("Slider DisabledColorProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.DISABLED_COLOR).Get(temp);
+ return temp;
+ });
+ /// 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 ValuePrecisionProperty = BindableProperty.Create("ValuePrecision", typeof(int), typeof(Slider), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.VALUE_PRECISION, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ Console.WriteLine("Slider ValuePrecisionProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.VALUE_PRECISION).Get(out temp);
+ return temp;
+ });
+ /// 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 ShowPopupProperty = BindableProperty.Create("ShowPopup", typeof(bool), typeof(Slider), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.SHOW_POPUP, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ Console.WriteLine("Slider ShowPopupProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.SHOW_POPUP).Get(out temp);
+ return temp;
+ });
+ /// 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 ShowValueProperty = BindableProperty.Create("ShowValue", typeof(bool), typeof(Slider), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.SHOW_VALUE, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ Console.WriteLine("Slider ShowValueProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.SHOW_VALUE).Get(out temp);
+ return temp;
+ });
+ /// 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 MarksProperty = BindableProperty.Create("Marks", typeof(PropertyArray), typeof(Slider), new PropertyArray(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.MARKS, new Tizen.NUI.PropertyValue((PropertyArray)newValue));
+ }
+ Console.WriteLine("Slider MarksPropertyProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.MARKS).Get(temp);
+ return temp;
+ });
+ /// 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 MarkToleranceProperty = BindableProperty.Create("MarkTolerance", typeof(float), typeof(Slider), default(float), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.MARK_TOLERANCE, new Tizen.NUI.PropertyValue((float)newValue));
+ }
+ Console.WriteLine("Slider MarkToleranceProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ float temp = 0.0f;
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.MARK_TOLERANCE).Get(out temp);
+ return temp;
+ });
+ /// 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 SnapToMarksProperty = BindableProperty.Create("SnapToMarks", typeof(bool), typeof(Slider), false, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var slider = (Slider)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(slider.swigCPtr, Slider.Property.SNAP_TO_MARKS, new Tizen.NUI.PropertyValue((bool)newValue));
+ }
+ Console.WriteLine("Slider SnapToMarksPropertyProperty changed: oldValue: " + oldValue + ", newValue: " + newValue);
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var slider = (Slider)bindable;
+ bool temp = false;
+ Tizen.NUI.Object.GetProperty(slider.swigCPtr, Slider.Property.SNAP_TO_MARKS).Get(out temp);
+ return temp;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal Slider(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Slider_SWIGUpcast(cPtr), cMemoryOwn)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ this.ValueChanged += (obj, e) => {
+ this.Value = e.SlideValue;
+ return true;
+ };
}
+
internal Slider(Slider handle) : this(NDalicPINVOKE.new_Slider__SWIG_1(Slider.getCPtr(handle)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
{
get
{
- float temp = 0.0f;
- GetProperty(Slider.Property.LOWER_BOUND).Get(out temp);
- return temp;
+ return (float)GetValue(LowerBoundProperty);
}
set
{
- SetProperty(Slider.Property.LOWER_BOUND, new Tizen.NUI.PropertyValue(value));
+ SetValue(LowerBoundProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(Slider.Property.UPPER_BOUND).Get(out temp);
- return temp;
+ return (float)GetValue(UpperBoundProperty);
}
set
{
- SetProperty(Slider.Property.UPPER_BOUND, new Tizen.NUI.PropertyValue(value));
+ SetValue(UpperBoundProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(Slider.Property.VALUE).Get(out temp);
- return temp;
+ return (float)GetValue(ValueProperty);
}
set
{
- SetProperty(Slider.Property.VALUE, new Tizen.NUI.PropertyValue(value));
+ SetValueAndForceSendChangeSignal(ValueProperty, value);
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Slider.Property.TRACK_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(TrackVisualProperty);
}
set
{
- SetProperty(Slider.Property.TRACK_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(TrackVisualProperty, value);
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Slider.Property.HANDLE_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(HandleVisualProperty);
}
set
{
- SetProperty(Slider.Property.HANDLE_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(HandleVisualProperty, value);
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Slider.Property.PROGRESS_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(ProgressVisualProperty);
}
set
{
- SetProperty(Slider.Property.PROGRESS_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(ProgressVisualProperty, value);
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Slider.Property.POPUP_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(PopupVisualProperty);
}
set
{
- SetProperty(Slider.Property.POPUP_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(PopupVisualProperty, value);
}
}
{
get
{
- PropertyMap temp = new PropertyMap();
- GetProperty(Slider.Property.POPUP_ARROW_VISUAL).Get(temp);
- return temp;
+ return (PropertyMap)GetValue(PopupArrowVisualProperty);
}
set
{
- SetProperty(Slider.Property.POPUP_ARROW_VISUAL, new Tizen.NUI.PropertyValue(value));
+ SetValue(PopupArrowVisualProperty, value);
}
}
{
get
{
- Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
- GetProperty(Slider.Property.DISABLED_COLOR).Get(temp);
- return temp;
+ return (Vector4)GetValue(DisabledColorProperty);
}
set
{
- SetProperty(Slider.Property.DISABLED_COLOR, new Tizen.NUI.PropertyValue(value));
+ SetValue(DisabledColorProperty, value);
}
}
{
get
{
- int temp = 0;
- GetProperty(Slider.Property.VALUE_PRECISION).Get(out temp);
- return temp;
+ return (int)GetValue(ValuePrecisionProperty);
}
set
{
- SetProperty(Slider.Property.VALUE_PRECISION, new Tizen.NUI.PropertyValue(value));
+ SetValue(ValuePrecisionProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(Slider.Property.SHOW_POPUP).Get(out temp);
- return temp;
+ return (bool)GetValue(ShowPopupProperty);
}
set
{
- SetProperty(Slider.Property.SHOW_POPUP, new Tizen.NUI.PropertyValue(value));
+ SetValue(ShowPopupProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(Slider.Property.SHOW_VALUE).Get(out temp);
- return temp;
+ return (bool)GetValue(ShowValueProperty);
}
set
{
- SetProperty(Slider.Property.SHOW_VALUE, new Tizen.NUI.PropertyValue(value));
+ SetValue(ShowValueProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
- GetProperty(Slider.Property.MARKS).Get(temp);
- return temp;
+ return (PropertyArray)GetValue(MarksProperty);
}
set
{
- SetProperty(Slider.Property.MARKS, new Tizen.NUI.PropertyValue(value));
+ SetValue(MarksProperty, value);
}
}
{
get
{
- bool temp = false;
- GetProperty(Slider.Property.SNAP_TO_MARKS).Get(out temp);
- return temp;
+ return (bool)GetValue(SnapToMarksProperty);
}
set
{
- SetProperty(Slider.Property.SNAP_TO_MARKS, new Tizen.NUI.PropertyValue(value));
+ SetValue(SnapToMarksProperty, value);
}
}
{
get
{
- float temp = 0.0f;
- GetProperty(Slider.Property.MARK_TOLERANCE).Get(out temp);
- return temp;
+ return (float)GetValue(MarkToleranceProperty);
}
set
{
- SetProperty(Slider.Property.MARK_TOLERANCE, new Tizen.NUI.PropertyValue(value));
+ SetValue(MarkToleranceProperty, value);
}
}
* limitations under the License.
*
*/
-
-using Tizen.NUI.BaseComponents;
+using System.ComponentModel;
+using Tizen.NUI.Binding;
namespace Tizen.NUI
{
/// <since_tizen> 3 </since_tizen>
public class ToggleButton : Tizen.NUI.UIComponents.Button
{
+ /// 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 StateVisualsProperty = BindableProperty.Create("StateVisuals", typeof(PropertyArray), typeof(ToggleButton), new PropertyArray(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var toggleButton = (ToggleButton)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(toggleButton.swigCPtr, ToggleButton.Property.STATE_VISUALS, new Tizen.NUI.PropertyValue((PropertyArray)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var toggleButton = (ToggleButton)bindable;
+ Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
+ Tizen.NUI.Object.GetProperty(toggleButton.swigCPtr, ToggleButton.Property.STATE_VISUALS).Get(temp);
+ return temp;
+ });
+ /// 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 TooltipsProperty = BindableProperty.Create("Tooltips", typeof(PropertyArray), typeof(ToggleButton), new PropertyArray(), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var toggleButton = (ToggleButton)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(toggleButton.swigCPtr, ToggleButton.Property.TOOLTIPS, new Tizen.NUI.PropertyValue((PropertyArray)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var toggleButton = (ToggleButton)bindable;
+ Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
+ Tizen.NUI.Object.GetProperty(toggleButton.swigCPtr, ToggleButton.Property.TOOLTIPS).Get(temp);
+ return temp;
+ });
+ /// 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 CurrentStateIndexProperty = BindableProperty.Create("CurrentStateIndex", typeof(int), typeof(ToggleButton), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var toggleButton = (ToggleButton)bindable;
+ if (newValue != null)
+ {
+ Tizen.NUI.Object.SetProperty(toggleButton.swigCPtr, ToggleButton.Property.CURRENT_STATE_INDEX, new Tizen.NUI.PropertyValue((int)newValue));
+ }
+ },
+ defaultValueCreator:(bindable) =>
+ {
+ var toggleButton = (ToggleButton)bindable;
+ int temp = 0;
+ Tizen.NUI.Object.GetProperty(toggleButton.swigCPtr, ToggleButton.Property.CURRENT_STATE_INDEX).Get(out temp);
+ return temp;
+ });
+
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal ToggleButton(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ToggleButton_SWIGUpcast(cPtr), cMemoryOwn)
{
get
{
- Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
- GetProperty(ToggleButton.Property.STATE_VISUALS).Get(temp);
- return temp;
+ return (PropertyArray)GetValue(StateVisualsProperty);
}
set
{
- SetProperty(ToggleButton.Property.STATE_VISUALS, new Tizen.NUI.PropertyValue(value));
+ SetValue(StateVisualsProperty, value);
}
}
{
get
{
- Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
- GetProperty(ToggleButton.Property.TOOLTIPS).Get(temp);
- return temp;
+ return (PropertyArray)GetValue(TooltipsProperty);
}
set
{
- SetProperty(ToggleButton.Property.TOOLTIPS, new Tizen.NUI.PropertyValue(value));
+ SetValue(TooltipsProperty, value);
}
}
{
get
{
- int temp = 0;
- GetProperty(ToggleButton.Property.CURRENT_STATE_INDEX).Get(out temp);
- return temp;
+ return (int)GetValue(CurrentStateIndexProperty);
}
set
{
- SetProperty(ToggleButton.Property.CURRENT_STATE_INDEX, new Tizen.NUI.PropertyValue(value));
+ SetValue(CurrentStateIndexProperty, value);
}
}
}
/// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ Vector2 vector2 = obj as Vector2;
+ bool equal = false;
+ if (X == vector2?.X && Y == vector2?.Y)
+ {
+ equal = true;
+ }
+ return equal;
+ }
+
+ /// <summary>
/// Returns the length of the vector.
/// </summary>
/// <returns>The length of the vector.</returns>
}
/// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ Vector3 vector3 = obj as Vector3;
+ bool equal = false;
+ if (X == vector3?.X && Y == vector3?.Y && Z == vector3?.Z)
+ {
+ equal = true;
+ }
+ return equal;
+ }
+
+ /// <summary>
/// Returns the length of the vector.
/// </summary>
/// <returns>The length of the vector.</returns>
}
/// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ /// <param name="obj">The object to compare with the current object.</param>
+ /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
+ public override bool Equals(System.Object obj)
+ {
+ Vector4 vector4 = obj as Vector4;
+ bool equal = false;
+ if (X == vector4?.X && Y == vector4?.Y && Z == vector4?.Z && W == vector4?.W)
+ {
+ equal = true;
+ }
+ return equal;
+ }
+
+ /// <summary>
/// Returns the length of the vector.
/// </summary>
/// <returns>The length.</returns>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static class Extensions
- {
+ {
/// <summary>
/// Returns an initialized view by loading the specified xaml.
/// </summary>
/// <param name="view">The view on which this method operates.</param>
/// <param name="callingType">The type of the caller.</param>
/// <returns>A TXaml with the properties that are defined in the application manifest for callingType.</returns>
+ /// 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 TXaml LoadFromXaml<TXaml>(this TXaml view, Type callingType)
- {
- XamlLoader.Load(view, callingType);
- return view;
- }
+ {
+ XamlLoader.Load(view, callingType);
+ return view;
+ }
/// <summary>
/// Returns a TXaml with the properties that are defined in the application manifest for callingType.
/// <param name="view">The view on which this method operates.</param>
/// <param name="xaml">The XAML that encodes the view state.</param>
/// <returns>A TXaml with the properties that are defined in the application manifest for callingType.</returns>
- public static TXaml LoadFromXaml<TXaml>(this TXaml view, string xaml)
- {
- XamlLoader.Load(view, xaml);
- return view;
- }
+ /// 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 TXaml LoadFromXaml<TXaml>(this TXaml view, string xaml)
+ {
+ XamlLoader.Load(view, xaml);
+ return view;
+ }
+
+ /// 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)
+ {
+ return XamlLoader.LoadTransition(animationXamlPath);
+ }
}
}
\ No newline at end of file
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract class BindableObject : INotifyPropertyChanged, IDynamicResourceHandler
- {
+ {
/// <summary>
/// Implements the bound property whose interface is provided by the BindingContext property.
/// </summary>
- public static readonly BindableProperty BindingContextProperty =
- BindableProperty.Create("BindingContext", typeof(object), typeof(BindableObject), default(object),
- BindingMode.OneWay, null, BindingContextPropertyChanged, null, null, BindingContextPropertyBindingChanging);
+ internal static readonly BindableProperty BindingContextProperty =
+ BindableProperty.Create("BindingContext", typeof(object), typeof(BindableObject), default(object),
+ BindingMode.OneWay, null, BindingContextPropertyChanged, null, null, BindingContextPropertyBindingChanging);
- readonly List<BindablePropertyContext> _properties = new List<BindablePropertyContext>(4);
+ readonly List<BindablePropertyContext> _properties = new List<BindablePropertyContext>(4);
- bool _applying;
- object _inheritedContext;
+ bool _applying;
+ object _inheritedContext;
/// <summary>
/// Gets or sets object that contains the properties that will be targeted by the bound properties that belong to this BindableObject.
/// </summary>
- public object BindingContext
- {
- get { return _inheritedContext ?? GetValue(BindingContextProperty); }
- set { SetValue(BindingContextProperty, value); }
- }
-
- void IDynamicResourceHandler.SetDynamicResource(BindableProperty property, string key)
- {
- SetDynamicResource(property, key, false);
- }
+ /// 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 object BindingContext
+ {
+ get { return _inheritedContext ?? GetValue(BindingContextProperty); }
+ set { SetValue(BindingContextProperty, value); }
+ }
+
+ void IDynamicResourceHandler.SetDynamicResource(BindableProperty property, string key)
+ {
+ SetDynamicResource(property, key, false);
+ }
/// <summary>
/// Raised when a property has changed.
/// </summary>
- public event PropertyChangedEventHandler PropertyChanged;
+ /// 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 event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Raised whenever the BindingContext property changes.
/// </summary>
- public event EventHandler BindingContextChanged;
+ /// 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 event EventHandler BindingContextChanged;
- internal void ClearValue(BindableProperty property, bool fromStyle)
- {
- ClearValue(property, fromStyle: fromStyle, checkAccess: true);
- }
+ internal void ClearValue(BindableProperty property, bool fromStyle)
+ {
+ ClearValue(property, fromStyle: fromStyle, checkAccess: true);
+ }
/// <summary>
/// Clears any value set by Xamarin.Forms.BindableObject.SetValue.
/// </summary>
/// <param name="property">The BindableProperty to clear</param>
- public void ClearValue(BindableProperty property)
- {
- ClearValue(property, fromStyle: false, checkAccess: true);
- }
+ internal void ClearValue(BindableProperty property)
+ {
+ ClearValue(property, fromStyle: false, checkAccess: true);
+ }
/// <summary>
/// Clears any value set by Xamarin.Forms.BindableObject.SetValue for the property that is identified by propertyKey.
/// </summary>
/// <param name="propertyKey">The BindablePropertyKey that identifies the BindableProperty to clear.</param>
- public void ClearValue(BindablePropertyKey propertyKey)
- {
- if (propertyKey == null)
- throw new ArgumentNullException("propertyKey");
+ internal void ClearValue(BindablePropertyKey propertyKey)
+ {
+ if (propertyKey == null)
+ throw new ArgumentNullException("propertyKey");
- ClearValue(propertyKey.BindableProperty, fromStyle:false, checkAccess: false);
- }
+ ClearValue(propertyKey.BindableProperty, fromStyle:false, checkAccess: false);
+ }
/// <summary>
/// Return true if the target property exists and has been set.
/// </summary>
/// <param name="targetProperty">The target property</param>
/// <returns>return true if the target property exists and has been set</returns>
- public bool IsSet(BindableProperty targetProperty)
- {
- if (targetProperty == null)
- throw new ArgumentNullException(nameof(targetProperty));
+ internal bool IsSet(BindableProperty targetProperty)
+ {
+ if (targetProperty == null)
+ throw new ArgumentNullException(nameof(targetProperty));
- var bpcontext = GetContext(targetProperty);
- return bpcontext != null
- && (bpcontext.Attributes & BindableContextAttributes.IsDefaultValue) == 0;
- }
+ var bpcontext = GetContext(targetProperty);
+ return bpcontext != null
+ && (bpcontext.Attributes & BindableContextAttributes.IsDefaultValue) == 0;
+ }
/// <summary>
/// Returns the value that is contained the BindableProperty.
/// </summary>
/// <param name="property">The BindableProperty for which to get the value.</param>
/// <returns>The value that is contained the BindableProperty</returns>
- public object GetValue(BindableProperty property)
- {
- if (property == null)
- throw new ArgumentNullException("property");
+ internal object GetValue(BindableProperty property)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
- BindablePropertyContext context = property.DefaultValueCreator != null ? GetOrCreateContext(property) : GetContext(property);
+ BindablePropertyContext context = property.DefaultValueCreator != null ? GetOrCreateContext(property) : GetContext(property);
- if (context == null)
- return property.DefaultValue;
+ if (context == null)
+ return property.DefaultValue;
- return context.Value;
- }
+ return context.Value;
+ }
/// <summary>
/// Raised when a property is about to change.
/// </summary>
- public event PropertyChangingEventHandler PropertyChanging;
+ /// 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 event PropertyChangingEventHandler PropertyChanging;
/// <summary>
/// Removes a previously set binding.
/// </summary>
/// <param name="property">The BindableProperty from which to remove bindings.</param>
- public void RemoveBinding(BindableProperty property)
- {
- if (property == null)
- throw new ArgumentNullException("property");
+ internal void RemoveBinding(BindableProperty property)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
- BindablePropertyContext context = GetContext(property);
- if (context == null || context.Binding == null)
- return;
+ BindablePropertyContext context = GetContext(property);
+ if (context == null || context.Binding == null)
+ return;
- RemoveBinding(property, context);
- }
+ RemoveBinding(property, context);
+ }
/// <summary>
/// Assigns a binding to a property.
/// </summary>
/// <param name="targetProperty">The BindableProperty on which to set a binding.</param>
/// <param name="binding">The binding to set.</param>
- public void SetBinding(BindableProperty targetProperty, BindingBase binding)
- {
- SetBinding(targetProperty, binding, false);
- }
+ internal void SetBinding(BindableProperty targetProperty, BindingBase binding)
+ {
+ SetBinding(targetProperty, binding, false);
+ }
+
+ internal bool isCreateByXaml = false;
/// <summary>
/// Sets the value of the specified property.
/// </summary>
/// <param name="property">The BindableProperty on which to assign a value.</param>
/// <param name="value">The value to set.</param>
- public void SetValue(BindableProperty property, object value)
- {
- SetValue(property, value, false, true);
- }
+ internal void SetValue(BindableProperty property, object value)
+ {
+ if (true == isCreateByXaml)
+ {
+ SetValue(property, value, false, true);
+ }
+ else
+ {
+ property.PropertyChanged?.Invoke(this, null, value);
+ }
+ }
+
+ internal void SetValueAndForceSendChangeSignal(BindableProperty property, object value)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
+
+ if (true == isCreateByXaml)
+ {
+ if (property.IsReadOnly)
+ throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
+
+ SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource,
+ SetValuePrivateFlags.ManuallySet | SetValuePrivateFlags.CheckAccess, true);
+ }
+ else
+ {
+ property.PropertyChanged?.Invoke(this, null, value);
+ }
+ }
/// <summary>
/// Sets the value of the propertyKey.
/// </summary>
/// <param name="propertyKey">The BindablePropertyKey on which to assign a value.</param>
/// <param name="value">The value to set.</param>
- public void SetValue(BindablePropertyKey propertyKey, object value)
- {
- if (propertyKey == null)
- throw new ArgumentNullException("propertyKey");
+ internal void SetValue(BindablePropertyKey propertyKey, object value)
+ {
+ if (propertyKey == null)
+ throw new ArgumentNullException("propertyKey");
- SetValue(propertyKey.BindableProperty, value, false, false);
- }
+ SetValue(propertyKey.BindableProperty, value, false, false);
+ }
/// <summary>
/// Set the inherited context to a neated element.
/// </summary>
/// <param name="bindable">The object on which to set the inherited binding context.</param>
/// <param name="value">The inherited context to set.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void SetInheritedBindingContext(BindableObject bindable, object value)
- {
- BindablePropertyContext bpContext = bindable.GetContext(BindingContextProperty);
- if (bpContext != null && ((bpContext.Attributes & BindableContextAttributes.IsManuallySet) != 0))
- return;
-
- object oldContext = bindable._inheritedContext;
-
- if (ReferenceEquals(oldContext, value))
- return;
-
- if (bpContext != null && oldContext == null)
- oldContext = bpContext.Value;
-
- if (bpContext != null && bpContext.Binding != null)
- {
- bpContext.Binding.Context = value;
- bindable._inheritedContext = null;
- }
- else
- {
- bindable._inheritedContext = value;
- }
-
- bindable.ApplyBindings(skipBindingContext:false, fromBindingContextChanged:true);
- bindable.OnBindingContextChanged();
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void SetInheritedBindingContext(BindableObject bindable, object value)
+ {
+ BindablePropertyContext bpContext = bindable.GetContext(BindingContextProperty);
+ if (bpContext != null && ((bpContext.Attributes & BindableContextAttributes.IsManuallySet) != 0))
+ return;
+
+ object oldContext = bindable._inheritedContext;
+
+ if (ReferenceEquals(oldContext, value))
+ return;
+
+ if (bpContext != null && oldContext == null)
+ oldContext = bpContext.Value;
+
+ if (bpContext != null && bpContext.Binding != null)
+ {
+ bpContext.Binding.Context = value;
+ bindable._inheritedContext = null;
+ }
+ else
+ {
+ bindable._inheritedContext = value;
+ }
+
+ bindable.ApplyBindings(skipBindingContext:false, fromBindingContextChanged:true);
+ bindable.OnBindingContextChanged();
+ }
/// <summary>
/// Apply the bindings to BindingContext.
/// </summary>
- protected void ApplyBindings()
- {
- ApplyBindings(skipBindingContext: false, fromBindingContextChanged: false);
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected void ApplyBindings()
+ {
+ ApplyBindings(skipBindingContext: false, fromBindingContextChanged: false);
+ }
/// <summary>
/// Override this method to execute an action when the BindingContext changes.
/// </summary>
- protected virtual void OnBindingContextChanged()
- {
- BindingContextChanged?.Invoke(this, EventArgs.Empty);
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnBindingContextChanged()
+ {
+ BindingContextChanged?.Invoke(this, EventArgs.Empty);
+ }
/// <summary>
/// Call this method from a child class to notify that a change happened on a property.
/// </summary>
/// <param name="propertyName">The name of the property that changed.</param>
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/// <summary>
/// Call this method from a child class to notify that a change is going to happen on a property.
/// </summary>
/// <param name="propertyName">The name of the property that is changing.</param>
- protected virtual void OnPropertyChanging([CallerMemberName] string propertyName = null)
- => PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName));
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnPropertyChanging([CallerMemberName] string propertyName = null)
+ => PropertyChanging?.Invoke(this, new PropertyChangingEventArgs(propertyName));
/// <summary>
/// Unapplies all previously set bindings.
/// </summary>
- protected void UnapplyBindings()
- {
- for (int i = 0, _propertiesCount = _properties.Count; i < _propertiesCount; i++) {
- BindablePropertyContext context = _properties [i];
- if (context.Binding == null)
- continue;
-
- context.Binding.Unapply();
- }
- }
-
- internal bool GetIsBound(BindableProperty targetProperty)
- {
- if (targetProperty == null)
- throw new ArgumentNullException("targetProperty");
-
- BindablePropertyContext bpcontext = GetContext(targetProperty);
- return bpcontext != null && bpcontext.Binding != null;
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected void UnapplyBindings()
+ {
+ for (int i = 0, _propertiesCount = _properties.Count; i < _propertiesCount; i++) {
+ BindablePropertyContext context = _properties [i];
+ if (context.Binding == null)
+ continue;
+
+ context.Binding.Unapply();
+ }
+ }
+
+ internal bool GetIsBound(BindableProperty targetProperty)
+ {
+ if (targetProperty == null)
+ throw new ArgumentNullException("targetProperty");
+
+ BindablePropertyContext bpcontext = GetContext(targetProperty);
+ return bpcontext != null && bpcontext.Binding != null;
+ }
/// <summary>
/// Returns the value that is contained the BindableProperty.
/// <param name="property0">The BindableProperty instance.</param>
/// <param name="property1">The BindableProperty instance.</param>
/// <returns>The value that is contained the BindableProperty</returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public object[] GetValues(BindableProperty property0, BindableProperty property1)
- {
- var values = new object[2];
-
- for (var i = 0; i < _properties.Count; i++)
- {
- BindablePropertyContext context = _properties[i];
-
- if (ReferenceEquals(context.Property, property0))
- {
- values[0] = context.Value;
- property0 = null;
- }
- else if (ReferenceEquals(context.Property, property1))
- {
- values[1] = context.Value;
- property1 = null;
- }
-
- if (property0 == null && property1 == null)
- return values;
- }
-
- if (!ReferenceEquals(property0, null))
- values[0] = property0.DefaultValueCreator == null ? property0.DefaultValue : CreateAndAddContext(property0).Value;
- if (!ReferenceEquals(property1, null))
- values[1] = property1.DefaultValueCreator == null ? property1.DefaultValue : CreateAndAddContext(property1).Value;
-
- return values;
- }
+ internal object[] GetValues(BindableProperty property0, BindableProperty property1)
+ {
+ var values = new object[2];
+
+ for (var i = 0; i < _properties.Count; i++)
+ {
+ BindablePropertyContext context = _properties[i];
+
+ if (ReferenceEquals(context.Property, property0))
+ {
+ values[0] = context.Value;
+ property0 = null;
+ }
+ else if (ReferenceEquals(context.Property, property1))
+ {
+ values[1] = context.Value;
+ property1 = null;
+ }
+
+ if (property0 == null && property1 == null)
+ return values;
+ }
+
+ if (!ReferenceEquals(property0, null))
+ values[0] = property0.DefaultValueCreator == null ? property0.DefaultValue : CreateAndAddContext(property0).Value;
+ if (!ReferenceEquals(property1, null))
+ values[1] = property1.DefaultValueCreator == null ? property1.DefaultValue : CreateAndAddContext(property1).Value;
+
+ return values;
+ }
/// <summary>
/// Returns the value that is contained the BindableProperty.
/// <param name="property1">The BindableProperty instance.</param>
/// <param name="property2">The BindableProperty instance.</param>
/// <returns>The value that is contained the BindableProperty</returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public object[] GetValues(BindableProperty property0, BindableProperty property1, BindableProperty property2)
- {
- var values = new object[3];
-
- for (var i = 0; i < _properties.Count; i++)
- {
- BindablePropertyContext context = _properties[i];
-
- if (ReferenceEquals(context.Property, property0))
- {
- values[0] = context.Value;
- property0 = null;
- }
- else if (ReferenceEquals(context.Property, property1))
- {
- values[1] = context.Value;
- property1 = null;
- }
- else if (ReferenceEquals(context.Property, property2))
- {
- values[2] = context.Value;
- property2 = null;
- }
-
- if (property0 == null && property1 == null && property2 == null)
- return values;
- }
-
- if (!ReferenceEquals(property0, null))
- values[0] = property0.DefaultValueCreator == null ? property0.DefaultValue : CreateAndAddContext(property0).Value;
- if (!ReferenceEquals(property1, null))
- values[1] = property1.DefaultValueCreator == null ? property1.DefaultValue : CreateAndAddContext(property1).Value;
- if (!ReferenceEquals(property2, null))
- values[2] = property2.DefaultValueCreator == null ? property2.DefaultValue : CreateAndAddContext(property2).Value;
-
- return values;
- }
+ internal object[] GetValues(BindableProperty property0, BindableProperty property1, BindableProperty property2)
+ {
+ var values = new object[3];
+
+ for (var i = 0; i < _properties.Count; i++)
+ {
+ BindablePropertyContext context = _properties[i];
+
+ if (ReferenceEquals(context.Property, property0))
+ {
+ values[0] = context.Value;
+ property0 = null;
+ }
+ else if (ReferenceEquals(context.Property, property1))
+ {
+ values[1] = context.Value;
+ property1 = null;
+ }
+ else if (ReferenceEquals(context.Property, property2))
+ {
+ values[2] = context.Value;
+ property2 = null;
+ }
+
+ if (property0 == null && property1 == null && property2 == null)
+ return values;
+ }
+
+ if (!ReferenceEquals(property0, null))
+ values[0] = property0.DefaultValueCreator == null ? property0.DefaultValue : CreateAndAddContext(property0).Value;
+ if (!ReferenceEquals(property1, null))
+ values[1] = property1.DefaultValueCreator == null ? property1.DefaultValue : CreateAndAddContext(property1).Value;
+ if (!ReferenceEquals(property2, null))
+ values[2] = property2.DefaultValueCreator == null ? property2.DefaultValue : CreateAndAddContext(property2).Value;
+
+ return values;
+ }
/// <summary>
/// Returns the value that is contained the BindableProperty.
/// </summary>
/// <param name="properties">The array of the BindableProperty instances</param>
/// <returns>The values that is contained the BindableProperty instances.</returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal object[] GetValues(params BindableProperty[] properties)
- {
- var values = new object[properties.Length];
- for (var i = 0; i < _properties.Count; i++) {
- var context = _properties[i];
- var index = properties.IndexOf(context.Property);
- if (index < 0)
- continue;
- values[index] = context.Value;
- }
- for (var i = 0; i < values.Length; i++) {
- if (!ReferenceEquals(values[i], null))
- continue;
- values[i] = properties[i].DefaultValueCreator == null ? properties[i].DefaultValue : CreateAndAddContext(properties[i]).Value;
- }
- return values;
- }
-
- internal virtual void OnRemoveDynamicResource(BindableProperty property)
- {
- }
-
- internal virtual void OnSetDynamicResource(BindableProperty property, string key)
- {
- }
-
- internal void RemoveDynamicResource(BindableProperty property)
- {
- if (property == null)
- throw new ArgumentNullException("property");
-
- OnRemoveDynamicResource(property);
- BindablePropertyContext context = GetOrCreateContext(property);
- context.Attributes &= ~BindableContextAttributes.IsDynamicResource;
- }
-
- internal void SetBinding(BindableProperty targetProperty, BindingBase binding, bool fromStyle)
- {
- if (targetProperty == null)
- throw new ArgumentNullException("targetProperty");
- if (binding == null)
- throw new ArgumentNullException("binding");
-
- if (fromStyle && !CanBeSetFromStyle(targetProperty))
- return;
-
- var context = GetOrCreateContext(targetProperty);
- if (fromStyle)
- context.Attributes |= BindableContextAttributes.IsSetFromStyle;
- else
- context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
-
- if (context.Binding != null)
- context.Binding.Unapply();
-
- BindingBase oldBinding = context.Binding;
- context.Binding = binding;
-
- targetProperty.BindingChanging?.Invoke(this, oldBinding, binding);
-
- binding.Apply(BindingContext, this, targetProperty);
- }
-
- bool CanBeSetFromStyle(BindableProperty property)
- {
- var context = GetContext(property);
- if (context == null)
- return true;
- if ((context.Attributes & BindableContextAttributes.IsSetFromStyle) == BindableContextAttributes.IsSetFromStyle)
- return true;
- if ((context.Attributes & BindableContextAttributes.IsDefaultValue) == BindableContextAttributes.IsDefaultValue)
- return true;
- if ((context.Attributes & BindableContextAttributes.IsDefaultValueCreated) == BindableContextAttributes.IsDefaultValueCreated)
- return true;
- return false;
- }
-
- internal void SetDynamicResource(BindableProperty property, string key)
- {
- SetDynamicResource(property, key, false);
- }
-
- internal void SetDynamicResource(BindableProperty property, string key, bool fromStyle)
- {
- if (property == null)
- throw new ArgumentNullException(nameof(property));
- if (string.IsNullOrEmpty(key))
- throw new ArgumentNullException(nameof(key));
- if (fromStyle && !CanBeSetFromStyle(property))
- return;
-
- var context = GetOrCreateContext(property);
-
- context.Attributes |= BindableContextAttributes.IsDynamicResource;
- if (fromStyle)
- context.Attributes |= BindableContextAttributes.IsSetFromStyle;
- else
- context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
-
- OnSetDynamicResource(property, key);
- }
-
- internal void SetValue(BindableProperty property, object value, bool fromStyle)
- {
- SetValue(property, value, fromStyle, true);
- }
-
- internal void SetValueCore(BindablePropertyKey propertyKey, object value, SetValueFlags attributes = SetValueFlags.None)
- {
- SetValueCore(propertyKey.BindableProperty, value, attributes, SetValuePrivateFlags.None);
- }
+ internal object[] GetValues(params BindableProperty[] properties)
+ {
+ var values = new object[properties.Length];
+ for (var i = 0; i < _properties.Count; i++) {
+ var context = _properties[i];
+ var index = properties.IndexOf(context.Property);
+ if (index < 0)
+ continue;
+ values[index] = context.Value;
+ }
+ for (var i = 0; i < values.Length; i++) {
+ if (!ReferenceEquals(values[i], null))
+ continue;
+ values[i] = properties[i].DefaultValueCreator == null ? properties[i].DefaultValue : CreateAndAddContext(properties[i]).Value;
+ }
+ return values;
+ }
+
+ internal virtual void OnRemoveDynamicResource(BindableProperty property)
+ {
+ }
+
+ internal virtual void OnSetDynamicResource(BindableProperty property, string key)
+ {
+ }
+
+ internal void RemoveDynamicResource(BindableProperty property)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
+
+ OnRemoveDynamicResource(property);
+ BindablePropertyContext context = GetOrCreateContext(property);
+ context.Attributes &= ~BindableContextAttributes.IsDynamicResource;
+ }
+
+ internal void SetBinding(BindableProperty targetProperty, BindingBase binding, bool fromStyle)
+ {
+ if (targetProperty == null)
+ throw new ArgumentNullException("targetProperty");
+ if (binding == null)
+ throw new ArgumentNullException("binding");
+
+ if (fromStyle && !CanBeSetFromStyle(targetProperty))
+ return;
+
+ var context = GetOrCreateContext(targetProperty);
+ if (fromStyle)
+ context.Attributes |= BindableContextAttributes.IsSetFromStyle;
+ else
+ context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
+
+ if (context.Binding != null)
+ context.Binding.Unapply();
+
+ BindingBase oldBinding = context.Binding;
+ context.Binding = binding;
+
+ targetProperty.BindingChanging?.Invoke(this, oldBinding, binding);
+
+ binding.Apply(BindingContext, this, targetProperty);
+ }
+
+ bool CanBeSetFromStyle(BindableProperty property)
+ {
+ var context = GetContext(property);
+ if (context == null)
+ return true;
+ if ((context.Attributes & BindableContextAttributes.IsSetFromStyle) == BindableContextAttributes.IsSetFromStyle)
+ return true;
+ if ((context.Attributes & BindableContextAttributes.IsDefaultValue) == BindableContextAttributes.IsDefaultValue)
+ return true;
+ if ((context.Attributes & BindableContextAttributes.IsDefaultValueCreated) == BindableContextAttributes.IsDefaultValueCreated)
+ return true;
+ return false;
+ }
+
+ internal void SetDynamicResource(BindableProperty property, string key)
+ {
+ SetDynamicResource(property, key, false);
+ }
+
+ internal void SetDynamicResource(BindableProperty property, string key, bool fromStyle)
+ {
+ if (property == null)
+ throw new ArgumentNullException(nameof(property));
+ if (string.IsNullOrEmpty(key))
+ throw new ArgumentNullException(nameof(key));
+ if (fromStyle && !CanBeSetFromStyle(property))
+ return;
+
+ var context = GetOrCreateContext(property);
+
+ context.Attributes |= BindableContextAttributes.IsDynamicResource;
+ if (fromStyle)
+ context.Attributes |= BindableContextAttributes.IsSetFromStyle;
+ else
+ context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
+
+ OnSetDynamicResource(property, key);
+ }
+
+ internal void SetValue(BindableProperty property, object value, bool fromStyle)
+ {
+ SetValue(property, value, fromStyle, true);
+ }
+
+ internal void SetValueCore(BindablePropertyKey propertyKey, object value, SetValueFlags attributes = SetValueFlags.None)
+ {
+ SetValueCore(propertyKey.BindableProperty, value, attributes, SetValuePrivateFlags.None, false);
+ }
/// <summary>
/// For internal use.
/// <param name="property">The BindableProperty on which to assign a value.</param>
/// <param name="value">The value to set</param>
/// <param name="attributes">The set value flag</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SetValueCore(BindableProperty property, object value, SetValueFlags attributes = SetValueFlags.None)
- {
- SetValueCore(property, value, attributes, SetValuePrivateFlags.Default);
- }
-
- internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes)
- {
- bool checkAccess = (privateAttributes & SetValuePrivateFlags.CheckAccess) != 0;
- bool manuallySet = (privateAttributes & SetValuePrivateFlags.ManuallySet) != 0;
- bool silent = (privateAttributes & SetValuePrivateFlags.Silent) != 0;
- bool fromStyle = (privateAttributes & SetValuePrivateFlags.FromStyle) != 0;
- bool converted = (privateAttributes & SetValuePrivateFlags.Converted) != 0;
-
- if (property == null)
- throw new ArgumentNullException("property");
- if (checkAccess && property.IsReadOnly)
- {
- Debug.WriteLine("Can not set the BindableProperty \"{0}\" because it is readonly.", property.PropertyName);
- return;
- }
-
- if (!converted && !property.TryConvert(ref value))
- {
- Console.WriteLine("SetValue", "Can not convert {0} to type '{1}'", value, property.ReturnType);
- return;
- }
-
- if (property.ValidateValue != null && !property.ValidateValue(this, value))
- throw new ArgumentException("Value was an invalid value for " + property.PropertyName, "value");
-
- if (property.CoerceValue != null)
- value = property.CoerceValue(this, value);
-
- BindablePropertyContext context = GetOrCreateContext(property);
- if (manuallySet) {
- context.Attributes |= BindableContextAttributes.IsManuallySet;
- context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
- } else
- context.Attributes &= ~BindableContextAttributes.IsManuallySet;
-
- if (fromStyle)
- context.Attributes |= BindableContextAttributes.IsSetFromStyle;
- // else omitted on purpose
-
- bool currentlyApplying = _applying;
-
- if ((context.Attributes & BindableContextAttributes.IsBeingSet) != 0)
- {
- Queue<SetValueArgs> delayQueue = context.DelayedSetters;
- if (delayQueue == null)
- context.DelayedSetters = delayQueue = new Queue<SetValueArgs>();
-
- delayQueue.Enqueue(new SetValueArgs(property, context, value, currentlyApplying, attributes));
- }
- else
- {
- context.Attributes |= BindableContextAttributes.IsBeingSet;
- SetValueActual(property, context, value, currentlyApplying, attributes, silent);
-
- Queue<SetValueArgs> delayQueue = context.DelayedSetters;
- if (delayQueue != null)
- {
- while (delayQueue.Count > 0)
- {
- SetValueArgs s = delayQueue.Dequeue();
- SetValueActual(s.Property, s.Context, s.Value, s.CurrentlyApplying, s.Attributes);
- }
-
- context.DelayedSetters = null;
- }
-
- context.Attributes &= ~BindableContextAttributes.IsBeingSet;
- }
- }
-
- internal void ApplyBindings(bool skipBindingContext, bool fromBindingContextChanged)
- {
- var prop = _properties.ToArray();
- for (int i = 0, propLength = prop.Length; i < propLength; i++) {
- BindablePropertyContext context = prop [i];
- BindingBase binding = context.Binding;
- if (binding == null)
- continue;
-
- if (skipBindingContext && ReferenceEquals(context.Property, BindingContextProperty))
- continue;
-
- binding.Unapply(fromBindingContextChanged: fromBindingContextChanged);
- binding.Apply(BindingContext, this, context.Property, fromBindingContextChanged: fromBindingContextChanged);
- }
- }
-
- static void BindingContextPropertyBindingChanging(BindableObject bindable, BindingBase oldBindingBase, BindingBase newBindingBase)
- {
- object context = bindable._inheritedContext;
- var oldBinding = oldBindingBase as Binding;
- var newBinding = newBindingBase as Binding;
-
- if (context == null && oldBinding != null)
- context = oldBinding.Context;
- if (context != null && newBinding != null)
- newBinding.Context = context;
- }
-
- static void BindingContextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
- {
- bindable._inheritedContext = null;
- bindable.ApplyBindings(skipBindingContext: true, fromBindingContextChanged:true);
- bindable.OnBindingContextChanged();
- }
-
- void ClearValue(BindableProperty property, bool fromStyle, bool checkAccess)
- {
- if (property == null)
- throw new ArgumentNullException(nameof(property));
-
- if (checkAccess && property.IsReadOnly)
- throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
-
- BindablePropertyContext bpcontext = GetContext(property);
- if (bpcontext == null)
- return;
-
- if (fromStyle && !CanBeSetFromStyle(property))
- return;
-
- object original = bpcontext.Value;
-
- object newValue = property.GetDefaultValue(this);
-
- bool same = Equals(original, newValue);
- if (!same)
- {
- property.PropertyChanging?.Invoke(this, original, newValue);
-
- OnPropertyChanging(property.PropertyName);
- }
-
- bpcontext.Attributes &= ~BindableContextAttributes.IsManuallySet;
- bpcontext.Value = newValue;
- if (property.DefaultValueCreator == null)
- bpcontext.Attributes |= BindableContextAttributes.IsDefaultValue;
- else
- bpcontext.Attributes |= BindableContextAttributes.IsDefaultValueCreated;
-
- if (!same)
- {
- OnPropertyChanged(property.PropertyName);
- property.PropertyChanged?.Invoke(this, original, newValue);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- BindablePropertyContext CreateAndAddContext(BindableProperty property)
- {
- var context = new BindablePropertyContext { Property = property, Value = property.DefaultValueCreator != null ? property.DefaultValueCreator(this) : property.DefaultValue };
-
- if (property.DefaultValueCreator == null)
- context.Attributes = BindableContextAttributes.IsDefaultValue;
- else
- context.Attributes = BindableContextAttributes.IsDefaultValueCreated;
-
- _properties.Add(context);
- return context;
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- BindablePropertyContext GetContext(BindableProperty property)
- {
- List<BindablePropertyContext> properties = _properties;
-
- for (var i = 0; i < properties.Count; i++)
- {
- BindablePropertyContext context = properties[i];
- if (ReferenceEquals(context.Property, property))
- return context;
- }
-
- return null;
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- BindablePropertyContext GetOrCreateContext(BindableProperty property)
- {
- BindablePropertyContext context = GetContext(property);
- if (context == null)
- {
- context = CreateAndAddContext(property);
- }
-
- return context;
- }
-
- void RemoveBinding(BindableProperty property, BindablePropertyContext context)
- {
- context.Binding.Unapply();
-
- property.BindingChanging?.Invoke(this, context.Binding, null);
-
- context.Binding = null;
- }
-
- void SetValue(BindableProperty property, object value, bool fromStyle, bool checkAccess)
- {
- if (property == null)
- throw new ArgumentNullException("property");
-
- if (checkAccess && property.IsReadOnly)
- throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
-
- if (fromStyle && !CanBeSetFromStyle(property))
- return;
-
- SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource,
- (fromStyle ? SetValuePrivateFlags.FromStyle : SetValuePrivateFlags.ManuallySet) | (checkAccess ? SetValuePrivateFlags.CheckAccess : 0));
- }
-
- void SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent = false)
- {
- object original = context.Value;
- bool raiseOnEqual = (attributes & SetValueFlags.RaiseOnEqual) != 0;
- bool clearDynamicResources = (attributes & SetValueFlags.ClearDynamicResource) != 0;
- bool clearOneWayBindings = (attributes & SetValueFlags.ClearOneWayBindings) != 0;
- bool clearTwoWayBindings = (attributes & SetValueFlags.ClearTwoWayBindings) != 0;
-
- bool same = ReferenceEquals(context.Property, BindingContextProperty) ? ReferenceEquals(value, original) : Equals(value, original);
- if (!silent && (!same || raiseOnEqual))
- {
- property.PropertyChanging?.Invoke(this, original, value);
-
- OnPropertyChanging(property.PropertyName);
- }
-
- if (!same || raiseOnEqual)
- {
- context.Value = value;
- }
-
- context.Attributes &= ~BindableContextAttributes.IsDefaultValue;
- context.Attributes &= ~BindableContextAttributes.IsDefaultValueCreated;
-
- if ((context.Attributes & BindableContextAttributes.IsDynamicResource) != 0 && clearDynamicResources)
- RemoveDynamicResource(property);
-
- BindingBase binding = context.Binding;
- if (binding != null)
- {
- if (clearOneWayBindings && binding.GetRealizedMode(property) == BindingMode.OneWay || clearTwoWayBindings && binding.GetRealizedMode(property) == BindingMode.TwoWay)
- {
- RemoveBinding(property, context);
- binding = null;
- }
- }
-
- if (!silent && (!same || raiseOnEqual))
- {
- if (binding != null && !currentlyApplying)
- {
- _applying = true;
- binding.Apply(true);
- _applying = false;
- }
-
- OnPropertyChanged(property.PropertyName);
-
- property.PropertyChanged?.Invoke(this, original, value);
- }
- }
-
- [Flags]
- enum BindableContextAttributes
- {
- IsManuallySet = 1 << 0,
- IsBeingSet = 1 << 1,
- IsDynamicResource = 1 << 2,
- IsSetFromStyle = 1 << 3,
- IsDefaultValue = 1 << 4,
- IsDefaultValueCreated = 1 << 5,
- }
-
- class BindablePropertyContext
- {
- public BindableContextAttributes Attributes;
- public BindingBase Binding;
- public Queue<SetValueArgs> DelayedSetters;
- public BindableProperty Property;
- public object Value;
- }
-
- [Flags]
- internal enum SetValuePrivateFlags
- {
- None = 0,
- CheckAccess = 1 << 0,
- Silent = 1 << 1,
- ManuallySet = 1 << 2,
- FromStyle = 1 << 3,
- Converted = 1 << 4,
- Default = CheckAccess
- }
-
- class SetValueArgs
- {
- public readonly SetValueFlags Attributes;
- public readonly BindablePropertyContext Context;
- public readonly bool CurrentlyApplying;
- public readonly BindableProperty Property;
- public readonly object Value;
-
- public SetValueArgs(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes)
- {
- Property = property;
- Context = context;
- Value = value;
- CurrentlyApplying = currentlyApplying;
- Attributes = attributes;
- }
- }
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes = SetValueFlags.None)
+ {
+ SetValueCore(property, value, attributes, SetValuePrivateFlags.Default, false);
+ }
+
+ internal void SetValueCore(BindableProperty property, object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, bool forceSendChangeSignal)
+ {
+ bool checkAccess = (privateAttributes & SetValuePrivateFlags.CheckAccess) != 0;
+ bool manuallySet = (privateAttributes & SetValuePrivateFlags.ManuallySet) != 0;
+ bool silent = (privateAttributes & SetValuePrivateFlags.Silent) != 0;
+ bool fromStyle = (privateAttributes & SetValuePrivateFlags.FromStyle) != 0;
+ bool converted = (privateAttributes & SetValuePrivateFlags.Converted) != 0;
+
+ if (property == null)
+ throw new ArgumentNullException("property");
+ if (checkAccess && property.IsReadOnly)
+ {
+ Debug.WriteLine("Can not set the BindableProperty \"{0}\" because it is readonly.", property.PropertyName);
+ return;
+ }
+
+ if (!converted && !property.TryConvert(ref value))
+ {
+ Console.WriteLine("SetValue", "Can not convert {0} to type '{1}'", value, property.ReturnType);
+ return;
+ }
+
+ if (property.ValidateValue != null && !property.ValidateValue(this, value))
+ throw new ArgumentException("Value was an invalid value for " + property.PropertyName, "value");
+
+ if (property.CoerceValue != null)
+ value = property.CoerceValue(this, value);
+
+ BindablePropertyContext context = GetOrCreateContext(property);
+ if (manuallySet) {
+ context.Attributes |= BindableContextAttributes.IsManuallySet;
+ context.Attributes &= ~BindableContextAttributes.IsSetFromStyle;
+ } else
+ context.Attributes &= ~BindableContextAttributes.IsManuallySet;
+
+ if (fromStyle)
+ context.Attributes |= BindableContextAttributes.IsSetFromStyle;
+ // else omitted on purpose
+
+ bool currentlyApplying = _applying;
+
+ if ((context.Attributes & BindableContextAttributes.IsBeingSet) != 0)
+ {
+ Queue<SetValueArgs> delayQueue = context.DelayedSetters;
+ if (delayQueue == null)
+ context.DelayedSetters = delayQueue = new Queue<SetValueArgs>();
+
+ delayQueue.Enqueue(new SetValueArgs(property, context, value, currentlyApplying, attributes));
+ }
+ else
+ {
+ context.Attributes |= BindableContextAttributes.IsBeingSet;
+ SetValueActual(property, context, value, currentlyApplying, forceSendChangeSignal, attributes, silent);
+
+ Queue<SetValueArgs> delayQueue = context.DelayedSetters;
+ if (delayQueue != null)
+ {
+ while (delayQueue.Count > 0)
+ {
+ SetValueArgs s = delayQueue.Dequeue();
+ SetValueActual(s.Property, s.Context, s.Value, s.CurrentlyApplying, forceSendChangeSignal, s.Attributes);
+ }
+
+ context.DelayedSetters = null;
+ }
+
+ context.Attributes &= ~BindableContextAttributes.IsBeingSet;
+ }
+ }
+
+ internal void ApplyBindings(bool skipBindingContext, bool fromBindingContextChanged)
+ {
+ var prop = _properties.ToArray();
+ for (int i = 0, propLength = prop.Length; i < propLength; i++) {
+ BindablePropertyContext context = prop [i];
+ BindingBase binding = context.Binding;
+ if (binding == null)
+ continue;
+
+ if (skipBindingContext && ReferenceEquals(context.Property, BindingContextProperty))
+ continue;
+
+ binding.Unapply(fromBindingContextChanged: fromBindingContextChanged);
+ binding.Apply(BindingContext, this, context.Property, fromBindingContextChanged: fromBindingContextChanged);
+ }
+ }
+
+ static void BindingContextPropertyBindingChanging(BindableObject bindable, BindingBase oldBindingBase, BindingBase newBindingBase)
+ {
+ object context = bindable._inheritedContext;
+ var oldBinding = oldBindingBase as Binding;
+ var newBinding = newBindingBase as Binding;
+
+ if (context == null && oldBinding != null)
+ context = oldBinding.Context;
+ if (context != null && newBinding != null)
+ newBinding.Context = context;
+ }
+
+ static void BindingContextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
+ {
+ bindable._inheritedContext = null;
+ bindable.ApplyBindings(skipBindingContext: true, fromBindingContextChanged:true);
+ bindable.OnBindingContextChanged();
+ }
+
+ void ClearValue(BindableProperty property, bool fromStyle, bool checkAccess)
+ {
+ if (property == null)
+ throw new ArgumentNullException(nameof(property));
+
+ if (checkAccess && property.IsReadOnly)
+ throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
+
+ BindablePropertyContext bpcontext = GetContext(property);
+ if (bpcontext == null)
+ return;
+
+ if (fromStyle && !CanBeSetFromStyle(property))
+ return;
+
+ object original = bpcontext.Value;
+
+ object newValue = property.GetDefaultValue(this);
+
+ bool same = Equals(original, newValue);
+ if (!same)
+ {
+ property.PropertyChanging?.Invoke(this, original, newValue);
+
+ OnPropertyChanging(property.PropertyName);
+ }
+
+ bpcontext.Attributes &= ~BindableContextAttributes.IsManuallySet;
+ bpcontext.Value = newValue;
+ if (property.DefaultValueCreator == null)
+ bpcontext.Attributes |= BindableContextAttributes.IsDefaultValue;
+ else
+ bpcontext.Attributes |= BindableContextAttributes.IsDefaultValueCreated;
+
+ if (!same)
+ {
+ OnPropertyChanged(property.PropertyName);
+ property.PropertyChanged?.Invoke(this, original, newValue);
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ BindablePropertyContext CreateAndAddContext(BindableProperty property)
+ {
+ var context = new BindablePropertyContext { Property = property, Value = property.DefaultValueCreator != null ? property.DefaultValueCreator(this) : property.DefaultValue };
+
+ if (property.DefaultValueCreator == null)
+ context.Attributes = BindableContextAttributes.IsDefaultValue;
+ else
+ context.Attributes = BindableContextAttributes.IsDefaultValueCreated;
+
+ _properties.Add(context);
+ return context;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ BindablePropertyContext GetContext(BindableProperty property)
+ {
+ List<BindablePropertyContext> properties = _properties;
+
+ for (var i = 0; i < properties.Count; i++)
+ {
+ BindablePropertyContext context = properties[i];
+ if (ReferenceEquals(context.Property, property))
+ return context;
+ }
+
+ return null;
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ BindablePropertyContext GetOrCreateContext(BindableProperty property)
+ {
+ BindablePropertyContext context = GetContext(property);
+ if (context == null)
+ {
+ context = CreateAndAddContext(property);
+ }
+ else if (property.DefaultValueCreator != null )
+ {
+ context.Value = property.DefaultValueCreator(this); //Update Value from dali
+ }//added by xb.teng
+
+ return context;
+ }
+
+ void RemoveBinding(BindableProperty property, BindablePropertyContext context)
+ {
+ context.Binding.Unapply();
+
+ property.BindingChanging?.Invoke(this, context.Binding, null);
+
+ context.Binding = null;
+ }
+
+ void SetValue(BindableProperty property, object value, bool fromStyle, bool checkAccess)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
+
+ if (checkAccess && property.IsReadOnly)
+ throw new InvalidOperationException(string.Format("The BindableProperty \"{0}\" is readonly.", property.PropertyName));
+
+ if (fromStyle && !CanBeSetFromStyle(property))
+ return;
+
+ SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearDynamicResource,
+ (fromStyle ? SetValuePrivateFlags.FromStyle : SetValuePrivateFlags.ManuallySet) | (checkAccess ? SetValuePrivateFlags.CheckAccess : 0),
+ false);
+ }
+
+ void SetValueActual(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, bool forceSendChangeSignal, SetValueFlags attributes, bool silent = false)
+ {
+ object original = context.Value;
+ bool raiseOnEqual = (attributes & SetValueFlags.RaiseOnEqual) != 0;
+ bool clearDynamicResources = (attributes & SetValueFlags.ClearDynamicResource) != 0;
+ bool clearOneWayBindings = (attributes & SetValueFlags.ClearOneWayBindings) != 0;
+ bool clearTwoWayBindings = (attributes & SetValueFlags.ClearTwoWayBindings) != 0;
+
+ bool same = ReferenceEquals(context.Property, BindingContextProperty) ? ReferenceEquals(value, original) : Equals(value, original);
+ if (!silent && (!same || raiseOnEqual))
+ {
+ property.PropertyChanging?.Invoke(this, original, value);
+
+ OnPropertyChanging(property.PropertyName);
+ }
+
+ if (!same || raiseOnEqual)
+ {
+ context.Value = value;
+ }
+
+ context.Attributes &= ~BindableContextAttributes.IsDefaultValue;
+ context.Attributes &= ~BindableContextAttributes.IsDefaultValueCreated;
+
+ if ((context.Attributes & BindableContextAttributes.IsDynamicResource) != 0 && clearDynamicResources)
+ RemoveDynamicResource(property);
+
+ BindingBase binding = context.Binding;
+ if (binding != null)
+ {
+ if (clearOneWayBindings && binding.GetRealizedMode(property) == BindingMode.OneWay || clearTwoWayBindings && binding.GetRealizedMode(property) == BindingMode.TwoWay)
+ {
+ RemoveBinding(property, context);
+ binding = null;
+ }
+ }
+
+ if (!silent)
+ {
+ if ((!same || raiseOnEqual))
+ {
+ property.PropertyChanged?.Invoke(this, original, value);
+
+ if (binding != null && !currentlyApplying)
+ {
+ _applying = true;
+ binding.Apply(true);
+ _applying = false;
+ }
+
+ OnPropertyChanged(property.PropertyName);
+ }
+ else if (true == same && true == forceSendChangeSignal)
+ {
+ if (binding != null && !currentlyApplying)
+ {
+ _applying = true;
+ binding.Apply(true);
+ _applying = false;
+ }
+
+ OnPropertyChanged(property.PropertyName);
+ }
+ }
+ }
+
+ [Flags]
+ enum BindableContextAttributes
+ {
+ IsManuallySet = 1 << 0,
+ IsBeingSet = 1 << 1,
+ IsDynamicResource = 1 << 2,
+ IsSetFromStyle = 1 << 3,
+ IsDefaultValue = 1 << 4,
+ IsDefaultValueCreated = 1 << 5,
+ }
+
+ class BindablePropertyContext
+ {
+ public BindableContextAttributes Attributes;
+ public BindingBase Binding;
+ public Queue<SetValueArgs> DelayedSetters;
+ public BindableProperty Property;
+ public object Value;
+ }
+
+ [Flags]
+ internal enum SetValuePrivateFlags
+ {
+ None = 0,
+ CheckAccess = 1 << 0,
+ Silent = 1 << 1,
+ ManuallySet = 1 << 2,
+ FromStyle = 1 << 3,
+ Converted = 1 << 4,
+ Default = CheckAccess
+ }
+
+ class SetValueArgs
+ {
+ public readonly SetValueFlags Attributes;
+ public readonly BindablePropertyContext Context;
+ public readonly bool CurrentlyApplying;
+ public readonly BindableProperty Property;
+ public readonly object Value;
+
+ public SetValueArgs(BindableProperty property, BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes)
+ {
+ Property = property;
+ Context = context;
+ Value = value;
+ CurrentlyApplying = currentlyApplying;
+ Attributes = attributes;
+ }
+ }
+ }
}
-namespace Tizen.NUI.Internals
+namespace Tizen.NUI.Binding.Internals
{
/// <summary>
/// SetValueFlags. For internal use.
/// </summary>
- [Flags]
- [EditorBrowsable(EditorBrowsableState.Never)]
- public enum SetValueFlags
- {
+ [Flags]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum SetValueFlags
+ {
/// <summary>
/// None.
/// </summary>
- None = 0,
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ None = 0,
/// <summary>
/// Clear OneWay bindings.
/// </summary>
- ClearOneWayBindings = 1 << 0,
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ ClearOneWayBindings = 1 << 0,
/// <summary>
/// Clear TwoWay bindings.
/// </summary>
- ClearTwoWayBindings = 1 << 1,
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ ClearTwoWayBindings = 1 << 1,
/// <summary>
/// Clear dynamic resource.
/// </summary>
- ClearDynamicResource = 1 << 2,
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ ClearDynamicResource = 1 << 2,
/// <summary>
/// Raise or equal.
/// </summary>
- RaiseOnEqual = 1 << 3
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ RaiseOnEqual = 1 << 3
+ }
}
\ No newline at end of file
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq.Expressions;
-using System.Reflection;
-using System.ComponentModel;
-using Tizen.NUI.Internals;
-using Tizen.NUI.Xaml;
-
-namespace Tizen.NUI.Binding
-{
- /// <summary>
- /// A BindableProperty is a backing store for properties allowing bindings on BindableObject.
- /// </summary>
- [DebuggerDisplay("{PropertyName}")]
- [TypeConverter(typeof(BindablePropertyConverter))]
- [EditorBrowsable(EditorBrowsableState.Never)]
- public sealed class BindableProperty
- {
- /// <summary>
- /// Delegate for BindableProperty.PropertyChanged.
- /// </summary>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <param name="oldValue">The old property value.</param>
- /// <param name="newValue">The new property value.</param>
- public delegate void BindingPropertyChangedDelegate(BindableObject bindable, object oldValue, object newValue);
-
- /// <summary>
- /// Strongly-typed delegate for BindableProperty.PropertyChanged.
- /// </summary>
- /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <param name="oldValue">The old property value.</param>
- /// <param name="newValue">The new property value.</param>
- public delegate void BindingPropertyChangedDelegate<in TPropertyType>(BindableObject bindable, TPropertyType oldValue, TPropertyType newValue);
-
- /// <summary>
- /// Delegate for BindableProperty.PropertyChanging.
- /// </summary>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <param name="oldValue">The old property value.</param>
- /// <param name="newValue">The new property value.</param>
- public delegate void BindingPropertyChangingDelegate(BindableObject bindable, object oldValue, object newValue);
-
- /// <summary>
- /// Strongly-typed delegate for BindableProperty.PropertyChanging.
- /// </summary>
- /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <param name="oldValue">The old property value.</param>
- /// <param name="newValue">The new property value.</param>
- public delegate void BindingPropertyChangingDelegate<in TPropertyType>(BindableObject bindable, TPropertyType oldValue, TPropertyType newValue);
-
- /// <summary>
- /// Delegate for BindableProperty.CoerceValue.
- /// </summary>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <param name="value">The value to coerce.</param>
- /// <returns>System.Object</returns>
- public delegate object CoerceValueDelegate(BindableObject bindable, object value);
-
- /// <summary>
- /// Strongly-typed delegate for BindableProperty.CoerceValue.
- /// </summary>
- /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <param name="value">The value to coerce.</param>
- /// <returns>TPropertyType</returns>
- public delegate TPropertyType CoerceValueDelegate<TPropertyType>(BindableObject bindable, TPropertyType value);
-
- /// <summary>
- /// Delegate for BindableProperty.DefaultValueCreator.
- /// </summary>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <returns>System.Object</returns>
- public delegate object CreateDefaultValueDelegate(BindableObject bindable);
-
- /// <summary>
- /// Strongly-typed delegate for BindableProperty.DefaultValueCreator.
- /// </summary>
- /// <typeparam name="TDeclarer">The type of the object that delared the property.</typeparam>
- /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <returns>TPropertyType</returns>
- public delegate TPropertyType CreateDefaultValueDelegate<in TDeclarer, out TPropertyType>(TDeclarer bindable);
-
- /// <summary>
- /// Delegate for BindableProperty.ValidateValue.
- /// </summary>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <param name="value">The default value.</param>
- /// <returns>System.Boolean</returns>
- public delegate bool ValidateValueDelegate(BindableObject bindable, object value);
-
- /// <summary>
- /// Strongly-typed delegate for BindableProperty.ValidateValue.
- /// </summary>
- /// <typeparam name="TPropertyType">The type of the bound property.</typeparam>
- /// <param name="bindable">The bindable object that contains the property.</param>
- /// <param name="value">The default value.</param>
- /// <returns>System.Boolean</returns>
- public delegate bool ValidateValueDelegate<in TPropertyType>(BindableObject bindable, TPropertyType value);
-
- static readonly Dictionary<Type, TypeConverter> WellKnownConvertTypes = new Dictionary<Type,TypeConverter>
- {
- { typeof(Uri), new UriTypeConverter() },
- { typeof(Color), new ColorTypeConverter() },
- };
-
- // more or less the encoding of this, without the need to reflect
- // http://msdn.microsoft.com/en-us/library/y5b434w4.aspx
- static readonly Dictionary<Type, Type[]> SimpleConvertTypes = new Dictionary<Type, Type[]>
- {
- { typeof(sbyte), new[] { typeof(string), typeof(short), typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal) } },
- { typeof(byte), new[] { typeof(string), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(ulong), typeof(float), typeof(double), typeof(decimal) } },
- { typeof(short), new[] { typeof(string), typeof(int), typeof(long), typeof(float), typeof(double), typeof(decimal) } },
- { typeof(ushort), new[] { typeof(string), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal) } },
- { typeof(int), new[] { typeof(string), typeof(long), typeof(float), typeof(double), typeof(decimal) } },
- { typeof(uint), new[] { typeof(string), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal) } },
- { typeof(long), new[] { typeof(string), typeof(float), typeof(double), typeof(decimal) } },
- { typeof(char), new[] { typeof(string), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal) } },
- { typeof(float), new[] { typeof(string), typeof(double) } },
- { typeof(ulong), new[] { typeof(string), typeof(float), typeof(double), typeof(decimal) } }
- };
-
- BindableProperty(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode = BindingMode.OneWay,
- ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
- CoerceValueDelegate coerceValue = null, BindablePropertyBindingChanging bindingChanging = null, bool isReadOnly = false, CreateDefaultValueDelegate defaultValueCreator = null)
- {
- if (propertyName == null)
- throw new ArgumentNullException("propertyName");
- if (ReferenceEquals(returnType, null))
- throw new ArgumentNullException("returnType");
- if (ReferenceEquals(declaringType, null))
- throw new ArgumentNullException("declaringType");
-
- // don't use Enum.IsDefined as its redonkulously expensive for what it does
- if (defaultBindingMode != BindingMode.Default && defaultBindingMode != BindingMode.OneWay && defaultBindingMode != BindingMode.OneWayToSource && defaultBindingMode != BindingMode.TwoWay && defaultBindingMode != BindingMode.OneTime)
- throw new ArgumentException("Not a valid type of BindingMode", "defaultBindingMode");
- if (defaultValue == null && Nullable.GetUnderlyingType(returnType) == null && returnType.GetTypeInfo().IsValueType)
- throw new ArgumentException("Not a valid default value", "defaultValue");
- if (defaultValue != null && !returnType.IsInstanceOfType(defaultValue))
- throw new ArgumentException("Default value did not match return type", "defaultValue");
- if (defaultBindingMode == BindingMode.Default)
- defaultBindingMode = BindingMode.OneWay;
-
- PropertyName = propertyName;
- ReturnType = returnType;
- ReturnTypeInfo = returnType.GetTypeInfo();
- DeclaringType = declaringType;
- DefaultValue = defaultValue;
- DefaultBindingMode = defaultBindingMode;
- PropertyChanged = propertyChanged;
- PropertyChanging = propertyChanging;
- ValidateValue = validateValue;
- CoerceValue = coerceValue;
- BindingChanging = bindingChanging;
- IsReadOnly = isReadOnly;
- DefaultValueCreator = defaultValueCreator;
- }
-
- /// <summary>
- /// Gets the type declaring the BindableProperty.
- /// </summary>
- public Type DeclaringType { get; private set; }
-
- /// <summary>
- /// Gets the default BindingMode.
- /// </summary>
- public BindingMode DefaultBindingMode { get; private set; }
-
- /// <summary>
- /// Gets the default value for the BindableProperty.
- /// </summary>
- public object DefaultValue { get; }
-
- /// <summary>
- /// Gets a value indicating if the BindableProperty is created form a BindablePropertyKey.
- /// </summary>
- public bool IsReadOnly { get; private set; }
-
- /// <summary>
- /// Gets the property name.
- /// </summary>
- public string PropertyName { get; }
-
- /// <summary>
- /// Gets the type of the BindableProperty.
- /// </summary>
- public Type ReturnType { get; }
-
- internal BindablePropertyBindingChanging BindingChanging { get; private set; }
-
- internal CoerceValueDelegate CoerceValue { get; private set; }
-
- internal CreateDefaultValueDelegate DefaultValueCreator { get; }
-
- internal BindingPropertyChangedDelegate PropertyChanged { get; private set; }
-
- internal BindingPropertyChangingDelegate PropertyChanging { get; private set; }
-
- internal System.Reflection.TypeInfo ReturnTypeInfo { get; }
-
- internal ValidateValueDelegate ValidateValue { get; private set; }
-
- /// <summary>
- /// Deprecated. Do not use.
- /// </summary>
- /// <typeparam name="TDeclarer">The type of the declaring object.</typeparam>
- /// <typeparam name="TPropertyType">The type of the property.</typeparam>
- /// <param name="getter">An expression identifying the getter for the property using this BindableProperty as backing store.</param>
- /// <param name="defaultValue">The default value for the property.</param>
- /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
- /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
- /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
- /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
- /// <returns>A newly created BindableProperty.</returns>
- [Obsolete("Create<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
- public static BindableProperty Create<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>> getter, TPropertyType defaultValue, BindingMode defaultBindingMode = BindingMode.OneWay,
- ValidateValueDelegate<TPropertyType> validateValue = null, BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null,
- BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null, CoerceValueDelegate<TPropertyType> coerceValue = null,
- CreateDefaultValueDelegate<TDeclarer, TPropertyType> defaultValueCreator = null) where TDeclarer : BindableObject
- {
- return Create(getter, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, defaultValueCreator: defaultValueCreator);
- }
-
- /// <summary>
- /// Creates a new instance of the BindableProperty class.
- /// </summary>
- /// <param name="propertyName">The name of the BindableProperty.</param>
- /// <param name="returnType">The type of the property.</param>
- /// <param name="declaringType">The type of the declaring object.</param>
- /// <param name="defaultValue">The default value for the property.</param>
- /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
- /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
- /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
- /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
- /// <returns>A newly created BindableProperty.</returns>
- public static BindableProperty Create(string propertyName, Type returnType, Type declaringType, object defaultValue = null, BindingMode defaultBindingMode = BindingMode.OneWay,
- ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
- CoerceValueDelegate coerceValue = null, CreateDefaultValueDelegate defaultValueCreator = null)
- {
- return new BindableProperty(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue,
- defaultValueCreator: defaultValueCreator);
- }
-
- /// <summary>
- /// Deprecated. Do not use.
- /// </summary>
- /// <typeparam name="TDeclarer">The type of the declaring object.</typeparam>
- /// <typeparam name="TPropertyType">The type of the property.</typeparam>
- /// <param name="staticgetter">An expression identifying a static method returning the value of the property using this BindableProperty as backing store.</param>
- /// <param name="defaultValue">The default value for the property.</param>
- /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
- /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
- /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
- /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
- [Obsolete("CreateAttached<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
- public static BindableProperty CreateAttached<TDeclarer, TPropertyType>(Expression<Func<BindableObject, TPropertyType>> staticgetter, TPropertyType defaultValue,
- BindingMode defaultBindingMode = BindingMode.OneWay, ValidateValueDelegate<TPropertyType> validateValue = null, BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null,
- BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null, CoerceValueDelegate<TPropertyType> coerceValue = null,
- CreateDefaultValueDelegate<BindableObject, TPropertyType> defaultValueCreator = null)
- {
- return CreateAttached<TDeclarer, TPropertyType>(staticgetter, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null,
- defaultValueCreator: defaultValueCreator);
- }
-
- /// <summary>
- /// Creates a new instance of the BindableProperty class for an attached property.
- /// </summary>
- /// <param name="propertyName">The name of the BindableProperty.</param>
- /// <param name="returnType">The type of the property.</param>
- /// <param name="declaringType">The type of the declaring object.</param>
- /// <param name="defaultValue">The default value for the property.</param>
- /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
- /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
- /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
- /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
- /// <returns>A newly created BindableProperty.</returns>
- public static BindableProperty CreateAttached(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode = BindingMode.OneWay,
- ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
- CoerceValueDelegate coerceValue = null, CreateDefaultValueDelegate defaultValueCreator = null)
- {
- return CreateAttached(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, false, defaultValueCreator);
- }
-
- /// <summary>
- /// Deprecated. Do not use.
- /// </summary>
- /// <typeparam name="TDeclarer">The type of the declaring object.</typeparam>
- /// <typeparam name="TPropertyType">The type of the property.</typeparam>
- /// <param name="staticgetter">An expression identifying a static method returning the value of the property using this BindableProperty as backing store.</param>
- /// <param name="defaultValue">The default value for the property.</param>
- /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
- /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
- /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
- /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
- /// <returns>A newly created attached read-only BindablePropertyKey.</returns>
- [Obsolete("CreateAttachedReadOnly<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
- public static BindablePropertyKey CreateAttachedReadOnly<TDeclarer, TPropertyType>(Expression<Func<BindableObject, TPropertyType>> staticgetter, TPropertyType defaultValue,
- BindingMode defaultBindingMode = BindingMode.OneWayToSource, ValidateValueDelegate<TPropertyType> validateValue = null,
- BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null, BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null,
- CoerceValueDelegate<TPropertyType> coerceValue = null, CreateDefaultValueDelegate<BindableObject, TPropertyType> defaultValueCreator = null)
-
- {
- return
- new BindablePropertyKey(CreateAttached<TDeclarer, TPropertyType>(staticgetter, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, true,
- defaultValueCreator));
- }
-
- /// <summary>
- /// Creates a new instance of the BindableProperty class for attached read-only properties.
- /// </summary>
- /// <param name="propertyName">The name of the BindableProperty.</param>
- /// <param name="returnType">The type of the property.</param>
- /// <param name="declaringType">The type of the declaring object.</param>
- /// <param name="defaultValue">The default value for the property.</param>
- /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
- /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
- /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
- /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
- /// <returns>A newly created attached read-only BindablePropertyKey.</returns>
- public static BindablePropertyKey CreateAttachedReadOnly(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode = BindingMode.OneWayToSource,
- ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
- CoerceValueDelegate coerceValue = null, CreateDefaultValueDelegate defaultValueCreator = null)
- {
- return
- new BindablePropertyKey(CreateAttached(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, true,
- defaultValueCreator));
- }
-
- /// <summary>
- /// Deprecated. Do not use.
- /// </summary>
- /// <typeparam name="TDeclarer">The type of the declaring object.</typeparam>
- /// <typeparam name="TPropertyType">The type of the property.</typeparam>
- /// <param name="getter">An expression identifying the getter for the property using this BindableProperty as backing store.</param>
- /// <param name="defaultValue">The default value for the property.</param>
- /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
- /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
- /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
- /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
- /// <returns>A newly created BindablePropertyKey.</returns>
- [Obsolete("CreateReadOnly<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
- public static BindablePropertyKey CreateReadOnly<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>> getter, TPropertyType defaultValue,
- BindingMode defaultBindingMode = BindingMode.OneWayToSource, ValidateValueDelegate<TPropertyType> validateValue = null,
- BindingPropertyChangedDelegate<TPropertyType> propertyChanged = null, BindingPropertyChangingDelegate<TPropertyType> propertyChanging = null,
- CoerceValueDelegate<TPropertyType> coerceValue = null, CreateDefaultValueDelegate<TDeclarer, TPropertyType> defaultValueCreator = null) where TDeclarer : BindableObject
- {
- return new BindablePropertyKey(Create(getter, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, null, true, defaultValueCreator));
- }
-
- /// <summary>
- /// Creates a new instance of the BindablePropertyKey class.
- /// </summary>
- /// <param name="propertyName">The name of the BindableProperty.</param>
- /// <param name="returnType">The type of the property.</param>
- /// <param name="declaringType">The type of the declaring object.</param>
- /// <param name="defaultValue">The default value for the property.</param>
- /// <param name="defaultBindingMode">The BindingMode to use on SetBinding() if no BindingMode is given. This parameter is optional. Default is BindingMode.OneWay.</param>
- /// <param name="validateValue">A delegate to be run when a value is set. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanged">A delegate to be run when the value has changed. This parameter is optional. Default is null.</param>
- /// <param name="propertyChanging">A delegate to be run when the value will change. This parameter is optional. Default is null.</param>
- /// <param name="coerceValue">A delegate used to coerce the range of a value. This parameter is optional. Default is null.</param>
- /// <param name="defaultValueCreator">A Func used to initialize default value for reference types.</param>
- /// <returns>A newly created BindablePropertyKey.</returns>
- public static BindablePropertyKey CreateReadOnly(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode = BindingMode.OneWayToSource,
- ValidateValueDelegate validateValue = null, BindingPropertyChangedDelegate propertyChanged = null, BindingPropertyChangingDelegate propertyChanging = null,
- CoerceValueDelegate coerceValue = null, CreateDefaultValueDelegate defaultValueCreator = null)
- {
- return
- new BindablePropertyKey(new BindableProperty(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue,
- isReadOnly: true, defaultValueCreator: defaultValueCreator));
- }
-
- [Obsolete("Create<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
- internal static BindableProperty Create<TDeclarer, TPropertyType>(Expression<Func<TDeclarer, TPropertyType>> getter, TPropertyType defaultValue, BindingMode defaultBindingMode,
- ValidateValueDelegate<TPropertyType> validateValue, BindingPropertyChangedDelegate<TPropertyType> propertyChanged, BindingPropertyChangingDelegate<TPropertyType> propertyChanging,
- CoerceValueDelegate<TPropertyType> coerceValue, BindablePropertyBindingChanging bindingChanging, bool isReadOnly = false,
- CreateDefaultValueDelegate<TDeclarer, TPropertyType> defaultValueCreator = null) where TDeclarer : BindableObject
- {
- if (getter == null)
- throw new ArgumentNullException("getter");
-
- Expression expr = getter.Body;
-
- var unary = expr as UnaryExpression;
- if (unary != null)
- expr = unary.Operand;
-
- var member = expr as MemberExpression;
- if (member == null)
- throw new ArgumentException("getter must be a MemberExpression", "getter");
-
- var property = (PropertyInfo)member.Member;
-
- ValidateValueDelegate untypedValidateValue = null;
- BindingPropertyChangedDelegate untypedBindingPropertyChanged = null;
- BindingPropertyChangingDelegate untypedBindingPropertyChanging = null;
- CoerceValueDelegate untypedCoerceValue = null;
- CreateDefaultValueDelegate untypedDefaultValueCreator = null;
- if (validateValue != null)
- untypedValidateValue = (bindable, value) => validateValue(bindable, (TPropertyType)value);
- if (propertyChanged != null)
- untypedBindingPropertyChanged = (bindable, oldValue, newValue) => propertyChanged(bindable, (TPropertyType)oldValue, (TPropertyType)newValue);
- if (propertyChanging != null)
- untypedBindingPropertyChanging = (bindable, oldValue, newValue) => propertyChanging(bindable, (TPropertyType)oldValue, (TPropertyType)newValue);
- if (coerceValue != null)
- untypedCoerceValue = (bindable, value) => coerceValue(bindable, (TPropertyType)value);
- if (defaultValueCreator != null)
- untypedDefaultValueCreator = o => defaultValueCreator((TDeclarer)o);
-
- return new BindableProperty(property.Name, property.PropertyType, typeof(TDeclarer), defaultValue, defaultBindingMode, untypedValidateValue, untypedBindingPropertyChanged,
- untypedBindingPropertyChanging, untypedCoerceValue, bindingChanging, isReadOnly, untypedDefaultValueCreator);
- }
-
- internal static BindableProperty Create(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode, ValidateValueDelegate validateValue,
- BindingPropertyChangedDelegate propertyChanged, BindingPropertyChangingDelegate propertyChanging, CoerceValueDelegate coerceValue, BindablePropertyBindingChanging bindingChanging,
- CreateDefaultValueDelegate defaultValueCreator = null)
- {
- return new BindableProperty(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, bindingChanging,
- defaultValueCreator: defaultValueCreator);
- }
-
- [Obsolete("CreateAttached<> (generic) is obsolete as of version 2.1.0 and is no longer supported.")]
- internal static BindableProperty CreateAttached<TDeclarer, TPropertyType>(Expression<Func<BindableObject, TPropertyType>> staticgetter, TPropertyType defaultValue, BindingMode defaultBindingMode,
- ValidateValueDelegate<TPropertyType> validateValue, BindingPropertyChangedDelegate<TPropertyType> propertyChanged, BindingPropertyChangingDelegate<TPropertyType> propertyChanging,
- CoerceValueDelegate<TPropertyType> coerceValue, BindablePropertyBindingChanging bindingChanging, bool isReadOnly = false,
- CreateDefaultValueDelegate<BindableObject, TPropertyType> defaultValueCreator = null)
- {
- if (staticgetter == null)
- throw new ArgumentNullException("staticgetter");
-
- Expression expr = staticgetter.Body;
-
- var unary = expr as UnaryExpression;
- if (unary != null)
- expr = unary.Operand;
-
- var methodcall = expr as MethodCallExpression;
- if (methodcall == null)
- throw new ArgumentException("staticgetter must be a MethodCallExpression", "staticgetter");
-
- MethodInfo method = methodcall.Method;
- if (!method.Name.StartsWith("Get", StringComparison.Ordinal))
- throw new ArgumentException("staticgetter name must start with Get", "staticgetter");
-
- string propertyname = method.Name.Substring(3);
-
- ValidateValueDelegate untypedValidateValue = null;
- BindingPropertyChangedDelegate untypedBindingPropertyChanged = null;
- BindingPropertyChangingDelegate untypedBindingPropertyChanging = null;
- CoerceValueDelegate untypedCoerceValue = null;
- CreateDefaultValueDelegate untypedDefaultValueCreator = null;
- if (validateValue != null)
- untypedValidateValue = (bindable, value) => validateValue(bindable, (TPropertyType)value);
- if (propertyChanged != null)
- untypedBindingPropertyChanged = (bindable, oldValue, newValue) => propertyChanged(bindable, (TPropertyType)oldValue, (TPropertyType)newValue);
- if (propertyChanging != null)
- untypedBindingPropertyChanging = (bindable, oldValue, newValue) => propertyChanging(bindable, (TPropertyType)oldValue, (TPropertyType)newValue);
- if (coerceValue != null)
- untypedCoerceValue = (bindable, value) => coerceValue(bindable, (TPropertyType)value);
- if (defaultValueCreator != null)
- untypedDefaultValueCreator = o => defaultValueCreator(o);
-
- return new BindableProperty(propertyname, method.ReturnType, typeof(TDeclarer), defaultValue, defaultBindingMode, untypedValidateValue, untypedBindingPropertyChanged, untypedBindingPropertyChanging,
- untypedCoerceValue, bindingChanging, isReadOnly, untypedDefaultValueCreator);
- }
-
- internal static BindableProperty CreateAttached(string propertyName, Type returnType, Type declaringType, object defaultValue, BindingMode defaultBindingMode, ValidateValueDelegate validateValue,
- BindingPropertyChangedDelegate propertyChanged, BindingPropertyChangingDelegate propertyChanging, CoerceValueDelegate coerceValue, BindablePropertyBindingChanging bindingChanging,
- bool isReadOnly, CreateDefaultValueDelegate defaultValueCreator = null)
- {
- return new BindableProperty(propertyName, returnType, declaringType, defaultValue, defaultBindingMode, validateValue, propertyChanged, propertyChanging, coerceValue, bindingChanging, isReadOnly,
- defaultValueCreator);
- }
-
- internal object GetDefaultValue(BindableObject bindable)
- {
- if (DefaultValueCreator != null)
- return DefaultValueCreator(bindable);
-
- return DefaultValue;
- }
-
- internal bool TryConvert(ref object value)
- {
- if (value == null)
- {
- return !ReturnTypeInfo.IsValueType || ReturnTypeInfo.IsGenericType && ReturnTypeInfo.GetGenericTypeDefinition() == typeof(Nullable<>);
- }
-
- Type valueType = value.GetType();
- Type type = ReturnType;
-
- // Dont support arbitrary IConvertible by limiting which types can use this
- Type[] convertableTo;
- TypeConverter typeConverterTo;
- if (SimpleConvertTypes.TryGetValue(valueType, out convertableTo) && Array.IndexOf(convertableTo, type) != -1)
- {
- value = Convert.ChangeType(value, type);
- }
- else if (WellKnownConvertTypes.TryGetValue(type, out typeConverterTo) && typeConverterTo.CanConvertFrom(valueType))
- {
- value = typeConverterTo.ConvertFromInvariantString(value.ToString());
- }
- else if (!ReturnTypeInfo.IsAssignableFrom(valueType.GetTypeInfo()))
- {
- var cast = type.GetImplicitConversionOperator(fromType: valueType, toType: type)
- ?? valueType.GetImplicitConversionOperator(fromType: valueType, toType: type);
-
- if (cast == null)
- return false;
-
- value = cast.Invoke(null, new[] { value });
- }
-
- return true;
- }
-
- internal delegate void BindablePropertyBindingChanging(BindableObject bindable, BindingBase oldValue, BindingBase newValue);
- }
-}
+++ /dev/null
-using System;
-using System.Collections;
-using System.Runtime.CompilerServices;
-using System.ComponentModel;
-
-namespace Tizen.NUI.Binding
-{
- /// <summary>
- /// An abstract class that provides a BindingMode and a formatting option.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public abstract class BindingBase
- {
- static readonly ConditionalWeakTable<IEnumerable, CollectionSynchronizationContext> SynchronizedCollections = new ConditionalWeakTable<IEnumerable, CollectionSynchronizationContext>();
-
- BindingMode _mode = BindingMode.Default;
- string _stringFormat;
-
- internal BindingBase()
- {
- }
-
- /// <summary>
- /// Gets or sets the mode for this binding.
- /// </summary>
- public BindingMode Mode
- {
- get { return _mode; }
- set
- {
- if ( value != BindingMode.Default
- && value != BindingMode.OneWay
- && value != BindingMode.OneWayToSource
- && value != BindingMode.TwoWay
- && value != BindingMode.OneTime)
- throw new ArgumentException("mode is not a valid BindingMode", "mode");
-
- ThrowIfApplied();
-
- _mode = value;
- }
- }
-
- /// <summary>
- /// Gets or sets the string format for this binding.
- /// </summary>
- public string StringFormat
- {
- get { return _stringFormat; }
- set
- {
- ThrowIfApplied();
-
- _stringFormat = value;
- }
- }
-
- internal bool AllowChaining { get; set; }
-
- internal object Context { get; set; }
-
- internal bool IsApplied { get; private set; }
-
- /// <summary>
- /// Stops synchronization on the collection.
- /// </summary>
- /// <param name="collection">The collection on which to stop synchronization.</param>
- public static void DisableCollectionSynchronization(IEnumerable collection)
- {
- if (collection == null)
- throw new ArgumentNullException(nameof(collection));
-
- SynchronizedCollections.Remove(collection);
- }
-
- internal static void EnableCollectionSynchronization(IEnumerable collection, object context, CollectionSynchronizationCallback callback)
- {
- if (collection == null)
- throw new ArgumentNullException(nameof(collection));
- if (callback == null)
- throw new ArgumentNullException(nameof(callback));
-
- SynchronizedCollections.Add(collection, new CollectionSynchronizationContext(context, callback));
- }
-
- /// <summary>
- /// Throws an InvalidOperationException if the binding has been applied.
- /// </summary>
- protected void ThrowIfApplied()
- {
- if (IsApplied)
- throw new InvalidOperationException("Can not change a binding while it's applied");
- }
-
- internal virtual void Apply(bool fromTarget)
- {
- IsApplied = true;
- }
-
- internal virtual void Apply(object context, BindableObject bindObj, BindableProperty targetProperty, bool fromBindingContextChanged = false)
- {
- IsApplied = true;
- }
-
- internal abstract BindingBase Clone();
-
- internal virtual object GetSourceValue(object value, Type targetPropertyType)
- {
- if (StringFormat != null)
- return string.Format(StringFormat, value);
-
- return value;
- }
-
- internal virtual object GetTargetValue(object value, Type sourcePropertyType)
- {
- return value;
- }
-
- internal static bool TryGetSynchronizedCollection(IEnumerable collection, out CollectionSynchronizationContext synchronizationContext)
- {
- if (collection == null)
- throw new ArgumentNullException(nameof(collection));
-
- return SynchronizedCollections.TryGetValue(collection, out synchronizationContext);
- }
-
- internal virtual void Unapply(bool fromBindingContextChanged = false)
- {
- IsApplied = false;
- }
- }
-}
\ No newline at end of file
namespace Tizen.NUI.Binding
{
- internal sealed class Command<T> : Command
- {
- public Command(Action<T> execute)
- : base(o =>
- {
- if (IsValidParameter(o))
- {
- execute((T)o);
- }
- })
- {
- if (execute == null)
- {
- throw new ArgumentNullException(nameof(execute));
- }
- }
-
- public Command(Action<T> execute, Func<T, bool> canExecute)
- : base(o =>
- {
- if (IsValidParameter(o))
- {
- execute((T)o);
- }
- }, o => IsValidParameter(o) && canExecute((T)o))
- {
- if (execute == null)
- throw new ArgumentNullException(nameof(execute));
- if (canExecute == null)
- throw new ArgumentNullException(nameof(canExecute));
- }
-
- static bool IsValidParameter(object o)
- {
- if (o != null)
- {
- // The parameter isn't null, so we don't have to worry whether null is a valid option
- return o is T;
- }
-
- var t = typeof(T);
-
- // The parameter is null. Is T Nullable?
- if (Nullable.GetUnderlyingType(t) != null)
- {
- return true;
- }
-
- // Not a Nullable, if it's a value type then null is not valid
- return !t.GetTypeInfo().IsValueType;
- }
- }
+ /// 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 sealed class Command<T> : Command
+ {
+ /// 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 Command(Action<T> execute)
+ : base(o =>
+ {
+ if (IsValidParameter(o))
+ {
+ execute((T)o);
+ }
+ })
+ {
+ if (execute == null)
+ {
+ throw new ArgumentNullException(nameof(execute));
+ }
+ }
+
+ /// 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 Command(Action<T> execute, Func<T, bool> canExecute)
+ : base(o =>
+ {
+ if (IsValidParameter(o))
+ {
+ execute((T)o);
+ }
+ }, o => IsValidParameter(o) && canExecute((T)o))
+ {
+ if (execute == null)
+ throw new ArgumentNullException(nameof(execute));
+ if (canExecute == null)
+ throw new ArgumentNullException(nameof(canExecute));
+ }
+
+ static bool IsValidParameter(object o)
+ {
+ if (o != null)
+ {
+ // The parameter isn't null, so we don't have to worry whether null is a valid option
+ return o is T;
+ }
+
+ var t = typeof(T);
+
+ // The parameter is null. Is T Nullable?
+ if (Nullable.GetUnderlyingType(t) != null)
+ {
+ return true;
+ }
+
+ // Not a Nullable, if it's a value type then null is not valid
+ return !t.GetTypeInfo().IsValueType;
+ }
+ }
/// <summary>
/// Defines an ICommand implementation that wraps a Action.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public class Command : ICommand
- {
- readonly Func<object, bool> _canExecute;
- readonly Action<object> _execute;
+ {
+ readonly Func<object, bool> _canExecute;
+ readonly Action<object> _execute;
/// <summary>
/// Initializes a new instance of the Command class.
/// </summary>
/// <param name="execute">An instance to execute when the Command is executed.</param>
- public Command(Action<object> execute)
- {
- if (execute == null)
- throw new ArgumentNullException(nameof(execute));
+ /// 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 Command(Action<object> execute)
+ {
+ if (execute == null)
+ throw new ArgumentNullException(nameof(execute));
- _execute = execute;
- }
+ _execute = execute;
+ }
/// <summary>
/// Initializes a new instance of the Command class.
/// </summary>
/// <param name="execute">An Action to execute when the Command is executed.</param>
- public Command(Action execute) : this(o => execute())
- {
- if (execute == null)
- throw new ArgumentNullException(nameof(execute));
- }
+ /// 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 Command(Action execute) : this(o => execute())
+ {
+ if (execute == null)
+ throw new ArgumentNullException(nameof(execute));
+ }
/// <summary>
/// Initializes a new instance of the Command class.
/// </summary>
/// <param name="execute">An Action to execute when the Command is executed.</param>
/// <param name="canExecute">A instance indicating if the Command can be executed.</param>
- public Command(Action<object> execute, Func<object, bool> canExecute) : this(execute)
- {
- if (canExecute == null)
- throw new ArgumentNullException(nameof(canExecute));
+ /// 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 Command(Action<object> execute, Func<object, bool> canExecute) : this(execute)
+ {
+ if (canExecute == null)
+ throw new ArgumentNullException(nameof(canExecute));
- _canExecute = canExecute;
- }
+ _canExecute = canExecute;
+ }
/// <summary>
/// Initializes a new instance of the Command class.
/// </summary>
/// <param name="execute">An Action to execute when the Command is executed.</param>
/// <param name="canExecute">A instance indicating if the Command can be executed.</param>
- public Command(Action execute, Func<bool> canExecute) : this(o => execute(), o => canExecute())
- {
- if (execute == null)
- throw new ArgumentNullException(nameof(execute));
- if (canExecute == null)
- throw new ArgumentNullException(nameof(canExecute));
- }
+ /// 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 Command(Action execute, Func<bool> canExecute) : this(o => execute(), o => canExecute())
+ {
+ if (execute == null)
+ throw new ArgumentNullException(nameof(execute));
+ if (canExecute == null)
+ throw new ArgumentNullException(nameof(canExecute));
+ }
/// <summary>
/// Returns a Boolean indicating if the Command can be exectued with the given parameter.
/// </summary>
/// <param name="parameter">An Object used as parameter to determine if the Command can be executed.</param>
/// <returns>true if the Command can be executed, false otherwise.</returns>
- public bool CanExecute(object parameter)
- {
- if (_canExecute != null)
- return _canExecute(parameter);
+ /// 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 bool CanExecute(object parameter)
+ {
+ if (_canExecute != null)
+ return _canExecute(parameter);
- return true;
- }
+ return true;
+ }
/// <summary>
/// Occurs when the target of the Command should reevaluate whether or not the Command can be executed.
/// </summary>
- public event EventHandler CanExecuteChanged;
+ /// 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 event EventHandler CanExecuteChanged;
/// <summary>
/// Invokes the execute Action.
/// </summary>
/// <param name="parameter">An Object used as parameter for the execute Action.</param>
+ /// 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 void Execute(object parameter)
- {
- _execute(parameter);
- }
+ {
+ _execute(parameter);
+ }
/// <summary>
/// Send a CanExecuteChanged.
/// </summary>
- public void ChangeCanExecute()
- {
- EventHandler changed = CanExecuteChanged;
- changed?.Invoke(this, EventArgs.Empty);
- }
- }
+ /// 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 void ChangeCanExecute()
+ {
+ EventHandler changed = CanExecuteChanged;
+ changed?.Invoke(this, EventArgs.Empty);
+ }
+ }
}
using System.ComponentModel;
using Tizen.NUI.Binding;
using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Xaml;
+using System.Collections.Generic;
+using System.IO;
namespace Tizen.NUI
{
[EditorBrowsable(EditorBrowsableState.Never)]
public class ContentPage : TemplatedPage
{
- private View _content;
+ /// 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 View Root {get; internal set;}
+ private Window Window;
- // public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(ContentPage), null, propertyChanged: TemplateUtilities.OnContentChanged);
+ internal 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);
+ // }
- // public View Content
- // {
- // get { return (View)GetValue(ContentProperty); }
- // set { SetValue(ContentProperty, value); }
- // }
+ // if (newValue != null)
+ // self.InternalChildren.Add(newElement);
+ // }
+ // else
+ // {
+ // if (newElement != null)
+ // {
+ // BindableObject.SetInheritedBindingContext(newElement, bindable.BindingContext);
+ // }
+ // }
+ var self = (ContentPage)bindable;
+ if (newValue != null)
+ {
+ self.Root.Add((View)newValue);
+ }
+ });
+
+ /// <summary>
+ /// The contents of ContentPage can be added into it.
+ /// </summary>
+ /// 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 View Content
+ {
+ get { return (View)GetValue(ContentProperty); }
+ set { SetValue(ContentProperty, value); }
+ }
/// <summary>
/// Method that is called when the binding content changes.
/// </summary>
- protected override void OnBindingContextChanged()
- {
- base.OnBindingContextChanged();
-
- View content = Content;
- ControlTemplate controlTemplate = ControlTemplate;
- if (content != null && controlTemplate != null)
- {
- SetInheritedBindingContext(content, BindingContext);
- }
- }
-
- internal override void OnControlTemplateChanged(ControlTemplate oldValue, ControlTemplate newValue)
- {
- if (oldValue == null)
- return;
-
- base.OnControlTemplateChanged(oldValue, newValue);
- View content = Content;
- ControlTemplate controlTemplate = ControlTemplate;
- if (content != null && controlTemplate != null)
- {
- SetInheritedBindingContext(content, BindingContext);
- }
- }
-
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void OnBindingContextChanged()
+ {
+ base.OnBindingContextChanged();
+
+ View content = Content;
+ ControlTemplate controlTemplate = ControlTemplate;
+ if (content != null && controlTemplate != null)
+ {
+ SetInheritedBindingContext(content, BindingContext);
+ }
+ }
+
+ internal override void OnControlTemplateChanged(ControlTemplate oldValue, ControlTemplate newValue)
+ {
+ if (oldValue == null)
+ return;
+
+ base.OnControlTemplateChanged(oldValue, newValue);
+ View content = Content;
+ ControlTemplate controlTemplate = ControlTemplate;
+ if (content != null && controlTemplate != null)
+ {
+ SetInheritedBindingContext(content, BindingContext);
+ }
+ }
+
/// <summary>
/// The constructor.
/// </summary>
+ /// 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 ContentPage(Window win)
{
- _content = new View();
- _content.WidthResizePolicy = ResizePolicyType.FillToParent;
- _content.HeightResizePolicy = ResizePolicyType.FillToParent;
- win.Add(_content);
+ isCreateByXaml = true;
+
+ Root = new View();
+ Root.WidthResizePolicy = ResizePolicyType.FillToParent;
+ Root.HeightResizePolicy = ResizePolicyType.FillToParent;
+
+ win.Add(Root);
+ }
+
+ /// <summary>
+ /// The Resources property.
+ /// </summary>
+ /// 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 ResourceDictionary Resources
+ {
+ get
+ {
+ return Application.Current.Resources;
+ }
+
+ set
+ {
+ Application.Current.Resources = value;
+ }
}
/// <summary>
/// To make the ContentPage instance be disposed.
/// </summary>
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
protected override void Dispose(DisposeTypes type)
{
if (disposed)
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.
- Window.Instance.Remove(_content);
- _content?.Dispose();
- _content = null;
+ Window.Instance.Remove(Root);
+ Root?.Dispose();
+ Root = null;
base.Dispose(type);
}
/// <summary>
- /// The contents of ContentPage can be added into it.
- /// </summary>
- public View Content
- {
- get
- {
- return _content;
- }
- set
- {
- if (value != null)
- {
- _content.Add(value);
- }
- }
- }
-
- /// <summary>
/// Check whether the content is empty.
/// </summary>
+ /// 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 bool IsEmpty
{
get
{
- return ( _content.ChildCount == 0 ) ? true : false;
+ return ( Root.ChildCount == 0 ) ? true : false;
}
}
/// <summary>
/// Clear all contents from this ContentPage.
/// </summary>
+ /// 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 void ClearContent()
{
- if ( _content != null )
+ if ( Root != null )
{
//Remove it from the window
- Window.Instance.Remove(_content);
- _content.Dispose();
- _content = null;
+ Window.Instance.Remove(Root);
+ Root.Dispose();
+ Root = null;
//Readd to window
- _content = new View();
- _content.WidthResizePolicy = ResizePolicyType.FillToParent;
- _content.HeightResizePolicy = ResizePolicyType.FillToParent;
- Window.Instance.Add(_content);
+ Root = new View();
+ Root.WidthResizePolicy = ResizePolicyType.FillToParent;
+ Root.HeightResizePolicy = ResizePolicyType.FillToParent;
+ Window.Instance.Add(Root);
ClearHandler();
}
/// <summary>
/// Clear event.
/// </summary>
+ /// 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 event EventHandler ClearEvent
{
add
/// <summary>
/// Users can set focus logic codes here.
/// </summary>
+ /// 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 virtual void SetFocus() { }
+ private Dictionary<string, Transition> transDictionary = new Dictionary<string, Transition>();
+
+ /// 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)
+ {
+ Animation ani = null;
+ Transition trans = null;
+ transDictionary.TryGetValue(animationType, out trans);
+
+ ani = trans?.CreateAnimation();
+ return ani;
+ }
+
+ private void CreateAnimationFactory()
+ {
+ foreach (string str in transitionType)
+ {
+ string resourceName = str + ".xaml";
+ Transition trans = null;
+
+ string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+
+ string likelyResourcePath = resource + "animation/" + resourceName;
+
+ if (File.Exists(likelyResourcePath))
+ {
+ trans = Extensions.LoadTransition(likelyResourcePath);
+ }
+
+ transDictionary.Add(trans.Name, trans);
+ }
+ }
+
+ private string[] transitionType;
+
+ /// 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
+ {
+ get
+ {
+ return transitionType;
+ }
+ set
+ {
+ transitionType = value;
+ CreateAnimationFactory();
+ }
+ }
}
}
\ No newline at end of file
+++ /dev/null
-using System;
-using System.ComponentModel;
-using Tizen.NUI.Internals;
-
-namespace Tizen.NUI.Binding
-{
- /// <summary>
- /// A collection of styles and properties that can be added to an element at run time.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public abstract class Effect
- {
- internal Effect()
- {
- }
-
- /// <summary>
- /// Gets the element to which the style is attached.
- /// </summary>
- public Element Element { get; internal set; }
-
- /// <summary>
- /// Gets a value that tells whether the effect is attached to an element.
- /// </summary>
- public bool IsAttached { get; private set; }
-
- /// <summary>
- /// Gets the ID that is used to resolve this effect at runtime.
- /// </summary>
- public string ResolveId { get; internal set; }
-
- #region Statics
- /// <summary>
- /// Returns an Effect for the specified name, which is of the form ResolutionGroupName.ExportEffect.
- /// </summary>
- /// <param name="name">The name of the effect to get.</param>
- /// <returns>The uniquely identified effect.</returns>
- public static Effect Resolve(string name)
- {
- Effect result = null;
- if (Tizen.NUI.Internals.Registrar.Effects.TryGetValue(name, out Type effectType))
- {
- result = (Effect)DependencyResolver.ResolveOrCreate(effectType);
- }
-
- if (result == null)
- result = new NullEffect();
- result.ResolveId = name;
- return result;
- }
-
- #endregion
-
- /// <summary>
- /// Method that is called after the effect is attached and made valid.
- /// </summary>
- protected abstract void OnAttached();
-
- /// <summary>
- /// Method that is called after the effect is detached and invalidated.
- /// </summary>
- protected abstract void OnDetached();
-
- internal virtual void ClearEffect()
- {
- if (IsAttached)
- SendDetached();
- Element = null;
- }
-
- internal virtual void SendAttached()
- {
- if (IsAttached)
- return;
- OnAttached();
- IsAttached = true;
- }
-
- internal virtual void SendDetached()
- {
- if (!IsAttached)
- return;
- OnDetached();
- IsAttached = false;
- }
-
- internal virtual void SendOnElementPropertyChanged(PropertyChangedEventArgs args)
- {
- }
- }
-}
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Xml;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
namespace Tizen.NUI.Binding
{
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public abstract partial class Element : BindableObject, IElement, INameScope, IElementController
- {
+ {
- // public static readonly BindableProperty MenuProperty = BindableProperty.CreateAttached(nameof(Menu), typeof(Menu), typeof(Element), null);
+ // public static readonly BindableProperty MenuProperty = BindableProperty.CreateAttached(nameof(Menu), typeof(Menu), typeof(Element), null);
- // public static Menu GetMenu(BindableObject bindable)
- // {
- // return (Menu)bindable.GetValue(MenuProperty);
- // }
+ // public static Menu GetMenu(BindableObject bindable)
+ // {
+ // return (Menu)bindable.GetValue(MenuProperty);
+ // }
- // public static void SetMenu(BindableObject bindable, Menu menu)
- // {
- // bindable.SetValue(MenuProperty, menu);
- // }
+ // public static void SetMenu(BindableObject bindable, Menu menu)
+ // {
+ // bindable.SetValue(MenuProperty, menu);
+ // }
- internal static readonly ReadOnlyCollection<Element> EmptyChildren = new ReadOnlyCollection<Element>(new Element[0]);
+ internal static readonly ReadOnlyCollection<Element> EmptyChildren = new ReadOnlyCollection<Element>(new Element[0]);
/// <summary>
/// Identifies the ClassId bindable property.
/// </summary>
- public static readonly BindableProperty ClassIdProperty = BindableProperty.Create("ClassId", typeof(string), typeof(Tizen.NUI.BaseComponents.View), null);
+ internal static readonly BindableProperty ClassIdProperty = BindableProperty.Create("ClassId", typeof(string), typeof(Tizen.NUI.BaseComponents.View), null);
- string _automationId;
+ string _automationId;
- IList<BindableObject> _bindableResources;
+ IList<BindableObject> _bindableResources;
- List<Action<object, ResourcesChangedEventArgs>> _changeHandlers;
+ List<Action<object, ResourcesChangedEventArgs>> _changeHandlers;
- Dictionary<BindableProperty, string> _dynamicResources;
+ Dictionary<BindableProperty, string> _dynamicResources;
- IEffectControlProvider _effectControlProvider;
+ IEffectControlProvider _effectControlProvider;
- TrackableCollection<Effect> _effects;
+ TrackableCollection<Effect> _effects;
- Guid? _id;
+ Guid? _id;
- Element _parentOverride;
+ Element _parentOverride;
- IPlatform _platform;
+ IPlatform _platform;
- string _styleId;
+ string _styleId;
/// <summary>
/// Gets or sets a value that allows the automation framework to find and interact with this element.
/// </summary>
- public string AutomationId
- {
- get { return _automationId; }
- set
- {
- if (_automationId != null)
- throw new InvalidOperationException("AutomationId may only be set one time");
- _automationId = value;
- }
- }
+ /// 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 AutomationId
+ {
+ get { return _automationId; }
+ set
+ {
+ if (_automationId != null)
+ throw new InvalidOperationException("AutomationId may only be set one time");
+ _automationId = value;
+ }
+ }
/// <summary>
/// Gets or sets a value used to identify a collection of semantically similar elements.
/// </summary>
- public string ClassId
- {
- get { return (string)GetValue(ClassIdProperty); }
- set { SetValue(ClassIdProperty, value); }
- }
-
- internal IList<Effect> Effects
- {
- get
- {
- if (_effects == null)
- {
- _effects = new TrackableCollection<Effect>();
- _effects.CollectionChanged += EffectsOnCollectionChanged;
- _effects.Clearing += EffectsOnClearing;
- }
- return _effects;
- }
- }
+ /// 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 ClassId
+ {
+ get { return (string)GetValue(ClassIdProperty); }
+ set { SetValue(ClassIdProperty, value); }
+ }
+
+ internal IList<Effect> Effects
+ {
+ get
+ {
+ if (_effects == null)
+ {
+ _effects = new TrackableCollection<Effect>();
+ _effects.CollectionChanged += EffectsOnCollectionChanged;
+ _effects.Clearing += EffectsOnClearing;
+ }
+ return _effects;
+ }
+ }
/// <summary>
/// Gets a value that can be used to uniquely identify an element through the run of an application.
/// </summary>
- public Guid Id
- {
- get
- {
- if (!_id.HasValue)
- _id = Guid.NewGuid();
- return _id.Value;
- }
- }
+ /// 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 Guid Id
+ {
+ get
+ {
+ if (!_id.HasValue)
+ _id = Guid.NewGuid();
+ return _id.Value;
+ }
+ }
/// <summary>
/// Gets the element which is the closest ancestor of this element that is a BaseHandle.
/// </summary>
- [Obsolete("ParentView is obsolete as of version 2.1.0. Please use Parent instead.")]
- public /*VisualElement*/BaseHandle ParentView
- {
- get
- {
- Element parent = Parent;
- while (parent != null)
- {
- var parentView = parent as /*VisualElement*/BaseHandle;
- if (parentView != null)
- return parentView;
- parent = parent.RealParent;
- }
- return null;
- }
- }
+ [Obsolete("ParentView is obsolete as of version 2.1.0. Please use Parent instead.")]
+ /// 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 /*VisualElement*/BaseHandle ParentView
+ {
+ get
+ {
+ Element parent = Parent;
+ while (parent != null)
+ {
+ var parentView = parent as /*VisualElement*/BaseHandle;
+ if (parentView != null)
+ return parentView;
+ parent = parent.RealParent;
+ }
+ return null;
+ }
+ }
/// <summary>
/// Gets or sets a user defined value to uniquely identify the element.
/// </summary>
- public string StyleId
- {
- get { return _styleId; }
- set
- {
- if (_styleId == value)
- return;
-
- OnPropertyChanging();
- _styleId = value;
- OnPropertyChanged();
- }
- }
-
- internal virtual ReadOnlyCollection<Element> LogicalChildrenInternal => EmptyChildren;
+ /// 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 StyleId
+ {
+ get { return _styleId; }
+ set
+ {
+ if (_styleId == value)
+ return;
+
+ OnPropertyChanging();
+ _styleId = value;
+ OnPropertyChanged();
+ }
+ }
+
+ internal virtual ReadOnlyCollection<Element> LogicalChildrenInternal => EmptyChildren;
/// <summary>
/// For internal use.
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public ReadOnlyCollection<Element> LogicalChildren => LogicalChildrenInternal;
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ReadOnlyCollection<Element> LogicalChildren => LogicalChildrenInternal;
- internal bool Owned { get; set; }
+ internal bool Owned { get; set; }
- internal Element ParentOverride
- {
- get { return _parentOverride; }
- set
- {
- if (_parentOverride == value)
- return;
+ internal Element ParentOverride
+ {
+ get { return _parentOverride; }
+ set
+ {
+ if (_parentOverride == value)
+ return;
- bool emitChange = Parent != value;
+ bool emitChange = Parent != value;
- if (emitChange)
- OnPropertyChanging(nameof(Parent));
+ if (emitChange)
+ OnPropertyChanging(nameof(Parent));
- _parentOverride = value;
+ _parentOverride = value;
- if (emitChange)
- OnPropertyChanged(nameof(Parent));
- }
- }
+ if (emitChange)
+ OnPropertyChanged(nameof(Parent));
+ }
+ }
/// <summary>
/// For internal use.
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public IPlatform Platform
- {
- get
- {
- if (_platform == null && RealParent != null)
- return RealParent.Platform;
- return _platform;
- }
- set
- {
- if (_platform == value)
- return;
- _platform = value;
- PlatformSet?.Invoke(this, EventArgs.Empty);
- foreach (Element descendant in Descendants())
- {
- descendant._platform = _platform;
- descendant.PlatformSet?.Invoke(this, EventArgs.Empty);
- }
- }
- }
+ internal IPlatform Platform
+ {
+ get
+ {
+ if (_platform == null && RealParent != null)
+ return RealParent.Platform;
+ return _platform;
+ }
+ set
+ {
+ if (_platform == value)
+ return;
+ _platform = value;
+ PlatformSet?.Invoke(this, EventArgs.Empty);
+ foreach (Element descendant in Descendants())
+ {
+ descendant._platform = _platform;
+ descendant.PlatformSet?.Invoke(this, EventArgs.Empty);
+ }
+ }
+ }
/// <summary>
/// For internal use.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public Element RealParent { get; private set; }
+ public Element RealParent { get; private set; }
- Dictionary<BindableProperty, string> DynamicResources
- {
- get { return _dynamicResources ?? (_dynamicResources = new Dictionary<BindableProperty, string>()); }
- }
+ Dictionary<BindableProperty, string> DynamicResources
+ {
+ get { return _dynamicResources ?? (_dynamicResources = new Dictionary<BindableProperty, string>()); }
+ }
- void IElement.AddResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged)
- {
- _changeHandlers = _changeHandlers ?? new List<Action<object, ResourcesChangedEventArgs>>(2);
- _changeHandlers.Add(onchanged);
- }
+ void IElement.AddResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged)
+ {
+ _changeHandlers = _changeHandlers ?? new List<Action<object, ResourcesChangedEventArgs>>(2);
+ _changeHandlers.Add(onchanged);
+ }
/// <summary>
/// Gets or sets the parent element of the element.
/// </summary>
- public Element Parent
- {
- get { return _parentOverride ?? RealParent; }
- set
- {
- if (RealParent == value)
- return;
-
- OnPropertyChanging();
-
- if (RealParent != null)
- ((IElement)RealParent).RemoveResourcesChangedListener(OnParentResourcesChanged);
- RealParent = value;
- if (RealParent != null)
- {
- OnParentResourcesChanged(RealParent?.GetMergedResources());
- ((IElement)RealParent).AddResourcesChangedListener(OnParentResourcesChanged);
- }
-
- object context = value != null ? value.BindingContext : null;
- if (value != null)
- {
- value.SetChildInheritedBindingContext(this, context);
- }
- else
- {
- SetInheritedBindingContext(this, null);
- }
-
- OnParentSet();
-
- if (RealParent != null)
- {
- IPlatform platform = RealParent.Platform;
- if (platform != null)
- Platform = platform;
- }
-
- OnPropertyChanged();
- }
- }
-
- void IElement.RemoveResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged)
- {
- if (_changeHandlers == null)
- return;
- _changeHandlers.Remove(onchanged);
- }
+ /// 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 Element Parent
+ {
+ get { return _parentOverride ?? RealParent; }
+ set
+ {
+ if (RealParent == value)
+ return;
+
+ OnPropertyChanging();
+
+ if (RealParent != null)
+ ((IElement)RealParent).RemoveResourcesChangedListener(OnParentResourcesChanged);
+ RealParent = value;
+ if (RealParent != null)
+ {
+ OnParentResourcesChanged(RealParent?.GetMergedResources());
+ ((IElement)RealParent).AddResourcesChangedListener(OnParentResourcesChanged);
+ }
+
+ object context = value != null ? value.BindingContext : null;
+ if (value != null)
+ {
+ value.SetChildInheritedBindingContext(this, context);
+ }
+ else
+ {
+ SetInheritedBindingContext(this, null);
+ }
+
+ OnParentSet();
+
+ if (RealParent != null)
+ {
+ IPlatform platform = RealParent.Platform;
+ if (platform != null)
+ Platform = platform;
+ }
+
+ OnPropertyChanged();
+ }
+ }
+
+ void IElement.RemoveResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged)
+ {
+ if (_changeHandlers == null)
+ return;
+ _changeHandlers.Remove(onchanged);
+ }
/// <summary>
/// For internal use.
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public IEffectControlProvider EffectControlProvider
- {
- get { return _effectControlProvider; }
- set
- {
- if (_effectControlProvider == value)
- return;
- if (_effectControlProvider != null && _effects != null)
- {
- foreach (Effect effect in _effects)
- effect?.SendDetached();
- }
- _effectControlProvider = value;
- if (_effectControlProvider != null && _effects != null)
- {
- foreach (Effect effect in _effects)
- {
- if (effect != null)
- AttachEffect(effect);
- }
- }
- }
- }
-
- void IElementController.SetValueFromRenderer(BindableProperty property, object value) => SetValueFromRenderer(property, value);
+ internal IEffectControlProvider EffectControlProvider
+ {
+ get { return _effectControlProvider; }
+ set
+ {
+ if (_effectControlProvider == value)
+ return;
+ if (_effectControlProvider != null && _effects != null)
+ {
+ foreach (Effect effect in _effects)
+ effect?.SendDetached();
+ }
+ _effectControlProvider = value;
+ if (_effectControlProvider != null && _effects != null)
+ {
+ foreach (Effect effect in _effects)
+ {
+ if (effect != null)
+ AttachEffect(effect);
+ }
+ }
+ }
+ }
+
+ //void IElementController.SetValueFromRenderer(BindableProperty property, object value) => SetValueFromRenderer(property, value);
/// <summary>
/// Sets the value of the specified property.
/// </summary>
/// <param name="property">The BindableProperty on which to assign a value.</param>
/// <param name="value">The value to set.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SetValueFromRenderer(BindableProperty property, object value)
- {
- SetValueCore(property, value);
- }
+ internal void SetValueFromRenderer(BindableProperty property, object value)
+ {
+ SetValueCore(property, value);
+ }
/// <summary>
/// Sets the value of the propertyKey.
/// </summary>
/// <param name="property">The BindablePropertyKey on which to assign a value.</param>
/// <param name="value">The value to set.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SetValueFromRenderer(BindablePropertyKey property, object value)
- {
- SetValueCore(property, value);
- }
+ internal void SetValueFromRenderer(BindablePropertyKey property, object value)
+ {
+ SetValueCore(property, value);
+ }
/// <summary>
/// For internal use.
/// </summary>
/// <param name="name">The nameof the effect</param>
/// <returns>true if attached</returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool EffectIsAttached(string name)
- {
- foreach (var effect in Effects)
- {
- if (effect.ResolveId == name)
- return true;
- }
- return false;
- }
-
- object INameScope.FindByName(string name)
- {
- INameScope namescope = GetNameScope();
- if (namescope == null)
- throw new InvalidOperationException("this element is not in a namescope");
- return namescope.FindByName(name);
- }
-
- void INameScope.RegisterName(string name, object scopedElement)
- {
- INameScope namescope = GetNameScope();
- if (namescope == null)
- throw new InvalidOperationException("this element is not in a namescope");
- namescope.RegisterName(name, scopedElement);
- }
-
- [Obsolete]
- void INameScope.RegisterName(string name, object scopedElement, IXmlLineInfo xmlLineInfo)
- {
- INameScope namescope = GetNameScope();
- if (namescope == null)
- throw new InvalidOperationException("this element is not in a namescope");
- namescope.RegisterName(name, scopedElement, xmlLineInfo);
- }
-
- void INameScope.UnregisterName(string name)
- {
- INameScope namescope = GetNameScope();
- if (namescope == null)
- throw new InvalidOperationException("this element is not in a namescope");
- namescope.UnregisterName(name);
- }
-
- internal event EventHandler<ElementEventArgs> ChildAdded;
-
- internal event EventHandler<ElementEventArgs> ChildRemoved;
-
- internal event EventHandler<ElementEventArgs> DescendantAdded;
-
- internal event EventHandler<ElementEventArgs> DescendantRemoved;
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool EffectIsAttached(string name)
+ {
+ foreach (var effect in Effects)
+ {
+ if (effect.ResolveId == name)
+ return true;
+ }
+ return false;
+ }
+
+ object INameScope.FindByName(string name)
+ {
+ INameScope namescope = GetNameScope();
+ if (namescope == null)
+ throw new InvalidOperationException("this element is not in a namescope");
+ return namescope.FindByName(name);
+ }
+
+ void INameScope.RegisterName(string name, object scopedElement)
+ {
+ INameScope namescope = GetNameScope();
+ if (namescope == null)
+ throw new InvalidOperationException("this element is not in a namescope");
+ namescope.RegisterName(name, scopedElement);
+ }
+
+ [Obsolete]
+ void INameScope.RegisterName(string name, object scopedElement, IXmlLineInfo xmlLineInfo)
+ {
+ INameScope namescope = GetNameScope();
+ if (namescope == null)
+ throw new InvalidOperationException("this element is not in a namescope");
+ namescope.RegisterName(name, scopedElement, xmlLineInfo);
+ }
+
+ void INameScope.UnregisterName(string name)
+ {
+ INameScope namescope = GetNameScope();
+ if (namescope == null)
+ throw new InvalidOperationException("this element is not in a namescope");
+ namescope.UnregisterName(name);
+ }
+
+ internal event EventHandler<ElementEventArgs> ChildAdded;
+
+ internal event EventHandler<ElementEventArgs> ChildRemoved;
+
+ internal event EventHandler<ElementEventArgs> DescendantAdded;
+
+ internal event EventHandler<ElementEventArgs> DescendantRemoved;
/// <summary>
/// Removes a previously set dynamic resource.
/// </summary>
/// <param name="property">The BindableProperty from which to remove the DynamicResource.</param>
- public new void RemoveDynamicResource(BindableProperty property)
- {
- base.RemoveDynamicResource(property);
- }
+ internal new void RemoveDynamicResource(BindableProperty property)
+ {
+ base.RemoveDynamicResource(property);
+ }
/// <summary>
/// Sets the BindableProperty property of this element to be updated via the DynamicResource with the provided key.
/// </summary>
/// <param name="property">The BindableProperty.</param>
/// <param name="key">The key of the DynamicResource</param>
- public new void SetDynamicResource(BindableProperty property, string key)
- {
- base.SetDynamicResource(property, key);
- }
+ internal new void SetDynamicResource(BindableProperty property, string key)
+ {
+ base.SetDynamicResource(property, key);
+ }
/// <summary>
/// Invoked whenever the binding context of the element changes. Implement this method to add class handling for this event.
/// </summary>
- protected override void OnBindingContextChanged()
- {
- var gotBindingContext = false;
- object bc = null;
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void OnBindingContextChanged()
+ {
+ var gotBindingContext = false;
+ object bc = null;
- for (var index = 0; index < LogicalChildrenInternal.Count; index++)
- {
- Element child = LogicalChildrenInternal[index];
+ for (var index = 0; index < LogicalChildrenInternal.Count; index++)
+ {
+ Element child = LogicalChildrenInternal[index];
- if (!gotBindingContext)
- {
- bc = BindingContext;
- gotBindingContext = true;
- }
+ if (!gotBindingContext)
+ {
+ bc = BindingContext;
+ gotBindingContext = true;
+ }
- SetChildInheritedBindingContext(child, bc);
- }
+ SetChildInheritedBindingContext(child, bc);
+ }
- if (_bindableResources != null)
- foreach (BindableObject item in _bindableResources)
- {
- SetInheritedBindingContext(item, BindingContext);
- }
+ if (_bindableResources != null)
+ foreach (BindableObject item in _bindableResources)
+ {
+ SetInheritedBindingContext(item, BindingContext);
+ }
- base.OnBindingContextChanged();
- }
+ base.OnBindingContextChanged();
+ }
/// <summary>
/// Invoked whenever the ChildAdded event needs to be emitted.Implement this method to add class handling for this event.
/// </summary>
/// <param name="child">The element that was added.</param>
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void OnChildAdded(Element child)
- {
- child.Parent = this;
- if (Platform != null)
- child.Platform = Platform;
+ {
+ child.Parent = this;
+ if (Platform != null)
+ child.Platform = Platform;
- child.ApplyBindings(skipBindingContext: false, fromBindingContextChanged:true);
+ child.ApplyBindings(skipBindingContext: false, fromBindingContextChanged:true);
- ChildAdded?.Invoke(this, new ElementEventArgs(child));
+ ChildAdded?.Invoke(this, new ElementEventArgs(child));
- OnDescendantAdded(child);
- foreach (Element element in child.Descendants())
- OnDescendantAdded(element);
- }
+ OnDescendantAdded(child);
+ foreach (Element element in child.Descendants())
+ OnDescendantAdded(element);
+ }
/// <summary>
/// Invoked whenever the ChildRemoved event needs to be emitted.Implement this method to add class handling for this event.
/// </summary>
/// <param name="child">The element that was removed.</param>
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void OnChildRemoved(Element child)
- {
- child.Parent = null;
+ {
+ child.Parent = null;
- ChildRemoved?.Invoke(child, new ElementEventArgs(child));
+ ChildRemoved?.Invoke(child, new ElementEventArgs(child));
- OnDescendantRemoved(child);
- foreach (Element element in child.Descendants())
- OnDescendantRemoved(element);
- }
+ OnDescendantRemoved(child);
+ foreach (Element element in child.Descendants())
+ OnDescendantRemoved(element);
+ }
/// <summary>
/// Invoked whenever the Parent of an element is set.Implement this method in order to add behavior when the element is added to a parent.
/// </summary>
- protected virtual void OnParentSet()
- {
- ParentSet?.Invoke(this, EventArgs.Empty);
- // ApplyStyleSheetsOnParentSet();
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnParentSet()
+ {
+ ParentSet?.Invoke(this, EventArgs.Empty);
+ // ApplyStyleSheetsOnParentSet();
+ }
/// <summary>
/// Method that is called when a bound property is changed.
/// </summary>
/// <param name="propertyName">The name of the bound property that changed.</param>
- protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- base.OnPropertyChanged(propertyName);
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ base.OnPropertyChanged(propertyName);
- if (_effects == null || _effects.Count == 0)
- return;
+ if (_effects == null || _effects.Count == 0)
+ return;
- var args = new PropertyChangedEventArgs(propertyName);
- foreach (Effect effect in _effects)
- {
- effect?.SendOnElementPropertyChanged(args);
- }
- }
+ var args = new PropertyChangedEventArgs(propertyName);
+ foreach (Effect effect in _effects)
+ {
+ effect?.SendOnElementPropertyChanged(args);
+ }
+ }
/// <summary>
/// For internal use.
/// </summary>
/// <returns>the elements</returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public IEnumerable<Element> Descendants()
- {
- var queue = new Queue<Element>(16);
- queue.Enqueue(this);
-
- while (queue.Count > 0)
- {
- ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildrenInternal;
- for (var i = 0; i < children.Count; i++)
- {
- Element child = children[i];
- yield return child;
- queue.Enqueue(child);
- }
- }
- }
-
- internal virtual void OnParentResourcesChanged(object sender, ResourcesChangedEventArgs e)
- {
- // if (e == ResourcesChangedEventArgs.StyleSheets)
- // // ApplyStyleSheetsOnParentSet();
- // else
- // OnParentResourcesChanged(e.Values);
- }
-
- internal virtual void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
- {
- OnResourcesChanged(values);
- }
-
- internal override void OnRemoveDynamicResource(BindableProperty property)
- {
- DynamicResources.Remove(property);
-
- if (DynamicResources.Count == 0)
- _dynamicResources = null;
- base.OnRemoveDynamicResource(property);
- }
-
- internal virtual void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
- {
- OnResourcesChanged(e.Values);
- }
-
- internal void OnResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
- {
- if (values == null)
- return;
- if (_changeHandlers != null)
- foreach (Action<object, ResourcesChangedEventArgs> handler in _changeHandlers)
- handler(this, new ResourcesChangedEventArgs(values));
- if (_dynamicResources == null)
- return;
- if (_bindableResources == null)
- _bindableResources = new List<BindableObject>();
- foreach (KeyValuePair<string, object> value in values)
- {
- List<BindableProperty> changedResources = null;
- foreach (KeyValuePair<BindableProperty, string> dynR in DynamicResources)
- {
- // when the DynamicResource bound to a BindableProperty is
- // changing then the BindableProperty needs to be refreshed;
- // The .Value is the name of DynamicResouce to which the BindableProperty is bound.
- // The .Key is the name of the DynamicResource whose value is changing.
- if (dynR.Value != value.Key)
- continue;
- changedResources = changedResources ?? new List<BindableProperty>();
- changedResources.Add(dynR.Key);
- }
- if (changedResources == null)
- continue;
- foreach (BindableProperty changedResource in changedResources)
- OnResourceChanged(changedResource, value.Value);
-
- var bindableObject = value.Value as BindableObject;
- if (bindableObject != null && (bindableObject as Element)?.Parent == null)
- {
- if (!_bindableResources.Contains(bindableObject))
- _bindableResources.Add(bindableObject);
- SetInheritedBindingContext(bindableObject, BindingContext);
- }
- }
- }
-
- internal override void OnSetDynamicResource(BindableProperty property, string key)
- {
- base.OnSetDynamicResource(property, key);
- DynamicResources[property] = key;
- object value;
- if (this.TryGetResource(key, out value))
- OnResourceChanged(property, value);
- }
-
- internal event EventHandler ParentSet;
-
- internal static void SetFlowDirectionFromParent(Element child)
- {
- // IFlowDirectionController controller = child as IFlowDirectionController;
- // if (controller == null)
- // return;
-
- // if (controller.EffectiveFlowDirection.IsImplicit())
- // {
- // var parentView = child.Parent as IFlowDirectionController;
- // if (parentView == null)
- // return;
-
- // var flowDirection = parentView.EffectiveFlowDirection.ToFlowDirection();
-
- // if (flowDirection != controller.EffectiveFlowDirection.ToFlowDirection())
- // {
- // controller.EffectiveFlowDirection = flowDirection.ToEffectiveFlowDirection();
- // }
- // }
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public IEnumerable<Element> Descendants()
+ {
+ var queue = new Queue<Element>(16);
+ queue.Enqueue(this);
+
+ while (queue.Count > 0)
+ {
+ ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildrenInternal;
+ for (var i = 0; i < children.Count; i++)
+ {
+ Element child = children[i];
+ yield return child;
+ queue.Enqueue(child);
+ }
+ }
+ }
+
+ internal virtual void OnParentResourcesChanged(object sender, ResourcesChangedEventArgs e)
+ {
+ // if (e == ResourcesChangedEventArgs.StyleSheets)
+ // // ApplyStyleSheetsOnParentSet();
+ // else
+ // OnParentResourcesChanged(e.Values);
+ }
+
+ internal virtual void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
+ {
+ OnResourcesChanged(values);
+ }
+
+ internal override void OnRemoveDynamicResource(BindableProperty property)
+ {
+ DynamicResources.Remove(property);
+
+ if (DynamicResources.Count == 0)
+ _dynamicResources = null;
+ base.OnRemoveDynamicResource(property);
+ }
+
+ internal virtual void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
+ {
+ OnResourcesChanged(e.Values);
+ }
+
+ internal void OnResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
+ {
+ if (values == null)
+ return;
+ if (_changeHandlers != null)
+ foreach (Action<object, ResourcesChangedEventArgs> handler in _changeHandlers)
+ handler(this, new ResourcesChangedEventArgs(values));
+ if (_dynamicResources == null)
+ return;
+ if (_bindableResources == null)
+ _bindableResources = new List<BindableObject>();
+ foreach (KeyValuePair<string, object> value in values)
+ {
+ List<BindableProperty> changedResources = null;
+ foreach (KeyValuePair<BindableProperty, string> dynR in DynamicResources)
+ {
+ // when the DynamicResource bound to a BindableProperty is
+ // changing then the BindableProperty needs to be refreshed;
+ // The .Value is the name of DynamicResouce to which the BindableProperty is bound.
+ // The .Key is the name of the DynamicResource whose value is changing.
+ if (dynR.Value != value.Key)
+ continue;
+ changedResources = changedResources ?? new List<BindableProperty>();
+ changedResources.Add(dynR.Key);
+ }
+ if (changedResources == null)
+ continue;
+ foreach (BindableProperty changedResource in changedResources)
+ OnResourceChanged(changedResource, value.Value);
+
+ var bindableObject = value.Value as BindableObject;
+ if (bindableObject != null && (bindableObject as Element)?.Parent == null)
+ {
+ if (!_bindableResources.Contains(bindableObject))
+ _bindableResources.Add(bindableObject);
+ SetInheritedBindingContext(bindableObject, BindingContext);
+ }
+ }
+ }
+
+ internal override void OnSetDynamicResource(BindableProperty property, string key)
+ {
+ base.OnSetDynamicResource(property, key);
+ DynamicResources[property] = key;
+ object value;
+ if (this.TryGetResource(key, out value))
+ OnResourceChanged(property, value);
+ }
+
+ internal event EventHandler ParentSet;
+
+ internal static void SetFlowDirectionFromParent(Element child)
+ {
+ // IFlowDirectionController controller = child as IFlowDirectionController;
+ // if (controller == null)
+ // return;
+
+ // if (controller.EffectiveFlowDirection.IsImplicit())
+ // {
+ // var parentView = child.Parent as IFlowDirectionController;
+ // if (parentView == null)
+ // return;
+
+ // var flowDirection = parentView.EffectiveFlowDirection.ToFlowDirection();
+
+ // if (flowDirection != controller.EffectiveFlowDirection.ToFlowDirection())
+ // {
+ // controller.EffectiveFlowDirection = flowDirection.ToEffectiveFlowDirection();
+ // }
+ // }
+ }
/// <summary>
/// For internal use.
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public event EventHandler PlatformSet;
-
- internal virtual void SetChildInheritedBindingContext(Element child, object context)
- {
- SetInheritedBindingContext(child, context);
- }
-
- internal IEnumerable<Element> VisibleDescendants()
- {
- var queue = new Queue<Element>(16);
- queue.Enqueue(this);
-
- while (queue.Count > 0)
- {
- ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildrenInternal;
- for (var i = 0; i < children.Count; i++)
- {
- var child = children[i] as /*VisualElement*/BaseHandle;
- if (child == null /*|| !child.IsVisible*/)
- continue;
- yield return child;
- queue.Enqueue(child);
- }
- }
- }
-
- void AttachEffect(Effect effect)
- {
- if (_effectControlProvider == null)
- return;
- if (effect.IsAttached)
- throw new InvalidOperationException("Cannot attach Effect to multiple sources");
-
- Effect effectToRegister = effect;
- if (effect is RoutingEffect)
- effectToRegister = ((RoutingEffect)effect).Inner;
- _effectControlProvider.RegisterEffect(effectToRegister);
- effectToRegister.Element = this;
- effect.SendAttached();
- }
-
- void EffectsOnClearing(object sender, EventArgs eventArgs)
- {
- foreach (Effect effect in _effects)
- {
- effect?.ClearEffect();
- }
- }
-
- void EffectsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- switch (e.Action)
- {
- case NotifyCollectionChangedAction.Add:
- foreach (Effect effect in e.NewItems)
- {
- AttachEffect(effect);
- }
- break;
- case NotifyCollectionChangedAction.Move:
- break;
- case NotifyCollectionChangedAction.Remove:
- foreach (Effect effect in e.OldItems)
- {
- effect.ClearEffect();
- }
- break;
- case NotifyCollectionChangedAction.Replace:
- foreach (Effect effect in e.NewItems)
- {
- AttachEffect(effect);
- }
- foreach (Effect effect in e.OldItems)
- {
- effect.ClearEffect();
- }
- break;
- case NotifyCollectionChangedAction.Reset:
- if (e.NewItems != null)
- {
- foreach (Effect effect in e.NewItems)
- {
- AttachEffect(effect);
- }
- }
- if (e.OldItems != null)
- {
- foreach (Effect effect in e.OldItems)
- {
- effect.ClearEffect();
- }
- }
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
- }
-
- INameScope GetNameScope()
- {
- INameScope namescope = NameScope.GetNameScope(this);
- Element p = RealParent;
- while (namescope == null && p != null)
- {
- namescope = NameScope.GetNameScope(p);
- p = p.RealParent;
- }
- return namescope;
- }
-
- void OnDescendantAdded(Element child)
- {
- DescendantAdded?.Invoke(this, new ElementEventArgs(child));
-
- if (RealParent != null)
- RealParent.OnDescendantAdded(child);
- }
-
- void OnDescendantRemoved(Element child)
- {
- DescendantRemoved?.Invoke(this, new ElementEventArgs(child));
-
- if (RealParent != null)
- RealParent.OnDescendantRemoved(child);
- }
-
- void OnResourceChanged(BindableProperty property, object value)
- {
- SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearTwoWayBindings);
- }
- }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler PlatformSet;
+
+ internal virtual void SetChildInheritedBindingContext(Element child, object context)
+ {
+ SetInheritedBindingContext(child, context);
+ }
+
+ internal IEnumerable<Element> VisibleDescendants()
+ {
+ var queue = new Queue<Element>(16);
+ queue.Enqueue(this);
+
+ while (queue.Count > 0)
+ {
+ ReadOnlyCollection<Element> children = queue.Dequeue().LogicalChildrenInternal;
+ for (var i = 0; i < children.Count; i++)
+ {
+ var child = children[i] as /*VisualElement*/BaseHandle;
+ if (child == null /*|| !child.IsVisible*/)
+ continue;
+ yield return child;
+ queue.Enqueue(child);
+ }
+ }
+ }
+
+ void AttachEffect(Effect effect)
+ {
+ if (_effectControlProvider == null)
+ return;
+ if (effect.IsAttached)
+ throw new InvalidOperationException("Cannot attach Effect to multiple sources");
+
+ Effect effectToRegister = effect;
+ if (effect is RoutingEffect)
+ effectToRegister = ((RoutingEffect)effect).Inner;
+ _effectControlProvider.RegisterEffect(effectToRegister);
+ effectToRegister.Element = this;
+ effect.SendAttached();
+ }
+
+ void EffectsOnClearing(object sender, EventArgs eventArgs)
+ {
+ foreach (Effect effect in _effects)
+ {
+ effect?.ClearEffect();
+ }
+ }
+
+ void EffectsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ switch (e.Action)
+ {
+ case NotifyCollectionChangedAction.Add:
+ foreach (Effect effect in e.NewItems)
+ {
+ AttachEffect(effect);
+ }
+ break;
+ case NotifyCollectionChangedAction.Move:
+ break;
+ case NotifyCollectionChangedAction.Remove:
+ foreach (Effect effect in e.OldItems)
+ {
+ effect.ClearEffect();
+ }
+ break;
+ case NotifyCollectionChangedAction.Replace:
+ foreach (Effect effect in e.NewItems)
+ {
+ AttachEffect(effect);
+ }
+ foreach (Effect effect in e.OldItems)
+ {
+ effect.ClearEffect();
+ }
+ break;
+ case NotifyCollectionChangedAction.Reset:
+ if (e.NewItems != null)
+ {
+ foreach (Effect effect in e.NewItems)
+ {
+ AttachEffect(effect);
+ }
+ }
+ if (e.OldItems != null)
+ {
+ foreach (Effect effect in e.OldItems)
+ {
+ effect.ClearEffect();
+ }
+ }
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ }
+
+ INameScope GetNameScope()
+ {
+ INameScope namescope = NameScope.GetNameScope(this);
+ Element p = RealParent;
+ while (namescope == null && p != null)
+ {
+ namescope = NameScope.GetNameScope(p);
+ p = p.RealParent;
+ }
+ return namescope;
+ }
+
+ void OnDescendantAdded(Element child)
+ {
+ DescendantAdded?.Invoke(this, new ElementEventArgs(child));
+
+ if (RealParent != null)
+ RealParent.OnDescendantAdded(child);
+ }
+
+ void OnDescendantRemoved(Element child)
+ {
+ DescendantRemoved?.Invoke(this, new ElementEventArgs(child));
+
+ if (RealParent != null)
+ RealParent.OnDescendantRemoved(child);
+ }
+
+ void OnResourceChanged(BindableProperty property, object value)
+ {
+ SetValueCore(property, value, SetValueFlags.ClearOneWayBindings | SetValueFlags.ClearTwoWayBindings);
+ }
+ }
}
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using Tizen.NUI.Internals;
-
-namespace Tizen.NUI.Binding
-{
- /// <summary>
- /// Base class for DataTemplate and ControlTemplate classes.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class ElementTemplate : IElement, IDataTemplate
- {
- List<Action<object, ResourcesChangedEventArgs>> _changeHandlers;
- Element _parent;
- bool _canRecycle; // aka IsDeclarative
-
- internal ElementTemplate()
- {
- }
-
- internal ElementTemplate(Type type) : this()
- {
- if (type == null)
- throw new ArgumentNullException("type");
-
- _canRecycle = true;
-
- LoadTemplate = () => Activator.CreateInstance(type);
- }
-
- internal ElementTemplate(Func<object> loadTemplate) : this()
- {
- if (loadTemplate == null)
- throw new ArgumentNullException("loadTemplate");
-
- LoadTemplate = loadTemplate;
- }
-
- Func<object> LoadTemplate { get; set; }
-
-#pragma warning disable 0612
- Func<object> IDataTemplate.LoadTemplate
- {
- get { return LoadTemplate; }
- set { LoadTemplate = value; }
- }
-#pragma warning restore 0612
-
- void IElement.AddResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged)
- {
- _changeHandlers = _changeHandlers ?? new List<Action<object, ResourcesChangedEventArgs>>(1);
- _changeHandlers.Add(onchanged);
- }
-
- internal bool CanRecycle => _canRecycle;
- Element IElement.Parent
- {
- get { return _parent; }
- set
- {
- if (_parent == value)
- return;
- if (_parent != null)
- ((IElement)_parent).RemoveResourcesChangedListener(OnResourcesChanged);
- _parent = value;
- if (_parent != null)
- ((IElement)_parent).AddResourcesChangedListener(OnResourcesChanged);
- }
- }
-
- void IElement.RemoveResourcesChangedListener(Action<object, ResourcesChangedEventArgs> onchanged)
- {
- if (_changeHandlers == null)
- return;
- _changeHandlers.Remove(onchanged);
- }
-
- /// <summary>
- /// Used by the XAML infrastructure to load data templates and set up the content of the resulting UI.
- /// </summary>
- /// <returns></returns>
- public object CreateContent()
- {
- if (LoadTemplate == null)
- throw new InvalidOperationException("LoadTemplate should not be null");
- if (this is DataTemplateSelector)
- throw new InvalidOperationException("Cannot call CreateContent directly on a DataTemplateSelector");
-
- object item = LoadTemplate();
- SetupContent(item);
-
- return item;
- }
-
- internal virtual void SetupContent(object item)
- {
- }
-
- void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
- {
- if (_changeHandlers == null)
- return;
- foreach (Action<object, ResourcesChangedEventArgs> handler in _changeHandlers)
- handler(this, e);
- }
- }
-}
--- /dev/null
+using System.ComponentModel;
+
+namespace Tizen.NUI.Binding
+{
+ /// 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 interface IResourcesProvider
+ {
+ bool IsResourcesCreated { get; }
+ ResourceDictionary Resources { get; set; }
+ }
+}
--- /dev/null
+using System;
+using System.Globalization;
+using System.ComponentModel;
+
+namespace Tizen.NUI.Binding
+{
+ /// 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 interface IValueConverter
+ {
+ object Convert(object value, Type targetType, object parameter, CultureInfo culture);
+ object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture);
+ }
+}
--- /dev/null
+using System.ComponentModel;
+using Tizen.NUI.Binding.Internals;
+
+namespace Tizen.NUI.Binding
+{
+ /// 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 class NameScopeExtensions
+ {
+ /// 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 FindByName<T>(this Element element, string name)
+ {
+ return ((INameScope)element).FindByName<T>(name);
+ }
+
+ internal static T FindByName<T>(this INameScope namescope, string name)
+ {
+ return (T)namescope.FindByName(name);
+ }
+ }
+}
\ No newline at end of file
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Linq;
-using System.Threading.Tasks;
-using Tizen.NUI.Internals;
-using Tizen.NUI.Binding;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// A Page that manages the navigation and user-experience of a stack of other pages.
- /// </summary>
- // [RenderWith(typeof(_NavigationPageRenderer))]
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class NavigationPage : Page, IPageContainer<Page>, INavigationPageController, IElementConfiguration<NavigationPage>
- {
- /// <summary>
- /// Identifies the property associated with the title of the back button.
- /// </summary>
- public static readonly BindableProperty BackButtonTitleProperty = BindableProperty.CreateAttached("BackButtonTitle", typeof(string), typeof(Page), null);
-
- /// <summary>
- /// Backing store for the HasNavigationBar property.
- /// </summary>
- public static readonly BindableProperty HasNavigationBarProperty = BindableProperty.CreateAttached("HasNavigationBar", typeof(bool), typeof(Page), true);
-
- /// <summary>
- /// Backing store for the HasBackButton property.
- /// </summary>
- public static readonly BindableProperty HasBackButtonProperty = BindableProperty.CreateAttached("HasBackButton", typeof(bool), typeof(NavigationPage), true);
-
- /// <summary>
- /// Identifies the Tint bindable property.
- /// </summary>
- [Obsolete("TintProperty is obsolete as of version 1.2.0. Please use BarBackgroundColorProperty and BarTextColorProperty to change NavigationPage bar color properties.")]
- public static readonly BindableProperty TintProperty = BindableProperty.Create("Tint", typeof(Color), typeof(NavigationPage), /*Color.Default*/Color.Black);
-
- /// <summary>
- /// Identifies the property associated with the color of the NavigationPage's bar background color.
- /// </summary>
- public static readonly BindableProperty BarBackgroundColorProperty = BindableProperty.Create("BarBackgroundColor", typeof(Color), typeof(NavigationPage), /*Color.Default*/Color.Black);
-
- /// <summary>
- /// Identifies the property associated with the color of the NavigationPage's bar text color.
- /// </summary>
- public static readonly BindableProperty BarTextColorProperty = BindableProperty.Create("BarTextColor", typeof(Color), typeof(NavigationPage), /*Color.Default*/Color.Black);
-
- /// <summary>
- /// Indicates the NavigationPage.SetTitleIcon/NavigationPage.GetTitleIcon property.
- /// </summary>
- public static readonly BindableProperty TitleIconProperty = BindableProperty.CreateAttached("TitleIcon", typeof(FileImageSource), typeof(NavigationPage), default(FileImageSource));
-
- static readonly BindablePropertyKey CurrentPagePropertyKey = BindableProperty.CreateReadOnly("CurrentPage", typeof(Page), typeof(NavigationPage), null);
-
- /// <summary>
- /// Identifies the property associated with NavigationPage.CurrentPage
- /// </summary>
- public static readonly BindableProperty CurrentPageProperty = CurrentPagePropertyKey.BindableProperty;
-
- static readonly BindablePropertyKey RootPagePropertyKey = BindableProperty.CreateReadOnly(nameof(RootPage), typeof(Page), typeof(NavigationPage), null);
- /// <summary>
- /// Identifies the property associated with NavigationPage.RootPage
- /// </summary>
- public static readonly BindableProperty RootPageProperty = RootPagePropertyKey.BindableProperty;
-
- /// <summary>
- /// Initializes a new NavigationPage object.
- /// </summary>
- public NavigationPage()
- {
- _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<NavigationPage>>(() => new PlatformConfigurationRegistry<NavigationPage>(this));
-
- Navigation = new NavigationImpl(this);
- }
-
- /// <summary>
- /// Creates a new NavigationPage element with root as its root element.
- /// </summary>
- /// <param name="root">The root page.</param>
- public NavigationPage(Page root) : this()
- {
- PushPage(root);
- }
-
- /// <summary>
- /// Gets or sets the background color for the bar at the top of the NavigationPage.
- /// </summary>
- public Color BarBackgroundColor
- {
- get { return (Color)GetValue(BarBackgroundColorProperty); }
- set { SetValue(BarBackgroundColorProperty, value); }
- }
-
- /// <summary>
- /// Gets or sets the text that appears on the bar at the top of the NavigationPage.
- /// </summary>
- public Color BarTextColor
- {
- get { return (Color)GetValue(BarTextColorProperty); }
- set { SetValue(BarTextColorProperty, value); }
- }
-
- /// <summary>
- /// The color to be used as the Tint of the NavigationPage.
- /// </summary>
- [Obsolete("Tint is obsolete as of version 1.2.0. Please use BarBackgroundColor and BarTextColor to change NavigationPage bar color properties.")]
- public Color Tint
- {
- get { return (Color)GetValue(TintProperty); }
- set { SetValue(TintProperty, value); }
- }
-
- internal Task CurrentNavigationTask { get; set; }
-
- /// <summary>
- /// For internal use
- /// </summary>
- /// <param name="depth">The depth</param>
- /// <returns>The page instance</returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Page Peek(int depth)
- {
- if (depth < 0)
- {
- return null;
- }
-
- if (InternalChildren.Count <= depth)
- {
- return null;
- }
-
- return (Page)InternalChildren[InternalChildren.Count - depth - 1];
- }
-
- /// <summary>
- /// For internal use.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public IEnumerable<Page> Pages => InternalChildren.Cast<Page>();
-
- /// <summary>
- /// For internal use
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public int StackDepth
- {
- get { return InternalChildren.Count; }
- }
-
- /// <summary>
- /// The Page that is currently top-most on the navigation stack.
- /// </summary>
- public Page CurrentPage
- {
- get { return (Page)GetValue(CurrentPageProperty); }
- private set { SetValue(CurrentPagePropertyKey, value); }
- }
-
- /// <summary>
- /// The Page that is the root of the navigation stack.
- /// </summary>
- public Page RootPage
- {
- get { return (Page)GetValue(RootPageProperty); }
- private set { SetValue(RootPagePropertyKey, value); }
- }
-
- /// <summary>
- /// The title of the back button for the specified page.
- /// </summary>
- /// <param name="page">The Page whose back-button's title is being requested.</param>
- /// <returns>The title of the back button that would be shown if the specified page were the Xamarin.Forms.CurrentPage.</returns>
- public static string GetBackButtonTitle(BindableObject page)
- {
- return (string)page.GetValue(BackButtonTitleProperty);
- }
-
- /// <summary>
- /// Returns a value that indicates whether page has a back button.
- /// </summary>
- /// <param name="page">The page to be checked</param>
- /// <returns>true if the page has a back button.</returns>
- public static bool GetHasBackButton(Page page)
- {
- if (page == null)
- throw new ArgumentNullException("page");
- return (bool)page.GetValue(HasBackButtonProperty);
- }
-
- /// <summary>
- /// Returns a value that indicates whether the page has a navigation bar.
- /// </summary>
- /// <param name="page">The Page being queried.</param>
- /// <returns>true if page would display a navigation bar were it the CurrentPage.</returns>
- public static bool GetHasNavigationBar(BindableObject page)
- {
- return (bool)page.GetValue(HasNavigationBarProperty);
- }
-
- internal static FileImageSource GetTitleIcon(BindableObject bindable)
- {
- return (FileImageSource)bindable.GetValue(TitleIconProperty);
- }
-
- /// <summary>
- /// Asynchronously removes the top Page from the navigation stack.
- /// </summary>
- /// <returns>The Page that had been at the top of the navigation stack.</returns>
- public Task<Page> PopAsync()
- {
- return PopAsync(true);
- }
-
- /// <summary>
- /// Asynchronously removes the top Page from the navigation stack, with optional animation.
- /// </summary>
- /// <param name="animated">Whether to animate the pop.</param>
- /// <returns>The Page that had been at the top of the navigation stack.</returns>
- public async Task<Page> PopAsync(bool animated)
- {
- var tcs = new TaskCompletionSource<bool>();
- if (CurrentNavigationTask != null && !CurrentNavigationTask.IsCompleted)
- {
- var oldTask = CurrentNavigationTask;
- CurrentNavigationTask = tcs.Task;
- await oldTask;
- }
- else
- CurrentNavigationTask = tcs.Task;
-
- var result = await PopAsyncInner(animated, false);
- tcs.SetResult(true);
- return result;
- }
-
- /// <summary>
- /// Event that is raised after a page is popped from this NavigationPage element.
- /// </summary>
- public event EventHandler<NavigationEventArgs> Popped;
-
- /// <summary>
- /// Event that is raised when the last nonroot element is popped from this NavigationPage element.
- /// </summary>
- public event EventHandler<NavigationEventArgs> PoppedToRoot;
-
- /// <summary>
- /// Pops all but the root Page off the navigation stack.
- /// </summary>
- /// <returns>A task that represents the asynchronous dismiss operation.</returns>
- public Task PopToRootAsync()
- {
- return PopToRootAsync(true);
- }
-
- /// <summary>
- /// A task for asynchronously popping all pages off of the navigation stack.
- /// </summary>
- /// <param name="animated">Whether to animate the pop.</param>
- /// <returns>A task that represents the asynchronous dismiss operation.</returns>
- public async Task PopToRootAsync(bool animated)
- {
- if (CurrentNavigationTask != null && !CurrentNavigationTask.IsCompleted)
- {
- var tcs = new TaskCompletionSource<bool>();
- Task oldTask = CurrentNavigationTask;
- CurrentNavigationTask = tcs.Task;
- await oldTask;
-
- await PopToRootAsyncInner(animated);
- tcs.SetResult(true);
- return;
- }
-
- Task result = PopToRootAsyncInner(animated);
- CurrentNavigationTask = result;
- await result;
- }
-
- /// <summary>
- /// Presents a Page modally.
- /// </summary>
- /// <param name="page">The Page to present modally.</param>
- /// <returns>An awaitable Task, indicating the PushModal completion.</returns>
- public Task PushAsync(Page page)
- {
- return PushAsync(page, true);
- }
-
- /// <summary>
- /// A task for asynchronously pushing a page onto the navigation stack, with optional animation.
- /// </summary>
- /// <param name="page">The Page to present modally.</param>
- /// <param name="animated">Whether to animate the pop.</param>
- /// <returns>An awaitable Task, indicating the PushModal completion.</returns>
- public async Task PushAsync(Page page, bool animated)
- {
- if (CurrentNavigationTask != null && !CurrentNavigationTask.IsCompleted)
- {
- var tcs = new TaskCompletionSource<bool>();
- Task oldTask = CurrentNavigationTask;
- CurrentNavigationTask = tcs.Task;
- await oldTask;
-
- await PushAsyncInner(page, animated);
- tcs.SetResult(true);
- return;
- }
-
- CurrentNavigationTask = PushAsyncInner(page, animated);
- await CurrentNavigationTask;
- }
-
- /// <summary>
- /// Event that is raised when a page is pushed onto this NavigationPage element.
- /// </summary>
- public event EventHandler<NavigationEventArgs> Pushed;
-
- /// <summary>
- /// Sets the title that appears on the back button for page.
- /// </summary>
- /// <param name="page">The BindableObject object.</param>
- /// <param name="value">The value to set.</param>
- public static void SetBackButtonTitle(BindableObject page, string value)
- {
- page.SetValue(BackButtonTitleProperty, value);
- }
-
- /// <summary>
- /// Adds or removes a back button to page, with optional animation.
- /// </summary>
- /// <param name="page">The page object.</param>
- /// <param name="value">The value to set.</param>
- public static void SetHasBackButton(Page page, bool value)
- {
- if (page == null)
- throw new ArgumentNullException("page");
- page.SetValue(HasBackButtonProperty, value);
- }
-
- /// <summary>
- /// Sets a value that indicates whether or not this NavigationPage element has a navigation bar.
- /// </summary>
- /// <param name="page">The BindableObject object</param>
- /// <param name="value">The value to set</param>
- public static void SetHasNavigationBar(BindableObject page, bool value)
- {
- page.SetValue(HasNavigationBarProperty, value);
- }
-
- internal static void SetTitleIcon(BindableObject bindable, FileImageSource value)
- {
- bindable.SetValue(TitleIconProperty, value);
- }
-
- /// <summary>
- /// Event that is raised when the hardware back button is pressed.
- /// </summary>
- /// <returns>true if consumed</returns>
- protected override bool OnBackButtonPressed()
- {
- if (CurrentPage.SendBackButtonPressed())
- return true;
-
- if (StackDepth > 1)
- {
- SafePop();
- return true;
- }
-
- return base.OnBackButtonPressed();
- }
-
- /// <summary>
- /// For internal use
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public event EventHandler<NavigationRequestedEventArgs> InsertPageBeforeRequested;
-
- /// <summary>
- /// For internal use
- /// </summary>
- /// <param name="animated">Whether animate the pop.</param>
- /// <param name="fast"></param>
- /// <returns>A task that represents the asynchronous dismiss operation.</returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public async Task<Page> PopAsyncInner(bool animated, bool fast)
- {
- if (StackDepth == 1)
- {
- return null;
- }
-
- var page = (Page)InternalChildren.Last();
-
- return await (this as INavigationPageController).RemoveAsyncInner(page, animated, fast);
- }
-
- async Task<Page> INavigationPageController.RemoveAsyncInner(Page page, bool animated, bool fast)
- {
- if (StackDepth == 1)
- {
- return null;
- }
-
- var args = new NavigationRequestedEventArgs(page, animated);
-
- var removed = true;
-
- EventHandler<NavigationRequestedEventArgs> requestPop = PopRequested;
- if (requestPop != null)
- {
- requestPop(this, args);
-
- if (args.Task != null && !fast)
- removed = await args.Task;
- }
-
- if (!removed && !fast)
- return CurrentPage;
-
- InternalChildren.Remove(page);
-
- CurrentPage = (Page)InternalChildren.Last();
-
- if (Popped != null)
- Popped(this, args);
-
- return page;
- }
-
- /// <summary>
- /// For internal use.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public event EventHandler<NavigationRequestedEventArgs> PopRequested;
-
- /// <summary>
- /// For internal use.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public event EventHandler<NavigationRequestedEventArgs> PopToRootRequested;
-
- /// <summary>
- /// For internal use.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public event EventHandler<NavigationRequestedEventArgs> PushRequested;
-
- /// <summary>
- /// For internal use.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public event EventHandler<NavigationRequestedEventArgs> RemovePageRequested;
-
- void InsertPageBefore(Page page, Page before)
- {
- if (page == null)
- throw new ArgumentNullException($"{nameof(page)} cannot be null.");
-
- if (before == null)
- throw new ArgumentNullException($"{nameof(before)} cannot be null.");
-
- if (!InternalChildren.Contains(before))
- throw new ArgumentException($"{nameof(before)} must be a child of the NavigationPage", nameof(before));
-
- if (InternalChildren.Contains(page))
- throw new ArgumentException("Cannot insert page which is already in the navigation stack");
-
- EventHandler<NavigationRequestedEventArgs> handler = InsertPageBeforeRequested;
- handler?.Invoke(this, new NavigationRequestedEventArgs(page, before, false));
-
- int index = InternalChildren.IndexOf(before);
- InternalChildren.Insert(index, page);
-
- if (index == 0)
- RootPage = page;
-
- // Shouldn't be required?
- // if (Width > 0 && Height > 0)
- ForceLayout();
- }
-
- async Task PopToRootAsyncInner(bool animated)
- {
- if (StackDepth == 1)
- return;
-
- Element[] childrenToRemove = InternalChildren.Skip(1).ToArray();
- foreach (Element child in childrenToRemove)
- InternalChildren.Remove(child);
-
- CurrentPage = RootPage;
-
- var args = new NavigationRequestedEventArgs(RootPage, animated);
-
- EventHandler<NavigationRequestedEventArgs> requestPopToRoot = PopToRootRequested;
- if (requestPopToRoot != null)
- {
- requestPopToRoot(this, args);
-
- if (args.Task != null)
- await args.Task;
- }
-
- // PoppedToRoot?.Invoke(this, new PoppedToRootEventArgs(RootPage, childrenToRemove.OfType<Page>().ToList()));
- }
-
- async Task PushAsyncInner(Page page, bool animated)
- {
- if (InternalChildren.Contains(page))
- return;
-
- PushPage(page);
-
- var args = new NavigationRequestedEventArgs(page, animated);
-
- EventHandler<NavigationRequestedEventArgs> requestPush = PushRequested;
- if (requestPush != null)
- {
- requestPush(this, args);
-
- if (args.Task != null)
- await args.Task;
- }
-
- Pushed?.Invoke(this, args);
- }
-
- void PushPage(Page page)
- {
- InternalChildren.Add(page);
-
- if (InternalChildren.Count == 1)
- RootPage = page;
-
- CurrentPage = page;
- }
-
- void RemovePage(Page page)
- {
- if (page == null)
- throw new ArgumentNullException($"{nameof(page)} cannot be null.");
-
- if (page == CurrentPage && CurrentPage == RootPage)
- throw new InvalidOperationException("Cannot remove root page when it is also the currently displayed page.");
- if (page == CurrentPage)
- {
- // Log.Warning("NavigationPage", "RemovePage called for CurrentPage object. This can result in undesired behavior, consider calling PopAsync instead.");
- PopAsync();
- return;
- }
-
- if (!InternalChildren.Contains(page))
- throw new ArgumentException("Page to remove must be contained on this Navigation Page");
-
- EventHandler<NavigationRequestedEventArgs> handler = RemovePageRequested;
- handler?.Invoke(this, new NavigationRequestedEventArgs(page, true));
-
- InternalChildren.Remove(page);
- if (RootPage == page)
- RootPage = (Page)InternalChildren.First();
- }
-
- void SafePop()
- {
- PopAsync(true).ContinueWith(t =>
- {
- if (t.IsFaulted)
- throw t.Exception;
- });
- }
-
- class NavigationImpl : NavigationProxy
- {
- // readonly Lazy<ReadOnlyCastingList<Page, Element>> _castingList;
-
- public NavigationImpl(NavigationPage owner)
- {
- Owner = owner;
- // _castingList = new Lazy<ReadOnlyCastingList<Page, Element>>(() => new ReadOnlyCastingList<Page, Element>(Owner.InternalChildren));
- }
-
- NavigationPage Owner { get; }
-
- protected override IReadOnlyList<Page> GetNavigationStack()
- {
- // return _castingList.Value;
- return null;
- }
-
- protected override void OnInsertPageBefore(Page page, Page before)
- {
- Owner.InsertPageBefore(page, before);
- }
-
- protected override Task<Page> OnPopAsync(bool animated)
- {
- return Owner.PopAsync(animated);
- }
-
- protected override Task OnPopToRootAsync(bool animated)
- {
- return Owner.PopToRootAsync(animated);
- }
-
- protected override Task OnPushAsync(Page root, bool animated)
- {
- return Owner.PushAsync(root, animated);
- }
-
- protected override void OnRemovePage(Page page)
- {
- Owner.RemovePage(page);
- }
- }
-
- readonly Lazy<PlatformConfigurationRegistry<NavigationPage>> _platformConfigurationRegistry;
-
- /// <summary>
- /// Returns the platform-specific instance of this NavigationPage, on which a platform-specific method may be called.
- /// </summary>
- /// <typeparam name="T">The platform for which to return an instance.</typeparam>
- /// <returns>The platform-specific instance of this NavigationPage</returns>
- public new IPlatformElementConfiguration<T, NavigationPage> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
- }
-}
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Tizen.NUI.Internals;
+using Tizen.NUI.Binding.Internals;
using Tizen.NUI.Binding;
namespace Tizen.NUI
// [RenderWith(typeof(_PageRenderer))]
[EditorBrowsable(EditorBrowsableState.Never)]
public class Page : /*VisualElement*/BaseHandle, ILayout, IPageController, IElementConfiguration<Page>, IPaddingElement
- {
+ {
/// <summary>
/// For internal use.
/// </summary>
- public const string BusySetSignalName = "Xamarin.BusySet";
+ /// 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 const string BusySetSignalName = "NUI.BusySet";
/// <summary>
/// For internal use.
/// </summary>
- public const string AlertSignalName = "Xamarin.SendAlert";
+ /// 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 const string AlertSignalName = "NUI.SendAlert";
/// <summary>
/// For internal use.
/// </summary>
- public const string ActionSheetSignalName = "Xamarin.ShowActionSheet";
+ /// 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 const string ActionSheetSignalName = "NUI.ShowActionSheet";
- internal static readonly BindableProperty IgnoresContainerAreaProperty = BindableProperty.Create("IgnoresContainerArea", typeof(bool), typeof(Page), false);
+ internal static readonly BindableProperty IgnoresContainerAreaProperty = BindableProperty.Create("IgnoresContainerArea", typeof(bool), typeof(Page), false);
/// <summary>
/// Identifies the BackgroundImage property.
/// </summary>
- public static readonly BindableProperty BackgroundImageProperty = BindableProperty.Create("BackgroundImage", typeof(string), typeof(Page), default(string));
+ internal static readonly BindableProperty BackgroundImageProperty = BindableProperty.Create("BackgroundImage", typeof(string), typeof(Page), default(string));
/// <summary>
/// Identifies the IsBusy property.
/// </summary>
- public static readonly BindableProperty IsBusyProperty = BindableProperty.Create("IsBusy", typeof(bool), typeof(Page), false, propertyChanged: (bo, o, n) => ((Page)bo).OnPageBusyChanged());
+ internal static readonly BindableProperty IsBusyProperty = BindableProperty.Create("IsBusy", typeof(bool), typeof(Page), false, propertyChanged: (bo, o, n) => ((Page)bo).OnPageBusyChanged());
/// <summary>
/// Identifies the Padding property.
/// </summary>
- public static readonly BindableProperty PaddingProperty = PaddingElement.PaddingProperty;
+ internal static readonly BindableProperty PaddingProperty = PaddingElement.PaddingProperty;
/// <summary>
/// Identifies the Title property.
/// </summary>
- public static readonly BindableProperty TitleProperty = BindableProperty.Create("Title", typeof(string), typeof(Page), null);
+ internal static readonly BindableProperty TitleProperty = BindableProperty.Create("Title", typeof(string), typeof(Page), null);
/// <summary>
/// Identifies the Icon property.
/// </summary>
- public static readonly BindableProperty IconProperty = BindableProperty.Create("Icon", typeof(FileImageSource), typeof(Page), default(FileImageSource));
+ internal static readonly BindableProperty IconProperty = BindableProperty.Create("Icon", typeof(FileImageSource), typeof(Page), default(FileImageSource));
- readonly Lazy<PlatformConfigurationRegistry<Page>> _platformConfigurationRegistry;
+ readonly Lazy<PlatformConfigurationRegistry<Page>> _platformConfigurationRegistry;
- bool _allocatedFlag;
- Rectangle _containerArea;
+ bool _allocatedFlag;
+ Rectangle _containerArea;
- bool _containerAreaSet;
+ bool _containerAreaSet;
- bool _hasAppeared;
+ bool _hasAppeared;
- ReadOnlyCollection<Element> _logicalChildren;
+ ReadOnlyCollection<Element> _logicalChildren;
/// <summary>
/// Creates a new Page element with default values.
/// </summary>
- public Page()
- {
- var toolbarItems = new ObservableCollection<ToolbarItem>();
- toolbarItems.CollectionChanged += OnToolbarItemsCollectionChanged;
- // ToolbarItems = toolbarItems;
- InternalChildren.CollectionChanged += InternalChildrenOnCollectionChanged;
- _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Page>>(() => new PlatformConfigurationRegistry<Page>(this));
- }
+ /// 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 Page()
+ {
+ var toolbarItems = new ObservableCollection<ToolbarItem>();
+ toolbarItems.CollectionChanged += OnToolbarItemsCollectionChanged;
+ // ToolbarItems = toolbarItems;
+ InternalChildren.CollectionChanged += InternalChildrenOnCollectionChanged;
+ _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Page>>(() => new PlatformConfigurationRegistry<Page>(this));
+ }
/// <summary>
/// Identifies the image used as a background for the Page.
/// </summary>
- public string BackgroundImage
- {
- get { return (string)GetValue(BackgroundImageProperty); }
- set { SetValue(BackgroundImageProperty, value); }
- }
+ /// 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 BackgroundImage
+ {
+ get { return (string)GetValue(BackgroundImageProperty); }
+ set { SetValue(BackgroundImageProperty, value); }
+ }
- internal FileImageSource Icon
- {
- get { return (FileImageSource)GetValue(IconProperty); }
- set { SetValue(IconProperty, value); }
- }
+ internal FileImageSource Icon
+ {
+ get { return (FileImageSource)GetValue(IconProperty); }
+ set { SetValue(IconProperty, value); }
+ }
/// <summary>
/// Marks the Page as busy. This will cause the platform specific global activity indicator to show a busy state.
/// </summary>
- public bool IsBusy
- {
- get { return (bool)GetValue(IsBusyProperty); }
- set { SetValue(IsBusyProperty, value); }
- }
+ /// 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 bool IsBusy
+ {
+ get { return (bool)GetValue(IsBusyProperty); }
+ set { SetValue(IsBusyProperty, value); }
+ }
/// <summary>
/// The space between the content of the Page and it's border.
/// </summary>
- public Thickness Padding
- {
- get { return (Thickness)GetValue(PaddingElement.PaddingProperty); }
- set { SetValue(PaddingElement.PaddingProperty, value); }
- }
+ internal Thickness Padding
+ {
+ get { return (Thickness)GetValue(PaddingElement.PaddingProperty); }
+ set { SetValue(PaddingElement.PaddingProperty, value); }
+ }
- Thickness IPaddingElement.PaddingDefaultValueCreator()
- {
- return default(Thickness);
- }
+ Thickness IPaddingElement.PaddingDefaultValueCreator()
+ {
+ return default(Thickness);
+ }
- void IPaddingElement.OnPaddingPropertyChanged(Thickness oldValue, Thickness newValue)
- {
- UpdateChildrenLayout();
- }
+ void IPaddingElement.OnPaddingPropertyChanged(Thickness oldValue, Thickness newValue)
+ {
+ UpdateChildrenLayout();
+ }
/// <summary>
/// The Page's title.
/// </summary>
- public string Title
- {
- get { return (string)GetValue(TitleProperty); }
- set { SetValue(TitleProperty, value); }
- }
+ /// 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 Title
+ {
+ get { return (string)GetValue(TitleProperty); }
+ set { SetValue(TitleProperty, value); }
+ }
- internal IList<ToolbarItem> ToolbarItems { get;/* internal set;*/ }
+ internal IList<ToolbarItem> ToolbarItems { get;/* internal set;*/ }
/// <summary>
/// For internal use.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public Rectangle ContainerArea
- {
- get { return _containerArea; }
- set
- {
- if (_containerArea == value)
- return;
- _containerAreaSet = true;
- _containerArea = value;
- ForceLayout();
- }
- }
+ {
+ get { return _containerArea; }
+ set
+ {
+ if (_containerArea == value)
+ return;
+ _containerAreaSet = true;
+ _containerArea = value;
+ ForceLayout();
+ }
+ }
/// <summary>
/// For internal use.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IgnoresContainerArea
- {
- get { return (bool)GetValue(IgnoresContainerAreaProperty); }
- set { SetValue(IgnoresContainerAreaProperty, value); }
- }
+ {
+ get { return (bool)GetValue(IgnoresContainerAreaProperty); }
+ set { SetValue(IgnoresContainerAreaProperty, value); }
+ }
/// <summary>
/// For internal use.
[EditorBrowsable(EditorBrowsableState.Never)]
public ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
- internal override ReadOnlyCollection<Element> LogicalChildrenInternal =>
- _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren));
+ internal override ReadOnlyCollection<Element> LogicalChildrenInternal =>
+ _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren));
/// <summary>
/// Raised when the layout of the Page has changed.
/// </summary>
- public event EventHandler LayoutChanged;
+ /// 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 event EventHandler LayoutChanged;
/// <summary>
/// ndicates that the Page is about to appear.
/// </summary>
- public event EventHandler Appearing;
+ /// 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 event EventHandler Appearing;
/// <summary>
/// Indicates that the Page is about to cease displaying.
/// </summary>
- public event EventHandler Disappearing;
+ /// 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 event EventHandler Disappearing;
/// <summary>
/// Displays a native platform action sheet, allowing the application user to choose from several buttons.
/// <param name="destruction">Text to be displayed in the 'Destruct' button. Can be null to hide the destructive option.</param>
/// <param name="buttons">Text labels for additional buttons. Must not be null.</param>
/// <returns>An awaitable Task that displays an action sheet and returns the Text of the button pressed by the user.</returns>
- public Task<string> DisplayActionSheet(string title, string cancel, string destruction, params string[] buttons)
- {
- var args = new ActionSheetArguments(title, cancel, destruction, buttons);
- MessagingCenter.Send(this, ActionSheetSignalName, args);
- return args.Result.Task;
- }
+ /// 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 Task<string> DisplayActionSheet(string title, string cancel, string destruction, params string[] buttons)
+ {
+ var args = new ActionSheetArguments(title, cancel, destruction, buttons);
+ MessagingCenter.Send(this, ActionSheetSignalName, args);
+ return args.Result.Task;
+ }
/// <summary>
/// Presents an alert dialog to the application user with a single cancel button.
/// <param name="message">The body text of the alert dialog.</param>
/// <param name="cancel">Text to be displayed on the 'Cancel' button.</param>
/// <returns></returns>
- public Task DisplayAlert(string title, string message, string cancel)
- {
- return DisplayAlert(title, message, null, cancel);
- }
+ /// 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 Task DisplayAlert(string title, string message, string cancel)
+ {
+ return DisplayAlert(title, message, null, cancel);
+ }
/// <summary>
/// resents an alert dialog to the application user with an accept and a cancel button.
/// <param name="accept">Text to be displayed on the 'Accept' button.</param>
/// <param name="cancel">Text to be displayed on the 'Cancel' button.</param>
/// <returns></returns>
- public Task<bool> DisplayAlert(string title, string message, string accept, string cancel)
- {
- if (string.IsNullOrEmpty(cancel))
- throw new ArgumentNullException("cancel");
+ /// 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 Task<bool> DisplayAlert(string title, string message, string accept, string cancel)
+ {
+ if (string.IsNullOrEmpty(cancel))
+ throw new ArgumentNullException("cancel");
- var args = new AlertArguments(title, message, accept, cancel);
- MessagingCenter.Send(this, AlertSignalName, args);
- return args.Result.Task;
- }
+ var args = new AlertArguments(title, message, accept, cancel);
+ MessagingCenter.Send(this, AlertSignalName, args);
+ return args.Result.Task;
+ }
/// <summary>
/// Forces the Page to perform a layout pass.
/// </summary>
- public void ForceLayout()
- {
- // SizeAllocated(Width, Height);
- }
+ /// 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 void ForceLayout()
+ {
+ // SizeAllocated(Width, Height);
+ }
/// <summary>
/// Calls OnBackButtonPressed().
/// </summary>
/// <returns></returns>
- public bool SendBackButtonPressed()
- {
- return OnBackButtonPressed();
- }
+ /// 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 bool SendBackButtonPressed()
+ {
+ return OnBackButtonPressed();
+ }
/// <summary>
/// Lays out children Elements into the specified area.
/// <param name="y">Top of layout area.</param>
/// <param name="width">Width of layout area.</param>
/// <param name="height">Height of layout area.</param>
- protected virtual void LayoutChildren(double x, double y, double width, double height)
- {
- var area = new Rectangle((int)x, (int)y, (int)width, (int)height);
- Rectangle originalArea = area;
- if (_containerAreaSet)
- {
- area = ContainerArea;
- area.X += (int)Padding.Left;
- area.Y += (int)Padding.Right;
- area.Width -= (int)Padding.HorizontalThickness;
- area.Height -= (int)Padding.VerticalThickness;
- area.Width = Math.Max(0, area.Width);
- area.Height = Math.Max(0, area.Height);
- }
-
- List<Element> elements = LogicalChildren.ToList();
- foreach (Element element in elements)
- {
- var child = element as /*VisualElement*/BaseHandle;
- if (child == null)
- continue;
- var page = child as Page;
- // if (page != null && page.IgnoresContainerArea)
- // Forms.Layout.LayoutChildIntoBoundingRegion(child, originalArea);
- // else
- // Forms.Layout.LayoutChildIntoBoundingRegion(child, area);
- }
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void LayoutChildren(double x, double y, double width, double height)
+ {
+ var area = new Rectangle((int)x, (int)y, (int)width, (int)height);
+ Rectangle originalArea = area;
+ if (_containerAreaSet)
+ {
+ area = ContainerArea;
+ area.X += (int)Padding.Left;
+ area.Y += (int)Padding.Right;
+ area.Width -= (int)Padding.HorizontalThickness;
+ area.Height -= (int)Padding.VerticalThickness;
+ area.Width = Math.Max(0, area.Width);
+ area.Height = Math.Max(0, area.Height);
+ }
+
+ List<Element> elements = LogicalChildren.ToList();
+ foreach (Element element in elements)
+ {
+ var child = element as /*VisualElement*/BaseHandle;
+ if (child == null)
+ continue;
+ var page = child as Page;
+ // if (page != null && page.IgnoresContainerArea)
+ // Forms.Layout.LayoutChildIntoBoundingRegion(child, originalArea);
+ // else
+ // Forms.Layout.LayoutChildIntoBoundingRegion(child, area);
+ }
+ }
/// <summary>
/// When overridden, allows application developers to customize behavior immediately prior to the Page becoming visible.
/// </summary>
- protected virtual void OnAppearing()
- {
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnAppearing()
+ {
+ }
/// <summary>
/// Application developers can override this method to provide behavior when the back button is pressed.
/// </summary>
/// <returns>true if consumed</returns>
- protected virtual bool OnBackButtonPressed()
- {
- var application = RealParent as Application;
- // if (application == null || this == application.MainPage)
- // return false;
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual bool OnBackButtonPressed()
+ {
+ var application = RealParent as Application;
+ // if (application == null || this == application.MainPage)
+ // return false;
- var canceled = false;
- EventHandler handler = (sender, args) => { canceled = true; };
- // application.PopCanceled += handler;
- Navigation.PopModalAsync().ContinueWith(t => { throw t.Exception; }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());
+ var canceled = false;
+ EventHandler handler = (sender, args) => { canceled = true; };
+ // application.PopCanceled += handler;
+ Navigation.PopModalAsync().ContinueWith(t => { throw t.Exception; }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());
- // application.PopCanceled -= handler;
- return !canceled;
- }
+ // application.PopCanceled -= handler;
+ return !canceled;
+ }
/// <summary>
/// Invoked whenever the binding context of the Page changes. Override this method to add class handling for this event.
/// </summary>
- protected override void OnBindingContextChanged()
- {
- base.OnBindingContextChanged();
- foreach (ToolbarItem toolbarItem in ToolbarItems)
- {
- SetInheritedBindingContext(toolbarItem, BindingContext);
- }
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void OnBindingContextChanged()
+ {
+ base.OnBindingContextChanged();
+ // foreach (ToolbarItem toolbarItem in ToolbarItems)
+ // {
+ // SetInheritedBindingContext(toolbarItem, BindingContext);
+ // }
+ }
/// <summary>
/// Indicates that the preferred size of a child Element has changed.
/// </summary>
/// <param name="sender">The object that raised the event.</param>
/// <param name="e">The event arguments.</param>
- protected virtual void OnChildMeasureInvalidated(object sender, EventArgs e)
- {
- InvalidationTrigger trigger = (e as InvalidationEventArgs)?.Trigger ?? InvalidationTrigger.Undefined;
- OnChildMeasureInvalidated((/*VisualElement*/BaseHandle)sender, trigger);
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnChildMeasureInvalidated(object sender, EventArgs e)
+ {
+ InvalidationTrigger trigger = (e as InvalidationEventArgs)?.Trigger ?? InvalidationTrigger.Undefined;
+ OnChildMeasureInvalidated((/*VisualElement*/BaseHandle)sender, trigger);
+ }
/// <summary>
/// When overridden, allows the application developer to customize behavior as the Page disappears.
/// </summary>
- protected virtual void OnDisappearing()
- {
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected virtual void OnDisappearing()
+ {
+ }
/// <summary>
/// Called when the Page's Parent property has changed.
/// </summary>
- protected override void OnParentSet()
- {
- //if (!Application.IsApplicationOrNull(RealParent) && !(RealParent is Page))
- // throw new InvalidOperationException("Parent of a Page must also be a Page");
- base.OnParentSet();
- }
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void OnParentSet()
+ {
+ //if (!Application.IsApplicationOrNull(RealParent) && !(RealParent is Page))
+ // throw new InvalidOperationException("Parent of a Page must also be a Page");
+ base.OnParentSet();
+ }
///// <summary>
///// Indicates that the Page has been assigned a size.
/// <summary>
/// Requests that the children Elements of the Page update their layouts.
/// </summary>
+ /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
protected void UpdateChildrenLayout()
- {
- if (!ShouldLayoutChildren())
- return;
-
- var startingLayout = new List<Rectangle>(LogicalChildren.Count);
- foreach (/*VisualElement*/BaseHandle c in LogicalChildren)
- {
- //startingLayout.Add(c.Bounds);
- }
-
- double x = Padding.Left;
- double y = Padding.Top;
- //double w = Math.Max(0, Width - Padding.HorizontalThickness);
- //double h = Math.Max(0, Height - Padding.VerticalThickness);
-
- //LayoutChildren(x, y, w, h);
-
- for (var i = 0; i < LogicalChildren.Count; i++)
- {
- var c = (/*VisualElement*/BaseHandle)LogicalChildren[i];
-
- // if (c.Bounds != startingLayout[i])
- // {
- // LayoutChanged?.Invoke(this, EventArgs.Empty);
- // return;
- // }
- }
- }
-
- internal virtual void OnChildMeasureInvalidated(/*VisualElement*/BaseHandle child, InvalidationTrigger trigger)
- {
- var container = this as IPageContainer<Page>;
- if (container != null)
- {
- Page page = container.CurrentPage;
- if (page != null /*&& page.IsVisible && (!page.IsPlatformEnabled || !page.IsNativeStateConsistent)*/)
- return;
- }
- else
- {
- for (var i = 0; i < LogicalChildren.Count; i++)
- {
- var v = LogicalChildren[i] as /*VisualElement*/BaseHandle;
- if (v != null /*&& v.IsVisible && (!v.IsPlatformEnabled || !v.IsNativeStateConsistent)*/)
- return;
- }
- }
-
- _allocatedFlag = false;
- // InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
- if (!_allocatedFlag /*&& Width >= 0 && Height >= 0*/)
- {
- // SizeAllocated(Width, Height);
- }
- }
+ {
+ if (!ShouldLayoutChildren())
+ return;
+
+ var startingLayout = new List<Rectangle>(LogicalChildren.Count);
+ foreach (/*VisualElement*/BaseHandle c in LogicalChildren)
+ {
+ //startingLayout.Add(c.Bounds);
+ }
+
+ double x = Padding.Left;
+ double y = Padding.Top;
+ //double w = Math.Max(0, Width - Padding.HorizontalThickness);
+ //double h = Math.Max(0, Height - Padding.VerticalThickness);
+
+ //LayoutChildren(x, y, w, h);
+
+ for (var i = 0; i < LogicalChildren.Count; i++)
+ {
+ var c = (/*VisualElement*/BaseHandle)LogicalChildren[i];
+
+ // if (c.Bounds != startingLayout[i])
+ // {
+ // LayoutChanged?.Invoke(this, EventArgs.Empty);
+ // return;
+ // }
+ }
+ }
+
+ internal virtual void OnChildMeasureInvalidated(/*VisualElement*/BaseHandle child, InvalidationTrigger trigger)
+ {
+ var container = this as IPageContainer<Page>;
+ if (container != null)
+ {
+ Page page = container.CurrentPage;
+ if (page != null /*&& page.IsVisible && (!page.IsPlatformEnabled || !page.IsNativeStateConsistent)*/)
+ return;
+ }
+ else
+ {
+ for (var i = 0; i < LogicalChildren.Count; i++)
+ {
+ var v = LogicalChildren[i] as /*VisualElement*/BaseHandle;
+ if (v != null /*&& v.IsVisible && (!v.IsPlatformEnabled || !v.IsNativeStateConsistent)*/)
+ return;
+ }
+ }
+
+ _allocatedFlag = false;
+ // InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
+ if (!_allocatedFlag /*&& Width >= 0 && Height >= 0*/)
+ {
+ // SizeAllocated(Width, Height);
+ }
+ }
/// <summary>
/// For intarnal use.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void SendAppearing()
- {
- if (_hasAppeared)
- return;
+ {
+ if (_hasAppeared)
+ return;
- _hasAppeared = true;
+ _hasAppeared = true;
- if (IsBusy)
- MessagingCenter.Send(this, BusySetSignalName, true);
+ if (IsBusy)
+ MessagingCenter.Send(this, BusySetSignalName, true);
- OnAppearing();
- Appearing?.Invoke(this, EventArgs.Empty);
+ OnAppearing();
+ Appearing?.Invoke(this, EventArgs.Empty);
- var pageContainer = this as IPageContainer<Page>;
- pageContainer?.CurrentPage?.SendAppearing();
+ var pageContainer = this as IPageContainer<Page>;
+ pageContainer?.CurrentPage?.SendAppearing();
- //FindApplication(this)?.OnPageAppearing(this);
- }
+ //FindApplication(this)?.OnPageAppearing(this);
+ }
/// <summary>
/// For intarnal use.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void SendDisappearing()
- {
- if (!_hasAppeared)
- return;
-
- _hasAppeared = false;
-
- if (IsBusy)
- MessagingCenter.Send(this, BusySetSignalName, false);
-
- var pageContainer = this as IPageContainer<Page>;
- pageContainer?.CurrentPage?.SendDisappearing();
-
- OnDisappearing();
- Disappearing?.Invoke(this, EventArgs.Empty);
-
- //FindApplication(this)?.OnPageDisappearing(this);
- }
-
- Application FindApplication(Element element)
- {
- if (element == null)
- return null;
-
- return (element.Parent is Application app) ? app : FindApplication(element.Parent);
- }
-
- void InternalChildrenOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- if (e.OldItems != null)
- {
- foreach (/*VisualElement*/BaseHandle item in e.OldItems.OfType</*VisualElement*/BaseHandle>())
- OnInternalRemoved(item);
- }
-
- if (e.NewItems != null)
- {
- foreach (/*VisualElement*/BaseHandle item in e.NewItems.OfType</*VisualElement*/BaseHandle>())
- OnInternalAdded(item);
- }
- }
-
- void OnInternalAdded(/*VisualElement*/BaseHandle view)
- {
- // view.MeasureInvalidated += OnChildMeasureInvalidated;
-
- OnChildAdded(view);
- // InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
- }
-
- void OnInternalRemoved(/*VisualElement*/BaseHandle view)
- {
- // view.MeasureInvalidated -= OnChildMeasureInvalidated;
-
- OnChildRemoved(view);
- }
-
- void OnPageBusyChanged()
- {
- if (!_hasAppeared)
- return;
-
- MessagingCenter.Send(this, BusySetSignalName, IsBusy);
- }
-
- void OnToolbarItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
- {
- if (args.Action != NotifyCollectionChangedAction.Add)
- return;
- foreach (IElement item in args.NewItems)
- item.Parent = this;
- }
-
- bool ShouldLayoutChildren()
- {
- if (!LogicalChildren.Any()/* || Width <= 0 || Height <= 0 || !IsNativeStateConsistent*/)
- return false;
-
- var container = this as IPageContainer<Page>;
- if (container?.CurrentPage != null)
- {
- // if (InternalChildren.Contains(container.CurrentPage))
- // return container.CurrentPage.IsPlatformEnabled && container.CurrentPage.IsNativeStateConsistent;
- return true;
- }
-
- var any = false;
- for (var i = 0; i < LogicalChildren.Count; i++)
- {
- var v = LogicalChildren[i] as /*VisualElement*/BaseHandle;
- if (v != null /*&& (!v.IsPlatformEnabled || !v.IsNativeStateConsistent)*/)
- {
- any = true;
- break;
- }
- }
- return !any;
- }
+ {
+ if (!_hasAppeared)
+ return;
+
+ _hasAppeared = false;
+
+ if (IsBusy)
+ MessagingCenter.Send(this, BusySetSignalName, false);
+
+ var pageContainer = this as IPageContainer<Page>;
+ pageContainer?.CurrentPage?.SendDisappearing();
+
+ OnDisappearing();
+ Disappearing?.Invoke(this, EventArgs.Empty);
+
+ //FindApplication(this)?.OnPageDisappearing(this);
+ }
+
+ Application FindApplication(Element element)
+ {
+ if (element == null)
+ return null;
+
+ return (element.Parent is Application app) ? app : FindApplication(element.Parent);
+ }
+
+ void InternalChildrenOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ if (e.OldItems != null)
+ {
+ foreach (/*VisualElement*/BaseHandle item in e.OldItems.OfType</*VisualElement*/BaseHandle>())
+ OnInternalRemoved(item);
+ }
+
+ if (e.NewItems != null)
+ {
+ foreach (/*VisualElement*/BaseHandle item in e.NewItems.OfType</*VisualElement*/BaseHandle>())
+ OnInternalAdded(item);
+ }
+ }
+
+ void OnInternalAdded(/*VisualElement*/BaseHandle view)
+ {
+ // view.MeasureInvalidated += OnChildMeasureInvalidated;
+
+ OnChildAdded(view);
+ // InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
+ }
+
+ void OnInternalRemoved(/*VisualElement*/BaseHandle view)
+ {
+ // view.MeasureInvalidated -= OnChildMeasureInvalidated;
+
+ OnChildRemoved(view);
+ }
+
+ void OnPageBusyChanged()
+ {
+ if (!_hasAppeared)
+ return;
+
+ MessagingCenter.Send(this, BusySetSignalName, IsBusy);
+ }
+
+ void OnToolbarItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
+ {
+ if (args.Action != NotifyCollectionChangedAction.Add)
+ return;
+ foreach (IElement item in args.NewItems)
+ item.Parent = this;
+ }
+
+ bool ShouldLayoutChildren()
+ {
+ if (!LogicalChildren.Any()/* || Width <= 0 || Height <= 0 || !IsNativeStateConsistent*/)
+ return false;
+
+ var container = this as IPageContainer<Page>;
+ if (container?.CurrentPage != null)
+ {
+ // if (InternalChildren.Contains(container.CurrentPage))
+ // return container.CurrentPage.IsPlatformEnabled && container.CurrentPage.IsNativeStateConsistent;
+ return true;
+ }
+
+ var any = false;
+ for (var i = 0; i < LogicalChildren.Count; i++)
+ {
+ var v = LogicalChildren[i] as /*VisualElement*/BaseHandle;
+ if (v != null /*&& (!v.IsPlatformEnabled || !v.IsNativeStateConsistent)*/)
+ {
+ any = true;
+ break;
+ }
+ }
+ return !any;
+ }
/// <summary>
/// Returns the platform-specific instance of this Page, on which a platform-specific method may be called.
/// </summary>
/// <typeparam name="T">The platform for which to return an instance.</typeparam>
/// <returns>The platform-specific instance of this Page</returns>
- public IPlatformElementConfiguration<T, Page> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
- }
+ internal IPlatformElementConfiguration<T, Page> On<T>() where T : IConfigPlatform
+ {
+ return _platformConfigurationRegistry.Value.On<T>();
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.ComponentModel;
+using System.Globalization;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+using Tizen.NUI.Binding.Internals;
+using Tizen.NUI.Xaml;
+
+namespace Tizen.NUI.Binding
+{
+ /// 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 ResourceDictionary : IResourceDictionary, IDictionary<string, object>
+ {
+ static ConditionalWeakTable<Type, ResourceDictionary> s_instances = new ConditionalWeakTable<Type, ResourceDictionary>();
+ readonly Dictionary<string, object> _innerDictionary = new Dictionary<string, object>();
+ ResourceDictionary _mergedInstance;
+ Type _mergedWith;
+ Uri _source;
+
+ /// 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 ResourceDictionary()
+ {
+ DependencyService.Register<IResourcesLoader, ResourcesLoader>();
+ }
+
+ [TypeConverter(typeof(TypeTypeConverter))]
+ [Obsolete("Use Source")]
+ /// 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 Type MergedWith {
+ get { return _mergedWith; }
+ set {
+ if (_mergedWith == value)
+ return;
+
+ if (_source != null)
+ throw new ArgumentException("MergedWith can not be used with Source");
+
+ if (!typeof(ResourceDictionary).GetTypeInfo().IsAssignableFrom(value.GetTypeInfo()))
+ throw new ArgumentException("MergedWith should inherit from ResourceDictionary");
+
+ _mergedWith = value;
+ if (_mergedWith == null)
+ return;
+
+ _mergedInstance = s_instances.GetValue(_mergedWith, (key) => (ResourceDictionary)Activator.CreateInstance(key));
+ OnValuesChanged(_mergedInstance.ToArray());
+ }
+ }
+
+ [TypeConverter(typeof(RDSourceTypeConverter))]
+ /// 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 Uri Source {
+ get { return _source; }
+ set {
+ if (_source == value)
+ return;
+ throw new InvalidOperationException("Source can only be set from XAML."); //through the RDSourceTypeConverter
+ }
+ }
+
+ //Used by the XamlC compiled converter
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void SetAndLoadSource(Uri value, string resourcePath, Assembly assembly, System.Xml.IXmlLineInfo lineInfo)
+ {
+ _source = value;
+ if (_mergedWith != null)
+ throw new ArgumentException("Source can not be used with MergedWith");
+
+ //this will return a type if the RD as an x:Class element, and codebehind
+ var type = XamlResourceIdAttribute.GetTypeForPath(assembly, resourcePath);
+ if (type != null)
+ _mergedInstance = s_instances.GetValue(type, (key) => (ResourceDictionary)Activator.CreateInstance(key));
+ else
+ _mergedInstance = DependencyService.Get<IResourcesLoader>().CreateFromResource<ResourceDictionary>(resourcePath, assembly, lineInfo);
+ OnValuesChanged(_mergedInstance.ToArray());
+ }
+
+ ICollection<ResourceDictionary> _mergedDictionaries;
+
+ /// 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 ICollection<ResourceDictionary> MergedDictionaries {
+ get {
+ if (_mergedDictionaries == null) {
+ var col = new ObservableCollection<ResourceDictionary>();
+ col.CollectionChanged += MergedDictionaries_CollectionChanged;
+ _mergedDictionaries = col;
+ }
+ return _mergedDictionaries;
+ }
+ }
+
+ internal IList<StyleSheets.StyleSheet> StyleSheets { get; set; }
+
+ void StyleSheetsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ switch (e.Action) {
+ case NotifyCollectionChangedAction.Add:
+ ValuesChanged?.Invoke(this, ResourcesChangedEventArgs.StyleSheets);
+ break;
+ }
+ }
+ IList<ResourceDictionary> _collectionTrack;
+
+ void MergedDictionaries_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ // Move() isn't exposed by ICollection
+ if (e.Action == NotifyCollectionChangedAction.Move)
+ return;
+
+ _collectionTrack = _collectionTrack ?? new List<ResourceDictionary>();
+ // Collection has been cleared
+ if (e.Action == NotifyCollectionChangedAction.Reset) {
+ foreach (var dictionary in _collectionTrack)
+ dictionary.ValuesChanged -= Item_ValuesChanged;
+
+ _collectionTrack.Clear();
+ return;
+ }
+
+ // New Items
+ if (e.NewItems != null)
+ {
+ foreach (var item in e.NewItems)
+ {
+ var rd = (ResourceDictionary)item;
+ _collectionTrack.Add(rd);
+ rd.ValuesChanged += Item_ValuesChanged;
+ OnValuesChanged(rd.ToArray());
+ }
+ }
+
+ // Old Items
+ if (e.OldItems != null)
+ {
+ foreach (var item in e.OldItems)
+ {
+ var rd = (ResourceDictionary)item;
+ rd.ValuesChanged -= Item_ValuesChanged;
+ _collectionTrack.Remove(rd);
+ }
+ }
+ }
+
+ void Item_ValuesChanged(object sender, ResourcesChangedEventArgs e)
+ {
+ OnValuesChanged(e.Values.ToArray());
+ }
+
+ void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)
+ {
+ ((ICollection<KeyValuePair<string, object>>)_innerDictionary).Add(item);
+ OnValuesChanged(item);
+ }
+
+ /// 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 void Clear()
+ {
+ _innerDictionary.Clear();
+ }
+
+ bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item)
+ {
+ return ((ICollection<KeyValuePair<string, object>>)_innerDictionary).Contains(item)
+ || (_mergedInstance != null && _mergedInstance.Contains(item));
+ }
+
+ void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
+ {
+ ((ICollection<KeyValuePair<string, object>>)_innerDictionary).CopyTo(array, arrayIndex);
+ }
+
+ /// 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 Count
+ {
+ get { return _innerDictionary.Count; }
+ }
+
+ bool ICollection<KeyValuePair<string, object>>.IsReadOnly
+ {
+ get { return ((ICollection<KeyValuePair<string, object>>)_innerDictionary).IsReadOnly; }
+ }
+
+ bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)
+ {
+ return ((ICollection<KeyValuePair<string, object>>)_innerDictionary).Remove(item);
+ }
+
+ /// 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 void Add(string key, object value)
+ {
+ if (ContainsKey(key))
+ throw new ArgumentException($"A resource with the key '{key}' is already present in the ResourceDictionary.");
+ _innerDictionary.Add(key, value);
+ OnValueChanged(key, value);
+ }
+
+ /// 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 bool ContainsKey(string key)
+ {
+ return _innerDictionary.ContainsKey(key);
+ }
+
+ [IndexerName("Item")]
+ /// 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 object this[string index]
+ {
+ get
+ {
+ if (_innerDictionary.ContainsKey(index))
+ return _innerDictionary[index];
+ if (_mergedInstance != null && _mergedInstance.ContainsKey(index))
+ return _mergedInstance[index];
+ if (MergedDictionaries != null)
+ foreach (var dict in MergedDictionaries.Reverse())
+ if (dict.ContainsKey(index))
+ return dict[index];
+ throw new KeyNotFoundException($"The resource '{index}' is not present in the dictionary.");
+ }
+ set
+ {
+ _innerDictionary[index] = value;
+ OnValueChanged(index, value);
+ }
+ }
+
+ /// 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 ICollection<string> Keys
+ {
+ get { return _innerDictionary.Keys; }
+ }
+
+ /// 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 bool Remove(string key)
+ {
+ return _innerDictionary.Remove(key);
+ }
+
+ /// 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 ICollection<object> Values
+ {
+ get { return _innerDictionary.Values; }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ /// 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 IEnumerator<KeyValuePair<string, object>> GetEnumerator()
+ {
+ return _innerDictionary.GetEnumerator();
+ }
+
+ internal IEnumerable<KeyValuePair<string, object>> MergedResources {
+ get {
+ if (MergedDictionaries != null)
+ foreach (var r in MergedDictionaries.Reverse().SelectMany(x => x.MergedResources))
+ yield return r;
+ if (_mergedInstance != null)
+ foreach (var r in _mergedInstance.MergedResources)
+ yield return r;
+ foreach (var r in _innerDictionary)
+ yield return r;
+ }
+ }
+
+ /// 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 bool TryGetValue(string key, out object value)
+ {
+ return _innerDictionary.TryGetValue(key, out value)
+ || (_mergedInstance != null && _mergedInstance.TryGetValue(key, out value))
+ || (MergedDictionaries != null && TryGetMergedDictionaryValue(key, out value));
+ }
+
+ bool TryGetMergedDictionaryValue(string key, out object value)
+ {
+ foreach (var dictionary in MergedDictionaries.Reverse())
+ if (dictionary.TryGetValue(key, out value))
+ return true;
+
+ value = null;
+ return false;
+ }
+
+ event EventHandler<ResourcesChangedEventArgs> IResourceDictionary.ValuesChanged
+ {
+ add { ValuesChanged += value; }
+ remove { ValuesChanged -= value; }
+ }
+
+ internal void Add(Style style)
+ {
+ if (string.IsNullOrEmpty(style.Class))
+ Add(style.TargetType.FullName, style);
+ else
+ {
+ IList<Style> classes;
+ object outclasses;
+ if (!TryGetValue(Style.StyleClassPrefix + style.Class, out outclasses) || (classes = outclasses as IList<Style>) == null)
+ classes = new List<Style>();
+ classes.Add(style);
+ this[Style.StyleClassPrefix + style.Class] = classes;
+ }
+ }
+
+ /// 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 void Add(ResourceDictionary mergedResourceDictionary)
+ {
+ MergedDictionaries.Add(mergedResourceDictionary);
+ }
+
+ internal void Add(StyleSheets.StyleSheet styleSheet)
+ {
+ StyleSheets = StyleSheets ?? new List<StyleSheets.StyleSheet>(2);
+ StyleSheets.Add(styleSheet);
+ ValuesChanged?.Invoke(this, ResourcesChangedEventArgs.StyleSheets);
+ }
+
+ void OnValueChanged(string key, object value)
+ {
+ OnValuesChanged(new KeyValuePair<string, object>(key, value));
+ }
+
+ void OnValuesChanged(params KeyValuePair<string, object>[] values)
+ {
+ if (values == null || values.Length == 0)
+ return;
+ ValuesChanged?.Invoke(this, new ResourcesChangedEventArgs(values));
+ }
+
+ event EventHandler<ResourcesChangedEventArgs> ValuesChanged;
+
+ // [Xaml.ProvideCompiled("Xamarin.Forms.Core.XamlC.RDSourceTypeConverter")]
+ internal class RDSourceTypeConverter : TypeConverter, IExtendedTypeConverter
+ {
+ object IExtendedTypeConverter.ConvertFromInvariantString(string value, IServiceProvider serviceProvider)
+ {
+ if (serviceProvider == null)
+ throw new ArgumentNullException(nameof(serviceProvider));
+
+ var targetRD = (serviceProvider.GetService(typeof(Xaml.IProvideValueTarget)) as Xaml.IProvideValueTarget)?.TargetObject as ResourceDictionary;
+ if (targetRD == null)
+ return null;
+
+ var rootObjectType = (serviceProvider.GetService(typeof(Xaml.IRootObjectProvider)) as Xaml.IRootObjectProvider)?.RootObject.GetType();
+ if (rootObjectType == null)
+ return null;
+
+ var lineInfo = (serviceProvider.GetService(typeof(Xaml.IXmlLineInfoProvider)) as Xaml.IXmlLineInfoProvider)?.XmlLineInfo;
+ var rootTargetPath = XamlResourceIdAttribute.GetPathForType(rootObjectType);
+ var uri = new Uri(value, UriKind.Relative); //we don't want file:// uris, even if they start with '/'
+ var resourcePath = GetResourcePath(uri, rootTargetPath);
+
+ targetRD.SetAndLoadSource(uri, resourcePath, rootObjectType.GetTypeInfo().Assembly, lineInfo);
+ return uri;
+ }
+
+ internal static string GetResourcePath(Uri uri, string rootTargetPath)
+ {
+ //need a fake scheme so it's not seen as file:// uri, and the forward slashes are valid on all plats
+ var resourceUri = uri.OriginalString.StartsWith("/", StringComparison.Ordinal)
+ ? new Uri($"pack://{uri.OriginalString}", UriKind.Absolute)
+ : new Uri($"pack:///{rootTargetPath}/../{uri.OriginalString}", UriKind.Absolute);
+
+ //drop the leading '/'
+ return resourceUri.AbsolutePath.Substring(1);
+ }
+
+ object IExtendedTypeConverter.ConvertFrom(CultureInfo culture, object value, IServiceProvider serviceProvider)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override object ConvertFromInvariantString(string value)
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public class TemplatedPage : Page, IControlTemplated
- {
+ {
/// <summary>
/// Backing store for the ControlTemplate property.
/// </summary>
- public static readonly BindableProperty ControlTemplateProperty = BindableProperty.Create(nameof(ControlTemplate), typeof(ControlTemplate), typeof(TemplatedPage), null,
- propertyChanged: TemplateUtilities.OnControlTemplateChanged);
+ internal static readonly BindableProperty ControlTemplateProperty = BindableProperty.Create(nameof(ControlTemplate), typeof(ControlTemplate), typeof(TemplatedPage), null,
+ propertyChanged: TemplateUtilities.OnControlTemplateChanged);
/// <summary>
/// Gets or sets the control template that is used to display content.
/// </summary>
- public ControlTemplate ControlTemplate
- {
- get { return (ControlTemplate)GetValue(ControlTemplateProperty); }
- set { SetValue(ControlTemplateProperty, value); }
- }
-
- IList<Element> IControlTemplated.InternalChildren => InternalChildren;
-
- // internal override void ComputeConstraintForView(View view)
- // {
- // LayoutOptions vOptions = view.VerticalOptions;
- // LayoutOptions hOptions = view.HorizontalOptions;
-
- // var result = LayoutConstraint.None;
- // if (vOptions.Alignment == LayoutAlignment.Fill)
- // result |= LayoutConstraint.VerticallyFixed;
- // if (hOptions.Alignment == LayoutAlignment.Fill)
- // result |= LayoutConstraint.HorizontallyFixed;
-
- // view.ComputedConstraint = result;
- // }
-
- internal override void SetChildInheritedBindingContext(Element child, object context)
- {
- if (ControlTemplate == null)
- base.SetChildInheritedBindingContext(child, context);
- }
-
- void IControlTemplated.OnControlTemplateChanged(ControlTemplate oldValue, ControlTemplate newValue)
- {
- OnControlTemplateChanged(oldValue, newValue);
- }
-
- internal virtual void OnControlTemplateChanged(ControlTemplate oldValue, ControlTemplate newValue)
- {
- }
- }
+ internal ControlTemplate ControlTemplate
+ {
+ get { return (ControlTemplate)GetValue(ControlTemplateProperty); }
+ set { SetValue(ControlTemplateProperty, value); }
+ }
+
+ IList<Element> IControlTemplated.InternalChildren => InternalChildren;
+
+ // internal override void ComputeConstraintForView(View view)
+ // {
+ // LayoutOptions vOptions = view.VerticalOptions;
+ // LayoutOptions hOptions = view.HorizontalOptions;
+
+ // var result = LayoutConstraint.None;
+ // if (vOptions.Alignment == LayoutAlignment.Fill)
+ // result |= LayoutConstraint.VerticallyFixed;
+ // if (hOptions.Alignment == LayoutAlignment.Fill)
+ // result |= LayoutConstraint.HorizontallyFixed;
+
+ // view.ComputedConstraint = result;
+ // }
+
+ internal override void SetChildInheritedBindingContext(Element child, object context)
+ {
+ if (ControlTemplate == null)
+ base.SetChildInheritedBindingContext(child, context);
+ }
+
+ void IControlTemplated.OnControlTemplateChanged(ControlTemplate oldValue, ControlTemplate newValue)
+ {
+ OnControlTemplateChanged(oldValue, newValue);
+ }
+
+ internal virtual void OnControlTemplateChanged(ControlTemplate oldValue, ControlTemplate newValue)
+ {
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+using System.ComponentModel;
+using static Tizen.NUI.Animation;
+
+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 class Transition : BaseHandle
+ {
+ private string name;
+
+ /// 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
+ {
+ get
+ {
+ return name;
+ }
+ set
+ {
+ name = value;
+ }
+ }
+
+ private int duration;
+
+ /// 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
+ {
+ get
+ {
+ return duration;
+ }
+ set
+ {
+ duration = value;
+ }
+ }
+
+ private int loopCount;
+
+ /// 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
+ {
+ get
+ {
+ return loopCount;
+ }
+ set
+ {
+ loopCount = value;
+ }
+ }
+
+ private EndActions endAction;
+
+ /// 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
+ {
+ get
+ {
+ return endAction;
+ }
+ set
+ {
+ endAction = value;
+ }
+ }
+
+ private string[] _properties = null;
+
+ /// 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
+ {
+ get
+ {
+ return _properties;
+ }
+ set
+ {
+ _properties = value;
+ }
+ }
+
+ private string[] _destValue = null;
+
+ /// 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
+ {
+ get
+ {
+ return _destValue;
+ }
+ set
+ {
+ _destValue = value;
+ }
+ }
+
+ private int[] _startTime = null;
+
+ /// 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
+ {
+ get
+ {
+ return _startTime;
+ }
+ set
+ {
+ _startTime = value;
+ }
+ }
+
+ private int[] _endTime = null;
+
+ /// 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
+ {
+ get
+ {
+ return _endTime;
+ }
+ set
+ {
+ _endTime = value;
+ }
+ }
+
+ /// 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()
+ {
+ Animation ani = new Animation();
+
+ ani.Duration = Duration;
+ ani.LoopCount = LoopCount;
+ ani.EndAction = EndAction;
+
+ ani.Properties = Properties;
+ ani.DestValue = DestValue;
+ ani.StartTime = StartTime;
+ ani.EndTime = EndTime;
+
+ return ani;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Diagnostics;
+using System.ComponentModel;
+
+namespace Tizen.NUI
+{
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+ [DebuggerDisplay("{XmlNamespace}, {ClrNamespace}, {AssemblyName}")]
+ /// 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 sealed class XmlnsDefinitionAttribute : Attribute
+ {
+ /// 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 XmlNamespace { get; }
+
+ /// 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 ClrNamespace { get; }
+
+ /// 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 AssemblyName { get; set; }
+
+ /// 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 XmlnsDefinitionAttribute(string xmlNamespace, string clrNamespace)
+ {
+ if (xmlNamespace == null)
+ throw new ArgumentNullException(nameof(xmlNamespace));
+ if (clrNamespace == null)
+ throw new ArgumentNullException(nameof(clrNamespace));
+
+ ClrNamespace = clrNamespace;
+ XmlNamespace = xmlNamespace;
+ }
+ }
+}
\ No newline at end of file