1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 06:26:02 +00:00

Ajout de SkiaSharp

This commit is contained in:
Yan Maniez 2018-04-29 20:55:20 +02:00
parent 411411271a
commit ca7b4247bb
6 changed files with 111 additions and 31 deletions

View file

@ -50,6 +50,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp.Views.Forms">
<Version>1.60.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="2.5.1.444934" />
<PackageReference Include="Xamarin.Android.Support.Design" Version="25.4.0.2" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="25.4.0.2" />

View file

@ -165,6 +165,9 @@
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp.Views.Forms">
<Version>1.60.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="2.5.1.444934" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.2" />
</ItemGroup>

View file

@ -122,6 +122,9 @@
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp.Views.Forms">
<Version>1.60.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms" Version="2.5.1.444934" />
</ItemGroup>
<ItemGroup>

View file

@ -9,6 +9,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp.Views.Forms" Version="1.60.0" />
<PackageReference Include="Xamarin.Forms" Version="2.5.1.444934" />
</ItemGroup>

View file

@ -2,6 +2,7 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:tools="clr-namespace:AideDeJeu.Tools"
xmlns:skia="clr-namespace:SkiaSharp.Views.Forms;assembly=SkiaSharp.Views.Forms"
x:Class="AideDeJeu.Views.MonsterDetailPage"
Title="{Binding Title}">
<ContentPage.Resources>
@ -9,50 +10,55 @@
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView Orientation="Vertical">
<ScrollView Orientation="Vertical" BackgroundColor="#fdf1dc">
<StackLayout Orientation="Vertical" Padding="15">
<skia:SKCanvasView PaintSurface="PaintHeaderBar" HorizontalOptions="FillAndExpand" HeightRequest="8" />
<Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsubsection}" />
<Label Text=" " />
<Label FormattedText="{Binding TypeSizeAlignment}" />
<BoxView WidthRequest="100" HeightRequest="2" Color="Red" />
<skia:SKCanvasView PaintSurface="PaintRedBar" HorizontalOptions="FillAndExpand" HeightRequest="8"/>
<!--<BoxView WidthRequest="100" HeightRequest="2" Color="#922610" />-->
<Label FormattedText="{Binding ArmorClass}" Style="{StaticResource Key=content}" />
<Label FormattedText="{Binding HitPoints}" Style="{StaticResource Key=content}" />
<Label FormattedText="{Binding Speed}" Style="{StaticResource Key=content}" />
<BoxView WidthRequest="100" HeightRequest="2" Color="Red" />
<skia:SKCanvasView PaintSurface="PaintRedBar" HorizontalOptions="FillAndExpand" HeightRequest="8"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Text="FOR" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="0" Text="{Binding Item.Strength}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="1" Text="DEX" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Item.Dexterity}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="2" Text="CON" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="2" Text="{Binding Item.Constitution}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="3" Text="INT" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="3" Text="{Binding Item.Intelligence}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="4" Text="SAG" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="4" Text="{Binding Item.Wisdom}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="5" Text="CHA" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="5" Text="{Binding Item.Charisma}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="0" Text="FOR" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="0" Text="{Binding Item.Strength}" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="1" Text="DEX" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Item.Dexterity}" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="2" Text="CON" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="2" Text="{Binding Item.Constitution}" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="3" Text="INT" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="3" Text="{Binding Item.Intelligence}" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="4" Text="SAG" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="4" Text="{Binding Item.Wisdom}" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="5" Text="CHA" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="5" Text="{Binding Item.Charisma}" HorizontalTextAlignment="Center" Style="{StaticResource Key=content}" />
</Grid>
<BoxView WidthRequest="100" HeightRequest="2" Color="Red" />
<skia:SKCanvasView PaintSurface="PaintRedBar" HorizontalOptions="FillAndExpand" HeightRequest="8"/>
<Label FormattedText="{Binding SavingThrows}" IsVisible="{Binding Item.SavingThrows, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
<Label FormattedText="{Binding Skills}" IsVisible="{Binding Item.Skills, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
@ -60,13 +66,16 @@
<Label FormattedText="{Binding Languages}" IsVisible="{Binding Item.Languages, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
<!--<Label FormattedText="{Binding Power}" Style="{StaticResource Key=content}" />-->
<Label FormattedText="{Binding Challenge}" IsVisible="{Binding Item.Challenge, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
<BoxView WidthRequest="100" HeightRequest="2" Color="Red" />
<skia:SKCanvasView PaintSurface="PaintRedBar" HorizontalOptions="FillAndExpand" HeightRequest="8"/>
<Label Text="{Binding Item.Description}" Style="{StaticResource Key=content}" />
<Label Text="{Binding Item.Picture}" Style="{StaticResource Key=content}" />
<Label Text="{Binding Item.Legendary}" Style="{StaticResource Key=content}" />
<Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />
<skia:SKCanvasView PaintSurface="PaintHeaderBar" HorizontalOptions="FillAndExpand" HeightRequest="8" />
</StackLayout>
</ScrollView>
</ContentPage>

View file

@ -1,6 +1,9 @@

using AideDeJeu.ViewModels;
using AideDeJeuLib.Monsters;
using SkiaSharp;
using SkiaSharp.Views.Forms;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
@ -31,5 +34,63 @@ namespace AideDeJeu.Views
viewModel = new MonsterDetailViewModel(item);
BindingContext = viewModel;
}
void PaintHeaderBar(object sender, SKPaintSurfaceEventArgs args)
{
SKImageInfo info = args.Info;
SKSurface surface = args.Surface;
SKCanvas canvas = surface.Canvas;
canvas.Clear();
SKPath path = new SKPath
{
FillType = SKPathFillType.EvenOdd
};
path.AddRect(new SKRect(0, 0, info.Width, 8));
SKPaint paint = new SKPaint()
{
Style = SKPaintStyle.Fill,
Color = new SKColor(0xFFE69A28)
};
canvas.DrawPath(path, paint);
paint.Style = SKPaintStyle.Stroke;
paint.StrokeWidth = 2;
paint.Color = SKColors.Black;
canvas.DrawPath(path, paint);
}
void PaintRedBar(object sender, SKPaintSurfaceEventArgs args)
{
SKImageInfo info = args.Info;
SKSurface surface = args.Surface;
SKCanvas canvas = surface.Canvas;
canvas.Clear();
SKPath path = new SKPath
{
FillType = SKPathFillType.EvenOdd
};
path.AddPoly(new SKPoint[] { new SKPoint(0,0), new SKPoint(info.Width, 8), new SKPoint(0, 8) });
SKPaint paint = new SKPaint()
{
Style = SKPaintStyle.Fill,
Color = new SKColor(0xFF922610)
};
canvas.DrawPath(path, paint);
//paint.Style = SKPaintStyle.Stroke;
//paint.StrokeWidth = 2;
//paint.Color = SKColors.Black;
//canvas.DrawPath(path, paint);
}
}
}