示例#1
0
		public RoundedFramePage ()
		{
			Title = "Rounded Frame Sample";
			this.BackgroundColor = ColorHelper.MyLightGray.ToFormsColor();

			var shadowSwitch = new Switch { IsToggled = true, HorizontalOptions = LayoutOptions.EndAndExpand };

			var originalFrame = new Frame { 
				Content = new Label { Text = "This is a regular frame" },
			};

			var roundedFrame = new RoundedFrame { 
				HasShadow = true,
				Content = new Label { Text = "This is a rounded frame" },
				CornerRadius = 24d
			};
			var cornerRadiusSlider = new Slider (0d, 50d, 24d) { HorizontalOptions = LayoutOptions.EndAndExpand };
			var outlineWidthSlider = new Slider (0d, 50d, 1d) { HorizontalOptions = LayoutOptions.EndAndExpand };

			var borderColorPicker = new ColorPicker { SelectedColor = Color.Default };
			var outlineColorPicker = new ColorPicker { SelectedColor = Color.Default };

			Content = new ScrollView {
				Content = new StackLayout { 
					Padding = new Thickness(8d),
					Spacing = 4d,
					Children = {
						originalFrame,
						roundedFrame,
						new BoxView { HeightRequest=16d, BackgroundColor=Color.Transparent },
						new Label { Text = "Background Color" },
						borderColorPicker,
						new Label { Text = "Outline Color" },
						outlineColorPicker,
						new StackLayout { 
							Orientation = StackOrientation.Horizontal,
							Children = { 
								new Label { Text = "Corner Radius", HorizontalOptions = LayoutOptions.Start },
								cornerRadiusSlider,
							},
						},
						new StackLayout { 
							Orientation = StackOrientation.Horizontal,
							Children = { 
								new Label { Text = "Outline Width", HorizontalOptions = LayoutOptions.Start },
								outlineWidthSlider,
							},
						},
						new StackLayout {
							Orientation = StackOrientation.Horizontal,
							Children = {
								new Label { Text = "Shadows?", HorizontalOptions = LayoutOptions.Start },
								shadowSwitch,
							},
						},
					}
				}
			};

			roundedFrame.SetBinding(RoundedFrame.CornerRadiusProperty, new Binding("Value", BindingMode.TwoWay, source:cornerRadiusSlider));

			originalFrame.SetBinding(RoundedFrame.HasShadowProperty, new Binding("IsToggled", BindingMode.TwoWay, source:shadowSwitch));
			roundedFrame.SetBinding(RoundedFrame.HasShadowProperty, new Binding("IsToggled", BindingMode.TwoWay, source:shadowSwitch));

			originalFrame.SetBinding(Frame.BackgroundColorProperty, new Binding("SelectedColor", BindingMode.OneWay, source:borderColorPicker));
			roundedFrame.SetBinding(Frame.BackgroundColorProperty, new Binding("SelectedColor", BindingMode.OneWay, source:borderColorPicker));
		
			originalFrame.SetBinding(Frame.OutlineColorProperty, new Binding("SelectedColor", BindingMode.OneWay, source:outlineColorPicker));
			roundedFrame.SetBinding(Frame.OutlineColorProperty, new Binding("SelectedColor", BindingMode.OneWay, source:outlineColorPicker));

			roundedFrame.SetBinding(RoundedFrame.OutlineWidthProperty, new Binding("Value", BindingMode.TwoWay, source:outlineWidthSlider));
		}
示例#2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="WF.Player.GameMainCellView"/> class.
		/// </summary>
		public GameMainCellView()
		{
			this.horiLayout = new StackLayout() 
				{
					BackgroundColor = Color.Transparent,
					Orientation = StackOrientation.Horizontal,
					Spacing = 5,
					Padding = new Thickness(10, 0, 0, 0),
					VerticalOptions = LayoutOptions.FillAndExpand,
					HorizontalOptions = LayoutOptions.FillAndExpand,
				};

			this.icon = new Image() 
			{
				BackgroundColor = Color.Transparent,
				WidthRequest = 48,
				HeightRequest = 48,
				Aspect = Aspect.AspectFit,
			};
			this.icon.SetBinding(Image.SourceProperty, GameMainCellViewModel.IconSourcePropertyName);
			this.icon.SetBinding(Image.IsVisibleProperty, GameMainCellViewModel.ShowIconPropertyName);

			var iconFrame = new Frame() 
				{
					WidthRequest = 1,
					HasShadow = false,
					Padding = new Thickness(0, 5),
				};

			iconFrame.SetBinding(Frame.HeightRequestProperty, GameMainCellViewModel.MinimumRowHeightPropertyName);

			this.name = new Label() 
				{
					XAlign = TextAlignment.Start,
					VerticalOptions = LayoutOptions.Center,
					HorizontalOptions = LayoutOptions.StartAndExpand,
					MinimumHeightRequest = 50,
					FontSize = Settings.FontSize,
					FontFamily = Settings.FontFamily,
					TextColor = App.Colors.Text,
				};
			this.name.SetBinding(Label.TextProperty, GameMainCellViewModel.NamePropertyName);

			var vertLayout = new StackLayout() 
			{
				WidthRequest = 54,
				Orientation = StackOrientation.Vertical,
				Spacing = 5,
				Padding = new Thickness(10, 5),
				VerticalOptions = LayoutOptions.End, //FillAndExpand,
				HorizontalOptions = LayoutOptions.End,
			};
			vertLayout.SetBinding(StackLayout.IsVisibleProperty, GameMainCellViewModel.ShowDirectionPropertyName);

			var direction = new DirectionArrow() 
			{
				BackgroundColor = Color.Transparent,
				CircleColor = App.Colors.DirectionBackground,
				ArrowColor = App.Colors.DirectionColor,
				WidthRequest = 32,
				HeightRequest = 32,
				HorizontalOptions = LayoutOptions.End,
			};
			direction.SetBinding(DirectionArrow.DirectionProperty, GameMainCellViewModel.DirectionPropertyName);

			var distance = new Label() 
			{
				TextColor = App.Colors.Text,
				Font = Font.SystemFontOfSize(12),
				XAlign = TextAlignment.Center,
				HorizontalOptions = LayoutOptions.End,
			};
			distance.SetBinding(Label.TextProperty, GameMainCellViewModel.DistancePropertyName, BindingMode.OneWay, new ConverterToDistance());

			vertLayout.Children.Add(direction);
			vertLayout.Children.Add(distance);

			this.horiLayout.Children.Add(this.icon);
			this.horiLayout.Children.Add(iconFrame);
			this.horiLayout.Children.Add(this.name);
			this.horiLayout.Children.Add(vertLayout);

			View = this.horiLayout;
		}