-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the y-coordinate to start top-left, not bottom-left
- Loading branch information
1 parent
dda5558
commit 949a2e4
Showing
11 changed files
with
127 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
CSharpMath.Forms.Example/CSharpMath.Forms.Example/SlidePage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:skia="clr-namespace:SkiaSharp.Views.Forms;assembly=SkiaSharp.Views.Forms" | ||
x:Class="CSharpMath.Forms.Example.SlidePage" | ||
Title="Slide"> | ||
<ContentPage.Content> | ||
<StackLayout> | ||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="{x:Binding Value, Source={x:Reference SliderX}}"/> | ||
<Slider x:Name="SliderX" HorizontalOptions="FillAndExpand" Minimum="-2" Maximum="{Binding Width, Source={x:Reference Canvas}}" ValueChanged="SliderX_ValueChanged"/> | ||
</StackLayout> | ||
<StackLayout Orientation="Horizontal"> | ||
<Label Text="{x:Binding Value, Source={x:Reference SliderY}}"/> | ||
<Slider x:Name="SliderY" HorizontalOptions="FillAndExpand" Minimum="-2" Maximum="{Binding Height, Source={x:Reference Canvas}}" ValueChanged="SliderY_ValueChanged"/> | ||
</StackLayout> | ||
<skia:SKCanvasView x:Name="Canvas" HorizontalOptions="Fill" VerticalOptions="FillAndExpand" EnableTouchEvents="True" PaintSurface="Canvas_PaintSurface" Touch="Canvas_Touch"/> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
</ContentPage> |
37 changes: 37 additions & 0 deletions
37
CSharpMath.Forms.Example/CSharpMath.Forms.Example/SlidePage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using Xamarin.Forms; | ||
using Xamarin.Forms.Xaml; | ||
|
||
using SkiaSharp.Views.Forms; | ||
|
||
namespace CSharpMath.Forms.Example | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class SlidePage : ContentPage { | ||
SkiaSharp.SkiaMathPainter painter = new SkiaSharp.SkiaMathPainter { LaTeX = @"\text{Press to clear}" }; | ||
bool reset; | ||
double x, y; | ||
|
||
public SlidePage() => InitializeComponent(); | ||
|
||
private void Canvas_PaintSurface(object sender, SKPaintSurfaceEventArgs e) { | ||
if (reset) { e.Surface.Canvas.Clear(); reset = false; } | ||
e.Surface.Canvas.DrawCircle(0f, 0f, 100f, new global::SkiaSharp.SKPaint { Color = new global::SkiaSharp.SKColor(255, 0, 0) }); | ||
painter.Draw(e.Surface.Canvas, (float)x, (float)y); | ||
e.Surface.Canvas.DrawCircle(300f, 0f, 100f, new global::SkiaSharp.SKPaint { Color = new global::SkiaSharp.SKColor(255, 255, 0) }); | ||
} | ||
|
||
private void Canvas_Touch(object sender, SKTouchEventArgs e) { | ||
if(e.InContact && e.ActionType == SKTouchAction.Pressed) { reset = true; Canvas.InvalidateSurface(); e.Handled = true; } | ||
} | ||
|
||
private void SliderX_ValueChanged(object sender, ValueChangedEventArgs e) { x = e.NewValue; Canvas.InvalidateSurface(); } | ||
|
||
private void SliderY_ValueChanged(object sender, ValueChangedEventArgs e) { y = e.NewValue; Canvas.InvalidateSurface(); } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
<HasSharedItems>true</HasSharedItems> | ||
<SharedGUID>4ab068f2-6f09-4b3b-8a81-f89f10cdce18</SharedGUID> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<Import_RootNamespace>CSharpMath._Extensions</Import_RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>4ab068f2-6f09-4b3b-8a81-f89f10cdce18</ProjectGuid> | ||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" /> | ||
<PropertyGroup /> | ||
<Import Project="CSharpMath._Extensions.projitems" Label="Shared" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters