Sha256: 5873d5412c9b7bd9b32d0299511b15009090c0ed90ca3f01a78aa526698f053e

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

using System.Collections.Generic;
using System.Linq;
using System.Windows.Automation;
using RAutomation.UIA.Extensions;

namespace RAutomation.UIA.Controls
{
    public class TabControl
    {
        private readonly AutomationElement _element;

        public TabControl(AutomationElement element)
        {
            _element = element;
        }

        public string[] TabNames
        {
            get { return TabItems.Select(x => x.Current.Name).ToArray(); }
        }

        public string Selection
        {
            get { return TabItems.First(IsSelected).Current.Name; }
            set { TabItems.First(x => x.Current.Name == value).AsSelectionItem().Select(); }
        }

        public int SelectedIndex
        {
            get { return TabItems.IndexOf(IsSelected); }
            set { SelectionItems.ElementAt(value).Select(); }
        }

        private static bool IsSelected(AutomationElement tabItem)
        {
            return tabItem.AsSelectionItem().Current.IsSelected;
        }

        private IEnumerable<AutomationElement> TabItems
        {
            get { return _element.Find(IsTabItem); }
        }

        private IEnumerable<SelectionItemPattern> SelectionItems
        {
            get { return TabItems.AsSelectionItems(); }
        }

        private static Condition IsTabItem
        {
            get { return new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem); }
        }
    }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rautomation-2.0.1-x86-mingw32 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-2.0.1-x64-mingw32 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs