using FLY.Thick.Blowing.IService;
using System;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Navigation;
using Unity;

namespace FLY.Thick.Blowing.UI.Fix.Client
{
    /// <summary>
    /// Page_Blowing.xaml 的交互逻辑
    /// </summary>
    public partial class PgBlowing : Page
    {
        PgBlowingVm viewModel;

        public PgBlowing()
        {
            InitializeComponent();
        }
        [InjectionMethod]
        public void Init(
            IBlowingFixService blowingFixService,
            IBlowingDetectService blowingDetectService)
        {

            viewModel = new PgBlowingVm();
            viewModel.Init(blowingFixService, blowingDetectService);
            this.DataContext = viewModel;
            //this.grid_blowing.DataContext = viewModel.renZiJiaService;
            //this.grid_bDetect.DataContext = viewModel.bDetect;

            //this.grid_viewModel.DataContext = viewModel;
        }

        private void button_cal_click(object sender, RoutedEventArgs e)
        {
            //TODO
            PgBlowingExt p = new PgBlowingExt();
            p.Init(viewModel.renZiJiaService, viewModel.bDetect);
            NavigationService.Navigate(p);
        }

    }





    public class BoltLengthMultiConverter : IMultiValueConverter
    {

        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            //FilmVelocity
            //RenZiJiaPeriod
            //NBolts
            if (values.Count() != 3)
            {
                return null;
            }
            if ((values[0] is double) && (values[1] is TimeSpan) && (values[2] is int))
            {
                double FilmVelocity = (double)values[0];
                TimeSpan RenZiJiaPeriod = (TimeSpan)values[1];
                int NBolts = (int)values[2];
                return RenZiJiaPeriod.TotalMinutes / NBolts * FilmVelocity;
            }
            return null;

        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }



}