--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+
+namespace ElmSharp.Test
+{
+ public class ImageTest2 : TestCaseBase
+ {
+ public override string TestName => "ImageTest2";
+ public override string TestDescription => "To test basic operation of Image";
+
+ Image image;
+ Label lbInfo;
+
+ public override void Run(Window window)
+ {
+ Conformant conformant = new Conformant(window);
+ conformant.Show();
+ Box box = new Box(window);
+ conformant.SetContent(box);
+ box.Show();
+
+ Box buttonBox1 = new Box(window) {
+ IsHorizontal = true,
+ AlignmentX = -1,
+ AlignmentY = 0,
+ };
+ buttonBox1.Show();
+
+ Button btnFile1 = new Button(window) {
+ Text = "Blue",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnFile1.Show();
+
+ Button btnFile2 = new Button(window) {
+ Text = "Default",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnFile2.Show();
+
+ Button btnFile3 = new Button(window) {
+ Text = "Aspect",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnFile3.Show();
+
+ Button btnFile4 = new Button(window) {
+ Text = "Rotate",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnFile4.Show();
+
+ buttonBox1.PackEnd(btnFile1);
+ buttonBox1.PackEnd(btnFile2);
+ buttonBox1.PackEnd(btnFile3);
+ buttonBox1.PackEnd(btnFile4);
+
+ lbInfo = new Label(window) {
+ Color = Color.White,
+ AlignmentX = -1,
+ AlignmentY = 0,
+ WeightX = 1
+ };
+ lbInfo.Show();
+
+ image = new Image(window) {
+ IsFixedAspect = true,
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ image.Show();
+ image.Load(Path.Combine(TestRunner.ResourceDir, "picture.png"));
+ image.Clicked += (s, e) =>
+ {
+ Console.WriteLine("Image has been clicked. (IsFixedAspect = {0}", image.IsFixedAspect);
+ image.IsFixedAspect = image.IsFixedAspect == true ? false : true;
+ };
+
+ btnFile1.Clicked += (s, e) => { image.BackgroundColor = Color.Blue; UpdateLabelText(image.BackgroundColor.ToString()); };
+ btnFile2.Clicked += (s, e) => { image.BackgroundColor = Color.Default; UpdateLabelText(image.BackgroundColor.ToString()); };
+ btnFile3.Clicked += (s, e) => { image.IsFixedAspect = image.IsFixedAspect == true ? false : true; };
+ btnFile4.Clicked += (s, e) => { image.Orientation = image.Orientation == ImageOrientation.None ? ImageOrientation.Rotate270 : ImageOrientation.None; };
+
+ box.PackEnd(buttonBox1);
+ box.PackEnd(lbInfo);
+ box.PackEnd(image);
+ }
+
+ void UpdateLabelText(string text)
+ {
+ lbInfo.Text = "<span color=#ffffff font_size=20>" + text + "</span>";
+ }
+ }
+}
{
get
{
- return Interop.Elementary.elm_image_file_get(Handle);
+ return Interop.Elementary.elm_image_file_get(RealHandle);
}
}
{
get
{
- return Interop.Elementary.elm_image_smooth_get(Handle);
+ return Interop.Elementary.elm_image_smooth_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_smooth_set(Handle, value);
+ Interop.Elementary.elm_image_smooth_set(RealHandle, value);
}
}
{
get
{
- return !Interop.Elementary.elm_image_no_scale_get(Handle);
+ return !Interop.Elementary.elm_image_no_scale_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_no_scale_set(Handle, !value);
+ Interop.Elementary.elm_image_no_scale_set(RealHandle, !value);
}
}
set
{
_canScaleDown = value;
- Interop.Elementary.elm_image_resizable_set(Handle, _canScaleUp, _canScaleDown);
+ Interop.Elementary.elm_image_resizable_set(RealHandle, _canScaleUp, _canScaleDown);
}
}
set
{
_canScaleUp = value;
- Interop.Elementary.elm_image_resizable_set(Handle, _canScaleUp, _canScaleDown);
+ Interop.Elementary.elm_image_resizable_set(RealHandle, _canScaleUp, _canScaleDown);
}
}
{
get
{
- return Interop.Elementary.elm_image_fill_outside_get(Handle);
+ return Interop.Elementary.elm_image_fill_outside_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_fill_outside_set(Handle, value);
+ Interop.Elementary.elm_image_fill_outside_set(RealHandle, value);
}
}
{
get
{
- return Interop.Elementary.elm_image_prescale_get(Handle);
+ return Interop.Elementary.elm_image_prescale_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_prescale_set(Handle, value);
+ Interop.Elementary.elm_image_prescale_set(RealHandle, value);
}
}
{
get
{
- return Interop.Elementary.elm_image_aspect_fixed_get(Handle);
+ return Interop.Elementary.elm_image_aspect_fixed_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_aspect_fixed_set(Handle, value);
+ Interop.Elementary.elm_image_aspect_fixed_set(RealHandle, value);
}
}
{
get
{
- return Interop.Elementary.elm_image_animated_get(Handle);
+ return Interop.Elementary.elm_image_animated_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_animated_set(Handle, value);
+ Interop.Elementary.elm_image_animated_set(RealHandle, value);
}
}
{
get
{
- return Interop.Elementary.elm_image_animated_available_get(Handle);
+ return Interop.Elementary.elm_image_animated_available_get(RealHandle);
}
}
{
get
{
- return Interop.Elementary.elm_image_animated_play_get(Handle);
+ return Interop.Elementary.elm_image_animated_play_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_animated_play_set(Handle, value);
+ Interop.Elementary.elm_image_animated_play_set(RealHandle, value);
}
}
{
get
{
- return Interop.Elementary.elm_image_editable_get(Handle);
+ return Interop.Elementary.elm_image_editable_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_editable_set(Handle, value);
+ Interop.Elementary.elm_image_editable_set(RealHandle, value);
}
}
get
{
int w, h;
- Interop.Elementary.elm_image_object_size_get(Handle, out w, out h);
+ Interop.Elementary.elm_image_object_size_get(RealHandle, out w, out h);
return new Size(w, h);
}
}
{
get
{
- IntPtr evasObj = Interop.Elementary.elm_image_object_get(Handle);
+ IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
if (evasObj != IntPtr.Zero)
{
return !Interop.Evas.evas_object_image_alpha_get(evasObj);
}
set
{
- IntPtr evasObj = Interop.Elementary.elm_image_object_get(Handle);
+ IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
if (evasObj != IntPtr.Zero)
{
Interop.Evas.evas_object_image_alpha_set(evasObj, !value);
{
get
{
- return (ImageOrientation)Interop.Elementary.elm_image_orient_get(Handle);
+ return (ImageOrientation)Interop.Elementary.elm_image_orient_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_orient_set(Handle, (int)value);
+ Interop.Elementary.elm_image_orient_set(RealHandle, (int)value);
}
}
get
{
int r = 255, g = 255, b = 255, a = 255;
- IntPtr evasObj = Interop.Elementary.elm_image_object_get(Handle);
+ IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
if (evasObj != IntPtr.Zero)
{
Interop.Evas.evas_object_color_get(evasObj, out r, out g, out b, out a);
}
set
{
- IntPtr evasObj = Interop.Elementary.elm_image_object_get(Handle);
+ IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
if (evasObj != IntPtr.Zero)
{
Interop.Evas.evas_object_color_set(evasObj, value.R, value.G, value.B, value.A);
}
}
+ public override Color BackgroundColor
+ {
+ set
+ {
+ if (value.IsDefault)
+ {
+ SetPartColor("bg", Color.Transparent);
+ }
+ else
+ {
+ SetPartColor("bg", value);
+ }
+ _backgroundColor = value;
+ }
+ }
+
public bool Load(string file)
{
if (file == null)
throw new ArgumentNullException("file");
- Interop.Elementary.elm_image_async_open_set(Handle, false);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, true);
- return Interop.Elementary.elm_image_file_set(Handle, file, null);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, false);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, true);
+ return Interop.Elementary.elm_image_file_set(RealHandle, file, null);
}
public bool Load(Uri uri)
if (img == null)
throw new ArgumentNullException("img");
- Interop.Elementary.elm_image_async_open_set(Handle, false);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, true);
- return Interop.Elementary.elm_image_memfile_set(Handle, img, size, IntPtr.Zero, IntPtr.Zero);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, false);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, true);
+ return Interop.Elementary.elm_image_memfile_set(RealHandle, img, size, IntPtr.Zero, IntPtr.Zero);
}
public bool Load(Stream stream)
if (stream == null)
throw new ArgumentNullException("stream");
- Interop.Elementary.elm_image_async_open_set(Handle, false);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, true);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, false);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, true);
MemoryStream memstream = new MemoryStream();
stream.CopyTo(memstream);
unsafe
byte[] dataArr = memstream.ToArray();
fixed (byte* data = &dataArr[0])
{
- return Interop.Elementary.elm_image_memfile_set(Handle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
+ return Interop.Elementary.elm_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
}
}
}
if (file == null)
throw new ArgumentNullException("file");
- Interop.Elementary.elm_image_async_open_set(Handle, true);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, false);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, true);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, false);
var tcs = new TaskCompletionSource<bool>();
}
};
- bool ret = Interop.Elementary.elm_image_file_set(Handle, file, null);
+ bool ret = Interop.Elementary.elm_image_file_set(RealHandle, file, null);
if (!ret)
{
throw new InvalidOperationException("Failed to set file to Image");
if (stream == null)
throw new ArgumentNullException("stream");
- Interop.Elementary.elm_image_async_open_set(Handle, true);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, false);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, true);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, false);
var tcs = new TaskCompletionSource<bool>();
byte[] dataArr = memstream.ToArray();
fixed (byte* data = &dataArr[0])
{
- bool ret = Interop.Elementary.elm_image_memfile_set(Handle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
+ bool ret = Interop.Elementary.elm_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
if (!ret)
{
return false;
protected override IntPtr CreateHandle(EvasObject parent)
{
- return Interop.Elementary.elm_image_add(parent.Handle);
+ IntPtr handle = Interop.Elementary.elm_layout_add(parent);
+ Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
+
+ RealHandle = Interop.Elementary.elm_image_add(handle);
+ Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
+
+ return handle;
}
}