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(1, new Microsoft.UI.Xaml.Controls.NavigationViewItemSeparator());

            //_newControlsMenuItem.Loaded += OnNewControlsMenuItemLoaded;
        }
Esempio n. 2
0
        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;
                }
            }
        }
Esempio n. 3
0
        private void ResizeForm()
        {
            int border_calls_width = 228;
            int accounts_left      = 237;
            int total_width        = 243;
            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;
        }
        /// <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);
        }
Esempio n. 5
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);
     }
 }
        /// <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 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.FindResource("cvs") as CollectionViewSource;

            cvs.GroupDescriptions.Add(new SportsGroupDescription());
            cvs.Source = GetGroupedPeople().SelectMany(g => g).ToList();
        }
        /// <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;
            }
        }
        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();
                }
            }
        }
        private async void LoadedHandler(object sender, RoutedEventArgs e)
        {
            this.Loaded -= LoadedHandler;
            if (OverlayToggleSwitch.IsOn)
            {
                var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
                preferences.CustomSize = new Size(400, 260);
                bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, preferences);

                GoToOverlayIcon.Visibility = Visibility.Collapsed;
                ExitOverlayIcon.Visibility = Visibility.Visible;
                ToolTip toolTip = new ToolTip();
                toolTip.Content = Strings.Resources.ExitOverlay;
                ToolTipService.SetToolTip(OverlayButton, toolTip);
                AutomationProperties.SetName(OverlayButton, Strings.Resources.ExitOverlay);
            }
            else
            {
                ExitOverlayIcon.Visibility = Visibility.Collapsed;
                GoToOverlayIcon.Visibility = Visibility.Visible;
                ToolTip toolTip = new ToolTip();
                toolTip.Content = Strings.Resources.GoToOverlay;
                ToolTipService.SetToolTip(OverlayButton, toolTip);
                AutomationProperties.SetName(OverlayButton, Strings.Resources.GoToOverlay);
            }
            await LoadThumbanails();

            if (filesInFolder && GalleryToggleSwitch.IsOn && ((Frame)Window.Current.Content).ActualWidth > 680)
            {
                SecondColumn.Width = new GridLength(4, GridUnitType.Star);
                ThirdColumn.Width  = new GridLength(2, GridUnitType.Star);
            }
            else
            {
                FirstColumn.Width  = new GridLength(1, GridUnitType.Star);
                SecondColumn.Width = new GridLength(0);
                ThirdColumn.Width  = new GridLength(1, GridUnitType.Star);
            }

            // We don't have to create the video folder at startup - just ignore populating the folder view if the folder doesn't exist (yet).
            // Saving a recording will automatically create the folder if missing.
        }
