public static string SetAccessibilityName(this IAccessibleObject Control, Element Element, string _defaultAccessibilityName = null) { if (Element == null || Control == null) { return(_defaultAccessibilityName); } if (_defaultAccessibilityName == null) { _defaultAccessibilityName = Control.Name; } Control.Name = (string)Element.GetValue(AutomationProperties.NameProperty) ?? _defaultAccessibilityName; return(_defaultAccessibilityName); }
public static string SetAccessibilityDescription(this IAccessibleObject Control, Element Element, string _defaultAccessibilityDescription = null) { if (Element == null || Control == null) { return(_defaultAccessibilityDescription); } if (_defaultAccessibilityDescription == null) { _defaultAccessibilityDescription = Control.Description; } Control.Description = (string)Element.GetValue(AutomationProperties.HelpTextProperty) ?? _defaultAccessibilityDescription; return(_defaultAccessibilityDescription); }
public static void SetLabeledBy(this IAccessibleObject Control, Element Element) { if (Element == null || Control == null) { return; } var targetElement = (VisualElement)Element.GetValue(AutomationProperties.LabeledByProperty); AccessibleObject view = (AccessibleObject)Platform.GetRenderer(targetElement)?.NativeView; if (view != null) { Control.AppendRelation(new LabelledBy() { Target = view }); } }
public static bool?SetIsAccessibilityElement(this IAccessibleObject Control, Element Element, bool?_defaultIsAccessibilityElement = null) { if (Element == null || Control == null) { return(_defaultIsAccessibilityElement); } if (!_defaultIsAccessibilityElement.HasValue) { _defaultIsAccessibilityElement = Control.CanHighlight; } Control.CanHighlight = (bool)((bool?)Element.GetValue(AutomationProperties.IsInAccessibleTreeProperty) ?? _defaultIsAccessibilityElement); // Images are ignored by default on Tizen. So, make accessible in order to enable the gesture and narration if (Control.CanHighlight && Element is Image) { Control.Role = AccessRole.PushButton; } return(_defaultIsAccessibilityElement); }
Widget CreatePage(Window win, string pageName) { Box box = new Box(win); ((IAccessibleObject)box).Name = pageName; box.Show(); Button abutton = new Button(win) { Text = "Accessibility-normal", WeightX = 1, AlignmentX = -1 }; ((IAccessibleObject)abutton).TranslationDomain = "kr"; ((IAccessibleObject)abutton).Name = "Accessibility"; ((IAccessibleObject)abutton).Description = "Description for Accessibility"; Label abutton_label = new Label(win) { WeightX = 1, AlignmentX = -1 }; abutton_label.Text = "domain : " + ((IAccessibleObject)abutton).TranslationDomain + ", name : " + ((IAccessibleObject)abutton).Name + ", desc : " + ((IAccessibleObject)abutton).Description; Button bbutton = new Button(win) { Text = "Accessibility-provider", WeightX = 1, AlignmentX = -1 }; ((IAccessibleObject)bbutton).NameProvider = (obj) => "Name-provider"; ((IAccessibleObject)bbutton).DescriptionProvider = (obj) => "Description-provider"; Label bbutton_label = new Label(win) { WeightX = 1, AlignmentX = -1 }; bbutton_label.Text = "name : " + ((IAccessibleObject)bbutton).Name + ", desc : " + ((IAccessibleObject)bbutton).Description; Button cbutton = new Button(win) { Text = "Readingtype,CanHighlight", WeightX = 1, AlignmentX = -1 }; ((IAccessibleObject)cbutton).ReadingInfoType = ReadingInfoType.Name | ReadingInfoType.Role | ReadingInfoType.Description; ((IAccessibleObject)cbutton).Name = "FooFoo"; ((IAccessibleObject)cbutton).Role = AccessRole.Text; ((IAccessibleObject)cbutton).Description = "FooFooButton"; Label name_onoff_label = new Label(win) { Text = "ReadingInfoType.Name : " + ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.Name) != 0 ? "on" : "off"), WeightX = 1, AlignmentX = -1 }; Label role_onoff_label = new Label(win) { Text = "ReadingInfoType.Role : " + ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.Role) != 0 ? "on" : "off"), WeightX = 1, AlignmentX = -1 }; Label description_onoff_label = new Label(win) { Text = "ReadingInfoType.Description : " + ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.Description) != 0 ? "on" : "off"), WeightX = 1, AlignmentX = -1 }; Label state_onoff_label = new Label(win) { Text = "ReadingInfoType.State : " + ((((IAccessibleObject)cbutton).ReadingInfoType & ReadingInfoType.State) != 0 ? "on" : "off"), WeightX = 1, AlignmentX = -1 }; Button saybutton = new Button(win) { Text = "HHGG with false", WeightX = 1, AlignmentX = -1 }; Button saybutton2 = new Button(win) { Text = "HHGG with true", WeightX = 1, AlignmentX = -1 }; int labelIndex = 0; Button roleButton = new Button(win) { WeightX = 1, AlignmentX = -1 }; roleButton.Clicked += (s, e) => { if (labelIndex >= accessRoleValues.Length) { labelIndex = 0; } IAccessibleObject obj = roleButton as IAccessibleObject; AccessRole role = (AccessRole)accessRoleValues.GetValue(labelIndex); obj.Role = role; roleButton.Text = Enum.GetName(typeof(AccessRole), obj.Role); labelIndex++; }; Label label = new Label(win) { Text = string.Format("{0} Apple", sequence++), WeightX = 1, AlignmentX = -1 }; ((IAccessibleObject)label).Name = "Apple"; Button push = new Button(win) { Text = "Push", WeightX = 1, AlignmentX = -1 }; ((IAccessibleObject)push).Name = "PushButton"; Button pop = new Button(win) { Text = "pop", WeightX = 1, AlignmentX = -1, }; ((IAccessibleObject)pop).Name = "PopButton"; abutton.Show(); abutton_label.Show(); bbutton.Show(); bbutton_label.Show(); cbutton.Show(); name_onoff_label.Show(); role_onoff_label.Show(); description_onoff_label.Show(); state_onoff_label.Show(); saybutton.Show(); saybutton2.Show(); roleButton.Show(); label.Show(); push.Show(); pop.Show(); push.Clicked += (s, e) => { NaviItem item = navi.Push(CreatePage(win, string.Format("Apple {0}", sequence - 1)), string.Format("Page {0}", sequence - 1)); }; Label statusLog = new Label(win) { WeightX = 1, AlignmentX = -1 }; statusLog.Show(); saybutton.Clicked += (s, e) => { AccessibleUtil.Say("The Hitchhiker's Guide to the Galaxy", false) .ContinueWith(status => { statusLog.Text = StatusStr(status.Result); }); }; saybutton2.Clicked += (s, e) => { AccessibleUtil.Say("The Hitchhiker's Guide to the Galaxy", true) .ContinueWith(status => { statusLog.Text = StatusStr(status.Result); }); }; pop.Clicked += (s, e) => { var item = navi.NavigationStack.LastOrDefault(); navi.Pop(); }; box.PackEnd(abutton); box.PackEnd(abutton_label); box.PackEnd(bbutton); box.PackEnd(bbutton_label); box.PackEnd(cbutton); box.PackEnd(name_onoff_label); box.PackEnd(role_onoff_label); box.PackEnd(description_onoff_label); box.PackEnd(state_onoff_label); box.PackEnd(saybutton); box.PackEnd(saybutton2); box.PackEnd(roleButton); box.PackEnd(label); box.PackEnd(push); box.PackEnd(pop); box.PackEnd(statusLog); return(box); }