コード例 #1
0
ファイル: FixedElement.cs プロジェクト: beda2280/wpf-1
        private Image GetImage()
        {
            Image image  = null; // return value
            Uri   source = _object as Uri;

            if (source != null)
            {
                image        = new Image();
                image.Source = new System.Windows.Media.Imaging.BitmapImage(source);
                image.Width  = image.Source.Width;
                image.Height = image.Source.Height;

                AutomationProperties.SetName(image, (String)this.GetValue(NameProperty));
                AutomationProperties.SetHelpText(image, (String)this.GetValue(HelpTextProperty));
            }
            return(image);
        }
コード例 #2
0
        private async void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case nameof(ViewModel.NextDefaultScanAction):
                await RunOnUIThreadAsync(CoreDispatcherPriority.Low, () =>
                {
                    switch (ViewModel.NextDefaultScanAction)
                    {
                    case ViewModels.ScanAction.AddPages:
                        MenuFlyoutItemButtonScan.FontWeight = Windows.UI.Text.FontWeights.SemiBold;
                        MenuFlyoutItemButtonScanAddToDocument.FontWeight = Windows.UI.Text.FontWeights.Normal;
                        MenuFlyoutItemButtonScanFresh.FontWeight         = Windows.UI.Text.FontWeights.Normal;
                        AutomationProperties.SetName(ButtonScan, MenuFlyoutItemButtonScan.Text);
                        break;

                    case ViewModels.ScanAction.AddPagesToDocument:
                    default:
                        MenuFlyoutItemButtonScan.FontWeight = Windows.UI.Text.FontWeights.Normal;
                        MenuFlyoutItemButtonScanAddToDocument.FontWeight = Windows.UI.Text.FontWeights.SemiBold;
                        MenuFlyoutItemButtonScanFresh.FontWeight         = Windows.UI.Text.FontWeights.Normal;
                        AutomationProperties.SetName(ButtonScan, MenuFlyoutItemButtonScanAddToDocument.Text);
                        break;

                    case ViewModels.ScanAction.StartFresh:
                        MenuFlyoutItemButtonScan.FontWeight = Windows.UI.Text.FontWeights.Normal;
                        MenuFlyoutItemButtonScanAddToDocument.FontWeight = Windows.UI.Text.FontWeights.Normal;
                        MenuFlyoutItemButtonScanFresh.FontWeight         = Windows.UI.Text.FontWeights.SemiBold;
                        AutomationProperties.SetName(ButtonScan, MenuFlyoutItemButtonScanFresh.Text);
                        break;
                    }
                });

                break;

            case nameof(ViewModel.SelectedResolution):
                await RunOnUIThreadAsync(CoreDispatcherPriority.Low, () =>
                {
                    // fix resolution ComboBox appears empty for new scanner
                    ComboBoxResolution.SelectedItem = ViewModel.SelectedResolution;
                });

                break;
            }
        }
コード例 #3
0
        public void VerifyUIANameBehavior()
        {
            NumberBox numberBox = null;
            TextBox   textBox   = null;

            RunOnUIThread.Execute(() =>
            {
                numberBox = new NumberBox();
                Content   = numberBox;
                Content.UpdateLayout();

                textBox = TestPage.FindVisualChildrenByType <TextBox>(numberBox)[0];
                Verify.IsNotNull(textBox);
                numberBox.Header = "Some header";
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                VerifyUIAName("Some header");
                numberBox.Header = new Button();
                AutomationProperties.SetName(numberBox, "Some UIA name");
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                VerifyUIAName("Some UIA name");
                numberBox.Header = new Button();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                VerifyUIAName("Some UIA name");
            });

            void VerifyUIAName(string value)
            {
                Verify.AreEqual(value, FrameworkElementAutomationPeer.CreatePeerForElement(textBox).GetName());
            }
        }
