Exemplo n.º 1
0
 public UiElement()
 {
     // temporary
     // later use here an empty proxy
     _elementHolderNet = classic.AutomationElement.RootElement;
     //
     _innerElementType = InnerElementTypes.Empty;
     // _innerElementType = InnerElementTypes.AutomationElementNet;
 }
Exemplo n.º 2
0
//        public static IUiElement GetUiElementViaChildKernel(AutomationElement element, IChildKernel childKernel)
//        {
//            if (null == element) {
//                return null;
//            }
//
//            try {
//                var singleElement = new ConstructorArgument("element", element);
//                IUiElement adapterElement = childKernel.Get<IUiElement>("AutomationElement.NET", singleElement);
//
//                if (Preferences.UseElementsPatternObjectModel) {
//
//                    IUiElement proxiedTypedUiElement =
//                        ConvertToProxiedElement(
//                            adapterElement);
//
//                    proxiedTypedUiElement.SetSourceElement<AutomationElement>(element);
//
//                    return (IUiElement)proxiedTypedUiElement; // as IUiElement;
//                } else {
//
//                    adapterElement.SetSourceElement<AutomationElement>(element);
//
//                    return adapterElement;
//                }
//
//            }
//            catch (Exception eFailedToIssueElement) {
//                // TODO
//                // write error to error object!!!
//                // Console.WriteLine("Element 01 via ChildKernel");
//                // Console.WriteLine(eFailedToIssueElement.Message);
//                return null;
//            }
//        }

        public static IUiElement GetUiElement(classic.AutomationElement element)
        {
            if (null == element)
            {
                return(null);
            }

            try {
                var singleElement = new ConstructorArgument("element", element);
                // 20140122
                IUiElement adapterElement; // = Kernel.Get<IUiElement>("AutomationElement.NET", singleElement);

//                if (null != ChildKernel) {
//Console.WriteLine("child elt");
                // adapterElement = ChildKernel.Get<IUiElement>("AutomationElement.NET", singleElement);
                // var childKernel = GetChildKernel();
                // adapterElement = childKernel.Get<IUiElement>("AutomationElement.NET", singleElement);
                adapterElement = ChildKernel.Get <IUiElement>("AutomationElement.NET", singleElement);
                // childKernel.Dispose();
                // (adapterElement as UiElement).ChildKernel = childKernel;
//                } else {
//                    adapterElement = Kernel.Get<IUiElement>("AutomationElement.NET", singleElement);
//                }

                // 20140313
                // if (Preferences.UseElementsPatternObjectModel) {
                // if (Preferences.UseElementsPatternObjectModel || Preferences.UseElementsSearchObjectModel || Preferences.UseElementsCached || Preferences.UseElementsCurrent) {
                // if (Preferences.UseElementsPatternObjectModel || Preferences.UseElementsCached || Preferences.UseElementsCurrent) {
                if (Preferences.UseProxy)
                {
                    IUiElement proxiedTypedUiElement =
                        ConvertToProxiedElement(
                            adapterElement);

                    proxiedTypedUiElement.SetSourceElement <classic.AutomationElement>(element);

                    return((IUiElement)proxiedTypedUiElement); // as IUiElement;
                }
                else
                {
                    adapterElement.SetSourceElement <classic.AutomationElement>(element);

                    return(adapterElement);
                }
            }
            catch (Exception) {
                // TODO
                // write error to error object!!!
                // Console.WriteLine("Element 01");
                // Console.WriteLine(eFailedToIssueElement.Message);
                return(null);
            }
        }
Exemplo n.º 3
0
        public virtual void SetSourceElement <T>(T element)
        {
            if (element is classic.AutomationElement)
            {
                _elementHolderNet = element as classic.AutomationElement;
                _innerElementType = InnerElementTypes.AutomationElementNet;
            }
            // if com
            if (element is IUiElement)
            {
                _elementHolderAdapter = (IUiElement)element;
                _innerElementType     = InnerElementTypes.UiElement;
            }

            if (null == element)
            {
                _elementHolderNet = null;
                // com
                _elementHolderAdapter = null;
            }
        }
Exemplo n.º 4
0
 protected override void SaveEventInput(
     // 20131109
     classic.AutomationElement src,
     //IUiElement src,
     classic.AutomationEventArgs e,
     string programmaticName,
     bool infoAdded)
 {
     // inform the Wait-UiaEventRaised cmdlet
     try {
         // 20131109
         //CurrentData.LastEventSource = src; //.SourceElement; // as AutomationElement;
         // 20131112
         //CurrentData.LastEventSource = new UiElement(src);
         CurrentData.LastEventSource    = AutomationFactory.GetUiElement(src);
         CurrentData.LastEventArgs      = e; // as AutomationEventArgs;
         CurrentData.LastEventType      = programmaticName;
         CurrentData.LastEventInfoAdded = infoAdded;
     }
     catch {
         //WriteVerbose(this, "failed to register an event in the collection");
     }
 }
Exemplo n.º 5
0
 public UiElement(classic.AutomationElement element)
 {
     _elementHolderNet = element;
     _innerElementType = InnerElementTypes.AutomationElementNet;
 }