Skip to content

Commit

Permalink
Example usage for #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Happypig375 committed Jan 6, 2019
1 parent 1ebba29 commit 1158d89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:skia="clr-namespace:SkiaSharp.Views.Forms;assembly=SkiaSharp.Views.Forms"
x:Class="CSharpMath.NuGetPackageTests.CSharp.MainPage">
<StackLayout>
<skia:SKCanvasView x:Name="canvas"/>
<Button x:Name="b"/>
<skia:SKCanvasView x:Name="canvas" VerticalOptions="FillAndExpand"/>
<math:MathKeyboard x:Name="b"/>
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@ namespace CSharpMath.NuGetPackageTests.CSharp
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
public MainPage() {
InitializeComponent();
global::SkiaSharp.Views.Forms.SKCanvasView canvasView = canvas;
CSharpMath.Forms.MathKeyboard keyboard = b;

var painter = new CSharpMath.SkiaSharp.MathPainter
{ /*set all properties aside from LocalTypefaces, FontSize, LineStyle,
MathList, LaTeX and Source (these are ignored)*/ };
keyboard.RedrawRequested += (sender, e) => canvasView.InvalidateSurface();
canvasView.PaintSurface += (sender, e) => {
e.Surface.Canvas.Clear();
//for any DrawDisplay overload, arguments after canvas are the same as Draw
CSharpMath.SkiaSharp.MathPainter.DrawDisplay(painter, keyboard.Display, e.Surface.Canvas);
keyboard.DrawCaret(e.Surface.Canvas, CSharpMath.Rendering.CaretShape.IBeam);
};
}
}
}

0 comments on commit 1158d89

Please sign in to comment.