コード例 #4
0
        public HitTest_LightDismiss()
        {
            this.InitializeComponent();

            var popupChild = new Border
            {
                Width      = 220,
                Height     = 140,
                Background = new SolidColorBrush(Colors.DarkGreen),
                Child      = new TextBlock
                {
                    Text = "X",
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                }
            };

            _popup = new Popup
            {
                Child = popupChild
            };
            AutomationProperties.SetAutomationId(popupChild, "TargetPopupContent");
            popupChild.PointerPressed += (o, e) => ResultTextBlock.Text = "Popup content pressed";

            void OnFlyoutOpenedOrClosed(object sender, object args)
            {
                FlyoutStatusTextBlock.Text = ((Flyout)sender).IsOpen.ToString();
            }

            ButtonFlyout.Opened += OnFlyoutOpenedOrClosed;
            ButtonFlyout.Closed += OnFlyoutOpenedOrClosed;

            void OnPopupOpenedOrClosed(object sender, object args)
            {
                PopupStatusTextBlock.Text = ((Popup)sender).IsOpen.ToString();
            }

            _popup.Opened += OnPopupOpenedOrClosed;
            _popup.Closed += OnPopupOpenedOrClosed;

            TargetComboBox.SelectionChanged += (o, e) =>
            {
                ResultTextBlock.Text = $"Item selected";
            };
        }
コード例 #5
0
        public TestPage()
        {
            AutomationProperties.SetName(this, "TestPage");
            Loaded += OnLoaded;

            Resources.ThemeDictionaries["Default"] = new ResourceDictionary
            {
                { "WhichTheme", ApplicationTheme.Dark }
            };
            Resources.ThemeDictionaries["Light"] = new ResourceDictionary
            {
                { "WhichTheme", ApplicationTheme.Light }
            };
            Resources.ThemeDictionaries["HighContrast"] = new ResourceDictionary
            {
                { "WhichTheme", ApplicationTheme.Light }
            };
        }
コード例 #6
0
        const float c_hoverLight_OuterConeAngle_Expected = 0.469878F;         // Does not change for any state.

        public RevealStatesPage()
        {
            this.InitializeComponent();

            if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
            {
                AutomationProperties.SetName(this, "RevealStatesPage");
                AutomationProperties.SetAutomationId(this, "RevealStatesPage");

                _revealTestApi      = new RevealTestApi();
                _revealBrushTestApi = new RevealBrushTestApi();

                _compositionPropertyLogger = new CompositionPropertyLogger();

                MaterialHelperTestApi.IgnoreAreEffectsFast     = true;
                MaterialHelperTestApi.SimulateDisabledByPolicy = false;
            }
        }
コード例 #7
0
 // This is called when the layout is updated to update the accessible name of the edit, delete and save buttons.
 private void TaskListsView_LayoutUpdated(object sender, object e)
 {
     for (int i = 0; i < TaskListCollection.Count; i++)
     {
         var item = TaskListsView.ContainerFromIndex(i) as FrameworkElement;
         if (item != null)
         {
             var grid         = VisualTreeHelper.GetChild(item, 0) as FrameworkElement;
             var buttonStack  = VisualTreeHelper.GetChild(grid, 2) as FrameworkElement;
             var editButton   = VisualTreeHelper.GetChild(buttonStack, 0) as FrameworkElement;
             var saveButton   = VisualTreeHelper.GetChild(buttonStack, 1) as FrameworkElement;
             var deleteButton = VisualTreeHelper.GetChild(buttonStack, 2) as FrameworkElement;
             AutomationProperties.SetName(editButton, TaskListCollection.ElementAt(i).Name + " Edit Button");
             AutomationProperties.SetName(saveButton, TaskListCollection.ElementAt(i).Name + " Save Button ");
             AutomationProperties.SetName(deleteButton, TaskListCollection.ElementAt(i).Name + " Delete Button");
         }
     }
 }
コード例 #8
0
ファイル: InputBox.xaml.cs プロジェクト: blueglare/FSClient2
        public static string[] GetTwoInput(String title, String desc, String label1, String default_value1, String label2, String default_value2)
        {
            InputBox box = new InputBox();

            box.lblDesc.Content = desc;
            box.Title           = title;
            box.rowInput.Height = new GridLength(60);
            box.Height          = 170;
            AutomationProperties.SetName(box.txtInput, desc);
            box.txtInput.Text  = default_value1;
            box.txtInput2.Text = default_value2;
            if (box.ShowDialog() != true)
            {
                return(null);
            }

            return(new[] { box.txtInput.Text, box.txtInput2.Text });
        }
