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 global::System.Runtime.InteropServices.HandleRef swigCPtr;
235 private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
236 private ResourceReadyEventCallbackType _resourceReadyEventCallback;
237 private EventHandler<ResourceLoadedEventArgs> _resourceLoadedEventHandler;
238 private _resourceLoadedCallbackType _resourceLoadedCallback;
240 private Rectangle _border;
241 private string _resourceUrl = "";
242 private bool _synchronosLoading = false;
244 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
245 [EditorBrowsable(EditorBrowsableState.Never)]
246 public ImageViewStyle Style => ViewStyle as ImageViewStyle;
249 /// Creates an initialized ImageView.
251 /// <since_tizen> 3 </since_tizen>
252 public ImageView() : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
258 [EditorBrowsable(EditorBrowsableState.Never)]
259 public ImageView(ViewStyle viewStyle) : this(Interop.ImageView.ImageView_New__SWIG_0(), true, viewStyle)
264 /// Creates an initialized ImageView with setting the status of shown or hidden.
266 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
267 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
268 [EditorBrowsable(EditorBrowsableState.Never)]
269 public ImageView(bool shown) : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276 /// Creates an initialized ImageView from a URL to an image resource.<br />
277 /// If the string is empty, ImageView will not display anything.<br />
279 /// <param name="url">The URL of the image resource to display.</param>
280 /// <since_tizen> 3 </since_tizen>
281 public ImageView(string url) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289 /// Creates an initialized ImageView from a URL to an image resource with setting shown or hidden.
291 /// <param name="url">The URL of the image resource to display.</param>
292 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
293 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
294 [EditorBrowsable(EditorBrowsableState.Never)]
295 public ImageView(string url, bool shown) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
298 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 internal ImageView(string url, Uint16Pair size, bool shown = true) : this(Interop.ImageView.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn, viewStyle)
315 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
323 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
325 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
333 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
334 private delegate void ResourceReadyEventCallbackType(IntPtr data);
335 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
336 private delegate void _resourceLoadedCallbackType(IntPtr view);
339 /// An event for ResourceReady signal which can be used to subscribe or unsubscribe the event handler.<br />
340 /// This signal is emitted after all resources required by a control are loaded and ready.<br />
341 /// Most resources are only loaded when the control is placed on the stage.<br />
343 /// <since_tizen> 3 </since_tizen>
344 public event EventHandler<ResourceReadyEventArgs> ResourceReady
348 if (_resourceReadyEventHandler == null)
350 _resourceReadyEventCallback = OnResourceReady;
351 ResourceReadySignal(this).Connect(_resourceReadyEventCallback);
354 _resourceReadyEventHandler += value;
359 _resourceReadyEventHandler -= value;
361 if (_resourceReadyEventHandler == null && ResourceReadySignal(this).Empty() == false)
363 ResourceReadySignal(this).Disconnect(_resourceReadyEventCallback);
368 internal event EventHandler<ResourceLoadedEventArgs> ResourceLoaded
372 if (_resourceLoadedEventHandler == null)
374 _resourceLoadedCallback = OnResourceLoaded;
375 this.ResourceReadySignal(this).Connect(_resourceLoadedCallback);
378 _resourceLoadedEventHandler += value;
382 _resourceLoadedEventHandler -= value;
384 if (_resourceLoadedEventHandler == null && this.ResourceReadySignal(this).Empty() == false)
386 this.ResourceReadySignal(this).Disconnect(_resourceLoadedCallback);
392 /// Enumeration for LoadingStatus of image.
394 /// <since_tizen> 5 </since_tizen>
395 public enum LoadingStatusType
398 /// Loading preparing status.
400 /// <since_tizen> 5 </since_tizen>
403 /// Loading ready status.
405 /// <since_tizen> 5 </since_tizen>
408 /// Loading failed status.
410 /// <since_tizen> 5 </since_tizen>
415 /// ImageView ResourceUrl, type string.
416 /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
417 /// When it is set as null, it gives empty string ("") to be read.
419 /// <since_tizen> 3 </since_tizen>
420 public string ResourceUrl
424 return (string)GetValue(ResourceUrlProperty);
428 SetValue(ResourceUrlProperty, value);
429 NotifyPropertyChanged();
434 /// This will be deprecated, please use Image instead. <br />
435 /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
437 /// <since_tizen> 3 </since_tizen>
438 [Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
439 [EditorBrowsable(EditorBrowsableState.Never)]
440 public PropertyMap ImageMap
446 PropertyMap temp = new PropertyMap();
447 GetProperty(ImageView.Property.IMAGE).Get(temp);
459 SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
460 NotifyPropertyChanged();
466 /// ImageView Image, type PropertyMap
468 /// <since_tizen> 4 </since_tizen>
469 public PropertyMap Image
475 return (PropertyMap)GetValue(ImageProperty);
486 SetValue(ImageProperty, value);
487 NotifyPropertyChanged();
493 /// ImageView PreMultipliedAlpha, type Boolean.<br />
494 /// Image must be initialized.<br />
496 /// <since_tizen> 3 </since_tizen>
497 public bool PreMultipliedAlpha
501 return (bool)GetValue(PreMultipliedAlphaProperty);
505 SetValue(PreMultipliedAlphaProperty, value);
506 NotifyPropertyChanged();
511 /// ImageView PixelArea, type Vector4 (Animatable property).<br />
512 /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br />
515 /// The property cascade chaining set is possible. For example, this (imageView.PixelArea.X = 0.1f;) is possible.
517 /// <since_tizen> 3 </since_tizen>
518 public RelativeVector4 PixelArea
522 RelativeVector4 temp = (RelativeVector4)GetValue(PixelAreaProperty);
523 return new RelativeVector4(OnPixelAreaChanged, temp.X, temp.Y, temp.Z, temp.W);
527 SetValue(PixelAreaProperty, value);
528 NotifyPropertyChanged();
533 /// The border of the image in the order: left, right, bottom, top.<br />
534 /// If set, ImageMap will be ignored.<br />
535 /// For N-Patch images only.<br />
539 /// The property cascade chaining set is possible. For example, this (imageView.Border.X = 1;) is possible.
541 /// <since_tizen> 3 </since_tizen>
542 public Rectangle Border
546 Rectangle temp = (Rectangle)GetValue(BorderProperty);
553 return new Rectangle(OnBorderChanged, temp.X, temp.Y, temp.Width, temp.Height);
558 SetValue(BorderProperty, value);
559 NotifyPropertyChanged();
564 /// Gets or sets whether to draw the borders only (if true).<br />
565 /// If not specified, the default is false.<br />
566 /// For N-Patch images only.<br />
569 /// <since_tizen> 3 </since_tizen>
570 public bool BorderOnly
574 return (bool)GetValue(BorderOnlyProperty);
578 SetValue(BorderOnlyProperty, value);
579 NotifyPropertyChanged();
584 /// Gets or sets whether to synchronos loading the resourceurl of image.<br />
586 /// <since_tizen> 3 </since_tizen>
587 public bool SynchronosLoading
591 return (bool)GetValue(SynchronosLoadingProperty);
595 SetValue(SynchronosLoadingProperty, value);
596 NotifyPropertyChanged();
601 /// Gets or sets whether to automatically correct the orientation of an image.<br />
603 /// <since_tizen> 5 </since_tizen>
604 public bool OrientationCorrection
608 return (bool)GetValue(OrientationCorrectionProperty);
612 SetValue(OrientationCorrectionProperty, value);
613 NotifyPropertyChanged();
618 /// Gets the loading state of the visual resource.
620 /// <since_tizen> 5 </since_tizen>
621 public ImageView.LoadingStatusType LoadingStatus
625 return (ImageView.LoadingStatusType)Interop.View.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
630 /// Downcasts a handle to imageView handle.
632 /// Please do not use! this will be deprecated!
633 /// Instead please use as keyword.
634 /// <since_tizen> 3 </since_tizen>
635 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
637 "BaseHandle handle = new ImageView(imagePath); " +
638 "ImageView image = handle as ImageView")]
639 [EditorBrowsable(EditorBrowsableState.Never)]
640 public static ImageView DownCast(BaseHandle handle)
642 ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
643 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
648 /// Sets this ImageView from the given URL.<br />
649 /// If the URL is empty, ImageView will not display anything.<br />
651 /// <param name="url">The URL to the image resource to display.</param>
652 /// <since_tizen> 3 </since_tizen>
653 public void SetImage(string url)
655 if(url.Contains(".json"))
657 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
661 Interop.ImageView.ImageView_SetImage__SWIG_1(swigCPtr, url);
662 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668 /// Queries if all resources required by a control are loaded and ready.<br />
669 /// Most resources are only loaded when the control is placed on the stage.<br />
670 /// True if the resources are loaded and ready, false otherwise.<br />
672 /// <since_tizen> 3 </since_tizen>
673 public new bool IsResourceReady()
675 bool ret = Interop.View.IsResourceReady(swigCPtr);
676 if (NDalicPINVOKE.SWIGPendingException.Pending)
677 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
682 /// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
684 /// <since_tizen> 5 </since_tizen>
687 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
691 /// Plays the animated GIF. This is also the default playback mode.
693 /// <since_tizen> 5 </since_tizen>
696 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
700 /// Pauses the animated GIF.
702 /// <since_tizen> 5 </since_tizen>
705 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
709 /// Stops the animated GIF.
711 /// <since_tizen> 5 </since_tizen>
714 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
718 /// Gets or sets the URL of the alpha mask.<br />
721 /// <since_tizen> 6</since_tizen>
722 [EditorBrowsable(EditorBrowsableState.Never)]
723 public string AlphaMaskURL
728 PropertyMap imageMap = new PropertyMap();
729 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
730 imageMap?.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
741 UpdateImage(ImageVisualProperty.AlphaMaskURL, new PropertyValue(value));
747 /// Whether to crop image to mask or scale mask to fit image.
749 /// <since_tizen> 6 </since_tizen>
750 public bool CropToMask
755 PropertyMap imageMap = new PropertyMap();
756 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
757 imageMap?.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
763 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue(value));
769 /// Gets or sets fitting options used when resizing images to fit the desired dimensions.<br />
770 /// If not supplied, the default is FittingModeType.ShrinkToFit.<br />
771 /// For normal quad images only.<br />
774 /// <since_tizen> 6 </since_tizen>
775 [EditorBrowsable(EditorBrowsableState.Never)]
776 public FittingModeType FittingMode
780 int ret = (int)FittingModeType.ShrinkToFit;
781 PropertyMap imageMap = new PropertyMap();
782 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
783 imageMap?.Find(ImageVisualProperty.FittingMode)?.Get(out ret);
785 return (FittingModeType)ret;
789 UpdateImage(ImageVisualProperty.CropToMask, new PropertyValue((int)value));
796 /// Gets or sets the desired image width.<br />
797 /// If not specified, the actual image width is used.<br />
798 /// For normal quad images only.<br />
801 /// <since_tizen> 6 </since_tizen>
802 [EditorBrowsable(EditorBrowsableState.Never)]
803 public int DesiredWidth
808 PropertyMap imageMap = new PropertyMap();
809 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
810 imageMap?.Find(ImageVisualProperty.DesiredWidth)?.Get(out ret);
816 UpdateImage(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
821 /// Gets or sets the desired image height.<br />
822 /// If not specified, the actual image height is used.<br />
823 /// For normal quad images only.<br />
826 /// <since_tizen> 6 </since_tizen>
827 [EditorBrowsable(EditorBrowsableState.Never)]
828 public int DesiredHeight
833 PropertyMap imageMap = new PropertyMap();
834 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
835 imageMap?.Find(ImageVisualProperty.DesiredHeight)?.Get(out ret);
841 UpdateImage(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
847 /// Gets or sets the wrap mode for the u coordinate.<br />
848 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br />
849 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
850 /// For normal quad images only.<br />
853 /// <since_tizen> 6 </since_tizen>
854 [EditorBrowsable(EditorBrowsableState.Never)]
855 public WrapModeType WrapModeU
859 int ret = (int)WrapModeType.Default;
860 PropertyMap imageMap = new PropertyMap();
861 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
862 imageMap?.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
864 return (WrapModeType)ret;
868 UpdateImage(ImageVisualProperty.WrapModeU, new PropertyValue((int)value));
873 /// Gets or sets the wrap mode for the v coordinate.<br />
874 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br />
875 /// 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 />
876 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
877 /// For normal quad images only.
880 /// <since_tizen> 6 </since_tizen>
881 [EditorBrowsable(EditorBrowsableState.Never)]
882 public WrapModeType WrapModeV
886 int ret = (int)WrapModeType.Default;
887 PropertyMap imageMap = new PropertyMap();
888 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
889 imageMap?.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
891 return (WrapModeType)ret;
895 UpdateImage(ImageVisualProperty.WrapModeV, new PropertyValue((int)value));
900 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageView obj)
902 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
906 /// Get attribues, it is abstract function and must be override.
908 /// <since_tizen> 6 </since_tizen>
909 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
910 [EditorBrowsable(EditorBrowsableState.Never)]
911 protected override ViewStyle GetViewStyle()
913 return new ImageViewStyle();
916 internal void SetImage(string url, Uint16Pair size)
918 if(url.Contains(".json"))
920 Tizen.Log.Fatal("NUI", "[ERROR] Please DO NOT set lottie file in ImageView! This is temporary checking, will be removed soon!");
924 Interop.ImageView.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
925 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
930 internal ViewResourceReadySignal ResourceReadySignal(View view)
932 ViewResourceReadySignal ret = new ViewResourceReadySignal(Interop.View.ResourceReadySignal(View.getCPtr(view)), false);
933 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
937 internal ResourceLoadingStatusType GetResourceStatus()
939 return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
942 internal static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector<string>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
944 var imageView = (ImageView)bindable;
945 imageView.resourceUrlSelector.Clone((Selector<string>)newValue);
947 defaultValueCreator: (bindable) =>
949 var imageView = (ImageView)bindable;
950 return imageView.resourceUrlSelector;
952 private TriggerableSelector<string> _resourceUrlSelector;
953 private TriggerableSelector<string> resourceUrlSelector
957 if (null == _resourceUrlSelector)
959 _resourceUrlSelector = new TriggerableSelector<string>(this, ResourceUrlProperty);
961 return _resourceUrlSelector;
965 internal static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector<Rectangle>), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
967 var imageView = (ImageView)bindable;
968 imageView.borderSelector.Clone((Selector<Rectangle>)newValue);
970 defaultValueCreator: (bindable) =>
972 var imageView = (ImageView)bindable;
973 return imageView.borderSelector;
975 private TriggerableSelector<Rectangle> _borderSelector;
976 private TriggerableSelector<Rectangle> borderSelector
980 if (null == _borderSelector)
982 _borderSelector = new TriggerableSelector<Rectangle>(this, BorderProperty);
984 return _borderSelector;
989 /// you can override it to clean-up your own resources.
991 /// <param name="type">DisposeTypes</param>
992 /// <since_tizen> 3 </since_tizen>
993 protected override void Dispose(DisposeTypes type)
1000 if (type == DisposeTypes.Explicit)
1003 //Release your own managed resources here.
1004 //You should release all of your own disposable objects here.
1009 //Release your own unmanaged resources here.
1010 //You should not access any managed member here except static instance.
1011 //because the execution order of Finalizes is non-deterministic.
1013 if (swigCPtr.Handle != global::System.IntPtr.Zero)
1017 swigCMemOwn = false;
1018 Interop.ImageView.delete_ImageView(swigCPtr);
1020 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
1026 // Callback for View ResourceReady signal
1027 private void OnResourceReady(IntPtr data)
1029 ResourceReadyEventArgs e = new ResourceReadyEventArgs();
1032 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1035 if (_resourceReadyEventHandler != null)
1037 _resourceReadyEventHandler(this, e);
1041 private void UpdateImageMap(PropertyMap fromMap)
1043 PropertyMap imageMap = new PropertyMap();
1044 Tizen.NUI.Object.GetProperty(swigCPtr, ImageView.Property.IMAGE).Get(imageMap);
1045 imageMap.Merge(fromMap);
1047 SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
1050 private void UpdateImage(int key, PropertyValue value)
1052 PropertyMap temp = new PropertyMap();
1054 if (_resourceUrl == "")
1056 temp.Insert(ImageVisualProperty.URL, new PropertyValue(_resourceUrl));
1057 SetProperty(ImageView.Property.IMAGE, new PropertyValue(temp));
1061 if (_border == null)
1063 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
1067 temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
1068 temp.Insert(NpatchImageVisualProperty.Border, new PropertyValue(_border));
1071 temp.Insert(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue(_synchronosLoading));
1075 temp.Insert(key, value);
1078 UpdateImageMap(temp);
1085 private void OnResourceLoaded(IntPtr view)
1087 ResourceLoadedEventArgs e = new ResourceLoadedEventArgs();
1088 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
1090 if (_resourceLoadedEventHandler != null)
1092 _resourceLoadedEventHandler(this, e);
1097 /// Event arguments of resource ready.
1099 /// <since_tizen> 3 </since_tizen>
1100 public class ResourceReadyEventArgs : EventArgs
1105 /// The view whose resource is ready.
1107 /// <since_tizen> 3 </since_tizen>
1121 internal class ResourceLoadedEventArgs : EventArgs
1123 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1124 public ResourceLoadingStatusType Status
1137 internal new class Property
1139 internal static readonly int IMAGE = Interop.ImageView.ImageView_Property_IMAGE_get();
1140 internal static readonly int PRE_MULTIPLIED_ALPHA = Interop.ImageView.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
1141 internal static readonly int PIXEL_AREA = Interop.ImageView.ImageView_Property_PIXEL_AREA_get();
1142 internal static readonly int ACTION_RELOAD = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
1143 internal static readonly int ACTION_PLAY = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
1144 internal static readonly int ACTION_PAUSE = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
1145 internal static readonly int ACTION_STOP = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
1148 private enum ImageType
1151 /// For Normal Image.
1156 /// For normal image, with synchronous loading and orientation correction property
1161 /// For nine-patch image
1166 private void OnBorderChanged(int x, int y, int width, int height)
1168 Border = new Rectangle(x, y, width, height);
1170 private void OnPixelAreaChanged(float x, float y, float z, float w)
1172 PixelArea = new RelativeVector4(x, y, z, w);