Skip to content

Commit

Permalink
Add WPF ImageViewBackend
Browse files Browse the repository at this point in the history
  • Loading branch information
ermau committed Feb 28, 2012
1 parent 1587e57 commit ec25c71
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions Xwt.WPF/Xwt.WPF.csproj
Expand Up @@ -44,6 +44,7 @@
<Compile Include="Xwt.WPFBackend\ButtonBackend.cs" />
<Compile Include="Xwt.WPFBackend\ImageBackend.cs" />
<Compile Include="Xwt.WPFBackend.Interop\NativeMethods.cs" />
<Compile Include="Xwt.WPFBackend\ImageViewBackend.cs" />
<Compile Include="Xwt.WPFBackend\LabelBackend.cs" />
<Compile Include="Xwt.WPFBackend\BoxBackend.cs" />
<Compile Include="Xwt.WPFBackend\DataConverter.cs" />
Expand Down
59 changes: 59 additions & 0 deletions Xwt.WPF/Xwt.WPFBackend/ImageViewBackend.cs
@@ -0,0 +1,59 @@
//
// ImageViewBackend.cs
//
// Author:
// Eric Maupin <ermau@xamarin.com>
//
// Copyright (c) 2012 Xamarin, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using System.Windows.Controls;
using System.Windows.Media;
using Xwt.Backends;

namespace Xwt.WPFBackend
{
public class ImageViewBackend
: WidgetBackend, IImageViewBackend
{
public ImageViewBackend()
{
Widget = new Image ();
}

public void SetImage (object nativeImage)
{
if (nativeImage == null)
throw new ArgumentNullException ("nativeImage");

ImageSource source = nativeImage as ImageSource;
if (source == null)
throw new ArgumentException ("nativeImage is not of the expected type", "nativeImage");

Image.Source = source;
}

protected Image Image
{
get { return (Image) NativeWidget; }
}
}
}
1 change: 1 addition & 0 deletions Xwt.WPF/Xwt.WPFBackend/WPFEngine.cs
Expand Up @@ -52,6 +52,7 @@ public override void InitializeApplication ()
WidgetRegistry.RegisterBackend (typeof (ToggleButton), typeof (ToggleButtonBackend));
WidgetRegistry.RegisterBackend (typeof (TreeView), typeof (TreeViewBackend));
WidgetRegistry.RegisterBackend (typeof (TreeStore), typeof (TreeStoreBackend));
WidgetRegistry.RegisterBackend (typeof (ImageView), typeof (ImageViewBackend));

WidgetRegistry.RegisterBackend (typeof (Image), typeof (ImageBackend));
WidgetRegistry.RegisterBackend (typeof (Font), typeof (FontBackendHandler));
Expand Down

0 comments on commit ec25c71

Please sign in to comment.