/// <summary>
        /// Handles unexpected form exception.
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <param name="expectedDestinationFormPatternMatch">The expected destination form pattern match.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        private bool HandleUnexpectedFormException(WindjammerInvalidOperationException ex, string expectedDestinationFormPatternMatch)
        {
            var result = false;

            // Failure can occur if there are more than 1 control that meets the property name/value criteria
            // Check if we have that condition and if so try to press them individually.
            if (Regex.IsMatch(ex.Message, "expected form", RegexOptions.IgnoreCase))
            {
                var actualForm = _device.ControlPanel.CurrentForm();
                if (Regex.IsMatch(actualForm, expectedDestinationFormPatternMatch, RegexOptions.IgnoreCase))
                {
                    result = true;
                }
            }
            return(result);
        }
        /// <summary>
        /// Handles possible duplicate control exception.
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <param name="propertyNameToSearch">The property name to search.</param>
        /// <param name="searchValue">The search value.</param>
        /// <param name="scrollControlName">Name of the scroll control.</param>
        /// <param name="destinationFormName">Name of the destination form.</param>
        /// <param name="ignorePopups">if set to <c>true</c> [ignore popups].</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        private bool HandlePossibleDuplicateControlException(WindjammerInvalidOperationException ex, string propertyNameToSearch, string searchValue, string scrollControlName, string destinationFormName, bool ignorePopups)
        {
            bool result = false;

            // Failure can occur if there are more than 1 control that meets the property name/value criteria
            // Check if we have that condition and if so try to press them individually.
            if (Regex.IsMatch(ex.Message, "control .* not (visible|enable)", RegexOptions.IgnoreCase))
            {
                var allControlNames = _device.ControlPanel.GetControls();
                foreach (var name in allControlNames)
                {
                    // try looking for that property name on each control
                    try
                    {
                        string propValue = _device.ControlPanel.GetProperty(name, propertyNameToSearch);
                        if (propValue.Equals(searchValue, StringComparison.OrdinalIgnoreCase))
                        {
                            try
                            {
                                PressAppButtonByName(scrollControlName, name, destinationFormName, ignorePopups);

                                // if we made it to here then we pressed the intended control
                                result = true;
                            }
                            catch (Exception)
                            {
                                // keep looking since this threw
                            }
                        }
                    }
                    catch
                    {
                        // property name was invalid for that control so ignore and move on
                    }
                }
            }
            return(result);
        }