Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.2.0 Editor Update has been released! #29

Closed
Happypig375 opened this issue Jan 22, 2019 · 4 comments
Closed

0.2.0 Editor Update has been released! #29

Happypig375 opened this issue Jan 22, 2019 · 4 comments
Labels
Aspect/Editor This is related to CSharpMath.Editor. Resolution/Superceded The described announcement or pull request has been superceded. Type/Announcement

Comments

@Happypig375
Copy link
Collaborator

Happypig375 commented Jan 22, 2019

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.

@sadqiang
Copy link
Contributor

sadqiang commented Jan 26, 2019

In the animation given above, instead of showing xxxxxx... (typing x multiple times), why don't we show something like \int_a^b f(x)\, \mathrm{d}x=F(b)-F(a), for example such that we can see the practical purposes?

@Happypig375
Copy link
Collaborator Author

To show the actual code for implementing one button, small x in this case.

@charlesroddie
Copy link
Collaborator

Great work @Happypig375. For keyboard input into a Xamarin.Forms control I think the best thing is an Effect (or otherwise custom renderer) on UWP that handles focus and keyboard input. Looking into this.

@charlesroddie charlesroddie added the Aspect/Editor This is related to CSharpMath.Editor. label Oct 13, 2019
@Happypig375
Copy link
Collaborator Author

Superceded by #104

@Happypig375 Happypig375 added the Resolution/Superceded The described announcement or pull request has been superceded. label Dec 19, 2019
@Happypig375 Happypig375 unpinned this issue Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aspect/Editor This is related to CSharpMath.Editor. Resolution/Superceded The described announcement or pull request has been superceded. Type/Announcement
Projects
None yet
Development

No branches or pull requests

3 participants