//------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
 
        #region Constructors

        internal AutomationAttributeInfo( 
            AutomationPropertyConverter converter,
            AutomationTextAttribute id,
            Type type
            )
        {
            _id = id;
            _type = type;
            _converter = converter;
        }
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        internal static AutomationIdentifier Register(UiaCoreTypesApi.AutomationIdType type, int id, string programmaticName)
        {
            // Keep past behavior, if the id is not supported by the current OS, return null
            if (!IsIdSupported(type, id))
            {
                return(null);
            }
            lock (_idTable)
            {
                // See if instance already exists...
                AutomationIdentifier autoid = (AutomationIdentifier)_idTable[id];
                if (autoid != null)
                {
                    return(autoid);
                }

                // If not, create one...
                switch (type)
                {
                case UiaCoreTypesApi.AutomationIdType.Property:      autoid = new AutomationProperty(id, programmaticName);      break;

                case UiaCoreTypesApi.AutomationIdType.Event:         autoid = new AutomationEvent(id, programmaticName);         break;

                case UiaCoreTypesApi.AutomationIdType.TextAttribute: autoid = new AutomationTextAttribute(id, programmaticName); break;

                case UiaCoreTypesApi.AutomationIdType.Pattern:       autoid = new AutomationPattern(id, programmaticName);       break;

                case UiaCoreTypesApi.AutomationIdType.ControlType:   autoid = new ControlType(id, programmaticName);             break;

                default: Debug.Assert(false, "Invalid type specified for AutomationIdentifier");
                    throw new InvalidOperationException("Invalid type specified for AutomationIdentifier");
                }

                _idTable[id] = autoid;
                return(autoid);
            }
        }
        static internal void SetWrongValueNotSupported(ref object value, AutomationTextAttribute key)
        {
            int intType = 0;     // actual values for these variables is not relevant
            bool boolType = false; // We just need the type, and for that we need an instance
            double doubleType = 0;     // of each type
            double[] doubleArrayType = new double[0];
            string stringType = "";
            AnimationStyle animationStyleType = AnimationStyle.BlinkingBackground;
            BulletStyle bulletStyleType = BulletStyle.DashBullet;
            CapStyle capStyleType = CapStyle.AllCap;
            CultureInfo cultureInfoType = new CultureInfo(CultureInfo.CurrentCulture.ToString());
            HorizontalTextAlignment horizontalTextAlignmentType = HorizontalTextAlignment.Centered;
            OutlineStyles outlineStylesType = OutlineStyles.Shadow;
            TextDecorationLineStyle textDecorationLineStyleType = TextDecorationLineStyle.Dash;
            FlowDirections flowDirectionsType = FlowDirections.Default;

            // Switch statement requires integral types, have to use a massive if-else instead.
            if (key == TextPattern.AnimationStyleAttribute)
            {
                value = (object)animationStyleType;
            }
            else if ((key == TextPattern.IsHiddenAttribute)
                  || (key == TextPattern.IsItalicAttribute)
                  || (key == TextPattern.IsReadOnlyAttribute)
                  || (key == TextPattern.IsSubscriptAttribute)
                  || (key == TextPattern.IsSuperscriptAttribute))
            {
                value = (object)boolType;
            }
            else if (key == TextPattern.BulletStyleAttribute)
            {
                value = (object)bulletStyleType;
            }
            else if (key == TextPattern.CapStyleAttribute)
            {
                value = (object)capStyleType;
            }
            else if (key == TextPattern.CultureAttribute)
            {
                value = (object)cultureInfoType;
            }
            else if ((key == TextPattern.FontSizeAttribute)
                  || (key == TextPattern.IndentationFirstLineAttribute)
                  || (key == TextPattern.IndentationLeadingAttribute)
                  || (key == TextPattern.IndentationTrailingAttribute)
                  || (key == TextPattern.MarginBottomAttribute)
                  || (key == TextPattern.MarginLeadingAttribute)
                  || (key == TextPattern.MarginTopAttribute)
                  || (key == TextPattern.MarginTrailingAttribute))
            {
                value = (object)doubleType;
            }
            else if (key == TextPattern.TabsAttribute)
            {
                value = (object)doubleArrayType;
            }
            else if (key == TextPattern.TextFlowDirectionsAttribute)
            {
                value = (object)flowDirectionsType;
            }
            else if (key == TextPattern.HorizontalTextAlignmentAttribute)
            {
                value = (object)horizontalTextAlignmentType;
            }
            else if ((key == TextPattern.BackgroundColorAttribute)
                  || (key == TextPattern.FontWeightAttribute)
                  || (key == TextPattern.ForegroundColorAttribute)
                  || (key == TextPattern.StrikethroughColorAttribute)
                  || (key == TextPattern.UnderlineColorAttribute)
                  || (key == TextPattern.OverlineColorAttribute))
            {
                value = (object)intType;
            }
            else if (key == TextPattern.OutlineStylesAttribute)
            {
                value = (object)outlineStylesType;
            }
            else if (key == TextPattern.FontNameAttribute)
            {
                value = (object)stringType;
            }
            else if ((key == TextPattern.OverlineStyleAttribute)
                  || (key == TextPattern.StrikethroughStyleAttribute)
                  || (key == TextPattern.UnderlineStyleAttribute))
            {
                value = (object)textDecorationLineStyleType;
            }
            else
            {
                throw new ArgumentException("CastAttributeToCorrectType() has no support for AutomationTextAttribute " + Helpers.GetProgrammaticName(key));
            }
        }
        static internal void SetWrongValue(ref object value, AutomationTextAttribute key)
        {
            double[] doubleArray = new double[0];
            string typeString = value.GetType().ToString();

            // If not supported, goto separate helper method
            if (value == AutomationElement.NotSupported)
            {
                SetWrongValueNotSupported(ref value, key);
            }
            else
            {
                switch (typeString)
                {
                    case "System.Windows.Automation.AutomationIdentifier":  // Do nothing, not supported by control
                        break;
                    case "System.Double[]":
                        doubleArray = (double[])value;
                        for (int i = 0; i < doubleArray.Length; i++)
                            doubleArray[i] = doubleArray[i] + 1;
                        value = (object)doubleArray;
                        break;
                    case "System.Int32":
                        value = (object)(((int)value) + 1);
                        break;
                    case "System.Boolean":
                        value = (object)(!((bool)value));
                        break;
                    case "System.Double":
                        value = (object)(((double)value) + 1);
                        break;
                    case "System.String":
                        value = (object)(((string)value) + "x");
                        break;
                    case "System.Windows.Automation.Text.AnimationStyle":
                        if (((AnimationStyle)value) == AnimationStyle.BlinkingBackground)
                            value = (object)AnimationStyle.LasVegasLights;
                        else
                            value = (object)AnimationStyle.BlinkingBackground;
                        break;
                    case "System.Windows.Automation.Text.BulletStyle":
                        if (((BulletStyle)value) == BulletStyle.DashBullet)
                            value = (object)BulletStyle.FilledRoundBullet;
                        else
                            value = (object)BulletStyle.DashBullet;
                        break;
                    case "System.Windows.Automation.Text.CapStyle":
                        if (((CapStyle)value) == CapStyle.AllCap)
                            value = (object)CapStyle.AllPetiteCaps;
                        else
                            value = (object)CapStyle.AllCap;
                        break;
                    case "System.Windows.Automation.Text.HorizontalTextAlignment":
                        if (((HorizontalTextAlignment)value) == HorizontalTextAlignment.Centered)
                            value = (object)HorizontalTextAlignment.Justified;
                        else
                            value = (object)HorizontalTextAlignment.Centered;
                        break;
                    case "System.Windows.Automation.Text.OutlineStyles":
                        if (((OutlineStyles)value) == OutlineStyles.Shadow)
                            value = (object)OutlineStyles.Outline;
                        else
                            value = (object)OutlineStyles.Shadow;
                        break;
                    case "System.Windows.Automation.Text.TextDecorationLineStyle":
                        if (((TextDecorationLineStyle)value) == TextDecorationLineStyle.Dash)
                            value = (object)TextDecorationLineStyle.DashDot;
                        else
                            value = (object)TextDecorationLineStyle.Dash;
                        break;
                    case "System.Windows.Automation.Text.FlowDirections":
                        if (((FlowDirections)value) == FlowDirections.BottomToTop)
                            value = (object)FlowDirections.Default;
                        else
                            value = (object)FlowDirections.BottomToTop;
                        break;
                    case "System.Globalization.CultureInfo":
                    default:
                        throw new ArgumentException("SetWrongValue has no support for " + typeString);
                }
            }
        }
        static internal void SetValue(TypeValue typeValue, AutomationTextAttribute key, ref object value)
        {
            switch (typeValue)
            {
                case TypeValue.MatchesTypeAndValue:                      // CORRECT type and value
                case TypeValue.WrongValue:                               // CORRECT type: INCORRECT value
                case TypeValue.WrongEnumValue:                           // Incorrect enum value
                    break; // Do nothing, casts that follow below will work
                case TypeValue.Null:                                     // NULL
                case TypeValue.WrongTypeAndValue:                        // INCORRECT type and value
                case TypeValue.WrongType:                                // INCORRECT type: CORRECT value
                    // no casts, we're done, type is handled elsewhere
                    return;
                default:
                    throw new ArgumentException("No support for " + ParseType(typeValue));
            }

            // Switch statement requires integral types, have to use a massive if-else instead.
            if (key == TextPattern.AnimationStyleAttribute)
            {
                value = (AnimationStyle)value;
            }
            else if ((key == TextPattern.IsHiddenAttribute)
                  || (key == TextPattern.IsItalicAttribute)
                  || (key == TextPattern.IsReadOnlyAttribute)
                  || (key == TextPattern.IsSubscriptAttribute)
                  || (key == TextPattern.IsSuperscriptAttribute))
            {
                value = (bool)value;
            }
            else if (key == TextPattern.BulletStyleAttribute)
            {
                value = (BulletStyle)value;
            }
            else if (key == TextPattern.CapStyleAttribute)
            {
                value = (CapStyle)value;
            }
            else if (key == TextPattern.CultureAttribute)
            {
                value = (CultureInfo)value;
            }
            else if ((key == TextPattern.FontSizeAttribute)
                  || (key == TextPattern.IndentationFirstLineAttribute)
                  || (key == TextPattern.IndentationLeadingAttribute)
                  || (key == TextPattern.IndentationTrailingAttribute)
                  || (key == TextPattern.MarginBottomAttribute)
                  || (key == TextPattern.MarginLeadingAttribute)
                  || (key == TextPattern.MarginTopAttribute)
                  || (key == TextPattern.MarginTrailingAttribute))
            {
                value = (double)value;
            }
            else if (key == TextPattern.TabsAttribute)
            {
                value = (double[])value;
            }
            else if (key == TextPattern.TextFlowDirectionsAttribute)
            {
                value = (FlowDirections)value;
            }
            else if (key == TextPattern.HorizontalTextAlignmentAttribute)
            {
                value = (HorizontalTextAlignment)value;
            }
            else if ((key == TextPattern.BackgroundColorAttribute)
                  || (key == TextPattern.FontWeightAttribute)
                  || (key == TextPattern.ForegroundColorAttribute)
                  || (key == TextPattern.StrikethroughColorAttribute)
                  || (key == TextPattern.UnderlineColorAttribute)
                  || (key == TextPattern.OverlineColorAttribute))
            {
                value = (int)value;
            }
            else if (key == TextPattern.OutlineStylesAttribute)
            {
                value = (OutlineStyles)value;
            }
            else if (key == TextPattern.FontNameAttribute)
            {
                value = (string)value;
            }
            else if ((key == TextPattern.OverlineStyleAttribute)
                  || (key == TextPattern.StrikethroughStyleAttribute)
                  || (key == TextPattern.UnderlineStyleAttribute))
            {
                value = (TextDecorationLineStyle)value;
            }
            else
            {
                throw new ArgumentException("SetValue() has no support for AutomationTextAttribute " + Helpers.GetProgrammaticName(key));
            }
        }
