当前位置: 首页>>代码示例>>C#>>正文


C# Controls.Button类代码示例

本文整理汇总了C#中Perspex.Controls.Button的典型用法代码示例。如果您正苦于以下问题:C# Button类的具体用法?C# Button怎么用?C# Button使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Button类属于Perspex.Controls命名空间,在下文中一共展示了Button类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNextInTabOrder_Continue_Returns_First_Control_In_Next_Sibling_Container

        public void GetNextInTabOrder_Continue_Returns_First_Control_In_Next_Sibling_Container()
        {
            StackPanel container;
            Button current;
            Button next;

            var top = new StackPanel
            {
                Children = new Controls
                {
                    (container = 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.GetNextInTabOrder(current);

            Assert.Equal(next, result);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:35,代码来源:KeyboardNavigationTests.cs

示例2: InitializeComponent

 private void InitializeComponent()
 {
     PerspexXamlLoader.Load(this);
     _carousel = this.FindControl<Carousel>("carousel");
     _left = this.FindControl<Button>("left");
     _right = this.FindControl<Button>("right");
 }
开发者ID:Arlorean,项目名称:Perspex,代码行数:7,代码来源:CarouselPage.paml.cs

示例3: Next_Continue_Returns_Next_Control_In_Container

        public void Next_Continue_Returns_Next_Control_In_Container()
        {
            StackPanel container;
            Button current;
            Button next;

            var top = new StackPanel
            {
                Children = new Controls
                {
                    (container = new StackPanel
                    {
                        Children = new Controls
                        {
                            new Button { Name = "Button1" },
                            (current = new Button { Name = "Button2" }),
                            (next = 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, FocusNavigationDirection.Next);

            Assert.Equal(next, result);
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:35,代码来源:KeyboardNavigationTests_Tab.cs

示例4: GetNextInTabOrder_Continue_Returns_Child_Of_Top_Level

        public void GetNextInTabOrder_Continue_Returns_Child_Of_Top_Level()
        {
            Button next;

            var top = new StackPanel
            {
                Children = new Controls
                {
                    (next = new Button { Name = "Button1" }),
                }
            };

            var result = KeyboardNavigationHandler.GetNextInTabOrder(top);

            Assert.Equal(next, result);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:16,代码来源:KeyboardNavigationTests.cs

示例5: Down_Contained_Stops_At_End

        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, FocusNavigationDirection.Down);

            Assert.Null(result);
        }
开发者ID:Scellow,项目名称:Perspex,代码行数:37,代码来源:KeyboardNavigationTests_Arrows.cs

示例6: Down_Continue_Returns_First_Control_In_Down_Sibling_Container

        public void Down_Continue_Returns_First_Control_In_Down_Sibling_Container()
        {
            StackPanel container;
            Button current;
            Button next;

            var top = new StackPanel
            {
                Children = new Controls
                {
                    (container = new StackPanel
                    {
                        [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
                        Children = new Controls
                        {
                            new Button { Name = "Button1" },
                            new Button { Name = "Button2" },
                            (current = new Button { Name = "Button3" }),
                        }
                    }),
                    new StackPanel
                    {
                        [KeyboardNavigation.DirectionalNavigationProperty] = KeyboardNavigationMode.Continue,
                        Children = new Controls
                        {
                            (next = new Button { Name = "Button4" }),
                            new Button { Name = "Button5" },
                            new Button { Name = "Button6" },
                        }
                    },
                }
            };

            var result = KeyboardNavigationHandler.GetNext(current, FocusNavigationDirection.Down);

            Assert.Equal(next, result);
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:37,代码来源:KeyboardNavigationTests_Arrows.cs

示例7: Template_Child_Of_Control_With_Two_Classes

        public void Template_Child_Of_Control_With_Two_Classes()
        {
            var template = new ControlTemplate(parent =>
            {
                return new Border
                {
                    Name = "border",
                };
            });

            var control = new Button
            {
                Template = template,
            };

            control.ApplyTemplate();

            var selector = new 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.Add("foo", "bar");
            Assert.Equal(new[] { false, true }, values);
            control.Classes.Remove("foo");
            Assert.Equal(new[] { false, true, false }, values);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:36,代码来源:SelectorTests_Multiple.cs

示例8: Previous_Continue_Returns_Last_Child_Of_Sibling

        public void Previous_Continue_Returns_Last_Child_Of_Sibling()
        {
            StackPanel container;
            Button current;
            Button next;

            var top = new StackPanel
            {
                Children = new Controls
                {
                    (container = new StackPanel
                    {
                        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, FocusNavigationDirection.Previous);

            Assert.Equal(next, result);
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:27,代码来源:KeyboardNavigationTests_Tab.cs

示例9: GetNextInTabOrder_Never_Skips_Container

        public void GetNextInTabOrder_Never_Skips_Container()
        {
            StackPanel container;
            Button current;
            Button next;

            var top = new StackPanel
            {
                Children = new Controls
                {
                    (container = new StackPanel
                    {
                        [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Never,
                        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.GetNextInTabOrder(current);

            Assert.Equal(next, result);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:38,代码来源:KeyboardNavigationTests.cs

示例10: GetNextInTabOrder_Cycle_Wraps_To_First

        public void GetNextInTabOrder_Cycle_Wraps_To_First()
        {
            StackPanel container;
            Button current;
            Button next;

            var top = new StackPanel
            {
                Children = new Controls
                {
                    (container = 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.GetNextInTabOrder(current);

            Assert.Equal(next, result);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:36,代码来源:KeyboardNavigationTests.cs

示例11: AnimationsTab

        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 = SolidColorBrush.Parse("#212121"),
						},
						new TextBlock
						{
							Text = "A few animations showcased below",
							FontSize = 13,
							Foreground = SolidColorBrush.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 TextBox
									{
										Background = Brushes.White,
										Text = "Hello!",
										HorizontalAlignment = HorizontalAlignment.Center,
										VerticalAlignment = VerticalAlignment.Center,
									},
									[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("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;
//.........这里部分代码省略.........
开发者ID:hacklex,项目名称:Perspex,代码行数:101,代码来源:Program.cs

示例12: Up_Cycle_Wraps_To_Last

        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, FocusNavigationDirection.Up);

            Assert.Equal(next, result);
        }
开发者ID:Scellow,项目名称:Perspex,代码行数:37,代码来源:KeyboardNavigationTests_Arrows.cs

示例13: ImagesTab

        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 Perspex.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 Perspex.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 = SolidColorBrush.Parse("#212121"),
                            },
                            new TextBlock
                            {
                                Text = "An items control that displays its items as pages that fill the controls.",
                                FontSize = 13,
                                Foreground = SolidColorBrush.Parse("#727272"),
                                Margin = new Thickness(0, 0, 0, 10)
                            },
                            new StackPanel
                            {
                                Name = "carouselVisual",
                                Orientation = Orientation.Horizontal,
                                Gap = 4,
                                Children = new Controls
                                {
                                    prev,
                                    imageCarousel,
                                    next
                                }
                            }
                        }
                    }
                }
            };
        }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:97,代码来源:MainWindow.cs

示例14: GetPreviousInTabOrder_Continue_Wraps

        public void GetPreviousInTabOrder_Continue_Wraps()
        {
            StackPanel container;
            Button current;
            Button next;

            var top = new StackPanel
            {
                Children = new Controls
                {
                    new StackPanel
                    {
                        Children = new Controls
                        {
                            (container = 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.GetPreviousInTabOrder(current);

            Assert.Equal(next, result);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:41,代码来源:KeyboardNavigationTests.cs

示例15: AnimationsTab

        private static TabItem AnimationsTab()
        {
            Border border1;
            Border border2;
            RotateTransform rotate;
            Button button1;

            var result = new TabItem
            {
                Header = "Animations",
                Content = new Grid
                {
                    ColumnDefinitions = new ColumnDefinitions
                    {
                        new ColumnDefinition(1, GridUnitType.Star),
                        new ColumnDefinition(1, GridUnitType.Star),
                    },
                    RowDefinitions = new RowDefinitions
                    {
                        new RowDefinition(1, GridUnitType.Star),
                        new RowDefinition(GridLength.Auto),
                    },
                    Children = new Controls
                    {
                        (border1 = new Border
                        {
                            Width = 100,
                            Height = 100,
                            HorizontalAlignment = HorizontalAlignment.Center,
                            VerticalAlignment = VerticalAlignment.Center,
                            Background = Brushes.Crimson,
                            RenderTransform = new RotateTransform(),
                            Child = new TextBox
                            {
                                Background = Brushes.White,
                                Text = "Hello!",
                                HorizontalAlignment = HorizontalAlignment.Center,
                                VerticalAlignment = VerticalAlignment.Center,
                            },
                        }),
                        (border2 = new Border
                        {
                            Width = 100,
                            Height = 100,
                            HorizontalAlignment = HorizontalAlignment.Center,
                            VerticalAlignment = VerticalAlignment.Center,
                            Background = Brushes.Coral,
                            Child = new Image
                            {
                                Source = new Bitmap("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),
                            },
                            [Grid.ColumnProperty] = 1,
                        }),
                        (button1 = new Button
                        {
                            HorizontalAlignment = HorizontalAlignment.Center,
                            Content = "Animate",
                            [Grid.ColumnProperty] = 1,
                            [Grid.RowProperty] = 1,
                        }),
                    },
                },
            };

            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;
//.........这里部分代码省略.........
开发者ID:healtech,项目名称:Perspex,代码行数:101,代码来源:Program.cs


注:本文中的Perspex.Controls.Button类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。