public override void GetName_AttachedProperty0() { Calendar fe = CreateConcreteFrameworkElement() as Calendar; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); Assert.AreEqual(fe.DisplayDate.ToString(), peer.GetName(), "GetName"); string name = "Attached Name"; fe.SetValue(AutomationProperties.NameProperty, name); Assert.AreEqual(name, peer.GetName(), "GetName #1"); fe.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(fe.DisplayDate.ToString(), peer.GetName(), "GetName #2"); }
public override void GetName_AttachedProperty0() { FrameworkElement fe = CreateConcreteFrameworkElement(); AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); Assert.AreEqual(string.Empty, peer.GetName(), "GetName"); string name = "Attached Name"; fe.SetValue(AutomationProperties.NameProperty, name); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #1"); fe.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #2"); }
public override void GetName_AttachedProperty0() { DataGridColumnHeader fe = CreateConcreteFrameworkElement() as DataGridColumnHeader; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); Assert.AreEqual(fe.Content, peer.GetName(), "GetName"); string name = "Attached Name"; fe.SetValue(AutomationProperties.NameProperty, name); Assert.AreEqual(fe.Content, peer.GetName(), "GetName #1"); fe.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(fe.Content, peer.GetName(), "GetName #2"); }
private string GetAutomationName(int index) { TreeViewItem item = null; string automationName = ""; if (IsIndexValid(index)) { var interim = ContainerFromIndex(index) as TreeViewItem; if (interim != null) { item = interim; } } if (item != null) { AutomationPeer itemPeer = FrameworkElementAutomationPeer.FromElement(item); if (itemPeer != null) { automationName = itemPeer.GetName(); } } return(automationName); }
protected override string GetNameCore() { string name = base.GetNameCore(); if (String.IsNullOrEmpty(name)) { RibbonContextualTabGroup tabGroup = Owner as RibbonContextualTabGroup; if (tabGroup != null && tabGroup.Header != null) { UIElement headerElement = tabGroup.Header as UIElement; if (headerElement != null) { AutomationPeer peer = CreatePeerForElement(headerElement); if (peer != null) { name = peer.GetName(); } } if (String.IsNullOrEmpty(name)) { name = tabGroup.Header.ToString(); } } } return(name); }
protected override string GetNameCore() { if (this.ChartArea.SelectionPanel != null && this.ChartArea.SelectionPanel.SelectedElement != null && this.ChartArea.SelectionPanel.SelectedElement != this.ChartArea) { AutomationPeer peerForElement = UIElementAutomationPeer.CreatePeerForElement((UIElement)this.ChartArea.SelectionPanel.SelectedElement); if (peerForElement != null) { return(peerForElement.GetName()); } } string str = base.GetNameCore(); if (string.IsNullOrEmpty(str)) { str = this.GetClassName(); } if (string.IsNullOrEmpty(str)) { str = this.ChartArea.Name; } if (string.IsNullOrEmpty(str)) { str = this.ChartArea.GetType().Name; } return(str); }
/// <summary> /// Returns the text label of the CalendarButton that is associated with /// this CalendarButtonAutomationPeer. This method is called by GetName. /// </summary> /// <returns> /// The text label of the element that is associated with this /// automation peer. /// </returns> /// <remarks> /// The name property can be thought of as the string of text that a /// user would use to explain which control is being referred to. It is /// important to have a textual representation for all controls in the /// graphical user interface (GUI) so that you can programmatically /// refer to the control in a localized manner. The value is settable /// on control instances through the AutomationProperties.Name attached /// property. /// </remarks> protected override string GetNameCore() { string name = base.GetNameCore(); if (string.IsNullOrEmpty(name)) { AutomationPeer labeledBy = GetLabeledByCore(); if (labeledBy != null) { name = labeledBy.GetName(); } CalendarButton button = this.OwningCalendarButton; if (string.IsNullOrEmpty(name) && button != null) { if (button.DataContext is DateTime) { if (this.OwningCalendar.DisplayMode == CalendarMode.Decade) { name = DateTimeHelper.ToYearString((DateTime)button.DataContext); } else { name = DateTimeHelper.ToYearMonthPatternString((DateTime)button.DataContext); } } else if (button.Content != null) { name = string.Format(DateTimeHelper.GetCurrentDateFormat(), button.Content.ToString()); } } } return(name); }
public override void GetName() { Calendar fe = CreateConcreteFrameworkElement() as Calendar; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); Assert.AreEqual(peer.GetName(), fe.DisplayDate.ToString(), "GetName"); }
internal static object GetPropertyValue(this AutomationPeer itemPeer, int id) { if (AutomationElementIdentifiers.NameProperty.Id == id) { return(itemPeer.GetName()); } else if (AutomationElementIdentifiers.AutomationIdProperty.Id == id) { return(itemPeer.GetAutomationId()); } else if (AutomationElementIdentifiers.ControlTypeProperty.Id == id) { return(AutomationPeerExtensions.GetControlType(itemPeer).Id); } else if (SelectionItemPatternIdentifiers.IsSelectedProperty.Id == id) { ISelectionItemProvider selectionItemProvider = itemPeer.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider; if (selectionItemProvider == null) { return(null); } return(selectionItemProvider.IsSelected); } return(null); }
/// <summary> /// Returns the text label of the CalendarDayButton that is associated /// with this CalendarDayButtonAutomationPeer. This method is called by /// GetName. /// </summary> /// <returns> /// The text label of the element that is associated with this /// automation peer. /// </returns> /// <remarks> /// The name property can be thought of as the string of text that a /// user would use to explain which control is being referred to. It is /// important to have a textual representation for all controls in the /// graphical user interface (GUI) so that you can programmatically /// refer to the control in a localized manner. The value is settable /// on control instances through the AutomationProperties.Name attached /// property. /// </remarks> protected override string GetNameCore() { string name = base.GetNameCore(); if (string.IsNullOrEmpty(name)) { AutomationPeer labeledBy = GetLabeledByCore(); if (labeledBy != null) { name = labeledBy.GetName(); } CalendarDayButton button = OwningCalendarDayButton; if (string.IsNullOrEmpty(name) && button != null) { if (button.DataContext is DateTime) { name = ((DateTime)button.DataContext).ToLongDateString(); } else if (button.Content != null) { name = string.Format(DateTimeHelper.GetCurrentDateFormat(), button.Content.ToString()); } } } return(name); }
public override void GetName() { CreateAsyncTest(calendar, () => { List <AutomationPeer> buttonChildren = GetButtonChildren(); AutomationPeer peer = buttonChildren[0]; Assert.AreEqual(CURRENT_MONTH, peer.GetName(), "GetName"); }); }
public override void GetName_AttachedProperty0() { CreateAsyncTest(calendar, () => { List <AutomationPeer> buttonChildren = GetButtonChildren(); FrameworkElement fe = ((FrameworkElementAutomationPeer)buttonChildren[0]).Owner as FrameworkElement; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); Assert.AreEqual(CURRENT_MONTH, peer.GetName(), "GetName"); string name = "Attached Name"; fe.SetValue(AutomationProperties.NameProperty, name); Assert.AreEqual(name, peer.GetName(), "GetName #1"); fe.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(CURRENT_MONTH, peer.GetName(), "GetName #2"); }); }
/// <inheritdoc/> public bool IsValid(FrameworkElement element, AutomationPeer peer) { // This only cares about the length. // If a name should be null or not is handled by another rule. if (peer?.GetName() is string name) { return(name.Length != 1 && name.Length <= 512); } return(true); }
Dictionary <string, string> CollectCommonProperties(FrameworkElement source, EventArgs e) { Dictionary <string, string> properties = new Dictionary <string, string>(); properties["Name"] = source.Name; properties["ClassName"] = source.GetType().ToString(); if (previousArgs == null) { previousArgs = new PreviousArgs() { EventArgs = e, Id = (currentId++).ToString("X") }; } else { if (e == null || !Object.ReferenceEquals(previousArgs.EventArgs, e)) { previousArgs = new PreviousArgs() { EventArgs = e, Id = (currentId++).ToString("X") }; } } properties["#e"] = previousArgs.Id; AutomationPeer automation = GetAutomationPeer(source); if (automation == null) { return(properties); } properties["Name"] = string.IsNullOrEmpty(source.Name) ? automation.GetName() : source.Name; string itemType = automation.GetItemType(); if (!string.IsNullOrEmpty(itemType)) { properties["ItemType"] = itemType; } var automationId = automation.GetAutomationId(); if (!string.IsNullOrEmpty(automationId)) { properties["AutomationID"] = automationId; } properties["ControlType"] = automation.GetAutomationControlType().ToString(); properties["windowCaption"] = properties["Name"]; CollectValue(properties, automation); return(properties); }
protected override string GetNameCore() { AutomationPeer wrapperPeer = this.GetWrapperPeer(); if (wrapperPeer != null) { return(wrapperPeer.GetName()); } return(string.Empty); }
protected override string GetNameCore() { AutomationPeer ribbonGroupPeer = GetParent(); if (ribbonGroupPeer != null) { return(ribbonGroupPeer.GetName()); } return(string.Empty); }
/// <inheritdoc/> public bool IsValid(FrameworkElement element, AutomationPeer peer) { if (peer?.GetAutomationControlType() != AutomationControlType.ListItem || VisualTreeHelper.GetChildrenCount(element) == 0) { return(true); } if (element is ListViewItem) { var child = VisualTreeHelper.GetChild(element, 0) as FrameworkElement; if (child?.DataContext == null) { child = VisualTreeHelper.GetChild(child, 0) as FrameworkElement; } if (child.DataContext == null) { return(true); } return(!peer.GetName().Contains(child?.DataContext?.GetType().ToString(), StringComparison.InvariantCultureIgnoreCase)); } else if (element is GridViewItem) { var child = VisualTreeHelper.GetChild(element, 0) as FrameworkElement; if (child?.DataContext == null) { child = VisualTreeHelper.GetChild(child, 0) as FrameworkElement; } if (child.DataContext == null) { return(true); } return(!peer.GetName().Contains(child?.DataContext?.GetType().ToString(), StringComparison.InvariantCultureIgnoreCase)); } else { return(true); } }
public override void GetName_AttachedProperty1() { CreateAsyncTest(calendar, () => { List <AutomationPeer> buttonChildren = GetButtonChildren(); FrameworkElement element = ((FrameworkElementAutomationPeer)buttonChildren[0]).Owner as FrameworkElement; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(element); string textblockName = "Hello world:"; string nameProperty = "TextBox name"; TextBlock textblock = new TextBlock(); textblock.Text = textblockName; element.SetValue(AutomationProperties.NameProperty, nameProperty); Assert.AreEqual(nameProperty, peer.GetName(), "GetName #0"); element.SetValue(AutomationProperties.LabeledByProperty, textblock); Assert.AreEqual(textblockName, peer.GetName(), "GetName #1"); textblock.Text = null; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #2"); textblock.Text = string.Empty; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #3"); element.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #4"); element.SetValue(AutomationProperties.LabeledByProperty, null); Assert.AreEqual(CURRENT_MONTH, peer.GetName(), "GetName #5"); }); }
public override void GetName_AttachedProperty1() { Calendar fe = CreateConcreteFrameworkElement() as Calendar; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); string textblockName = "Hello world:"; string nameProperty = "TextBox name"; TextBlock textblock = new TextBlock(); textblock.Text = textblockName; fe.SetValue(AutomationProperties.NameProperty, nameProperty); Assert.AreEqual(nameProperty, peer.GetName(), "GetName #0"); fe.SetValue(AutomationProperties.LabeledByProperty, textblock); Assert.AreEqual(textblockName, peer.GetName(), "GetName #1"); textblock.Text = null; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #2"); textblock.Text = string.Empty; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #3"); fe.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #4"); fe.SetValue(AutomationProperties.LabeledByProperty, null); Assert.AreEqual(((Calendar)fe).DisplayDate.ToString(), peer.GetName(), "GetName #5"); }
public override void GetName_AttachedProperty1() { TabControl tabControl = new TabControl(); TabItem tabItem = new TabItem(); CreateAsyncTest(tabControl, () => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabItem); string textblockName = "Hello world:"; string nameProperty = "TextBox name"; TextBlock textblock = new TextBlock(); textblock.Text = textblockName; tabItem.SetValue(AutomationProperties.NameProperty, nameProperty); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #0"); tabItem.SetValue(AutomationProperties.LabeledByProperty, textblock); Assert.AreEqual(textblockName, peer.GetName(), "GetName #1"); textblock.Text = null; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #2"); textblock.Text = string.Empty; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #3"); tabItem.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #4"); tabItem.SetValue(AutomationProperties.LabeledByProperty, null); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #5"); }); }
public override void GetName_AttachedProperty1() { DataGridColumnHeader element = CreateConcreteFrameworkElement() as DataGridColumnHeader; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(element); string textblockName = "Hello world:"; string nameProperty = "TextBox name"; TextBlock textblock = new TextBlock(); textblock.Text = textblockName; element.SetValue(AutomationProperties.NameProperty, nameProperty); Assert.AreEqual(element.Content, peer.GetName(), "GetName #0"); element.SetValue(AutomationProperties.LabeledByProperty, textblock); Assert.AreEqual(textblockName, peer.GetName(), "GetName #1"); textblock.Text = null; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #2"); textblock.Text = string.Empty; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #3"); element.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #4"); element.SetValue(AutomationProperties.LabeledByProperty, null); Assert.AreEqual(element.Content, peer.GetName(), "GetName #5"); }
/// <inheritdoc/> public bool IsValid(FrameworkElement element, AutomationPeer peer) { if (peer != null) { if (peer.GetAutomationControlType() == AutomationControlType.Text || peer.GetAutomationControlType() == AutomationControlType.Image || peer.IsKeyboardFocusable()) { return(!string.IsNullOrWhiteSpace(peer.GetName())); } } return(true); }
public void AllTests() { DataGridColumnHeader fe = CreateConcreteFrameworkElement() as DataGridColumnHeader; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); // GetAutomationControlType Assert.AreEqual(AutomationControlType.HeaderItem, peer.GetAutomationControlType(), "GetAutomationControlType"); // GetBoundingRectangle Rect boundingRectangle = peer.GetBoundingRectangle(); Assert.AreNotEqual(0, boundingRectangle.X, "GetBoundingRectangle X"); Assert.AreNotEqual(0, boundingRectangle.Y, "GetBoundingRectangle Y"); Assert.AreNotEqual(0, boundingRectangle.Width, "GetBoundingRectangle Width"); Assert.AreNotEqual(0, boundingRectangle.Height, "GetBoundingRectangle Height"); // GetChildren List <AutomationPeer> children = peer.GetChildren(); Assert.IsNotNull(children, "#0"); Assert.AreEqual(1, children.Count, "#1"); // IsKeyboardFocusable Assert.IsFalse(peer.IsKeyboardFocusable(), "IsKeyboardFocusable"); // GetClassName Assert.AreEqual("DataGridColumnHeader", peer.GetClassName(), "#0"); // IsContentElement Assert.IsFalse(peer.IsContentElement(), "#0"); // GetName Assert.AreEqual(fe.Content, peer.GetName(), "GetName"); // GetClickablePoint Point p = peer.GetClickablePoint(); Assert.IsFalse(double.IsNaN(p.X), "#0"); Assert.IsFalse(double.IsNaN(p.Y), "#1"); // GetParent Assert.IsNotNull(peer.GetParent(), "GetParent"); // IsOffscreen Assert.IsFalse(peer.IsOffscreen(), "IsOffScreen"); }
protected override string GetNameCore() { AutomationPeer wrapperPeer = this.GetWrapperPeer(); string name = null; if (wrapperPeer != null) { name = wrapperPeer.GetName(); } if (name == null) { name = string.Empty; } return(name); }
/// <summary> /// Returns the text label of the Calendar that is associated with this /// CalendarAutomationPeer. This method is called by GetName. /// </summary> /// <returns> /// The text label of the element that is associated with this /// automation peer. /// </returns> protected override string GetNameCore() { string name = base.GetNameCore(); if (string.IsNullOrEmpty(name)) { AutomationPeer labeledBy = GetLabeledByCore(); if (labeledBy != null) { name = labeledBy.GetName(); } if (string.IsNullOrEmpty(name)) { name = OwningCalendar.ToString(); } } return(name); }
public static void NotifyScreenReaderAutomationIfKeyboardFocused(AutomationPeer automationPeer, UIElement uiElement) { if (uiElement.IsKeyboardFocused) { var str = uiElement.GetValue(AutomationProperties.NameProperty) as String; #if DEBUG Console.WriteLine("AUTOMATION NAME ==> " + str); var str2 = AutomationProperties.GetName(uiElement); DebugFix.Assert(str2 == str); if (automationPeer != null) { string str3 = automationPeer.GetName(); DebugFix.Assert(str3 == str); } #endif //DEBUG TextBlockWithAutomationPeer.NotifyScreenReaderAutomation(automationPeer, str); } }
/// <summary> /// /// </summary> /// <returns></returns> protected override string GetNameCore() { string nameCore = base.GetNameCore(); if (string.IsNullOrEmpty(nameCore)) { AutomationPeer labeledByCore = this.GetLabeledByCore(); if (labeledByCore != null) { nameCore = labeledByCore.GetName(); } if (string.IsNullOrEmpty(nameCore)) { nameCore = this.OwnerControl.ToString(); } } return(nameCore); }
/// <summary> /// Generates name from peer and list of children. /// Warning! It has clearing the Name AP as a side effect! /// </summary> /// <param name="peer"></param> /// <returns>Generated name.</returns> private static string GenerateNameFromPeer(AutomationPeer peer) { // Clear Name attached property to unhide any name generated by peer var element = GetUIElementFromAutomationPeer(peer); if (element != null) { element.ClearValue(AutomationProperties.NameProperty); } var ownName = peer.GetName(); if (!string.IsNullOrEmpty(ownName)) { // Own name present, we can use return(ownName); } // Defer to children return(GenerateNameFromChildren(peer.GetChildren())); }
public string GetRowDescription(int row) { if (tableProvider == null) { return(null); } IRawElementProviderSimple [] items = tableProvider.GetRowHeaders(); if (items == null || row < 0 || row >= items.Length) { return(null); } AutomationPeer peer = items [row].AutomationPeer; var frameworkPeer = peer as FrameworkElementAutomationPeer; if (frameworkPeer != null) { return(frameworkPeer.GetHelpText()); } return(peer.GetName()); }
/// <summary> /// Returns name for automation clients to display /// </summary> protected override string GetNameCore() { string name = base.GetNameCore(); RibbonMenuButton owner = OwningMenuButton; if (String.IsNullOrEmpty(name)) { name = owner.Label; } // Get ToggleButton.Content if (String.IsNullOrEmpty(name) && owner.PartToggleButton != null) { AutomationPeer buttonPeer = UIElementAutomationPeer.CreatePeerForElement(owner.PartToggleButton); if (buttonPeer != null) { name = buttonPeer.GetName(); } } return(name); }