-
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.
(#63) TexEnvironment: move to the Shared assembly
- Loading branch information
Showing
14 changed files
with
89 additions
and
62 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
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 |
---|---|---|
@@ -1,49 +1,52 @@ | ||
using System.Windows.Media; | ||
using WpfMath.Boxes; | ||
using WpfMath.Rendering; | ||
|
||
namespace WpfMath.Atoms | ||
namespace WpfMath.Atoms; | ||
|
||
/// <summary>Atom specifying graphical style.</summary> | ||
internal record StyledAtom : Atom, IRow | ||
{ | ||
// Atom specifying graphical style. | ||
internal record StyledAtom : Atom, IRow | ||
public StyledAtom( | ||
SourceSpan? source, | ||
Atom? atom, | ||
IPlatformBrush? backgroundColor, | ||
IPlatformBrush? foregroundColor) | ||
: base(source) | ||
{ | ||
public StyledAtom(SourceSpan? source, Atom? atom, Brush? backgroundColor, Brush? foregroundColor) | ||
: base(source) | ||
{ | ||
this.RowAtom = new RowAtom(source, atom); | ||
this.Background = backgroundColor; | ||
this.Foreground = foregroundColor; | ||
} | ||
this.RowAtom = new RowAtom(source, atom); | ||
this.Background = backgroundColor; | ||
this.Foreground = foregroundColor; | ||
} | ||
|
||
// RowAtom to which colors are applied. | ||
public RowAtom RowAtom { get; init; } | ||
// RowAtom to which colors are applied. | ||
public RowAtom RowAtom { get; init; } | ||
|
||
public Brush? Background { get; init; } | ||
public IPlatformBrush? Background { get; init; } | ||
|
||
public Brush? Foreground { get; init; } | ||
public IPlatformBrush? Foreground { get; init; } | ||
|
||
public Atom WithPreviousAtom(DummyAtom? previousAtom) => | ||
this with { RowAtom = (RowAtom) RowAtom.WithPreviousAtom(previousAtom) }; | ||
public Atom WithPreviousAtom(DummyAtom? previousAtom) => | ||
this with { RowAtom = (RowAtom) RowAtom.WithPreviousAtom(previousAtom) }; | ||
|
||
protected override Box CreateBoxCore(TexEnvironment environment) | ||
{ | ||
var newEnvironment = environment with | ||
{ | ||
Foreground = this.Foreground ?? environment.Foreground | ||
}; | ||
var childBox = this.RowAtom.CreateBox(newEnvironment); | ||
if (Background != null) | ||
childBox.Background = Background; | ||
return childBox; | ||
} | ||
|
||
public override TexAtomType GetLeftType() | ||
protected override Box CreateBoxCore(TexEnvironment environment) | ||
{ | ||
var newEnvironment = environment with | ||
{ | ||
return this.RowAtom.GetLeftType(); | ||
} | ||
Foreground = this.Foreground ?? environment.Foreground | ||
}; | ||
var childBox = this.RowAtom.CreateBox(newEnvironment); | ||
if (Background != null) | ||
childBox.Background = Background; | ||
return childBox; | ||
} | ||
|
||
public override TexAtomType GetRightType() | ||
{ | ||
return this.RowAtom.GetRightType(); | ||
} | ||
public override TexAtomType GetLeftType() | ||
{ | ||
return this.RowAtom.GetLeftType(); | ||
} | ||
|
||
public override TexAtomType GetRightType() | ||
{ | ||
return this.RowAtom.GetRightType(); | ||
} | ||
} |
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
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
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,9 @@ | ||
using System.Windows.Media; | ||
|
||
namespace WpfMath.Rendering; | ||
|
||
internal static class BrushExtensions | ||
{ | ||
public static Brush? ToWpf(this IPlatformBrush? brush) => ((WpfBrush?)brush)?.Get(); | ||
public static IPlatformBrush? ToPlatform(this Brush? brush) => brush == null ? null : WpfBrush.FromBrush(brush); | ||
} |
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
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