Esempio n. 1
0
 public void AddStructureChangedEventHandler(IUiElement element, classic.TreeScope scope, classic.StructureChangedEventHandler eventHandler)
 {
     classic.Automation.AddStructureChangedEventHandler(
         element.GetSourceElement() as classic.AutomationElement,
         scope,
         eventHandler);
 }
Esempio n. 2
0
 public void AddAutomationPropertyChangedEventHandler(IUiElement element, classic.TreeScope scope, classic.AutomationPropertyChangedEventHandler eventHandler, params classic.AutomationProperty[] properties)
 {
     classic.Automation.AddAutomationPropertyChangedEventHandler(
         element.GetSourceElement() as classic.AutomationElement,
         scope,
         eventHandler,
         properties);
 }
        /// <summary>
        ///  /// </summary>
        /// <param name="element"></param>
        /// <param name="scope"></param>
        /// <returns></returns>
        internal static IUiElement[] GetParentOrAncestor(this IUiElement element, classic.TreeScope scope)
        {
            var walker =
                new classic.TreeWalker(
                    classic.Condition.TrueCondition);

            var ancestors =
                new List <IUiElement>();

            try {
                IUiElement testParent = AutomationFactory.GetUiElement(walker.GetParent(element.GetSourceElement() as classic.AutomationElement));

                if (scope == classic.TreeScope.Parent || scope == classic.TreeScope.Ancestors)
                {
                    if (testParent.GetCurrent() != UiElement.RootElement.GetCurrent())
                    {
                        ancestors.Add(testParent);
                    }

                    if ((testParent.Equals(UiElement.RootElement) && testParent.GetCurrent().Equals(UiElement.RootElement.GetCurrent())) ||
                        scope == classic.TreeScope.Parent)
                    {
                        return(ancestors.ToArray());
                    }
                }

                while (testParent != null &&
                       (int)testParent.GetCurrent().ProcessId > 0 &&
                       !testParent.GetCurrent().Equals(UiElement.RootElement.GetCurrent()))
                {
                    testParent =
                        AutomationFactory.GetUiElement(walker.GetParent(testParent.GetSourceElement() as classic.AutomationElement));

                    if (testParent != null &&
                        (int)testParent.GetCurrent().ProcessId > 0 &&
                        !testParent.GetCurrent().Equals(UiElement.RootElement.GetCurrent()))
                    {
                        ancestors.Add(testParent);
                    }
                    else
                    {
                        break;
                    }
                }
                return(ancestors.ToArray());
            } catch {
                return(ancestors.ToArray());
            }
        }
Esempio n. 4
0
        public virtual IUiElement FindFirst(classic.TreeScope scope, UIANET.System.Windows.Automation.Condition condition)
        {
            switch (_innerElementType)
            {
            case InnerElementTypes.AutomationElementNet:
                return(AutomationFactory.GetUiElement(_elementHolderNet.FindFirst(scope, condition)));

//                case InnerElementTypes.AutomationElementCom:
//                    //
            case InnerElementTypes.UiElement:
                return(_elementHolderAdapter.FindFirst(scope, condition));

            default:
                return(AutomationFactory.GetUiElement(_elementHolderNet.FindFirst(scope, condition)));
            }
        }
