Skip to content

Commit

Permalink
Verify #59
Browse files Browse the repository at this point in the history
  • Loading branch information
Happypig375 committed Sep 13, 2019
1 parent d950444 commit ff02d0e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 36 deletions.
3 changes: 0 additions & 3 deletions CSharpMath.Forms.Example/CSharpMath.Forms.Example/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
xmlns:math="clr-namespace:CSharpMath.Forms;assembly=CSharpMath.Forms"
android:TabbedPage.IsSwipePagingEnabled="False"
ChildAdded="Handle_ChildAdded">
<!--<ContentPage x:Name="ContentPage">
<math:MathView LaTeX="{Binding .LaTeX}"/>
</ContentPage>-->
<local:IconPage/>
<local:ExamplePage/>
<local:ExamplesPage/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
x:Class="CSharpMath.Forms.Example.CustomExamplePage"
Title="Try">
<StackLayout>
<StackLayout Orientation="Horizontal" BackgroundColor="LightGray">
<Entry x:Name="Entry" HorizontalOptions="FillAndExpand"/>
<Picker x:Name="Size" HorizontalOptions="Fill" ItemsSource="{x:Static local:CustomExamplePage.FontSizes}"/>
</StackLayout>
<Entry x:Name="Entry" HorizontalOptions="FillAndExpand"/>
<Label x:Name="Exit" HorizontalOptions="FillAndExpand"/>
<Picker x:Name="Size" HorizontalOptions="Fill" ItemsSource="{x:Static local:CustomExamplePage.FontSizes}"/>
<math:MathView x:Name="View" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" EnableTouchEvents="True"/>
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,23 @@ namespace CSharpMath.Forms.Example
[XamlCompilation(XamlCompilationOptions.Compile), Android.Runtime.Preserve(AllMembers = true), Foundation.Preserve(AllMembers = true)]
public partial class CustomExamplePage : ContentPage
{
public static float[] FontSizes = new float[] { 1, 2, 4, 8, 12, 16, 24, 36, 48, 60, 72, 96, 108, 144, 192, 288, 384, 480, 576, 666 /*(insert trollface here)*/, 768, 864, 960 };
Dictionary<string, string> dict = ExamplesPage.AllConstants.ToDictionary(info => info.Name, info => (string)info.GetRawConstantValue());
public static float[] FontSizes = new float[] { 1, 2, 4, 8, 12, 16, 20, 24, 30, 36, 48, 60, 72, 96, 108, 144, 192, 288, 384, 480, 576, 666 /*(insert trollface here)*/, 768, 864, 960 };
public CustomExamplePage() {
InitializeComponent();
App.AllViews.Add(View);
Size.SelectedItem = View.FontSize;
Size.SelectedIndexChanged += (sender, e) => {
View.FontSize = (float)Size.SelectedItem;
View.InvalidateSurface();
};
Entry.TextChanged += (sender, e) => { View.LaTeX = Entry.Text; View.InvalidateSurface(); };
Entry.TextChanged += (sender, e) => {
View.LaTeX = Entry.Text;
(Exit.Text, Exit.TextColor) =
View.MathList is Interfaces.IMathList ml ?
(Atoms.MathListBuilder.MathListToString(ml), Color.Black) :
("Error: " + View.ErrorMessage, Color.Red);
View.InvalidateSurface();
};
}
protected override void OnDisappearing() {
//App.AllViews.Remove(View);
Expand Down
14 changes: 5 additions & 9 deletions CSharpMath.Forms.Example/CSharpMath.Forms.Example/TextPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
xmlns:text="clr-namespace:CSharpMath.Forms;assembly=CSharpMath.Forms"
xmlns:local="clr-namespace:CSharpMath.Forms.Example"
Title="Text">
<ContentPage.Content>
<StackLayout x:Name="outerStack" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<StackLayout x:Name="innerStack" Orientation="Horizontal" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Editor x:Name="Text" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" TextChanged="Text_TextChanged" />
<Picker x:Name="Size" HorizontalOptions="Fill" VerticalOptions="Fill" ItemsSource="{x:Static local:CustomExamplePage.FontSizes}" SelectedIndexChanged="Size_SelectedIndexChanged"/>
</StackLayout>
<text:TextView x:Name="View" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" EnableTouchEvents="true"/>
</StackLayout>
</ContentPage.Content>
<StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Editor x:Name="Text" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" TextChanged="Text_TextChanged" />
<Picker x:Name="Size" HorizontalOptions="Fill" ItemsSource="{x:Static local:CustomExamplePage.FontSizes}" SelectedIndexChanged="Size_SelectedIndexChanged"/>
<text:TextView x:Name="View" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" EnableTouchEvents="true"/>
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,7 @@ public TextPage() {
InitializeComponent();
//Text.Text = @"Here are some text. This text is made to be long enough to have the TextPainter of CSharpMath (hopefully) add a line break to this text automatically. To demonstrate the capabilities of the TextPainter, here are some math content: First, a fraction in inline mode: $\frac34$ Next, a summation in inline mode: $\sum_{i=0}^3i^i$ Then, a summation in display mode: $$\sum_{i=0}^3i^i$$ (ah, bugs.) After that, an integral in display mode: $$\int^6_{-56}x\ dx$$ Finally, an escaped dollar sign \$ that represents the start/end of math mode when it is unescaped. Even though colours are currently unsupported, it can be done via math mode with the \\color command with the help of the \\text command. It looks like this: $\color{#F00}{\text{some red text}}$, which is nearly indistinguishable from non-math mode aside from not being able to automatically break up when spaces are inside the coloured text. The SkiaSharp version of this is located at CSharpMath.SkiaSharp.TextPainter; and the Xamarin.Forms version of this is located at CSharpMath.Forms.TextView. Was added in 0.1.0-pre4; working in 0.1.0-pre5.";
//However, it is also not yet complete as in not being able to SeparateThisReallyLongWordWhichIsSoLongThatItSpansAcrossTheEntirePageAndWontStopEvenWhenPartOfItIsOutOfBounds.
}

private double width = 0;
private double height = 0;
protected override void OnSizeAllocated(double width, double height) {
base.OnSizeAllocated(width, height);
if (width != this.width || height != this.height) {
this.width = width;
this.height = height;
if (width > height) {
outerStack.Orientation = StackOrientation.Horizontal;
innerStack.Orientation = StackOrientation.Vertical;
} else {
outerStack.Orientation = StackOrientation.Vertical;
innerStack.Orientation = StackOrientation.Horizontal;
}
}
Size.SelectedItem = View.FontSize;
}

private void Size_SelectedIndexChanged(object sender, EventArgs e) {
Expand Down

0 comments on commit ff02d0e

Please sign in to comment.