コード例 #9
0
        private void UpdateTimer_Tick(object sender, object e)
        {
            var focusedControl = FocusManager.GetFocusedElement() as FrameworkElement;

            if (focusedControl == null)
            {
                ClearContent();
                return;
            }

            controlName.Text           = focusedControl.Name;
            controlType.Text           = focusedControl.GetType().Name;
            controlAutomationName.Text = AutomationProperties.GetName(focusedControl);

            var parentWithName = FindVisualAscendantWithName(focusedControl);

            controlFirstParentWithName.Text = parentWithName?.Name ?? string.Empty;
        }
        private void ShowErrorHResult()
        {
            this.tbResult.Visibility       = Visibility.Visible;
            this.cbElements.Visibility     = Visibility.Collapsed;
            this.ctrlProperties.Visibility = Visibility.Collapsed;
            this.ctrlPatterns.Visibility   = Visibility.Collapsed;
            this.cbElements.ItemsSource    = null;

            if (this.ActionViewModel.ReturnValue != null)
            {
                this.tbResult.Text = string.Format(Properties.Resources.ReturnA11yElementsView_ShowErrorHResult_Failed_HResult_0x_0_X8, this.ActionViewModel.ReturnValue);
            }
            else
            {
                this.tbResult.Text = Properties.Resources.FailedEmphasizedText;
            }
            AutomationProperties.SetName(this.tbResult, "Execution result failed");
        }
コード例 #11
0
        /// <summary>
        /// Updates the columns from column settings.
        /// </summary>
        /// <param name="dataGrid">The data grid.</param>
        private static void UpdateColumnsFromColumnSettings(DataGrid dataGrid)
        {
            if (!GetIsUpdatingColumnSettings(dataGrid))
            {
                SetIsUpdatingColumnSettings(dataGrid, true);

                string    columnSettings = GetColumnSettings(dataGrid);
                ArrayList columnInfos    = (ArrayList)XamlReader.Parse(columnSettings);
                foreach (DataGridColumnInfo columnInfo in columnInfos)
                {
                    DataGridColumn column = dataGrid.Columns.FirstOrDefault(
                        x => string.Equals(columnInfo.Name, AutomationProperties.GetName(x), System.StringComparison.Ordinal));
                    columnInfo.Apply(column, dataGrid.Columns.Count);
                }

                SetIsUpdatingColumnSettings(dataGrid, false);
            }
        }
コード例 #12
0
ファイル: BurlsExpander.cs プロジェクト: BEzGumpTion/Burls
        private static void OnHeaderChanged(DependencyObject d, DependencyProperty dp)
        {
            BurlsExpander self = (BurlsExpander)d;

            if (self.Header != null)
            {
                if (self.Header.GetType() == typeof(BurlsItem))
                {
                    BurlsItem selfSetting = (BurlsItem)self.Header;
                    selfSetting.Style = (Style)App.Current.Resources["ExpanderHeaderSettingStyle"];

                    if (!string.IsNullOrEmpty(selfSetting.Header))
                    {
                        AutomationProperties.SetName(self, selfSetting.Header);
                    }
                }
            }
        }
コード例 #13
0
        public void VerifyTreeComplyBehavior()
        {
            var noMainPeer = FrameworkElementAutomationPeer.CreatePeerForElement(new Button());
            var mainButton = new Button();

            AutomationProperties.SetLandmarkType(mainButton, AutomationLandmarkType.Main);
            var mainPeer = FrameworkElementAutomationPeer.CreatePeerForElement(mainButton);
            var rule     = new LandmarkTypeMainOnceRule();

            Assert.IsTrue(rule.IsValid(null, noMainPeer));

            Assert.IsTrue(rule.IsValid(null, mainPeer));

            for (int i = 0; i < 10; i++)
            {
                Assert.IsTrue(rule.IsValid(null, noMainPeer));
            }
        }
