Skip to content

0.2.0 Editor Update has been released! #29

@Happypig375

Description

@Happypig375

0.2.0 Editor Update - the final minor update of CSharpMath before becoming MathDisplay.NET (Edit by the time of 0.3.0 release: Not yet... I'll do it when I have time.).

Features

  • A math editor! There are two ways to use it, below are CSharpMath.Forms examples:
  1. Having a custom keyboard:
//from XAML
SkiaSharp.Views.Forms.SKCanvasView canvasView = ...;
Xamarin.Forms.Button button = ...;

var painter = new CSharpMath.SkiaSharp.MathPainter
{ /*set all properties aside from LocalTypefaces, FontSize, LineStyle,
    MathList, LaTeX and Source (these are ignored)*/ };
var keyboard = new CSharpMath.Rendering.MathKeyboard(/*optional fontSize*/)
{ /*set Fonts, LineStyle and InsertionIndex here*/ };
button.Pressed += (sender, e) => keyboard.KeyPress(CSharpMath.Editor.MathKeyboardInput.SmallX /*or any key*/);
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(
    new CSharpMath.SkiaSharp.SkiaCanvas(e.Surface.Canvas, SkiaSharp.SKStrokeCap.Butt, false),
    CSharpMath.Rendering.CaretShape.IBeam);
};

screen
2. Using the default keyboard:

//from XAML
SkiaSharp.Views.Forms.SKCanvasView canvasView = ...;
CSharpMath.Forms.MathKeyboard keyboard = ...;

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);
};

screen

Why did it take so long?

October was the month when most of the logic were ported successfully. However, with limited understanding of .xib files which are Xcode UI definitions, I tried to literally port the XML contents to C#, but resulted in messy code. There went November.
A port of the keyboard UI code to XAML costed a December's worth of time.
Not much happened here in January, mostly waiting for potential bug reports.
Welp, that was time badly spent. I'm sorry for that.

Current plans

  • .Net LaTeX projects #4 Merge with wpf-math
    • F# instead of C# (just as interoperable but much more maintainable)
    • Refactor TextAtoms and MathAtoms to have common atoms
    • Refactor MathAtoms to get rid of MathAtomType and AtomCloner
    • Unit tests (and picture comparisons)
    • Tavis CI integration
    • An intuitive README for getting started
    • Documentation on both NuGet and GitHub wiki
    • Document release procedure
    • Promote awareness!!
    • Native platform support for the popular ones
  • Implement \middle
  • Optimize loading times of the Android example project

A new start

The merge with wpf-math is happening in this repository. Please watch the repository for future updates!

Supersedes #21.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions