2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
19 using System.ComponentModel;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.BaseComponents
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 />
29 /// <since_tizen> 3 </since_tizen>
30 public class ImageView : View
32 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33 [EditorBrowsable(EditorBrowsableState.Never)]
34 public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ImageView.ResourceUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
36 var imageView = (ImageView)bindable;
37 string url = (string)newValue;
38 url = (url == null ? "" : url);
39 if (imageView.IsCreateByXaml && url.Contains("*Resource*"))
41 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
42 url = url.Replace("*Resource*", resource);
44 imageView._resourceUrl = url;
45 imageView.UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
47 defaultValueCreator: (bindable) =>
49 var imageView = (ImageView)bindable;
52 PropertyMap imageMap = new PropertyMap();
53 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
54 imageMap.Find(ImageVisualProperty.URL)?.Get(out ret);
58 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
59 [EditorBrowsable(EditorBrowsableState.Never)]
60 public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(ImageView.Image), typeof(PropertyMap), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
62 var imageView = (ImageView)bindable;
65 PropertyMap map = (PropertyMap)newValue;
66 if (imageView.IsCreateByXaml)
68 string url = "", alphaMaskURL = "", auxiliaryImageURL = "";
69 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
70 PropertyValue urlValue = map.Find(NDalic.IMAGE_VISUAL_URL);
72 if (urlValue != null) ret = urlValue.Get(out url);
73 PropertyMap mmap = new PropertyMap();
74 if (ret && url.Contains("*Resource*"))
76 url = url.Replace("*Resource*", resource);
77 mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(url));
81 PropertyValue alphaMaskUrlValue = map.Find(NDalic.IMAGE_VISUAL_ALPHA_MASK_URL);
82 if (alphaMaskUrlValue != null) ret = alphaMaskUrlValue.Get(out alphaMaskURL);
83 if (ret && alphaMaskURL.Contains("*Resource*"))
85 alphaMaskURL = alphaMaskURL.Replace("*Resource*", resource);
86 mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(alphaMaskURL));
90 PropertyValue auxiliaryImageURLValue = map.Find(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL);
91 if (auxiliaryImageURLValue != null) ret = auxiliaryImageURLValue.Get(out auxiliaryImageURL);
92 if (ret && auxiliaryImageURL.Contains("*Resource*"))
94 auxiliaryImageURL = auxiliaryImageURL.Replace("*Resource*", resource);
95 mmap.Insert(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL, new PropertyValue(auxiliaryImageURL));
100 if (imageView._border == null)
102 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
106 defaultValueCreator: (bindable) =>
108 var imageView = (ImageView)bindable;
109 if (imageView._border == null)
111 PropertyMap temp = new PropertyMap();
112 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(temp);
121 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
122 [EditorBrowsable(EditorBrowsableState.Never)]
123 public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create("PreMultipliedAlpha", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
125 var imageView = (ImageView)bindable;
126 if (newValue != null)
128 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue((bool)newValue));
131 defaultValueCreator: (bindable) =>
133 var imageView = (ImageView)bindable;
135 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
139 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create("PixelArea", typeof(RelativeVector4), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
143 var imageView = (ImageView)bindable;
144 if (newValue != null)
146 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
149 defaultValueCreator: (bindable) =>
151 var imageView = (ImageView)bindable;
152 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
153 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA).Get(temp);
154 RelativeVector4 relativeTemp = new RelativeVector4(temp.X, temp.Y, temp.Z, temp.W);
158 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
159 [EditorBrowsable(EditorBrowsableState.Never)]
160 public static readonly BindableProperty BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
164 var imageView = (ImageView)bindable;
165 imageView._border = (Rectangle)newValue;
166 imageView.UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(imageView._border));
169 defaultValueCreator: (bindable) =>
171 var imageView = (ImageView)bindable;
172 return imageView._border;
175 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
176 [EditorBrowsable(EditorBrowsableState.Never)]
177 public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create("BorderOnly", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
179 var imageView = (ImageView)bindable;
180 if (newValue != null)
182 imageView.UpdateImage(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)newValue));
185 defaultValueCreator: (bindable) =>
187 var imageView = (ImageView)bindable;
189 PropertyMap imageMap = new PropertyMap();
190 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
191 imageMap.Find(ImageVisualProperty.BorderOnly)?.Get(out ret);
195 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
196 [EditorBrowsable(EditorBrowsableState.Never)]
197 public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create("SynchronosLoading", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
199 var imageView = (ImageView)bindable;
200 if (newValue != null)
202 imageView._synchronosLoading = (bool) newValue;
203 imageView.UpdateImage(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
206 defaultValueCreator: (bindable) =>
208 var imageView = (ImageView)bindable;
209 return imageView._synchronosLoading;
212 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
213 [EditorBrowsable(EditorBrowsableState.Never)]
214 public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create("OrientationCorrection", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
216 var imageView = (ImageView)bindable;
217 if (newValue != null)
219 imageView.UpdateImage(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)newValue));
222 defaultValueCreator: (bindable) =>
224 var imageView = (ImageView)bindable;
227 PropertyMap imageMap = new PropertyMap();
228 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
229 imageMap?.Find(ImageVisualProperty.OrientationCorrection)?.Get(out ret);
234 private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
235 private ResourceReadyEventCallbackType _resourceReadyEventCallback;
236 private EventHandler<ResourceLoadedEventArgs> _resourceLoadedEventHandler;
237 private _resourceLoadedCallbackType _resourceLoadedCallback;
239 private Rectangle _border;
240 private string _resourceUrl = "";
241 private bool _synchronosLoading = false;
243 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
244 [EditorBrowsable(EditorBrowsableState.Never)]
245 public ImageViewStyle Style => ViewStyle as ImageViewStyle;
248 /// Creates an initialized ImageView.
250 /// <since_tizen> 3 </since_tizen>
251 public ImageView() : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
257 [EditorBrowsable(EditorBrowsableState.Never)]
258 public ImageView(ViewStyle viewStyle) : this(Interop.ImageView.ImageView_New__SWIG_0(), true, viewStyle)
263 /// Creates an initialized ImageView with setting the status of shown or hidden.
265 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
266 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
267 [EditorBrowsable(EditorBrowsableState.Never)]
268 public ImageView(bool shown) : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 /// Creates an initialized ImageView from a URL to an image resource.<br />
276 /// If the string is empty, ImageView will not display anything.<br />
278 /// <param name="url">The URL of the image resource to display.</param>
279 /// <since_tizen> 3 </since_tizen>
280 public ImageView(string url) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 /// Creates an initialized ImageView from a URL to an image resource with setting shown or hidden.
290 /// <param name="url">The URL of the image resource to display.</param>
291 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
292 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
293 [EditorBrowsable(EditorBrowsableState.Never)]
294 public ImageView(string url, bool shown) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
301 internal ImageView(string url, Uint16Pair size, bool shown = true) : this(Interop.ImageView.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
304 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn, viewStyle)
320 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
328 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
329 private delegate void ResourceReadyEventCallbackType(IntPtr data);
330 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
331 private delegate void _resourceLoadedCallbackType(IntPtr view);
334 /// An event for ResourceReady signal which can be used to subscribe or unsubscribe the event handler.<br />
335 /// This signal is emitted after all resources required by a control are loaded and ready.<br />
336 /// Most resources are only loaded when the control is placed on the stage.<br />
338 /// <since_tizen> 3 </since_tizen>
339 public event EventHandler<ResourceReadyEventArgs> ResourceReady
343 if (_resourceReadyEventHandler == null)
345 _resourceReadyEventCallback = OnResourceReady;
346 ResourceReadySignal(this).Connect(_resourceReadyEventCallback);
349 _resourceReadyEventHandler += value;
354 _resourceReadyEventHandler -= value;
356 if (_resourceReadyEventHandler == null && ResourceReadySignal(this).Empty() == false)
358 ResourceReadySignal(this).Disconnect(_resourceReadyEventCallback);
363 internal event EventHandler<ResourceLoadedEventArgs> ResourceLoaded
367 if (_resourceLoadedEventHandler == null)
369 _resourceLoadedCallback = OnResourceLoaded;
370 this.ResourceReadySignal(this).Connect(_resourceLoadedCallback);
373 _resourceLoadedEventHandler += value;
377 _resourceLoadedEventHandler -= value;
379 if (_resourceLoadedEventHandler == null && this.ResourceReadySignal(this).Empty() == false)
381 this.ResourceReadySignal(this).Disconnect(_resourceLoadedCallback);
387 /// Enumeration for LoadingStatus of image.
389 /// <since_tizen> 5 </since_tizen>
390 public enum LoadingStatusType
393 /// Loading preparing status.
395 /// <since_tizen> 5 </since_tizen>
398 /// Loading ready status.
400 /// <since_tizen> 5 </since_tizen>
403 /// Loading failed status.
405 /// <since_tizen> 5 </since_tizen>
410 /// ImageView ResourceUrl, type string.
411 /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
412 /// When it is set as null, it gives empty string ("") to be read.
414 /// <since_tizen> 3 </since_tizen>
415 public string ResourceUrl
419 return (string)GetValue(ResourceUrlProperty);
423 SetValue(ResourceUrlProperty, value);
424 NotifyPropertyChanged();
429 /// This will be deprecated, please use Image instead. <br />
430 /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
432 /// <since_tizen> 3 </since_tizen>
433 [Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
434 [EditorBrowsable(EditorBrowsableState.Never)]
435 public PropertyMap ImageMap
441 PropertyMap temp = new PropertyMap();
442 GetProperty(ImageView.Property.IMAGE).Get(temp);
454 SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
455 NotifyPropertyChanged();
461 /// ImageView Image, type PropertyMap
463 /// <since_tizen> 4 </since_tizen>
464 public PropertyMap Image
470 return (PropertyMap)GetValue(ImageProperty);
481 SetValue(ImageProperty, value);
482 NotifyPropertyChanged();
488 /// ImageView PreMultipliedAlpha, type Boolean.<br />
489 /// Image must be initialized.<br />
491 /// <since_tizen> 3 </since_tizen>
492 public bool PreMultipliedAlpha
496 return (bool)GetValue(PreMultipliedAlphaProperty);
500 SetValue(PreMultipliedAlphaProperty, value);
501 NotifyPropertyChanged();
506 /// ImageView PixelArea, type Vector4 (Animatable property).<br />
507 /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br />
510 /// The property cascade chaining set is possible. For example, this (imageView.PixelArea.X = 0.1f;) is possible.
512 /// <since_tizen> 3 </since_tizen>
513 public RelativeVector4 PixelArea
517 RelativeVector4 temp = (RelativeVector4)GetValue(PixelAreaProperty);
518 return new RelativeVector4(OnPixelAreaChanged, temp.X, temp.Y, temp.Z, temp.W);
522 SetValue(PixelAreaProperty, value);
523 NotifyPropertyChanged();
528 /// The border of the image in the order: left, right, bottom, top.<br />
529 /// If set, ImageMap will be ignored.<br />
530 /// For N-Patch images only.<br />
534 /// The property cascade chaining set is possible. For example, this (imageView.Border.X = 1;) is possible.
536 /// <since_tizen> 3 </since_tizen>
537 public Rectangle Border
541 Rectangle temp = (Rectangle)GetValue(BorderProperty);
548 return new Rectangle(OnBorderChanged, temp.X, temp.Y, temp.Width, temp.Height);
553 SetValue(BorderProperty, value);
554 NotifyPropertyChanged();
559 /// Gets or sets whether to draw the borders only (if true).<br />
560 /// If not specified, the default is false.<br />
561 /// For N-Patch images only.<br />
564 /// <since_tizen> 3 </since_tizen>
565 public bool BorderOnly
569 return (bool)GetValue(BorderOnlyProperty);
573 SetValue(BorderOnlyProperty, value);
574 NotifyPropertyChanged();
579 /// Gets or sets whether to synchronos loading the resourceurl of image.<br />
581 /// <since_tizen> 3 </since_tizen>
582 public bool SynchronosLoading
586 return (bool)GetValue(SynchronosLoadingProperty);
590 SetValue(SynchronosLoadingProperty, value);
591 NotifyPropertyChanged();
596 /// Gets or sets whether to automatically correct the orientation of an image.<br />
598 /// <since_tizen> 5 </since_tizen>
599 public bool OrientationCorrection
603 return (bool)GetValue(OrientationCorrectionProperty);
607 SetValue(OrientationCorrectionProperty, value);
608 NotifyPropertyChanged();
613 /// Gets the loading state of the visual resource.
615 /// <since_tizen> 5 </since_tizen>
616 public ImageView.LoadingStatusType LoadingStatus
620 return (ImageView.LoadingStatusType)Interop.View.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
625 /// Downcasts a handle to imageView handle.
627 /// Please do not use! this will be deprecated!
628 /// Instead please use as keyword.
629 /// <since_tizen> 3 </since_tizen>
630 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
632 "BaseHandle handle = new ImageView(imagePath); " +
633 "ImageView image = handle as ImageView")]
634 [EditorBrowsable(EditorBrowsableState.Never)]
635 public static ImageView DownCast(BaseHandle handle)
637 ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
638 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
643 /// Sets this ImageView from the given URL.<br />
644 /// If the URL is empty, ImageView will not display anything.<br />
646 /// <param name="url">The URL to the image resource to display.</param>
647 /// <since_tizen> 3 </since_tizen>
648 public void SetImage(string url)
650 if(url.Contains(".json"))
652 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
656 Interop.ImageView.ImageView_SetImage__SWIG_1(swigCPtr, url);
657 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 /// Queries if all resources required by a control are loaded and ready.<br />
664 /// Most resources are only loaded when the control is placed on the stage.<br />
665 /// True if the resources are loaded and ready, false otherwise.<br />
667 /// <since_tizen> 3 </since_tizen>
668 public new bool IsResourceReady()
670 bool ret = Interop.View.IsResourceReady(swigCPtr);
671 if (NDalicPINVOKE.SWIGPendingException.Pending)
672 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
677 /// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
679 /// <since_tizen> 5 </since_tizen>
682 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
686 /// Plays the animated GIF. This is also the default playback mode.
688 /// <since_tizen> 5 </since_tizen>
691 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
695 /// Pauses the animated GIF.
697 /// <since_tizen> 5 </since_tizen>
700 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
704 /// Stops the animated GIF.
706 /// <since_tizen> 5 </since_tizen>
709 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
713 /// Gets or sets the URL of the alpha mask.<br />
716 /// <since_tizen> 6</since_tizen>
717 [EditorBrowsable(EditorBrowsableState.Never)]
718 public string AlphaMaskURL
723 PropertyMap imageMap = new PropertyMap();
724 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
725 imageMap?.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
736 UpdateImage(ImageVisualProperty.AlphaMaskURL, new PropertyValue(value));
742 /// Whether to crop image to mask or scale mask to fit image.
744 /// <since_tizen> 6 </since_tizen>
745 public bool CropToMask
750 PropertyMap imageMap = new PropertyMap();
751 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
752 imageMap?.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
758 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue(value));
764 /// Gets or sets fitting options used when resizing images to fit the desired dimensions.<br />
765 /// If not supplied, the default is FittingModeType.ShrinkToFit.<br />
766 /// For normal quad images only.<br />
769 /// <since_tizen> 6 </since_tizen>
770 [EditorBrowsable(EditorBrowsableState.Never)]
771 public FittingModeType FittingMode
775 int ret = (int)FittingModeType.ShrinkToFit;
776 PropertyMap imageMap = new PropertyMap();
777 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
778 imageMap?.Find(ImageVisualProperty.FittingMode)?.Get(out ret);
780 return (FittingModeType)ret;
784 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue((int)value));
791 /// Gets or sets the desired image width.<br />
792 /// If not specified, the actual image width is used.<br />
793 /// For normal quad images only.<br />
796 /// <since_tizen> 6 </since_tizen>
797 [EditorBrowsable(EditorBrowsableState.Never)]
798 public int DesiredWidth
803 PropertyMap imageMap = new PropertyMap();
804 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
805 imageMap?.Find(ImageVisualProperty.DesiredWidth)?.Get(out ret);
811 UpdateImage(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
816 /// Gets or sets the desired image height.<br />
817 /// If not specified, the actual image height is used.<br />
818 /// For normal quad images only.<br />
821 /// <since_tizen> 6 </since_tizen>
822 [EditorBrowsable(EditorBrowsableState.Never)]
823 public int DesiredHeight
828 PropertyMap imageMap = new PropertyMap();
829 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
830 imageMap?.Find(ImageVisualProperty.DesiredHeight)?.Get(out ret);
836 UpdateImage(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
842 /// Gets or sets the wrap mode for the u coordinate.<br />
843 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br />
844 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
845 /// For normal quad images only.<br />
848 /// <since_tizen> 6 </since_tizen>
849 [EditorBrowsable(EditorBrowsableState.Never)]
850 public WrapModeType WrapModeU
854 int ret = (int)WrapModeType.Default;
855 PropertyMap imageMap = new PropertyMap();
856 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
857 imageMap?.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
859 return (WrapModeType)ret;
863 UpdateImage(ImageVisualProperty.WrapModeU, new PropertyValue((int)value));
868 /// Gets or sets the wrap mode for the v coordinate.<br />
869 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br />
870 /// 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 />
871 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
872 /// For normal quad images only.
875 /// <since_tizen> 6 </since_tizen>
876 [EditorBrowsable(EditorBrowsableState.Never)]
877 public WrapModeType WrapModeV
881 int ret = (int)WrapModeType.Default;
882 PropertyMap imageMap = new PropertyMap();
883 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
884 imageMap?.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
886 return (WrapModeType)ret;
890 UpdateImage(ImageVisualProperty.WrapModeV, new PropertyValue((int)value));
895 /// Get attribues, it is abstract function and must be override.
897 /// <since_tizen> 6 </since_tizen>
898 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
899 [EditorBrowsable(EditorBrowsableState.Never)]
900 protected override ViewStyle GetViewStyle()
902 return new ImageViewStyle();
905 internal void SetImage(string url, Uint16Pair size)
907 if(url.Contains(".json"))
909 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
913 Interop.ImageView.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
914 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
919 internal ViewResourceReadySignal ResourceReadySignal(View view)
921 ViewResourceReadySignal ret = new ViewResourceReadySignal(Interop.View.ResourceReadySignal(View.getCPtr(view)), false);
922 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
926 internal ResourceLoadingStatusType GetResourceStatus()
928 return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
931 internal static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector<string>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
933 var imageView = (ImageView)bindable;
934 imageView.resourceUrlSelector.Clone((Selector<string>)newValue);
936 defaultValueCreator: (bindable) =>
938 var imageView = (ImageView)bindable;
939 return imageView.resourceUrlSelector;
941 private TriggerableSelector<string> _resourceUrlSelector;
942 private TriggerableSelector<string> resourceUrlSelector
946 if (null == _resourceUrlSelector)
948 _resourceUrlSelector = new TriggerableSelector<string>(this, ResourceUrlProperty);
950 return _resourceUrlSelector;
954 internal static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector<Rectangle>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
956 var imageView = (ImageView)bindable;
957 imageView.borderSelector.Clone((Selector<Rectangle>)newValue);
959 defaultValueCreator: (bindable) =>
961 var imageView = (ImageView)bindable;
962 return imageView.borderSelector;
964 private TriggerableSelector<Rectangle> _borderSelector;
965 private TriggerableSelector<Rectangle> borderSelector
969 if (null == _borderSelector)
971 _borderSelector = new TriggerableSelector<Rectangle>(this, BorderProperty);
973 return _borderSelector;
978 /// you can override it to clean-up your own resources.
980 /// <param name="type">DisposeTypes</param>
981 /// <since_tizen> 3 </since_tizen>
982 protected override void Dispose(DisposeTypes type)
989 if (type == DisposeTypes.Explicit)
992 //Release your own managed resources here.
993 //You should release all of your own disposable objects here.
1001 /// This will not be public opened.
1002 [EditorBrowsable(EditorBrowsableState.Never)]
1003 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1005 Interop.ImageView.delete_ImageView(swigCPtr);
1008 // Callback for View ResourceReady signal
1009 private void OnResourceReady(IntPtr data)
1011 ResourceReadyEventArgs e = new ResourceReadyEventArgs();
1014 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1017 if (_resourceReadyEventHandler != null)
1019 _resourceReadyEventHandler(this, e);
1023 private void UpdateImageMap(PropertyMap fromMap)
1025 PropertyMap imageMap = new PropertyMap();
1026 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
1027 imageMap.Merge(fromMap);
1029 SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
1032 private void UpdateImage(int key, PropertyValue value)
1034 PropertyMap temp = new PropertyMap();
1036 if (_resourceUrl == "")
1038 temp.Insert(ImageVisualProperty.URL, new PropertyValue(_resourceUrl));
1039 SetProperty(ImageView.Property.IMAGE, new PropertyValue(temp));
1043 if (_border == null)
1045 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
1049 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
1050 temp.Insert(NpatchImageVisualProperty.Border, new PropertyValue(_border));
1053 temp.Insert(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronosLoading));
1057 temp.Insert(key, value);
1060 UpdateImageMap(temp);
1067 private void OnResourceLoaded(IntPtr view)
1069 ResourceLoadedEventArgs e = new ResourceLoadedEventArgs();
1070 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
1072 if (_resourceLoadedEventHandler != null)
1074 _resourceLoadedEventHandler(this, e);
1079 /// Event arguments of resource ready.
1081 /// <since_tizen> 3 </since_tizen>
1082 public class ResourceReadyEventArgs : EventArgs
1087 /// The view whose resource is ready.
1089 /// <since_tizen> 3 </since_tizen>
1103 internal class ResourceLoadedEventArgs : EventArgs
1105 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1106 public ResourceLoadingStatusType Status
1119 internal new class Property
1121 internal static readonly int IMAGE = Interop.ImageView.ImageView_Property_IMAGE_get();
1122 internal static readonly int PRE_MULTIPLIED_ALPHA = Interop.ImageView.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
1123 internal static readonly int PIXEL_AREA = Interop.ImageView.ImageView_Property_PIXEL_AREA_get();
1124 internal static readonly int ACTION_RELOAD = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
1125 internal static readonly int ACTION_PLAY = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
1126 internal static readonly int ACTION_PAUSE = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
1127 internal static readonly int ACTION_STOP = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
1130 private enum ImageType
1133 /// For Normal Image.
1138 /// For normal image, with synchronous loading and orientation correction property
1143 /// For nine-patch image
1148 private void OnBorderChanged(int x, int y, int width, int height)
1150 Border = new Rectangle(x, y, width, height);
1152 private void OnPixelAreaChanged(float x, float y, float z, float w)
1154 PixelArea = new RelativeVector4(x, y, z, w);