Esempio n. 5
0
        // internal static
        #endregion Common objects

        #region IUiElement
        // 20140210
        internal static IExtendedModelHolder GetUiExtendedModelHolder(IUiElement parentElement, classic.TreeScope scope)
        // internal static IExtendedModelHolder GetUiExtendedModelHolder(IUiElement parentElement, TreeScope scope, int seconds)
        {
            if (null == parentElement)
            {
                return(null);
            }

            try {
                // 20140122
                // IExtendedModelHolder holder = Kernel.Get<IExtendedModelHolder>(new IParameter[] {});
                IExtendedModelHolder holder;
//                if (null != ChildKernel) {
                // holder = ChildKernel.Get<IExtendedModelHolder>(new IParameter[] {});
                // var childKernel = GetChildKernel();
//                    if (null == (parentElement as UiElement).ChildKernel) {
//                        (parentElement as UiElement).ChildKernel = GetChildKernel();
//                    }
                // holder = childKernel.Get<IExtendedModelHolder>(new IParameter[] {});
                // holder = (parentElement as UiElement).ChildKernel.Get<IExtendedModelHolder>(new IParameter[] {});
                // childKernel.Dispose();

                // 20140210
                holder = ChildKernel.Get <IExtendedModelHolder>(new IParameter[] {});
                // var paramSeconds = new ConstructorArgument("seconds", seconds);
                // holder = ChildKernel.Get<IExtendedModelHolder>(paramSeconds);

                // (parentElement as UiElement).ChildKernel.Dispose();
//                } else {
//                    holder = Kernel.Get<IExtendedModelHolder>(new IParameter[] {});
//                }

                var proxiedHolder =
                    (IExtendedModelHolder)_generator.CreateClassProxy(
                        typeof(UiExtendedModelHolder),
                        new Type[] { typeof(IExtendedModel) },
                        new MethodSelectorAspect());

                proxiedHolder.SetScope(scope);

                proxiedHolder.SetParentElement(parentElement);

                return(proxiedHolder);
            }
            catch (Exception) {
                // TODO
                // write error to error object!!!
                // Console.WriteLine("Holder");
                // Console.WriteLine(eFailedToIssueHolder.Message);
                return(null);
            }
        }
 public void SetScope(classic.TreeScope scope)
 {
     _scope = scope;
 }
Esempio n. 7
0
 public void SetScope(classic.TreeScope scope)
 {
     _scope = scope;
 }
Esempio n. 8
0
 public void AddAutomationEventHandler(classic.AutomationEvent eventId, IUiElement element, classic.TreeScope scope, classic.AutomationEventHandler eventHandler)
 {
     classic.Automation.AddAutomationEventHandler(
         eventId,
         element.GetSourceElement() as classic.AutomationElement,
         scope,
         eventHandler);
 }
        protected void GetAutomationElements(classic.TreeScope scope)
        {
            if (!CheckAndPrepareInput(this))
            {
                return;
            }

            foreach (IUiElement inputObject in InputObject)
            {
                var searchResults =
                    new List <IUiElement>();

                if (scope == classic.TreeScope.Children ||
                    scope == classic.TreeScope.Descendants)
                {
                    // WriteVerbose(this, "selected TreeScope." + scope.ToString());

                    var controlSearch =
                        AutomationFactory.GetSearcherImpl <ControlSearcher>() as ControlSearcher;

                    classic.Condition conditions =
                        ControlSearcher.GetWildcardSearchCondition(
                            controlSearch.ConvertCmdletToControlSearcherData(this));

                    IUiEltCollection temporaryResults = null;
                    if (conditions != null)
                    {
                        temporaryResults =
                            inputObject.FindAll(
                                scope,
                                conditions);

                        searchResults.AddRange(temporaryResults.Cast <IUiElement>());
                    }
                    else
                    {
                        // WriteVerbose(this, "no conditions. Performing search with TrueCondition");
                        temporaryResults =
                            inputObject.FindAll(
                                scope,
                                classic.Condition.TrueCondition);
                        if (temporaryResults.Count > 0)
                        {
//                            WriteVerbose(this,
//                                         "returned " +
//                                         temporaryResults.Count.ToString() +
//                                         " results");
                            searchResults.AddRange(temporaryResults.Cast <IUiElement>());
                        }
                    }
                    // WriteVerbose(this, "results found: " + searchResults.Count.ToString());
                    WriteObject(this, searchResults.ToArray());
                }

                if (null != searchResults)
                {
                    searchResults.Clear();
                    searchResults = null;
                }

                if (scope != classic.TreeScope.Parent && scope != classic.TreeScope.Ancestors)
                {
                    continue;
                }

                IUiElement[] outResult = inputObject.GetParentOrAncestor(scope);
                WriteObject(this, outResult);

                if (null != outResult)
                {
                    outResult = null;
                }
            }
        }