public override bool TryInvoke(System.Windows.FrameworkElement owner, AutomationMethod method, out AutomationValue result)
        {
            result = AutomationValue.NotSetValue;

            if (owner is not TestHost testHost)
            {
                return(false);
            }

            var itemsControl = testHost.FindVisualDescendantByType <System.Windows.Controls.ItemsControl>();

            if (itemsControl is null)
            {
                return(false);
            }

            itemsControl.ItemsPanel = new ItemsPanelTemplate(new FrameworkElementFactory(typeof(StaggeredPanel)));

            var dataTemplate = new DataTemplate(typeof(StaggeredPanelTestItem));

            var textBlock = new FrameworkElementFactory(typeof(TextBlock));

            //textBlock.SetBinding(TextBlock.WidthProperty, new Binding(nameof(StaggeredPanelTestItem.Width)));
            //textBlock.SetBinding(TextBlock.HeightProperty, new Binding(nameof(StaggeredPanelTestItem.Height)));
            textBlock.SetBinding(TextBlock.TextProperty, new Binding(nameof(StaggeredPanelTestItem.Content)));

            dataTemplate.VisualTree = textBlock;

            itemsControl.ItemTemplate = dataTemplate;

            result = AutomationValue.FromValue(true);

            return(true);
        }
        public override bool TryInvoke(FrameworkElement owner, AutomationMethod method, out AutomationValue result)
        {
            result = AutomationValue.FromValue(true);

            if (owner is not Views.SnapshotsView snapshotsView)
            {
                return(true);
            }

#pragma warning disable IDISP001 // Dispose created
            var serviceLocator = this.GetServiceLocator();
#pragma warning restore IDISP001 // Dispose created

            var languageService = serviceLocator.ResolveType <ILanguageService>();
            languageService.RegisterLanguageSource(new LanguageResourceSource("Orc.Snapshots.Xaml", "Orc.Snapshots.Properties", "Resources"));

            serviceLocator.RegisterType <ISnapshotManager, SnapshotManager>();
            serviceLocator.RegisterType <ISnapshotStorageService, SnapshotStorageServiceMock>();

            foreach (var scope in SnapshotTestData.AvailableScopes)
            {
                RegisterScope(scope);
            }

            var vm = this.GetTypeFactory().CreateInstanceWithParametersAndAutoCompletion <ViewModels.SnapshotsViewModel>();
            snapshotsView.DataContext = vm;

            return(true);
        }
Beispiel #3
0
        public override bool TryInvoke(FrameworkElement owner, AutomationMethod method, out AutomationValue result)
        {
            result = AutomationValue.NotSetValue;
            var pinnableToolTip = new PinnableToolTip
            {
                Name             = "PinnableToolTipId",
                AllowCloseByUser = true,
                ResizeMode       = ResizeMode.CanResize,
                MinWidth         = 100,
                MinHeight        = 100,
                HorizontalOffset = -12,
                VerticalOffset   = -12,
            };

            var dataTemplate = new DataTemplate();
            var label        = new FrameworkElementFactory(typeof(Label));

            label.SetValue(ContentControl.ContentProperty, "Test content");
            dataTemplate.VisualTree         = label;
            pinnableToolTip.ContentTemplate = dataTemplate;

            owner.SetCurrentValue(PinnableToolTipService.ToolTipProperty, pinnableToolTip);

            result = AutomationValue.FromValue(true);

            return(true);
        }
Beispiel #4
0
        public override bool TryInvoke(FrameworkElement owner, AutomationMethod method, out AutomationValue result)
        {
            StyleHelper.CreateStyleForwardersForDefaultStyles();

            result = AutomationValue.FromValue(10);

            return(true);
        }
Beispiel #5
0
        public override bool TryInvoke(FrameworkElement owner, AutomationMethod method, out AutomationValue result)
        {
            result = AutomationValue.FromValue(true);

            StyleHelper.CreateStyleForwardersForDefaultStyles();
            ThemeManager.Current.SynchronizeTheme();

            return(true);
        }
        public override bool TryInvoke(FrameworkElement owner, AutomationMethod method, out AutomationValue result)
        {
            result = AutomationValue.FromValue(10);

            if (owner is not DropDownButton dropDown)
            {
                return(false);
            }

            var contextMenu = new ContextMenu();

            var items = contextMenu.Items;

            items.Add("One");
            items.Add("Two");
            items.Add("Three");
            items.Add("Four");
            items.Add("Five");

            dropDown.SetCurrentValue(DropDownButton.DropDownProperty, contextMenu);

            return(true);
        }
        public override bool TryInvoke(System.Windows.FrameworkElement owner, AutomationMethod method, out AutomationValue result)
        {
            result = AutomationValue.NotSetValue;

            if (owner is not TestHost testHost)
            {
                return(false);
            }

            var itemsControl = testHost.FindVisualDescendantByType <System.Windows.Controls.ItemsControl>();

            if (itemsControl is null)
            {
                return(false);
            }

            var itemSource = method.Parameters.FirstOrDefault()?.ExtractValue() as IEnumerable;

            itemsControl.ItemsSource = itemSource;

            result = AutomationValue.FromValue(true);

            return(true);
        }