Skip to content

Commit

Permalink
packport fix for ImageZoom
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneWandererProductions committed Jan 2, 2024
1 parent f852531 commit 390e0b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
22 changes: 8 additions & 14 deletions CommonControls/ImageZoom.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,31 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:imaging1="clr-namespace:Imaging;assembly=Imaging"
xmlns:imag="clr-namespace:Imaging;assembly=Imaging"
mc:Ignorable="d"
Name="ImgZoom"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<ScrollViewer x:Name="ScrollView" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Canvas
x:Name="MainCanvas"
MouseDown="Canvas_MouseDown"
MouseUp="Canvas_MouseUp"
MouseMove="Canvas_MouseMove"
MouseWheel="Canvas_MouseWheel">
<Canvas>
<imaging1:ImageGif
<Grid x:Name="MainCanvas" MouseDown="Canvas_MouseDown" MouseUp="Canvas_MouseUp" MouseMove="Canvas_MouseMove" MouseWheel="Canvas_MouseWheel">
<imag:ImageGif
Stretch="None"
SnapsToDevicePixels="True"
UseLayoutRounding="True"
Name="BtmImage"
RenderOptions.BitmapScalingMode="NearestNeighbor"
AutoStart="{Binding ElementName=ImgZoom, Path=AutoplayGifImage}">
<imaging1:ImageGif.LayoutTransform>
<imag:ImageGif.LayoutTransform>
<ScaleTransform x:Name="Scale" />
</imaging1:ImageGif.LayoutTransform>
</imaging1:ImageGif>
</imag:ImageGif.LayoutTransform>
</imag:ImageGif>
<Rectangle
x:Name="SelectionBox"
Visibility="Collapsed"
Stroke="Black"
StrokeThickness="1" />
</Canvas>
</Canvas>

</Grid>
</ScrollViewer>
</Grid>
</UserControl>
25 changes: 14 additions & 11 deletions CommonControls/ImageZoom.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public sealed partial class ImageZoom
/// </summary>
public static readonly DependencyProperty AutoplayGif = DependencyProperty.Register(nameof(AutoplayGifImage),
typeof(bool),
typeof(ImageZoom), new PropertyMetadata(OnAutoplayGifSourcePropertyChanged));

typeof(ImageZoom), null);

/// <summary>
/// The image Start Point
Expand Down Expand Up @@ -150,15 +149,6 @@ public bool AutoplayGifImage
set => SetValue(AutoplayGif, value);
}

/// <summary>
/// Called when [autoplay GIF source property changed].
/// </summary>
/// <param name="d">The d.</param>
/// <param name="e">The <see cref="DependencyPropertyChangedEventArgs" /> instance containing the event data.</param>
private static void OnAutoplayGifSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
}

/// <summary>
/// Occurs when [selected frame] was changed
/// </summary>
Expand Down Expand Up @@ -204,7 +194,20 @@ private void OnImageSourceGifChanged()
return;
}

//reset position
var matrix = BtmImage.RenderTransform.Value;
matrix.OffsetX = 0;
matrix.OffsetY = 0;
BtmImage.RenderTransform = new MatrixTransform(matrix);

//reset Scrollbar
ScrollView.ScrollToTop();
ScrollView.UpdateLayout();

BtmImage.GifSource = ImageGifPath;

MainCanvas.Height = BtmImage.Source.Height;
MainCanvas.Width = BtmImage.Source.Width;
}

/// <summary>
Expand Down

0 comments on commit 390e0b1

Please sign in to comment.