Esempio n. 11
0
        /// <summary>
        /// 初始化菜单;
        /// </summary>
        private void InitializeMenu()
        {
            _ribbon.AppMenu.Items.Clear();

            //初始化顶级菜单;
            foreach (var menuItem in _mefMenuItems.OrderBy(p => p.Metadata.Order))
            {
                var header      = LanguageService.FindResourceString(menuItem.Metadata.HeaderLanguageKey);
                var radMenuItem = new RadMenuItem {
                    Command = menuItem.Value.Command,
                    Header  = header
                };

                if (!string.IsNullOrEmpty(menuItem.Metadata.Icon))
                {
                    try
                    {
                        radMenuItem.Icon = new Image
                        {
                            Source = new BitmapImage(new Uri(menuItem.Metadata.Icon, UriKind.RelativeOrAbsolute)),
                            Width  = Constants.MenuIconWidth,
                            Height = Constants.MenuIconHeight
                        };
                    }
                    catch (Exception ex)
                    {
                        LoggerService.WriteException(ex);
                    }
                }

                _ribbon.AppMenu.Items.Add(radMenuItem);

                ///设定UI自动化测试相关属性;
                AutomationProperties.SetAutomationId(radMenuItem, menuItem.Metadata.GUID);
                AutomationProperties.SetName(radMenuItem, header);

                if (menuItem.Metadata.Key != Key.None)
                {
                    ShellService.Current.AddKeyBinding(menuItem.Value.Command, menuItem.Metadata.Key, menuItem.Metadata.ModifierKeys);
                }
            }
        }
        public MainPage()
        {
            InitializeComponent();

            accessibilityNameService = DependencyService.Get <IAccessibilityName>(DependencyFetchTarget.NewInstance);

            b1 = new Button
            {
                Text            = "I HAVE AN ACCESSIBILITY DESCRIPTION",
                BackgroundColor = Color.Green,
            };
            AutomationProperties.SetName(b1, "This is my accessibility name");
            AutomationProperties.SetHelpText(b1, "And this is my accessibility help text");
            stacklayout.Children.Add(b1);

            b2 = new Button
            {
                Text            = "USELESS BUTTON WITH NO DESCRIPTION",
                BackgroundColor = Color.Green,
            };
            stacklayout.Children.Add(b2);

            l1 = new Label
            {
                BackgroundColor = Color.Orange,
                WidthRequest    = 100,
                HeightRequest   = 100,
            };
            AutomationProperties.SetIsInAccessibleTree(l1, true);
            AutomationProperties.SetName(l1, "Accessibility name should not be visible");
            AutomationProperties.SetHelpText(l1, "Neither accessibility help text should not be visible");
            stacklayout.Children.Add(l1);

            l2 = new Label
            {
                BackgroundColor = Color.Orange,
                WidthRequest    = 100,
                HeightRequest   = 100,
            };
            AutomationProperties.SetIsInAccessibleTree(l2, true);
            stacklayout.Children.Add(l2);
        }
Esempio n. 13
0
        /// <summary>
        /// Asynchronously displays the image file and properties text in the UI. This method is called
        /// when the user loads a new file, or when the app resumes from a suspended state.
        /// </summary>
        /// <param name="file">The image to be displayed.</param>
        /// <param name="propertyText">Collection of property text to be displayed. Must contain the following keys:
        /// Title, Keywords, DateTaken, Make, Model, LatRef, LongRef, LatDeg, LatMin, LatSec, LongDeg, LongMin,
        /// LongSec, Orientation, Exposure, FNumber.</param>
        private async Task DisplayImageUIAsync(StorageFile file, IDictionary <string, string> propertyText)
        {
            BitmapImage src = new BitmapImage();

            src.SetSource(await file.OpenAsync(FileAccessMode.Read));
            Image1.Source = src;
            AutomationProperties.SetName(Image1, file.Name);

            TitleTextbox.Text         = propertyText["Title"];
            KeywordsTextbox.Text      = propertyText["Keywords"];
            DateTakenTextblock.Text   = propertyText["DateTaken"];
            MakeTextblock.Text        = propertyText["Make"];
            ModelTextblock.Text       = propertyText["Model"];
            OrientationTextblock.Text = propertyText["Orientation"];
            LatDegTextbox.Text        = propertyText["LatDeg"];
            LatMinTextbox.Text        = propertyText["LatMin"];
            LatRefTextbox.Text        = propertyText["LatRef"];
            LongDegTextbox.Text       = propertyText["LongDeg"];
            LongMinTextbox.Text       = propertyText["LongMin"];
            LongRefTextbox.Text       = propertyText["LongRef"];
            ExposureTextblock.Text    = propertyText["Exposure"];
            FNumberTextblock.Text     = propertyText["FNumber"];

            // Truncate the latitude and longitude seconds data to 4 decimal places (precision of 1/10000th).
            if (propertyText["LatSec"].Length > 7)
            {
                LatSecTextbox.Text = propertyText["LatSec"].Substring(0, 7);
            }
            else
            {
                LatSecTextbox.Text = propertyText["LatSec"];
            }

            if (propertyText["LongSec"].Length > 7)
            {
                LongSecTextbox.Text = propertyText["LongSec"].Substring(0, 7);
            }
            else
            {
                LongSecTextbox.Text = propertyText["LongSec"];
            }
        }
