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