From c3b6e29c8708bdca4e971b3e1fad456e8bb7828d Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 22 Nov 2016 15:25:56 +0100 Subject: [PATCH] Fixes the image button rendering --- .../BookAStar.Droid/BookAStar.Droid.csproj | 1 + .../Rendering/ImageButtonRenderer.cs | 256 ++++++++++++++++++ BookAStar/BookAStar/BookAStar.csproj | 1 + BookAStar/BookAStar/Helpers/UserHelpers.cs | 1 - .../Pages/UserProfile/UserProfilePage.xaml | 23 +- .../Pages/UserProfile/UserProfilePage.xaml.cs | 3 +- BookAStar/BookAStar/Views/ImageButton.cs | 157 +++++++++++ 7 files changed, 433 insertions(+), 9 deletions(-) create mode 100644 BookAStar/BookAStar.Droid/Rendering/ImageButtonRenderer.cs create mode 100644 BookAStar/BookAStar/Views/ImageButton.cs diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj index 7c1f681d..07016d17 100644 --- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj +++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj @@ -343,6 +343,7 @@ + diff --git a/BookAStar/BookAStar.Droid/Rendering/ImageButtonRenderer.cs b/BookAStar/BookAStar.Droid/Rendering/ImageButtonRenderer.cs new file mode 100644 index 00000000..9a568c9b --- /dev/null +++ b/BookAStar/BookAStar.Droid/Rendering/ImageButtonRenderer.cs @@ -0,0 +1,256 @@ +// *********************************************************************** +// Assembly : XLabs.Forms.Droid +// Author : XLabs Team +// Created : 12-27-2015 +// +// Last Modified By : XLabs Team +// Last Modified On : 01-04-2016 +// *********************************************************************** +// +// Copyright (c) XLabs Team. All rights reserved. +// +// +// This project is licensed under the Apache 2.0 license +// https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/LICENSE +// +// XLabs is a open source project that aims to provide a powerfull and cross +// platform set of controls tailored to work with Xamarin Forms. +// +// *********************************************************************** +// + +using System; +using System.ComponentModel; +using System.Threading.Tasks; +using Android.Graphics; +using Android.Graphics.Drawables; +using Android.Views; +using XLabs.Enums; +using XLabs.Forms.Extensions; +using Color = Xamarin.Forms.Color; +using View = Android.Views.View; +using BookAStar.Rendering; +using BookAStar.Views; +using Xamarin.Forms.Platform.Android.AppCompat; +using Xamarin.Forms; +using Xamarin.Forms.Platform.Android; +using System.IO; +using BookAStar.Helpers; +using System.Reflection; +using System.Threading; + +[assembly: ExportRenderer(typeof(ImageButton), typeof(ImageButtonRenderer))] +namespace BookAStar.Rendering +{ + /// + /// Draws a button on the Android platform with the image shown in the right + /// position with the right size. + /// + public partial class ImageButtonRenderer : Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer + { + private static float _density = float.MinValue; + + + /// + /// Sets up the button including the image. + /// + /// The event arguments. + private ImageButton ImageButton + { + get { return (ImageButton)Element; } + } + + protected override async void OnElementChanged(ElementChangedEventArgs