Inheritance: AutomationIdentifier
		static WindowPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "WindowPatternIdentifiers.Pattern");
			CanMaximizeProperty =
				new AutomationProperty (CanMaximizePropertyId,
				                        "WindowPatternIdentifiers.CanMaximizeProperty");
			CanMinimizeProperty =
				new AutomationProperty (CanMinimizePropertyId,
				                        "WindowPatternIdentifiers.CanMinimizeProperty");
			IsModalProperty =
				new AutomationProperty (IsModalPropertyId,
				                        "WindowPatternIdentifiers.IsModalProperty");
			IsTopmostProperty =
				new AutomationProperty (IsTopmostPropertyId,
				                        "WindowPatternIdentifiers.IsTopmostProperty");
			WindowInteractionStateProperty =
				new AutomationProperty (WindowInteractionStatePropertyId,
				                        "WindowPatternIdentifiers.WindowInteractionStateProperty");
			WindowVisualStateProperty =
				new AutomationProperty (WindowVisualStatePropertyId,
				                        "WindowPatternIdentifiers.WindowVisualStateProperty");
			WindowClosedEvent =
				new AutomationEvent (WindowClosedEventId,
				                     "WindowPatternIdentifiers.WindowClosedProperty");
			WindowOpenedEvent =
				new AutomationEvent (WindowOpenedEventId,
				                     "WindowPatternIdentifiers.WindowOpenedProperty");
		}
        // ------------------------------------------------------
        //
        // Patterns Implementation
        //
        // ------------------------------------------------------

        #region ProxySimple Interface

        // Returns a pattern interface if supported.
        internal override object GetPatternProvider (AutomationPattern iid)
        {
            // Treate these toolbar items as menuitems and only support Invoke or Expand/Collapse patterns.
            // Invoke Pattern needs to be supported when the item has no children.  When the item does have
            // children it needs to support ExpandCollapse Pattern.

            // Check if button is a separator
            if (IsSeparator())
            {
                return null;
            }

            // Check if button is disabled
            if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONENABLED, new IntPtr(_idCommand), IntPtr.Zero) == 0)
            {
                return null;
            }

            // Check if button is hidden
            if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONHIDDEN, new IntPtr(_idCommand), IntPtr.Zero) != 0)
            {
                return null;
            }

            // 
            if (iid == InvokePattern.Pattern)
            {
                // button is enabled and not hidden and not a separator
                return this;
            }

            //

            return null;
        }
        private T GetNativePatternAs <T>(UIA.AutomationPattern pattern) where T : UIA.BasePattern
        {
            object nativePattern;

            BasicAutomationElement.NativeElement.TryGetCurrentPattern(pattern, out nativePattern);
            return((T)nativePattern);
        }
        //------------------------------------------------------
        //
        //  Patterns Implementation
        //
        //------------------------------------------------------

        #region ProxySimple Interface

        // Returns a pattern interface if supported.
        internal override object GetPatternProvider (AutomationPattern iid)
        {
            if (iid == InvokePattern.Pattern && WindowsListView.ListViewInvokable(_hwnd))
            {
                return this;
            }

            if (iid == SelectionItemPattern.Pattern)
            {
                return this;
            }

            if (iid == ValuePattern.Pattern && WindowsListView.ListViewEditable (_hwnd))
            {
                return this;
            }

            if (iid == GridItemPattern.Pattern && IsImplementingGrid (_hwnd))
            {
                return this;
            }

            if (iid == TogglePattern.Pattern && IsItemWithCheckbox(_hwnd, _item))
            {
                return CreateListViewItemCheckbox();
            }

            if (iid == ScrollItemPattern.Pattern && WindowScroll.IsScrollable(_hwnd))
            {
                return this;
            }

            return null;
        }
		static GridItemPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
						"GridItemPatternIdentifiers.Pattern");

			RowProperty =
				new AutomationProperty (RowPropertyId,
						"GridItemPatternIdentifiers.RowProperty");

			ColumnProperty =
				new AutomationProperty (ColumnPropertyId,
						"GridItemPatternIdentifiers.ColumnProperty");

			RowSpanProperty =
				new AutomationProperty (RowSpanPropertyId,
						"GridItemPatternIdentifiers.RowSpanProperty");

			ColumnSpanProperty =
				new AutomationProperty (ColumnSpanPropertyId,
						"GridItemPatternIdentifiers.ColumnSpanProperty");

			ContainingGridProperty =
				new AutomationProperty (ContainingGridPropertyId,
						"GridItemPatternIdentifiers.ContainingGridProperty");
		}
		protected override bool IsBehaviorEnabled (AutomationPattern pattern)
		{
			object behavior = GetPatternProvider (pattern.Id);
			if (behavior != null)
				return true;
			return base.IsBehaviorEnabled (pattern);
		}