コード例 #14
0
        public void SetAccessibilityLiveRegion(TFrameworkElement view, string liveRegion)
        {
            var liveSetting = AutomationLiveSetting.Off;

            switch (liveRegion)
            {
            case "polite":
                liveSetting = AutomationLiveSetting.Polite;
                break;

            case "assertive":
                liveSetting = AutomationLiveSetting.Assertive;
                break;
            }

            AutomationProperties.SetLiveSetting(view, liveSetting);
            AccessibilityHelper.AnnounceIfNeeded(view);
        }
コード例 #15
0
        /// <summary>
        /// This method is used to prompt to login screen.
        /// </summary>
        /// <returns>True if sign in successfully, otherwise false</returns>
        public async Task <bool> SignInAsync()
        {
            if (await GraphService.TryLoginAsync())
            {
                AutomationProperties.SetName(this, string.Empty);

                Flyout = GenerateMenuItems();

                SignInCompleted?.Invoke(this, new SignInEventArgs()
                {
                    GraphClient = GraphService.GraphProvider
                });

                return(true);
            }

            return(false);
        }
コード例 #16
0
        private void PersonPicture_Loaded(object sender, RoutedEventArgs e)
        {
            string    InitialTextBlockName = "InitialsTextBlock";
            TextBlock initialTextBlock     = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, InitialTextBlockName) as TextBlock;

            if (initialTextBlock != null)
            {
                AutomationProperties.SetName(initialTextBlock, InitialTextBlockName);
                AutomationProperties.SetAccessibilityView(initialTextBlock, AccessibilityView.Content);
            }

            string    badgeTextBlockName = "BadgeNumberTextBlock";
            TextBlock badgeTextBlock     = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, badgeTextBlockName) as TextBlock;

            if (badgeTextBlock != null)
            {
                AutomationProperties.SetName(badgeTextBlock, badgeTextBlockName);
                AutomationProperties.SetAccessibilityView(badgeTextBlock, AccessibilityView.Content);
            }

            string   badgeGlyphIconName = "BadgeGlyphIcon";
            FontIcon badgeFontIcon      = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, badgeGlyphIconName) as FontIcon;

            if (badgeFontIcon != null)
            {
                AutomationProperties.SetName(badgeFontIcon, badgeGlyphIconName);
                AutomationProperties.SetAccessibilityView(badgeFontIcon, AccessibilityView.Content);
            }

            string  badgeEllipseName = "BadgingEllipse";
            Ellipse badgeEllipse     = VisualTreeUtils.FindVisualChildByName(this.TestPersonPicture, badgeEllipseName) as Ellipse;

            if (badgeEllipse != null)
            {
                AutomationProperties.SetName(badgeEllipse, badgeEllipseName);
                AutomationProperties.SetAccessibilityView(badgeEllipse, AccessibilityView.Content);
            }

            // Uno docs: This currently fails and returns null.
            // https://github.com/unoplatform/uno/issues/7258
            //CollectionViewSource cvs = rootGrid.FindName("cvs") as CollectionViewSource;
            cvs.Source          = GetGroupedPeople();
            cvs.IsSourceGrouped = true;
        }
