當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。