0087ad6ebad80ee27390371e853c2434ec060648
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ImageView.cs
1 /*
2 * Copyright(c) 2019 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         static ImageView() { }
33
34         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
35         [EditorBrowsable(EditorBrowsableState.Never)]
36         public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ImageView.ResourceUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
37         {
38             var imageView = (ImageView)bindable;
39             string url = (string)newValue;
40             url = (url == null ? "" : url);
41             if (imageView.IsCreateByXaml && url.Contains("*Resource*"))
42             {
43                 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
44                 url = url.Replace("*Resource*", resource);
45             }
46             imageView._resourceUrl = url;
47             imageView.UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
48         },
49         defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
50         {
51             var imageView = (ImageView)bindable;
52             string ret = "";
53
54             PropertyMap imageMap = new PropertyMap();
55             Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE).Get(imageMap);
56             imageMap.Find(ImageVisualProperty.URL)?.Get(out ret);
57             return ret;
58         }));
59
60         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
61         [EditorBrowsable(EditorBrowsableState.Never)]
62         public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(ImageView.Image), typeof(PropertyMap), typeof(ImageView), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
63         {
64             var imageView = (ImageView)bindable;
65             if (newValue != null)
66             {
67                 PropertyMap map = (PropertyMap)newValue;
68                 if (imageView.IsCreateByXaml)
69                 {
70                     string url = "", alphaMaskURL = "", auxiliaryImageURL = "";
71                     string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
72                     PropertyValue urlValue = map.Find(NDalic.ImageVisualUrl);
73                     bool ret = false;
74                     if (urlValue != null) ret = urlValue.Get(out url);
75                     PropertyMap mmap = new PropertyMap();
76                     if (ret && url.Contains("*Resource*"))
77                     {
78                         url = url.Replace("*Resource*", resource);
79                         mmap.Insert(NDalic.ImageVisualUrl, new PropertyValue(url));
80                     }
81
82                     ret = false;
83                     PropertyValue alphaMaskUrlValue = map.Find(NDalic.ImageVisualAlphaMaskUrl);
84                     if (alphaMaskUrlValue != null) ret = alphaMaskUrlValue.Get(out alphaMaskURL);
85                     if (ret && alphaMaskURL.Contains("*Resource*"))
86                     {
87                         alphaMaskURL = alphaMaskURL.Replace("*Resource*", resource);
88                         mmap.Insert(NDalic.ImageVisualUrl, new PropertyValue(alphaMaskURL));
89                     }
90
91                     ret = false;
92                     PropertyValue auxiliaryImageURLValue = map.Find(NDalic.ImageVisualAuxiliaryImageUrl);
93                     if (auxiliaryImageURLValue != null) ret = auxiliaryImageURLValue.Get(out auxiliaryImageURL);
94                     if (ret && auxiliaryImageURL.Contains("*Resource*"))
95                     {
96                         auxiliaryImageURL = auxiliaryImageURL.Replace("*Resource*", resource);
97                         mmap.Insert(NDalic.ImageVisualAuxiliaryImageUrl, new PropertyValue(auxiliaryImageURL));
98                     }
99
100                     map.Merge(mmap);
101                 }
102                 if (imageView._border == null)
103                 {
104                     Tizen.NUI.Object.SetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
105                 }
106             }
107         }),
108         defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
109         {
110             var imageView = (ImageView)bindable;
111             if (imageView._border == null)
112             {
113                 PropertyMap temp = new PropertyMap();
114                 Tizen.NUI.Object.GetProperty((HandleRef)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(nameof(PreMultipliedAlpha), typeof(bool), typeof(ImageView), false, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
126         {
127             var imageView = (ImageView)bindable;
128             if (newValue != null)
129             {
130                 Tizen.NUI.Object.SetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.PreMultipliedAlpha, new Tizen.NUI.PropertyValue((bool)newValue));
131             }
132         }),
133         defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
134         {
135             var imageView = (ImageView)bindable;
136             bool temp = false;
137             Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.PreMultipliedAlpha).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(nameof(PixelArea), typeof(RelativeVector4), typeof(ImageView), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
144         {
145             var imageView = (ImageView)bindable;
146             if (newValue != null)
147             {
148                 Tizen.NUI.Object.SetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.PixelArea, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
149             }
150         }),
151         defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((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((HandleRef)imageView.SwigCPtr, ImageView.Property.PixelArea).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(nameof(Border), typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
163         {
164             var imageView = (ImageView)bindable;
165             if (newValue != null)
166             {
167                 imageView._border = new Rectangle((Rectangle)newValue);
168                 imageView.UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(imageView._border));
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(nameof(BorderOnly), typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
180         {
181             var imageView = (ImageView)bindable;
182             if (newValue != null)
183             {
184                 imageView.UpdateImage(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)newValue));
185             }
186         },
187         defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
188         {
189             var imageView = (ImageView)bindable;
190             bool ret = false;
191             PropertyMap imageMap = new PropertyMap();
192             Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE).Get(imageMap);
193             imageMap.Find(ImageVisualProperty.BorderOnly)?.Get(out ret);
194             return ret;
195         }));
196
197         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
198         [EditorBrowsable(EditorBrowsableState.Never)]
199         public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create(nameof(SynchronosLoading), typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
200         {
201             var imageView = (ImageView)bindable;
202             if (newValue != null)
203             {
204                 imageView._synchronosLoading = (bool)newValue;
205                 imageView.UpdateImage(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
206             }
207         },
208         defaultValueCreator: (bindable) =>
209         {
210             var imageView = (ImageView)bindable;
211             return imageView._synchronosLoading;
212         });
213
214         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
215         [EditorBrowsable(EditorBrowsableState.Never)]
216         public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create(nameof(OrientationCorrection), typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
217         {
218             var imageView = (ImageView)bindable;
219             if (newValue != null)
220             {
221                 imageView.UpdateImage(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)newValue));
222             }
223         },
224         defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
225         {
226             var imageView = (ImageView)bindable;
227
228             bool ret = false;
229             PropertyMap imageMap = new PropertyMap();
230             Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE).Get(imageMap);
231             imageMap?.Find(ImageVisualProperty.OrientationCorrection)?.Get(out ret);
232
233             return ret;
234         }));
235
236         internal static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector<string>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
237         {
238             var imageView = (ImageView)bindable;
239             imageView.resourceUrlSelector.Update(imageView, (Selector<string>)newValue, true);
240         },
241         defaultValueCreator: (bindable) =>
242         {
243             var imageView = (ImageView)bindable;
244             return imageView.resourceUrlSelector.Get(imageView);
245         });
246
247         internal static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector<Rectangle>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
248         {
249             var imageView = (ImageView)bindable;
250             imageView.borderSelector.Update(imageView, (Selector<Rectangle>)newValue, true);
251         },
252         defaultValueCreator: (bindable) =>
253         {
254             var imageView = (ImageView)bindable;
255             return imageView.borderSelector.Get(imageView);
256         });
257
258         private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
259         private ResourceReadyEventCallbackType _resourceReadyEventCallback;
260         private EventHandler<ResourceLoadedEventArgs> _resourceLoadedEventHandler;
261         private _resourceLoadedCallbackType _resourceLoadedCallback;
262
263         private Rectangle _border;
264         private string _resourceUrl = "";
265         private bool _synchronosLoading = false;
266         private string _alphaMaskUrl = null;
267         private int _desired_width = -1;
268         private int _desired_height = -1;
269         private readonly TriggerableSelector<string> resourceUrlSelector = new TriggerableSelector<string>(ResourceUrlProperty);
270         private readonly TriggerableSelector<Rectangle> borderSelector = new TriggerableSelector<Rectangle>(BorderProperty);
271
272         /// <summary>
273         /// Creates an initialized ImageView.
274         /// </summary>
275         /// <since_tizen> 3 </since_tizen>
276         public ImageView() : this(Interop.ImageView.New(), true)
277         {
278             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279         }
280
281         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
282         [EditorBrowsable(EditorBrowsableState.Never)]
283         public ImageView(ViewStyle viewStyle) : this(Interop.ImageView.New(), true, viewStyle)
284         {
285         }
286
287         /// <summary>
288         /// Creates an initialized ImageView with setting the status of shown or hidden.
289         /// </summary>
290         /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
291         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
292         [EditorBrowsable(EditorBrowsableState.Never)]
293         public ImageView(bool shown) : this(Interop.ImageView.New(), true)
294         {
295             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296             SetVisible(shown);
297         }
298
299         /// <summary>
300         /// Creates an initialized ImageView from a URL to an image resource.<br />
301         /// If the string is empty, ImageView will not display anything.<br />
302         /// </summary>
303         /// <param name="url">The URL of the image resource to display.</param>
304         /// <since_tizen> 3 </since_tizen>
305         public ImageView(string url) : this(Interop.ImageView.New(url), true)
306         {
307             ResourceUrl = url;
308             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309
310         }
311
312         /// <summary>
313         /// Creates an initialized ImageView from a URL to an image resource with setting shown or hidden.
314         /// </summary>
315         /// <param name="url">The URL of the image resource to display.</param>
316         /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
317         /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
318         [EditorBrowsable(EditorBrowsableState.Never)]
319         public ImageView(string url, bool shown) : this(Interop.ImageView.New(url), true)
320         {
321             ResourceUrl = url;
322             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323             SetVisible(shown);
324         }
325
326         internal ImageView(string url, Uint16Pair size, bool shown = true) : this(Interop.ImageView.New(url, Uint16Pair.getCPtr(size)), true)
327         {
328             ResourceUrl = url;
329             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330
331             if (!shown)
332             {
333                 SetVisible(false);
334             }
335         }
336
337         internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(cPtr, cMemoryOwn, viewStyle)
338         {
339             if (!shown)
340             {
341                 SetVisible(false);
342             }
343         }
344
345         internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn, null)
346         {
347             if (!shown)
348             {
349                 SetVisible(false);
350             }
351         }
352
353         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
354         private delegate void ResourceReadyEventCallbackType(IntPtr data);
355         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
356         private delegate void _resourceLoadedCallbackType(IntPtr view);
357
358         /// <summary>
359         /// An event for ResourceReady signal which can be used to subscribe or unsubscribe the event handler.<br />
360         /// This signal is emitted after all resources required by a control are loaded and ready.<br />
361         /// Most resources are only loaded when the control is placed on the stage.<br />
362         /// </summary>
363         /// <since_tizen> 3 </since_tizen>
364         public event EventHandler<ResourceReadyEventArgs> ResourceReady
365         {
366             add
367             {
368                 if (_resourceReadyEventHandler == null)
369                 {
370                     _resourceReadyEventCallback = OnResourceReady;
371                     ViewResourceReadySignal resourceReadySignal = ResourceReadySignal(this);
372                     resourceReadySignal?.Connect(_resourceReadyEventCallback);
373                     resourceReadySignal?.Dispose();
374                 }
375
376                 _resourceReadyEventHandler += value;
377             }
378
379             remove
380             {
381                 _resourceReadyEventHandler -= value;
382
383                 ViewResourceReadySignal resourceReadySignal = ResourceReadySignal(this);
384                 if (_resourceReadyEventHandler == null && resourceReadySignal?.Empty() == false)
385                 {
386                     resourceReadySignal?.Disconnect(_resourceReadyEventCallback);
387                 }
388                 resourceReadySignal?.Dispose();
389             }
390         }
391
392         internal event EventHandler<ResourceLoadedEventArgs> ResourceLoaded
393         {
394             add
395             {
396                 if (_resourceLoadedEventHandler == null)
397                 {
398                     _resourceLoadedCallback = OnResourceLoaded;
399                     ViewResourceReadySignal resourceReadySignal = this.ResourceReadySignal(this);
400                     resourceReadySignal?.Connect(_resourceLoadedCallback);
401                     resourceReadySignal?.Dispose();
402                 }
403
404                 _resourceLoadedEventHandler += value;
405             }
406             remove
407             {
408                 _resourceLoadedEventHandler -= value;
409                 ViewResourceReadySignal resourceReadySignal = this.ResourceReadySignal(this);
410                 if (_resourceLoadedEventHandler == null && resourceReadySignal?.Empty() == false)
411                 {
412                     resourceReadySignal?.Disconnect(_resourceLoadedCallback);
413                 }
414                 resourceReadySignal?.Dispose();
415             }
416         }
417
418         /// <summary>
419         /// Enumeration for LoadingStatus of image.
420         /// </summary>
421         /// <since_tizen> 5 </since_tizen>
422         public enum LoadingStatusType
423         {
424             /// <summary>
425             /// Loading preparing status.
426             /// </summary>
427             /// <since_tizen> 5 </since_tizen>
428             Preparing,
429             /// <summary>
430             /// Loading ready status.
431             /// </summary>
432             /// <since_tizen> 5 </since_tizen>
433             Ready,
434             /// <summary>
435             /// Loading failed status.
436             /// </summary>
437             /// <since_tizen> 5 </since_tizen>
438             Failed
439         }
440
441         /// <summary>
442         /// ImageView ResourceUrl, type string.
443         /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
444         /// When it is set as null, it gives empty string ("") to be read.
445         /// </summary>
446         /// <since_tizen> 3 </since_tizen>
447         public string ResourceUrl
448         {
449             get
450             {
451                 return (string)GetValue(ResourceUrlProperty);
452             }
453             set
454             {
455                 SetValue(ResourceUrlProperty, value);
456                 resourceUrlSelector.UpdateIfNeeds(this, value);
457                 NotifyPropertyChanged();
458             }
459         }
460
461         /// <summary>
462         /// This will be deprecated, please use Image instead. <br />
463         /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
464         /// </summary>
465         /// <since_tizen> 3 </since_tizen>
466         [Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
467         [EditorBrowsable(EditorBrowsableState.Never)]
468         public PropertyMap ImageMap
469         {
470             get
471             {
472                 if (_border == null)
473                 {
474                     PropertyMap returnValue = new PropertyMap();
475                     PropertyValue image = GetProperty(ImageView.Property.IMAGE);
476                     image?.Get(returnValue);
477                     image?.Dispose();
478                     return returnValue;
479                 }
480                 else
481                 {
482                     return null;
483                 }
484             }
485             set
486             {
487                 if (_border == null)
488                 {
489                     PropertyValue setValue = new Tizen.NUI.PropertyValue(value);
490                     SetProperty(ImageView.Property.IMAGE, setValue);
491                     NotifyPropertyChanged();
492                     setValue?.Dispose();
493                 }
494             }
495         }
496
497         /// <summary>
498         /// ImageView Image, type PropertyMap
499         /// </summary>
500         /// <since_tizen> 4 </since_tizen>
501         public PropertyMap Image
502         {
503             get
504             {
505                 if (_border == null)
506                 {
507                     return (PropertyMap)GetValue(ImageProperty);
508                 }
509                 else
510                 {
511                     return null;
512                 }
513             }
514             set
515             {
516                 if (_border == null)
517                 {
518                     SetValue(ImageProperty, value);
519                     NotifyPropertyChanged();
520                 }
521             }
522         }
523
524         /// <summary>
525         /// ImageView PreMultipliedAlpha, type Boolean.<br />
526         /// Image must be initialized.<br />
527         /// </summary>
528         /// <since_tizen> 3 </since_tizen>
529         public bool PreMultipliedAlpha
530         {
531             get
532             {
533                 return (bool)GetValue(PreMultipliedAlphaProperty);
534             }
535             set
536             {
537                 SetValue(PreMultipliedAlphaProperty, value);
538                 NotifyPropertyChanged();
539             }
540         }
541
542         /// <summary>
543         /// ImageView PixelArea, type Vector4 (Animatable property).<br />
544         /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br />
545         /// </summary>
546         /// <remarks>
547         /// The property cascade chaining set is possible. For example, this (imageView.PixelArea.X = 0.1f;) is possible.
548         /// </remarks>
549         /// <since_tizen> 3 </since_tizen>
550         public RelativeVector4 PixelArea
551         {
552             get
553             {
554                 RelativeVector4 temp = (RelativeVector4)GetValue(PixelAreaProperty);
555                 return new RelativeVector4(OnPixelAreaChanged, temp.X, temp.Y, temp.Z, temp.W);
556             }
557             set
558             {
559                 SetValue(PixelAreaProperty, value);
560                 NotifyPropertyChanged();
561             }
562         }
563
564         /// <summary>
565         /// The border of the image in the order: left, right, bottom, top.<br />
566         /// If set, ImageMap will be ignored.<br />
567         /// For N-Patch images only.<br />
568         /// Optional.
569         /// </summary>
570         /// <remarks>
571         /// The property cascade chaining set is possible. For example, this (imageView.Border.X = 1;) is possible.
572         /// </remarks>
573         /// <since_tizen> 3 </since_tizen>
574         public Rectangle Border
575         {
576             get
577             {
578                 Rectangle temp = (Rectangle)GetValue(BorderProperty);
579                 if (null == temp)
580                 {
581                     return null;
582                 }
583                 else
584                 {
585                     return new Rectangle(OnBorderChanged, temp.X, temp.Y, temp.Width, temp.Height);
586                 }
587             }
588             set
589             {
590                 SetValue(BorderProperty, value);
591                 borderSelector.UpdateIfNeeds(this, value);
592                 NotifyPropertyChanged();
593             }
594         }
595
596         /// <summary>
597         /// Gets or sets whether to draw the borders only (if true).<br />
598         /// If not specified, the default is false.<br />
599         /// For N-Patch images only.<br />
600         /// Optional.
601         /// </summary>
602         /// <since_tizen> 3 </since_tizen>
603         public bool BorderOnly
604         {
605             get
606             {
607                 return (bool)GetValue(BorderOnlyProperty);
608             }
609             set
610             {
611                 SetValue(BorderOnlyProperty, value);
612                 NotifyPropertyChanged();
613             }
614         }
615
616         /// <summary>
617         /// Gets or sets whether to synchronos loading the resourceurl of image.<br />
618         /// </summary>
619         /// <since_tizen> 3 </since_tizen>
620         public bool SynchronosLoading
621         {
622             get
623             {
624                 return (bool)GetValue(SynchronosLoadingProperty);
625             }
626             set
627             {
628                 SetValue(SynchronosLoadingProperty, value);
629                 NotifyPropertyChanged();
630             }
631         }
632
633         /// <summary>
634         /// Gets or sets whether to automatically correct the orientation of an image.<br />
635         /// </summary>
636         /// <since_tizen> 5 </since_tizen>
637         public bool OrientationCorrection
638         {
639             get
640             {
641                 return (bool)GetValue(OrientationCorrectionProperty);
642             }
643             set
644             {
645                 SetValue(OrientationCorrectionProperty, value);
646                 NotifyPropertyChanged();
647             }
648         }
649
650         /// <summary>
651         /// Gets the loading state of the visual resource.
652         /// </summary>
653         /// <since_tizen> 5 </since_tizen>
654         public ImageView.LoadingStatusType LoadingStatus
655         {
656             get
657             {
658                 return (ImageView.LoadingStatusType)Interop.View.GetVisualResourceStatus(SwigCPtr, (int)Property.IMAGE);
659             }
660         }
661
662         /// <summary>
663         /// Downcasts a handle to imageView handle.
664         /// </summary>
665         /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
666         /// Please do not use! this will be deprecated!
667         /// Instead please use as keyword.
668         /// <since_tizen> 3 </since_tizen>
669         [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
670         "Like: " +
671         "BaseHandle handle = new ImageView(imagePath); " +
672         "ImageView image = handle as ImageView")]
673         [EditorBrowsable(EditorBrowsableState.Never)]
674         public static ImageView DownCast(BaseHandle handle)
675         {
676             if (null == handle)
677             {
678                 throw new ArgumentNullException(nameof(handle));
679             }
680             ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
681             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
682             return ret;
683         }
684
685         /// <summary>
686         /// Sets this ImageView from the given URL.<br />
687         /// If the URL is empty, ImageView will not display anything.<br />
688         /// </summary>
689         /// <param name="url">The URL to the image resource to display.</param>
690         /// <exception cref="ArgumentNullException"> Thrown when url is null. </exception>
691         /// <since_tizen> 3 </since_tizen>
692         public void SetImage(string url)
693         {
694             if (null == url)
695             {
696                 throw new ArgumentNullException(nameof(url));
697             }
698
699             if (url.Contains(".json"))
700             {
701                 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
702                 return;
703             }
704
705             Interop.ImageView.SetImage(SwigCPtr, url);
706             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707
708             ResourceUrl = url;
709         }
710
711         /// <summary>
712         /// Queries if all resources required by a control are loaded and ready.<br />
713         /// Most resources are only loaded when the control is placed on the stage.<br />
714         /// True if the resources are loaded and ready, false otherwise.<br />
715         /// </summary>
716         /// <since_tizen> 3 </since_tizen>
717         public new bool IsResourceReady()
718         {
719             bool ret = Interop.View.IsResourceReady(SwigCPtr);
720             if (NDalicPINVOKE.SWIGPendingException.Pending)
721                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
722             return ret;
723         }
724
725         /// <summary>
726         /// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
727         /// </summary>
728         /// <since_tizen> 5 </since_tizen>
729         public void Reload()
730         {
731             PropertyValue attributes = new PropertyValue(0);
732             this.DoAction(ImageView.Property.IMAGE, Property.ActionReload, attributes);
733             attributes?.Dispose();
734         }
735
736         /// <summary>
737         /// Plays the animated GIF. This is also the default playback mode.
738         /// </summary>
739         /// <since_tizen> 5 </since_tizen>
740         public void Play()
741         {
742             PropertyValue attributes = new PropertyValue(0);
743             this.DoAction(ImageView.Property.IMAGE, Property.ActionPlay, attributes);
744             attributes?.Dispose();
745         }
746
747         /// <summary>
748         /// Pauses the animated GIF.
749         /// </summary>
750         /// <since_tizen> 5 </since_tizen>
751         public void Pause()
752         {
753             PropertyValue attributes = new PropertyValue(0);
754             this.DoAction(ImageView.Property.IMAGE, Property.ActionPause, attributes);
755             attributes?.Dispose();
756         }
757
758         /// <summary>
759         /// Stops the animated GIF.
760         /// </summary>
761         /// <since_tizen> 5 </since_tizen>
762         public void Stop()
763         {
764             PropertyValue attributes = new PropertyValue(0);
765             this.DoAction(ImageView.Property.IMAGE, Property.ActionStop, attributes);
766             attributes?.Dispose();
767         }
768
769         /// <summary>
770         /// Gets or sets the URL of the alpha mask.<br />
771         /// Optional.
772         /// </summary>
773         /// <since_tizen> 6</since_tizen>
774         [EditorBrowsable(EditorBrowsableState.Never)]
775         public string AlphaMaskURL
776         {
777             get
778             {
779                 string ret = "";
780                 PropertyMap imageMap = new PropertyMap();
781                 PropertyValue image = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE);
782                 image?.Get(imageMap);
783                 PropertyValue maskUrl = imageMap?.Find(ImageVisualProperty.AlphaMaskURL);
784                 maskUrl?.Get(out ret);
785                 _alphaMaskUrl = ret;
786
787                 imageMap?.Dispose();
788                 image?.Dispose();
789                 maskUrl?.Dispose();
790
791                 return ret;
792             }
793             set
794             {
795                 if (value == null)
796                 {
797                     value = "";
798                 }
799
800                 _alphaMaskUrl = value;
801
802                 PropertyValue setValue = new PropertyValue(value);
803                 UpdateImage(ImageVisualProperty.AlphaMaskURL, setValue);
804                 setValue?.Dispose();
805             }
806         }
807
808
809         /// <summary>
810         ///  Whether to crop image to mask or scale mask to fit image.
811         /// </summary>
812         /// <since_tizen> 6 </since_tizen>
813         public bool CropToMask
814         {
815             get
816             {
817                 bool ret = false;
818                 PropertyMap imageMap = new PropertyMap();
819                 PropertyValue image = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE);
820                 image?.Get(imageMap);
821                 PropertyValue cropUrl = imageMap?.Find(ImageVisualProperty.CropToMask);
822                 cropUrl?.Get(out ret);
823
824                 imageMap?.Dispose();
825                 image?.Dispose();
826                 cropUrl?.Dispose();
827
828                 return ret;
829             }
830             set
831             {
832                 PropertyValue setValue = new PropertyValue(value);
833                 UpdateImage(ImageVisualProperty.CropToMask, setValue);
834                 setValue.Dispose();
835             }
836         }
837
838         internal VisualFittingModeType CovertFittingModetoVisualFittingMode(FittingModeType value)
839         {
840             switch (value)
841             {
842                 case FittingModeType.ShrinkToFit:
843                     return VisualFittingModeType.FitKeepAspectRatio;
844                 case FittingModeType.ScaleToFill:
845                     return VisualFittingModeType.OverFitKeepAspectRatio;
846                 case FittingModeType.Center:
847                     return VisualFittingModeType.Center;
848                 case FittingModeType.Fill:
849                     return VisualFittingModeType.Fill;
850                 case FittingModeType.FitHeight:
851                     return VisualFittingModeType.FitHeight;
852                 case FittingModeType.FitWidth:
853                     return VisualFittingModeType.FitHeight;
854                 default:
855                     return VisualFittingModeType.Fill;
856             }
857         }
858
859         internal FittingModeType ConvertVisualFittingModetoFittingMode(VisualFittingModeType value)
860         {
861             switch (value)
862             {
863                 case VisualFittingModeType.FitKeepAspectRatio:
864                     return FittingModeType.ShrinkToFit;
865                 case VisualFittingModeType.OverFitKeepAspectRatio:
866                     return FittingModeType.ScaleToFill;
867                 case VisualFittingModeType.Center:
868                     return FittingModeType.Center;
869                 case VisualFittingModeType.Fill:
870                     return FittingModeType.Fill;
871                 case VisualFittingModeType.FitHeight:
872                     return FittingModeType.FitHeight;
873                 case VisualFittingModeType.FitWidth:
874                     return FittingModeType.FitWidth;
875                 default:
876                     return FittingModeType.ShrinkToFit;
877             }
878         }
879
880         /// <summary>
881         /// Gets or sets fitting options used when resizing images to fit.<br />
882         /// If not supplied, the default is FittingModeType.Fill.<br />
883         /// For normal quad images only.<br />
884         /// Optional.
885         /// </summary>
886         /// <since_tizen> 6 </since_tizen>
887         [EditorBrowsable(EditorBrowsableState.Never)]
888         public FittingModeType FittingMode
889         {
890             get
891             {
892                 int ret = (int)VisualFittingModeType.Fill;
893                 PropertyMap imageMap = new PropertyMap();
894                 PropertyValue image = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE);
895                 image?.Get(imageMap);
896                 PropertyValue fittingMode = imageMap?.Find(Visual.Property.VisualFittingMode);
897                 fittingMode?.Get(out ret);
898
899                 imageMap?.Dispose();
900                 image?.Dispose();
901                 fittingMode?.Dispose();
902
903                 return ConvertVisualFittingModetoFittingMode((VisualFittingModeType)ret);
904             }
905             set
906             {
907                 VisualFittingModeType ret = CovertFittingModetoVisualFittingMode(value);
908                 PropertyValue setValue = new PropertyValue((int)ret);
909                 UpdateImage(Visual.Property.VisualFittingMode, setValue);
910                 setValue?.Dispose();
911             }
912         }
913
914
915
916         /// <summary>
917         /// Gets or sets the desired image width.<br />
918         /// If not specified, the actual image width is used.<br />
919         /// For normal quad images only.<br />
920         /// Optional.
921         /// </summary>
922         /// <since_tizen> 6 </since_tizen>
923         [EditorBrowsable(EditorBrowsableState.Never)]
924         public int DesiredWidth
925         {
926             get
927             {
928                 PropertyMap imageMap = new PropertyMap();
929                 PropertyValue image = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE);
930                 image?.Get(imageMap);
931                 PropertyValue desireWidth = imageMap?.Find(ImageVisualProperty.DesiredWidth);
932                 desireWidth?.Get(out _desired_width);
933
934                 imageMap?.Dispose();
935                 image?.Dispose();
936                 desireWidth?.Dispose();
937
938                 return _desired_width;
939             }
940             set
941             {
942                 if (_desired_width != value)
943                 {
944                     _desired_width = value;
945                     UpdateImage(0, null);
946                 }
947             }
948         }
949
950         /// <summary>
951         /// Gets or sets the desired image height.<br />
952         /// If not specified, the actual image height is used.<br />
953         /// For normal quad images only.<br />
954         /// Optional.
955         /// </summary>
956         /// <since_tizen> 6 </since_tizen>
957         [EditorBrowsable(EditorBrowsableState.Never)]
958         public int DesiredHeight
959         {
960             get
961             {
962                 PropertyMap imageMap = new PropertyMap();
963                 PropertyValue image = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE);
964                 image?.Get(imageMap);
965                 PropertyValue desireheight = imageMap?.Find(ImageVisualProperty.DesiredHeight);
966                 desireheight?.Get(out _desired_height);
967
968                 imageMap?.Dispose();
969                 image?.Dispose();
970                 desireheight?.Dispose();
971
972                 return _desired_height;
973             }
974             set
975             {
976                 if (_desired_height != value)
977                 {
978                     _desired_height = value;
979                     UpdateImage(0, null);
980                 }
981             }
982         }
983
984         /// <summary>
985         /// Gets or sets ReleasePolicy for image.<br />
986         /// If not supplied, the default is ReleasePolicyType.Detached.<br />
987         /// </summary>
988         [EditorBrowsable(EditorBrowsableState.Never)]
989         public ReleasePolicyType ReleasePolicy
990         {
991             get
992             {
993                 int ret = (int)ReleasePolicyType.Detached;
994                 PropertyMap imageMap = new PropertyMap();
995                 PropertyValue image = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE);
996                 image?.Get(imageMap);
997                 PropertyValue releasePoli = imageMap?.Find(ImageVisualProperty.ReleasePolicy);
998                 releasePoli?.Get(out ret);
999
1000                 imageMap?.Dispose();
1001                 image?.Dispose();
1002                 releasePoli?.Dispose();
1003
1004                 return (ReleasePolicyType)ret;
1005             }
1006             set
1007             {
1008                 PropertyValue setValue = new PropertyValue((int)value);
1009                 UpdateImage(ImageVisualProperty.ReleasePolicy, setValue);
1010                 setValue?.Dispose();
1011             }
1012         }
1013
1014         /// <summary>
1015         /// Gets or sets the wrap mode for the u coordinate.<br />
1016         /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br />
1017         /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
1018         /// For normal quad images only.<br />
1019         /// Optional.
1020         /// </summary>
1021         /// <since_tizen> 6 </since_tizen>
1022         [EditorBrowsable(EditorBrowsableState.Never)]
1023         public WrapModeType WrapModeU
1024         {
1025             get
1026             {
1027                 int ret = (int)WrapModeType.Default;
1028                 PropertyMap imageMap = new PropertyMap();
1029                 PropertyValue image = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE);
1030                 image?.Get(imageMap);
1031                 PropertyValue warpModeU = imageMap?.Find(ImageVisualProperty.WrapModeU);
1032                 warpModeU?.Get(out ret);
1033
1034                 imageMap?.Dispose();
1035                 image?.Dispose();
1036                 warpModeU?.Dispose();
1037
1038                 return (WrapModeType)ret;
1039             }
1040             set
1041             {
1042                 PropertyValue setValue = new PropertyValue((int)value);
1043                 UpdateImage(ImageVisualProperty.WrapModeU, setValue);
1044                 setValue?.Dispose();
1045             }
1046         }
1047
1048         /// <summary>
1049         /// Gets or sets the wrap mode for the v coordinate.<br />
1050         /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br />
1051         /// The first two elements indicate the top-left position of the area, and the last two elements are the areas of the width and the height respectively.<br />
1052         /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
1053         /// For normal quad images only.
1054         /// Optional.
1055         /// </summary>
1056         /// <since_tizen> 6 </since_tizen>
1057         [EditorBrowsable(EditorBrowsableState.Never)]
1058         public WrapModeType WrapModeV
1059         {
1060             get
1061             {
1062                 int ret = (int)WrapModeType.Default;
1063                 PropertyMap imageMap = new PropertyMap();
1064                 PropertyValue image = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE);
1065                 image?.Get(imageMap);
1066                 PropertyValue wrapModeV = imageMap?.Find(ImageVisualProperty.WrapModeV);
1067                 wrapModeV?.Get(out ret);
1068
1069                 imageMap?.Dispose();
1070                 image?.Dispose();
1071                 wrapModeV?.Dispose();
1072
1073                 return (WrapModeType)ret;
1074             }
1075             set
1076             {
1077                 PropertyValue setValue = new PropertyValue((int)value);
1078                 UpdateImage(ImageVisualProperty.WrapModeV, setValue);
1079                 setValue?.Dispose();
1080             }
1081         }
1082
1083         /// <summary>
1084         /// Get attribues, it is abstract function and must be override.
1085         /// </summary>
1086         [EditorBrowsable(EditorBrowsableState.Never)]
1087         protected override ViewStyle CreateViewStyle()
1088         {
1089             return new ImageViewStyle();
1090         }
1091
1092         internal void SetImage(string url, Uint16Pair size)
1093         {
1094             if (url.Contains(".json"))
1095             {
1096                 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
1097                 return;
1098             }
1099
1100             Interop.ImageView.SetImage(SwigCPtr, url, Uint16Pair.getCPtr(size));
1101             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1102
1103             ResourceUrl = url;
1104         }
1105
1106         internal ViewResourceReadySignal ResourceReadySignal(View view)
1107         {
1108             ViewResourceReadySignal ret = new ViewResourceReadySignal(Interop.View.ResourceReadySignal(View.getCPtr(view)), false);
1109             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1110             return ret;
1111         }
1112
1113         internal override void ApplyCornerRadius()
1114         {
1115             base.ApplyCornerRadius();
1116
1117             UpdateImage(0, null);
1118         }
1119
1120         internal ResourceLoadingStatusType GetResourceStatus()
1121         {
1122             return (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.IMAGE);
1123         }
1124
1125         /// <summary>
1126         /// you can override it to clean-up your own resources.
1127         /// </summary>
1128         /// <param name="type">DisposeTypes</param>
1129         /// <since_tizen> 3 </since_tizen>
1130         protected override void Dispose(DisposeTypes type)
1131         {
1132             if (disposed)
1133             {
1134                 return;
1135             }
1136
1137             if (type == DisposeTypes.Explicit)
1138             {
1139                 //Called by User
1140                 //Release your own managed resources here.
1141                 //You should release all of your own disposable objects here.
1142                 _border?.Dispose();
1143                 _border = null;
1144                 borderSelector.Reset(this);
1145                 resourceUrlSelector.Reset(this);
1146             }
1147
1148             base.Dispose(type);
1149         }
1150
1151         /// This will not be public opened.
1152         [EditorBrowsable(EditorBrowsableState.Never)]
1153         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1154         {
1155             Interop.ImageView.DeleteImageView(swigCPtr);
1156         }
1157
1158         // Callback for View ResourceReady signal
1159         private void OnResourceReady(IntPtr data)
1160         {
1161             ResourceReadyEventArgs e = new ResourceReadyEventArgs();
1162             if (data != null)
1163             {
1164                 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1165             }
1166
1167             if (_resourceReadyEventHandler != null)
1168             {
1169                 _resourceReadyEventHandler(this, e);
1170             }
1171         }
1172
1173         private void UpdateImageMap(PropertyMap fromMap)
1174         {
1175             PropertyMap imageMap = new PropertyMap();
1176
1177             PropertyValue image = Tizen.NUI.Object.GetProperty(SwigCPtr, ImageView.Property.IMAGE);
1178             image?.Get(imageMap);
1179             imageMap?.Merge(fromMap);
1180             PropertyValue setValue = new PropertyValue(imageMap);
1181             SetProperty(ImageView.Property.IMAGE, setValue);
1182
1183             imageMap?.Dispose();
1184             image?.Dispose();
1185             setValue?.Dispose();
1186         }
1187
1188         private void UpdateImage(int key, PropertyValue value)
1189         {
1190             PropertyMap imageMap = new PropertyMap();
1191
1192             if (_alphaMaskUrl != null)
1193             {
1194                 PropertyValue alphaMaskUrl = new PropertyValue(_alphaMaskUrl);
1195                 imageMap?.Insert(ImageVisualProperty.AlphaMaskURL, alphaMaskUrl);
1196                 alphaMaskUrl?.Dispose();
1197             }
1198
1199             if (string.IsNullOrEmpty(_resourceUrl))
1200             {
1201                 PropertyValue resourceUrl = new PropertyValue(_resourceUrl);
1202                 imageMap?.Insert(ImageVisualProperty.URL, resourceUrl);
1203                 PropertyValue setValue = new PropertyValue(imageMap);
1204                 SetProperty(ImageView.Property.IMAGE, setValue);
1205                 resourceUrl?.Dispose();
1206                 setValue?.Dispose();
1207                 return;
1208             }
1209
1210             if (_border == null)
1211             {
1212                 PropertyValue image = new PropertyValue((int)Visual.Type.Image);
1213                 imageMap?.Insert(Visual.Property.Type, image);
1214                 image?.Dispose();
1215             }
1216             else
1217             {
1218                 PropertyValue nPatch = new PropertyValue((int)Visual.Type.NPatch);
1219                 imageMap?.Insert(Visual.Property.Type, nPatch);
1220                 nPatch?.Dispose();
1221                 PropertyValue border = new PropertyValue(_border);
1222                 imageMap?.Insert(NpatchImageVisualProperty.Border, border);
1223                 border?.Dispose();
1224             }
1225
1226             PropertyValue synchronosLoading = new PropertyValue(_synchronosLoading);
1227             imageMap?.Insert(NpatchImageVisualProperty.SynchronousLoading, synchronosLoading);
1228             synchronosLoading?.Dispose();
1229
1230             if (backgroundExtraData != null && backgroundExtraData.CornerRadius > 0)
1231             {
1232                 using (var cornerRadius = new PropertyValue(backgroundExtraData.CornerRadius))
1233                 using (var cornerRadiusPolicy = new PropertyValue((int)backgroundExtraData.CornerRadiusPolicy))
1234                 {
1235                     imageMap.Insert(Visual.Property.CornerRadius, cornerRadius);
1236                     imageMap.Insert(Visual.Property.CornerRadiusPolicy, new PropertyValue((int)(backgroundExtraData.CornerRadiusPolicy)));
1237                 }
1238             }
1239
1240             if (value != null)
1241             {
1242                 imageMap?.Insert(key, value);
1243             }
1244
1245             // Do Fitting Buffer when desired dimension is set
1246             if (_desired_width != -1 && _desired_height != -1)
1247             {
1248                 if (_resourceUrl != null)
1249                 {
1250                     Size2D imageSize = ImageLoading.GetOriginalImageSize(_resourceUrl, true);
1251
1252                     int adjustedDesiredWidth, adjustedDesiredHeight;
1253                     float aspectOfDesiredSize = (float)_desired_height / (float)_desired_width;
1254                     float aspectOfImageSize = (float)imageSize.Height / (float)imageSize.Width;
1255                     if (aspectOfImageSize > aspectOfDesiredSize)
1256                     {
1257                         adjustedDesiredWidth = _desired_width;
1258                         adjustedDesiredHeight = imageSize.Height * _desired_width / imageSize.Width;
1259                     }
1260                     else
1261                     {
1262                         adjustedDesiredWidth = imageSize.Width * _desired_height / imageSize.Height;
1263                         adjustedDesiredHeight = _desired_height;
1264                     }
1265
1266                     PropertyValue returnWidth = new PropertyValue(adjustedDesiredWidth);
1267                     imageMap?.Insert(ImageVisualProperty.DesiredWidth, returnWidth);
1268                     returnWidth?.Dispose();
1269                     PropertyValue returnHeight = new PropertyValue(adjustedDesiredHeight);
1270                     imageMap?.Insert(ImageVisualProperty.DesiredHeight, returnHeight);
1271                     returnHeight?.Dispose();
1272                     PropertyValue scaleToFit = new PropertyValue((int)FittingModeType.ScaleToFill);
1273                     imageMap?.Insert(ImageVisualProperty.FittingMode, scaleToFit);
1274                     scaleToFit?.Dispose();
1275                 }
1276             }
1277
1278             UpdateImageMap(imageMap);
1279
1280             imageMap?.Dispose();
1281             imageMap = null;
1282         }
1283
1284
1285         private void OnResourceLoaded(IntPtr view)
1286         {
1287             ResourceLoadedEventArgs e = new ResourceLoadedEventArgs();
1288             e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.IMAGE);
1289
1290             if (_resourceLoadedEventHandler != null)
1291             {
1292                 _resourceLoadedEventHandler(this, e);
1293             }
1294         }
1295
1296         /// <summary>
1297         /// Event arguments of resource ready.
1298         /// </summary>
1299         /// <since_tizen> 3 </since_tizen>
1300         public class ResourceReadyEventArgs : EventArgs
1301         {
1302             private View _view;
1303
1304             /// <summary>
1305             /// The view whose resource is ready.
1306             /// </summary>
1307             /// <since_tizen> 3 </since_tizen>
1308             public View View
1309             {
1310                 get
1311                 {
1312                     return _view;
1313                 }
1314                 set
1315                 {
1316                     _view = value;
1317                 }
1318             }
1319         }
1320
1321         internal class ResourceLoadedEventArgs : EventArgs
1322         {
1323             private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1324             public ResourceLoadingStatusType Status
1325             {
1326                 get
1327                 {
1328                     return status;
1329                 }
1330                 set
1331                 {
1332                     status = value;
1333                 }
1334             }
1335         }
1336
1337         internal new class Property
1338         {
1339             internal static readonly int IMAGE = Interop.ImageView.ImageGet();
1340             internal static readonly int PreMultipliedAlpha = Interop.ImageView.PreMultipliedAlphaGet();
1341             internal static readonly int PixelArea = Interop.ImageView.PixelAreaGet();
1342             internal static readonly int ActionReload = Interop.ImageView.ImageVisualActionReloadGet();
1343             internal static readonly int ActionPlay = Interop.ImageView.ImageVisualActionPlayGet();
1344             internal static readonly int ActionPause = Interop.ImageView.ImageVisualActionPauseGet();
1345             internal static readonly int ActionStop = Interop.ImageView.ImageVisualActionStopGet();
1346         }
1347
1348         private enum ImageType
1349         {
1350             /// <summary>
1351             /// For Normal Image.
1352             /// </summary>
1353             Normal = 0,
1354
1355             /// <summary>
1356             /// For normal image, with synchronous loading and orientation correction property
1357             /// </summary>
1358             Specific = 1,
1359
1360             /// <summary>
1361             /// For nine-patch image
1362             /// </summary>
1363             Npatch = 2,
1364         }
1365
1366         private void OnBorderChanged(int x, int y, int width, int height)
1367         {
1368             Border = new Rectangle(x, y, width, height);
1369         }
1370         private void OnPixelAreaChanged(float x, float y, float z, float w)
1371         {
1372             PixelArea = new RelativeVector4(x, y, z, w);
1373         }
1374     }
1375 }