Пример #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref = "BaseProdControl" /> class.
        /// </summary>
        /// <param name = "prodWindow">The prodWindow.</param>
        /// <param name = "automationId">The automation id.</param>
        /// <remarks>
        ///     Will attempt to match AutomationId, then ReadOnly
        /// </remarks>
        public BaseProdControl(ProdWindow prodWindow, string automationId)
        {
            if (prodWindow == null)
            {
                throw new ProdOperationException("ProdWindow cannot be null");
            }

            try
            {
                /* get the element using automationID*/
                Condition cond = new PropertyCondition(AutomationElement.AutomationIdProperty, automationId);
                UIAElement = prodWindow.UIAElement.FindFirst(TreeScope.Descendants, cond);

                /* then we'll try the name...who knows? */
                if (UIAElement == null)
                {
                    /* try the name */
                    Condition condName = new PropertyCondition(AutomationElement.NameProperty, automationId, PropertyConditionFlags.IgnoreCase);
                    UIAElement = prodWindow.UIAElement.FindFirst(TreeScope.Descendants, condName);
                }
                GetSupportedProperties();
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
Пример #2
0
 /// <summary>
 ///     Initializes a new instance of the ProdUI.Controls class using the supplied handle
 /// </summary>
 /// <param name = "prodWindow">The prod window.</param>
 /// <param name = "controlHandle">Window handle of the control</param>
 internal BaseProdControl(ProdWindow prodWindow, IntPtr controlHandle)
 {
     try
     {
         UIAElement = AutomationElement.FromHandle(controlHandle);
         GetSupportedProperties();
     }
     catch (ElementNotAvailableException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
 }
Пример #3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref = "BaseProdControl" /> class.
        /// </summary>
        /// <param name = "prodWindow">The prod window.</param>
        /// <param name = "treePosition">The tree position.</param>
        public BaseProdControl(ProdWindow prodWindow, int treePosition)
        {
            if (prodWindow == null)
            {
                throw new ProdOperationException("ProdWindow cannot be null");
            }

            try
            {
                ControlTree tree = new ControlTree((IntPtr)prodWindow.UIAElement.Current.NativeWindowHandle);
                UIAElement = tree.FindElement(treePosition);
                GetSupportedProperties();
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }