2 * Copyright(c) 2021 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.ComponentModel;
19 using System.Runtime.InteropServices;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.BaseComponents
24 public partial class ImageView
26 /// Intenal used, will never be opened.
27 [EditorBrowsable(EditorBrowsableState.Never)]
28 public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ImageView.ResourceUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
30 var imageView = (ImageView)bindable;
32 if (newValue is Selector<string> selector)
34 imageView.ResourceUrlSelector = selector;
38 imageView.resourceUrlSelector?.Reset(imageView);
39 imageView.SetResourceUrl((string)newValue);
42 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
44 var imageView = (ImageView)bindable;
47 PropertyMap imageMap = new PropertyMap();
48 Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE).Get(imageMap);
49 imageMap.Find(ImageVisualProperty.URL)?.Get(out ret);
53 /// Intenal used, will never be opened.
54 [EditorBrowsable(EditorBrowsableState.Never)]
55 public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(ImageView.Image), typeof(PropertyMap), typeof(ImageView), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
57 var imageView = (ImageView)bindable;
60 PropertyMap map = (PropertyMap)newValue;
61 if (imageView.IsCreateByXaml)
63 string url = "", alphaMaskURL = "", auxiliaryImageURL = "";
64 string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
65 PropertyValue urlValue = map.Find(NDalic.ImageVisualUrl);
67 if (urlValue != null) ret = urlValue.Get(out url);
68 PropertyMap mmap = new PropertyMap();
69 if (ret && url.StartsWith("*Resource*"))
71 url = url.Replace("*Resource*", resource);
72 mmap.Insert(NDalic.ImageVisualUrl, new PropertyValue(url));
76 PropertyValue alphaMaskUrlValue = map.Find(NDalic.ImageVisualAlphaMaskUrl);
77 if (alphaMaskUrlValue != null) ret = alphaMaskUrlValue.Get(out alphaMaskURL);
78 if (ret && alphaMaskURL.StartsWith("*Resource*"))
80 alphaMaskURL = alphaMaskURL.Replace("*Resource*", resource);
81 mmap.Insert(NDalic.ImageVisualUrl, new PropertyValue(alphaMaskURL));
85 PropertyValue auxiliaryImageURLValue = map.Find(NDalic.ImageVisualAuxiliaryImageUrl);
86 if (auxiliaryImageURLValue != null) ret = auxiliaryImageURLValue.Get(out auxiliaryImageURL);
87 if (ret && auxiliaryImageURL.StartsWith("*Resource*"))
89 auxiliaryImageURL = auxiliaryImageURL.Replace("*Resource*", resource);
90 mmap.Insert(NDalic.ImageVisualAuxiliaryImageUrl, new PropertyValue(auxiliaryImageURL));
95 if (imageView._border == null)
97 Tizen.NUI.Object.SetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
101 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
103 var imageView = (ImageView)bindable;
104 if (imageView._border == null)
106 PropertyMap temp = new PropertyMap();
107 Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE).Get(temp);
116 /// Intenal used, will never be opened.
117 [EditorBrowsable(EditorBrowsableState.Never)]
118 public static readonly BindableProperty PreMultipliedAlphaProperty = BindableProperty.Create(nameof(PreMultipliedAlpha), typeof(bool), typeof(ImageView), false, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
120 var imageView = (ImageView)bindable;
121 if (newValue != null)
123 Tizen.NUI.Object.SetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.PreMultipliedAlpha, new Tizen.NUI.PropertyValue((bool)newValue));
126 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
128 var imageView = (ImageView)bindable;
130 Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.PreMultipliedAlpha).Get(out temp);
134 /// Intenal used, will never be opened.
135 [EditorBrowsable(EditorBrowsableState.Never)]
136 public static readonly BindableProperty PixelAreaProperty = BindableProperty.Create(nameof(PixelArea), typeof(RelativeVector4), typeof(ImageView), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) =>
138 var imageView = (ImageView)bindable;
139 if (newValue != null)
141 Tizen.NUI.Object.SetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.PixelArea, new Tizen.NUI.PropertyValue((RelativeVector4)newValue));
144 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
146 var imageView = (ImageView)bindable;
147 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
148 Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.PixelArea).Get(temp);
149 RelativeVector4 relativeTemp = new RelativeVector4(temp.X, temp.Y, temp.Z, temp.W);
153 /// Intenal used, will never be opened.
154 [EditorBrowsable(EditorBrowsableState.Never)]
155 public static readonly BindableProperty BorderProperty = BindableProperty.Create(nameof(Border), typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
157 var imageView = (ImageView)bindable;
158 imageView.borderSelector?.Reset(imageView);
160 if (newValue is Selector<Rectangle> selector)
162 if (selector.HasAll()) imageView.SetBorder(selector.All);
163 else imageView.borderSelector = new TriggerableSelector<Rectangle>(imageView, selector, imageView.SetBorder, true);
167 imageView.SetBorder((Rectangle)newValue);
170 defaultValueCreator: (bindable) =>
172 var imageView = (ImageView)bindable;
173 return imageView._border;
176 /// Intenal used, will never be opened.
177 [EditorBrowsable(EditorBrowsableState.Never)]
178 public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create(nameof(BorderOnly), typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
180 var imageView = (ImageView)bindable;
181 if (newValue != null)
183 imageView.UpdateImage(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)newValue));
186 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
188 var imageView = (ImageView)bindable;
190 PropertyMap imageMap = new PropertyMap();
191 Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE).Get(imageMap);
192 imageMap.Find(ImageVisualProperty.BorderOnly)?.Get(out ret);
196 /// Intenal used, will never be opened.
197 [EditorBrowsable(EditorBrowsableState.Never)]
198 public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create(nameof(SynchronousLoading), typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
200 var imageView = (ImageView)bindable;
201 if (newValue != null)
203 imageView._synchronousLoading = (bool)newValue;
204 imageView.UpdateImage(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
207 defaultValueCreator: (bindable) =>
209 var imageView = (ImageView)bindable;
210 return imageView._synchronousLoading;
213 /// This will be public opened in tizen_7.0 after ACR done. Before ACR, need to be hidden as inhouse API.
214 [EditorBrowsable(EditorBrowsableState.Never)]
215 public static readonly BindableProperty SynchronousLoadingProperty = BindableProperty.Create(nameof(SynchronousLoading), typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
217 var imageView = (ImageView)bindable;
218 if (newValue != null)
220 imageView._synchronousLoading = (bool)newValue;
221 imageView.UpdateImage(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
224 defaultValueCreator: (bindable) =>
226 var imageView = (ImageView)bindable;
227 return imageView._synchronousLoading;
230 /// Intenal used, will never be opened.
231 [EditorBrowsable(EditorBrowsableState.Never)]
232 public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create(nameof(OrientationCorrection), typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
234 var imageView = (ImageView)bindable;
235 if (newValue != null)
237 imageView.UpdateImage(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)newValue));
240 defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
242 var imageView = (ImageView)bindable;
245 PropertyMap imageMap = new PropertyMap();
246 Tizen.NUI.Object.GetProperty((HandleRef)imageView.SwigCPtr, ImageView.Property.IMAGE).Get(imageMap);
247 imageMap?.Find(ImageVisualProperty.OrientationCorrection)?.Get(out ret);
255 [EditorBrowsable(EditorBrowsableState.Never)]
256 public static readonly BindableProperty ImageMapProperty = BindableProperty.Create(nameof(ImageMap), typeof(Tizen.NUI.PropertyMap), typeof(Tizen.NUI.BaseComponents.ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
258 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
259 if (newValue != null)
261 instance.InternalImageMap = (Tizen.NUI.PropertyMap)newValue;
264 defaultValueCreator: (bindable) =>
266 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
267 return instance.InternalImageMap;
271 /// AlphaMaskURLProperty
273 [EditorBrowsable(EditorBrowsableState.Never)]
274 public static readonly BindableProperty AlphaMaskURLProperty = BindableProperty.Create(nameof(AlphaMaskURL), typeof(string), typeof(Tizen.NUI.BaseComponents.ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
276 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
277 if (newValue != null)
279 instance.InternalAlphaMaskURL = (string)newValue;
282 defaultValueCreator: (bindable) =>
284 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
285 return instance.InternalAlphaMaskURL;
289 /// CropToMaskProperty
291 [EditorBrowsable(EditorBrowsableState.Never)]
292 public static readonly BindableProperty CropToMaskProperty = BindableProperty.Create(nameof(CropToMask), typeof(bool), typeof(Tizen.NUI.BaseComponents.ImageView), 0, propertyChanged: (bindable, oldValue, newValue) =>
294 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
295 if (newValue != null)
297 instance.InternalCropToMask = (bool)newValue;
300 defaultValueCreator: (bindable) =>
302 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
303 return instance.InternalCropToMask;
307 /// FittingModeProperty
309 [EditorBrowsable(EditorBrowsableState.Never)]
310 public static readonly BindableProperty FittingModeProperty = BindableProperty.Create(nameof(FittingMode), typeof(Tizen.NUI.FittingModeType), typeof(Tizen.NUI.BaseComponents.ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
312 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
313 if (newValue != null)
315 instance.InternalFittingMode = (Tizen.NUI.FittingModeType)newValue;
318 defaultValueCreator: (bindable) =>
320 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
321 return instance.InternalFittingMode;
325 /// DesiredWidthProperty
327 [EditorBrowsable(EditorBrowsableState.Never)]
328 public static readonly BindableProperty DesiredWidthProperty = BindableProperty.Create(nameof(DesiredWidth), typeof(int), typeof(Tizen.NUI.BaseComponents.ImageView), 0, propertyChanged: (bindable, oldValue, newValue) =>
330 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
331 if (newValue != null)
333 instance.InternalDesiredWidth = (int)newValue;
336 defaultValueCreator: (bindable) =>
338 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
339 return instance.InternalDesiredWidth;
343 /// DesiredHeightProperty
345 [EditorBrowsable(EditorBrowsableState.Never)]
346 public static readonly BindableProperty DesiredHeightProperty = BindableProperty.Create(nameof(DesiredHeight), typeof(int), typeof(Tizen.NUI.BaseComponents.ImageView), 0, propertyChanged: (bindable, oldValue, newValue) =>
348 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
349 if (newValue != null)
351 instance.InternalDesiredHeight = (int)newValue;
354 defaultValueCreator: (bindable) =>
356 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
357 return instance.InternalDesiredHeight;
361 /// ReleasePolicyProperty
363 [EditorBrowsable(EditorBrowsableState.Never)]
364 public static readonly BindableProperty ReleasePolicyProperty = BindableProperty.Create(nameof(ReleasePolicy), typeof(Tizen.NUI.ReleasePolicyType), typeof(Tizen.NUI.BaseComponents.ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
366 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
367 if (newValue != null)
369 instance.InternalReleasePolicy = (Tizen.NUI.ReleasePolicyType)newValue;
372 defaultValueCreator: (bindable) =>
374 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
375 return instance.InternalReleasePolicy;
379 /// WrapModeUProperty
381 [EditorBrowsable(EditorBrowsableState.Never)]
382 public static readonly BindableProperty WrapModeUProperty = BindableProperty.Create(nameof(WrapModeU), typeof(Tizen.NUI.WrapModeType), typeof(Tizen.NUI.BaseComponents.ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
384 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
385 if (newValue != null)
387 instance.InternalWrapModeU = (Tizen.NUI.WrapModeType)newValue;
390 defaultValueCreator: (bindable) =>
392 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
393 return instance.InternalWrapModeU;
397 /// WrapModeVProperty
399 [EditorBrowsable(EditorBrowsableState.Never)]
400 public static readonly BindableProperty WrapModeVProperty = BindableProperty.Create(nameof(WrapModeV), typeof(Tizen.NUI.WrapModeType), typeof(Tizen.NUI.BaseComponents.ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
402 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
403 if (newValue != null)
405 instance.InternalWrapModeV = (Tizen.NUI.WrapModeType)newValue;
408 defaultValueCreator: (bindable) =>
410 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
411 return instance.InternalWrapModeV;
415 /// AdjustViewSizeProperty
417 [EditorBrowsable(EditorBrowsableState.Never)]
418 public static readonly BindableProperty AdjustViewSizeProperty = BindableProperty.Create(nameof(AdjustViewSize), typeof(bool), typeof(Tizen.NUI.BaseComponents.ImageView), 0, propertyChanged: (bindable, oldValue, newValue) =>
420 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
421 if (newValue != null)
423 instance.adjustViewSize = (bool)newValue;
426 defaultValueCreator: (bindable) =>
428 var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
429 return instance.adjustViewSize;