示例#6
0
		public object GetAttributeValue (AutomationTextAttribute attribute)
		{
			int start, end;
			IDictionary<string, string> attributes = text.GetAttributeRun (startOffset, out start, out end, true);
			string val;
			if (attributes == null)
				return null;
			if (end < endOffset)
				return TextPattern.MixedAttributeValue;

			if (attribute.Id == TextPattern.FontWeightAttribute.Id &&
				attributes.TryGetValue ("weight", out val)) {
				if (val == "bold")
					return 400;
				return Int32.Parse (val);
			} else if (attribute.Id == TextPattern.BackgroundColorAttribute.Id &&
				attributes.TryGetValue ("bg-color", out val)) {
				Match m = parse_color.Match (val);
				if (m.Success) {
					int v1, v2, v3;
					v1 = Int32.Parse (m.Groups [1].ToString ());
					v2 = Int32.Parse (m.Groups [2].ToString ());
					v3 = Int32.Parse (m.Groups [3].ToString ());
					return (v1 << 16) + (v2 << 8) + v3;
				}
			} else if (attribute.Id == TextPattern.ForegroundColorAttribute.Id &&
				attributes.TryGetValue ("fg-color", out val)) {
				Match m = parse_color.Match (val);
				if (m.Success) {
					int v1, v2, v3;
					v1 = Int32.Parse (m.Groups [1].ToString ());
					v2 = Int32.Parse (m.Groups [2].ToString ());
					v3 = Int32.Parse (m.Groups [3].ToString ());
					return (v1 << 16) + (v2 << 8) + v3;
				}
			} else if (attribute.Id == TextPattern.FontNameAttribute.Id &&
				attributes.TryGetValue ("family-name", out val)) {
				return val;
			} else if (attribute.Id == TextPattern.FontSizeAttribute.Id &&
				attributes.TryGetValue ("size", out val)) {
				return Int32.Parse (val);
			} else if (attribute.Id == TextPattern.IsItalicAttribute.Id) {
				if (attributes.TryGetValue ("font-size", out val))
					return (val == "italic");
				return false;
			}
			Log.Debug ("TODO: GetAttributeValue for " + attribute.ProgrammaticName);
			return null;
		}
