[NUI] Add Obsolete attributes for EditorBrowsable apis
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ImageView.cs
index 30bcac2..3641ddb 100755 (executable)
  * limitations under the License.
  *
  */
+using System;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
 
 namespace Tizen.NUI.BaseComponents
 {
-    using System;
-    using System.Runtime.InteropServices;
 
     /// <summary>
     /// ImageView is a class for displaying an image resource.<br />
     /// An instance of ImageView can be created using a URL or an image instance.<br />
     /// </summary>
+    /// <since_tizen> 3 </since_tizen>
     public class ImageView : View
     {
         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
@@ -42,6 +44,7 @@ namespace Tizen.NUI.BaseComponents
         /// <summary>
         /// Event arguments of resource ready.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public class ResourceReadyEventArgs : EventArgs
         {
             private View _view;
@@ -102,7 +105,7 @@ namespace Tizen.NUI.BaseComponents
         private void OnResourceReady(IntPtr data)
         {
             ResourceReadyEventArgs e = new ResourceReadyEventArgs();
-            if(data != null)
+            if (data != null)
             {
                 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
             }
@@ -125,7 +128,7 @@ namespace Tizen.NUI.BaseComponents
                 return;
             }
 
-            if(type == DisposeTypes.Explicit)
+            if (type == DisposeTypes.Explicit)
             {
                 //Called by User
                 //Release your own managed resources here.
@@ -190,15 +193,23 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// [Obsolete("Please do not use! this will be deprecated")]
+        /// Downcasts a handle to imageView handle.
         /// </summary>
-        [Obsolete("Please do not use! this will be deprecated")]
+        /// Please do not use! this will be deprecated!
+        /// Instead please use as keyword.
+        /// <since_tizen> 3 </since_tizen>
+        [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
+            "Like: " +
+            "BaseHandle handle = new ImageView(imagePath); " +
+            "ImageView image = handle as ImageView")]
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public new static ImageView DownCast(BaseHandle handle)
         {
-            ImageView ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
+            ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
+
         /// <summary>
         /// Sets this ImageView from the given URL.<br />
         /// If the URL is empty, ImageView will not display anything.<br />
@@ -218,7 +229,8 @@ namespace Tizen.NUI.BaseComponents
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        internal ViewResourceReadySignal ResourceReadySignal(View view) {
+        internal ViewResourceReadySignal ResourceReadySignal(View view)
+        {
             ViewResourceReadySignal ret = new ViewResourceReadySignal(NDalicPINVOKE.ResourceReadySignal(View.getCPtr(view)), false);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
@@ -230,7 +242,7 @@ namespace Tizen.NUI.BaseComponents
         /// True if the resources are loaded and ready, false otherwise.<br />
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        public new  bool IsResourceReady()
+        public new bool IsResourceReady()
         {
             bool ret = NDalicPINVOKE.IsResourceReady(swigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending)
@@ -246,20 +258,23 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                GetProperty(ImageView.Property.RESOURCE_URL).Get(out _url);
+                GetProperty(ImageView.Property.IMAGE).Get(out _url);
                 return _url;
             }
             set
             {
-                _url = value;
+                _url = (value == null? "" : value);
                 UpdateImage();
             }
         }
 
         /// <summary>
-        /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise
+        /// This will be deprecated, please use Image instead. <br />
+        /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
+        [Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
+        [EditorBrowsable(EditorBrowsableState.Never)]
         public PropertyMap ImageMap
         {
             get
@@ -279,6 +294,36 @@ namespace Tizen.NUI.BaseComponents
             {
                 if (_border == null)
                 {
+                    if (_url != null) { value.Add("url", new PropertyValue(_url)); }
+                    SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
+                }
+            }
+        }
+
+        /// <summary>
+        /// ImageView Image, type PropertyMap
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        public PropertyMap Image
+        {
+            get
+            {
+                if (_border == null)
+                {
+                    PropertyMap temp = new PropertyMap();
+                    GetProperty(ImageView.Property.IMAGE).Get(temp);
+                    return temp;
+                }
+                else
+                {
+                    return null;
+                }
+            }
+            set
+            {
+                if (_border == null)
+                {
+                    if(_url != null) { value.Add("url", new PropertyValue(_url)); }
                     SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
                 }
             }
@@ -379,6 +424,60 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        /// <summary>
+        /// Gets or sets whether to correct orientation of image automatically.<br />
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        public bool OrientationCorrection
+        {
+            get
+            {
+                return _orientationCorrection ?? false;
+            }
+            set
+            {
+                _orientationCorrection = value;
+                UpdateImage();
+            }
+        }
+
+
+        /// <summary>
+        /// Get the loading state of the visual resource.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        public ImageView.LoadingStatusType LoadingStatus
+        {
+            get
+            {
+                return (ImageView.LoadingStatusType)NDalicManualPINVOKE.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
+            }
+        }
+
+        /// <summary>
+        /// Enumeration for LoadingStatus of image.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        public enum LoadingStatusType
+        {
+            /// <summary>
+            /// Loading preparing status.
+            /// </summary>
+            /// <since_tizen> 5 </since_tizen>
+            Preparing,
+            /// <summary>
+            /// Loading ready status.
+            /// </summary>
+            /// <since_tizen> 5 </since_tizen>
+            Ready,
+            /// <summary>
+            /// Loading failed status.
+            /// </summary>
+            /// <since_tizen> 5 </since_tizen>
+            Failed
+        }
+
+
         private void UpdateImage()
         {
             if (_url != null)
@@ -390,20 +489,22 @@ namespace Tizen.NUI.BaseComponents
                     _nPatchMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
                     _nPatchMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border));
                     if (_borderOnly != null) { _nPatchMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
-                    if (_synchronousLoading != null) _nPatchMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading));
+                    if (_synchronousLoading != null) { _nPatchMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
+                    if (_orientationCorrection != null) { _nPatchMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); }
                     SetProperty(ImageView.Property.IMAGE, new PropertyValue(_nPatchMap));
                 }
-                else if(_synchronousLoading != null)
+                else if (_synchronousLoading != null || _orientationCorrection != null)
                 { // for normal image, with synchronous loading property
                     PropertyMap imageMap = new PropertyMap();
                     imageMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
                     imageMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
-                    imageMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading));
+                    if (_synchronousLoading != null) { imageMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
+                    if (_orientationCorrection != null) { imageMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); }
                     SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
                 }
                 else
                 { // just for normal image
-                    SetProperty(ImageView.Property.RESOURCE_URL, new PropertyValue(_url));
+                    SetProperty(ImageView.Property.IMAGE, new PropertyValue(_url));
                 }
             }
         }
@@ -413,7 +514,7 @@ namespace Tizen.NUI.BaseComponents
         private bool? _synchronousLoading = null;
         private bool? _borderOnly = null;
         private string _url = null;
-
+        private bool? _orientationCorrection = null;
     }
 
-}
\ No newline at end of file
+}