コード例 #17
0
        /// <summary>
        /// Override default OnApplyTemplate to capture child controls
        /// </summary>
        protected async override void OnApplyTemplate()
        {
            ApplyTemplate();

            AutomationProperties.SetName(this, SignInDefaultText);

            Click -= AadLogin_Clicked;
            Click += AadLogin_Clicked;

            GraphService.IsAuthenticatedChanged -= GraphService_StateChanged;
            GraphService.IsAuthenticatedChanged += GraphService_StateChanged;

            if (GraphService.IsAuthenticated)
            {
                CurrentUserId = (await GraphService.User.GetProfileAsync(new MicrosoftGraphUserFields[1] {
                    MicrosoftGraphUserFields.Id
                })).Id;
            }
        }
        private void ExecuteAction()
        {
            this.ActionViewModel.DoAction();

            if (this.ActionViewModel.ReturnType == typeof(void) || this.ActionViewModel.IsSucceeded == false)
            {
                this.ctrlTextRange.Visibility = Visibility.Collapsed;
                this.tbResult.Visibility      = Visibility.Visible;

                if (this.ActionViewModel.IsSucceeded)
                {
                    this.tbResult.Text = Properties.Resources.TextRangeActionView_ExecuteAction_Succeeded;
                    AutomationProperties.SetName(this.tbResult, Properties.Resources.TextRangeActionView_ExecuteAction_Execution_result_passed);
                }
                else
                {
                    if (this.ActionViewModel.ReturnValue != null)
                    {
                        this.tbResult.Text = string.Format(Properties.Resources.TextRangeActionView_ExecuteAction_Failed_HResult__0x_0_X8, this.ActionViewModel.ReturnValue);
                    }
                    else
                    {
                        this.tbResult.Text = Properties.Resources.TextRangeActionView_ExecuteAction_Failed;
                    }
                    AutomationProperties.SetName(this.tbResult, Properties.Resources.TextRangeActionView_ExecuteAction_Execution_result_failed);
                }
            }
            else
            {
                if (this.ActionViewModel.ReturnValue != null)
                {
                    this.ctrlTextRange.Visibility = Visibility.Visible;
                    this.tbResult.Visibility      = Visibility.Collapsed;
                    this.ctrlTextRange.SetTextRangeViewModel(new TextRangeViewModel(this.ActionViewModel.ReturnValue, null));
                }
                else
                {
                    this.tbResult.Visibility      = Visibility.Visible;
                    this.ctrlTextRange.Visibility = Visibility.Collapsed;
                    this.tbResult.Text            = Properties.Resources.TextRangeActionView_ExecuteAction_No_error_but_No_TextRange_is_returned;
                }
            }
        }
コード例 #19
0
        private void SetAllAutomationProperties(DependencyObject dependencyObject)
        {
            if (dependencyObject != null)
            {
                AutomationProperties.SetName(dependencyObject, string.Format(formatName, i));
                dependencyObject.SetValue(AutomationProperties.HelpTextProperty, string.Format(formatHelp, i));
                i++;

                var children = dependencyObject.GetChildren().ToList();

                if (children != null)
                {
                    foreach (var child in children)
                    {
                        SetAllAutomationProperties(child);
                    }
                }
            }
        }
コード例 #20
0
 /// <summary>
 /// In some cases (just Popovers currently) we need to wait to set the automation properties until the element
 /// that needs them comes into existence (a PopoverRoot in the case of a Popover, when it's shown).  This is
 /// used for that delayed initialization.
 /// </summary>
 /// <param name="element">UIElement on which to set the properties</param>
 public void InitAutomationProperties(UIElement element)
 {
     if (identifier != null)
     {
         AutomationProperties.SetAutomationId(element, identifier);
     }
     if (label != null)
     {
         AutomationProperties.SetName(element, label);
     }
     if (description != null)
     {
         AutomationProperties.SetHelpText(element, description);
     }
     if (labelWidget != null)
     {
         AutomationProperties.SetLabeledBy(element, (Toolkit.GetBackend(labelWidget) as WidgetBackend)?.Widget);
     }
 }
コード例 #21
0
        private void ResizeForm()
        {
            int border_calls_width = 238;
            int accounts_left      = 237;
            int total_width        = 253;
            int body_left          = 3;

            if (borderAccounts.Visibility == Visibility.Visible)
            {
                total_width += 196;
                AutomationProperties.SetName(btnAccountsTab, "Accounts Pane Hide");
            }
            else
            {
                AutomationProperties.SetName(btnAccountsTab, "Accounts Pane Show");
            }
            if (borderCalls.Visibility == Visibility.Visible)
            {
                total_width   += border_calls_width;
                body_left     += border_calls_width;
                accounts_left += border_calls_width;
                if (!border_calls_was_visible)
                {
                    border_calls_was_visible = true;
                    Left -= border_calls_width;
                }
                AutomationProperties.SetName(btnCallsTab, "Calls Pane Hide");
            }
            else if (border_calls_was_visible)
            {
                border_calls_was_visible = false;
                Left += border_calls_width;
                AutomationProperties.SetName(btnCallsTab, "Calls Pane Show");
            }
            else
            {
                AutomationProperties.SetName(btnCallsTab, "Calls Pane Show");
            }

            Canvas.SetLeft(canvasPhoneBody, body_left);
            Canvas.SetLeft(borderAccounts, accounts_left);
            Width = total_width;
        }
