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