VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.Wpf.UI Namespace / WpfImageViewerState Class / AutoScrollPosition Property
Синтаксис Example Требования Смотрите также
В этом разделе
    AutoScrollPosition Свойство (WpfImageViewerState)
    В этом разделе
    Возвращает или задает положение автоматической прокрутки.
    Синтаксис
    'Declaration
    
    Public Property AutoScrollPosition As System.Windows.Point
    
    
    public System.Windows.Point AutoScrollPosition { get; set; }
    
    
    public: __property System.Windows.Point get_AutoScrollPosition();
    public: __property void set_AutoScrollPosition(
    System.Windows.Point value
    );
    public:
    property System.Windows.Point AutoScrollPosition { System.Windows.Point get(); void set(System.Windows.Point value); }
    Пример

    
    Public Partial Class WpfImageViewer_ExternalScrollBars
        Inherits System.Windows.Window
    
        #Region "Constructors"
    
        Public Sub New()
            InitializeComponent()
            ' ...
            AddHandler imageViewer.ImageLoaded, New System.EventHandler(Of Vintasoft.Imaging.ImageLoadedEventArgs)(AddressOf imageViewer_ImageLoaded)
            AddHandler imageViewer.ZoomChanged, New System.EventHandler(Of Vintasoft.Imaging.UI.ZoomChangedEventArgs)(AddressOf imageViewer_ZoomChanged)
            AddHandler imageViewer.SizeChanged, New System.Windows.SizeChangedEventHandler(AddressOf imageViewer_SizeChanged)
            AddHandler horizontalScrollBar.ValueChanged, New System.Windows.RoutedPropertyChangedEventHandler(Of Double)(AddressOf ScrollBar_ValueChanged)
            AddHandler verticalScrollBar.ValueChanged, New System.Windows.RoutedPropertyChangedEventHandler(Of Double)(AddressOf ScrollBar_ValueChanged)
    
                ' ...
            imageViewer.AutoScroll = False
        End Sub
    
        #End Region
    
    
    
        #Region "Methods"
    
        ''' <summary>
        ''' Image is loaded in image viewer.
        ''' </summary>
        Private Sub imageViewer_ImageLoaded(sender As Object, e As Vintasoft.Imaging.ImageLoadedEventArgs)
            SetScrollBarsParams()
        End Sub
    
        ''' <summary>
        ''' Image viewer size is changed.
        ''' </summary>
        Private Sub imageViewer_SizeChanged(sender As Object, e As System.Windows.SizeChangedEventArgs)
            SetScrollBarsParams()
        End Sub
    
        ''' <summary>
        ''' Image viewer zoom is changed.
        ''' </summary>
        Private Sub imageViewer_ZoomChanged(sender As Object, e As Vintasoft.Imaging.UI.ZoomChangedEventArgs)
            SetScrollBarsParams()
        End Sub
    
        ''' <summary>
        ''' Sets parameters of scroll bars.
        ''' </summary>
        Private Sub SetScrollBarsParams()
            ' initialize horizontal scroll bar
            horizontalScrollBar.Minimum = 0
            horizontalScrollBar.Maximum = imageViewer.ViewerState.AutoScrollSize.Width
            horizontalScrollBar.Track.ViewportSize = imageViewer.ActualWidth
    
            ' initialize vertical scroll bar
            verticalScrollBar.Minimum = 0
            verticalScrollBar.Maximum = imageViewer.ViewerState.AutoScrollSize.Height
            verticalScrollBar.Track.ViewportSize = imageViewer.ActualHeight
        End Sub
    
        ''' <summary>
        ''' Scroolbar is changed.
        ''' </summary>
        Private Sub ScrollBar_ValueChanged(sender As Object, e As System.Windows.RoutedPropertyChangedEventArgs(Of Double))
            Dim currentPosition As New System.Windows.Point(horizontalScrollBar.Value, verticalScrollBar.Value)
            imageViewer.ViewerState.AutoScrollPosition = currentPosition
        End Sub
    
        #End Region
    
    End Class
    
    
    
    public partial class WpfImageViewer_ExternalScrollBars : System.Windows.Window
    {
    
        #region Constructors
    
        public WpfImageViewer_ExternalScrollBars()
        {
            InitializeComponent();
            // ...
            imageViewer.ImageLoaded += new System.EventHandler<Vintasoft.Imaging.ImageLoadedEventArgs>(imageViewer_ImageLoaded);
            imageViewer.ZoomChanged += new System.EventHandler<Vintasoft.Imaging.UI.ZoomChangedEventArgs>(imageViewer_ZoomChanged);
            imageViewer.SizeChanged += new System.Windows.SizeChangedEventHandler(imageViewer_SizeChanged);
            horizontalScrollBar.ValueChanged +=
                new System.Windows.RoutedPropertyChangedEventHandler<double>(ScrollBar_ValueChanged);
            verticalScrollBar.ValueChanged +=
                new System.Windows.RoutedPropertyChangedEventHandler<double>(ScrollBar_ValueChanged);
    
            imageViewer.AutoScroll = false;
            // ...
        }
    
        #endregion
    
    
    
        #region Methods
    
        /// <summary>
        /// Image is loaded in image viewer.
        /// </summary>
        private void imageViewer_ImageLoaded(object sender, Vintasoft.Imaging.ImageLoadedEventArgs e)
        {
            SetScrollBarsParams();
        }
    
        /// <summary>
        /// Image viewer size is changed.
        /// </summary>
        private void imageViewer_SizeChanged(object sender, System.Windows.SizeChangedEventArgs e)
        {
            SetScrollBarsParams();
        }
    
        /// <summary>
        /// Image viewer zoom is changed.
        /// </summary>
        private void imageViewer_ZoomChanged(object sender, Vintasoft.Imaging.UI.ZoomChangedEventArgs e)
        {
            SetScrollBarsParams();
        }
    
        /// <summary>
        /// Sets parameters of scroll bars.
        /// </summary>
        private void SetScrollBarsParams()
        {
            // initialize horizontal scroll bar
            horizontalScrollBar.Minimum = 0;
            horizontalScrollBar.Maximum = imageViewer.ViewerState.AutoScrollSize.Width;
            horizontalScrollBar.Track.ViewportSize = imageViewer.ActualWidth;
    
            // initialize vertical scroll bar
            verticalScrollBar.Minimum = 0;
            verticalScrollBar.Maximum = imageViewer.ViewerState.AutoScrollSize.Height;
            verticalScrollBar.Track.ViewportSize = imageViewer.ActualHeight;
        }
    
        /// <summary>
        /// Scroolbar is changed.
        /// </summary>
        private void ScrollBar_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
        {
            System.Windows.Point currentPosition =
                new System.Windows.Point(horizontalScrollBar.Value, verticalScrollBar.Value);
            imageViewer.ViewerState.AutoScrollPosition = currentPosition;
        }
    
        #endregion
    
    }
    
    

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также