VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Wpf.UI Namespace / WpfImageViewer Class / SetFocusedIndexSync Method
New value of FocusedIndex property.
Example



In This Topic
    SetFocusedIndexSync Method (WpfImageViewer)
    In This Topic
    Sets synchronously a new value of the FocusedIndex property.
    Syntax
    'Declaration
     
    Public Sub SetFocusedIndexSync( _
       ByVal newFocusedIndex As Integer _
    ) 
    public void SetFocusedIndexSync( 
       int newFocusedIndex
    )
    public: void SetFocusedIndexSync( 
       int newFocusedIndex
    ) 
    public:
    void SetFocusedIndexSync( 
       int newFocusedIndex
    ) 

    Parameters

    newFocusedIndex
    New value of FocusedIndex property.
    Example
    This example shows how to start animation in WpfImageViewer if images are stored in Images property.
    ''' <summary>
    ''' Starts showing animation in image viewer.
    ''' </summary>
    ''' <param name="viewer">An image viewer.</param>
    ''' <param name="delay">The animation delay in milliseconds.</param>
    Private Sub StartAnimation(viewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer, delay As Integer)
    	' start animation
    	System.Threading.ThreadPool.QueueUserWorkItem(New System.Threading.WaitCallback(AddressOf ShowAnimation), New Object() {viewer, delay})
    End Sub
                
    ''' <summary>
    ''' Shows animation in image viewer.
    ''' </summary>
    ''' <param name="state">Data that the method uses.</param>
    Private Sub ShowAnimation(state As Object)
    	' get data
    	Dim data As Object() = DirectCast(state, Object())
    	' get image viewer
    	Dim viewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer = DirectCast(data(0), Vintasoft.Imaging.Wpf.UI.WpfImageViewer)
    	' get delay value
    	Dim delay As Integer = CInt(data(1))
    	' for each image in image collection of image viewer
    	For i As Integer = 0 To viewer.Images.Count - 1
    		' change image in image viewer
    		viewer.SetFocusedIndexSync(i)
    		' sleep for a while
    		System.Threading.Thread.Sleep(delay)
    	Next
    End Sub
    /// <summary>
    /// Starts showing animation in image viewer.
    /// </summary>
    /// <param name="viewer">An image viewer.</param>
    /// <param name="delay">The animation delay in milliseconds.</param>
    private void StartAnimation(Vintasoft.Imaging.Wpf.UI.WpfImageViewer viewer, int delay)
    {
        // start animation
        System.Threading.ThreadPool.QueueUserWorkItem(
            new System.Threading.WaitCallback(ShowAnimation), new object[] { viewer, delay });
    }
                
    /// <summary>
    /// Shows animation in image viewer.
    /// </summary>
    /// <param name="state">Data that the method uses.</param>
    private void ShowAnimation(object state)
    {
        // get data
        object[] data = (object[])state;
        // get image viewer
        Vintasoft.Imaging.Wpf.UI.WpfImageViewer viewer =
             (Vintasoft.Imaging.Wpf.UI.WpfImageViewer)data[0];
        // get delay value
        int delay = (int)data[1];
        // for each image in image collection of image viewer
        for (int i = 0; i < viewer.Images.Count; i++)
        {
            // change image in image viewer
            viewer.SetFocusedIndexSync(i);
            // sleep for a while
            System.Threading.Thread.Sleep(delay);
        }
    }
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also