示例#7
0
        //---------------------------------------------------------------------------
        // Wrapper for TextPatternRange.FindAttribute Method
        //---------------------------------------------------------------------------
        internal void Range_FindAttribute(TextPatternRange callingRange, ref TextPatternRange targetRange, AutomationTextAttribute attrib, object val, bool backward, Type expectedException, CheckType checkType)
        {
            string call = "";
            if (attrib != null)
                call = "TextPatternRange.FindAttribute(" + Helpers.GetProgrammaticName(attrib) + ", " + (val == null ? "NULL" : val.ToString()) + ", " + backward + ")";
            else
                call = "TextPatternRange.FindAttribute(NULL," + (val == null ? "NULL" : val.ToString()) + ", " + backward + ")";
            Comment("---Calling " + call);

            if (callingRange == null)
                throw new ArgumentNullException(call + " requires non-NULL TextPatterncallingRange");

            try
            {
                targetRange = callingRange.FindAttribute(attrib, val, backward);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(expectedException, actualException, call, checkType);
                return;
            }
            TestNoExceptionQuiet(expectedException, call, checkType);
        }
示例#8
0
		static TextPatternIdentifiers ()
		{
			MixedAttributeValue = new object ();

			Pattern =
				new AutomationPattern (PatternId,
				                       "TextPatternIdentifiers.Pattern");
			CaretMovedEvent = 
				new AutomationEvent (CaretMovedEventId,
				                     "TextPatternIdentifiers.CaretMovedEvent");
			TextChangedEvent = 
				new AutomationEvent (TextChangedEventId,
				                     "TextPatternIdentifiers.TextChangedEvent");
			TextSelectionChangedEvent = 
				new AutomationEvent (TextSelectionChangedEventId,
				                     "TextPatternIdentifiers.TextSelectionChangedEvent");

			AnimationStyleAttribute =
				new AutomationTextAttribute (AnimationStyleAttributeId,
			                                     "TextPatternIdentifiers.AnimationStyleAttribute");
			BackgroundColorAttribute =
				new AutomationTextAttribute (BackgroundColorAttributeId,
			                                     "TextPatternIdentifiers.BackgroundColorAttribute");
			BulletStyleAttribute =
				new AutomationTextAttribute (BulletStyleAttributeId,
			                                     "TextPatternIdentifiers.BulletStyleAttribute");
			CapStyleAttribute =
				new AutomationTextAttribute (CapStyleAttributeId,
			                                     "TextPatternIdentifiers.CapStyleAttribute");
			CultureAttribute =
				new AutomationTextAttribute (CultureAttributeId,
			                                     "TextPatternIdentifiers.CultureAttribute");
			FontNameAttribute =
				new AutomationTextAttribute (FontNameAttributeId,
			                                     "TextPatternIdentifiers.FontNameAttribute");
			FontSizeAttribute =
				new AutomationTextAttribute (FontSizeAttributeId,
			                                     "TextPatternIdentifiers.FontSizeAttribute");
			FontWeightAttribute =
				new AutomationTextAttribute (FontWeightAttributeId,
			                                     "TextPatternIdentifiers.FontWeightAttribute");
			ForegroundColorAttribute =
				new AutomationTextAttribute (ForegroundColorAttributeId,
			                                     "TextPatternIdentifiers.ForegroundColorAttribute");
			HorizontalTextAlignmentAttribute =
				new AutomationTextAttribute (HorizontalTextAlignmentAttributeId,
			                                     "TextPatternIdentifiers.HorizontalTextAlignmentAttribute");
			IndentationFirstLineAttribute =
				new AutomationTextAttribute (IndentationFirstLineAttributeId,
			                                     "TextPatternIdentifiers.IndentationFirstLineAttribute");
			IndentationLeadingAttribute =
				new AutomationTextAttribute (IndentationLeadingAttributeId,
			                                     "TextPatternIdentifiers.IndentationLeadingAttribute");
			IndentationTrailingAttribute =
				new AutomationTextAttribute (IndentationTrailingAttributeId,
			                                     "TextPatternIdentifiers.IndentationTrailingAttribute");
			IsHiddenAttribute =
				new AutomationTextAttribute (IsHiddenAttributeId,
			                                     "TextPatternIdentifiers.IsHiddenAttribute");
			IsItalicAttribute =
				new AutomationTextAttribute (IsItalicAttributeId,
			                                     "TextPatternIdentifiers.IsItalicAttribute");
			IsReadOnlyAttribute =
				new AutomationTextAttribute (IsReadOnlyAttributeId,
			                                     "TextPatternIdentifiers.IsReadOnlyAttribute");
			IsSubscriptAttribute =
				new AutomationTextAttribute (IsSubscriptAttributeId,
			                                     "TextPatternIdentifiers.IsSubscriptAttribute");
			IsSuperscriptAttribute =
				new AutomationTextAttribute (IsSuperscriptAttributeId,
			                                     "TextPatternIdentifiers.IsSuperscriptAttribute");
			MarginBottomAttribute =
				new AutomationTextAttribute (MarginBottomAttributeId,
			                                     "TextPatternIdentifiers.MarginBottomAttribute");
			MarginLeadingAttribute =
				new AutomationTextAttribute (MarginLeadingAttributeId,
			                                     "TextPatternIdentifiers.MarginLeadingAttribute");
			MarginTopAttribute =
				new AutomationTextAttribute (MarginTopAttributeId,
			                                     "TextPatternIdentifiers.MarginTopAttribute");
			MarginTrailingAttribute =
				new AutomationTextAttribute (MarginTrailingAttributeId,
			                                     "TextPatternIdentifiers.MarginTrailingAttribute");
			OutlineStylesAttribute =
				new AutomationTextAttribute (OutlineStylesAttributeId,
			                                     "TextPatternIdentifiers.OutlineStylesAttribute");
			OverlineColorAttribute =
				new AutomationTextAttribute (OverlineColorAttributeId,
			                                     "TextPatternIdentifiers.OverlineColorAttribute");
			OverlineStyleAttribute =
				new AutomationTextAttribute (OverlineStyleAttributeId,
			                                     "TextPatternIdentifiers.OverlineStyleAttribute");
			StrikethroughColorAttribute =
				new AutomationTextAttribute (StrikethroughColorAttributeId,
			                                     "TextPatternIdentifiers.StrikethroughColorAttribute");
			StrikethroughStyleAttribute =
				new AutomationTextAttribute (StrikethroughStyleAttributeId,
			                                     "TextPatternIdentifiers.StrikethroughStyleAttribute");
			TabsAttribute =
				new AutomationTextAttribute (TabsAttributeId,
			                                     "TextPatternIdentifiers.TabsAttribute");
			TextFlowDirectionsAttribute =
				new AutomationTextAttribute (TextFlowDirectionsAttributeId,
			                                     "TextPatternIdentifiers.TextFlowDirectionsAttribute");
			UnderlineColorAttribute =
				new AutomationTextAttribute (UnderlineColorAttributeId,
			                                     "TextPatternIdentifiers.UnderlineColorAttribute");
			UnderlineStyleAttribute =
				new AutomationTextAttribute (UnderlineStyleAttributeId,
			                                     "TextPatternIdentifiers.UnderlineStyleAttribute");
		}
