English Review: NUI_BaseComponents (#422)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ImageView.cs
1 /*
2  * Copyright(c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System;
18 using System.Runtime.InteropServices;
19 using System.ComponentModel;
20 using Tizen.NUI.Binding;
21
22 namespace Tizen.NUI.BaseComponents
23 {
24
25     /// <summary>
26     /// ImageView is a class for displaying an image resource.<br />
27     /// An instance of ImageView can be created using a URL or an image instance.<br />
28     /// </summary>
29     /// <since_tizen> 3 </since_tizen>
30     public class ImageView : View
31     {
32         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33         [EditorBrowsable(EditorBrowsableState.Never)]
34         public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create("ResourceUrl", typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
35         {
36             var imageView = (ImageView)bindable;
37             if (newValue != null)
38             {
39                 imageView._url = (newValue == null? "" : (string)newValue);
40                 imageView.UpdateImage();
41             }
42         },
43         defaultValueCreator:(bindable) =>
44         {
45             var imageView = (ImageView)bindable;
46             Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(out imageView._url);
47             return imageView._url;
48         });
49         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
50         [EditorBrowsable(EditorBrowsableState.Never)]
51         public static readonly BindableProperty ImageProperty = BindableProperty.Create("Image", typeof(PropertyMap), typeof(ImageView), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
52         {
53             var imageView = (ImageView)bindable;
54             if (newValue != null)
55             {
56                 if (imageView._border == null)
57                 {
58                     Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
59                 }
60             }
61         },
62         defaultValueCreator:(bindable) =>
63         {
64             var imageView = (ImageView)bindable;
65             if (imageView._border == null)
66             {
67                 PropertyMap temp = new PropertyMap();
68                 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(temp);
69                 return temp;
70             }
71             else
72             {
73                 return null;
74             }
75         });
76         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
77         [EditorBrowsable(EditorBrowsableState.Never)]
78         public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create("PreMultipliedAlpha", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
79         {
80             var imageView = (ImageView)bindable;
81             if (newValue != null)
82             {
83                 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue((bool)newValue));
84             }
85         },
86         defaultValueCreator:(bindable) =>
87         {
88             var imageView = (ImageView)bindable;
89             bool temp = false;
90             Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
91             return temp;
92         });
93         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
94         [EditorBrowsable(EditorBrowsableState.Never)]
95         public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create("PixelArea", typeof(RelativeVector4), typeof(ImageView), new RelativeVector4(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
96         {
97             var imageView = (ImageView)bindable;
98             if (newValue != null)
99             {
100                 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
101             }
102         },
103         defaultValueCreator:(bindable) =>
104         {
105             var imageView = (ImageView)bindable;
106             Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
107             Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA).Get(temp);
108             RelativeVector4 relativeTemp = new RelativeVector4(temp.X, temp.Y, temp.Z, temp.W);
109             return relativeTemp;
110         });
111         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
112         [EditorBrowsable(EditorBrowsableState.Never)]
113         public static readonly BindableProperty BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), new Rectangle(0,0,0,0), propertyChanged: (bindable, oldValue, newValue) =>
114         {
115             var imageView = (ImageView)bindable;
116             if (newValue != null)
117             {
118                 imageView._border = (Rectangle)newValue;
119                 imageView.UpdateImage();
120             }
121         },
122         defaultValueCreator:(bindable) =>
123         {
124             var imageView = (ImageView)bindable;
125             return imageView._border;
126         });
127         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
128         [EditorBrowsable(EditorBrowsableState.Never)]
129         public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create("BorderOnly", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
130         {
131             var imageView = (ImageView)bindable;
132             if (newValue != null)
133             {
134                 imageView._borderOnly = (bool)newValue;
135                 imageView.UpdateImage();
136             }
137         },
138         defaultValueCreator:(bindable) =>
139         {
140             var imageView = (ImageView)bindable;
141             return imageView._borderOnly ?? false;
142         });
143         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
144         [EditorBrowsable(EditorBrowsableState.Never)]
145         public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create("SynchronosLoading", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
146         {
147             var imageView = (ImageView)bindable;
148             if (newValue != null)
149             {
150                 imageView._synchronousLoading = (bool)newValue;
151                 imageView.UpdateImage();
152             }
153         },
154         defaultValueCreator:(bindable) =>
155         {
156             var imageView = (ImageView)bindable;
157             return imageView._synchronousLoading ?? false;
158         });
159         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
160         [EditorBrowsable(EditorBrowsableState.Never)]
161         public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create("OrientationCorrection", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
162         {
163             var imageView = (ImageView)bindable;
164             if (newValue != null)
165             {
166                 imageView._orientationCorrection = (bool)newValue;
167                 imageView.UpdateImage();
168             }
169         },
170         defaultValueCreator:(bindable) =>
171         {
172             var imageView = (ImageView)bindable;
173             return imageView._orientationCorrection ?? false;
174         });
175
176         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
177
178         internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
179         {
180             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
181         }
182
183         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageView obj)
184         {
185             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
186         }
187
188
189         /// <summary>
190         /// Event arguments of resource ready.
191         /// </summary>
192         /// <since_tizen> 3 </since_tizen>
193         public class ResourceReadyEventArgs : EventArgs
194         {
195             private View _view;
196
197             /// <summary>
198             /// The view whose resource is ready.
199             /// </summary>
200             /// <since_tizen> 3 </since_tizen>
201             public View View
202             {
203                 get
204                 {
205                     return _view;
206                 }
207                 set
208                 {
209                     _view = value;
210                 }
211             }
212         }
213
214         private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
215         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
216         private delegate void ResourceReadyEventCallbackType(IntPtr data);
217         private ResourceReadyEventCallbackType _resourceReadyEventCallback;
218
219         /// <summary>
220         /// An event for ResourceReady signal which can be used to subscribe or unsubscribe the event handler.<br />
221         /// This signal is emitted after all resources required by a control are loaded and ready.<br />
222         /// Most resources are only loaded when the control is placed on the stage.<br />
223         /// </summary>
224         /// <since_tizen> 3 </since_tizen>
225         public event EventHandler<ResourceReadyEventArgs> ResourceReady
226         {
227             add
228             {
229                 if (_resourceReadyEventHandler == null)
230                 {
231                     _resourceReadyEventCallback = OnResourceReady;
232                     ResourceReadySignal(this).Connect(_resourceReadyEventCallback);
233                 }
234
235                 _resourceReadyEventHandler += value;
236             }
237
238             remove
239             {
240                 _resourceReadyEventHandler -= value;
241
242                 if (_resourceReadyEventHandler == null && ResourceReadySignal(this).Empty() == false)
243                 {
244                     ResourceReadySignal(this).Disconnect(_resourceReadyEventCallback);
245                 }
246             }
247         }
248
249         // Callback for View ResourceReady signal
250         private void OnResourceReady(IntPtr data)
251         {
252             ResourceReadyEventArgs e = new ResourceReadyEventArgs();
253             if (data != null)
254             {
255                 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
256             }
257
258             if (_resourceReadyEventHandler != null)
259             {
260                 _resourceReadyEventHandler(this, e);
261             }
262         }
263
264         /// <summary>
265         /// you can override it to clean-up your own resources.
266         /// </summary>
267         /// <param name="type">DisposeTypes</param>
268         /// <since_tizen> 3 </since_tizen>
269         protected override void Dispose(DisposeTypes type)
270         {
271             if (disposed)
272             {
273                 return;
274             }
275
276             if (type == DisposeTypes.Explicit)
277             {
278                 //Called by User
279                 //Release your own managed resources here.
280                 //You should release all of your own disposable objects here.
281                 _border?.Dispose();
282                 _border = null;
283                 _nPatchMap?.Dispose();
284                 _nPatchMap = null;
285             }
286
287             //Release your own unmanaged resources here.
288             //You should not access any managed member here except static instance.
289             //because the execution order of Finalizes is non-deterministic.
290
291             if (swigCPtr.Handle != global::System.IntPtr.Zero)
292             {
293                 if (swigCMemOwn)
294                 {
295                     swigCMemOwn = false;
296                     NDalicPINVOKE.delete_ImageView(swigCPtr);
297                 }
298                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
299             }
300
301             base.Dispose(type);
302         }
303
304         internal new class Property
305         {
306             internal static readonly int RESOURCE_URL = NDalicPINVOKE.ImageView_Property_RESOURCE_URL_get();
307             internal static readonly int IMAGE = NDalicPINVOKE.ImageView_Property_IMAGE_get();
308             internal static readonly int PRE_MULTIPLIED_ALPHA = NDalicPINVOKE.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
309             internal static readonly int PIXEL_AREA = NDalicPINVOKE.ImageView_Property_PIXEL_AREA_get();
310             internal static readonly int ACTION_RELOAD = NDalicManualPINVOKE.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
311             internal static readonly int ACTION_PLAY = NDalicManualPINVOKE.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
312             internal static readonly int ACTION_PAUSE = NDalicManualPINVOKE.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
313             internal static readonly int ACTION_STOP = NDalicManualPINVOKE.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
314         }
315
316         /// <summary>
317         /// Creates an initialized ImageView.
318         /// </summary>
319         /// <since_tizen> 3 </since_tizen>
320         public ImageView() : this(NDalicPINVOKE.ImageView_New__SWIG_0(), true)
321         {
322             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323         }
324
325         /// <summary>
326         /// Creates an initialized ImageView from a URL to an image resource.<br />
327         /// If the string is empty, ImageView will not display anything.<br />
328         /// </summary>
329         /// <param name="url">The URL of the image resource to display.</param>
330         /// <since_tizen> 3 </since_tizen>
331         public ImageView(string url) : this(NDalicPINVOKE.ImageView_New__SWIG_2(url), true)
332         {
333             _url = url;
334             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335
336         }
337         internal ImageView(string url, Uint16Pair size) : this(NDalicPINVOKE.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
338         {
339             _url = url;
340             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341
342         }
343
344         /// <summary>
345         /// Downcasts a handle to imageView handle.
346         /// </summary>
347         /// Please do not use! this will be deprecated!
348         /// Instead please use as keyword.
349         /// <since_tizen> 3 </since_tizen>
350         [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
351             "Like: " +
352             "BaseHandle handle = new ImageView(imagePath); " +
353             "ImageView image = handle as ImageView")]
354         [EditorBrowsable(EditorBrowsableState.Never)]
355         public static ImageView DownCast(BaseHandle handle)
356         {
357             ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
358             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
359             return ret;
360         }
361
362         /// <summary>
363         /// Sets this ImageView from the given URL.<br />
364         /// If the URL is empty, ImageView will not display anything.<br />
365         /// </summary>
366         /// <param name="url">The URL to the image resource to display.</param>
367         /// <since_tizen> 3 </since_tizen>
368         public void SetImage(string url)
369         {
370             _url = url;
371             NDalicPINVOKE.ImageView_SetImage__SWIG_1(swigCPtr, url);
372             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
373         }
374         internal void SetImage(string url, Uint16Pair size)
375         {
376             _url = url;
377             NDalicPINVOKE.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
378             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
379         }
380
381         internal ViewResourceReadySignal ResourceReadySignal(View view)
382         {
383             ViewResourceReadySignal ret = new ViewResourceReadySignal(NDalicPINVOKE.ResourceReadySignal(View.getCPtr(view)), false);
384             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385             return ret;
386         }
387
388         /// <summary>
389         /// Queries if all resources required by a control are loaded and ready.<br />
390         /// Most resources are only loaded when the control is placed on the stage.<br />
391         /// True if the resources are loaded and ready, false otherwise.<br />
392         /// </summary>
393         /// <since_tizen> 3 </since_tizen>
394         public new bool IsResourceReady()
395         {
396             bool ret = NDalicPINVOKE.IsResourceReady(swigCPtr);
397             if (NDalicPINVOKE.SWIGPendingException.Pending)
398                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399             return ret;
400         }
401
402         /// <summary>
403         /// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
404         /// </summary>
405         /// <since_tizen> 5 </since_tizen>        
406         public void Reload()
407         {
408             this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
409         }
410
411         /// <summary>
412         /// Plays the animated GIF. This is also the default playback mode.
413         /// </summary>
414         /// <since_tizen> 5 </since_tizen>
415         public void Play()
416         {
417             this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
418         }
419
420         /// <summary>
421         /// Pauses the animated GIF.
422         /// </summary>
423         /// <since_tizen> 5 </since_tizen>
424         public void Pause()
425         {
426             this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
427         }
428
429         /// <summary>
430         /// Stops the animated GIF.
431         /// </summary>
432         /// <since_tizen> 5 </since_tizen>
433         public void Stop()
434         {
435             this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
436         }
437
438         /// <summary>
439         /// ImageView ResourceUrl, type string.
440         /// </summary>
441         /// <since_tizen> 3 </since_tizen>
442         public string ResourceUrl
443         {
444             get
445             {
446                 return (string)GetValue(ResourceUrlProperty);
447             }
448             set
449             {
450                 SetValue(ResourceUrlProperty, value);
451                 NotifyPropertyChanged();
452             }
453         }
454
455         /// <summary>
456         /// This will be deprecated, please use Image instead. <br />
457         /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
458         /// </summary>
459         /// <since_tizen> 3 </since_tizen>
460         [Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
461         [EditorBrowsable(EditorBrowsableState.Never)]
462         public PropertyMap ImageMap
463         {
464             get
465             {
466                 if (_border == null)
467                 {
468                     PropertyMap temp = new PropertyMap();
469                     GetProperty(ImageView.Property.IMAGE).Get(temp);
470                     return temp;
471                 }
472                 else
473                 {
474                     return null;
475                 }
476             }
477             set
478             {
479                 if (_border == null)
480                 {
481                     if (_url != null) { value.Add("url", new PropertyValue(_url)); }
482                     SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
483                     NotifyPropertyChanged();
484                 }
485             }
486         }
487
488         /// <summary>
489         /// ImageView Image, type PropertyMap
490         /// </summary>
491         /// <since_tizen> 4 </since_tizen>
492         public PropertyMap Image
493         {
494             get
495             {
496                 if (_border == null)
497                 {
498                     return (PropertyMap)GetValue(ImageProperty);
499                 }
500                 else
501                 {
502                     return null;
503                 }
504             }
505             set
506             {
507                 if (_border == null)
508                 {
509                     SetValue(ImageProperty, value);
510                     NotifyPropertyChanged();
511                 }
512             }
513         }
514
515         /// <summary>
516         /// ImageView PreMultipliedAlpha, type Boolean.<br />
517         /// Image must be initialized.<br />
518         /// </summary>
519         /// <since_tizen> 3 </since_tizen>
520         public bool PreMultipliedAlpha
521         {
522             get
523             {
524                 return (bool)GetValue(PreMultipliedAlphaProperty);
525             }
526             set
527             {
528                 SetValue(PreMultipliedAlphaProperty, value);
529                 NotifyPropertyChanged();
530             }
531         }
532
533         /// <summary>
534         /// ImageView PixelArea, type Vector4 (Animatable property).<br />
535         /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br />
536         /// </summary>
537         /// <since_tizen> 3 </since_tizen>
538         public RelativeVector4 PixelArea
539         {
540             get
541             {
542                 return (RelativeVector4)GetValue(PixelAreaProperty);
543             }
544             set
545             {
546                 SetValue(PixelAreaProperty, value);
547                 NotifyPropertyChanged();
548             }
549         }
550
551         /// <summary>
552         /// The border of the image in the order: left, right, bottom, top.<br />
553         /// If set, ImageMap will be ignored.<br />
554         /// For N-Patch images only.<br />
555         /// Optional.
556         /// </summary>
557         /// <since_tizen> 3 </since_tizen>
558         public Rectangle Border
559         {
560             get
561             {
562                 return (Rectangle)GetValue(BorderProperty);
563             }
564             set
565             {
566                 SetValue(BorderProperty, value);
567                 NotifyPropertyChanged();
568             }
569         }
570
571         /// <summary>
572         /// Gets or sets whether to draw the borders only (if true).<br />
573         /// If not specified, the default is false.<br />
574         /// For N-Patch images only.<br />
575         /// Optional.
576         /// </summary>
577         /// <since_tizen> 3 </since_tizen>
578         public bool BorderOnly
579         {
580             get
581             {
582                 return (bool)GetValue(BorderOnlyProperty);
583             }
584             set
585             {
586                 SetValue(BorderOnlyProperty, value);
587                 NotifyPropertyChanged();
588             }
589         }
590
591         /// <summary>
592         /// Gets or sets whether to synchronos loading the resourceurl of image.<br />
593         /// </summary>
594         /// <since_tizen> 3 </since_tizen>
595         public bool SynchronosLoading
596         {
597             get
598             {
599                 return (bool)GetValue(SynchronosLoadingProperty);
600             }
601             set
602             {
603                 SetValue(SynchronosLoadingProperty, value);
604                 NotifyPropertyChanged();
605             }
606         }
607
608         /// <summary>
609         /// Gets or sets whether to automatically correct the orientation of an image.<br />
610         /// </summary>
611         /// <since_tizen> 5 </since_tizen>
612         public bool OrientationCorrection
613         {
614             get
615             {
616                 return (bool)GetValue(OrientationCorrectionProperty);
617             }
618             set
619             {
620                 SetValue(OrientationCorrectionProperty, value);
621                 NotifyPropertyChanged();
622             }
623         }
624
625
626         /// <summary>
627         /// Gets the loading state of the visual resource.
628         /// </summary>
629         /// <since_tizen> 5 </since_tizen>
630         public ImageView.LoadingStatusType LoadingStatus
631         {
632             get
633             {
634                 return (ImageView.LoadingStatusType)NDalicManualPINVOKE.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
635             }
636         }
637
638         /// <summary>
639         /// Enumeration for LoadingStatus of image.
640         /// </summary>
641         /// <since_tizen> 5 </since_tizen>
642         public enum LoadingStatusType
643         {
644             /// <summary>
645             /// Loading preparing status.
646             /// </summary>
647             /// <since_tizen> 5 </since_tizen>
648             Preparing,
649             /// <summary>
650             /// Loading ready status.
651             /// </summary>
652             /// <since_tizen> 5 </since_tizen>
653             Ready,
654             /// <summary>
655             /// Loading failed status.
656             /// </summary>
657             /// <since_tizen> 5 </since_tizen>
658             Failed
659         }
660
661
662         private void UpdateImage()
663         {
664             if (_url != null)
665             {
666                 if (_border != null)
667                 { // for nine-patch image
668                     _nPatchMap = new PropertyMap();
669                     _nPatchMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
670                     _nPatchMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
671                     _nPatchMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border));
672                     if (_borderOnly != null) { _nPatchMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
673                     if (_synchronousLoading != null) { _nPatchMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
674                     if (_orientationCorrection != null) { _nPatchMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); }
675                     SetProperty(ImageView.Property.IMAGE, new PropertyValue(_nPatchMap));
676                 }
677                 else if (_synchronousLoading != null || _orientationCorrection != null)
678                 { // for normal image, with synchronous loading property
679                     PropertyMap imageMap = new PropertyMap();
680                     imageMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
681                     imageMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
682                     if (_synchronousLoading != null) { imageMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
683                     if (_orientationCorrection != null) { imageMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); }
684                     SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
685                 }
686                 else
687                 { // just for normal image
688                     SetProperty(ImageView.Property.IMAGE, new PropertyValue(_url));
689                 }
690             }
691         }
692
693         private Rectangle _border = null;
694         private PropertyMap _nPatchMap = null;
695         private bool? _synchronousLoading = null;
696         private bool? _borderOnly = null;
697         private string _url = null;
698         private bool? _orientationCorrection = null;
699     }
700
701 }