コード例 #22
0
        private void SetAccessibilityTraits()
        {
            var baseElement = Element as   MvvmAspire.Controls.Image;

            if (baseElement != null && baseElement.AccessibilityTraits != string.Empty)
            {
                var accessiblityTrait = baseElement.AccessibilityTraits;

                switch (accessiblityTrait)
                {
                case "button":
                    AutomationProperties.SetName(baseElement, AutomationProperties.GetName(baseElement) + " button. Double tap to activate.");
                    break;

                default:
                    break;
                }
            }
        }
コード例 #23
0
ファイル: StartWindow.xaml.cs プロジェクト: sanslash332/t5
        public StartWindow(MainWindow _screen)
        {
            InitializeComponent();
            StartSinglePlayerButton.Click += new RoutedEventHandler(StartSinglePlayerButton_Click);
            buttonCreate.Click            += new RoutedEventHandler(buttonCreate_Click);
            buttonJoin.Click += new RoutedEventHandler(buttonJoin_Click);
            playerScreen      = _screen;
            AutomationProperties.SetName(IpTextBox, "Ip to conect");
            AutomationProperties.SetName(PortConectTextBox, "Port to use in conection");
            AutomationProperties.SetName(playlifetextbox, "Life to habe te canons");
            AutomationProperties.SetName(InitialMineralTextBox, "Mineral to start");
            AutomationProperties.SetName(TotalMineralTextBox, "Max mineral of mine");
            AutomationProperties.SetName(PortTextBox, "Port use for server");
            AutomationProperties.SetName(iptextBoxdisplay, "ips availables");
            iptextBoxdisplay.Text = "Your ip directions: ";
            adjustip();

            Closed += new EventHandler(StartWindow_Closed);
        }
コード例 #24
0
        private void PersonPicture_Loaded(object sender, RoutedEventArgs e)
        {
            string    InitialTextBlockName = "InitialsTextBlock";
            TextBlock initialTextBlock     = FindVisualChildByName(this.TestPersonPicture, InitialTextBlockName) as TextBlock;

            if (initialTextBlock != null)
            {
                AutomationProperties.SetName(initialTextBlock, InitialTextBlockName);
                AutomationProperties.SetAccessibilityView(initialTextBlock, AccessibilityView.Content);
            }

            string    badgeTextBlockName = "BadgeNumberTextBlock";
            TextBlock badgeTextBlock     = FindVisualChildByName(this.TestPersonPicture, badgeTextBlockName) as TextBlock;

            if (badgeTextBlock != null)
            {
                AutomationProperties.SetName(badgeTextBlock, badgeTextBlockName);
                AutomationProperties.SetAccessibilityView(badgeTextBlock, AccessibilityView.Content);
            }

            string   badgeGlyphIconName = "BadgeGlyphIcon";
            FontIcon badgeFontIcon      = FindVisualChildByName(this.TestPersonPicture, badgeGlyphIconName) as FontIcon;

            if (badgeFontIcon != null)
            {
                AutomationProperties.SetName(badgeFontIcon, badgeGlyphIconName);
                AutomationProperties.SetAccessibilityView(badgeFontIcon, AccessibilityView.Content);
            }

            string  badgeEllipseName = "BadgingEllipse";
            Ellipse badgeEllipse     = FindVisualChildByName(this.TestPersonPicture, badgeEllipseName) as Ellipse;

            if (badgeEllipse != null)
            {
                AutomationProperties.SetName(badgeEllipse, badgeEllipseName);
                AutomationProperties.SetAccessibilityView(badgeEllipse, AccessibilityView.Content);
            }

            CollectionViewSource cvs = rootGrid.FindName("cvs") as CollectionViewSource;

            cvs.Source          = GetGroupedPeople();
            cvs.IsSourceGrouped = true;
        }