Beispiel #7
0
 protected object TryGetPattern(AutomationPattern pattern,AutomationElement elementNeedToGet = null)
 {
     elementNeedToGet = elementNeedToGet ?? this.self;
     object returnPattern;
     elementNeedToGet.TryGetCurrentPattern(pattern, out returnPattern);
     return returnPattern ?? null;
 }
Beispiel #8
0
 public void executePattern(AutomationElement subject, AutomationPattern inPattern)
 {
     switch (inPattern.ProgrammaticName)
     {
         case "InvokePatternIdentifiers.Pattern":
             {
                 InvokePattern invoke = (InvokePattern)subject.GetCurrentPattern(InvokePattern.Pattern);
                 invoke.Invoke();
                 break;
             }
         case "SelectionItemPatternIdentifiers.Pattern":
             {
                 SelectionItemPattern select = (SelectionItemPattern)subject.GetCurrentPattern(SelectionItemPattern.Pattern);
                 select.Select();
                 break;
             }
         case "TogglePatternIdentifiers.Pattern":
             {
                 TogglePattern toggle = (TogglePattern)subject.GetCurrentPattern(TogglePattern.Pattern);
                 toggle.Toggle();
                 break;
             }
         case "ExpandCollapsePatternIdentifiers.Pattern":
             {
                 ExpandCollapsePattern exColPat = (ExpandCollapsePattern)subject.GetCurrentPattern(ExpandCollapsePattern.Pattern);
                 // exColPat.Expand();
                 break;
             }
     }
 }
Beispiel #9
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
 
        #region Constructors

        internal AutomationPatternInfo( 
            AutomationPattern id,
            WrapObject wcpWrapper)
        {
            _id = id;
            _wcpWrapper = wcpWrapper;
        }
		public ProviderBehaviorEventArgs (IProviderBehavior behavior,
		                                  AutomationPattern pattern,
		                                  bool replaced)
		{
			this.replaced = replaced;
			this.behavior = behavior;
			this.pattern = pattern;
		}
Beispiel #11
0
 private object Pattern(AutomationPattern pattern) {
     try {
         return element.GetCurrentPattern(pattern);
     } catch (InvalidOperationException e) {
         ControlType type = (ControlType)element.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty);
         throw new InvalidOperationException(type.ProgrammaticName + " does not support " + pattern.ProgrammaticName, e);
     }
 }
Beispiel #12
0
		public override IProviderBehavior GetListItemBehaviorRealization (AutomationPattern behavior,
		                                                                  ListItemProvider listItem)
		{
			if (behavior == TogglePatternIdentifiers.Pattern)
				return new ListItemToggleProviderBehavior (listItem);	
			else
				return base.GetListItemBehaviorRealization (behavior, listItem);
		}
Beispiel #13
0
		static DockPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "DockPatternIdentifiers.Pattern");
			DockPositionProperty = 
				new AutomationProperty (DockPositionPropertyId,
				                        "DockPatternIdentifiers.DockPositionProperty");
		}
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
 
        #region Constructors

        public AutomationPatternInfo( 
            AutomationPattern id,
            AutomationProperty [ ] properties,
            WrapObjectClientSide clientSideWrapper )
        {
            _id = id;
            _properties = properties;
            _clientSideWrapper = clientSideWrapper;
        }
		static InvokePatternIdentifiers ()
		{
			InvokedEvent =
				new AutomationEvent (InvokedEventId, 
				                     "InvokePatternIdentifiers.InvokedEvent");
			Pattern =
				new AutomationPattern (PatternId,
				                       "InvokePatternIdentifiers.Pattern");
		}
		static TogglePatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "TogglePatternIdentifiers.Pattern");
			ToggleStateProperty =
				new AutomationProperty (ToggleStatePropertyId,
				                        "TogglePatternIdentifiers.ToggleStateProperty");
		}
