System.Windows.Automation.LegacyIAccessiblePattern.DoDefaultAction C# (CSharp) Method

DoDefaultAction() public method

public DoDefaultAction ( ) : void
return void
        public void DoDefaultAction()
        {
            try
            {
                this._pattern.DoDefaultAction();
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

Beispiel #1
0
        public static bool TryDoDefaultAction(this AutomationElement el)
        {
            if (!el.Current.IsEnabled)
            {
                return(false);
            }
            object invoke;

            if (el.TryGetCurrentPattern(InvokePattern.Pattern, out invoke))
            {
                ((InvokePattern)invoke).Invoke();
                return(true);
            }

            object legacyPattern;

            if (el.TryGetCurrentPattern(LegacyIAccessiblePattern.Pattern, out legacyPattern))
            {
                LegacyIAccessiblePattern legacy = (LegacyIAccessiblePattern)legacyPattern;
                if (legacy.Current.DefaultAction != "")
                {
                    legacy.DoDefaultAction();
                }
                return(true);
            }

            return(false);
        }