public void Next_Continue_Returns_First_Control_In_Next_Sibling_Container() { Button current; Button next; var top = new StackPanel { Children = new Controls { new StackPanel { Children = new Controls { new Button { Name = "Button1" }, new Button { Name = "Button2" }, (current = new Button { Name = "Button3" }), } }, new StackPanel { Children = new Controls { (next = new Button { Name = "Button4" }), new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Next); Assert.Equal(next, result); }
private void InitializeComponent() { AvaloniaXamlLoader.Load(this); _carousel = this.FindControl<Carousel>("carousel"); _left = this.FindControl<Button>("left"); _right = this.FindControl<Button>("right"); _transition = this.FindControl<DropDown>("transition"); }
private void InitializeComponent() { AvaloniaXamlLoader.Load(this); //create directories Directory.CreateDirectory(PV_WebsiteIconDir); //locate controls TitleBarHost = this.FindControl <Grid>("TitleBarHost"); ControlsPanel = this.FindControl <Panel>("ControlsPanel"); HeaderText = this.FindControl <TextBlock>("HeaderText"); SettingsBtn = this.FindControl <Button>("SettingsBtn"); AddWebsiteBtn = this.FindControl <Button>("AddWebsiteBtn"); AddFolderBtn = this.FindControl <Button>("AddFolderBtn"); AddFileBtn = this.FindControl <Button>("AddFileBtn"); NavView = this.FindControl <NavigationView>("NavView"); AllItemsItem = this.FindControl <NavigationViewItem>("AllItemsItem"); FilesItem = this.FindControl <NavigationViewItem>("FilesItem"); FoldersItem = this.FindControl <NavigationViewItem>("FoldersItem"); WebsitesItem = this.FindControl <NavigationViewItem>("WebsitesItem"); ContentCarousel = this.FindControl <Carousel>("ContentCarousel"); AllItemsPage = this.FindControl <Panel>("AllItemsPage"); FilesPage = this.FindControl <Panel>("FilesPage"); FoldersPage = this.FindControl <Panel>("FoldersPage"); WebsitesPage = this.FindControl <Panel>("WebsitesPage"); //AllItemsGridView = this.FindControl<GridView>("AllItemsGridView"); AllItemsGridView = this.FindControl <ListBox>("AllItemsGridView"); //FilesGridView = this.FindControl<GridView>("FilesGridView"); FilesGridView = this.FindControl <ListBox>("FilesGridView"); //FoldersGridView = this.FindControl<GridView>("FoldersGridView"); FoldersGridView = this.FindControl <ListBox>("FoldersGridView"); //WebsitesGridView = this.FindControl<GridView>("WebsitesGridView"); WebsitesGridView = this.FindControl <ListBox>("WebsitesGridView"); //set the application shutdownmode to onmainwindowclose if (Application.Current != null) { if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { desktop.ShutdownMode = ShutdownMode.OnMainWindowClose; } } //set the NavView SelectedItem manually and navigate to that page NavView.SelectedItem = AllItemsItem; //all event handlers go here AllItemsGridView.SelectionChanged += GridViewItem_SelectionChanged; FilesGridView.SelectionChanged += GridViewItem_SelectionChanged; FoldersGridView.SelectionChanged += GridViewItem_SelectionChanged; WebsitesGridView.SelectionChanged += GridViewItem_SelectionChanged; SettingsBtn.Click += SettingsBtn_Click; AddWebsiteBtn.Click += AddWebsiteBtn_Click; NavView.SelectionChanged += NavView_SelectionChanged; }
public static void Build(MainWindow window) { // maxRow y maxCol deberÃan estar definidas en el ViewModel... int maxRow = 9; int maxCol = 5; int i = 0; Grid grdMain = window.FindControl <Grid>("grdMain"); for (int row = 0; row < maxRow; row++) { grdMain.RowDefinitions.Add(new RowDefinition { Height = GridLength.Parse("*", CultureInfo.InstalledUICulture) }); } for (int col = 0; col < maxCol; col++) { grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Parse("1*", CultureInfo.InstalledUICulture) }); } for (int row = 0; row < maxRow; row++) { for (int col = 0; col < maxCol; col++) { ButtonT b = new ButtonT("Boton Nro: " + i.ToString(), i); var stackPanel = new Avalonia.Controls.StackPanel(); var textBlock = new Avalonia.Controls.TextBlock { [!TextBlock.TextProperty] = new Binding("Name") }; stackPanel.Children.Add(textBlock); var btn = new Avalonia.Controls.Button { Background = b.ButtonColor, [!Button.BackgroundProperty] = b.ToBinding <SolidColorBrush>(), [Grid.RowProperty] = row, [Grid.ColumnProperty] = col, // window.DataContext es null, por eso uso la instancia global del viewmodel :( ) Command = ReactiveCommand.Create <ButtonT>(MainWindowViewModel.Instance.RunTheThing), CommandParameter = b, Content = stackPanel, DataContext = b }; i++; grdMain.Children.Add(btn); } } }
public void Focus_Should_Set_FocusManager_Current() { Button target; using (UnitTestApplication.Start(TestServices.RealFocus)) { var root = new TestRoot { Child = target = new Button() }; target.Focus(); Assert.Same(target, FocusManager.Instance.Current); } }
public void Focus_Should_Be_Cleared_When_Control_Is_Removed_From_VisualTree() { Button target; using (UnitTestApplication.Start(TestServices.RealFocus)) { var root = new TestRoot { Child = target = new Button() }; target.Focus(); root.Child = null; Assert.Null(FocusManager.Instance.Current); } }
/// <summary> /// Initializes the new instance of <see cref="MainWindow"/> class. /// </summary> public MainWindow() { this.InitializeComponent(); App.AttachDevTools(this); btnGetWavHeader = this.FindControl<Button>("btnGetWavHeader"); progress = this.FindControl<ProgressBar>("progress"); btnCancel = this.FindControl<Button>("btnCancel"); btnSplitWavFiles = this.FindControl<Button>("btnSplitWavFiles"); textOutputPath = this.FindControl<TextBox>("textOutputPath"); btnBrowseOutputPath = this.FindControl<Button>("btnBrowseOutputPath"); textOutput = this.FindControl<TextBox>("textOutput"); var v = Assembly.GetExecutingAssembly().GetName().Version; Title = string.Format("SimpleWavSplitter v{0}.{1}.{2}", v.Major, v.Minor, v.Build); btnBrowseOutputPath.Click += async (sender, e) => await GetOutputPath(); btnGetWavHeader.Click += async (sender, e) => await GetWavHeader(); btnSplitWavFiles.Click += async (sender, e) => await SplitWavFiles(); btnCancel.Click += async (sender, e) => await CancelSplitWavFiles(); }
Border CreateControl() { var border = new Border() { Child = _panel }; _panel.HorizontalAlignment = HorizontalAlignment.Right; _panel.Orientation = Orientation.Horizontal; _upButton = new AButton { Content = "+", Width = 100 }; _downButton = new AButton { Content = "-", Width = 100 }; _panel.Children.Add(_downButton); _panel.Children.Add(_upButton); return(border); }
private void InitializeComponent() { int maxRow = 3; int maxCol = 5; AvaloniaXamlLoader.Load(this); int i = 0; var grdMain = this.FindControl <Grid>("grdMain"); for (int row = 0; row < maxRow; row++) { grdMain.RowDefinitions.Add(new RowDefinition { Height = GridLength.Parse("*", CultureInfo.InstalledUICulture) }); } for (int col = 0; col < maxCol; col++) { grdMain.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Parse("1*", CultureInfo.InstalledUICulture) }); } for (int row = 0; row < maxRow; row++) { for (int col = 0; col < maxCol; col++) { var btn = new Avalonia.Controls.Button { [Grid.RowProperty] = row, [Grid.ColumnProperty] = col, //Fill = lstColores[i%lstColores.Count], Command = ReactiveCommand.Create <int>(RunTheThing), CommandParameter = i, Content = i.ToString() }; i++; grdMain.Children.Add(btn); } } }
private void InitializeComponent() { AvaloniaXamlLoader.Load(this); //locate controls TitleBarHost = this.FindControl <Grid>("TitleBarHost"); ControlsPanel = this.FindControl <Panel>("ControlsPanel"); IconSizeNumUpDown = this.FindControl <NumericUpDown>("IconSizeNumUpDown"); HeaderTextBox = this.FindControl <TextBox>("HeaderTextBox"); VersionText = this.FindControl <TextBlock>("VersionText"); LightThmRadioBtn = this.FindControl <RadioButton>("LightThmRadioBtn"); DarkThmRadioBtn = this.FindControl <RadioButton>("DarkThmRadioBtn"); AboutBtn = this.FindControl <Button>("AboutBtn"); CheckUpdatesBtn = this.FindControl <Button>("CheckUpdatesBtn"); SaveBtn = this.FindControl <Button>("SaveBtn"); //all event handlers go here LightThmRadioBtn.Checked += LightThmRadioBtn_Checked; DarkThmRadioBtn.Checked += DarkThmRadioBtn_Checked; AboutBtn.Click += AboutBtn_Click; CheckUpdatesBtn.Click += CheckUpdatesBtn_Click; SaveBtn.Click += SaveBtn_Click; }
public void Down_Contained_Stops_At_End() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, Children = new Controls { (next = new Button { Name = "Button1" }), new Button { Name = "Button2" }, (current = new Button { Name = "Button3" }), } }), new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Down); Assert.Null(result); }
public void Down_Continue_Returns_Down_Control_In_Container() { Button current; Button next; var top = new StackPanel { Children = new Controls { new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Children = new Controls { new Button { Name = "Button1" }, (current = new Button { Name = "Button2" }), (next = new Button { Name = "Button3" }), } }, new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Down); Assert.Equal(next, result); }
public void Template_Child_Of_Control_With_Two_Classes() { var template = new FuncControlTemplate(parent => { return new Border { Name = "border", }; }); var control = new Button { Template = template, }; control.ApplyTemplate(); var selector = default(Selector) .OfType<Button>() .Class("foo") .Class("bar") .Template() .Name("border"); var border = (Border)((IVisual)control).VisualChildren.Single(); var values = new List<bool>(); var activator = selector.Match(border).ObservableResult; activator.Subscribe(x => values.Add(x)); Assert.Equal(new[] { false }, values); control.Classes.AddRange(new[] { "foo", "bar" }); Assert.Equal(new[] { false, true }, values); control.Classes.Remove("foo"); Assert.Equal(new[] { false, true, false }, values); }
public void Previous_Contained_Returns_Previous_Control_In_Container() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained, Children = new Controls { (next = new Button { Name = "Button1" }), (current = new Button { Name = "Button2" }), new Button { Name = "Button3" }, } }), new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Previous); Assert.Equal(next, result); }
public void Down_None_Does_Nothing() { Button current; var top = new StackPanel { Children = new Controls { new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.None, Children = new Controls { new Button { Name = "Button1" }, (current = new Button { Name = "Button2" }), new Button { Name = "Button3" }, } }, new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Contained, Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Down); Assert.Null(result); }
public void Up_Continue_Returns_Last_Child_Of_Sibling() { StackPanel container; Button current; Button next; var top = new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Children = new Controls { (container = new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Children = new Controls { new Button { Name = "Button1" }, new Button { Name = "Button2" }, (next = new Button { Name = "Button3" }), } }), (current = new Button { Name = "Button4" }), } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Up); Assert.Equal(next, result); }
public void Up_Cycle_Wraps_To_Last() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, Children = new Controls { (current = new Button { Name = "Button1" }), new Button { Name = "Button2" }, (next = new Button { Name = "Button3" }), } }), new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Cycle, Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Up); Assert.Equal(next, result); }
private static TabItem AnimationsTab() { Border border1; Border border2; RotateTransform rotate; Button button1; var result = new TabItem { Header = "Animations", Content = new StackPanel { Orientation = Orientation.Vertical, Gap = 4, Margin = new Thickness(10), Children = new Controls { new TextBlock { Text = "Animations", FontWeight = FontWeight.Medium, FontSize = 20, Foreground = Brush.Parse("#212121"), }, new TextBlock { Text = "A few animations showcased below", FontSize = 13, Foreground = Brush.Parse("#727272"), Margin = new Thickness(0, 0, 0, 10) }, (button1 = new Button { Content = "Animate", Width = 120, [Grid.ColumnProperty] = 1, [Grid.RowProperty] = 1, }), new Canvas { ClipToBounds = false, Children = new Controls { (border1 = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Background = Brushes.Crimson, RenderTransform = new RotateTransform(), Child = new Grid { Children = new Controls { new Ellipse() { Width = 100, Height = 100, Fill = new RadialGradientBrush() { GradientStops = { new GradientStop(Colors.Blue, 0), new GradientStop(Colors.Green, 1) }, Radius = 75 } }, new Avalonia.Controls.Shapes.Path { Data = StreamGeometry.Parse( "F1 M 16.6309,18.6563C 17.1309,8.15625 29.8809,14.1563 29.8809,14.1563C 30.8809,11.1563 34.1308,11.4063 34.1308,11.4063C 33.5,12 34.6309,13.1563 34.6309,13.1563C 32.1309,13.1562 31.1309,14.9062 31.1309,14.9062C 41.1309,23.9062 32.6309,27.9063 32.6309,27.9062C 24.6309,24.9063 21.1309,22.1562 16.6309,18.6563 Z M 16.6309,19.9063C 21.6309,24.1563 25.1309,26.1562 31.6309,28.6562C 31.6309,28.6562 26.3809,39.1562 18.3809,36.1563C 18.3809,36.1563 18,38 16.3809,36.9063C 15,36 16.3809,34.9063 16.3809,34.9063C 16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z"), Fill = new LinearGradientBrush() { GradientStops = { new GradientStop(Colors.Green, 0), new GradientStop(Colors.LightSeaGreen, 1) } }, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, RenderTransform = new MatrixTransform(Matrix.CreateScale(2, 2)) } } }, [Canvas.LeftProperty] = 100, [Canvas.TopProperty] = 100, }), (border2 = new Border { Width = 100, Height = 100, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Background = Brushes.Coral, Child = new Image { Source = new Bitmap(GetImage("github_icon.png")), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }, RenderTransform = (rotate = new RotateTransform { PropertyTransitions = new PropertyTransitions { RotateTransform.AngleProperty.Transition(500), } }), PropertyTransitions = new PropertyTransitions { Layoutable.WidthProperty.Transition(300), Layoutable.HeightProperty.Transition(1000), }, [Canvas.LeftProperty] = 400, [Canvas.TopProperty] = 100, }), } } }, }, }; button1.Click += (s, e) => { if (border2.Width == 100) { border2.Width = border2.Height = 400; rotate.Angle = 180; } else { border2.Width = border2.Height = 100; rotate.Angle = 0; } }; var start = Animate.Stopwatch.Elapsed; var degrees = Animate.Timer .Select(x => { var elapsed = (x - start).TotalSeconds; var cycles = elapsed / 4; var progress = cycles % 1; return 360.0 * progress; }); border1.RenderTransform.Bind( RotateTransform.AngleProperty, degrees, BindingPriority.Animation); return result; }
public void Previous_Continue_Returns_Parent() { Button current; var top = new Decorator { Focusable = true, Child = current = new Button { Name = "Button", } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Previous); Assert.Equal(top, result); }
public void Previous_Continue_Wraps() { Button current; Button next; var top = new StackPanel { Children = new Controls { new StackPanel { Children = new Controls { new StackPanel { Children = new Controls { (current = new Button { Name = "Button1" }), new Button { Name = "Button2" }, new Button { Name = "Button3" }, } }, }, }, new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, (next = new Button { Name = "Button6" }), } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Previous); Assert.Equal(next, result); }
protected override void OnTemplateApplied(TemplateAppliedEventArgs e) { titleBar = e.NameScope.Find<Grid>("titlebar"); minimiseButton = e.NameScope.Find<Button>("minimiseButton"); restoreButton = e.NameScope.Find<Button>("restoreButton"); closeButton = e.NameScope.Find<Button>("closeButton"); icon = e.NameScope.Find<Image>("icon"); topHorizontalGrip = e.NameScope.Find<Grid>("topHorizontalGrip"); bottomHorizontalGrip = e.NameScope.Find<Grid>("bottomHorizontalGrip"); leftVerticalGrip = e.NameScope.Find<Grid>("leftVerticalGrip"); rightVerticalGrip = e.NameScope.Find<Grid>("rightVerticalGrip"); topLeftGrip = e.NameScope.Find<Grid>("topLeftGrip"); bottomLeftGrip = e.NameScope.Find<Grid>("bottomLeftGrip"); topRightGrip = e.NameScope.Find<Grid>("topRightGrip"); bottomRightGrip = e.NameScope.Find<Grid>("bottomRightGrip"); minimiseButton.Click += (sender, ee) => { WindowState = WindowState.Minimized; }; restoreButton.Click += (sender, ee) => { ToggleWindowState(); }; titleBar.DoubleTapped += (sender, ee) => { ToggleWindowState(); }; closeButton.Click += (sender, ee) => { Application.Current.Exit(); }; icon.DoubleTapped += (sender, ee) => { Close(); }; }
public void Next_Cycle_Wraps_To_First() { Button current; Button next; var top = new StackPanel { Children = new Controls { new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, Children = new Controls { (next = new Button { Name = "Button1" }), new Button { Name = "Button2" }, (current = new Button { Name = "Button3" }), } }, new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Next); Assert.Equal(next, result); }
public void Next_Continue_Returns_Child_Of_Top_Level() { Button next; var top = new StackPanel { Children = new Controls { (next = new Button { Name = "Button1" }), } }; var result = KeyboardNavigationHandler.GetNext(top, NavigationDirection.Next); Assert.Equal(next, result); }
public void Down_Continue_Returns_Child_Of_Top_Level() { Button next; var top = new StackPanel { [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Children = new Controls { (next = new Button { Name = "Button1" }), } }; var result = KeyboardNavigationHandler.GetNext(top, NavigationDirection.Down); Assert.Equal(next, result); }
public void Previous_Continue_Returns_Last_Control_In_Previous_Nephew_Container() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { new StackPanel { Children = new Controls { (container = new StackPanel { Children = new Controls { new Button { Name = "Button1" }, new Button { Name = "Button2" }, (next = new Button { Name = "Button3" }), } }), }, }, new StackPanel { Children = new Controls { (current = new Button { Name = "Button4" }), new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Previous); Assert.Equal(next, result); }
public void Next_Continue_Doesnt_Enter_Panel_With_TabNavigation_None() { Button current; Button next; var top = new StackPanel { Children = new Controls { new StackPanel { Children = new Controls { (next = new Button { Name = "Button1" }), new Button { Name = "Button2" }, (current = new Button { Name = "Button3" }), } }, new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.None, Children = new Controls { new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } } } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Next); Assert.Equal(next, result); }
public void Previous_Contained_Stops_At_Beginning() { Button current; var top = new StackPanel { Children = new Controls { new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Contained, Children = new Controls { (current = new Button { Name = "Button1" }), new Button { Name = "Button2" }, new Button { Name = "Button3" }, } }, new StackPanel { Children = new Controls { new Button { Name = "Button4" }, new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Previous); Assert.Null(result); }
private static TabItem ImagesTab() { var imageCarousel = new Carousel { Width = 400, Height = 400, Transition = new PageSlide(TimeSpan.FromSeconds(0.25)), Items = new[] { new Image { Source = new Bitmap(GetImage("github_icon.png")), Width = 400, Height = 400 }, new Image { Source = new Bitmap(GetImage("pattern.jpg")), Width = 400, Height = 400 }, } }; var next = new Button { VerticalAlignment = VerticalAlignment.Center, Padding = new Thickness(20), Content = new Avalonia.Controls.Shapes.Path { Data = StreamGeometry.Parse("M4,11V13H16L10.5,18.5L11.92,19.92L19.84,12L11.92,4.08L10.5,5.5L16,11H4Z"), Fill = Brushes.Black } }; var prev = new Button { VerticalAlignment = VerticalAlignment.Center, Padding = new Thickness(20), Content = new Avalonia.Controls.Shapes.Path { Data = StreamGeometry.Parse("M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"), Fill = Brushes.Black } }; prev.Click += (s, e) => { if (imageCarousel.SelectedIndex == 0) imageCarousel.SelectedIndex = 1; else imageCarousel.SelectedIndex--; }; next.Click += (s, e) => { if (imageCarousel.SelectedIndex == 1) imageCarousel.SelectedIndex = 0; else imageCarousel.SelectedIndex++; }; return new TabItem { Header = "Images", Content = new ScrollViewer { Content = new StackPanel { HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Vertical, VerticalAlignment = VerticalAlignment.Top, Gap = 4, Margin = new Thickness(10), Children = new Controls { new TextBlock { Text = "Carousel", FontWeight = FontWeight.Medium, FontSize = 20, Foreground = Brush.Parse("#212121"), }, new TextBlock { Text = "An items control that displays its items as pages that fill the controls.", FontSize = 13, Foreground = Brush.Parse("#727272"), Margin = new Thickness(0, 0, 0, 10) }, new StackPanel { Name = "carouselVisual", Orientation = Orientation.Horizontal, Gap = 4, Children = new Controls { prev, imageCarousel, next } } } } } }; }
public void Previous_Once_Moves_To_First_Element() { Button current; Button next; var top = new StackPanel { Children = new Controls { new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, Children = new Controls { (next = new Button { Name = "Button1" }), new Button { Name = "Button2" }, new Button { Name = "Button3" }, } }, new StackPanel { Children = new Controls { (current = new Button { Name = "Button4" }), new Button { Name = "Button5" }, new Button { Name = "Button6" }, } }, } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Previous); Assert.Equal(next, result); }
public void Next_None_Skips_Container() { StackPanel container; Button current; Button next; var top = new StackPanel { Children = new Controls { (container = new StackPanel { [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.None, Children = new Controls { new Button { Name = "Button1" }, new Button { Name = "Button2" }, new Button { Name = "Button3" }, } }), new StackPanel { Children = new Controls { (next = new Button { Name = "Button4" }), new Button { Name = "Button5" }, (current = new Button { Name = "Button6" }), } }, } }; KeyboardNavigation.SetTabOnceActiveElement(container, next); var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Next); Assert.Equal(next, result); }
public void Up_Continue_Returns_Parent() { Button current; var top = new Decorator { Focusable = true, [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue, Child = current = new Button { Name = "Button", } }; var result = KeyboardNavigationHandler.GetNext(current, NavigationDirection.Up); Assert.Equal(top, result); }