26 changed files with 77 additions and 319 deletions
@ -1,61 +0,0 @@ |
|||
using System; |
|||
using Avalonia.Controls.Shapes; |
|||
using Avalonia.Media; |
|||
using Avalonia.Metadata; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
[Obsolete("Use Image control with DrawingImage source")] |
|||
public class DrawingPresenter : Control |
|||
{ |
|||
static DrawingPresenter() |
|||
{ |
|||
AffectsMeasure<DrawingPresenter>(DrawingProperty); |
|||
AffectsRender<DrawingPresenter>(DrawingProperty); |
|||
} |
|||
|
|||
public static readonly StyledProperty<Drawing> DrawingProperty = |
|||
AvaloniaProperty.Register<DrawingPresenter, Drawing>(nameof(Drawing)); |
|||
|
|||
public static readonly StyledProperty<Stretch> StretchProperty = |
|||
AvaloniaProperty.Register<DrawingPresenter, Stretch>(nameof(Stretch), Stretch.Uniform); |
|||
|
|||
[Content] |
|||
public Drawing Drawing |
|||
{ |
|||
get => GetValue(DrawingProperty); |
|||
set => SetValue(DrawingProperty, value); |
|||
} |
|||
|
|||
public Stretch Stretch |
|||
{ |
|||
get => GetValue(StretchProperty); |
|||
set => SetValue(StretchProperty, value); |
|||
} |
|||
|
|||
private Matrix _transform = Matrix.Identity; |
|||
|
|||
protected override Size MeasureOverride(Size availableSize) |
|||
{ |
|||
if (Drawing == null) return new Size(); |
|||
|
|||
var (size, transform) = Shape.CalculateSizeAndTransform(availableSize, Drawing.GetBounds(), Stretch); |
|||
|
|||
_transform = transform; |
|||
|
|||
return size; |
|||
} |
|||
|
|||
public override void Render(DrawingContext context) |
|||
{ |
|||
if (Drawing != null) |
|||
{ |
|||
using (context.PushPreTransform(_transform)) |
|||
using (context.PushClip(new Rect(Bounds.Size))) |
|||
{ |
|||
Drawing.Draw(context); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,16 +1,7 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Controls |
|||
namespace Avalonia.Controls |
|||
{ |
|||
|
|||
[Obsolete("This class exists to maintain backwards compatibility with existing code. Use NativeMenuItemSeparator instead")] |
|||
public class NativeMenuItemSeperator : NativeMenuItemSeparator |
|||
{ |
|||
} |
|||
|
|||
public class NativeMenuItemSeparator : NativeMenuItemBase |
|||
{ |
|||
[Obsolete("This is a temporary hack to make our MenuItem recognize this as a separator, don't use", true)] |
|||
public string Header => "-"; |
|||
|
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue