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