示例#9
0
        private ITextRangeProvider FindAttributeBackwards(AutomationTextAttribute attribute, object val, TomUnit unit)
        {
            // this works just like FindAttributeForwards except we work our way backward through the range.

            // we accumulate the resulting subrange with these two endpoints:
            const int NoMatchYet = -1;
            int start = NoMatchYet; // a character position that is extended each time we find another matching subrange.
            int end = NoMatchYet; // set to a character position when we find the beginning of the match.

            // examine each subrange of uniform formatting until we reach the end of our range.
            // if we complete a match within the range we will break out of the middle of the loop.
            int limit = _range.Start; // cache the limit of our search range.
            ITextRange subrange = LastUnit(_range);
            while (PreviousUnit(limit, subrange, unit))
            {
                // if this subrange of values has a matching attribute then add it to
                // our resulting subrange.
                object subrangeVal = GetAttributeValueForRange(subrange, attribute);
                if (AttributeValuesAreEqual(val, subrangeVal))
                {
                    // set the start pointer if this is the first matching subrange.
                    if (end == NoMatchYet)
                    {
                        end = subrange.End;
                    }

                    // update the start of the matching subrange to include the current one.
                    start = subrange.Start;
                }
                else
                {
                    // no match.

                    // if we have found a matching subrange then we're done.
                    if (end != NoMatchYet)
                    {
                        break;
                    }
                }
            }

            // if we have a matching subrange then return it, otherwise return null.
            if (end != NoMatchYet)
            {
                subrange.SetRange(start, end);
                return new WindowsRichEditRange(subrange, _pattern);
            }
            else
            {
                return null;
            }
        }