Beispiel #17
0
 public void Add(AutomationPattern pattern)
 {
     Utility.ValidateArgumentNonNull(pattern, "pattern");
     lock (this._lock)
     {
         this.CheckAccess();
         this._obj.AddPattern(pattern.Id);
     }
 }
            //------------------------------------------------------
            //
            //  Pattern Implementation
            //
            //------------------------------------------------------

            #region ProxySimple Interface

            // Returns a pattern interface if supported.
            internal override object GetPatternProvider (AutomationPattern iid)
            {
                if (iid == InvokePattern.Pattern)
                {
                    return this;
                }

                return null;
            }
		static ExpandCollapsePatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "ExpandCollapsePatternIdentifiers.Pattern");
			
			ExpandCollapseStateProperty =
				new AutomationProperty (ExpandCollapseStatePropertyId, 
			                        "ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty");
		}
        //------------------------------------------------------
        //
        //  Patterns Implementation
        //
        //------------------------------------------------------

        #region ProxySimple Interface

        // Returns a pattern interface if supported.
        internal override object GetPatternProvider(AutomationPattern iid)
        {
            if (iid == GridPattern.Pattern)
            {
                return this;
            }
            else if (iid == ExpandCollapsePattern.Pattern && WindowsListView.IsGroupViewEnabled(_hwnd))
            {
                return this;
            }

            return null;
        }
Beispiel #21
0
		static ValuePatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId, 
				                       "ValuePatternIdentifiers.Pattern");

			IsReadOnlyProperty = 
				new AutomationProperty (IsReadOnlyPropertyId,
				                        "ValuePatternIdentifiers.IsReadOnlyProperty");
			
			ValueProperty = 
				new AutomationProperty (ValuePropertyId,
				                        "ValuePatternIdentifiers.ValueProperty");
		}
		static MultipleViewPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "MultipleViewPatternIdentifiers.Pattern");
			
			CurrentViewProperty =
				new AutomationProperty (CurrentViewPropertyId,
				                        "MultipleViewPatternIdentifiers.CurrentViewProperty");

			SupportedViewsProperty =
				new AutomationProperty (SupportedViewsPropertyId,
				                        "MultipleViewPatternIdentifiers.SupportedViewsProperty");
		}
		static TableItemPatternIdentifiers()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "TableItemPatternIdentifiers.Pattern");

			ColumnHeaderItemsProperty =
				new AutomationProperty (ColumnHeaderItemsPropertyId,
						"TableItemPatternIdentifiers.ColumnHeaderItemsProperty");

			RowHeaderItemsProperty =
				new AutomationProperty (RowHeaderItemsPropertyId,
						"TableItemPatternIdentifiers.RowHeaderItemsProperty");
		}
        //------------------------------------------------------
        //
        //  Patterns Implementation
        //
        //------------------------------------------------------

        #region ProxySimple Interface

        // Returns a pattern interface if supported.
        internal override object GetPatternProvider(AutomationPattern iid)
        {
            // Treate these listview items as menuitems and only support Invoke or Expand/Collapse patterns.
            // Invoke Pattern needs to be supported when the item has no children.  When the item does have
            // children it needs to support ExpandCollapse Pattern.

            if (iid == InvokePattern.Pattern)
            {
                return this;
            }

            // 

            return null;
        }
		static TransformPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "TransformPatternIdentifiers.Pattern");
			CanMoveProperty = 
				new AutomationProperty (CanMovePropertyId,
				                        "TransformPatternIdentifiers.CanMoveProperty");
			CanResizeProperty = 
				new AutomationProperty (CanResizePropertyId,
				                        "TransformPatternIdentifiers.CanResizeProperty");
			CanRotateProperty = 
				new AutomationProperty (CanRotatePropertyId,
				                        "TransformPatternIdentifiers.CanRotateProperty");
		}
Beispiel #26
0
		static GridPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
						"GridPatternIdentifiers.Pattern");

			RowCountProperty =
				new AutomationProperty (RowCountPropertyId,
						"GridPatternIdentifiers.RowCountProperty");

			ColumnCountProperty =
				new AutomationProperty (ColumnCountPropertyId,
						"GridPatternIdentifiers.ColumnCountProperty");
			ColumnReorderedEvent =
				new AutomationEvent (ColumnReorderedEventId,
				                     "GridPatternIdentifiers.ColumnReorderedEvent");
		}
		static SelectionPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "SelectionPatternIdentifiers.Pattern");
			CanSelectMultipleProperty =
				new AutomationProperty (CanSelectMultiplePropertyId,
				                        "SelectionPatternIdentifiers.CanSelectMultipleProperty");
			IsSelectionRequiredProperty =
				new AutomationProperty (IsSelectionRequiredPropertyId,
				                        "SelectionPatternIdentifiers.IsSelectionRequiredProperty");
			SelectionProperty =
				new AutomationProperty (SelectionPropertyId,
				                        "SelectionPatternIdentifiers.SelectionProperty");
			InvalidatedEvent =
				new AutomationEvent (InvalidatedEventId,
				                     "SelectionPatternIdentifiers.InvalidatedEvent");
		}
