This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

View File

@@ -34,16 +34,16 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
Resources.MergedDictionaries.Clear();
SizeChanged += ImagePanel_SizeChanged;
viewPanelImage.DoZoomToFit += (_, _) => DoZoomToFit();
ViewPanelImage.DoZoomToFit += (_, _) => DoZoomToFit();
viewPanel.PreviewMouseWheel += ViewPanel_PreviewMouseWheel;
viewPanel.MouseLeftButtonDown += ViewPanel_MouseLeftButtonDown;
viewPanel.MouseMove += ViewPanel_MouseMove;
viewPanel.MouseDoubleClick += ViewPanel_MouseDoubleClick;
ViewPanel.PreviewMouseWheel += ViewPanel_PreviewMouseWheel;
ViewPanel.MouseLeftButtonDown += ViewPanel_MouseLeftButtonDown;
ViewPanel.MouseMove += ViewPanel_MouseMove;
ViewPanel.MouseDoubleClick += ViewPanel_MouseDoubleClick;
viewPanel.ManipulationInertiaStarting += ViewPanel_ManipulationInertiaStarting;
viewPanel.ManipulationStarting += ViewPanel_ManipulationStarting;
viewPanel.ManipulationDelta += ViewPanel_ManipulationDelta;
ViewPanel.ManipulationInertiaStarting += ViewPanel_ManipulationInertiaStarting;
ViewPanel.ManipulationStarting += ViewPanel_ManipulationStarting;
ViewPanel.ManipulationDelta += ViewPanel_ManipulationDelta;
}
public bool ZoomWithControlKey
@@ -152,7 +152,7 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
}
if (ShowZoomLevelInfo)
((Storyboard)zoomLevelInfo.FindResource("StoryboardShowZoomLevelInfo")).Begin();
((Storyboard)ZoomLevelInfo.FindResource("StoryboardShowZoomLevelInfo")).Begin();
}
}
@@ -176,14 +176,14 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
OnPropertyChanged();
if (ImageUriSource == null)
viewPanelImage.Source = _source;
ViewPanelImage.Source = _source;
}
}
public void Dispose()
{
viewPanelImage?.Dispose();
viewPanelImage = null;
ViewPanelImage?.Dispose();
ViewPanelImage = null;
}
public event PropertyChangedEventHandler? PropertyChanged;
@@ -211,7 +211,7 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
private void ViewPanel_ManipulationStarting(object? sender, ManipulationStartingEventArgs e)
{
e.ManipulationContainer = viewPanel;
e.ManipulationContainer = ViewPanel;
e.Mode = ManipulationModes.Scale | ManipulationModes.Translate;
}
@@ -223,19 +223,19 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
Zoom(newZoom);
viewPanel.ScrollToHorizontalOffset(viewPanel.HorizontalOffset - delta.Translation.X);
viewPanel.ScrollToVerticalOffset(viewPanel.VerticalOffset - delta.Translation.Y);
ViewPanel.ScrollToHorizontalOffset(ViewPanel.HorizontalOffset - delta.Translation.X);
ViewPanel.ScrollToVerticalOffset(ViewPanel.VerticalOffset - delta.Translation.Y);
e.Handled = true;
}
private void ViewPanel_MouseLeftButtonDown(object? sender, MouseButtonEventArgs e)
{
e.MouseDevice.Capture(viewPanel);
e.MouseDevice.Capture(ViewPanel);
_dragInitPos = e.GetPosition(viewPanel);
_dragInitPos = e.GetPosition(ViewPanel);
var temp = _dragInitPos.Value; // Point is a type value
temp.Offset(viewPanel.HorizontalOffset, viewPanel.VerticalOffset);
temp.Offset(ViewPanel.HorizontalOffset, ViewPanel.VerticalOffset);
_dragInitPos = temp;
}
@@ -259,10 +259,10 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
e.Handled = true;
var delta = _dragInitPos.Value - e.GetPosition(viewPanel);
var delta = _dragInitPos.Value - e.GetPosition(ViewPanel);
viewPanel.ScrollToHorizontalOffset(delta.X);
viewPanel.ScrollToVerticalOffset(delta.Y);
ViewPanel.ScrollToHorizontalOffset(delta.X);
ViewPanel.ScrollToVerticalOffset(delta.Y);
}
private void ViewPanel_PreviewMouseWheel(object? sender, MouseWheelEventArgs e)
@@ -272,7 +272,7 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
// normal scroll when Control is not pressed, useful for PdfViewer
if (ZoomWithControlKey && (Keyboard.Modifiers & ModifierKeys.Control) == 0)
{
viewPanel.ScrollToVerticalOffset(viewPanel.VerticalOffset - e.Delta);
ViewPanel.ScrollToVerticalOffset(ViewPanel.VerticalOffset - e.Delta);
ImageScrolled?.Invoke(this, e.Delta);
return;
}
@@ -285,18 +285,18 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
public Size GetScrollSize()
{
return new Size(viewPanel.ScrollableWidth, viewPanel.ScrollableHeight);
return new Size(ViewPanel.ScrollableWidth, ViewPanel.ScrollableHeight);
}
public Point GetScrollPosition()
{
return new Point(viewPanel.HorizontalOffset, viewPanel.VerticalOffset);
return new Point(ViewPanel.HorizontalOffset, ViewPanel.VerticalOffset);
}
public void SetScrollPosition(Point point)
{
viewPanel.ScrollToHorizontalOffset(point.X);
viewPanel.ScrollToVerticalOffset(point.Y);
ViewPanel.ScrollToHorizontalOffset(point.X);
ViewPanel.ScrollToVerticalOffset(point.Y);
}
public void DoZoomToFit()
@@ -308,14 +308,14 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
private void UpdateZoomToFitFactor()
{
if (viewPanelImage?.Source == null)
if (ViewPanelImage?.Source == null)
{
ZoomToFitFactor = 1d;
return;
}
var factor = Math.Min(viewPanel.ActualWidth / viewPanelImage.Source.Width,
viewPanel.ActualHeight / viewPanelImage.Source.Height);
var factor = Math.Min(ViewPanel.ActualWidth / ViewPanelImage.Source.Width,
ViewPanel.ActualHeight / ViewPanelImage.Source.Height);
ZoomToFitFactor = factor;
}
@@ -328,7 +328,7 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
public void Zoom(double factor, bool suppressEvent = false, bool isToFit = false)
{
if (viewPanelImage?.Source == null)
if (ViewPanelImage?.Source == null)
return;
// pause when fit width
@@ -356,21 +356,21 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
ZoomFactor = factor;
var position = ZoomToFit
? new Point(viewPanelImage.Source.Width / 2, viewPanelImage.Source.Height / 2)
: Mouse.GetPosition(viewPanelImage);
? new Point(ViewPanelImage.Source.Width / 2, ViewPanelImage.Source.Height / 2)
: Mouse.GetPosition(ViewPanelImage);
viewPanelImage.LayoutTransform = new ScaleTransform(factor, factor);
ViewPanelImage.LayoutTransform = new ScaleTransform(factor, factor);
viewPanel.InvalidateMeasure();
ViewPanel.InvalidateMeasure();
// critical for calculating offset
viewPanel.ScrollToHorizontalOffset(0);
viewPanel.ScrollToVerticalOffset(0);
ViewPanel.ScrollToHorizontalOffset(0);
ViewPanel.ScrollToVerticalOffset(0);
UpdateLayout();
var offset = viewPanelImage.TranslatePoint(position, viewPanel) - Mouse.GetPosition(viewPanel);
viewPanel.ScrollToHorizontalOffset(offset.X);
viewPanel.ScrollToVerticalOffset(offset.Y);
var offset = ViewPanelImage.TranslatePoint(position, ViewPanel) - Mouse.GetPosition(ViewPanel);
ViewPanel.ScrollToHorizontalOffset(offset.X);
ViewPanel.ScrollToVerticalOffset(offset.Y);
UpdateLayout();
if (!suppressEvent)
@@ -400,11 +400,11 @@ public partial class ImageView : UserControl, INotifyPropertyChanged, IDisposabl
public void ScrollToTop()
{
viewPanel.ScrollToTop();
ViewPanel.ScrollToTop();
}
public void ScrollToBottom()
{
viewPanel.ScrollToBottom();
ViewPanel.ScrollToBottom();
}
}