-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
318 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.