public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ImageView.ResourceUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
var imageView = (ImageView)bindable;
- string url = (string)newValue;
- url = (url == null ? "" : url);
-
- imageView.UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
+ if (newValue != null)
+ {
+ string url = (string)newValue;
+ imageView._url = url;
+ imageView.UpdateImage();
+ }
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
- string ret = "";
- PropertyMap imageMap = (PropertyMap)imageView.GetValue(ImageProperty);
- imageMap.Find(ImageVisualProperty.URL)?.Get(out ret);
- return ret;
+ if(imageView._imageType == ImageType.Normal)
+ {
+ Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(out imageView._url);
+ }
+ return imageView._url;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
if (imageView._border == null)
{
- Tizen.NUI.Object.SetProperty(imageView.swigCPtr, ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(map));
+ imageView._image = map;
+ imageView.UpdateImage();
}
}
},
public static readonly BindableProperty BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var imageView = (ImageView)bindable;
- imageView._border = (Rectangle)newValue;
if (newValue != null)
{
- imageView.UpdateImage(ImageVisualProperty.Border, new PropertyValue(imageView._border));
- }
- else
- {
- imageView.UpdateImage(ImageVisualProperty.Border, new PropertyValue(new Rectangle(0,0,0,0)));
+ imageView._border = (Rectangle)newValue;
+ imageView.UpdateImage();
}
},
defaultValueCreator: (bindable) =>
var imageView = (ImageView)bindable;
if (newValue != null)
{
- imageView.UpdateImage(ImageVisualProperty.BorderOnly, new PropertyValue((bool)newValue));
+ imageView._borderOnly = (bool)newValue;
+ imageView.UpdateImage();
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
- bool ret = false;
- PropertyMap imageMap = (PropertyMap)imageView.GetValue(ImageProperty);
- imageMap.Find(ImageVisualProperty.BorderOnly)?.Get(out ret);
- return ret;
+ return imageView._borderOnly ?? false;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var imageView = (ImageView)bindable;
if (newValue != null)
{
- imageView.UpdateImage(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)newValue));
+ imageView._synchronousLoading = (bool)newValue;
+ imageView.UpdateImage();
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
- bool ret = false;
- PropertyMap imageMap = (PropertyMap)imageView.GetValue(ImageProperty);
- imageMap.Find(ImageVisualProperty.SynchronousLoading)?.Get(out ret);
- return ret;
+ return imageView._synchronousLoading ?? false;
});
/// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var imageView = (ImageView)bindable;
if (newValue != null)
{
- imageView.UpdateImage(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)newValue));
+ imageView._orientationCorrection = (bool)newValue;
+ imageView.UpdateImage();
}
},
defaultValueCreator: (bindable) =>
{
var imageView = (ImageView)bindable;
-
- bool ret = false;
- PropertyMap imageMap = (PropertyMap)imageView.GetValue(ImageProperty);
- imageMap?.Find(ImageVisualProperty.OrientationCorrection)?.Get(out ret);
-
- return ret;
+ return imageView._orientationCorrection ?? false;
});
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private _resourceLoadedCallbackType _resourceLoadedCallback;
private Rectangle _border;
+ private PropertyMap _nPatchMap;
+ private bool? _synchronousLoading;
+ private bool? _borderOnly;
+ private string _url;
+ private bool? _orientationCorrection;
+ private PropertyMap _image;
+ private ImageType _imageType;
/// <summary>
/// Creates an initialized ImageView.
/// <since_tizen> 3 </since_tizen>
public ImageView(string url) : this(Interop.ImageView.ImageView_New__SWIG_2(url), true)
{
- UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
+ _url = url;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal ImageView(string url, Uint16Pair size) : this(Interop.ImageView.ImageView_New__SWIG_3(url, Uint16Pair.getCPtr(size)), true)
{
- UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
+ _url = url;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}
set
{
- SetValue(ResourceUrlProperty, value);
- NotifyPropertyChanged();
+ _url = (value == null ? "" : value);
+ SetValue(ResourceUrlProperty, _url);
+ NotifyPropertyChanged();
+
}
}
{
if (_border == null)
{
+ if (_url != null) { value.Add("url", new PropertyValue(_url)); }
SetProperty(ImageView.Property.IMAGE, new Tizen.NUI.PropertyValue(value));
NotifyPropertyChanged();
}
/// <since_tizen> 3 </since_tizen>
public void SetImage(string url)
{
- UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
+ _url = url;
+ Interop.ImageView.ImageView_SetImage__SWIG_1(swigCPtr, url);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
/// <summary>
get
{
string ret = "";
- PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
- imageMap?.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
+ Image.Find(ImageVisualProperty.AlphaMaskURL)?.Get(out ret);
return ret;
}
temp.Insert(ImageVisualProperty.AlphaMaskURL, new PropertyValue(value));
PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
-
imageMap.Merge(temp);
-
- SetValue(ImageProperty, imageMap);
- NotifyPropertyChanged();
+
+ SetValue(ImageProperty, imageMap);
+ NotifyPropertyChanged();
}
}
get
{
bool ret = false;
- PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
- imageMap?.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
+ Image.Find(ImageVisualProperty.CropToMask)?.Get(out ret);
return ret;
}
{
PropertyMap temp = new PropertyMap();
temp.Insert(ImageVisualProperty.CropToMask, new PropertyValue(value));
-
+
PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
imageMap.Merge(temp);
get
{
int ret = (int)FittingModeType.ShrinkToFit;
- PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
- imageMap?.Find(ImageVisualProperty.FittingMode)?.Get(out ret);
+ Image.Find(ImageVisualProperty.FittingMode)?.Get(out ret);
return (FittingModeType)ret;
}
{
PropertyMap temp = new PropertyMap();
temp.Insert(ImageVisualProperty.FittingMode, new PropertyValue((int)value));
-
+
PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
imageMap.Merge(temp);
-
+
SetValue(ImageProperty, imageMap);
NotifyPropertyChanged();
}
get
{
int ret = -1;
- PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
- imageMap?.Find(ImageVisualProperty.DesiredWidth)?.Get(out ret);
+ Image.Find(ImageVisualProperty.DesiredWidth)?.Get(out ret);
return ret;
}
{
PropertyMap temp = new PropertyMap();
temp.Insert(ImageVisualProperty.DesiredWidth, new PropertyValue(value));
-
+
PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
imageMap.Merge(temp);
-
+
SetValue(ImageProperty, imageMap);
NotifyPropertyChanged();
}
get
{
int ret = -1;
- PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
- imageMap?.Find(ImageVisualProperty.DesiredHeight)?.Get(out ret);
+ Image.Find(ImageVisualProperty.DesiredHeight)?.Get(out ret);
return ret;
}
{
PropertyMap temp = new PropertyMap();
temp.Insert(ImageVisualProperty.DesiredHeight, new PropertyValue(value));
-
+
PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
imageMap.Merge(temp);
-
+
SetValue(ImageProperty, imageMap);
NotifyPropertyChanged();
}
get
{
int ret = (int)WrapModeType.Default;
- PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
- imageMap?.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
+ Image.Find(ImageVisualProperty.WrapModeU)?.Get(out ret);
return (WrapModeType)ret;
}
{
PropertyMap temp = new PropertyMap();
temp.Insert(ImageVisualProperty.WrapModeU, new PropertyValue((int)value));
-
+
PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
imageMap.Merge(temp);
-
+
SetValue(ImageProperty, imageMap);
NotifyPropertyChanged();
}
get
{
int ret = (int)WrapModeType.Default;
- PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
- imageMap?.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
+ Image.Find(ImageVisualProperty.WrapModeV)?.Get(out ret);
return (WrapModeType)ret;
}
{
PropertyMap temp = new PropertyMap();
temp.Insert(ImageVisualProperty.WrapModeV, new PropertyValue((int)value));
-
+
PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
imageMap.Merge(temp);
-
+
SetValue(ImageProperty, imageMap);
NotifyPropertyChanged();
}
}
-
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ImageView obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
internal void SetImage(string url, Uint16Pair size)
{
+ _url = url;
Interop.ImageView.ImageView_SetImage__SWIG_2(swigCPtr, url, Uint16Pair.getCPtr(size));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
- UpdateImage(ImageVisualProperty.URL, new PropertyValue(url));
}
internal ViewResourceReadySignal ResourceReadySignal(View view)
//You should release all of your own disposable objects here.
_border?.Dispose();
_border = null;
+ _nPatchMap?.Dispose();
+ _nPatchMap = null;
+ _image?.Dispose();
+ _image = null;
}
//Release your own unmanaged resources here.
}
}
- private void UpdateImage(int key, PropertyValue value)
+ private void UpdateImage()
{
- PropertyMap temp = new PropertyMap();
- temp.Insert(key, value);
-
- if (_border != null)
+ if (_url != null && _url != "")
{
- temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
+ if (_border != null)
+ { // for nine-patch image
+ _nPatchMap = new PropertyMap();
+ _nPatchMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.NPatch));
+ _nPatchMap.Add(NpatchImageVisualProperty.URL, new PropertyValue(_url));
+ _nPatchMap.Add(NpatchImageVisualProperty.Border, new PropertyValue(_border));
+ if (_borderOnly != null) { _nPatchMap.Add(NpatchImageVisualProperty.BorderOnly, new PropertyValue((bool)_borderOnly)); }
+ if (_synchronousLoading != null) { _nPatchMap.Add(NpatchImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
+ if (_orientationCorrection != null) { _nPatchMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); }
+ SetProperty(ImageView.Property.IMAGE, new PropertyValue(_nPatchMap));
+ _imageType = ImageType.Npatch;
+ }
+ else if (_synchronousLoading != null || _orientationCorrection != null)
+ { // for normal image, with synchronous loading property
+ PropertyMap imageMap = new PropertyMap();
+ imageMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
+ imageMap.Add(ImageVisualProperty.URL, new PropertyValue(_url));
+ if (_synchronousLoading != null) { imageMap.Add(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading)); }
+ if (_orientationCorrection != null) { imageMap.Add(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); }
+ SetProperty(ImageView.Property.IMAGE, new PropertyValue(imageMap));
+
+ _imageType = ImageType.Specific;
+ }
+ else
+ { // just for normal image
+ SetProperty(ImageView.Property.IMAGE, new PropertyValue(_url));
+ _imageType = ImageType.Normal;
+ }
}
else
{
- temp.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
- temp.Insert(ImageVisualProperty.BorderOnly, new PropertyValue((false)));
+ //Image property is set and used
+ PropertyMap map = new PropertyMap();
+ map.Insert(ImageVisualProperty.URL, new PropertyValue(""));
+ if (_synchronousLoading != null)
+ {
+ map.Insert(ImageVisualProperty.SynchronousLoading, new PropertyValue((bool)_synchronousLoading));
+ }
+ if (_orientationCorrection != null)
+ {
+ map.Insert(ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection));
+ }
+ if (_image != null)
+ {
+ map.Merge(_image);
+ }
+ SetProperty(ImageView.Property.IMAGE, new PropertyValue(map));
+ _imageType = ImageType.Normal;
}
-
-
- PropertyMap imageMap = (PropertyMap)GetValue(ImageProperty);
- imageMap.Merge(temp);
-
- SetValue(ImageProperty, imageMap);
- NotifyPropertyChanged();
-
- temp.Dispose();
- temp = null;
}
private void OnResourceLoaded(IntPtr view)