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

    
    Public Partial Class ImageViewer_ExternalScrollBars
        Inherits System.Windows.Forms.Form
    
        #Region "Constructors"
    
        Public Sub New()
            InitializeComponent()
            ' ...
            AddHandler imageViewer.ZoomChanged, New System.EventHandler(Of Vintasoft.Imaging.UI.ZoomChangedEventArgs)(AddressOf imageViewer_ZoomChanged)
            AddHandler imageViewer.ImageLoaded, New System.EventHandler(Of Vintasoft.Imaging.ImageLoadedEventArgs)(AddressOf imageViewer_ImageLoaded)
            AddHandler imageViewer.SizeChanged, New System.EventHandler(AddressOf imageViewer_SizeChanged)
            AddHandler hScrollBar1.ValueChanged, New System.EventHandler(AddressOf ScrollBar_ValueChanged)
            AddHandler vScrollBar1.ValueChanged, New System.EventHandler(AddressOf ScrollBar_ValueChanged)
    
                ' ...
            imageViewer.AutoScroll = False
        End Sub
    
        #End Region
    
    
    
        #Region "Methods"
    
        ''' <summary>
        ''' Image viewer size is changed.
        ''' </summary>
        Private Sub imageViewer_SizeChanged(sender As Object, e As System.EventArgs)
            SetScrollBarParams()
        End Sub
    
        ''' <summary>
        ''' Image is loaded in image viewer.
        ''' </summary>
        Private Sub imageViewer_ImageLoaded(sender As Object, e As Vintasoft.Imaging.ImageLoadedEventArgs)
            SetScrollBarParams()
        End Sub
    
        ''' <summary>
        ''' Image viewer zoom is changed.
        ''' </summary>
        Private Sub imageViewer_ZoomChanged(sender As Object, e As Vintasoft.Imaging.UI.ZoomChangedEventArgs)
            SetScrollBarParams()
        End Sub
    
        ''' <summary>
        ''' Sets parameters of scroll bars.
        ''' </summary>
        Private Sub SetScrollBarParams()
            ' initialize horizontal scroll bar
            Dim width As Integer = imageViewer.ViewerState.AutoScrollSize.Width
            hScrollBar1.Minimum = 0
            hScrollBar1.Maximum = width + width \ 5
            hScrollBar1.LargeChange = width \ 5
            hScrollBar1.SmallChange = width \ 20
            hScrollBar1.Enabled = width <> 0
    
            ' initialize vertical scroll bar
            Dim height As Integer = imageViewer.ViewerState.AutoScrollSize.Height
            vScrollBar1.Minimum = 0
            vScrollBar1.Maximum = height + height \ 5
            vScrollBar1.LargeChange = height \ 5
            vScrollBar1.SmallChange = height \ 20
            vScrollBar1.Enabled = height <> 0
        End Sub
    
        ''' <summary>
        ''' Scrollbar value is changed.
        ''' </summary>
        Private Sub ScrollBar_ValueChanged(sender As Object, e As System.EventArgs)
            Dim currentPosition As New System.Drawing.PointF(CSng(hScrollBar1.Value), CSng(vScrollBar1.Value))
            imageViewer.ViewerState.AutoScrollPosition = currentPosition
        End Sub
    
        #End Region
    
    End Class
    
    
    
    public partial class ImageViewer_ExternalScrollBars : System.Windows.Forms.Form
    {
    
        #region Constructors
    
        public ImageViewer_ExternalScrollBars()
        {
            InitializeComponent();
            // ...
            imageViewer.ZoomChanged += new System.EventHandler<Vintasoft.Imaging.UI.ZoomChangedEventArgs>(imageViewer_ZoomChanged);
            imageViewer.ImageLoaded += new System.EventHandler<Vintasoft.Imaging.ImageLoadedEventArgs>(imageViewer_ImageLoaded);
            imageViewer.SizeChanged += new System.EventHandler(imageViewer_SizeChanged);
            hScrollBar1.ValueChanged += new System.EventHandler(ScrollBar_ValueChanged);
            vScrollBar1.ValueChanged += new System.EventHandler(ScrollBar_ValueChanged);
    
            imageViewer.AutoScroll = false;
            // ...
        }
    
        #endregion
    
    
    
        #region Methods
    
        /// <summary>
        /// Image viewer size is changed.
        /// </summary>
        private void imageViewer_SizeChanged(object sender, System.EventArgs e)
        {
            SetScrollBarParams();
        }
    
        /// <summary>
        /// Image is loaded in image viewer.
        /// </summary>
        private void imageViewer_ImageLoaded(object sender, Vintasoft.Imaging.ImageLoadedEventArgs e)
        {
            SetScrollBarParams();
        }
    
        /// <summary>
        /// Image viewer zoom is changed.
        /// </summary>
        private void imageViewer_ZoomChanged(object sender, Vintasoft.Imaging.UI.ZoomChangedEventArgs e)
        {
            SetScrollBarParams();
        }
    
        /// <summary>
        /// Sets parameters of scroll bars.
        /// </summary>
        private void SetScrollBarParams()
        {
            // initialize horizontal scroll bar
            int width = imageViewer.ViewerState.AutoScrollSize.Width;
            hScrollBar1.Minimum = 0;
            hScrollBar1.Maximum = width + width / 5;
            hScrollBar1.LargeChange = width / 5;
            hScrollBar1.SmallChange = width / 20;
            hScrollBar1.Enabled = width != 0;
    
            // initialize vertical scroll bar
            int height = imageViewer.ViewerState.AutoScrollSize.Height;
            vScrollBar1.Minimum = 0;
            vScrollBar1.Maximum = height + height / 5;
            vScrollBar1.LargeChange = height / 5;
            vScrollBar1.SmallChange = height / 20;
            vScrollBar1.Enabled = height != 0;
        }
    
        /// <summary>
        /// Scrollbar value is changed.
        /// </summary>
        private void ScrollBar_ValueChanged(object sender, System.EventArgs e)
        {
            System.Drawing.PointF currentPosition =
                new System.Drawing.PointF((float)hScrollBar1.Value, (float)vScrollBar1.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

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