private Atk.Attribute [] GetAttributesInRange(int start, int end) { CG.List <Atk.Attribute> attrs = new CG.List <Atk.Attribute> (); IRawElementProviderSimple prov = resource.Provider; if (prov == null) { return(attrs.ToArray()); } ITextProvider textProvider = prov.GetPatternProvider(TextPatternIdentifiers.Pattern.Id) as ITextProvider; if (textProvider == null) { return(attrs.ToArray()); } ITextRangeProvider textRange = GetTextRange(start, end); foreach (Atk.TextAttribute attr in SUPPORTED_ATTRS) { AddTextAttribute(attrs, attr, textRange); } return(attrs.ToArray()); }
private Atk.Attribute [] GetAttributesInRange (int start, int end) { CG.List<Atk.Attribute> attrs = new CG.List<Atk.Attribute> (); IRawElementProviderSimple prov = resource.Provider; if (prov == null) { return attrs.ToArray (); } ITextProvider textProvider = prov.GetPatternProvider (TextPatternIdentifiers.Pattern.Id) as ITextProvider; if (textProvider == null) { return attrs.ToArray (); } ITextRangeProvider textRange = GetTextRange (start, end); foreach (Atk.TextAttribute attr in SUPPORTED_ATTRS) AddTextAttribute (attrs, attr, textRange); return attrs.ToArray (); }
private void AddTextAttribute(CG.List <Atk.Attribute> attrs, Atk.TextAttribute atkAttr, ITextRangeProvider textRange) { if (textRange == null) { return; } string name = Atk.TextAdapter.AttributeGetName(atkAttr); string val = null; object tmp; switch (atkAttr) { case Atk.TextAttribute.Style: if (IsAttrNotNullOrMultiValued(TextPattern.IsItalicAttribute.Id, textRange, out tmp)) { val = ((bool)tmp) ? "italic" : "normal"; } break; case Atk.TextAttribute.Justification: if (!IsAttrNotNullOrMultiValued(TextPattern.HorizontalTextAlignmentAttribute.Id, textRange, out tmp)) { break; } HorizontalTextAlignment align = (HorizontalTextAlignment)tmp; if (align == HorizontalTextAlignment.Left) { val = "left"; } else if (align == HorizontalTextAlignment.Right) { val = "right"; } else if (align == HorizontalTextAlignment.Centered) { val = "center"; } else if (align == HorizontalTextAlignment.Justified) { val = "fill"; } break; case Atk.TextAttribute.FgColor: if (IsAttrNotNullOrMultiValued(TextPattern.ForegroundColorAttribute.Id, textRange, out tmp)) { Color fgColor = Color.FromArgb((int)tmp); val = String.Format("{0},{1},{2}", fgColor.R, fgColor.G, fgColor.B); } break; case Atk.TextAttribute.BgColor: if (IsAttrNotNullOrMultiValued(TextPattern.BackgroundColorAttribute.Id, textRange, out tmp)) { Color fgColor = Color.FromArgb((int)tmp); val = String.Format("{0},{1},{2}", fgColor.R, fgColor.G, fgColor.B); } break; case Atk.TextAttribute.FamilyName: if (IsAttrNotNullOrMultiValued(TextPattern.FontNameAttribute.Id, textRange, out tmp)) { val = (string)tmp; } break; case Atk.TextAttribute.Weight: if (IsAttrNotNullOrMultiValued(TextPattern.FontWeightAttribute.Id, textRange, out tmp)) { val = ((int)tmp).ToString(); } break; case Atk.TextAttribute.Strikethrough: if (IsAttrNotNullOrMultiValued(TextPattern.StrikethroughStyleAttribute.Id, textRange, out tmp)) { TextDecorationLineStyle strikeStyle = (TextDecorationLineStyle)tmp; val = strikeStyle == TextDecorationLineStyle.None ? "false" : "true"; } break; case Atk.TextAttribute.Underline: if (!IsAttrNotNullOrMultiValued(TextPattern.UnderlineStyleAttribute.Id, textRange, out tmp)) { break; } TextDecorationLineStyle underlineStyle = (TextDecorationLineStyle)tmp; if (underlineStyle == TextDecorationLineStyle.None) { val = "none"; } else if (underlineStyle == TextDecorationLineStyle.Double || underlineStyle == TextDecorationLineStyle.DoubleWavy) { val = "double"; } else { val = "single"; } break; case Atk.TextAttribute.PixelsBelowLines: if (IsAttrNotNullOrMultiValued(TextPattern.IndentationTrailingAttribute.Id, textRange, out tmp)) { val = ((int)tmp).ToString(); } break; case Atk.TextAttribute.PixelsAboveLines: if (IsAttrNotNullOrMultiValued(TextPattern.IndentationLeadingAttribute.Id, textRange, out tmp)) { val = ((int)tmp).ToString(); } break; case Atk.TextAttribute.Editable: if (IsAttrNotNullOrMultiValued(TextPattern.IsReadOnlyAttribute.Id, textRange, out tmp)) { val = !((bool)tmp) ? "true" : "false"; } break; case Atk.TextAttribute.Invisible: if (IsAttrNotNullOrMultiValued(TextPattern.IsHiddenAttribute.Id, textRange, out tmp)) { val = ((bool)tmp) ? "true" : "false"; } break; case Atk.TextAttribute.Indent: if (IsAttrNotNullOrMultiValued(TextPattern.IndentationFirstLineAttribute.Id, textRange, out tmp)) { val = ((int)tmp).ToString(); } break; } if (val != null) { attrs.Add(new Atk.Attribute { Name = name, Value = val }); } }