Esempio n. 14
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));
        }
Esempio n. 15
0
        public RadioMenuFlyoutItemPage()
        {
            this.InitializeComponent();

            itemStates = new Dictionary <string, TextBlock>();

            if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.MenuFlyoutItem", "Icon"))
            {
                IconMenuFlyoutItem.Icon      = new SymbolIcon(Symbol.Calendar);
                IconRadioMenuFlyoutItem.Icon = new SymbolIcon(Symbol.Calculator);
            }

            if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Grid", "ColumnSpacing"))
            {
                InfoGrid.ColumnSpacing = 12;

                ItemNames.Spacing  = 4;
                ItemStates.Spacing = 4;
            }

            // register all RadioMenuFlyoutItems
            foreach (MenuFlyoutItemBase item in ButtonMenuFlyout.Items)
            {
                if (item is RadioMenuFlyoutItem)
                {
                    RadioMenuFlyoutItem radioItem = item as RadioMenuFlyoutItem;

                    radioItem.RegisterPropertyChangedCallback(RadioMenuFlyoutItem.IsCheckedProperty, new DependencyPropertyChangedCallback(IsCheckedChanged));

                    TextBlock nameText = new TextBlock();
                    nameText.Text = radioItem.Text;
                    ItemNames.Children.Add(nameText);

                    TextBlock stateText = new TextBlock();
                    AutomationProperties.SetName(stateText, radioItem.Text + "State");
                    UpdateTextState(radioItem, stateText);
                    ItemStates.Children.Add(stateText);

                    itemStates.Add(radioItem.Text, stateText);
                }
            }
        }
        private void RegisterItem(MenuFlyoutItemBase item)
        {
            if (item is RadioMenuFlyoutItem)
            {
                RadioMenuFlyoutItem radioItem = item as RadioMenuFlyoutItem;

                radioItem.RegisterPropertyChangedCallback(RadioMenuFlyoutItem.IsCheckedProperty, new DependencyPropertyChangedCallback(IsCheckedChanged));

                TextBlock nameText = new TextBlock();
                nameText.Text = radioItem.Text;
                ItemNames.Children.Add(nameText);

                TextBlock stateText = new TextBlock();
                AutomationProperties.SetName(stateText, radioItem.Text + "State");
                UpdateTextState(radioItem, stateText);
                ItemStates.Children.Add(stateText);

                itemStates.Add(radioItem.Text, stateText);
            }
        }
Esempio n. 17
0
            private void ProcessDescription(Task <CompletionDescription> obj)
            {
                Debug.Assert(_toolTipProvider._threadingContext.JoinableTaskContext.IsOnMainThread);

                // If we were canceled, or didn't run all the way to completion, then don't bother
                // updating the UI.
                if (_cancellationTokenSource.IsCancellationRequested ||
                    obj.Status != TaskStatus.RanToCompletion)
                {
                    return;
                }

                var description = obj.Result;

                this.Content = description.TaggedParts.ToTextBlock(_toolTipProvider._formatMap, _toolTipProvider._typeMap);

                // The editor will pull AutomationProperties.Name from our UIElement and expose
                // it to automation.
                AutomationProperties.SetName(this, description.Text);
            }
Esempio n. 18
0
            private void ProcessDescription(Task <CompletionDescription> obj)
            {
                Debug.Assert(_foregroundObject.IsForeground());

                // If we were canceled, or didn't run all the way to completion, then don't bother
                // updating the UI.
                if (_cancellationTokenSource.IsCancellationRequested ||
                    obj.Status != TaskStatus.RanToCompletion)
                {
                    return;
                }

                var description = obj.Result;

                this.Content = GetTextBlock(description.TaggedParts);

                // The editor will pull AutomationProperties.Name from our UIElement and expose
                // it to automation.
                AutomationProperties.SetName(this, description.Text);
            }
