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