Skip to content

Commit

Permalink
Gallery updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Nov 1, 2024
1 parent 98e38e8 commit 094e570
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 333 deletions.
6 changes: 6 additions & 0 deletions src/PicView.Avalonia/CustomControls/GalleryListBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ public void ScrollToEnd()
_autoScrollViewer.Offset = new Vector(double.PositiveInfinity, double.PositiveInfinity);
_autoScrollViewer.ScrollToEnd();
}

public void ScrollToHome()
{
_autoScrollViewer.Offset = new Vector(double.NegativeInfinity, double.NegativeInfinity);
_autoScrollViewer.ScrollToHome();
}

public void PageLeft()
{
Expand Down
51 changes: 51 additions & 0 deletions src/PicView.Avalonia/CustomControls/ThumbImage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media;

namespace PicView.Avalonia.CustomControls;

public class ThumbImage : Image
{
protected override Size MeasureOverride(Size availableSize)
{
Size? size = null;
try
{
size = new Size();


if (Source != null)
{
size = Stretch.CalculateSize(availableSize, Source.Size, StretchDirection);
}
}
catch (Exception e)
{
#if DEBUG
Console.WriteLine(e);
#endif
}

return size ?? new Size();
}

protected override Size ArrangeOverride(Size finalSize)
{
try
{
if (Source != null)
{
var sourceSize = Source.Size;
var result = Stretch.CalculateSize(finalSize, sourceSize);
return result;
}
}
catch (Exception e)
{
#if DEBUG
Console.WriteLine(e);
#endif
}
return new Size();
}
}
Loading

0 comments on commit 094e570

Please sign in to comment.