Esempio n. 19
0
        protected override void Init()
        {
            Button button  = new Button();
            Switch _switch = new Switch();

            AutomationProperties.SetName(button, "invisible text");
            AutomationProperties.SetName(_switch, "invisible text");

            Content = new StackLayout
            {
                Children =
                {
                    new Label {
                        Text = "The text on the controls below should be empty. But TalkBack should read 'invisible text'"
                    },
                    button,
                    _switch
                }
            };
        }
        public void VerifyDataContextOfDirectChildOfGridViewItem()
        {
            var gridViewItem = new GridViewItem();

            AutomationProperties.SetName(gridViewItem, "Windows.UI.Xaml.Controls.Button");
            var content = new Button()
            {
                DataContext = new Button()
            };

            gridViewItem.Content     = content;
            gridViewItem.DataContext = null;
            var peer = FrameworkElementAutomationPeer.CreatePeerForElement(gridViewItem);

            App.Content = gridViewItem;

            var rule = new ListItemNameNotEqualDataContextRule();

            Assert.IsFalse(rule.IsValid(gridViewItem, peer));
        }
Esempio n. 21
0
        public MainPage()
        {
            InitializeComponent();

            AutomationProperties.SetName(this, "MainPage");
            Loaded += OnLoaded;

            foreach (var locale in locales)
            {
                var item = new ComboBoxItem {
                    Content = locale
                };
                LanguageChooser.Items.Add(item);
                AutomationProperties.SetAutomationId(item, locale);
            }

            foreach (var flowDirection in FlowDirections)
            {
                var item = new ComboBoxItem {
                    Content = flowDirection.ToString(), Tag = flowDirection
                };
                FlowDirectionChooser.Items.Add(item);
                AutomationProperties.SetAutomationId(item, flowDirection.ToString());
            }

            // This setting is persisted across multiple openings of an app, so we always want to initialize it to en-US
            // in case the app crashed while in a different language or otherwise was not able to set it back.
            //ModernWpfTestApp.App.LanguageOverride = "en-US";

            // We'll additionally make sure that the combo box begins on the right element to reflect the current value.
            LanguageChooser.SelectedIndex = locales.IndexOf("en-US");
            //LongAnimationsDisabled.IsChecked = ModernWpfTestApp.App.DisableLongAnimations;
            FlowDirectionChooser.SelectedIndex = FlowDirections.IndexOf(GetRootFlowDirection());

            // App remembers ExtendViewIntoTitleBar and the value persists true if test case aborted and didn't change it back
            // Always set it to false when app restarted
            //CoreApplicationViewTitleBar titleBar = CoreApplication.GetCurrentView().TitleBar;
            //titleBar.ExtendViewIntoTitleBar = false;

            DataContext = this;
        }
