Exemplo n.º 1
0
        public static ToolBarButton CreateGroupContainer(EntityOperationGroup group)
        {
            ToolBarButton groupButton = new ToolBarButton
            {
                Content     = group.Text(),
                ContextMenu = new ContextMenu(),
                Background  = group.Background,
            };

            Common.SetOrder(groupButton, group.Order);

            AutomationProperties.SetItemStatus(groupButton, "Group");

            if (group.AutomationName.HasText())
            {
                AutomationProperties.SetName(groupButton, group.AutomationName);
            }

            groupButton.ContextMenu = new ContextMenu
            {
                PlacementTarget = groupButton,
                Placement       = PlacementMode.Bottom,
            };

            ContextMenuService.SetIsEnabled(groupButton, false);

            groupButton.Click += (object sender, RoutedEventArgs e) =>
            {
                ToolBarButton tbb = (ToolBarButton)sender;
                tbb.ContextMenu.IsEnabled = true;
                tbb.ContextMenu.IsOpen    = true;
            };

            return(groupButton);
        }
Exemplo n.º 2
0
        protected virtual void OnEntityChanged(object oldValue, object newValue)
        {
            EntityChanged?.Invoke(this, isUserInteraction, oldValue, newValue);

            AutomationProperties.SetItemStatus(this, Common.GetEntityStringAndHashCode(newValue));

            UpdateVisibility();
        }
Exemplo n.º 3
0
        private void ProcessButton_Click(object sender, RoutedEventArgs e)
        {
            StatusButton.Text = "Hello Narrator ";

            // ACCESSIBILITY BUG FIX:
            // Note: WPF does not support LiveRegions and so Narrator will not announce
            // the above change made to the static label. One option here would be to
            // pop up a message conveying the current status. Instead, for this demo,
            // set the UIA ItemStatus property of the button to be the current status.

            AutomationProperties.SetItemStatus(ProcessButton, StatusButton.Text);
        }
Exemplo n.º 4
0
        private void OnSorted(object sender, ValueEventArgs <DataGridColumn> valueEventArgs)
        {
            var sortedColumn = valueEventArgs.Value;

            // Get all the column headers in this DataGrid.
            List <DataGridColumnHeader> columnHeaders = GetVisualChildCollection <DataGridColumnHeader>(sender as DataGrid);

            foreach (DataGridColumnHeader columnHeader in columnHeaders)
            {
                // If this is not the sorted column, clear any item status that may already exist
                // due to the DataGrid havng been previoulsy sorted by this column. If this sample
                // app, the ItemStatus is not use for any purpose other than conveying the current
                // sort order.
                if (columnHeader.Column != sortedColumn)
                {
                    AutomationProperties.SetItemStatus(columnHeader, "");
                }
                else
                {
                    // Important: At the time of writing this, when SetItemStatus() is
                    // called below, a UIA PropertyChanged event is automatically raised,
                    // meaning that screen readers such as Narrator are made aware of the
                    // change and can make a related accouncement if it wants to. If the
                    // event were not raise automatically, then an event could be raised
                    // here by uncommenting all the commented-out the code below.

                    // Get the current UIA ItemStatus from the header element. ​
                    //string oldStatus = AutomationProperties.GetItemStatus(columnHeader);

                    // Set the new status based on the current sort order.
                    string newStatus = columnHeader.SortDirection.ToString();

                    // Now set the new UIA ItemStatus on the header element.
                    AutomationProperties.SetItemStatus(columnHeader, newStatus);

                    // If an event were not automatically raised in response to the call
                    // to SetItemStatus(), then raise a UIA property changed event here.
                    // Note that the peer may be null here unless a UIA client app such as
                    // Narrator or the Accessibility Insights for Windows tool are running.
                    //var peer = FrameAutomationPeer.FromElement(columnHeader);
                    //if (peer != null)
                    //{
                    //    peer.RaisePropertyChangedEvent(
                    //        AutomationElementIdentifiers.ItemStatusProperty,
                    //        oldStatus,
                    //        newStatus);
                    //}
                }
            }
        }
Exemplo n.º 5
0
        private void OnValidationError(object sender, ValidationErrorEventArgs e)
        {
            // Get the current UIA ItemStatus from the element element.
            var oldStatus = AutomationProperties.GetItemStatus((DependencyObject)sender);

            // Set some sample new ItemStatus here...
            var newStatus = e.Action == ValidationErrorEventAction.Added ? e.Error.ErrorContent.ToString() : String.Empty;

            AutomationProperties.SetItemStatus((DependencyObject)sender, newStatus);

            // Having just set the new ItemStatus, raise a UIA property changed event. Note that the peer may
            // be null here unless a UIA client app such as Narrator or the AccEvent SDK tool are running.
            var automationPeer = UIElementAutomationPeer.FromElement((UIElement)sender);

            automationPeer?.RaisePropertyChangedEvent(AutomationElementIdentifiers.ItemStatusProperty, oldStatus, newStatus);
        }
Exemplo n.º 6
0
        static void RegisterUpdater(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            var fe = (FrameworkElement)sender;

            if ((bool)args.NewValue)
            {
                fe.DataContextChanged += Common_DataContextChanged;

                AutomationProperties.SetItemStatus(fe, GetEntityStringAndHashCode(fe.DataContext));
            }
            else
            {
                fe.DataContextChanged -= Common_DataContextChanged;

                AutomationProperties.SetItemStatus(fe, "");
            }
        }
Exemplo n.º 7
0
 private void OnConverterChanged(object converter)
 {
     AutomationProperties.SetItemStatus(this, ((TimeSpanConverter)converter)?.Format);
 }
Exemplo n.º 8
0
 private void ConverterChanged(object converter)
 {
     AutomationProperties.SetItemStatus(this, ((NullableNumericConverter)converter)?.Format);
 }
Exemplo n.º 9
0
 static void Common_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     AutomationProperties.SetItemStatus((DependencyObject)sender, GetEntityStringAndHashCode(e.NewValue));
 }