summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/CoreGalleryPages/ButtonCoreGalleryPage.cs
blob: 65aa6fa3cbb874d4d9b229589fe08731dbe02abf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using Xamarin.Forms.CustomAttributes;

namespace Xamarin.Forms.Controls
{
	internal class ButtonCoreGalleryPage : CoreGalleryPage<Button>
	{
		protected override bool SupportsTapGestureRecognizer {
			get { return false; }
		}

		protected override bool SupportsFocus {
			get { return false; }
		}

		protected override void InitializeElement (Button element)
		{
			element.Text = "Button";
		}

		protected override void Build (StackLayout stackLayout)
		{
			base.Build (stackLayout);

			IsEnabledStateViewContainer.View.Clicked += (sender, args) => IsEnabledStateViewContainer.TitleLabel.Text += " (Tapped)";

			var borderButtonContainer = new ViewContainer<Button> (Test.Button.BorderColor, 
				new Button {
					Text = "BorderColor",
					BackgroundColor = Color.Transparent, 
					BorderColor = Color.Red, 
					BorderWidth = 1,
				}
			);

			var borderRadiusContainer = new ViewContainer<Button> (Test.Button.BorderRadius, 
				new Button {
					Text = "BorderRadius",
					BackgroundColor = Color.Transparent,
					BorderColor = Color.Red,
					BorderRadius = 20,
					BorderWidth = 1,
				}
			);
		
			var borderWidthContainer = new ViewContainer<Button> (Test.Button.BorderWidth,
				new Button {
					Text = "BorderWidth",
					BackgroundColor = Color.Transparent,
					BorderColor = Color.Red,
					BorderWidth = 15,
				}
			);

			var clickedContainer = new EventViewContainer<Button> (Test.Button.Clicked, 
				new Button {
					Text = "Clicked"
				}
			);
			clickedContainer.View.Clicked += (sender, args) => clickedContainer.EventFired ();

			var commandContainer = new ViewContainer<Button> (Test.Button.Command, 
				new Button {
					Text = "Command", 
					Command = new Command (() => DisplayActionSheet ("Hello Command", "Cancel", "Destroy"))
				}
			);

			var fontContainer = new ViewContainer<Button> (Test.Button.Font,
				new Button {
					Text = "Font", 
					Font = Font.SystemFontOfSize (NamedSize.Large, FontAttributes.Bold) 
				}
			);

			var imageContainer = new ViewContainer<Button> (Test.Button.Image, 
				new Button {
					Text = "Image", 
					Image = new FileImageSource { File = "bank.png" }
				}
			)
			;
			var textContainer = new ViewContainer<Button> (Test.Button.Text, 
				new Button {
					Text = "Text"
				}
			);

			var textColorContainer = new ViewContainer<Button> (Test.Button.TextColor, 
				new Button {
					Text = "TextColor", TextColor = Color.Pink
				}
			);

			Add (borderButtonContainer);
			Add (borderRadiusContainer);
			Add (borderWidthContainer);
			Add (clickedContainer);
			Add (commandContainer);
			Add (fontContainer);
			Add (imageContainer);
			Add (textContainer);
			Add (textColorContainer);
			//stackLayout.Children.Add (textColorContainer);
		}
	}
}