Esempio n. 22
0
        private void PrepareCell(TreeGridCell cell, TreeGridColumn column)
        {
            cell.Column = column;
            if (column.CellStyle != null)
            {
                cell.Style = column.CellStyle;
            }

            cell.UpdateContent(false);

            //IsEditing
            var row = this.Row;

            if (row != null)
            {
                var grid = row.TreeGrid;

                //当前行是表格中正在编辑的行
                if (grid != null && this.DataContext == grid.EditingItem)
                {
                    //整行编辑、或者正在编辑该单元格
                    if (grid.EditingMode == TreeGridEditingMode.Row || column == grid.EditingColumn)
                    {
                        if (cell.Column.CanEdit(cell.DataContext))
                        {
                            cell.SetIsEditingField(true);

                            //this.RestoreEditingContent(cell, column, grid);
                        }
                    }
                }
            }

            //Automation
            var headerLabel = column.HeaderLabel;

            if (!string.IsNullOrEmpty(headerLabel))
            {
                AutomationProperties.SetName(cell, headerLabel);
            }
        }
        /// <summary>
        /// Clear all of the state that is stored in memory and in the UI
        /// </summary>
        private async void ResetSessionState()
        {
            m_fileToken = null;
            m_displayHeightNonScaled = 0;
            m_displayWidthNonScaled  = 0;
            m_scaleFactor            = 1;
            m_userRotation           = PhotoOrientation.Normal;
            m_exifOrientation        = PhotoOrientation.Normal;
            m_disableExifOrientation = false;

            RotateLeftButton.IsEnabled  = false;
            RotateRightButton.IsEnabled = false;
            SaveButton.IsEnabled        = false;
            SaveAsButton.IsEnabled      = false;
            CloseButton.IsEnabled       = false;

            StorageFile placeholderImage = await Package.Current.InstalledLocation.GetFileAsync("Assets\\placeholder-sdk.png");

            BitmapImage bitmapImage = new BitmapImage();

            using (IRandomAccessStream stream = await placeholderImage.OpenAsync(FileAccessMode.Read))
            {
                await bitmapImage.SetSourceAsync(stream);
            }

            Image1.Source = bitmapImage;
            AutomationProperties.SetName(Image1, "A placeholder image");

            m_transform.CenterX          = ImageViewbox.Width / 2;
            m_transform.CenterY          = ImageViewbox.Height / 2;
            ImageViewbox.RenderTransform = m_transform;
            UpdateImageRotation(PhotoOrientation.Normal);

            ScaleTextblock.Text           = "";
            ScaleSlider.Value             = 100;
            ScaleSlider.IsEnabled         = false;
            HeightTextblock.Text          = "";
            WidthTextblock.Text           = "";
            UserRotationTextblock.Text    = "";
            ExifOrientationTextblock.Text = "";
        }
Esempio n. 24
0
        // IFrameworkElement

        protected override void OnApplyTemplate()
        {
            if (GetTemplateChild <Control>(c_expanderHeader) is ToggleButton toggleButton)
            {
                // We will do 2 things with the toggle button's peer:
                // 1. Set the events source of the toggle button peer to
                // the expander's automation peer. This is is because we
                // don't want to announce the toggle button's on/off property
                // changes, but the expander's expander/collapse property changes
                // (or on the events source that's set, if it's set) and
                //
                // 2. Set the expander's automation properties name to the
                // toggleButton's in case the expander doesn't have one. This just follows
                // what WPF does.
                if (FrameworkElementAutomationPeer.FromElement(toggleButton) is AutomationPeer toggleButtonPeer)
                {
                    // 1. Set the events source of the toggle button peer to the expander's.
                    if (FrameworkElementAutomationPeer.FromElement(this) is AutomationPeer expanderPeer)
                    {
                        // Uno Doc: EventSource is not implemented in the Uno Platform
                        //var expanderEventsSource = expanderPeer.EventsSource != null ?
                        //	expanderPeer.EventsSource :
                        //	expanderPeer;
                        //toggleButtonPeer.EventsSource = expanderEventsSource;
                    }

                    // 2. If the expander doesn't have any AutomationProperties.Name set,
                    // we will try setting one based on the header. This is how
                    // WPF's expanders work.
                    if (string.IsNullOrEmpty(AutomationProperties.GetName(this)) &&
                        !string.IsNullOrEmpty(toggleButtonPeer.GetName()))
                    {
                        // Uno Doc: The equivalent '.GetName()' substituted for '.GetNameCore()' in WinUI
                        AutomationProperties.SetName(this, toggleButtonPeer.GetName());
                    }
                }
            }

            UpdateExpandState(false);
            UpdateExpandDirection(false);
        }
Esempio n. 25
0
        /// <summary>
        /// The framework calls this method on new view instance creation. The method is
        /// intended for performing necessary accessibility setup (if any) for the newly created views.
        /// </summary>
        /// <param name="view"></param>
        internal static void OnViewInstanceCreated(UIElement view)
        {
            var elementPeer = FrameworkElementAutomationPeer.FromElement(view);

            if (elementPeer == null)
            {
                // Not all the UIElements will create AutomationPeer immediately after being created (e.g. Border, Canvas).
                // We need to make sure AutomationPeer is always created since the impementation relies on
                // traversing automation tree. Setting AutomationProperties.Name to some string and then clearing it will guarantee that
                // AutomationPeer is always created.
                AutomationProperties.SetName(view, " ");
                view.ClearValue(AutomationProperties.NameProperty);
            }

            // Create context proactively, there is no room for allocation optimization due to CurrentlyHidingChildren property.
            EnsureElementAccessibilityContext(view);

#if PERF_LOG
            s_treeContext.Value.ElementCount++;
#endif
        }
