ITextRangeProvider ITextRangeProvider.FindAttribute(int attributeId, object val, bool backwards)
        {
            AutomationTextAttribute attribute = AutomationTextAttribute.LookupById(attributeId);
            // generic controls are plain text so if the attribute matches then it matches over the whole range.

            // To workaround the conversion that Marshaling of COM-interop did.
            object targetAttribute = GetAttributeValue(attribute);

            if (targetAttribute is Enum)
            {
                targetAttribute = (int)targetAttribute;
            }

            return(val.Equals(targetAttribute) ? new WindowsEditBoxRange(_provider, Start, End) : null);
        }
Пример #2
0
        public void BackgroundColorAttributeTest()
        {
            AutomationTextAttribute myBackgroundColorAttribute =
                TextPatternIdentifiers.BackgroundColorAttribute;

            Assert.IsNotNull(
                myBackgroundColorAttribute,
                "Field must not be null.");
            Assert.AreEqual(
                40001,
                myBackgroundColorAttribute.Id,
                "Id");
            Assert.AreEqual(
                "TextPatternIdentifiers.BackgroundColorAttribute",
                myBackgroundColorAttribute.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myBackgroundColorAttribute,
                AutomationTextAttribute.LookupById(myBackgroundColorAttribute.Id),
                "LookupById");
        }
Пример #3
0
        public void UnderlineStyleAttributeTest()
        {
            AutomationTextAttribute myUnderlineStyleAttribute =
                TextPatternIdentifiers.UnderlineStyleAttribute;

            Assert.IsNotNull(
                myUnderlineStyleAttribute,
                "Field must not be null.");
            Assert.AreEqual(
                40030,
                myUnderlineStyleAttribute.Id,
                "Id");
            Assert.AreEqual(
                "TextPatternIdentifiers.UnderlineStyleAttribute",
                myUnderlineStyleAttribute.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myUnderlineStyleAttribute,
                AutomationTextAttribute.LookupById(myUnderlineStyleAttribute.Id),
                "LookupById");
        }
Пример #4
0
        public void TextFlowDirectionsAttributeTest()
        {
            AutomationTextAttribute myTextFlowDirectionsAttribute =
                TextPatternIdentifiers.TextFlowDirectionsAttribute;

            Assert.IsNotNull(
                myTextFlowDirectionsAttribute,
                "Field must not be null.");
            Assert.AreEqual(
                40028,
                myTextFlowDirectionsAttribute.Id,
                "Id");
            Assert.AreEqual(
                "TextPatternIdentifiers.TextFlowDirectionsAttribute",
                myTextFlowDirectionsAttribute.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myTextFlowDirectionsAttribute,
                AutomationTextAttribute.LookupById(myTextFlowDirectionsAttribute.Id),
                "LookupById");
        }
Пример #5
0
        public void MarginTrailingAttributeTest()
        {
            AutomationTextAttribute myMarginTrailingAttribute =
                TextPatternIdentifiers.MarginTrailingAttribute;

            Assert.IsNotNull(
                myMarginTrailingAttribute,
                "Field must not be null.");
            Assert.AreEqual(
                40021,
                myMarginTrailingAttribute.Id,
                "Id");
            Assert.AreEqual(
                "TextPatternIdentifiers.MarginTrailingAttribute",
                myMarginTrailingAttribute.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myMarginTrailingAttribute,
                AutomationTextAttribute.LookupById(myMarginTrailingAttribute.Id),
                "LookupById");
        }
Пример #6
0
        public void HorizontalTextAlignmentAttributeTest()
        {
            AutomationTextAttribute myHorizontalTextAlignmentAttribute =
                TextPatternIdentifiers.HorizontalTextAlignmentAttribute;

            Assert.IsNotNull(
                myHorizontalTextAlignmentAttribute,
                "Field must not be null.");
            Assert.AreEqual(
                40009,
                myHorizontalTextAlignmentAttribute.Id,
                "Id");
            Assert.AreEqual(
                "TextPatternIdentifiers.HorizontalTextAlignmentAttribute",
                myHorizontalTextAlignmentAttribute.ProgrammaticName,
                "ProgrammaticName");
            Assert.AreEqual(
                myHorizontalTextAlignmentAttribute,
                AutomationTextAttribute.LookupById(myHorizontalTextAlignmentAttribute.Id),
                "LookupById");
        }
        object ITextRangeProvider.GetAttributeValue(int attributeId)
        {
            AutomationTextAttribute attribute = AutomationTextAttribute.LookupById(attributeId);

            return(GetAttributeValue(attribute));
        }
Пример #8
0
 public object GetAttributeValue(int attribute)
 {
     return(GetAttributeValue(AutomationTextAttribute.LookupById(attribute)));
 }