示例#10
0
        private object GetAttributeValueForRange(ITextRange range, AutomationTextAttribute attribute)
        {
            // conditional attributes that we aren't implementing this version are commented out.

            object rval;
            if (attribute == TextPattern.AnimationStyleAttribute) { rval = GetAnimationStyle(range.Font); }
            else if (attribute == TextPattern.BackgroundColorAttribute) { rval = GetBackgroundColor(range.Font); }
            else if (attribute == TextPattern.BulletStyleAttribute) { rval = GetBulletStyle(range.Para); }
            else if (attribute == TextPattern.CapStyleAttribute) { rval = GetCapStyle(range.Font); }
//            else if (attribute == TextPattern.CompositionStateAttribute) { rval = GetCompositionState(range.Font, range.Para); }
//            else if (attribute == TextPattern.CultureAttribute) { rval = GetCulture(range.Font, range.Para); }
            else if (attribute == TextPattern.FontNameAttribute) { rval = GetFontName(range); }
            else if (attribute == TextPattern.FontSizeAttribute) { rval = GetFontSize(range.Font); }
            else if (attribute == TextPattern.FontWeightAttribute) { rval = GetFontWeight(range.Font); }
            else if (attribute == TextPattern.ForegroundColorAttribute) { rval = GetForegroundColor(range.Font); }
//            else if (attribute == TextPattern.HeadingLevelAttribute) { rval = GetHeadingLevel(range.Font, range.Para); }
            else if (attribute == TextPattern.HorizontalTextAlignmentAttribute) { rval = GetHorizontalTextAlignment(range.Para); }
            else if (attribute == TextPattern.IndentationFirstLineAttribute) { rval = GetIndentationFirstLine(range.Para); }
            else if (attribute == TextPattern.IndentationLeadingAttribute) { rval = GetIndentationLeading(range.Para); }
            else if (attribute == TextPattern.IndentationTrailingAttribute) { rval = GetIndentationTrailing(range.Para); }
            else if (attribute == TextPattern.IsHiddenAttribute) { rval = GetHidden(range.Font); }
            else if (attribute == TextPattern.IsItalicAttribute) { rval = GetItalic(range.Font); }
            else if (attribute == TextPattern.IsReadOnlyAttribute) { rval = GetReadOnly(range.Font); }
            else if (attribute == TextPattern.IsSubscriptAttribute) { rval = GetSubscript(range.Font); }
            else if (attribute == TextPattern.IsSuperscriptAttribute) { rval = GetSuperscript(range.Font); }
//            else if (attribute == TextPattern.MarginBottomAttribute) { rval = GetMarginBottom(range.Font, range.Para); }
//            else if (attribute == TextPattern.MarginLeadingAttribute) { rval = GetMarginLeading(range.Font, range.Para); }
//            else if (attribute == TextPattern.MarginTopAttribute) { rval = GetMarginTop(range.Font, range.Para); }
//            else if (attribute == TextPattern.MarginTrailingAttribute) { rval = GetMarginTrailing(range.Font, range.Para); }
//            else if (attribute == TextPattern.MarkedAutoCorrectedAttribute) { rval = GetMarkedAutoCorrected(range.Font, range.Para); }
//            else if (attribute == TextPattern.MarkedGrammaticallyWrongAttribute) { rval = GetMarkedGrammaticallyWrong(range.Font, range.Para); }
//            else if (attribute == TextPattern.MarkedMisspelledAttribute) { rval = GetMarkedMisspelled(range.Font, range.Para); }
//            else if (attribute == TextPattern.MarkedSmartTagAttribute) { rval = GetMarkedSmartTag(range.Font, range.Para); }
//            else if (attribute == TextPattern.OrderedListStringAttribute) { rval = GetOrderedListString(range.Font, range.Para); }
            else if (attribute == TextPattern.OutlineStylesAttribute) { rval = GetOutlineStyles(range.Font); }
//            else if (attribute == TextPattern.OverlineColorAttribute) { rval = GetOverlineColor(range.Font); }
//            else if (attribute == TextPattern.OverlineStyleAttribute) { rval = GetOverlineStyle(range.Font); }
//            else if (attribute == TextPattern.PageHeightAttribute) { rval = GetPageHeight(range.Font, range.Para); }
//            else if (attribute == TextPattern.PageNumberAttribute) { rval = GetPageNumber(range.Font, range.Para); }
//            else if (attribute == TextPattern.PageWidthAttribute) { rval = GetPageWidth(range.Font, range.Para); }
//            else if (attribute == TextPattern.PortraitAttribute) { rval = GetPortrait(range.Font, range.Para); }
//            else if (attribute == TextPattern.StrikethroughColorAttribute) { rval = GetStrikethroughColor(range.Font); }
            else if (attribute == TextPattern.StrikethroughStyleAttribute) { rval = GetStrikethroughStyle(range.Font); }
            else if (attribute == TextPattern.TabsAttribute) { rval = GetTabs(range.Para); }
//            else if (attribute == TextPattern.TextFlowDirectionAttribute) { rval = GetTextFlowDirection(range.Font, range.Para); }
//            else if (attribute == TextPattern.UnderlineColorAttribute) { rval = GetUnderlineColor(range.Font); }
            else if (attribute == TextPattern.UnderlineStyleAttribute) { rval = GetUnderlineStyle(range.Font); }
//            else if (attribute == TextPattern.VerticalTextAlignmentAttribute) { rval = GetVerticalTextAlignment(range.Font, range.Para); }
            else
            {
                rval = AutomationElement.NotSupported;
            }
            return rval;
        }