Esempio n. 26
0
        public MainPage()
        {
            this.InitializeComponent();

            MainFrame.Navigated       += MainFrame_Navigated;
            NavigationHelper.PageFrame = MainFrame;
            NavService.CurrentFrame    = MainFrame;

            foreach (PageInfo page in NavigationHelper.Pages)
            {
                var item = new Microsoft.UI.Xaml.Controls.NavigationViewItem()
                {
                    Content    = page.Title,
                    Icon       = page.Icon,
                    Visibility = page.Visibility,
                };
                MainNav.MenuItems.Add(item);
                AutomationProperties.SetName(item, page.Title);
            }
            MainNav.SelectedItem = MainNav.MenuItems[0];
        }
Esempio n. 27
0
        NavigationViewItem CreateNavViewItemFromCategory(NavCategory category)
        {
            var item = new NavigationViewItem();

            item.DataContext = category;

            var icon = new FontIcon();

            icon.FontFamily = (Windows.UI.Xaml.Media.FontFamily)(App.Current.Resources["CalculatorFontFamily"]);
            icon.Glyph      = category.Glyph;
            item.Icon       = icon;

            item.Content   = category.Name;
            item.AccessKey = category.AccessKey;
            item.Style     = (Windows.UI.Xaml.Style)(Resources["NavViewItemStyle"]);

            AutomationProperties.SetName(item, category.AutomationName);
            AutomationProperties.SetAutomationId(item, category.AutomationId);

            return(item);
        }
Esempio n. 28
0
        public TestPage()
        {
            AutomationProperties.SetName(this, "TestPage");
            Loaded += OnLoaded;

            var resources = new ResourceDictionaryEx();

            resources.ThemeDictionaries["Default"] = new ResourceDictionary
            {
                { "WhichTheme", ApplicationTheme.Dark }
            };
            resources.ThemeDictionaries["Light"] = new ResourceDictionary
            {
                { "WhichTheme", ApplicationTheme.Light }
            };
            resources.ThemeDictionaries["HighContrast"] = new ResourceDictionary
            {
                { "WhichTheme", ApplicationTheme.Light }
            };
            Resources = resources;
        }
Esempio n. 29
0
        // Set the AutomationPeer name to be the same as the x:Name on each FrameworkElement
        // that is a child of the given panel, and continue recursively into any panel children.
        // This is so we don't need to set both properties on the elements in XAML.
        void SetAutomationPeerNames(Panel root)
        {
            foreach (var child in root.Children)
            {
                if (child is FrameworkElement element)
                {
                    // Copy the x:Name into the AutomationPeer name unless it already has an AutomationPeer name.
                    var name = element.Name;
                    if (!string.IsNullOrEmpty(name) && string.IsNullOrEmpty(AutomationProperties.GetName(element)))
                    {
                        AutomationProperties.SetName(element, name);
                    }

                    if (child is Panel panel)
                    {
                        // Recurse to get the rest of the tree.
                        SetAutomationPeerNames(panel);
                    }
                }
            }
        }
        CompositionBrush _previousCompositionBrush;          // Used by test helpers that get called multiple times

        public AcrylicBrushPage()
        {
            this.InitializeComponent();

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

                _acrylicBrush = new AcrylicBrush {
                    BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                    FallbackColor    = Color.FromArgb(0xFF, 0x0, 0x0, 0xFF),
                    TintOpacity      = TintOpacity.Value
                };

                _acrylicTestApi = new AcrylicTestApi();

                _iteration_RunHideAndShowWindow   = 0;
                _iteration_TintTransitionDuration = 0;
            }
        }