示例#1
0
        public string [] GetSelectionPaths()
        {
            var           selection      = provider.GetSelection();
            List <string> selectionPaths = new List <string> (selection.Length);

            foreach (var selectionRange in selection)
            {
                selectionPaths.Add(GetOrCreateTextRange(selectionRange));
            }
            return(selectionPaths.ToArray());
        }
示例#2
0
        private static void HandleTextSelectionChangedEvent(ProxySimple el, IntPtr hwnd, int eventId)
        {
            ITextProvider textProvider = el.GetPatternProvider(TextPattern.Pattern) as ITextProvider;

            if (textProvider == null)
            {
                return;
            }

            if (eventId == NativeMethods.EventObjectLocationChange)
            {
                // We do not want to raise the EventObjectLocationChange when it is caused by a scroll.  To do this
                // store the previous range and compare it to the current range.  The range will not change when scrolling.
                ITextRangeProvider[] currentRanges = textProvider.GetSelection();
                ITextRangeProvider   currentRange  = null;
                if (currentRanges != null && currentRanges.Length > 0)
                {
                    currentRange = currentRanges[0];
                }

                if (hwnd == _hwndLast && currentRange != null)
                {
                    if (_lastSelection != null && !currentRange.Compare(_lastSelection))
                    {
                        AutomationInteropProvider.RaiseAutomationEvent(TextPattern.TextSelectionChangedEvent, el, new AutomationEventArgs(TextPattern.TextSelectionChangedEvent));
                    }
                }
                else
                {
                    AutomationInteropProvider.RaiseAutomationEvent(TextPattern.TextSelectionChangedEvent, el, new AutomationEventArgs(TextPattern.TextSelectionChangedEvent));
                }

                //store the current range and window handle.
                _hwndLast      = hwnd;
                _lastSelection = currentRange;
            }
            else if (eventId == NativeMethods.EventObjectTextSelectionChanged)
            {
                AutomationInteropProvider.RaiseAutomationEvent(
                    TextPattern.TextSelectionChangedEvent, el,
                    new AutomationEventArgs(TextPattern.TextSelectionChangedEvent));
            }
        }