示例#11
0
        static TextPatternIdentifiers()
        {
            MixedAttributeValue = new object();

            Pattern =
                new AutomationPattern(PatternId,
                                      "TextPatternIdentifiers.Pattern");
            CaretMovedEvent =
                new AutomationEvent(CaretMovedEventId,
                                    "TextPatternIdentifiers.CaretMovedEvent");
            TextChangedEvent =
                new AutomationEvent(TextChangedEventId,
                                    "TextPatternIdentifiers.TextChangedEvent");
            TextSelectionChangedEvent =
                new AutomationEvent(TextSelectionChangedEventId,
                                    "TextPatternIdentifiers.TextSelectionChangedEvent");

            AnimationStyleAttribute =
                new AutomationTextAttribute(AnimationStyleAttributeId,
                                            "TextPatternIdentifiers.AnimationStyleAttribute");
            BackgroundColorAttribute =
                new AutomationTextAttribute(BackgroundColorAttributeId,
                                            "TextPatternIdentifiers.BackgroundColorAttribute");
            BulletStyleAttribute =
                new AutomationTextAttribute(BulletStyleAttributeId,
                                            "TextPatternIdentifiers.BulletStyleAttribute");
            CapStyleAttribute =
                new AutomationTextAttribute(CapStyleAttributeId,
                                            "TextPatternIdentifiers.CapStyleAttribute");
            CultureAttribute =
                new AutomationTextAttribute(CultureAttributeId,
                                            "TextPatternIdentifiers.CultureAttribute");
            FontNameAttribute =
                new AutomationTextAttribute(FontNameAttributeId,
                                            "TextPatternIdentifiers.FontNameAttribute");
            FontSizeAttribute =
                new AutomationTextAttribute(FontSizeAttributeId,
                                            "TextPatternIdentifiers.FontSizeAttribute");
            FontWeightAttribute =
                new AutomationTextAttribute(FontWeightAttributeId,
                                            "TextPatternIdentifiers.FontWeightAttribute");
            ForegroundColorAttribute =
                new AutomationTextAttribute(ForegroundColorAttributeId,
                                            "TextPatternIdentifiers.ForegroundColorAttribute");
            HorizontalTextAlignmentAttribute =
                new AutomationTextAttribute(HorizontalTextAlignmentAttributeId,
                                            "TextPatternIdentifiers.HorizontalTextAlignmentAttribute");
            IndentationFirstLineAttribute =
                new AutomationTextAttribute(IndentationFirstLineAttributeId,
                                            "TextPatternIdentifiers.IndentationFirstLineAttribute");
            IndentationLeadingAttribute =
                new AutomationTextAttribute(IndentationLeadingAttributeId,
                                            "TextPatternIdentifiers.IndentationLeadingAttribute");
            IndentationTrailingAttribute =
                new AutomationTextAttribute(IndentationTrailingAttributeId,
                                            "TextPatternIdentifiers.IndentationTrailingAttribute");
            IsHiddenAttribute =
                new AutomationTextAttribute(IsHiddenAttributeId,
                                            "TextPatternIdentifiers.IsHiddenAttribute");
            IsItalicAttribute =
                new AutomationTextAttribute(IsItalicAttributeId,
                                            "TextPatternIdentifiers.IsItalicAttribute");
            IsReadOnlyAttribute =
                new AutomationTextAttribute(IsReadOnlyAttributeId,
                                            "TextPatternIdentifiers.IsReadOnlyAttribute");
            IsSubscriptAttribute =
                new AutomationTextAttribute(IsSubscriptAttributeId,
                                            "TextPatternIdentifiers.IsSubscriptAttribute");
            IsSuperscriptAttribute =
                new AutomationTextAttribute(IsSuperscriptAttributeId,
                                            "TextPatternIdentifiers.IsSuperscriptAttribute");
            MarginBottomAttribute =
                new AutomationTextAttribute(MarginBottomAttributeId,
                                            "TextPatternIdentifiers.MarginBottomAttribute");
            MarginLeadingAttribute =
                new AutomationTextAttribute(MarginLeadingAttributeId,
                                            "TextPatternIdentifiers.MarginLeadingAttribute");
            MarginTopAttribute =
                new AutomationTextAttribute(MarginTopAttributeId,
                                            "TextPatternIdentifiers.MarginTopAttribute");
            MarginTrailingAttribute =
                new AutomationTextAttribute(MarginTrailingAttributeId,
                                            "TextPatternIdentifiers.MarginTrailingAttribute");
            OutlineStylesAttribute =
                new AutomationTextAttribute(OutlineStylesAttributeId,
                                            "TextPatternIdentifiers.OutlineStylesAttribute");
            OverlineColorAttribute =
                new AutomationTextAttribute(OverlineColorAttributeId,
                                            "TextPatternIdentifiers.OverlineColorAttribute");
            OverlineStyleAttribute =
                new AutomationTextAttribute(OverlineStyleAttributeId,
                                            "TextPatternIdentifiers.OverlineStyleAttribute");
            StrikethroughColorAttribute =
                new AutomationTextAttribute(StrikethroughColorAttributeId,
                                            "TextPatternIdentifiers.StrikethroughColorAttribute");
            StrikethroughStyleAttribute =
                new AutomationTextAttribute(StrikethroughStyleAttributeId,
                                            "TextPatternIdentifiers.StrikethroughStyleAttribute");
            TabsAttribute =
                new AutomationTextAttribute(TabsAttributeId,
                                            "TextPatternIdentifiers.TabsAttribute");
            TextFlowDirectionsAttribute =
                new AutomationTextAttribute(TextFlowDirectionsAttributeId,
                                            "TextPatternIdentifiers.TextFlowDirectionsAttribute");
            UnderlineColorAttribute =
                new AutomationTextAttribute(UnderlineColorAttributeId,
                                            "TextPatternIdentifiers.UnderlineColorAttribute");
            UnderlineStyleAttribute =
                new AutomationTextAttribute(UnderlineStyleAttributeId,
                                            "TextPatternIdentifiers.UnderlineStyleAttribute");
        }
