Added the Android X.F renderer
This commit is contained in:
Родитель
7514404808
Коммит
6fb1af16e9
|
@ -0,0 +1,26 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("SkiaSharp.Views.Forms.Android")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("(c) Matthew Leibowitz")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
0
source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Android/Resources/Resource.designer.cs
сгенерированный
Normal file
0
source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.Android/Resources/Resource.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using Android.Content;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
|
||||
using SKFormsView = SkiaSharp.Views.Forms.SKView;
|
||||
using SKNativeView = SkiaSharp.Views.SKView;
|
||||
|
||||
[assembly: ExportRenderer(typeof(SKFormsView), typeof(SkiaSharp.Views.Forms.SKViewRenderer))]
|
||||
|
||||
namespace SkiaSharp.Views.Forms
|
||||
{
|
||||
internal class SKViewRenderer : ViewRenderer<SKFormsView, SKNativeView>
|
||||
{
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<SKFormsView> e)
|
||||
{
|
||||
if (e.OldElement != null)
|
||||
{
|
||||
var oldController = (ISKViewController)e.OldElement;
|
||||
|
||||
// unsubscribe from events
|
||||
oldController.SurfaceInvalidated -= OnSurfaceInvalidated;
|
||||
}
|
||||
|
||||
if (e.NewElement != null)
|
||||
{
|
||||
var newController = (ISKViewController)e.NewElement;
|
||||
|
||||
// create the native view
|
||||
var view = new InternalView(Context, newController);
|
||||
SetNativeControl(view);
|
||||
|
||||
// subscribe to events from the user
|
||||
newController.SurfaceInvalidated += OnSurfaceInvalidated;
|
||||
|
||||
// paint for the first time
|
||||
Control.Invalidate();
|
||||
}
|
||||
|
||||
base.OnElementChanged(e);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
// detach all events before disposing
|
||||
var controller = (ISKViewController)Element;
|
||||
if (controller != null)
|
||||
{
|
||||
controller.SurfaceInvalidated -= OnSurfaceInvalidated;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void OnSurfaceInvalidated(object sender, EventArgs eventArgs)
|
||||
{
|
||||
// repaint the native control
|
||||
Control.Invalidate();
|
||||
}
|
||||
|
||||
private class InternalView : SKNativeView
|
||||
{
|
||||
private readonly ISKViewController controller;
|
||||
|
||||
public InternalView(Context context, ISKViewController controller)
|
||||
: base(context)
|
||||
{
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
protected override void OnDraw(SKSurface surface, SKImageInfo info)
|
||||
{
|
||||
base.OnDraw(surface, info);
|
||||
|
||||
// the control is being repainted, let the user know
|
||||
controller.OnPaintSurface(new SKPaintSurfaceEventArgs(surface, info));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{2F94F024-1841-47E8-B521-74AA4E3EBA54}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>SkiaSharp.Views.Forms</RootNamespace>
|
||||
<AssemblyName>SkiaSharp.Views.Forms</AssemblyName>
|
||||
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
|
||||
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
<AndroidSupportedAbis>arm64-v8a;armeabi;armeabi-v7a;x86</AndroidSupportedAbis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AndroidManagedSymbols>true</AndroidManagedSymbols>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="SkiaSharp">
|
||||
<HintPath>..\packages\SkiaSharp.1.54.0.1\lib\MonoAndroid\SkiaSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SkiaSharp.Views.Android">
|
||||
<HintPath>..\packages\SkiaSharp.Views.1.54.0.1-beta1\lib\MonoAndroid\SkiaSharp.Views.Android.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.Support.v4">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.v4.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.Support.v7.CardView">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.v7.CardView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.CardView.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.Support.v7.RecyclerView">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.v7.RecyclerView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.RecyclerView.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.Support.Vector.Drawable">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Vector.Drawable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.Support.Animated.Vector.Drawable">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Animated.Vector.Drawable.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.Support.v7.AppCompat">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.AppCompat.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.Support.Design">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.Design.23.3.0\lib\MonoAndroid43\Xamarin.Android.Support.Design.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.Support.v7.MediaRouter">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.v7.MediaRouter.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.MediaRouter.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FormsViewGroup">
|
||||
<HintPath>..\packages\Xamarin.Forms.2.3.0.49\lib\MonoAndroid10\FormsViewGroup.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Forms.Core">
|
||||
<HintPath>..\packages\Xamarin.Forms.2.3.0.49\lib\MonoAndroid10\Xamarin.Forms.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Forms.Platform.Android">
|
||||
<HintPath>..\packages\Xamarin.Forms.2.3.0.49\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Forms.Platform">
|
||||
<HintPath>..\packages\Xamarin.Forms.2.3.0.49\lib\MonoAndroid10\Xamarin.Forms.Platform.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Forms.Xaml">
|
||||
<HintPath>..\packages\Xamarin.Forms.2.3.0.49\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Resources\Resource.designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SKViewRenderer.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\SkiaSharp.Views.Forms.Shared\SkiaSharp.Views.Forms.Shared.projitems" Label="Shared" Condition="Exists('..\SkiaSharp.Views.Forms.Shared\SkiaSharp.Views.Forms.Shared.projitems')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
<Import Project="..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets" Condition="Exists('..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\build\Xamarin.Android.Support.Vector.Drawable.targets')" />
|
||||
<Import Project="..\packages\Xamarin.Forms.2.3.0.49\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.3.0.49\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
|
||||
</Project>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="SkiaSharp" version="1.54.0.1" targetFramework="monoandroid60" />
|
||||
<package id="SkiaSharp.Views" version="1.54.0.1-beta1" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
|
||||
<package id="Xamarin.Forms" version="2.3.0.49" targetFramework="monoandroid60" />
|
||||
</packages>
|
|
@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.Views.Forms.iOS",
|
|||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SkiaSharp.Views.Forms.Shared", "SkiaSharp.Views.Forms.Shared\SkiaSharp.Views.Forms.Shared.shproj", "{794B3FB8-5BCF-42FB-9D18-6BA595187B94}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.Views.Forms.Android", "SkiaSharp.Views.Forms.Android\SkiaSharp.Views.Forms.Android.csproj", "{2F94F024-1841-47E8-B521-74AA4E3EBA54}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -21,5 +23,9 @@ Global
|
|||
{4AC36D63-BF11-445F-81EE-107C0CEF4FC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4AC36D63-BF11-445F-81EE-107C0CEF4FC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4AC36D63-BF11-445F-81EE-107C0CEF4FC9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2F94F024-1841-47E8-B521-74AA4E3EBA54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2F94F024-1841-47E8-B521-74AA4E3EBA54}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2F94F024-1841-47E8-B521-74AA4E3EBA54}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2F94F024-1841-47E8-B521-74AA4E3EBA54}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
Загрузка…
Ссылка в новой задаче