Updatre version to 0.10, fix some warnings
This commit is contained in:
Родитель
5fc322ea65
Коммит
b01ab9d603
|
@ -254,12 +254,12 @@ namespace TheArtOfDev.HtmlRenderer.Avalonia.Adapters
|
|||
|
||||
public override void DrawImage(RImage image, RRect destRect, RRect srcRect)
|
||||
{
|
||||
_g.DrawImage(((ImageAdapter) image).Image, /*1, */Util.Convert(srcRect), Util.Convert(destRect));
|
||||
_g.DrawImage(((ImageAdapter) image).Image, Util.Convert(srcRect), Util.Convert(destRect));
|
||||
}
|
||||
|
||||
public override void DrawImage(RImage image, RRect destRect)
|
||||
{
|
||||
_g.DrawImage(((ImageAdapter) image).Image, /*1, */new Rect(0, 0, image.Width, image.Height),
|
||||
_g.DrawImage(((ImageAdapter) image).Image, new Rect(0, 0, image.Width, image.Height),
|
||||
Util.Convert(destRect));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,12 +32,10 @@ namespace TheArtOfDev.HtmlRenderer.Avalonia.Adapters
|
|||
/// </summary>
|
||||
private double _width;
|
||||
|
||||
private DashStyle _dashStyle;
|
||||
|
||||
/// <summary>
|
||||
/// the dash style of the pen
|
||||
/// </summary>
|
||||
//private DashStyle _dashStyle = DashStyles.Solid;
|
||||
private IDashStyle _dashStyle;
|
||||
|
||||
/// <summary>
|
||||
/// Init.
|
||||
|
@ -58,13 +56,13 @@ namespace TheArtOfDev.HtmlRenderer.Avalonia.Adapters
|
|||
set { DashStyles.TryGetValue(value, out _dashStyle); }
|
||||
}
|
||||
|
||||
private static readonly Dictionary<RDashStyle, DashStyle> DashStyles = new Dictionary<RDashStyle, DashStyle>
|
||||
private static readonly Dictionary<RDashStyle, IDashStyle> DashStyles = new Dictionary<RDashStyle, IDashStyle>
|
||||
{
|
||||
{RDashStyle.Solid,null },
|
||||
{RDashStyle.Dash, null/*global::Avalonia.Media.DashStyle.Dash*/ },
|
||||
{RDashStyle.DashDot, null/*global::Avalonia.Media.DashStyle.DashDot*/ },
|
||||
{RDashStyle.DashDotDot, null/*global::Avalonia.Media.DashStyle.DashDotDot*/ },
|
||||
{RDashStyle.Dot, null/*global::Avalonia.Media.DashStyle.Dot*/ }
|
||||
{RDashStyle.Solid, null },
|
||||
{RDashStyle.Dash, global::Avalonia.Media.DashStyle.Dash },
|
||||
{RDashStyle.DashDot, global::Avalonia.Media.DashStyle.DashDot },
|
||||
{RDashStyle.DashDotDot, global::Avalonia.Media.DashStyle.DashDotDot },
|
||||
{RDashStyle.Dot, global::Avalonia.Media.DashStyle.Dot }
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -106,12 +106,10 @@
|
|||
<Compile Include="HtmlControl.cs" />
|
||||
<Compile Include="HtmlLabel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="PropertyHelper.cs" />
|
||||
<Compile Include="HtmlRendererRoutedEventArgs.cs" />
|
||||
<Compile Include="Utilities\Util.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.10.0-preview4" />
|
||||
<PackageReference Include="System.Reactive.Core" Version="4.4.1" />
|
||||
<PackageReference Include="Avalonia" Version="0.10.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -462,7 +462,7 @@ namespace TheArtOfDev.HtmlRenderer.Avalonia
|
|||
/// </summary>
|
||||
private static RKeyEvent CreateKeyEevent(KeyEventArgs e)
|
||||
{
|
||||
var control = (e.Modifiers & InputModifiers.Control) == InputModifiers.Control;
|
||||
var control = e.KeyModifiers.HasFlag(KeyModifiers.Control);
|
||||
return new RKeyEvent(control, e.Key == Key.A, e.Key == Key.C);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
// "The Art of War"
|
||||
|
||||
using System;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.HtmlRenderer;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
|
@ -116,7 +114,7 @@ namespace Avalonia.Controls.Html
|
|||
static HtmlControl()
|
||||
{
|
||||
FocusableProperty.OverrideDefaultValue(typeof(HtmlControl), true);
|
||||
AffectsRender(TextProperty);
|
||||
AffectsRender<HtmlControl>(TextProperty);
|
||||
|
||||
AvoidImagesLateLoadingProperty.Changed.AddClassHandler<HtmlControl>(OnAvaloniaProperty_valueChanged);
|
||||
IsSelectionEnabledProperty.Changed.AddClassHandler<HtmlControl>(OnAvaloniaProperty_valueChanged);
|
||||
|
|
37
HtmlLabel.cs
37
HtmlLabel.cs
|
@ -16,6 +16,7 @@ using Avalonia.Media;
|
|||
using TheArtOfDev.HtmlRenderer.Adapters.Entities;
|
||||
using TheArtOfDev.HtmlRenderer.Core;
|
||||
using TheArtOfDev.HtmlRenderer.Avalonia.Adapters;
|
||||
using TheArtOfDev.HtmlRenderer.Core;
|
||||
|
||||
namespace Avalonia.Controls.Html
|
||||
{
|
||||
|
@ -36,6 +37,10 @@ namespace Avalonia.Controls.Html
|
|||
|
||||
public static readonly AvaloniaProperty AutoSizeProperty = PropertyHelper.Register<HtmlLabel, bool>("AutoSize", true, OnAvaloniaProperty_valueChanged);
|
||||
public static readonly AvaloniaProperty AutoSizeHeightOnlyProperty = PropertyHelper.Register<HtmlLabel, bool>("AutoSizeHeightOnly", false, OnAvaloniaProperty_valueChanged);
|
||||
public static readonly StyledProperty<bool> AutoSizeProperty =
|
||||
AvaloniaProperty.Register<HtmlLabel, bool>("AutoSize", true);
|
||||
public static readonly StyledProperty<bool> AutoSizeHeightOnlyProperty =
|
||||
AvaloniaProperty.Register<HtmlLabel, bool>("AutoSizeHeightOnly", false);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -46,6 +51,25 @@ namespace Avalonia.Controls.Html
|
|||
static HtmlLabel()
|
||||
{
|
||||
BackgroundProperty.OverrideDefaultValue<HtmlLabel>(Brushes.Transparent);
|
||||
AffectsMeasure<HtmlLabel>(AutoSizeProperty, AutoSizeHeightOnlyProperty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automatically sets the size of the label by content size
|
||||
/// </summary>
|
||||
public bool AutoSize
|
||||
{
|
||||
get => GetValue(AutoSizeProperty);
|
||||
set => SetValue(AutoSizeProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automatically sets the height of the label by content height (width is not effected).
|
||||
/// </summary>
|
||||
public virtual bool AutoSizeHeightOnly
|
||||
{
|
||||
get => GetValue(AutoSizeHeightOnlyProperty);
|
||||
set => SetValue(AutoSizeHeightOnlyProperty, value);
|
||||
}
|
||||
|
||||
#region Private methods
|
||||
|
@ -79,15 +103,21 @@ namespace Avalonia.Controls.Html
|
|||
return constraint;
|
||||
}
|
||||
|
||||
|
||||
/// <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)
|
||||
{
|
||||
|
@ -95,8 +125,13 @@ namespace Avalonia.Controls.Html
|
|||
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)
|
||||
{
|
||||
|
@ -104,10 +139,12 @@ namespace Avalonia.Controls.Html
|
|||
control.InvalidateMeasure();
|
||||
control.InvalidateVisual();
|
||||
}
|
||||
SetValue(AutoSizeProperty, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Avalonia.HtmlRenderer
|
||||
{
|
||||
static class PropertyHelper
|
||||
{
|
||||
|
||||
/*public static AvaloniaProperty Register<TOwner, T>(string name, T def, Action<AvaloniaObject, AvaloniaPropertyChangedEventArgs> changed) where TOwner : AvaloniaObject
|
||||
{
|
||||
var pp = AvaloniaProperty.Register<TOwner, T>(name, def);
|
||||
Action<AvaloniaPropertyChangedEventArgs> cb = args =>
|
||||
{
|
||||
changed(args.Sender, args);
|
||||
};
|
||||
|
||||
pp.Changed.Subscribe(cb);
|
||||
return pp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/public static AvaloniaProperty Register<TOwner, T>(string name, T def, Action<IAvaloniaObject, AvaloniaPropertyChangedEventArgs> changed) where TOwner : IAvaloniaObject
|
||||
{
|
||||
var pp = AvaloniaProperty.Register<TOwner, T>(name, def);
|
||||
|
||||
/*IObserver<AvaloniaPropertyChangedEventArgs> cb = new Observer<AvaloniaPropertyChangedEventArgs>.Create((args) =>
|
||||
{
|
||||
changed(args.Sender, args);
|
||||
});*/
|
||||
|
||||
pp.Changed.Subscribe(args =>
|
||||
{
|
||||
changed.Invoke(args.Sender, args);
|
||||
/*if ((args != null) && (args.Sender != null) && (changed != null))
|
||||
changed(args.Sender, args);*/
|
||||
});
|
||||
|
||||
//pp.Changed.Subscribe(changed);
|
||||
return pp;
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче