[NUI] add Reload() to reload image forcely 24/164524/3
authordongsug.song <dongsug.song@samsung.com>
Tue, 19 Dec 2017 13:05:21 +0000 (22:05 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Wed, 20 Dec 2017 01:24:08 +0000 (10:24 +0900)
Conflicts:
src/Tizen.NUI/src/internal/ManualPINVOKE.cs

Change-Id: I66b31730146927f035717f24e8f144742ca0e555
Signed-off-by: dongsug.song <dongsug.song@samsung.com>
src/Tizen.NUI/src/internal/ManualPINVOKE.cs
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
test/NUITestSample/NUITestSample/examples/imageview-doaction-test.cs [new file with mode: 0755]

index 82005ff..4d9d25f 100755 (executable)
@@ -1726,5 +1726,9 @@ namespace Tizen.NUI
 
         [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_TextEditor_Property_ENABLE_SHIFT_SELECTION_get")]
         public static extern int TextEditor_Property_ENABLE_SHIFT_SELECTION_get();
+
+        [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_ImageView_IMAGE_VISUAL_ACTION_RELOAD_get")]
+        public static extern int ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
+
     }
 }
index c5f5f14..2add727 100755 (executable)
@@ -232,6 +232,19 @@ namespace Tizen.NUI.BaseComponents
             return ret;
         }
 
+
+        private static readonly int _actionReload = NDalicManualPINVOKE.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
+        /// <summary>
+        /// Force reloading of the image, all visuals using this image will get the latest one.
+        /// </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 void Reload()
+        {
+            this.DoAction(ImageView.Property.IMAGE, _actionReload, new PropertyValue(0));
+        }
+
         /// <summary>
         /// ImageView ResourceUrl, type string.
         /// </summary>
diff --git a/test/NUITestSample/NUITestSample/examples/imageview-doaction-test.cs b/test/NUITestSample/NUITestSample/examples/imageview-doaction-test.cs
new file mode 100755 (executable)
index 0000000..3fe14a0
--- /dev/null
@@ -0,0 +1,89 @@
+
+using System;
+using Tizen.NUI;
+using Tizen.NUI.UIComponents;
+using Tizen.NUI.BaseComponents;
+
+namespace ImageViewDoActionTest
+{
+    class Example : NUIApplication
+    {
+        protected override void OnCreate()
+        {
+            base.OnCreate();
+            Initialize();
+            DoActionTest();
+        }
+
+        private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+        private Window window;
+        private Layer defaultLayer;
+        public void Initialize()
+        {
+            Tizen.Log.Error("NUI", "Initialize() START!");
+            window = Window.Instance;
+            window.BackgroundColor = Color.Green;
+            window.TouchEvent += OnWindowTouched;
+            window.WheelEvent += OnWindowWheelMoved;
+            window.KeyEvent += OnWindowKeyPressed;
+
+            defaultLayer = window.GetDefaultLayer();
+
+            Tizen.Log.Error("NUI", "Initialize() END!");
+
+        }
+
+        ImageView imageView1, imageView2;
+        public void DoActionTest()
+        {
+            string myUrl = resourcePath + "/images/gallery-0.jpg";
+
+            imageView1 = new ImageView();
+            imageView1.ResourceUrl = myUrl;
+            imageView1.Position2D = new Position2D(100, 100);
+            imageView1.Size2D = new Size2D(200, 200);
+            defaultLayer.Add(imageView1);
+
+            imageView2 = new ImageView();
+            imageView2.ResourceUrl = myUrl;
+            imageView2.Position2D = new Position2D(500, 100);
+            imageView2.Size2D = new Size2D(400, 400);
+            defaultLayer.Add(imageView2);
+        }
+
+        public void OnWindowKeyPressed(object sender, Window.KeyEventArgs e)
+        {
+            Tizen.Log.Error("NUI", $"OnWindowKeyPressed()! keyPressedName={e.Key.KeyPressedName} state={e.Key.State}");
+
+            if(e.Key.State == Key.StateType.Down)
+            {
+                if(e.Key.KeyPressedName == "Up")
+                {
+                    PropertyMap attributes = new PropertyMap();
+                    imageView1.Reload();
+                }
+                else if (e.Key.KeyPressedName == "Down")
+                {
+
+                }
+            }
+        }
+
+        public void OnWindowWheelMoved(object sender, Window.WheelEventArgs e)
+        {
+            Tizen.Log.Error("NUI", $"OnWindowWheelMoved()! direction={e.Wheel.Direction} type={e.Wheel.Type}");
+        }
+
+        public void OnWindowTouched(object sender, Window.TouchEventArgs e)
+        {
+            Tizen.Log.Error("NUI", $"OnWindowTouched()! e.TouchData.GetState(0)={e.Touch.GetState(0)}");
+        }
+
+        [STAThread]
+        static void _Main(string[] args)
+        {
+            Example example = new Example();
+            example.Run(args);
+        }
+    }
+}