[EXaml] Support Trigger in EXaml
authorFang Xiaohui <xiaohui.fang@samsung.com>
Tue, 31 Aug 2021 08:11:51 +0000 (16:11 +0800)
committerhuiyu <35286162+huiyueun@users.noreply.github.com>
Tue, 7 Sep 2021 09:05:39 +0000 (18:05 +0900)
src/Tizen.NUI/Properties/AssemblyInfo.cs
src/Tizen.NUI/src/internal/EXaml/Action/CreateInstanceAction.cs
src/Tizen.NUI/src/internal/EXaml/Operation/GatherTypeObject.cs [new file with mode: 0755]
src/Tizen.NUI/src/public/XamlBinding/Setter.cs
src/Tizen.NUI/src/public/XamlBinding/TriggerBase.cs

index b5b0c1a..95e458b 100755 (executable)
@@ -18,3 +18,5 @@ using Tizen.NUI;
 [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")]
+
+[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2009/xaml", "System.Collections.Generic", AssemblyName = "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
\ No newline at end of file
index f5bd770..3c2bf82 100755 (executable)
@@ -58,6 +58,10 @@ namespace Tizen.NUI.EXaml
                     getStaticInstanceOp = new GetValueListAction('}', this);
                     return getStaticInstanceOp;
 
+                case '`':
+                    getTypeObjectIndexOp = new GetValueListAction(c, this);
+                    return getTypeObjectIndexOp;
+
                 default:
                     getTypeIndexOp = new GetValueAction(c, this);
                     return getTypeIndexOp;
@@ -104,13 +108,20 @@ namespace Tizen.NUI.EXaml
                     getParamListOp = null;
                 }
             }
+            else if (null != getTypeObjectIndexOp)
+            {
+                int typeIndex = (int)(getTypeObjectIndexOp.ValueList[0]);
+                globalDataList.Operations.Add(new GatherTypeObject(globalDataList, typeIndex));
+            }
 
             getTypeIndexOp = null;
+            getTypeObjectIndexOp = null;
         }
 
         private GetValueAction getTypeIndexOp;
         private GetValueListAction getXFactoryMethodIndexOp;
         private GetValueListAction getParamListOp;
         private GetValueListAction getStaticInstanceOp;
+        private GetValueListAction getTypeObjectIndexOp;
     }
 }
diff --git a/src/Tizen.NUI/src/internal/EXaml/Operation/GatherTypeObject.cs b/src/Tizen.NUI/src/internal/EXaml/Operation/GatherTypeObject.cs
new file mode 100755 (executable)
index 0000000..3d28065
--- /dev/null
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.NUI.EXaml
+{
+    internal class GatherTypeObject : Operation
+    {
+        public GatherTypeObject(GlobalDataList globalDataList, int typeIndex)
+        {
+            this.typeIndex = typeIndex;
+            this.globalDataList = globalDataList;
+        }
+
+        public void Do()
+        {
+            var type = globalDataList.GatheredTypes[typeIndex];
+
+            if (null != type)
+            {
+                globalDataList.GatheredInstances.Add(type);
+            }
+        }
+
+        private int typeIndex;
+        private GlobalDataList globalDataList;
+    }
+}
index c66a8bb..4a951d6 100755 (executable)
@@ -40,10 +40,23 @@ namespace Tizen.NUI.Binding
         [EditorBrowsable(EditorBrowsableState.Never)]
         public BindableProperty Property { get; set; }
 
+        private bool isOriginalValue = false;
+        private object value;
         /// <since_tizen> 6 </since_tizen>
         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public object Value { get; set; }
+        public object Value
+        {
+            get
+            {
+                return value;
+            }
+            set
+            {
+                this.value = value;
+                isOriginalValue = true;
+            }
+        }
 
         object IValueProvider.ProvideValue(IServiceProvider serviceProvider)
         {
@@ -86,6 +99,17 @@ namespace Tizen.NUI.Binding
                 target.SetDynamicResource(Property, dynamicResource.Key, fromStyle);
             else
             {
+                if (true == isOriginalValue && null != Property)
+                {
+                    var tempValue = Value;
+                    if (Property.TryConvert(ref tempValue))
+                    {
+                        Value = tempValue;
+                    }
+
+                    isOriginalValue = false;
+                }
+
                 target.SetValue(Property, Value, fromStyle);
             }
         }
index 6fdd371..3f4d866 100755 (executable)
@@ -125,7 +125,7 @@ namespace Tizen.NUI.Binding
             }
         }
 
-        internal class SealedList<T> : IList<T>
+        internal class SealedList<T> : IList<T>, IList
         {
             readonly IList<T> _actual;
 
@@ -178,6 +178,14 @@ namespace Tizen.NUI.Binding
                 }
             }
 
+            public bool IsFixedSize => throw new NotImplementedException();
+
+            public bool IsSynchronized => throw new NotImplementedException();
+
+            public object SyncRoot => throw new NotImplementedException();
+
+            object IList.this[int index] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
+
             public bool Remove(T item)
             {
                 if (IsReadOnly)
@@ -224,6 +232,37 @@ namespace Tizen.NUI.Binding
                     throw new InvalidOperationException("This list is ReadOnly");
                 _actual.RemoveAt(index);
             }
+
+            public int Add(object value)
+            {
+                Add((T)value);
+                return _actual.Count;
+            }
+
+            public bool Contains(object value)
+            {
+                return Contains((T)value);
+            }
+
+            public int IndexOf(object value)
+            {
+                return IndexOf((T)value);
+            }
+
+            public void Insert(int index, object value)
+            {
+                Insert(index, (T)value);
+            }
+
+            public void Remove(object value)
+            {
+                Remove((T)value);
+            }
+
+            public void CopyTo(Array array, int index)
+            {
+                CopyTo((T[])array, index);
+            }
         }
     }
 }