Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fixes for circle and picture controls #926

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ public Point Center
set => SetInvalidatingProperty(ref center, value);
}

/// <inheritdoc/>
public override int Left
{
get => center.X - radius;
set
{
center.X = value + radius;
Invalidate();
}
}

/// <inheritdoc/>
public override int Top
{
get => center.Y - radius;
set
{
center.Y = value + radius;
Invalidate();
}
}

/// <summary>
/// Gets or sets the foreground color of the Circle.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Picture : ThemedControl
private Color _backColor = Color.Transparent;
private VerticalAlignment _verticalAlignment = VerticalAlignment.Center;
private HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Center;
private MF.Image _image = default!;
private MF.Image? _image = default!;

/// <summary>
/// Initializes a new instance of the <see cref="MicroLayout.Picture"/> class with the specified dimensions and image.
Expand All @@ -21,7 +21,7 @@ public class Picture : ThemedControl
/// <param name="width">The width of the image display control.</param>
/// <param name="height">The height of the image display control.</param>
/// <param name="image">The image to be displayed.</param>
public Picture(int left, int top, int width, int height, MF.Image image)
public Picture(int left, int top, int width, int height, MF.Image? image = null)
: base(left, top, width, height)
{
Image = image;
Expand All @@ -42,7 +42,7 @@ public override void ApplyTheme(DisplayTheme theme)
/// <summary>
/// Gets or sets the image to be displayed on the image display control.
/// </summary>
public MF.Image Image
public MF.Image? Image
{
get => _image;
set => SetInvalidatingProperty(ref _image, value);
Expand Down Expand Up @@ -81,6 +81,8 @@ public Color BackColor
/// <param name="graphics">The <see cref="MicroGraphics"/> surface to draw the image display control on.</param>
protected override void OnDraw(MicroGraphics graphics)
{
if (Image == null) { return; }

if (BackColor != Color.Transparent)
{
graphics.DrawRectangle(
Expand Down
Loading