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 static ImageView() { }
34 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
35 [EditorBrowsable(EditorBrowsableState.Never)]
36 public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ImageView.ResourceUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
38 var imageView = (ImageView)bindable;
39 string url = (string)newValue;
40 url = (url == null ? "" : url);
41 if (imageView.IsCreateByXaml && url.Contains("*Resource*"))
43 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
44 url = url.Replace("*Resource*", resource);
46 imageView._resourceUrl = url;
47 imageView.UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
49 defaultValueCreator: (bindable) =>
51 var imageView = (ImageView)bindable;
54 PropertyMap imageMap = new PropertyMap();
55 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
56 imageMap.Find(ImageVisualProperty.URL)?.Get(out ret);
60 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
61 [EditorBrowsable(EditorBrowsableState.Never)]
62 public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(ImageView.Image), typeof(PropertyMap), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
64 var imageView = (ImageView)bindable;
67 PropertyMap map = (PropertyMap)newValue;
68 if (imageView.IsCreateByXaml)
70 string url = "", alphaMaskURL = "", auxiliaryImageURL = "";
71 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
72 PropertyValue urlValue = map.Find(NDalic.IMAGE_VISUAL_URL);
74 if (urlValue != null) ret = urlValue.Get(out url);
75 PropertyMap mmap = new PropertyMap();
76 if (ret && url.Contains("*Resource*"))
78 url = url.Replace("*Resource*", resource);
79 mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(url));
83 PropertyValue alphaMaskUrlValue = map.Find(NDalic.IMAGE_VISUAL_ALPHA_MASK_URL);
84 if (alphaMaskUrlValue != null) ret = alphaMaskUrlValue.Get(out alphaMaskURL);
85 if (ret && alphaMaskURL.Contains("*Resource*"))
87 alphaMaskURL = alphaMaskURL.Replace("*Resource*", resource);
88 mmap.Insert(NDalic.IMAGE_VISUAL_URL, new PropertyValue(alphaMaskURL));
92 PropertyValue auxiliaryImageURLValue = map.Find(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL);
93 if (auxiliaryImageURLValue != null) ret = auxiliaryImageURLValue.Get(out auxiliaryImageURL);
94 if (ret && auxiliaryImageURL.Contains("*Resource*"))
96 auxiliaryImageURL = auxiliaryImageURL.Replace("*Resource*", resource);
97 mmap.Insert(NDalic.IMAGE_VISUAL_AUXILIARY_IMAGE_URL, new PropertyValue(auxiliaryImageURL));
102 if (imageView._border == null)
104 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
108 defaultValueCreator: (bindable) =>
110 var imageView = (ImageView)bindable;
111 if (imageView._border == null)
113 PropertyMap temp = new PropertyMap();
114 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(temp);
123 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
124 [EditorBrowsable(EditorBrowsableState.Never)]
125 public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create("PreMultipliedAlpha", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
127 var imageView = (ImageView)bindable;
128 if (newValue != null)
130 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue((bool)newValue));
133 defaultValueCreator: (bindable) =>
135 var imageView = (ImageView)bindable;
137 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
141 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
142 [EditorBrowsable(EditorBrowsableState.Never)]
143 public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create("PixelArea", typeof(RelativeVector4), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
145 var imageView = (ImageView)bindable;
146 if (newValue != null)
148 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
151 defaultValueCreator: (bindable) =>
153 var imageView = (ImageView)bindable;
154 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
155 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA).Get(temp);
156 RelativeVector4 relativeTemp = new RelativeVector4(temp.X, temp.Y, temp.Z, temp.W);
160 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
161 [EditorBrowsable(EditorBrowsableState.Never)]
162 public static readonly BindableProperty BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
166 var imageView = (ImageView)bindable;
167 imageView._border = (Rectangle)newValue;
168 imageView.UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(imageView._border));
171 defaultValueCreator: (bindable) =>
173 var imageView = (ImageView)bindable;
174 return imageView._border;
177 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
178 [EditorBrowsable(EditorBrowsableState.Never)]
179 public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create("BorderOnly", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
181 var imageView = (ImageView)bindable;
182 if (newValue != null)
184 imageView.UpdateImage(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)newValue));
187 defaultValueCreator: (bindable) =>
189 var imageView = (ImageView)bindable;
191 PropertyMap imageMap = new PropertyMap();
192 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
193 imageMap.Find(ImageVisualProperty.BorderOnly)?.Get(out ret);
197 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
198 [EditorBrowsable(EditorBrowsableState.Never)]
199 public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create("SynchronosLoading", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
201 var imageView = (ImageView)bindable;
202 if (newValue != null)
204 imageView._synchronosLoading = (bool) newValue;
205 imageView.UpdateImage(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
208 defaultValueCreator: (bindable) =>
210 var imageView = (ImageView)bindable;
211 return imageView._synchronosLoading;
214 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
215 [EditorBrowsable(EditorBrowsableState.Never)]
216 public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create("OrientationCorrection", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
218 var imageView = (ImageView)bindable;
219 if (newValue != null)
221 imageView.UpdateImage(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)newValue));
224 defaultValueCreator: (bindable) =>
226 var imageView = (ImageView)bindable;
229 PropertyMap imageMap = new PropertyMap();
230 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
231 imageMap?.Find(ImageVisualProperty.OrientationCorrection)?.Get(out ret);
236 private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
237 private ResourceReadyEventCallbackType _resourceReadyEventCallback;
238 private EventHandler<ResourceLoadedEventArgs> _resourceLoadedEventHandler;
239 private _resourceLoadedCallbackType _resourceLoadedCallback;
241 private Rectangle _border;
242 private string _resourceUrl = "";
243 private bool _synchronosLoading = false;
245 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
246 [EditorBrowsable(EditorBrowsableState.Never)]
247 public ImageViewStyle Style => ViewStyle as ImageViewStyle;
250 /// Creates an initialized ImageView.
252 /// <since_tizen> 3 </since_tizen>
253 public ImageView() : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
255 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
259 [EditorBrowsable(EditorBrowsableState.Never)]
260 public ImageView(ViewStyle viewStyle) : this(Interop.ImageView.ImageView_New__SWIG_0(), true, viewStyle)
265 /// Creates an initialized ImageView with setting the status of shown or hidden.
267 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
268 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
269 [EditorBrowsable(EditorBrowsableState.Never)]
270 public ImageView(bool shown) : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 /// Creates an initialized ImageView from a URL to an image resource.<br />
278 /// If the string is empty, ImageView will not display anything.<br />
280 /// <param name="url">The URL of the image resource to display.</param>
281 /// <since_tizen> 3 </since_tizen>
282 public ImageView(string url) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 /// Creates an initialized ImageView from a URL to an image resource with setting shown or hidden.
292 /// <param name="url">The URL of the image resource to display.</param>
293 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
294 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
295 [EditorBrowsable(EditorBrowsableState.Never)]
296 public ImageView(string url, bool shown) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 internal ImageView(string url, Uint16Pair size, bool shown = true) : this(Interop.ImageView.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
314 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn, viewStyle)
322 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
330 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
331 private delegate void ResourceReadyEventCallbackType(IntPtr data);
332 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
333 private delegate void _resourceLoadedCallbackType(IntPtr view);
336 /// An event for ResourceReady signal which can be used to subscribe or unsubscribe the event handler.<br />
337 /// This signal is emitted after all resources required by a control are loaded and ready.<br />
338 /// Most resources are only loaded when the control is placed on the stage.<br />
340 /// <since_tizen> 3 </since_tizen>
341 public event EventHandler<ResourceReadyEventArgs> ResourceReady
345 if (_resourceReadyEventHandler == null)
347 _resourceReadyEventCallback = OnResourceReady;
348 ResourceReadySignal(this).Connect(_resourceReadyEventCallback);
351 _resourceReadyEventHandler += value;
356 _resourceReadyEventHandler -= value;
358 if (_resourceReadyEventHandler == null && ResourceReadySignal(this).Empty() == false)
360 ResourceReadySignal(this).Disconnect(_resourceReadyEventCallback);
365 internal event EventHandler<ResourceLoadedEventArgs> ResourceLoaded
369 if (_resourceLoadedEventHandler == null)
371 _resourceLoadedCallback = OnResourceLoaded;
372 this.ResourceReadySignal(this).Connect(_resourceLoadedCallback);
375 _resourceLoadedEventHandler += value;
379 _resourceLoadedEventHandler -= value;
381 if (_resourceLoadedEventHandler == null && this.ResourceReadySignal(this).Empty() == false)
383 this.ResourceReadySignal(this).Disconnect(_resourceLoadedCallback);
389 /// Enumeration for LoadingStatus of image.
391 /// <since_tizen> 5 </since_tizen>
392 public enum LoadingStatusType
395 /// Loading preparing status.
397 /// <since_tizen> 5 </since_tizen>
400 /// Loading ready status.
402 /// <since_tizen> 5 </since_tizen>
405 /// Loading failed status.
407 /// <since_tizen> 5 </since_tizen>
412 /// ImageView ResourceUrl, type string.
413 /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
414 /// When it is set as null, it gives empty string ("") to be read.
416 /// <since_tizen> 3 </since_tizen>
417 public string ResourceUrl
421 return (string)GetValue(ResourceUrlProperty);
425 SetValue(ResourceUrlProperty, value);
426 NotifyPropertyChanged();
431 /// This will be deprecated, please use Image instead. <br />
432 /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
434 /// <since_tizen> 3 </since_tizen>
435 [Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
436 [EditorBrowsable(EditorBrowsableState.Never)]
437 public PropertyMap ImageMap
443 PropertyMap temp = new PropertyMap();
444 GetProperty(ImageView.Property.IMAGE).Get(temp);
456 SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
457 NotifyPropertyChanged();
463 /// ImageView Image, type PropertyMap
465 /// <since_tizen> 4 </since_tizen>
466 public PropertyMap Image
472 return (PropertyMap)GetValue(ImageProperty);
483 SetValue(ImageProperty, value);
484 NotifyPropertyChanged();
490 /// ImageView PreMultipliedAlpha, type Boolean.<br />
491 /// Image must be initialized.<br />
493 /// <since_tizen> 3 </since_tizen>
494 public bool PreMultipliedAlpha
498 return (bool)GetValue(PreMultipliedAlphaProperty);
502 SetValue(PreMultipliedAlphaProperty, value);
503 NotifyPropertyChanged();
508 /// ImageView PixelArea, type Vector4 (Animatable property).<br />
509 /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br />
512 /// The property cascade chaining set is possible. For example, this (imageView.PixelArea.X = 0.1f;) is possible.
514 /// <since_tizen> 3 </since_tizen>
515 public RelativeVector4 PixelArea
519 RelativeVector4 temp = (RelativeVector4)GetValue(PixelAreaProperty);
520 return new RelativeVector4(OnPixelAreaChanged, temp.X, temp.Y, temp.Z, temp.W);
524 SetValue(PixelAreaProperty, value);
525 NotifyPropertyChanged();
530 /// The border of the image in the order: left, right, bottom, top.<br />
531 /// If set, ImageMap will be ignored.<br />
532 /// For N-Patch images only.<br />
536 /// The property cascade chaining set is possible. For example, this (imageView.Border.X = 1;) is possible.
538 /// <since_tizen> 3 </since_tizen>
539 public Rectangle Border
543 Rectangle temp = (Rectangle)GetValue(BorderProperty);
550 return new Rectangle(OnBorderChanged, temp.X, temp.Y, temp.Width, temp.Height);
555 SetValue(BorderProperty, value);
556 NotifyPropertyChanged();
561 /// Gets or sets whether to draw the borders only (if true).<br />
562 /// If not specified, the default is false.<br />
563 /// For N-Patch images only.<br />
566 /// <since_tizen> 3 </since_tizen>
567 public bool BorderOnly
571 return (bool)GetValue(BorderOnlyProperty);
575 SetValue(BorderOnlyProperty, value);
576 NotifyPropertyChanged();
581 /// Gets or sets whether to synchronos loading the resourceurl of image.<br />
583 /// <since_tizen> 3 </since_tizen>
584 public bool SynchronosLoading
588 return (bool)GetValue(SynchronosLoadingProperty);
592 SetValue(SynchronosLoadingProperty, value);
593 NotifyPropertyChanged();
598 /// Gets or sets whether to automatically correct the orientation of an image.<br />
600 /// <since_tizen> 5 </since_tizen>
601 public bool OrientationCorrection
605 return (bool)GetValue(OrientationCorrectionProperty);
609 SetValue(OrientationCorrectionProperty, value);
610 NotifyPropertyChanged();
615 /// Gets the loading state of the visual resource.
617 /// <since_tizen> 5 </since_tizen>
618 public ImageView.LoadingStatusType LoadingStatus
622 return (ImageView.LoadingStatusType)Interop.View.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
627 /// Downcasts a handle to imageView handle.
629 /// Please do not use! this will be deprecated!
630 /// Instead please use as keyword.
631 /// <since_tizen> 3 </since_tizen>
632 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
634 "BaseHandle handle = new ImageView(imagePath); " +
635 "ImageView image = handle as ImageView")]
636 [EditorBrowsable(EditorBrowsableState.Never)]
637 public static ImageView DownCast(BaseHandle handle)
639 ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
640 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645 /// Sets this ImageView from the given URL.<br />
646 /// If the URL is empty, ImageView will not display anything.<br />
648 /// <param name="url">The URL to the image resource to display.</param>
649 /// <since_tizen> 3 </since_tizen>
650 public void SetImage(string url)
652 if(url.Contains(".json"))
654 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
658 Interop.ImageView.ImageView_SetImage__SWIG_1(swigCPtr, url);
659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665 /// Queries if all resources required by a control are loaded and ready.<br />
666 /// Most resources are only loaded when the control is placed on the stage.<br />
667 /// True if the resources are loaded and ready, false otherwise.<br />
669 /// <since_tizen> 3 </since_tizen>
670 public new bool IsResourceReady()
672 bool ret = Interop.View.IsResourceReady(swigCPtr);
673 if (NDalicPINVOKE.SWIGPendingException.Pending)
674 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
679 /// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
681 /// <since_tizen> 5 </since_tizen>
684 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
688 /// Plays the animated GIF. This is also the default playback mode.
690 /// <since_tizen> 5 </since_tizen>
693 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
697 /// Pauses the animated GIF.
699 /// <since_tizen> 5 </since_tizen>
702 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
706 /// Stops the animated GIF.
708 /// <since_tizen> 5 </since_tizen>
711 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
715 /// Gets or sets the URL of the alpha mask.<br />
718 /// <since_tizen> 6</since_tizen>
719 [EditorBrowsable(EditorBrowsableState.Never)]
720 public string AlphaMaskURL
725 PropertyMap imageMap = new PropertyMap();
726 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
727 imageMap?.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
738 UpdateImage(ImageVisualProperty.AlphaMaskURL, new PropertyValue(value));
744 /// Whether to crop image to mask or scale mask to fit image.
746 /// <since_tizen> 6 </since_tizen>
747 public bool CropToMask
752 PropertyMap imageMap = new PropertyMap();
753 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
754 imageMap?.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
760 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue(value));
766 /// Gets or sets fitting options used when resizing images to fit the desired dimensions.<br />
767 /// If not supplied, the default is FittingModeType.ShrinkToFit.<br />
768 /// For normal quad images only.<br />
771 /// <since_tizen> 6 </since_tizen>
772 [EditorBrowsable(EditorBrowsableState.Never)]
773 public FittingModeType FittingMode
777 int ret = (int)FittingModeType.ShrinkToFit;
778 PropertyMap imageMap = new PropertyMap();
779 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
780 imageMap?.Find(ImageVisualProperty.FittingMode)?.Get(out ret);
782 return (FittingModeType)ret;
786 UpdateImage(ImageVisualProperty.FittingMode, new PropertyValue((int)value));
793 /// Gets or sets the desired image width.<br />
794 /// If not specified, the actual image width is used.<br />
795 /// For normal quad images only.<br />
798 /// <since_tizen> 6 </since_tizen>
799 [EditorBrowsable(EditorBrowsableState.Never)]
800 public int DesiredWidth
805 PropertyMap imageMap = new PropertyMap();
806 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
807 imageMap?.Find(ImageVisualProperty.DesiredWidth)?.Get(out ret);
813 UpdateImage(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
818 /// Gets or sets the desired image height.<br />
819 /// If not specified, the actual image height is used.<br />
820 /// For normal quad images only.<br />
823 /// <since_tizen> 6 </since_tizen>
824 [EditorBrowsable(EditorBrowsableState.Never)]
825 public int DesiredHeight
830 PropertyMap imageMap = new PropertyMap();
831 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
832 imageMap?.Find(ImageVisualProperty.DesiredHeight)?.Get(out ret);
838 UpdateImage(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
844 /// Gets or sets the wrap mode for the u coordinate.<br />
845 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br />
846 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
847 /// For normal quad images only.<br />
850 /// <since_tizen> 6 </since_tizen>
851 [EditorBrowsable(EditorBrowsableState.Never)]
852 public WrapModeType WrapModeU
856 int ret = (int)WrapModeType.Default;
857 PropertyMap imageMap = new PropertyMap();
858 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
859 imageMap?.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
861 return (WrapModeType)ret;
865 UpdateImage(ImageVisualProperty.WrapModeU, new PropertyValue((int)value));
870 /// Gets or sets the wrap mode for the v coordinate.<br />
871 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br />
872 /// 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 />
873 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
874 /// For normal quad images only.
877 /// <since_tizen> 6 </since_tizen>
878 [EditorBrowsable(EditorBrowsableState.Never)]
879 public WrapModeType WrapModeV
883 int ret = (int)WrapModeType.Default;
884 PropertyMap imageMap = new PropertyMap();
885 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
886 imageMap?.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
888 return (WrapModeType)ret;
892 UpdateImage(ImageVisualProperty.WrapModeV, new PropertyValue((int)value));
897 /// Get attribues, it is abstract function and must be override.
899 /// <since_tizen> 6 </since_tizen>
900 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
901 [EditorBrowsable(EditorBrowsableState.Never)]
902 protected override ViewStyle GetViewStyle()
904 return new ImageViewStyle();
907 internal void SetImage(string url, Uint16Pair size)
909 if(url.Contains(".json"))
911 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
915 Interop.ImageView.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
916 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
921 internal ViewResourceReadySignal ResourceReadySignal(View view)
923 ViewResourceReadySignal ret = new ViewResourceReadySignal(Interop.View.ResourceReadySignal(View.getCPtr(view)), false);
924 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
928 internal ResourceLoadingStatusType GetResourceStatus()
930 return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
933 internal static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector<string>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
935 var imageView = (ImageView)bindable;
936 imageView.resourceUrlSelector.Clone((Selector<string>)newValue);
938 defaultValueCreator: (bindable) =>
940 var imageView = (ImageView)bindable;
941 return imageView.resourceUrlSelector;
943 private TriggerableSelector<string> _resourceUrlSelector;
944 private TriggerableSelector<string> resourceUrlSelector
948 if (null == _resourceUrlSelector)
950 _resourceUrlSelector = new TriggerableSelector<string>(this, ResourceUrlProperty);
952 return _resourceUrlSelector;
956 internal static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector<Rectangle>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
958 var imageView = (ImageView)bindable;
959 imageView.borderSelector.Clone((Selector<Rectangle>)newValue);
961 defaultValueCreator: (bindable) =>
963 var imageView = (ImageView)bindable;
964 return imageView.borderSelector;
966 private TriggerableSelector<Rectangle> _borderSelector;
967 private TriggerableSelector<Rectangle> borderSelector
971 if (null == _borderSelector)
973 _borderSelector = new TriggerableSelector<Rectangle>(this, BorderProperty);
975 return _borderSelector;
980 /// you can override it to clean-up your own resources.
982 /// <param name="type">DisposeTypes</param>
983 /// <since_tizen> 3 </since_tizen>
984 protected override void Dispose(DisposeTypes type)
991 if (type == DisposeTypes.Explicit)
994 //Release your own managed resources here.
995 //You should release all of your own disposable objects here.
1003 /// This will not be public opened.
1004 [EditorBrowsable(EditorBrowsableState.Never)]
1005 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1007 Interop.ImageView.delete_ImageView(swigCPtr);
1010 // Callback for View ResourceReady signal
1011 private void OnResourceReady(IntPtr data)
1013 ResourceReadyEventArgs e = new ResourceReadyEventArgs();
1016 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1019 if (_resourceReadyEventHandler != null)
1021 _resourceReadyEventHandler(this, e);
1025 private void UpdateImageMap(PropertyMap fromMap)
1027 PropertyMap imageMap = new PropertyMap();
1028 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
1029 imageMap.Merge(fromMap);
1031 SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
1034 private void UpdateImage(int key, PropertyValue value)
1036 PropertyMap temp = new PropertyMap();
1038 if (_resourceUrl == "")
1040 temp.Insert(ImageVisualProperty.URL, new PropertyValue(_resourceUrl));
1041 SetProperty(ImageView.Property.IMAGE, new PropertyValue(temp));
1045 if (_border == null)
1047 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
1051 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
1052 temp.Insert(NpatchImageVisualProperty.Border, new PropertyValue(_border));
1055 temp.Insert(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronosLoading));
1059 temp.Insert(key, value);
1062 UpdateImageMap(temp);
1069 private void OnResourceLoaded(IntPtr view)
1071 ResourceLoadedEventArgs e = new ResourceLoadedEventArgs();
1072 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
1074 if (_resourceLoadedEventHandler != null)
1076 _resourceLoadedEventHandler(this, e);
1081 /// Event arguments of resource ready.
1083 /// <since_tizen> 3 </since_tizen>
1084 public class ResourceReadyEventArgs : EventArgs
1089 /// The view whose resource is ready.
1091 /// <since_tizen> 3 </since_tizen>
1105 internal class ResourceLoadedEventArgs : EventArgs
1107 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1108 public ResourceLoadingStatusType Status
1121 internal new class Property
1123 internal static readonly int IMAGE = Interop.ImageView.ImageView_Property_IMAGE_get();
1124 internal static readonly int PRE_MULTIPLIED_ALPHA = Interop.ImageView.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
1125 internal static readonly int PIXEL_AREA = Interop.ImageView.ImageView_Property_PIXEL_AREA_get();
1126 internal static readonly int ACTION_RELOAD = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
1127 internal static readonly int ACTION_PLAY = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
1128 internal static readonly int ACTION_PAUSE = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
1129 internal static readonly int ACTION_STOP = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
1132 private enum ImageType
1135 /// For Normal Image.
1140 /// For normal image, with synchronous loading and orientation correction property
1145 /// For nine-patch image
1150 private void OnBorderChanged(int x, int y, int width, int height)
1152 Border = new Rectangle(x, y, width, height);
1154 private void OnPixelAreaChanged(float x, float y, float z, float w)
1156 PixelArea = new RelativeVector4(x, y, z, w);