///////////////////////////////////////////////////////////////////////////////////////////////// // // InitializeSample() // // Create all sample objects responsible for interacting with UIA and highlighting hyperlinks. // // Note that this sample app assumes that all required operations succeed. A shipping app // would need the appropriate error handling in place. // ///////////////////////////////////////////////////////////////////////////////////////////////// void InitializeSample() { // Initialize the highlighting used to magnify hyperlinks in the browser window. _highlight = new Highlight(); _highlight.Initialize(); // Initialize the object which will make all the UIA calls on a background MTA thread. _linkProcessor = new LinkProcessor(); _linkProcessor.Initialize(new SampleUIListUpdateDelegate(UpdateListOnUIThread), listViewLinks, _highlight); // Initialize the event handler which is called when the UIA tree structure changes in the browser window. SampleUIEventHandlerDelegate sampleUIEventHandlerDelegate = new SampleUIEventHandlerDelegate(HandleEventOnUIThread); _sampleEventHandler = new SampleEventHandler(this, sampleUIEventHandlerDelegate); }
void InitializeSample() { // Initialize the highlighting used to magnify the element with focus. _highlight = new Highlight(); _highlight.Initialize(); try { _synth = new SpeechSynthesizer(); } catch { // Allow this sample to run even if speech is not available. _synth = null; } // Initialize the event handler which is called when focus changes. SampleUIEventHandlerDelegate sampleUIEventHandlerDelegate = new SampleUIEventHandlerDelegate(HandleEventOnUIThread); _sampleFocusEventHandler = new SampleFocusEventHandler(this, sampleUIEventHandlerDelegate); // Now tell the sample event handler to register for events from UIA. _sampleFocusEventHandler.StartEventHandler(); }