-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy the modified Avalonia projects to their own directories (#17)
- Loading branch information
Showing
117 changed files
with
10,222 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Application xmlns="https://github.com/avaloniaui"> | ||
<Application.Styles> | ||
<StyleInclude Source="resm:Avalonia.Themes.Default.DefaultTheme.xaml?assembly=Avalonia.Themes.Default"/> | ||
<StyleInclude Source="resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"/> | ||
|
||
<Style Selector="TextBlock.h1"> | ||
<Setter Property="Foreground" Value="#212121"/> | ||
<Setter Property="FontSize" Value="20"/> | ||
<Setter Property="FontWeight" Value="Medium"/> | ||
</Style> | ||
|
||
<Style Selector="TextBlock.h2"> | ||
<Setter Property="Foreground" Value="#727272"/> | ||
<Setter Property="FontSize" Value="13"/> | ||
</Style> | ||
|
||
</Application.Styles> | ||
</Application> |
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 @@ | ||
using Avalonia; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace AvaloniaMath.Example | ||
{ | ||
public class App : Application | ||
{ | ||
public override void Initialize() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} | ||
} |
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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<ApplicationIcon /> | ||
<OutputType>Exe</OutputType> | ||
<StartupObject /> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Update="**\*.xaml.cs"> | ||
<DependentUpon>%(Filename)</DependentUpon> | ||
<SubType>Code</SubType> | ||
</Compile> | ||
<EmbeddedResource Include="**\*.xaml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\AvaloniaMath\AvaloniaMath.csproj" /> | ||
</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,6 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:pages="clr-namespace:ControlCatalog.Pages;assembly=Example" | ||
xmlns:controls="clr-namespace:AvaloniaMath.Controls;assembly=AvaloniaMath" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<controls:FormulaControl Formula="\int" /> | ||
</UserControl> |
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,18 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace AvaloniaMath.Example | ||
{ | ||
public class MainView : UserControl | ||
{ | ||
public MainView() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} | ||
} |
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,6 @@ | ||
<Window xmlns="https://github.com/avaloniaui" | ||
xmlns:example="clr-namespace:AvaloniaMath.Example" | ||
MinWidth="500" MinHeight="300" | ||
Title="Avalonia Math Example"> | ||
<example:MainView /> | ||
</Window> |
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,25 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace AvaloniaMath.Example | ||
{ | ||
public class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
this.InitializeComponent(); | ||
this.AttachDevTools(); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
// TODO: iOS does not support dynamically loading assemblies | ||
// so we must refer to this resource DLL statically. For | ||
// now I am doing that here. But we need a better solution!! | ||
var theme = new Avalonia.Themes.Default.DefaultTheme(); | ||
theme.FindResource("Button"); | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} | ||
} |
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,15 @@ | ||
using Avalonia; | ||
|
||
namespace AvaloniaMath.Example | ||
{ | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
AppBuilder.Configure<App>() | ||
.UsePlatformDetect() | ||
.Start<MainWindow>(); | ||
|
||
} | ||
} | ||
} |
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,3 @@ | ||
<?xml version="1.0"?> | ||
<configuration> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration> |
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,111 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace WpfMath | ||
{ | ||
// Atom representing base atom with accent above it. | ||
internal class AccentedAtom : Atom | ||
{ | ||
public AccentedAtom(Atom baseAtom, string accentName) | ||
{ | ||
this.BaseAtom = baseAtom; | ||
this.AccentAtom = SymbolAtom.GetAtom(accentName); | ||
|
||
if (this.AccentAtom.Type != TexAtomType.Accent) | ||
throw new ArgumentException("The specified symbol name is not an accent.", "accent"); | ||
} | ||
|
||
public AccentedAtom(Atom baseAtom, TexFormula accent) | ||
{ | ||
var rootSymbol = accent.RootAtom as SymbolAtom; | ||
if (rootSymbol == null) | ||
throw new ArgumentException("The formula for the accent is not a single symbol.", "accent"); | ||
this.AccentAtom = (SymbolAtom)rootSymbol; | ||
|
||
if (this.AccentAtom.Type != TexAtomType.Accent) | ||
throw new ArgumentException("The specified symbol name is not an accent.", "accent"); | ||
} | ||
|
||
// Atom over which accent symbol is placed. | ||
public Atom BaseAtom | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
// Atom representing accent symbol to place over base atom. | ||
public SymbolAtom AccentAtom | ||
{ | ||
get; | ||
private set; | ||
} | ||
|
||
public override Box CreateBox(TexEnvironment environment) | ||
{ | ||
CharSymbol GetBaseChar() | ||
{ | ||
var baseAtom = BaseAtom; | ||
while (baseAtom is AccentedAtom a) | ||
{ | ||
baseAtom = a.BaseAtom; | ||
} | ||
|
||
return baseAtom as CharSymbol; | ||
} | ||
|
||
var texFont = environment.MathFont; | ||
var style = environment.Style; | ||
|
||
// Create box for base atom. | ||
var baseBox = this.BaseAtom == null ? StrutBox.Empty : this.BaseAtom.CreateBox(environment.GetCrampedStyle()); | ||
var baseCharFont = GetBaseChar()?.GetCharFont(texFont); | ||
var skew = baseCharFont == null ? 0.0 : texFont.GetSkew(baseCharFont, style); | ||
|
||
// Find character of best scale for accent symbol. | ||
var accentChar = texFont.GetCharInfo(AccentAtom.Name, style); | ||
while (texFont.HasNextLarger(accentChar)) | ||
{ | ||
var nextLargerChar = texFont.GetNextLargerCharInfo(accentChar, style); | ||
if (nextLargerChar.Metrics.Width > baseBox.Width) | ||
break; | ||
accentChar = nextLargerChar; | ||
} | ||
|
||
var resultBox = new VerticalBox(); | ||
|
||
// Create and add box for accent symbol. | ||
Box accentBox; | ||
var accentItalicWidth = accentChar.Metrics.Italic; | ||
if (accentItalicWidth > TexUtilities.FloatPrecision) | ||
{ | ||
accentBox = new HorizontalBox(new CharBox(environment, accentChar)); | ||
accentBox.Add(new StrutBox(accentItalicWidth, 0, 0, 0)); | ||
} | ||
else | ||
{ | ||
accentBox = new CharBox(environment, accentChar); | ||
} | ||
resultBox.Add(accentBox); | ||
|
||
var delta = Math.Min(baseBox.Height, texFont.GetXHeight(style, accentChar.FontId)); | ||
resultBox.Add(new StrutBox(0, -delta, 0, 0)); | ||
|
||
// Centre and add box for base atom. Centre base box and accent box with respect to each other. | ||
var boxWidthsDiff = (baseBox.Width - accentBox.Width) / 2; | ||
accentBox.Shift = skew + Math.Max(boxWidthsDiff, 0); | ||
if (boxWidthsDiff < 0) | ||
baseBox = new HorizontalBox(baseBox, accentBox.Width, TexAlignment.Center); | ||
resultBox.Add(baseBox); | ||
|
||
// Adjust height and depth of result box. | ||
var depth = baseBox.Depth; | ||
var totalHeight = resultBox.Height + resultBox.Depth; | ||
resultBox.Depth = depth; | ||
resultBox.Height = totalHeight - depth; | ||
|
||
return resultBox; | ||
} | ||
} | ||
} |
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,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace WpfMath | ||
{ | ||
// Atom (smallest unit) of TexFormula. | ||
internal abstract class Atom | ||
{ | ||
public Atom() | ||
{ | ||
this.Type = TexAtomType.Ordinary; | ||
} | ||
|
||
public TexAtomType Type | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
public abstract Box CreateBox(TexEnvironment environment); | ||
|
||
// Gets type of leftmost child item. | ||
public virtual TexAtomType GetLeftType() | ||
{ | ||
return this.Type; | ||
} | ||
|
||
// Gets type of leftmost child item. | ||
public virtual TexAtomType GetRightType() | ||
{ | ||
return this.Type; | ||
} | ||
} | ||
} |
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,15 @@ | ||
using System.Collections.Generic; | ||
using Avalonia.Media; | ||
|
||
namespace WpfMath.Avalonia | ||
{ | ||
public class GeometryGroup : Geometry | ||
{ | ||
public override Geometry Clone() | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
|
||
public IList<Geometry> Children { get; set; } | ||
} | ||
} |
Oops, something went wrong.