-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c629355
commit 824d0df
Showing
11 changed files
with
61 additions
and
92 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
using SkiaSharp; | ||
using Xamarin.Forms; | ||
namespace CSharpMath.Forms { | ||
using SkiaSharp; | ||
[ContentProperty(nameof(Content))] | ||
public abstract class BaseButton<TView, TPainter, TContent> : ImageButton | ||
where TView : BaseView<TPainter, TContent> | ||
where TPainter : Rendering.FrontEnd.Painter<SKCanvas, TContent, SKColor>, new() | ||
where TContent : class { | ||
public BaseButton() { | ||
Aspect = Aspect.AspectFit; | ||
// Color.Default will be ugly: https://github.com/verybadcat/CSharpMath/issues/111 | ||
BackgroundColor = Color.Transparent; | ||
Source = ImageSource.FromStream(() => { | ||
if (Content is { } c) { | ||
var latex = c.Painter.LaTeX; | ||
// Appropriate positioning for non-full characters, e.g. prime, degree | ||
// Also acts as spacing between MathButtons next to each other | ||
c.Painter.LaTeX = @"{\color{#0000}|}" + latex + @"{\color{#0000}|}"; | ||
var stream = c.Painter.DrawAsStream(); | ||
c.Painter.LaTeX = latex; | ||
return stream; | ||
} | ||
return null; | ||
}); | ||
} | ||
public TView? Content { get => (TView?)GetValue(ContentProperty); set => SetValue(ContentProperty, value); } | ||
public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(TView), typeof(BaseButton<TView, TPainter, TContent>)); | ||
} | ||
public class MathButton : BaseButton<MathView, MathPainter, Atom.MathList> { } | ||
public class TextButton : BaseButton<TextView, TextPainter, Rendering.Text.TextAtom> { } | ||
} |
This file was deleted.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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