using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MWS.Domain.Controls
{
    /// <summary>
    /// TimePickerControl1.xaml 的交互逻辑
    /// </summary>
    public partial class TimePickerControl1 : UserControl
    {
        public DateTime DateTime;
        public TimePickerControl1()
        {
            InitializeComponent();
            tbHour.Text = DateTime.Hour.ToString();
            tbMinute.Text = DateTime.Minute.ToString();
            tbSecond.Text = DateTime.Second.ToString();
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            BindData();

        }
        public void BindData()
        {
            tbHour.Text = DateTime.Hour.ToString();
            tbMinute.Text = DateTime.Minute.ToString();
            tbSecond.Text = DateTime.Second.ToString();
        }

        private void BtnHourUp_Click(object sender, RoutedEventArgs e)
        {
            if (DateTime.Hour<23)
            {

                DateTime = DateTime.AddHours(1);
            }
            else
            {

                DateTime = DateTime.AddHours(-23);
            }
            BindData();
        }

        private void BtnHourDown_Click(object sender, RoutedEventArgs e)
        {
            if (DateTime.Hour >0)
            {

                DateTime = DateTime.AddHours(-1);
            }
            else
            {

                DateTime = DateTime.AddHours(+23);
            }
            BindData();
        }

        private void BtnMinuteUp_Click(object sender, RoutedEventArgs e)
        {
            if (DateTime.Minute< 59)
            {
                DateTime = DateTime.AddMinutes(1);
            }
            else
            {
                DateTime = DateTime.AddMinutes(-59);
            }
            BindData();

        }

        private void BtnMinuteDown_Click(object sender, RoutedEventArgs e)
        {
            if (DateTime.Minute >0)
            {
                DateTime = DateTime.AddMinutes(-1);
            }
            else
            {
                DateTime = DateTime.AddMinutes(59);
            }
            BindData();
        }
       

        private void btnSecondUp_Click(object sender, RoutedEventArgs e)
        {
            if (DateTime.Second < 59)
            {
                DateTime = DateTime.AddSeconds(1);
            }
            else
            {
                DateTime = DateTime.AddSeconds(-59);
            }
            BindData();
        }

        private void btnSecondDown_Click(object sender, RoutedEventArgs e)
        {
            if (DateTime.Second > 0)
            {
                DateTime = DateTime.AddSeconds(-1);
            }
            else
            {
                DateTime = DateTime.AddSeconds(59);
            }
            BindData();
        }
    }
}
