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

Change from UserControl to Custom Control. #384

Closed samirem closed 1 year ago

samirem commented 1 year ago

This should fix #97.

Instead of inheriting from UserControl, the FormulaControl now inherits from Control, and overrides the DefaultStyleKey. I also had to override MeasureOverride, and compute the size of the control by making some minor modifications to other classes.

ygra commented 1 year ago

You've lost the error template along the way. I think you should be able to include this in a generic.xaml for the assembly, which then provides a default style for the control. The whole concept is a bit underdocumented, admittedly.

If the error message could be rendered in the same DrawingContext, you could lose the template as well and probably go with a FrameworkElement as base class.

Also I'm not quite sure whether it's a good idea to render the control into a dummy DrawingContext just to measure it; perhaps not rendering is cheaper, even if it incurs font metric calculations, but at least you don't have to render text you never need.

ForNeVeR commented 1 year ago

I am so sorry this took me some time to get to review. It somehow slipped through my mailbox. I'll take a closer look in the next few days.

ForNeVeR commented 1 year ago

Could you please give an example of how you would like to use/override the default style?

I am concerned by the fact that this introduces several breaking changes into the library, and I'd like to get a code example to play with and maybe figure out if it's possible to do in a less breaking way, or is it worth to introduce a compatibility layer.

ForNeVeR commented 1 year ago

Without explanations, I'm sorry, I have to decline this for now. I don't understand the issue, and I don't understand how to check that the issue is resolved.