using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Xamarin.Forms;

namespace XamarinStudy.Views
{
	public class SampleElementPage2 : ContentPage
	{
		public SampleElementPage2()
		{
			BackgroundColor = Color.White;

			Button changeBackgroundColorButton = new Button() { Text = "Change background color", BackgroundColor = Color.DarkViolet, FontSize = 30 };
			changeBackgroundColorButton.Clicked += ChangeBackgroundColorButton_Clicked;
			Label label1 = new Label() { Text = "CS Label", TextColor = Color.Red, BackgroundColor = Color.DeepSkyBlue, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) };
			Label label2 = new Label() { Text = "CS 20 Label", TextColor = Color.Red, BackgroundColor = Color.DeepSkyBlue, FontSize = 30 };
			
			Editor editor = new Editor()
			{
				Placeholder = "Multi-line input",
				HeightRequest = 100
			};
			if (Device.RuntimePlatform == Device.UWP)
			{
				editor.BackgroundColor = Color.White;
				editor.TextColor = Color.Black;
			}
			else
			{
				editor.BackgroundColor = Color.Black;
				editor.TextColor = Color.White;
			}

			Slider slider = new Slider()
			{
				Maximum = 30,
				Minimum = 5,
				Value = 10,
				MinimumTrackColor = Color.Pink,
				MaximumTrackColor = Color.Red,
			};
			slider.ValueChanged += (s, e) => editor.Text = e.NewValue.ToString("N2");

			ProgressBar progressBar = new ProgressBar() { ProgressColor = Color.Coral };
			Stepper stepper = new Stepper()
			{
				Maximum = 10,
				Minimum = 0,
			};
			stepper.ValueChanged += (s, e) =>
			{
				progressBar.ProgressTo(e.NewValue / 10, 1500, Easing.BounceOut);
			};

			Content = new StackLayout
			{
				Children =
				{
					changeBackgroundColorButton,
					label1,
					label2,
					editor,
					slider,
					stepper,
					progressBar
				}
			};
		}

		private void ChangeBackgroundColorButton_Clicked(object sender, EventArgs e)
		{
			if (BackgroundColor == Color.White)
				BackgroundColor = Color.DarkSlateGray;
			else
				BackgroundColor = Color.White;
		}
	}
}