ForNeVeR / xaml-math

A collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and Avalonia XAML-based frameworks
MIT License
637 stars 100 forks source link

How to use SetBackground #406

Closed seghier closed 1 year ago

seghier commented 1 year ago

Hi Thank you for this useful tool How to use SetBackground to change the background from transparent to another color?

ForNeVeR commented 1 year ago

Could you please clarify: the background of what? Of a particular formula element or of the whole control?

seghier commented 1 year ago

Thanks, i find a solution to set the background of the image If you can replace brush with System.Drawing.Color this will be better .....SetBackground(System.Drawing.Color)

var mediaBackClr = System.Windows.Media.Color.FromArgb(backClr.A, backClr.R, backClr.G, backClr.B);
var backsolidbrush = new System.Windows.Media.SolidColorBrush(mediaBackClr);
var backBrush = WpfMath.Rendering.WpfBrush.FromBrush(backsolidbrush);
latexformula.SetBackground(backBrush);
ForNeVeR commented 1 year ago

Ok, now I see what you mean.

Unfortunately, I don't think we are going that way.

While not exactly, System.Drawing.Color is mostly associated with Windows Forms and not WPF; as you can see, WPF uses its own color types (while, for simple coloring, they directly correspond to each other).

WPF part of XAML Math is only going to deal with WPF types. Aside from color types, this allows you to apply any WPF brush to select coloring, even a texture brush or whatnot.

We will be developing a separate Windows Forms backend (#378), though, that will allow you to use WinForms Brush instead. And that one is a bit easier to construct from a System.Drawing.Color.

Note that it will never be possible to mix WPF rendering and Windows Forms brushes, though.