コード例 #25
0
        /// <summary>
        /// Update <see cref="AutomationProperties.NameProperty"/> on <paramref name="peer"/>'s owner
        /// and all its parents as far up as needed and only when the name is generated. This must be called
        /// when anything influencing generated names has changed in <paramref name="peer"/>'s owner or somewhere in its subtree.
        /// </summary>
        /// <param name="peer"></param>
        private static void UpdateGeneratedNameHereAndUp(AutomationPeer peer)
        {
            var current = peer;

            while (current != null)
            {
                UIElement element = GetUIElementFromAutomationPeer(current);
                if (IsElementIgnoresChildrenForName(element))
                {
                    break;
                }
                if (IsInGenerativeState(element))
                {
                    var generatedName = GenerateNameFromUpdated(current);
                    AutomationProperties.SetName(element, generatedName);
                }
                current = current.Navigate(AutomationNavigationDirection.Parent) as AutomationPeer;
            }
        }
コード例 #26
0
        private void AddNavigationMenuItems()
        {
            foreach (var group in ControlInfoDataSource.Instance.Groups.OrderBy(i => i.Title))
            {
                var itemGroup = new Microsoft.UI.Xaml.Controls.NavigationViewItem()
                {
                    Content = group.Title, Tag = group.UniqueId, DataContext = group, Icon = GetIcon(group.ImagePath)
                };
                AutomationProperties.SetName(itemGroup, group.Title);

                foreach (var item in group.Items)
                {
                    var itemInGroup = new Microsoft.UI.Xaml.Controls.NavigationViewItem()
                    {
                        Content = item.Title, Tag = item.UniqueId, DataContext = item, Icon = GetIcon(item.ImagePath)
                    };
                    itemGroup.MenuItems.Add(itemInGroup);
                    AutomationProperties.SetName(itemInGroup, item.Title);
                }

                NavigationViewControl.MenuItems.Add(itemGroup);

                if (group.UniqueId == "AllControls")
                {
                    this._allControlsMenuItem = itemGroup;
                }
                else if (group.UniqueId == "NewControls")
                {
                    this._newControlsMenuItem = itemGroup;
                }
            }

            // Move "What's New" and "All Controls" to the top of the NavigationView
            NavigationViewControl.MenuItems.Remove(_allControlsMenuItem);
            NavigationViewControl.MenuItems.Remove(_newControlsMenuItem);
            NavigationViewControl.MenuItems.Insert(0, _allControlsMenuItem);
            NavigationViewControl.MenuItems.Insert(0, _newControlsMenuItem);

            // Separate the All/New items from the rest of the categories.
            NavigationViewControl.MenuItems.Insert(2, new Microsoft.UI.Xaml.Controls.NavigationViewItemSeparator());

            _newControlsMenuItem.Loaded += OnNewControlsMenuItemLoaded;
        }
        private void ExecuteAction()
        {
            this.ActionViewModel.DoAction();

            if (this.ActionViewModel.ReturnType == typeof(void))
            {
                ReadyForShowingText();

                if (this.ActionViewModel.IsSucceeded)
                {
                    this.tbResult.Text = Properties.Resources.ReturnA11yElementsView_ExecuteAction_Succeeded;
                    AutomationProperties.SetName(this.tbResult, Properties.Resources.ReturnA11yElementsView_ExecuteAction_Execution_result_passed);
                }
                else
                {
                    ShowErrorHResult();
                }
            }
            else
            {
                if (this.ActionViewModel.IsSucceeded == true)
                {
                    if (this.ActionViewModel.ReturnValue != null && this.ActionViewModel.ReturnValue.Count != 0)
                    {
                        ReadyForShowingElements();

                        this.cbElements.ItemsSource   = this.ActionViewModel.ReturnValue;
                        this.cbElements.SelectedIndex = 0;
                    }
                    else
                    {
                        ReadyForShowingText();

                        this.tbResult.Text = Properties.Resources.ReturnA11yElementsView_ExecuteAction_Succeeded_with_no_element_returned;
                    }
                    AutomationProperties.SetName(this.tbResult, Properties.Resources.ReturnA11yElementsView_ExecuteAction_Execution_result_passed);
                }
                else
                {
                    ShowErrorHResult();
                }
            }
        }
        /// <summary>
        /// Add a button segment to the control
        /// </summary>
        /// <param name="content">The content of the button, either text or image</param>
        /// <param name="helpTitle">The title of the help window that appears on hover</param>
        /// <param name="helpMessage">The message in the help window that appears on hover</param>
        /// <param name="isPrimary">Indicates how the button should be styled</param>
        private void AddButton(object content, string automationName, IQuickHelpControlBuilder?helpBuilder, bool isPrimary)
        {
            var button = new ActionButton();

            // We started with a design that had two styles of buttons: primary and secondary
            // They featured different background shades, but the lighter shade was too low of
            // contrast wit the white text for users who need high contrast.  So we're now
            // using only the primary style and adding a space in between the buttons
            button.Style       = CreatePrimaryButtonStyle();
            button.Content     = content;
            button.HelpBuilder = helpBuilder;
            AutomationProperties.SetName(button, automationName);
            button.Click += Button_Click;
            if (ActionStack.Children.Count > 0)
            {
                button.Margin = new Thickness(1, 0, 0, 0);
            }
            ActionStack.Children.Add(button);
        }
