Beispiel #1
0
        private void TestLiteralValue(AutomationControlType controlType, string localizedValue)
        {
            ConcreteFrameworkElement fe = new ConcreteFrameworkElement();
            ConcreteFrameworkElementAutomationPeer peer
                = FrameworkElementAutomationPeer.CreatePeerForElement(fe) as ConcreteFrameworkElementAutomationPeer;

            peer.ControlType = controlType;
            Assert.AreEqual(localizedValue, peer.GetLocalizedControlType(), string.Format("Literal value: '{0}'", localizedValue));
        }
Beispiel #2
0
        private void OnAutomationPropertyChanged(object o, AutomationPropertyChangedEventArgs args)
        {
            if (args.Property == ValuePatternIdentifiers.ValueProperty)
            {
                AutomationControlType controlType
                    = peer.GetAutomationControlType();
                if (controlType == AutomationControlType.Edit ||
                    controlType == AutomationControlType.Document)
                {
                    TextAdapter textAdapter
                        = new TextAdapter((TextImplementor)adapter);

                    string oldValue = (string)args.OldValue;
                    string newValue = (string)args.NewValue;

                    if (oldValue == newValue)
                    {
                        return;
                    }

                    if (newValue.StartsWith(oldValue))
                    {
                        textAdapter.EmitTextChanged(Atk.TextChangedDetail.Insert,
                                                    oldValue.Length,
                                                    newValue.Length - oldValue.Length);
                    }
                    else if (oldValue.StartsWith(newValue))
                    {
                        textAdapter.EmitTextChanged(Atk.TextChangedDetail.Delete,
                                                    newValue.Length,
                                                    oldValue.Length - newValue.Length);
                    }
                    else
                    {
                        // XXX: Improve this algorithm so that
                        // it diffs the two values (maybe using
                        // a modified Levenshtein alg?) and
                        // send just what is deleted or
                        // inserted to avoid thrashing ATs.
                        textAdapter.EmitTextChanged(Atk.TextChangedDetail.Delete,
                                                    0, oldValue.Length);

                        textAdapter.EmitTextChanged(Atk.TextChangedDetail.Insert,
                                                    0, newValue.Length);
                    }
                }
                else
                {
                    // Mirror Gtk+'s behavior here somewhat
                    // and only fire visible_data_changed
                    // in the case of label and label-like
                    // elements.
                    adapter.EmitSignal("visible_data_changed");
                }
            }
        }
Beispiel #3
0
 public BaseElementAutomationPeer(
     UIElement owner,
     string className,
     AutomationControlType automationControlType = AutomationControlType.Custom,
     int searchDepth             = DefaultSearchDepth,
     XamlFramework xamlFramework = XamlFramework.WPF) : base(owner)
 {
     this.ClassName             = className;
     this.AutomationControlType = automationControlType;
     this.SearchDepth           = searchDepth;
     this.AutomationPeerFactory = AutomationPeerAbstractFactory.Create(xamlFramework);
 }
Beispiel #4
0
        public virtual void RatingAutomationPeerTypeAndClass()
        {
            Rating acc = new Rating();
            RatingAutomationPeer peer = null;

            TestAsync(
                acc,
                () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(acc) as RatingAutomationPeer,
                () =>
            {
                AutomationControlType controlType = peer.GetAutomationControlType();

                Assert.AreEqual(controlType, AutomationControlType.Slider, "Unexpected AutomationControlType!");
            });
        }
Beispiel #5
0
 public CustomControlOverridingAutomationPeer(
     UserControl owner,
     string localizedControl,
     bool isControlElement             = true,
     bool isContentElement             = false,
     bool hideChildren                 = false,
     AutomationControlType controlType = AutomationControlType.Custom)
     : base(owner)
 {
     if (isContentElement && !isControlElement)
     {
         throw new ArgumentException(Resources.ContentTreeIsSubsetofControlTree);
     }
     this.LocalizedControlType = localizedControl;
     this.IsControlElem        = isControlElement;
     this.IsContentElem        = isContentElement;
     this.HideChildren         = hideChildren;
     this.ControlType          = controlType;
 }
Beispiel #6
0
 private static string LocalizeControlType(AutomationControlType controlType)
 {
     // TODO: Humanize ("AppBarButton" -> "app bar button")
     // TODO: Localize
     return(Enum.GetName(typeof(AutomationControlType), controlType));
 }
Beispiel #7
0
 /// <summary>
 /// Modified ReactControl with interactive role.
 /// </summary>
 /// <param name="owner">The ReactControl instance.</param>
 public ReactControlAutomationPeer(ReactControl owner) : base(owner)
 {
     this.reactControl           = owner;
     _ownerAutomationControlType = owner.AutomationControlType;
 }
