[ElmSharp] Introduce EvasImage 30/149830/6
authorSeungkeun Lee <sngn.lee@samsung.com>
Wed, 13 Sep 2017 07:05:01 +0000 (16:05 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Tue, 19 Sep 2017 22:54:30 +0000 (07:54 +0900)
 - The new class for evas_object_image
 - Image class provide ImageObject property to access interal EvasImage

Change-Id: I3020cd5432e70950491620b935f0485cd0d13ac4

src/ElmSharp/ElmSharp/EvasImage.cs [new file with mode: 0644]
src/ElmSharp/ElmSharp/Image.cs
src/ElmSharp/Interop/Interop.Evas.Image.cs
src/ElmSharp/Interop/Interop.Evas.cs
test/ElmSharp.Test/TC/EvasImageTest1.cs [new file with mode: 0644]
test/ElmSharp.Test/TC/EvasImageTest2.cs [new file with mode: 0644]

diff --git a/src/ElmSharp/ElmSharp/EvasImage.cs b/src/ElmSharp/ElmSharp/EvasImage.cs
new file mode 100644 (file)
index 0000000..6ef6537
--- /dev/null
@@ -0,0 +1,270 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
+using System.Text;
+
+namespace ElmSharp
+{
+    /// <summary>
+    /// This group provides functions for image objects.
+    /// </summary>
+    public class EvasImage : EvasObject
+    {
+        EvasObject _source = null;
+        IntPtr _handle = IntPtr.Zero;
+
+        /// <summary>
+        /// Creates and initializes a new instance of EvasImage class.
+        /// </summary>
+        /// <param name="parent">The parent is a given container which will be attached by EvasImage as a child. It's <see cref="EvasObject"/> type.</param>
+        public EvasImage(EvasObject parent) : base(parent)
+        {
+        }
+
+        internal EvasImage(EvasObject parent, IntPtr handle) : base()
+        {
+            _handle = handle;
+            Realize(parent);
+        }
+
+        /// <summary>
+        /// Sets or gets the source file from where an image object must fetch the real image data
+        /// </summary>
+        public string File
+        {
+            get
+            {
+                string file, key;
+                Interop.Evas.evas_object_image_file_get(RealHandle, out file, out key);
+                return file;
+            }
+            set
+            {
+                Interop.Evas.evas_object_image_file_set(RealHandle, value, null);
+            }
+        }
+
+        /// <summary>
+        /// Sets or gets the source object to be visible.
+        /// </summary>
+        public bool IsSourceVisible
+        {
+            get
+            {
+                return Interop.Evas.evas_object_image_source_visible_get(RealHandle);
+            }
+            set
+            {
+                Interop.Evas.evas_object_image_source_visible_set(RealHandle, value);
+            }
+        }
+
+        /// <summary>
+        /// Sets or gets whether an object is clipped by source object's clipper.
+        /// </summary>
+        public bool IsSourceClipped
+        {
+            get
+            {
+                return Interop.Evas.evas_object_image_source_clip_get(RealHandle);
+            }
+            set
+            {
+                Interop.Evas.evas_object_image_source_clip_set(RealHandle, value);
+            }
+        }
+
+        /// <summary>
+        /// Sets or gets if the center part of the given image object (not the border) should be drawn.
+        /// </summary>
+        /// <remarks>
+        /// When rendering, the image may be scaled to fit the size of the image object.
+        /// This function sets if the center part of the scaled image is to be drawn or left completely blank, or forced to be solid.
+        /// Very useful for frames and decorations.
+        /// </remarks>
+        public ImageBorderFillMode BorderCenterFillMode
+        {
+            get
+            {
+                return (ImageBorderFillMode)Interop.Evas.evas_object_image_border_center_fill_get(RealHandle);
+            }
+            set
+            {
+                Interop.Evas.evas_object_image_border_center_fill_set(RealHandle, (int)value);
+            }
+        }
+
+        /// <summary>
+        /// Sets or gets whether the image object's fill property should track the object's size.
+        /// </summary>
+        public bool IsFilled
+        {
+            get
+            {
+                return Interop.Evas.evas_object_image_filled_get(RealHandle);
+            }
+            set
+            {
+                Interop.Evas.evas_object_image_filled_set(RealHandle, value);
+            }
+        }
+
+        /// <summary>
+        /// Sets or gets the scaling factor (multiplier) for the borders of an image object.
+        /// </summary>
+        public double BorderScale
+        {
+            get
+            {
+                return Interop.Evas.evas_object_image_border_scale_get(RealHandle);
+            }
+            set
+            {
+                Interop.Evas.evas_object_image_border_scale_set(RealHandle, value);
+            }
+        }
+
+        /// <summary>
+        /// Sets or gets the size of the given image object.
+        /// </summary>
+        public Size Size
+        {
+            get
+            {
+                int w, h;
+                Interop.Evas.evas_object_image_size_get(RealHandle, out w, out h);
+                return new Size(w, h);
+            }
+            set
+            {
+                Interop.Evas.evas_object_image_size_set(RealHandle, value.Width, value.Height);
+            }
+        }
+
+        /// <summary>
+        /// Gets the row stride of the given image object.
+        /// </summary>
+        public int Stride
+        {
+            get
+            {
+                return Interop.Evas.evas_object_image_stride_get(RealHandle);
+            }
+        }
+
+        /// <summary>
+        /// Sets or gets whether alpha channel data is being used on the given image object.
+        /// </summary>
+        public bool IsOpaque
+        {
+            get
+            {
+                return !Interop.Evas.evas_object_image_alpha_get(RealHandle);
+            }
+            set
+            {
+                Interop.Evas.evas_object_image_alpha_set(RealHandle, !value);
+
+            }
+        }
+
+        /// <summary>
+        /// Sets or gets whether to use high-quality image scaling algorithm on the given image object.
+        /// </summary>
+        public bool IsSmoothScaled
+        {
+            get
+            {
+                return Interop.Evas.evas_object_image_smooth_scale_get(RealHandle);
+            }
+            set
+            {
+                Interop.Evas.evas_object_image_smooth_scale_set(RealHandle, value);
+            }
+        }
+
+        /// <summary>
+        /// Sets how to fill an image object's drawing rectangle given the (real) image bound to it.
+        /// </summary>
+        /// <param name="geometry"></param>
+        public void SetFill(Rect geometry)
+        {
+            Interop.Evas.evas_object_image_fill_set(RealHandle, geometry.X, geometry.Y, geometry.Width, geometry.Height);
+        }
+
+        /// <summary>
+        /// Sets the source file from where an image object must fetch the real image data (it may be an Eet file, besides pure image ones).
+        /// </summary>
+        /// <param name="file">The image file path</param>
+        /// <param name="key">The image key in file (if its an Eet one), otherwise set null</param>
+        public void SetFile(string file, string key)
+        {
+            Interop.Evas.evas_object_image_file_set(RealHandle, file, key);
+        }
+
+        /// <summary>
+        /// Sets the data for an image from memory to be loaded.
+        /// </summary>
+        /// <param name="stream">memory stream</param>
+        public void SetStream(Stream stream)
+        {
+            if (stream == null)
+                throw new ArgumentNullException("stream");
+
+            MemoryStream memstream = new MemoryStream();
+            stream.CopyTo(memstream);
+            unsafe
+            {
+                byte[] dataArr = memstream.ToArray();
+                fixed (byte* data = &dataArr[0])
+                {
+                    Interop.Evas.evas_object_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Sets the source object on an image object to used as a proxy.
+        /// </summary>
+        /// <param name="source">The proxy (image) object</param>
+        /// <returns>true if the source object is set successfully, ortherwise false on error</returns>
+        public bool SetSource(EvasObject source)
+        {
+            bool result = false;
+            _source = source;
+            result = Interop.Evas.evas_object_image_source_set(RealHandle, IntPtr.Zero);
+            if (source != null)
+                result = result && Interop.Evas.evas_object_image_source_set(RealHandle, source.Handle);
+            return result;
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetNativeSurface(IntPtr surface)
+        {
+            Interop.Evas.evas_object_image_native_surface_set(RealHandle, surface);
+        }
+
+        /// <summary>
+        /// Sets the dimensions for an image object's border, a region which is not scaled together with its center ever.
+        /// </summary>
+        /// <param name="left">The border's left width</param>
+        /// <param name="right">The border's right width</param>
+        /// <param name="top">The border's top width</param>
+        /// <param name="bottom">The border's bottom width</param>
+        public void SetBorder(int left, int right, int top, int bottom)
+        {
+            Interop.Evas.evas_object_image_border_set(RealHandle, left, right, top, bottom);
+        }
+
+        /// <summary>
+        /// Sets the content at a part of a given container widget.
+        /// </summary>
+        /// <param name="parent">The parent is a given container which will be attached by Image as a child. It's <see cref="EvasObject"/> type.</param>
+        /// <returns>The new object, otherwise null if it cannot be created</returns>
+        protected override IntPtr CreateHandle(EvasObject parent)
+        {
+            return _handle != IntPtr.Zero ? _handle : Interop.Evas.evas_object_image_add(Interop.Evas.evas_object_evas_get(parent.Handle));
+        }
+    }
+}
index 743cb42..5420e44 100644 (file)
@@ -33,6 +33,8 @@ namespace ElmSharp
         SmartEvent _clicked;
         Color _color = Color.Default;
 
+        EvasImage _imageObject = null;
+
         /// <summary>
         /// Creates and initializes a new instance of Image class.
         /// </summary>
@@ -255,19 +257,17 @@ namespace ElmSharp
         {
             get
             {
-                IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
-                if (evasObj != IntPtr.Zero)
+                if (ImageObject != null)
                 {
-                    return !Interop.Evas.evas_object_image_alpha_get(evasObj);
+                    return ImageObject.IsOpaque;
                 }
                 return false;
             }
             set
             {
-                IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
-                if (evasObj != IntPtr.Zero)
+                if (ImageObject != null)
                 {
-                    Interop.Evas.evas_object_image_alpha_set(evasObj, !value);
+                    ImageObject.IsOpaque = value;
                 }
             }
         }
@@ -298,18 +298,15 @@ namespace ElmSharp
             }
             set
             {
-                IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
-                if (evasObj != IntPtr.Zero)
+                if (ImageObject != null)
                 {
                     if (value.IsDefault)
                     {
-                        // Currently, we assume the Image.Color property as a blending color (actually, multiply blending).
-                        // Thus we are using Color.White (255,255,255,255) as a default color to ensure original image color. (255/255 * original = original)
-                        Interop.Evas.evas_object_color_set(evasObj, 255, 255, 255, 255);
+                        ImageObject.Color = Color.FromRgba(255, 255, 255, 255);
                     }
                     else
                     {
-                        Interop.Evas.SetPremultipliedColor(evasObj, value.R, value.G, value.B, value.A);
+                        ImageObject.Color = value;
                     }
                 }
                 _color = value;
@@ -335,6 +332,20 @@ namespace ElmSharp
             }
         }
 
+        public EvasImage ImageObject
+        {
+            get
+            {
+                if (_imageObject == null)
+                {
+                    IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
+                    if (evasObj != IntPtr.Zero)
+                        _imageObject = new EvasImage(this, evasObj);
+                }
+                return _imageObject;
+            }
+        }
+
         /// <summary>
         /// Sets the dimensions for an image object's border, a region which is not scaled together with its center ever.
         /// </summary>
@@ -344,8 +355,7 @@ namespace ElmSharp
         /// <param name="bottom">The border's bottom width</param>
         public void SetBorder(int left, int right, int top, int bottom)
         {
-            IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
-            Interop.Evas.evas_object_image_border_set(evasObj, left, right, top, bottom);
+            ImageObject?.SetBorder(left, right, top, bottom);
         }
 
         /// <summary>
@@ -360,13 +370,22 @@ namespace ElmSharp
         {
             get
             {
-                IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
-                return (ImageBorderFillMode)Interop.Evas.evas_object_image_border_center_fill_get(evasObj);
+                if (ImageObject != null)
+                {
+                    return ImageObject.BorderCenterFillMode;
+                }
+                else
+                {
+                    return default(ImageBorderFillMode);
+                }
+
             }
             set
             {
-                IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
-                Interop.Evas.evas_object_image_border_center_fill_set(evasObj, (int)value);
+                if (ImageObject != null)
+                {
+                    ImageObject.BorderCenterFillMode = value;
+                }
             }
         }
 
index c18cbdd..815afff 100644 (file)
@@ -21,34 +21,127 @@ internal static partial class Interop
 {
     internal static partial class Evas
     {
+
+        [DllImport(Libraries.Evas)]
+        internal static extern IntPtr evas_object_image_add(IntPtr obj);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern IntPtr evas_object_image_filled_add(IntPtr obj);
+
+        [DllImport(Libraries.Evas)]
+        internal unsafe static extern void evas_object_image_memfile_set(IntPtr obj, byte* img, long size, IntPtr format, IntPtr key);
+
         [DllImport(Libraries.Evas)]
         internal static extern void evas_object_image_file_set(IntPtr obj, string file, string key);
 
+        [DllImport(Libraries.Evas, EntryPoint = "_evas_object_image_file_get")]
+        internal static extern void _evas_object_image_file_get(IntPtr obj, out IntPtr file, out IntPtr key);
+
+        internal static void evas_object_image_file_get(IntPtr obj, out string file, out string key)
+        {
+            IntPtr outFile, outKey;
+            _evas_object_image_file_get(obj, out outFile, out outKey);
+            file = Marshal.PtrToStringAnsi(outFile);
+            key = Marshal.PtrToStringAnsi(outKey);
+        }
+
         [DllImport(Libraries.Evas)]
         internal static extern void evas_object_image_border_set(IntPtr obj, int l, int r, int t, int b);
 
         [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_border_get(IntPtr obj, out int l, out int r, out int t, out int b);
+
+        [DllImport(Libraries.Evas)]
         internal static extern int evas_object_image_border_center_fill_get(IntPtr obj);
 
         [DllImport(Libraries.Evas)]
         internal static extern void evas_object_image_border_center_fill_set(IntPtr obj, int filled);
 
         [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_filled_set(IntPtr obj, bool setting);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern bool evas_object_image_filled_get(IntPtr obj);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_border_scale_set(IntPtr obj, double scale);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern double evas_object_image_border_scale_get(IntPtr obj);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_size_set(IntPtr obj, int w, int h);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_size_get(IntPtr obj, IntPtr w, out int h);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_size_get(IntPtr obj, out int w, IntPtr h);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_size_get(IntPtr obj, out int w, out int h);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern int evas_object_image_stride_get(IntPtr obj);
+
+        [DllImport(Libraries.Evas)]
         internal static extern void evas_object_image_alpha_set(IntPtr obj, bool has_alpha);
 
         [DllImport(Libraries.Evas)]
         internal static extern bool evas_object_image_alpha_get(IntPtr obj);
 
         [DllImport(Libraries.Evas)]
-        internal static extern LoadError evas_object_image_load_error_get(IntPtr obj);
+        internal static extern void evas_object_image_colorspace_set(IntPtr obj, Colorspace colorSpace);
 
         [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_size_get(IntPtr obj, IntPtr x, out int y);
+        internal static extern void evas_object_image_data_copy_set(IntPtr obj, IntPtr data);
 
         [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_size_get(IntPtr obj, out int x, IntPtr y);
+        internal static extern IntPtr evas_object_image_data_get(IntPtr obj, bool forWriting);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_data_set(IntPtr obj, IntPtr data);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_data_update_add(IntPtr obj, int x, int y, int w, int h);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_fill_set(IntPtr obj, int x, int y, int w, int h);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_pixels_dirty_set(IntPtr obj, bool dirty);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_save(IntPtr obj, string file, string key, string flags);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_scale_hint_set(IntPtr obj, ImageScaleHint hint);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_smooth_scale_set(IntPtr obj, bool smoothScale);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern bool evas_object_image_smooth_scale_get(IntPtr obj);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern bool evas_object_image_source_set(IntPtr obj, IntPtr src);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_source_visible_set(IntPtr obj, bool visible);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern bool evas_object_image_source_visible_get(IntPtr obj);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_object_image_source_clip_set(IntPtr obj, bool source_clip);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern bool evas_object_image_source_clip_get(IntPtr obj);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern LoadError evas_object_image_load_error_get(IntPtr obj);
 
         [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_size_get(IntPtr obj, out int x, out int y);
+        internal static extern void evas_object_image_native_surface_set(IntPtr obj, IntPtr surface);
     }
 }
\ No newline at end of file
index cd4d0b6..af4e749 100644 (file)
@@ -211,9 +211,6 @@ internal static partial class Interop
         internal static extern IntPtr evas_object_evas_get(IntPtr obj);
 
         [DllImport(Libraries.Evas)]
-        internal static extern IntPtr evas_object_image_add(IntPtr obj);
-
-        [DllImport(Libraries.Evas)]
         internal static extern void evas_object_del(IntPtr objectPtr);
 
         [DllImport(Libraries.Evas)]
@@ -489,54 +486,6 @@ internal static partial class Interop
         internal static extern void evas_object_freeze_events_set(IntPtr obj, bool freeze);
 
         [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_colorspace_set(IntPtr obj, Colorspace colorSpace);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_data_copy_set(IntPtr obj, IntPtr data);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern IntPtr evas_object_image_data_get(IntPtr obj, bool forWriting);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_data_set(IntPtr obj, IntPtr data);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_data_update_add(IntPtr obj, int x, int y, int w, int h);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_fill_set(IntPtr obj, int x, int y, int w, int h);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern IntPtr evas_object_image_filled_add(IntPtr obj);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_filled_set(IntPtr obj, bool setting);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_memfile_set(IntPtr obj, IntPtr data, int size, string format, string key);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_pixels_dirty_set(IntPtr obj, bool dirty);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_save(IntPtr obj, string file, string key, string flags);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_scale_hint_set(IntPtr obj, ImageScaleHint hint);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_size_set(IntPtr obj, int w, int h);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_smooth_scale_set(IntPtr obj, bool smoothScale);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_source_set(IntPtr obj, IntPtr src);
-
-        [DllImport(Libraries.Evas)]
-        internal static extern void evas_object_image_source_visible_set(IntPtr obj, bool visible);
-
-        [DllImport(Libraries.Evas)]
         internal static extern void evas_object_layer_set(IntPtr obj, int layer);
 
         [DllImport(Libraries.Evas)]
diff --git a/test/ElmSharp.Test/TC/EvasImageTest1.cs b/test/ElmSharp.Test/TC/EvasImageTest1.cs
new file mode 100644 (file)
index 0000000..37a7d7c
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 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;
+using ElmSharp;
+using System.Collections.Generic;
+
+namespace ElmSharp.Test
+{
+    public class EvasImageTest1 : TestCaseBase
+    {
+        public override string TestName => "EvasImageTest1";
+        public override string TestDescription => "To test EvasImage proxy feature";
+
+        public override void Run(Window window)
+        {
+            Conformant conformant = new Conformant(window);
+            conformant.Show();
+            Box box = new Box(window);
+            conformant.SetContent(box);
+            box.Show();
+
+            Box horizentalBox = new Box(window)
+            {
+                IsHorizontal = true,
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+            };
+            horizentalBox.Show();
+
+            Button realObject1 = new Button(window) {
+                Text = "It is RealObject",
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+            };
+            realObject1.Show();
+
+            Image realObject2 = new Image(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+            };
+            realObject2.Load(Path.Combine(TestRunner.ResourceDir, "picture.png"));
+            realObject2.Show();
+
+            horizentalBox.PackEnd(realObject1);
+            horizentalBox.PackEnd(realObject2);
+
+            EvasImage proxyObject = new EvasImage(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 0.5,
+            };
+            Button toggle = new Button(window)
+            {
+                Text = "Change Source",
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 0.1,
+            };
+            toggle.Show();
+
+            EvasObject proxyedObject = realObject1;
+            toggle.Clicked += (s, e) =>
+            {
+                if (proxyedObject == realObject1)
+                {
+                    proxyedObject = realObject2;
+                }
+                else
+                {
+                    proxyedObject = realObject1;
+                }
+                proxyObject.SetSource(proxyedObject);
+            };
+
+
+            proxyObject.IsFilled = true;
+            proxyObject.SetSource(realObject1);
+            proxyObject.Show();
+
+            box.PackEnd(horizentalBox);
+            box.PackEnd(proxyObject);
+            box.PackEnd(toggle);
+        }
+    }
+}
diff --git a/test/ElmSharp.Test/TC/EvasImageTest2.cs b/test/ElmSharp.Test/TC/EvasImageTest2.cs
new file mode 100644 (file)
index 0000000..b003fa3
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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;
+using ElmSharp;
+using System.Collections.Generic;
+
+namespace ElmSharp.Test
+{
+    public class EvasImageTest2 : TestCaseBase
+    {
+        public override string TestName => "EvasImageTest2";
+        public override string TestDescription => "To test EvasImage";
+
+        public override void Run(Window window)
+        {
+            Conformant conformant = new Conformant(window);
+            conformant.Show();
+            Box box = new Box(window);
+            conformant.SetContent(box);
+            box.Show();
+
+            Image realObject2 = new Image(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+            };
+            realObject2.Load(Path.Combine(TestRunner.ResourceDir, "picture.png"));
+            realObject2.Show();
+
+            EvasImage img1 = new EvasImage(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+            };
+            img1.IsFilled = true;
+            img1.File = Path.Combine(TestRunner.ResourceDir, "picture.png");
+            img1.Show();
+
+            EvasImage img2 = new EvasImage(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+            };
+            img2.IsFilled = true;
+            img2.SetStream(new FileStream(Path.Combine(TestRunner.ResourceDir, "picture.png"), FileMode.Open, FileAccess.Read));
+            img2.Show();
+
+            EvasImage img3 = new EvasImage(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+            };
+            img3.IsFilled = true;
+            img3.SetSource(realObject2);
+            img3.Show();
+            img3.IsSourceVisible = true;
+
+            box.PackEnd(realObject2);
+            box.PackEnd(img1);
+            box.PackEnd(img2);
+            box.PackEnd(img3);
+        }
+    }
+}