StrokeBox.Foreground is not initialized in constructor
- Dominant language
- C#
- Stars
- 719
- Forks
- 113
- Avg merge
- 6d 12h
- Merged PRs (30d)
- 1
Description
The constructors of its base class `Box` and some other derived classes like [`CharBox`](https://github.com/ForNeVeR/xaml-math/blob/master/src/XamlMath.Shared/Boxes/CharBox.cs) require a argument of type `TexEnvironment`, from which they initialize their `Foreground` property. But the constructor of [`StrokeBox`](https://github.com/ForNeVeR/xaml-math/blob/f3e0ebd6b83c14c75443ee5a9f943eda71f8a3d2/src/XamlMath.Shared/Boxes/StrokeBox.cs) does not accept arguments of type `TexEnvironment`, which makes its Foreground property not set in constructor and stay null.
As a result, if `FormulaControl.Foreground` is set to other color, the color of lines rendered from `StrokeBox` is still the fallback value set in `IElementRenderer.RenderLine`.
I think we can add a parameter of type `TexEnvironment` to the constructor of `StrokeBox`. The constructor is only used in `CancelAtom.CreateBoxCore` method.
``` C#
public StrokeBox(TexEnvironment environment, StrokeBoxMode mode) : base(environment)
{
_mode = mode;
}
```
``` C#
protected override Box CreateBoxCore(TexEnvironment environment)
{
var contentBox = _contentAtom is null ? StrutBox.Empty : _contentAtom.CreateBox(environment);
var lineBox = new StrokeBox(environment, _strokeBoxMode)
{
Height = contentBox.Height,
Depth = contentBox.Depth,
Width = contentBox.Width
};
var box = new LayeredBox();
box.Add(contentBox);
box.Add(lineBox);
return box;
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.