AvaloniaUI / Avalonia.HtmlRenderer

Avalonia front-end for the HtmlRenderer project.
MIT License
137 stars 34 forks source link

HtmlLabel.cs seems not to be correct ... #11

Closed berndmehnert closed 3 years ago

berndmehnert commented 3 years ago

Hi, I am particularly referring to the following code within HtmlLabel.cs and there f.e. to the first else if. Something seems to be missing there. Since Avalonia at the moment seems not to be capable of displaying text with inlines in it, I hoped that I could somehow use your HtmlRenderer ;).

      /// <summary>
        /// Handle when dependency property value changes to update the underline HtmlContainer with the new value.
        /// </summary>
        private static Action<IAvaloniaObject, AvaloniaPropertyChangedEventArgs> OnAvaloniaProperty_valueChanged = new Action<IAvaloniaObject, AvaloniaPropertyChangedEventArgs>((AvaloniaObject, e) =>
        protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> e)
        {
            var control = AvaloniaObject as HtmlLabel;
            if (control != null)
            base.OnPropertyChanged(e);
            if (e.Property == AutoSizeProperty)
            {
                if (e.Property == AutoSizeProperty)
                if (e.NewValue.GetValueOrDefault<bool>())
                {
                    if ((bool)e.NewValue)
                    {
                        AvaloniaObject.SetValue(AutoSizeHeightOnlyProperty, false);
                        control.InvalidateMeasure();
                        control.InvalidateVisual();
                    }
                    SetValue(AutoSizeHeightOnlyProperty, false);
                }
                else if (e.Property == AutoSizeHeightOnlyProperty)
            }
            else if (e.Property == AutoSizeHeightOnlyProperty)
            {
                if (e.NewValue.GetValueOrDefault<bool>())
                {
                    if ((bool)e.NewValue)
                    {
                        AvaloniaObject.SetValue(AutoSizeProperty, false);
                        control.InvalidateMeasure();
                        control.InvalidateVisual();
                    }
                    SetValue(AutoSizeProperty, false);
                }
            }
        });

        }
        #endregion
    }
kekekeks commented 3 years ago

Looks like an automatic merge that messed up the code. The original one is here: https://github.com/ArthurHub/HTML-Renderer/blob/a004aefeb87b5226aece75c49e84040dbaf9f3e0/Source/HtmlRenderer.WPF/HtmlLabel.cs#L108-L132

maxkatz6 commented 3 years ago

@berndmehnert thanks for letting know. Fixed https://github.com/AvaloniaUI/Avalonia.HtmlRenderer/pull/12