示例#12
0
		public object GetAttributeValue (AutomationTextAttribute attribute)
		{
			try {
				//todo Need object transformation
				return range.GetAttributeValue (attribute.Id);
			} catch (Exception ex) {
				throw DbusExceptionTranslator.Translate (ex);
			}
		}
示例#13
0
		public ITextPatternRange FindAttribute (AutomationTextAttribute attribute, object value, bool backward)
		{
			//todo Need object transformation
			string path = null;
			try {
				path = range.FindAttribute (attribute.Id, value, backward);
			} catch (Exception ex) {
				throw DbusExceptionTranslator.Translate (ex);
			}
			return parent.GetTextPatternRange (path);
		}
示例#14
0
 /// --------------------------------------------------------------------
 /// <summary>
 ///     Parse the target selection based on the text attribute of interest.
 /// </summary>
 /// <param name="selectedText">The current target selection.</param>
 /// <param name="automationTextAttribute">
 ///     The text attribute of interest.
 /// </param>
 /// <returns>
 ///     A string representing the requested attribute details.
 /// </returns>
 /// --------------------------------------------------------------------
 private string ParseTextRangeByAttribute(
     string selectedText,
     AutomationTextAttribute automationTextAttribute)
 {
     var attributeDetails = new StringBuilder();
     // Initialize the current attribute value.
     var attributeValue = "";
     // Make a copy of the text range.
     var searchRangeClone = _searchRange.Clone();
     // Collapse the range to the starting endpoint.
     searchRangeClone.Move(TextUnit.Character, -1);
     // Iterate through the range character by character.
     for (var x = 1; x <= selectedText.Length; x++)
     {
         searchRangeClone.Move(TextUnit.Character, 1);
         // Get the attribute value of the current character.
         var newAttributeValue =
             searchRangeClone.GetAttributeValue(automationTextAttribute).ToString();
         // If the new attribute value is not equal to the old then report 
         // the new value along with its location within the range.
         if (newAttributeValue != attributeValue)
         {
             attributeDetails.Append(automationTextAttribute.ProgrammaticName)
                 .Append(":\n<")
                 .Append(newAttributeValue)
                 .Append("> at text range position ")
                 .AppendLine(x.ToString());
             attributeValue = newAttributeValue;
         }
     }
     return attributeDetails.ToString();
 }
示例#15
0
        //---------------------------------------------------------------------------
        // Wrapper for TextPatternRange.GetAttributeValue Method
        //---------------------------------------------------------------------------
        internal void Range_GetAttributeValue(TextPatternRange callingRange, AutomationTextAttribute attrib, ref object val, Type expectedException, CheckType checkType)
        {
            string call = "";
            if (attrib != null)
                call = "TextPatternRange.GetAttributeValue(" + Helpers.GetProgrammaticName(attrib) + ")";
            else
                call = "TextPatternRange.GetAttributeValue(NULL)";
            Comment("---Calling " + call);

            if (callingRange == null)
                throw new ArgumentNullException(call + " requires non-NULL TextPatterncallingRange");

            try
            {
                val = callingRange.GetAttributeValue(attrib);

                if (val.Equals(AutomationElement.NotSupported))
                {
                    string msg = Helpers.GetProgrammaticName(attrib) + " not supported by control";
                    Comment(msg);
                }
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(expectedException, actualException, call, checkType);
                return;
            }
            TestNoExceptionQuiet(expectedException, call, checkType);
        }
 // a big pseudo-switch statement based on the attribute
 private object GetAttributeValue(AutomationTextAttribute attribute)
 {
     object rval;
     if (attribute == TextPattern.BackgroundColorAttribute)
     {
         rval = GetBackgroundColor();
     }
     else if (attribute == TextPattern.CapStyleAttribute)
     {
         rval = GetCapStyle(_provider.WindowStyle);
     }
     else if (attribute == TextPattern.FontNameAttribute)
     {
         rval = GetFontName(_provider.GetLogfont());
     }
     else if (attribute == TextPattern.FontSizeAttribute)
     {
         rval = GetFontSize(_provider.GetLogfont());
     }
     else if (attribute == TextPattern.FontWeightAttribute)
     {
         rval = GetFontWeight(_provider.GetLogfont());
     }
     else if (attribute == TextPattern.ForegroundColorAttribute)
     {
         rval = GetForegroundColor();
     }
     else if (attribute == TextPattern.HorizontalTextAlignmentAttribute)
     {
         rval = GetHorizontalTextAlignment(_provider.WindowStyle);
     }
     else if (attribute == TextPattern.IsItalicAttribute)
     {
         rval = GetItalic(_provider.GetLogfont());
     }
     else if (attribute == TextPattern.IsReadOnlyAttribute)
     {
         rval = GetReadOnly();
     }
     else if (attribute == TextPattern.StrikethroughStyleAttribute)
     {
         rval = GetStrikethroughStyle(_provider.GetLogfont());
     }
     else if (attribute == TextPattern.UnderlineStyleAttribute)
     {
         rval = GetUnderlineStyle(_provider.GetLogfont());
     }
     else
     {
         rval = AutomationElement.NotSupported;
     }
     return rval;
 }
