예제 #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Initializes this object from the given from handle. </summary>
        ///
        /// <param name="handle">   The handle. </param>
        ///
        /// <returns>   . </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public static WinControlUnderTest FromHandle(IntPtr handle)
        {
            var uiaSut = new WinControlUnderTest
            {
                _handle = handle,
            };

            uiaSut.SetUnderlyingObject(null);
            if (handle != IntPtr.Zero)
            {
                uiaSut.SetUnderlyingObject(AutomationElement.FromHandle(handle));
            }
            return(uiaSut);
        }
예제 #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Initializes this object from the given from control def. </summary>
        ///
        /// <param name="controlLocatorDef">   The control def. </param>
        ///
        /// <returns>   . </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public static WinControlUnderTest FromControlDef(IControlLocatorDef controlLocatorDef, bool bCreateHandle = true)
        {
            var uiaSut = new WinControlUnderTest
            {
                _controlLocatorDef = controlLocatorDef,
            };

            uiaSut.SetUnderlyingObject(null);
            if (bCreateHandle)
            {
                var handle = controlLocatorDef.Handle;
                if (handle != IntPtr.Zero)
                {
                    uiaSut.SetUnderlyingObject(AutomationElement.FromHandle(handle));
                }
            }
            return(uiaSut);
        }