Beispiel #28
0
		public static string PatternName (AutomationPattern pattern)
		{
			if (pattern == null)
				throw new ArgumentNullException ("pattern");

			if (pattern == DockPatternIdentifiers.Pattern)
				return "Dock";
			else if (pattern == ExpandCollapsePatternIdentifiers.Pattern)
				return "ExpandCollapse";
			else if (pattern == GridItemPatternIdentifiers.Pattern)
				return "GridItem";
			else if (pattern == GridPatternIdentifiers.Pattern)
				return "Grid";
			else if (pattern == InvokePatternIdentifiers.Pattern)
				return "Invoke";
			else if (pattern == MultipleViewPatternIdentifiers.Pattern)
				return "MultipleView";
			else if (pattern == RangeValuePatternIdentifiers.Pattern)
				return "RangeValue";
			else if (pattern == ScrollItemPatternIdentifiers.Pattern)
				return "ScrollItem";
			else if (pattern == ScrollPatternIdentifiers.Pattern)
				return "Scroll";
			else if (pattern == SelectionItemPatternIdentifiers.Pattern)
				return "SelectionItem";
			else if (pattern == SelectionPatternIdentifiers.Pattern)
				return "Selection";
			else if (pattern == TableItemPatternIdentifiers.Pattern)
				return "TableItem";
			else if (pattern == TablePatternIdentifiers.Pattern)
				return "Table";
			else if (pattern == TextPatternIdentifiers.Pattern)
				return "Text";
			else if (pattern == TogglePatternIdentifiers.Pattern)
				return "Toggle";
			else if (pattern == TransformPatternIdentifiers.Pattern)
				return "Transform";
			else if (pattern == ValuePatternIdentifiers.Pattern)
				return "Value";
			else if (pattern == WindowPatternIdentifiers.Pattern)
				return "Window";

			return null;
		}
Beispiel #29
0
		//Check the patterns that a control must support according to MSDN.
		public void PatternChcek (Element e, AutomationElement ae, AutomationPattern[] addStates, AutomationPattern[] invalidState)
		{
			procedureLogger.Action (string.Format ("Check {0}'s supported patterns.", e));
			
			//Remove the extra patterns from supported patterns list
			for (int i = 0; i < invalidState.Length; i++)
				if(((System.Collections.IList)e.SupportedPatterns).Contains(invalidState [i]))
					e.SupportedPatterns.Remove(invalidState[i]);
					
			//Add necessary patterns to the supported patterns list		
			for (int j = 0; j < addStates.Length; j++)
				e.SupportedPatterns.Add(addStates [j]);

			//Get list of actual patterns of this control
			AutomationPattern[] actualPatterns = ae.GetSupportedPatterns ();
			procedureLogger.ExpectedResult (string.Format ("supported patterns :"));
			for (int k = 0; k < actualPatterns.Length; k++)
				procedureLogger.ExpectedResult (string.Format ("{0} ", actualPatterns [k]));
			
			//get a list of actual patterns that are missing or extraneous
			List<AutomationPattern> missPattern = new List<AutomationPattern>();
			List<AutomationPattern> extraPattern = new List<AutomationPattern>();
			for (int p = 0; p < e.SupportedPatterns.Count; p++)
				if(!(actualPatterns.Contains (e.SupportedPatterns[p])))
					missPattern.Add(e.SupportedPatterns[p]);

			for (int q = 0; q < actualPatterns.Length; q++)
				if(!(e.SupportedPatterns.Contains (actualPatterns[q])))
					extraPattern.Add(actualPatterns[q]);

			//If missingPatterns and extraPatterns are empty, the test case passes
			//otherwise, throw an exception
			if(0 != missPattern.Count)
					Console.WriteLine("Missing miss actions: ");
					for (int n = 0; n < missPattern.Count; n++)
						Console.WriteLine(" {0}", missPattern[n]);	
			Assert.AreEqual(0, missPattern.Count);
				
			if(0 != actualPatterns.Length)
					Console.WriteLine("Missing actual actions: ");
					for (int m = 0; m < actualPatterns.Length; m++)
						Console.WriteLine(" {0}", actualPatterns[m]);
		}