示例#17
0
        internal static AutomationIdentifier Register(UiaCoreIds.AutomationIdType type, Guid guid, string programmaticName)
        {
            int id = UiaCoreIds.UiaLookupId(type, ref guid);
            if (id == 0)
            {
                return null;
            }
            var directory = GetIdentifierDictionaryForType(type);
            lock (directory)
            {
                AutomationIdentifier identifier;
                if (directory.TryGetValue(id, out identifier)) return identifier;
                switch (type)
                {
                    case UiaCoreIds.AutomationIdType.Property:
                        identifier = new AutomationProperty(id, guid, programmaticName);
                        break;

                    case UiaCoreIds.AutomationIdType.Pattern:
                        identifier = new AutomationPattern(id, guid, programmaticName);
                        break;

                    case UiaCoreIds.AutomationIdType.Event:
                        identifier = new AutomationEvent(id, guid, programmaticName);
                        break;

                    case UiaCoreIds.AutomationIdType.ControlType:
                        identifier = new ControlType(id, guid, programmaticName);
                        break;

                    case UiaCoreIds.AutomationIdType.TextAttribute:
                        identifier = new AutomationTextAttribute(id, guid, programmaticName);
                        break;

                    default:
                        throw new InvalidOperationException("Invalid type specified for AutomationIdentifier");
                }
                directory[id] = identifier;
                return identifier;
            }
        }
示例#18
0
		public ITextPatternRange FindAttribute (AutomationTextAttribute attribute, object value, bool backward)
		{
			// TODO: Support this in at-spi.
			// I don't want to iterate over the wire.
			Log.Debug ("AtspiUiaSource: TODO: FindAttribute");
			return null;
		}
示例#19
0
                private object GetAttributeValue(AutomationTextAttribute attribute)
                {
                    Func<TextRangeProvider, object> func;
                    if (_attributeGetter.TryGetValue(attribute, out func))
                        return func(this);

                    return null;
                }
示例#20
0
文件: Schema.cs 项目: JianwenSun/cc
 // look up information on the specified property, returns true if found, else false
 internal static bool GetAttributeInfo( AutomationTextAttribute id, out AutomationAttributeInfo info )
 {
     foreach( AutomationAttributeInfo ai in _attributeInfoTable )
     {
         if( ai.ID == id )
         {
             info = ai;
             return true;
         }
     }
     info = null;
     Debug.Assert( false, "GetAttributeInfo failed " + id );
     return false;
 }
示例#21
0
        //---------------------------------------------------------------------------
        // Add attribute to dictionary
        //---------------------------------------------------------------------------
        internal void AddAttributeToDictionary(TextPatternRange callingRange, ref IDictionary dict, AutomationTextAttribute attrib, CheckType checkType)
        {
            object attribValue = null;

            Range_GetAttributeValue(callingRange, attrib, ref attribValue, null, checkType);

            if (attribValue == null)
                ThrowMe(checkType, "Null incorrectly returned for value of text attribute " + Helpers.GetProgrammaticName(attrib));

            dict.Add(attrib, attribValue);
        }
示例#22
0
        internal static AutomationIdentifier Register(UiaCoreIds.AutomationIdType type, Guid guid, string programmaticName)
        {
            int id = UiaCoreIds.UiaLookupId(type, ref guid);
            if (id == 0)
            {
                return null;
            }
            lock (_identifierDirectory)
            {
                AutomationIdentifier identifier = (AutomationIdentifier)_identifierDirectory[guid];
                if (identifier == null)
                {
                    switch (type)
                    {
                        case UiaCoreIds.AutomationIdType.Property:
                            identifier = new AutomationProperty(id, guid, programmaticName);
                            break;

                        case UiaCoreIds.AutomationIdType.Pattern:
                            identifier = new AutomationPattern(id, guid, programmaticName);
                            break;

                        case UiaCoreIds.AutomationIdType.Event:
                            identifier = new AutomationEvent(id, guid, programmaticName);
                            break;

                        case UiaCoreIds.AutomationIdType.ControlType:
                            identifier = new ControlType(id, guid, programmaticName);
                            break;

                        case UiaCoreIds.AutomationIdType.TextAttribute:
                            identifier = new AutomationTextAttribute(id, guid, programmaticName);
                            break;

                        default:
                            throw new InvalidOperationException("Invalid type specified for AutomationIdentifier");
                    }
                    _identifierDirectory[id] = identifier;
                }
                return identifier;
            }
        }
示例#23
0
        internal static AutomationIdentifier Register(UiaCoreTypesApi.AutomationIdType type, Guid guid, string programmaticName)
        {
            int num = UiaCoreTypesApi.UiaLookupId(type, ref guid);

            if (num == 0)
            {
                if ((!AutomationIdentifier.IsWin7OnlyPatternGuid(guid) && Environment.OSVersion.Version.Major <= 6) || Environment.OSVersion.Version.Major >= 7)
                {
                    int num2 = 1;
                    while (num == 0 && num2 < 1000)
                    {
                        Thread.Sleep(num2);
                        num   = UiaCoreTypesApi.UiaLookupId(type, ref guid);
                        num2 *= 2;
                    }
                }
                if (num == 0)
                {
                    return(null);
                }
            }
            Hashtable            idTable = AutomationIdentifier._idTable;
            AutomationIdentifier result;

            lock (idTable)
            {
                AutomationIdentifier automationIdentifier = (AutomationIdentifier)AutomationIdentifier._idTable[guid];
                if (automationIdentifier != null)
                {
                    result = automationIdentifier;
                }
                else
                {
                    switch (type)
                    {
                    case UiaCoreTypesApi.AutomationIdType.Property:
                        automationIdentifier = new AutomationProperty(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.Pattern:
                        automationIdentifier = new AutomationPattern(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.Event:
                        automationIdentifier = new AutomationEvent(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.ControlType:
                        automationIdentifier = new ControlType(num, guid, programmaticName);
                        break;

                    case UiaCoreTypesApi.AutomationIdType.TextAttribute:
                        automationIdentifier = new AutomationTextAttribute(num, guid, programmaticName);
                        break;

                    default:
                        throw new InvalidOperationException("Invalid type specified for AutomationIdentifier");
                    }
                    AutomationIdentifier._idTable[num] = automationIdentifier;
                    result = automationIdentifier;
                }
            }
            return(result);
        }