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>
    /// TimePickerControl.xaml 的交互逻辑
    /// </summary>
    public partial class TimePickerControl : UserControl
    {
        public DateTime DateTime;
        public TimePickerControl()
        {
            InitializeComponent();
            tbHour.Text = DateTime.Hour.ToString();
            tbMinute.Text = DateTime.Minute.ToString();
            dpDate.Text = DateTime.ToLongDateString();
        }
        public void BindData()
        {
            tbHour.Text = DateTime.Hour.ToString();
            tbMinute.Text = DateTime.Minute.ToString();
            dpDate.Text = DateTime.ToLongDateString();
        }

        private void BtnHourUp_Click(object sender, RoutedEventArgs e)
        {
            DateTime = DateTime.AddHours(1);
            BindData();
        }

        private void BtnHourDown_Click(object sender, RoutedEventArgs e)
        {
            DateTime = DateTime.AddHours(-1);
            BindData();
        }

        private void BtnMinuteUp_Click(object sender, RoutedEventArgs e)
        {

            DateTime = DateTime.AddMinutes(1);
            BindData();

        }

        private void BtnMinuteDown_Click(object sender, RoutedEventArgs e)
        {
            DateTime = DateTime.AddMinutes(-1);
            BindData();
        }

        private void DpDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            DateTime = Convert.ToDateTime(dpDate.Text + " " + tbHour.Text + ":" + tbMinute.Text);
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            BindData();

        }
    }
}