Beispiel #8
0
 /// <summary>
 /// Used to set automation control type
 /// </summary>
 /// <param name="type">automation control type</param>
 public void SetAutomationControlType(AutomationControlType type)
 {
     AutomationControlType = type;
 }
Beispiel #9
0
 public ControlTypePeer(FrameworkElement owner, AutomationControlType type) : base(owner)
 {
     returnType = type;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtendedFrameworkElementAutomationPeer" /> class.
 /// </summary>
 /// <param name="owner">The owner of the automation peer.</param>
 /// <param name="controlType">The control type of the element that is associated with the automation peer.</param>
 /// <param name="isControlElement">Whether the element should show in the logical tree.</param>
 public ExtendedFrameworkElementAutomationPeer(FrameworkElement owner, AutomationControlType controlType, bool isControlElement)
     : this(owner, controlType)
 {
     this.isControlElement = isControlElement;
 }
            protected override AutomationControlType GetAutomationControlTypeCore()
            {
                AutomationControlType pReturnValue = AutomationControlType.Button;

                return(pReturnValue);
            }
 public ControlTypeFocusPeer(FrameworkElement owner, AutomationControlType type, bool focusable) : base(owner, type)
 {
     isFocusable = focusable;
 }
Beispiel #13
0
		private void TestLiteralValue (AutomationControlType controlType, string localizedValue)
		{

			ConcreteFrameworkElement fe = new ConcreteFrameworkElement ();
			ConcreteFrameworkElementAutomationPeer peer 
				= FrameworkElementAutomationPeer.CreatePeerForElement (fe) as ConcreteFrameworkElementAutomationPeer;
			peer.ControlType = controlType;
			Assert.AreEqual (localizedValue, peer.GetLocalizedControlType (), string.Format ("Literal value: '{0}'", localizedValue));
		}
 public ImplementsPatternAttribute(AutomationControlType controlType)
 {
     ControlType = controlType;
 }
Beispiel #15
0
 public PatternInterfacePeer(FrameworkElement owner, AutomationControlType type) : base(owner, type)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtendedFrameworkElementAutomationPeer" /> class.
 /// </summary>
 /// <param name="owner">The owner of the automation peer.</param>
 /// <param name="controlType">The control type of the element that is associated with the automation peer.</param>
 public ExtendedFrameworkElementAutomationPeer(FrameworkElement owner, AutomationControlType controlType)
     : this(owner)
 {
     this.controlType = controlType;
 }
Beispiel #17
0
        private void RegisterPatternImplementors()
        {
            Assembly asm = typeof(DynamicAdapterFactory).Assembly;

            foreach (Type t in asm.GetTypes())
            {
                object [] attrs = t.GetCustomAttributes(
                    typeof(ImplementsPatternAttribute),
                    false);

                if (t.IsSubclassOf(typeof(Adapter)))
                {
                    continue;
                }

                foreach (Attribute attr in attrs)
                {
                    ImplementsPatternAttribute ipa
                        = attr as ImplementsPatternAttribute;
                    if (ipa == null)
                    {
                        continue;
                    }

                    if (ipa.IsProvidesSet)
                    {
                        blacklist [t] = ipa.Provides;
                    }

                    // If there's a explicit type to match we don't care
                    // about blacklisting it, because the adapter will *only*
                    // work with that peer.
                    if (!string.IsNullOrEmpty(ipa.ElementType))
                    {
                        explicitImplementors.Add(ipa.ElementType, t);
                        continue;
                    }

                    if (ipa.ControlType.HasValue)
                    {
                        AutomationControlType controlType = ipa.ControlType.Value;
                        if (!controlTypeImplementors.ContainsKey(controlType))
                        {
                            controlTypeImplementors [controlType] = new List <Type> ();
                        }

                        controlTypeImplementors [controlType].Add(t);
                        continue;
                    }

                    if (!patternImplementors.ContainsKey(ipa.Pattern))
                    {
                        // Micro-optimization: Most
                        // likely, we'll only have 1
                        // implementor per pattern
                        patternImplementors [ipa.Pattern]
                            = new List <Type> (1);
                    }

                    patternImplementors [ipa.Pattern].Add(t);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtendedFrameworkElementAutomationPeer" /> class.
 /// </summary>
 /// <param name="owner">The owner of the automation peer.</param>
 /// <param name="controlType">The control type of the element that is associated with the automation peer.</param>
 /// <param name="isControlElement">Whether the element should show in the logical tree.</param>
 public ExtendedFrameworkElementAutomationPeer(FrameworkElement owner, AutomationControlType controlType, bool isControlElement)
     : this(owner, controlType)
 {
     this.isControlElement = isControlElement;
 }
Beispiel #19
0
        protected override Role OnGetRole()
        {
            if (Peer == null)
            {
                return(Role.Unknown);
            }

            if (PatternImplementors.Length > 0 &&
                PatternImplementors [0].OverriddenRole != Role.Unknown)
            {
                if (PatternImplementors.Length > 1)
                {
                    Log.Warn("Adapter has more than one PatternImplementor, we are going to use the first OverridenRole value");
                }
                return(PatternImplementors [0].OverriddenRole);
            }

            if (Peer.IsPassword())
            {
                return(Role.PasswordText);
            }

            AutomationControlType type = Peer.GetAutomationControlType();

            switch (type)
            {
            case AutomationControlType.Button:
                return(Role.PushButton);

            case AutomationControlType.Calendar:
                return(Role.Calendar);

            case AutomationControlType.CheckBox:
                return(Role.CheckBox);

            case AutomationControlType.ComboBox:
                return(Role.ComboBox);

            case AutomationControlType.Edit:
                return(Role.Text);

            case AutomationControlType.Hyperlink:
                return(Role.PushButton);

            case AutomationControlType.Image:
                return(Role.Image);

            case AutomationControlType.ListItem:
                return(Role.ListItem);

            case AutomationControlType.List:
                return(Role.List);

            case AutomationControlType.Menu:
                return(Role.Menu);

            case AutomationControlType.MenuBar:
                return(Role.MenuBar);

            case AutomationControlType.MenuItem:
                return(Role.MenuItem);

            case AutomationControlType.ProgressBar:
                return(Role.ProgressBar);

            case AutomationControlType.RadioButton:
                return(Role.RadioButton);

            case AutomationControlType.ScrollBar:
                return(Role.ScrollBar);

            case AutomationControlType.Slider:
                return(Role.Slider);

            case AutomationControlType.Spinner:
                return(Role.SpinButton);

            case AutomationControlType.StatusBar:
                return(Role.Statusbar);

            case AutomationControlType.Tab:
                return(Role.PageTabList);

            case AutomationControlType.TabItem:
                return(Role.PageTab);

            case AutomationControlType.Text:
                return(Role.Label);

            case AutomationControlType.ToolBar:
                return(Role.ToolBar);

            case AutomationControlType.ToolTip:
                return(Role.ToolTip);

            case AutomationControlType.Tree:
                return(Role.Table);

            case AutomationControlType.TreeItem:
                return(Role.TableCell);

            case AutomationControlType.Custom:
                return(Role.Unknown);

            case AutomationControlType.Group:
                return(Role.LayeredPane);

            case AutomationControlType.Thumb:
                return(Role.PushButton);

            case AutomationControlType.DataGrid:
                return(Role.Table);

            case AutomationControlType.DataItem:
                return(Role.TableCell);

            case AutomationControlType.Document:
                return(Role.Panel);

            case AutomationControlType.SplitButton:
                return(Role.PushButton);

            case AutomationControlType.Window:
                return(Role.Filler);

            case AutomationControlType.Pane:
                return(Role.Panel);

            case AutomationControlType.Header:
                return(Role.TableRowHeader);

            case AutomationControlType.HeaderItem:
                return(Role.TableCell);

            case AutomationControlType.Table:
                return(Role.Table);

            case AutomationControlType.TitleBar:
                return(Role.MenuBar);

            case AutomationControlType.Separator:
                return(Role.Separator);

            default:
                return(Role.Unknown);
            }
        }
Beispiel #20
0
 private static string LocalizeControlType(AutomationControlType controlType) =>
 // TODO: Humanize ("AppBarButton" -> "app bar button")
 // TODO: Localize
 Enum.GetName(typeof(AutomationControlType), controlType).ToLowerInvariant();
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtendedFrameworkElementAutomationPeer" /> class.
 /// </summary>
 /// <param name="owner">The owner of the automation peer.</param>
 /// <param name="controlType">The control type of the element that is associated with the automation peer.</param>
 public ExtendedFrameworkElementAutomationPeer(FrameworkElement owner, AutomationControlType controlType)
     : this(owner)
 {
     this.controlType = controlType;
 }
Beispiel #22
0
 public NoneOrientationPeer(FrameworkElement owner, AutomationControlType type) : base(owner, type)
 {
 }
Beispiel #23
0
 public MockAutomationPeer(FrameworkElement owner, AutomationControlType controlType)
     : base(owner)
 {
     _controlType = controlType;
 }