コード例 #29
0
        /// <inheritdoc />
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_dismissButton != null)
            {
                _dismissButton.Click -= DismissButton_Click;
            }

            if (_visualStateGroup != null)
            {
                _visualStateGroup.CurrentStateChanging -= OnCurrentStateChanging;
                _visualStateGroup.CurrentStateChanged  -= OnCurrentStateChanged;
            }

            _dismissButton    = (Button)GetTemplateChild(DismissButtonPart);
            _visualStateGroup = (VisualStateGroup)GetTemplateChild(GroupContent);
            _contentProvider  = (ContentPresenter)GetTemplateChild(ContentPresenterPart);

            if (_dismissButton != null)
            {
                _dismissButton.Visibility = ShowDismissButton ? Visibility.Visible : Visibility.Collapsed;
                _dismissButton.Click     += DismissButton_Click;
                //AutomationProperties.SetName(_dismissButton, "Dismiss Notification");
            }

            if (_visualStateGroup != null)
            {
                _visualStateGroup.CurrentStateChanging += OnCurrentStateChanging;
                _visualStateGroup.CurrentStateChanged  += OnCurrentStateChanged;
            }

            var firstNotification = _stackedNotificationOptions.FirstOrDefault();

            if (firstNotification != null)
            {
                UpdateContent(firstNotification);
                VisualStateManager.GoToState(this, StateContentVisible, true);
            }

            AutomationProperties.SetLabeledBy(this, this.GetFirstDescendantOfType <ContentPresenter>());
        }
コード例 #30
0
        /// <inheritdoc />
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_dismissButton != null)
            {
                _dismissButton.Click -= DismissButton_Click;
            }

            if (_visualStateGroup != null)
            {
                _visualStateGroup.CurrentStateChanging -= OnCurrentStateChanging;
                _visualStateGroup.CurrentStateChanged  -= OnCurrentStateChanged;
            }

            _dismissButton    = (Button)GetTemplateChild(DismissButtonPart);
            _visualStateGroup = (VisualStateGroup)GetTemplateChild(GroupContent);
            _contentProvider  = (ContentPresenter)GetTemplateChild(ContentPresenterPart);

            if (_dismissButton != null)
            {
                _dismissButton.Visibility = ShowDismissButton ? Visibility.Visible : Visibility.Collapsed;
                _dismissButton.Click     += DismissButton_Click;
                AutomationProperties.SetName(_dismissButton, "WCT_InAppNotification_DismissButton_AutomationName".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls/Resources"));
            }

            if (_visualStateGroup != null)
            {
                _visualStateGroup.CurrentStateChanging += OnCurrentStateChanging;
                _visualStateGroup.CurrentStateChanged  += OnCurrentStateChanged;
            }

            var firstNotification = _stackedNotificationOptions.FirstOrDefault();

            if (firstNotification != null)
            {
                UpdateContent(firstNotification);
                VisualStateManager.GoToState(this, StateContentVisible, true);
            }

            AutomationProperties.SetLabeledBy(this, VisualTree.FindDescendant <ContentPresenter>(this));
        }