Beispiel #30
0
        //------------------------------------------------------
        //
        //  Patterns Implementation
        //
        //------------------------------------------------------

        #region ProxySimple Interface

        // Returns a pattern interface if supported.
        internal override object GetPatternProvider (AutomationPattern iid)
        {
            if (iid == GridItemPattern.Pattern)
            {
                return this;
            }

            // Only the first element is editable
            if (iid == ValuePattern.Pattern && _item == 0 && WindowsListView.ListViewEditable (_hwnd))
            {
                return this;
            }

            if (iid == TableItemPattern.Pattern)
            {
                return this;
            }

            return null;
        }
		static SelectionItemPatternIdentifiers ()
		{
			Pattern =
				new AutomationPattern (PatternId,
				                       "SelectionItemPatternIdentifiers.Pattern");
			ElementAddedToSelectionEvent =
				new AutomationEvent (ElementAddedToSelectionEventId,
				                     "SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent");
			ElementRemovedFromSelectionEvent =
				new AutomationEvent (ElementRemovedFromSelectionEventId,
				                     "SelectionItemPatternIdentifiers.ElementRemovedFromSelectionEvent");
			ElementSelectedEvent =
				new AutomationEvent (ElementSelectedEventId,
				                     "SelectionItemPatternIdentifiers.ElementSelectedEvent");
			IsSelectedProperty =
				new AutomationProperty (IsSelectedPropertyId,
				                     "SelectionItemPatternIdentifiers.IsSelectedProperty");
			SelectionContainerProperty =
				new AutomationProperty (SelectionContainerPropertyId,
				                     "SelectionItemPatternIdentifiers.SelectionContainerProperty");
		}
Beispiel #32
0
 public static string PatternName(AutomationPattern pattern)
 {
     return(Boundary.UIAutomation(f: () => AutomationClass.GetPatternProgrammaticName(pattern: pattern.Id)));
 }
 static EditableRangePatternIdentifiers()
 {
     Pattern =
         new AutomationPattern(PatternId,
                               "EditableRangePatternIdentifiers.Pattern");
 }
Beispiel #34
0
        internal static AutomationIdentifier Register(UiaCoreTypesApi.AutomationIdType type, Guid guid, string programmaticName)
        {
            int num = UiaCoreTypesApi.UiaLookupId(type, ref guid);

            if (num == 0)
            {
                if ((!AutomationIdentifier.IsWin7OnlyPatternGuid(guid) && Environment.OSVersion.Version.Major <= 6) || Environment.OSVersion.Version.Major >= 7)
                {
                    int num2 = 1;
                    while (num == 0 && num2 < 1000)
                    {
                        Thread.Sleep(num2);
                        num   = UiaCoreTypesApi.UiaLookupId(type, ref guid);
                        num2 *= 2;
                    }
                }
                if (num == 0)
                {
                    return(null);
                }
            }
            Hashtable            idTable = AutomationIdentifier._idTable;
            AutomationIdentifier result;

            lock (idTable)
            {
                AutomationIdentifier automationIdentifier = (AutomationIdentifier)AutomationIdentifier._idTable[guid];
                if (automationIdentifier != null)
                {
                    result = automationIdentifier;
                }
                else
                {
                    switch (type)
                    {
                    case UiaCoreTypesApi.AutomationIdType.Property:
                        automationIdentifier = new AutomationProperty(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.Pattern:
                        automationIdentifier = new AutomationPattern(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.Event:
                        automationIdentifier = new AutomationEvent(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.ControlType:
                        automationIdentifier = new ControlType(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.TextAttribute:
                        automationIdentifier = new AutomationTextAttribute(num, guid, programmaticName);
                        break;

                    default:
                        throw new InvalidOperationException("Invalid type specified for AutomationIdentifier");
                    }
                    AutomationIdentifier._idTable[num] = automationIdentifier;
                    result = automationIdentifier;
                }
            }
            return(result);
        }
Beispiel #35
0
 static CaretPatternIdentifiers()
 {
     Pattern =
         new AutomationPattern(PatternId,
                               "CaretPatternIdentifiers.Pattern");
 }
Beispiel #36
0
 public static string PatternName(AutomationPattern pattern)
 {
     Utility.ValidateArgumentNonNull(pattern, "pattern");
     return(Factory.GetPatternProgrammaticName(pattern.Id));
 }