Skip to content

Commit

Permalink
Copy the modified Avalonia projects to their own directories (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Jan 13, 2019
1 parent 13090ac commit 3438c9a
Show file tree
Hide file tree
Showing 117 changed files with 10,222 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Avalonia-Math.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaMath", "src\WpfMath\AvaloniaMath.csproj", "{7CAD197E-2BDC-4F1A-9A74-FDADB223C92C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaloniaMath", "src\AvaloniaMath\AvaloniaMath.csproj", "{1C4986E0-D0C3-4FE1-BBFD-FF8032610997}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaMath.Example", "src\WpfMath.Example\AvaloniaMath.Example.csproj", "{FEDBA64C-56F1-4FE7-B13A-81C4EF94910A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvaloniaMath.Example", "src\AvaloniaMath.Example\AvaloniaMath.Example.csproj", "{ADEE0B42-3EAF-4C86-BB79-1E2280715A8C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7CAD197E-2BDC-4F1A-9A74-FDADB223C92C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7CAD197E-2BDC-4F1A-9A74-FDADB223C92C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7CAD197E-2BDC-4F1A-9A74-FDADB223C92C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7CAD197E-2BDC-4F1A-9A74-FDADB223C92C}.Release|Any CPU.Build.0 = Release|Any CPU
{FEDBA64C-56F1-4FE7-B13A-81C4EF94910A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FEDBA64C-56F1-4FE7-B13A-81C4EF94910A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FEDBA64C-56F1-4FE7-B13A-81C4EF94910A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FEDBA64C-56F1-4FE7-B13A-81C4EF94910A}.Release|Any CPU.Build.0 = Release|Any CPU
{1C4986E0-D0C3-4FE1-BBFD-FF8032610997}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C4986E0-D0C3-4FE1-BBFD-FF8032610997}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C4986E0-D0C3-4FE1-BBFD-FF8032610997}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C4986E0-D0C3-4FE1-BBFD-FF8032610997}.Release|Any CPU.Build.0 = Release|Any CPU
{ADEE0B42-3EAF-4C86-BB79-1E2280715A8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADEE0B42-3EAF-4C86-BB79-1E2280715A8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADEE0B42-3EAF-4C86-BB79-1E2280715A8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADEE0B42-3EAF-4C86-BB79-1E2280715A8C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 18 additions & 0 deletions src/AvaloniaMath.Example/App.xaml
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>
13 changes: 13 additions & 0 deletions src/AvaloniaMath.Example/App.xaml.cs
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);
}
}
}
18 changes: 18 additions & 0 deletions src/AvaloniaMath.Example/AvaloniaMath.Example.csproj
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>
6 changes: 6 additions & 0 deletions src/AvaloniaMath.Example/MainView.xaml
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>
18 changes: 18 additions & 0 deletions src/AvaloniaMath.Example/MainView.xaml.cs
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);
}
}
}
6 changes: 6 additions & 0 deletions src/AvaloniaMath.Example/MainWindow.xaml
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>
25 changes: 25 additions & 0 deletions src/AvaloniaMath.Example/MainWindow.xaml.cs
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);
}
}
}
15 changes: 15 additions & 0 deletions src/AvaloniaMath.Example/Program.cs
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>();

}
}
}
3 changes: 3 additions & 0 deletions src/AvaloniaMath.Example/app.config
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>
111 changes: 111 additions & 0 deletions src/AvaloniaMath/AccentedAtom.cs
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;
}
}
}
36 changes: 36 additions & 0 deletions src/AvaloniaMath/Atom.cs
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;
}
}
}
15 changes: 15 additions & 0 deletions src/AvaloniaMath/Avalonia/GroupGeometry.cs
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; }
}
}
Loading

0 comments on commit 3438c9a

Please sign in to comment.