예제 #1
0
        protected override void DoImpl()
        {
            var element = GetFrameworkElement();

            if (element == null)
            {
                return;
            }

            string textValue;

            if (ValueCommandHelper.TryGetValue(element, out textValue))
            {
                SendTextResult(textValue);
                return;
            }

            var value = AutomationElementFinder.GetValueForFrameworkElement(element);

            if (value != null)
            {
                SendTextResult(value);
                return;
            }

            // if text is missing... then give up
            SendNotFoundResult(string.Format("GetValueCommand: Could not find the element : {0}", AutomationIdentifier.ToIdOrName()));
        }
예제 #2
0
        protected override void DoImpl()
        {
            var element = GetUIElement();

            if (element == null)
            {
                return;
            }

            if (ValueCommandHelper.TrySetValue(element, TextValue))
            {
                SendSuccessResult();
                return;
            }

            if (AutomationElementFinder.SetElementProperty(element, "Text", TextValue))
            {
                SendSuccessResult();
                return;
            }

            if (AutomationElementFinder.SetElementProperty(element, "Password", TextValue))
            {
                SendSuccessResult();
                return;
            }

            bool boolValue;

            if (bool.TryParse(TextValue, out boolValue))
            {
                if (AutomationElementFinder.SetElementProperty(element, "IsChecked", boolValue))
                {
                    SendSuccessResult();
                    return;
                }
            }

            int intValue;

            if (int.TryParse(TextValue, out intValue))
            {
                if (AutomationElementFinder.SetElementProperty(element, "Value", intValue))
                {
                    SendSuccessResult();
                    return;
                }
            }

            double doubleValue;

            if (double.TryParse(TextValue, out doubleValue))
            {
                if (AutomationElementFinder.SetElementProperty(element, "Value", doubleValue))
                {
                    SendSuccessResult();
                    return;
                }
            }

            DateTime dateTimeValue;

            if (DateTime.TryParse(TextValue, out dateTimeValue))
            {
                if (AutomationElementFinder.SetElementProperty(element, "Value", dateTimeValue))
                {
                    SendSuccessResult();
                    return;
                }

                if (AutomationElementFinder.SetElementProperty <DateTime?>(element, "Value", dateTimeValue))
                {
                    SendSuccessResult();
                    return;
                }
            }

            if (AutomationElementFinder.SetElementProperty(element, "Value", TextValue))
            {
                SendSuccessResult();
                return;
            }


            // if text, password IsChecked, Value are all missing... then give up
            SendNotFoundResult(string.Format("SetValueCommand: Could not set the value :{0} in control :{1}", TextValue,
                                             AutomationIdentifier.ToIdOrName()));
        }
예제 #3
0
 public void AddValueManipulator(IValueManipulator valueManipulator)
 {
     ValueCommandHelper.AddManipulator(valueManipulator);
 }