Sha256: 1ab4c925fe8249ff5c9232dfcf2a25cea85edc868b94a83dbeb9d397805eb9a8

Contents?: true

Size: 1.49 KB

Versions: 10

Compression:

Stored size: 1.49 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

10 entries across 10 versions & 1 rubygems

Version Path
rautomation-1.1.0 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-1.0.0 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-0.17.0 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-0.16.0 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-0.15.0 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-0.14.1 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-0.14.0 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-0.13.0 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-0.12.0 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs
rautomation-0.11.0 ext/UiaDll/RAutomation.UIA/Controls/TabControl.cs