2 * Copyright(c) 2018 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;
39 string url = (string)newValue;
41 imageView.UpdateImage();
44 defaultValueCreator: (bindable) =>
46 var imageView = (ImageView)bindable;
47 if(imageView._imageType == ImageType.Normal)
49 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(out imageView._url);
51 return imageView._url;
54 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
55 [EditorBrowsable(EditorBrowsableState.Never)]
56 public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(ImageView.Image), typeof(PropertyMap), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
58 var imageView = (ImageView)bindable;
61 PropertyMap map = (PropertyMap)newValue;
63 if (imageView._border == null)
65 imageView._image = map;
66 imageView.UpdateImage();
70 defaultValueCreator: (bindable) =>
72 var imageView = (ImageView)bindable;
73 if (imageView._border == null)
75 PropertyMap temp = new PropertyMap();
76 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(temp);
85 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
86 [EditorBrowsable(EditorBrowsableState.Never)]
87 public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create("PreMultipliedAlpha", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
89 var imageView = (ImageView)bindable;
92 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA, new Tizen.NUI.PropertyValue((bool)newValue));
95 defaultValueCreator: (bindable) =>
97 var imageView = (ImageView)bindable;
99 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PRE_MULTIPLIED_ALPHA).Get(out temp);
103 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
104 [EditorBrowsable(EditorBrowsableState.Never)]
105 public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create("PixelArea", typeof(RelativeVector4), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
107 var imageView = (ImageView)bindable;
108 if (newValue != null)
110 Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
113 defaultValueCreator: (bindable) =>
115 var imageView = (ImageView)bindable;
116 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
117 Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.PIXEL_AREA).Get(temp);
118 RelativeVector4 relativeTemp = new RelativeVector4(temp.X, temp.Y, temp.Z, temp.W);
122 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
123 [EditorBrowsable(EditorBrowsableState.Never)]
124 public static readonly BindableProperty BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
126 var imageView = (ImageView)bindable;
127 if (newValue != null)
129 imageView._border = (Rectangle)newValue;
130 imageView.UpdateImage();
133 defaultValueCreator: (bindable) =>
135 var imageView = (ImageView)bindable;
136 return imageView._border;
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 BorderOnlyProperty = BindableProperty.Create("BorderOnly", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
143 var imageView = (ImageView)bindable;
144 if (newValue != null)
146 imageView._borderOnly = (bool)newValue;
147 imageView.UpdateImage();
150 defaultValueCreator: (bindable) =>
152 var imageView = (ImageView)bindable;
153 return imageView._borderOnly ?? false;
156 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
157 [EditorBrowsable(EditorBrowsableState.Never)]
158 public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create("SynchronosLoading", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
160 var imageView = (ImageView)bindable;
161 if (newValue != null)
163 imageView._synchronousLoading = (bool)newValue;
164 imageView.UpdateImage();
167 defaultValueCreator: (bindable) =>
169 var imageView = (ImageView)bindable;
170 return imageView._synchronousLoading ?? false;
173 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
174 [EditorBrowsable(EditorBrowsableState.Never)]
175 public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create("OrientationCorrection", typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
177 var imageView = (ImageView)bindable;
178 if (newValue != null)
180 imageView._orientationCorrection = (bool)newValue;
181 imageView.UpdateImage();
184 defaultValueCreator: (bindable) =>
186 var imageView = (ImageView)bindable;
187 return imageView._orientationCorrection ?? false;
190 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
191 private EventHandler<ResourceReadyEventArgs> _resourceReadyEventHandler;
192 private ResourceReadyEventCallbackType _resourceReadyEventCallback;
193 private EventHandler<ResourceLoadedEventArgs> _resourceLoadedEventHandler;
194 private _resourceLoadedCallbackType _resourceLoadedCallback;
196 private Rectangle _border;
197 private PropertyMap _nPatchMap;
198 private bool? _synchronousLoading;
199 private bool? _borderOnly;
201 private bool? _orientationCorrection;
202 private PropertyMap _image;
203 private ImageType _imageType;
206 /// Creates an initialized ImageView.
208 /// <since_tizen> 3 </since_tizen>
209 public ImageView() : this(Interop.ImageView.ImageView_New__SWIG_0(), true)
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// Creates an initialized ImageView from a URL to an image resource.<br />
216 /// If the string is empty, ImageView will not display anything.<br />
218 /// <param name="url">The URL of the image resource to display.</param>
219 /// <since_tizen> 3 </since_tizen>
220 public ImageView(string url) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
223 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226 internal ImageView(string url, Uint16Pair size) : this(Interop.ImageView.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn)
234 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
237 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
238 private delegate void ResourceReadyEventCallbackType(IntPtr data);
239 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
240 private delegate void _resourceLoadedCallbackType(IntPtr view);
243 /// An event for ResourceReady signal which can be used to subscribe or unsubscribe the event handler.<br />
244 /// This signal is emitted after all resources required by a control are loaded and ready.<br />
245 /// Most resources are only loaded when the control is placed on the stage.<br />
247 /// <since_tizen> 3 </since_tizen>
248 public event EventHandler<ResourceReadyEventArgs> ResourceReady
252 if (_resourceReadyEventHandler == null)
254 _resourceReadyEventCallback = OnResourceReady;
255 ResourceReadySignal(this).Connect(_resourceReadyEventCallback);
258 _resourceReadyEventHandler += value;
263 _resourceReadyEventHandler -= value;
265 if (_resourceReadyEventHandler == null && ResourceReadySignal(this).Empty() == false)
267 ResourceReadySignal(this).Disconnect(_resourceReadyEventCallback);
272 internal event EventHandler<ResourceLoadedEventArgs> ResourceLoaded
276 if (_resourceLoadedEventHandler == null)
278 _resourceLoadedCallback = OnResourceLoaded;
279 this.ResourceReadySignal(this).Connect(_resourceLoadedCallback);
282 _resourceLoadedEventHandler += value;
286 _resourceLoadedEventHandler -= value;
288 if (_resourceLoadedEventHandler == null && this.ResourceReadySignal(this).Empty() == false)
290 this.ResourceReadySignal(this).Disconnect(_resourceLoadedCallback);
296 /// Enumeration for LoadingStatus of image.
298 /// <since_tizen> 5 </since_tizen>
299 public enum LoadingStatusType
302 /// Loading preparing status.
304 /// <since_tizen> 5 </since_tizen>
307 /// Loading ready status.
309 /// <since_tizen> 5 </since_tizen>
312 /// Loading failed status.
314 /// <since_tizen> 5 </since_tizen>
319 /// ImageView ResourceUrl, type string.
320 /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
321 /// When it is set as null, it gives empty string ("") to be read.
323 /// <since_tizen> 3 </since_tizen>
324 public string ResourceUrl
328 return (string)GetValue(ResourceUrlProperty);
332 _url = (value == null ? "" : value);
333 SetValue(ResourceUrlProperty, _url);
334 NotifyPropertyChanged();
336 PropertyMap temp = new PropertyMap();
337 temp.Insert(ImageVisualProperty.URL, new PropertyValue(value));
339 PropertyMap imageMap = Image;
340 imageMap.Merge(temp);
342 SetValue(ImageProperty, imageMap);
348 /// This will be deprecated, please use Image instead. <br />
349 /// ImageView ImageMap, type PropertyMap: string if it is a URL, map otherwise.
351 /// <since_tizen> 3 </since_tizen>
352 [Obsolete("Please do not use! This will be deprecated! Please use Image property instead!")]
353 [EditorBrowsable(EditorBrowsableState.Never)]
354 public PropertyMap ImageMap
360 PropertyMap temp = new PropertyMap();
361 GetProperty(ImageView.Property.IMAGE).Get(temp);
373 if (_url != null) { value.Add("url", new PropertyValue(_url)); }
374 SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
375 NotifyPropertyChanged();
381 /// ImageView Image, type PropertyMap
383 /// <since_tizen> 4 </since_tizen>
384 public PropertyMap Image
390 return (PropertyMap)GetValue(ImageProperty);
401 SetValue(ImageProperty, value);
402 NotifyPropertyChanged();
408 /// ImageView PreMultipliedAlpha, type Boolean.<br />
409 /// Image must be initialized.<br />
411 /// <since_tizen> 3 </since_tizen>
412 public bool PreMultipliedAlpha
416 return (bool)GetValue(PreMultipliedAlphaProperty);
420 SetValue(PreMultipliedAlphaProperty, value);
421 NotifyPropertyChanged();
426 /// ImageView PixelArea, type Vector4 (Animatable property).<br />
427 /// Pixel area is a relative value with the whole image area as [0.0, 0.0, 1.0, 1.0].<br />
429 /// <since_tizen> 3 </since_tizen>
430 public RelativeVector4 PixelArea
434 return (RelativeVector4)GetValue(PixelAreaProperty);
438 SetValue(PixelAreaProperty, value);
439 NotifyPropertyChanged();
444 /// The border of the image in the order: left, right, bottom, top.<br />
445 /// If set, ImageMap will be ignored.<br />
446 /// For N-Patch images only.<br />
449 /// <since_tizen> 3 </since_tizen>
450 public Rectangle Border
454 return (Rectangle)GetValue(BorderProperty);
458 SetValue(BorderProperty, value);
459 NotifyPropertyChanged();
464 /// Gets or sets whether to draw the borders only (if true).<br />
465 /// If not specified, the default is false.<br />
466 /// For N-Patch images only.<br />
469 /// <since_tizen> 3 </since_tizen>
470 public bool BorderOnly
474 return (bool)GetValue(BorderOnlyProperty);
478 SetValue(BorderOnlyProperty, value);
479 NotifyPropertyChanged();
484 /// Gets or sets whether to synchronos loading the resourceurl of image.<br />
486 /// <since_tizen> 3 </since_tizen>
487 public bool SynchronosLoading
491 return (bool)GetValue(SynchronosLoadingProperty);
495 SetValue(SynchronosLoadingProperty, value);
496 NotifyPropertyChanged();
501 /// Gets or sets whether to automatically correct the orientation of an image.<br />
503 /// <since_tizen> 5 </since_tizen>
504 public bool OrientationCorrection
508 return (bool)GetValue(OrientationCorrectionProperty);
512 SetValue(OrientationCorrectionProperty, value);
513 NotifyPropertyChanged();
518 /// Gets the loading state of the visual resource.
520 /// <since_tizen> 5 </since_tizen>
521 public ImageView.LoadingStatusType LoadingStatus
525 return (ImageView.LoadingStatusType)Interop.View.View_GetVisualResourceStatus(swigCPtr, (int)Property.IMAGE);
530 /// Downcasts a handle to imageView handle.
532 /// Please do not use! this will be deprecated!
533 /// Instead please use as keyword.
534 /// <since_tizen> 3 </since_tizen>
535 [Obsolete("Please do not use! This will be deprecated! Please use as keyword instead! " +
537 "BaseHandle handle = new ImageView(imagePath); " +
538 "ImageView image = handle as ImageView")]
539 [EditorBrowsable(EditorBrowsableState.Never)]
540 public static ImageView DownCast(BaseHandle handle)
542 ImageView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ImageView;
543 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
548 /// Sets this ImageView from the given URL.<br />
549 /// If the URL is empty, ImageView will not display anything.<br />
551 /// <param name="url">The URL to the image resource to display.</param>
552 /// <since_tizen> 3 </since_tizen>
553 public void SetImage(string url)
556 Interop.ImageView.ImageView_SetImage__SWIG_1(swigCPtr, url);
557 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
561 /// Queries if all resources required by a control are loaded and ready.<br />
562 /// Most resources are only loaded when the control is placed on the stage.<br />
563 /// True if the resources are loaded and ready, false otherwise.<br />
565 /// <since_tizen> 3 </since_tizen>
566 public new bool IsResourceReady()
568 bool ret = Interop.View.IsResourceReady(swigCPtr);
569 if (NDalicPINVOKE.SWIGPendingException.Pending)
570 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
575 /// Forcefully reloads the image. All the visuals using this image will reload to the latest image.
577 /// <since_tizen> 5 </since_tizen>
580 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_RELOAD, new PropertyValue(0));
584 /// Plays the animated GIF. This is also the default playback mode.
586 /// <since_tizen> 5 </since_tizen>
589 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PLAY, new PropertyValue(0));
593 /// Pauses the animated GIF.
595 /// <since_tizen> 5 </since_tizen>
598 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_PAUSE, new PropertyValue(0));
602 /// Stops the animated GIF.
604 /// <since_tizen> 5 </since_tizen>
607 this.DoAction(ImageView.Property.IMAGE, Property.ACTION_STOP, new PropertyValue(0));
611 /// Gets or sets the URL of the alpha mask.<br />
614 /// <since_tizen> 6</since_tizen>
615 [EditorBrowsable(EditorBrowsableState.Never)]
616 public string AlphaMaskURL
621 Image.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
632 PropertyMap temp = new PropertyMap();
633 temp.Insert(ImageVisualProperty.AlphaMaskURL, new PropertyValue(value));
635 PropertyMap imageMap = Image;
636 imageMap.Merge(temp);
638 SetValue(ImageProperty, imageMap);
639 NotifyPropertyChanged();
645 /// Whether to crop image to mask or scale mask to fit image.
647 /// <since_tizen> 6 </since_tizen>
648 [EditorBrowsable(EditorBrowsableState.Never)]
649 public bool CropToMask
654 Image.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
660 PropertyMap temp = new PropertyMap();
661 temp.Insert(ImageVisualProperty.CropToMask, new PropertyValue(value));
663 PropertyMap imageMap = Image;
664 imageMap.Merge(temp);
666 SetValue(ImageProperty, imageMap);
667 NotifyPropertyChanged();
673 /// Gets or sets fitting options used when resizing images to fit the desired dimensions.<br />
674 /// If not supplied, the default is FittingModeType.ShrinkToFit.<br />
675 /// For normal quad images only.<br />
678 /// <since_tizen> 6 </since_tizen>
679 [EditorBrowsable(EditorBrowsableState.Never)]
680 public FittingModeType FittingMode
684 int ret = (int)FittingModeType.ShrinkToFit;
685 Image.Find(ImageVisualProperty.FittingMode)?.Get(out ret);
687 return (FittingModeType)ret;
691 PropertyMap temp = new PropertyMap();
692 temp.Insert(ImageVisualProperty.FittingMode, new PropertyValue((int)value));
694 PropertyMap imageMap = Image;
695 imageMap.Merge(temp);
697 SetValue(ImageProperty, imageMap);
698 NotifyPropertyChanged();
705 /// Gets or sets the desired image width.<br />
706 /// If not specified, the actual image width is used.<br />
707 /// For normal quad images only.<br />
710 /// <since_tizen> 6 </since_tizen>
711 [EditorBrowsable(EditorBrowsableState.Never)]
712 public int DesiredWidth
717 Image.Find(ImageVisualProperty.DesiredWidth)?.Get(out ret);
723 PropertyMap temp = new PropertyMap();
724 temp.Insert(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
726 PropertyMap imageMap = Image;
727 imageMap.Merge(temp);
729 SetValue(ImageProperty, imageMap);
730 NotifyPropertyChanged();
735 /// Gets or sets the desired image height.<br />
736 /// If not specified, the actual image height is used.<br />
737 /// For normal quad images only.<br />
740 /// <since_tizen> 6 </since_tizen>
741 [EditorBrowsable(EditorBrowsableState.Never)]
742 public int DesiredHeight
747 Image.Find(ImageVisualProperty.DesiredHeight)?.Get(out ret);
753 PropertyMap temp = new PropertyMap();
754 temp.Insert(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
756 PropertyMap imageMap = Image;
757 imageMap.Merge(temp);
759 SetValue(ImageProperty, imageMap);
760 NotifyPropertyChanged();
766 /// Gets or sets the wrap mode for the u coordinate.<br />
767 /// It decides how the texture should be sampled when the u coordinate exceeds the range of 0.0 to 1.0.<br />
768 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
769 /// For normal quad images only.<br />
772 /// <since_tizen> 6 </since_tizen>
773 [EditorBrowsable(EditorBrowsableState.Never)]
774 public WrapModeType WrapModeU
778 int ret = (int)WrapModeType.Default;
779 Image.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
781 return (WrapModeType)ret;
785 PropertyMap temp = new PropertyMap();
786 temp.Insert(ImageVisualProperty.WrapModeU, new PropertyValue((int)value));
788 PropertyMap imageMap = Image;
789 imageMap.Merge(temp);
791 SetValue(ImageProperty, imageMap);
792 NotifyPropertyChanged();
797 /// Gets or sets the wrap mode for the v coordinate.<br />
798 /// It decides how the texture should be sampled when the v coordinate exceeds the range of 0.0 to 1.0.<br />
799 /// 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 />
800 /// If not specified, the default is WrapModeType.Default(CLAMP).<br />
801 /// For normal quad images only.
804 /// <since_tizen> 6 </since_tizen>
805 [EditorBrowsable(EditorBrowsableState.Never)]
806 public WrapModeType WrapModeV
810 int ret = (int)WrapModeType.Default;
811 Image.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
813 return (WrapModeType)ret;
817 PropertyMap temp = new PropertyMap();
818 temp.Insert(ImageVisualProperty.WrapModeV, new PropertyValue((int)value));
820 PropertyMap imageMap = Image;
821 imageMap.Merge(temp);
823 SetValue(ImageProperty, imageMap);
824 NotifyPropertyChanged();
828 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageView obj)
830 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
833 internal void SetImage(string url, Uint16Pair size)
836 Interop.ImageView.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
837 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
840 internal ViewResourceReadySignal ResourceReadySignal(View view)
842 ViewResourceReadySignal ret = new ViewResourceReadySignal(Interop.View.ResourceReadySignal(View.getCPtr(view)), false);
843 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
847 internal ResourceLoadingStatusType GetResourceStatus()
849 return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
853 /// you can override it to clean-up your own resources.
855 /// <param name="type">DisposeTypes</param>
856 /// <since_tizen> 3 </since_tizen>
857 protected override void Dispose(DisposeTypes type)
864 if (type == DisposeTypes.Explicit)
867 //Release your own managed resources here.
868 //You should release all of your own disposable objects here.
871 _nPatchMap?.Dispose();
877 //Release your own unmanaged resources here.
878 //You should not access any managed member here except static instance.
879 //because the execution order of Finalizes is non-deterministic.
881 if (swigCPtr.Handle != global::System.IntPtr.Zero)
886 Interop.ImageView.delete_ImageView(swigCPtr);
888 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
894 // Callback for View ResourceReady signal
895 private void OnResourceReady(IntPtr data)
897 ResourceReadyEventArgs e = new ResourceReadyEventArgs();
900 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
903 if (_resourceReadyEventHandler != null)
905 _resourceReadyEventHandler(this, e);
909 private void UpdateImage()
911 if (_url != null && _url != "")
914 { // for nine-patch image
915 _nPatchMap = new PropertyMap();
916 _nPatchMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
917 _nPatchMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
918 _nPatchMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border));
919 if (_borderOnly != null) { _nPatchMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
920 if (_synchronousLoading != null) { _nPatchMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
921 if (_orientationCorrection != null) { _nPatchMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); }
922 SetProperty(ImageView.Property.IMAGE, new PropertyValue(_nPatchMap));
923 _imageType = ImageType.Npatch;
925 else if (_synchronousLoading != null || _orientationCorrection != null)
926 { // for normal image, with synchronous loading property
927 PropertyMap imageMap = new PropertyMap();
928 imageMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
929 imageMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
930 if (_synchronousLoading != null) { imageMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
931 if (_orientationCorrection != null) { imageMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); }
932 SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
934 _imageType = ImageType.Specific;
937 { // just for normal image
938 SetProperty(ImageView.Property.IMAGE, new PropertyValue(_url));
939 _imageType = ImageType.Normal;
944 //Image property is set and used
945 PropertyMap map = new PropertyMap();
946 map.Insert(ImageVisualProperty.URL, new PropertyValue(""));
947 if (_synchronousLoading != null)
949 map.Insert(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading));
951 if (_orientationCorrection != null)
953 map.Insert(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection));
959 SetProperty(ImageView.Property.IMAGE, new PropertyValue(map));
960 _imageType = ImageType.Normal;
964 private void OnResourceLoaded(IntPtr view)
966 ResourceLoadedEventArgs e = new ResourceLoadedEventArgs();
967 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE);
969 if (_resourceLoadedEventHandler != null)
971 _resourceLoadedEventHandler(this, e);
976 /// Event arguments of resource ready.
978 /// <since_tizen> 3 </since_tizen>
979 public class ResourceReadyEventArgs : EventArgs
984 /// The view whose resource is ready.
986 /// <since_tizen> 3 </since_tizen>
1000 internal class ResourceLoadedEventArgs : EventArgs
1002 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1003 public ResourceLoadingStatusType Status
1016 internal new class Property
1018 internal static readonly int RESOURCE_URL = Interop.ImageView.ImageView_Property_RESOURCE_URL_get();
1019 internal static readonly int IMAGE = Interop.ImageView.ImageView_Property_IMAGE_get();
1020 internal static readonly int PRE_MULTIPLIED_ALPHA = Interop.ImageView.ImageView_Property_PRE_MULTIPLIED_ALPHA_get();
1021 internal static readonly int PIXEL_AREA = Interop.ImageView.ImageView_Property_PIXEL_AREA_get();
1022 internal static readonly int ACTION_RELOAD = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_RELOAD_get();
1023 internal static readonly int ACTION_PLAY = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PLAY_get();
1024 internal static readonly int ACTION_PAUSE = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_PAUSE_get();
1025 internal static readonly int ACTION_STOP = Interop.ImageView.ImageView_IMAGE_VISUAL_ACTION_STOP_get();
1028 private enum ImageType
1031 /// For Normal Image.
1036 /// For normal image, with synchronous loading and orientation correction property
1041 /// For nine-patch image