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

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace XamarinStudy.Views
{
	[XamlCompilation(XamlCompilationOptions.Compile)]
	public partial class SampleElementPage1 : ContentPage
	{
		public SampleElementPage1()
		{
			InitializeComponent();
			BackgroundColor = Color.White;
		}

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

		private void stepper1_ValueChanged(object sender, ValueChangedEventArgs e)
		{
			lbl1.Text = e.NewValue.ToString("N2");
			pb1.ProgressTo(e.NewValue / 100, 1000, Easing.SpringIn);
			pb2.ProgressTo(e.NewValue / 100, 1000, Easing.SpringOut);
			pb3.ProgressTo(e.NewValue / 100, 1500, Easing.BounceOut);
		}

		private void searchBar_TextChanged(object sender, TextChangedEventArgs e)
		{
			if (string.IsNullOrEmpty(e.NewTextValue) || string.IsNullOrEmpty(editor.Text))
				return;

			char a = e.NewTextValue[0];
			int count = editor.Text.Count(x => x == a);
			entryNum.Text = count.ToString();
		}

		private void switch_Toggled(object sender, ToggledEventArgs e)
		{
			entryText.Text = e.Value.ToString();
			entryText.IsEnabled = e.Value;
		}

		private void checkBox_CheckedChanged(object sender, CheckedChangedEventArgs e)
		{
			entryText.Text = e.Value.ToString();
			entryText.IsEnabled = e.Value;
		}
	}
}