1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Xamarin.Forms;
- using Xamarin.Forms.Xaml;
- namespace PRS.Mobile.CustomControls
- {
- [XamlCompilation(XamlCompilationOptions.Compile)]
- public partial class MultiButtonScroller : ContentView
- {
- public MultiButtonScroller()
- {
- InitializeComponent();
- }
- public void LoadButtons(List<Button> buttons)
- {
- foreach (Button button in buttons)
- {
- button.BackgroundColor = Color.FromHex("#15C7C1");
- button.Margin = 5;
- button.CornerRadius = 10;
- button.TextColor = Color.White;
- button.FontAttributes = FontAttributes.Bold;
- button.VerticalOptions = LayoutOptions.CenterAndExpand;
- button.HeightRequest = 60;
- button.Padding = new Thickness(10, 5, 10, 5);
- button.FontSize = Device.GetNamedSize(NamedSize.Medium, button);
- buttonsStackLayout.Children.Add(button);
- }
-
- Label labelLeft = new Label()
- {
- Text = "<",
- VerticalOptions = LayoutOptions.Center,
- VerticalTextAlignment = TextAlignment.Center,
- FontAttributes = FontAttributes.Bold,
- Margin = new Thickness(5, 0, 0, 0)
- };
- labelLeft.FontSize = Device.GetNamedSize(NamedSize.Large, labelLeft);
- Label labelRight = new Label()
- {
- Text = ">",
- VerticalOptions = LayoutOptions.Center,
- VerticalTextAlignment = TextAlignment.Center,
- FontAttributes = FontAttributes.Bold,
- Margin = new Thickness(0, 0, 5, 0)
- };
- labelRight.FontSize = Device.GetNamedSize(NamedSize.Large, labelRight);
- labelLeft.SetValue(Grid.ColumnProperty, 0);
- labelLeft.SetValue(Grid.RowProperty, 0);
- labelRight.SetValue(Grid.ColumnProperty, 2);
- labelRight.SetValue(Grid.RowProperty, 0);
- grid.Children.Add(labelLeft);
- grid.Children.Add(labelRight);
- }
- public void AddButton(Button button)
- {
- button.BackgroundColor = Color.FromHex("#15C7C1");
- button.Margin = 5;
- button.CornerRadius = 10;
- button.TextColor = Color.White;
- button.FontAttributes = FontAttributes.Bold;
- button.VerticalOptions = LayoutOptions.CenterAndExpand;
- button.HeightRequest = 60;
- button.Padding = 5;
- button.FontSize = Device.GetNamedSize(NamedSize.Medium, button);
- buttonsStackLayout.Children.Add(button);
- }
- }
- }
|