using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using FLY.Thick.Base.UI.Converter;

using System.Net;

using FLY.Thick.Base.Common;
using FLY.Thick.Base.Client;
using FLY.Thick.Base.IService;
using Unity;
using System.ComponentModel;
using GalaSoft.MvvmLight.Command;

namespace FLY.Thick.Base.UI
{
    /// <summary>
    /// Page_Initparam.xaml 的交互逻辑
    /// </summary>
    public partial class PgInitparamSync : Page
    {
        PgInitParamSyncVm viewModel;
        public PgInitparamSync()
        {
            InitializeComponent();
        }
        [InjectionMethod]
        public void Init(IInitParamService initParamService) 
        {
            viewModel = new PgInitParamSyncVm();
            viewModel.Init(initParamService);
            this.DataContext = viewModel;
        }
    }
    public class PgInitParamSyncVm : PgInitParamVm
    {
        /// <summary>
        /// 本测厚仪探头与机头测厚仪探头距离单位m
        /// </summary>
        public double VDistanceWithHeader { get; set; }

        /// <summary>
        /// 纵向光纤传感器与本测厚仪探头距离 单位m;
        /// 修改此值，会改变纵向偏移
        /// </summary>
        public double VSensorOffset { get; set; }

        public override void Init(IInitParamService initParamService)
        {
            base.Init(initParamService);
            Misc.BindingOperations.SetBinding(initParamService, "VSensorOffset", this, "VSensorOffset");
            Misc.BindingOperations.SetBinding(initParamService, "VDistanceWithHeader", this, "VDistanceWithHeader");


        }

        protected override void Apply()
        {

            if (!WdPassword.Authorize("InitParam"))
                return;

            initParamService.PosLength = this.PosLength;
            initParamService.IsTimeGridAdvEnabled = this.IsTimeGridAdvEnabled;
            initParamService.ADLag = this.ADLag;
            
            initParamService.FilmVSrc = this.FilmVSrc;
            initParamService.FilmVThreshold = this.FilmVThreshold;
            initParamService.Encoder2_mmpp = this.Encoder2_mmpp;
            initParamService.Encoder2_comp = this.Encoder2_comp;
            initParamService.MmOfR = this.MmOfR;
            initParamService.VSensorOffset = this.VSensorOffset;
            initParamService.VDistanceWithHeader = this.VDistanceWithHeader;

            initParamService.VScan = this.VScan;
            initParamService.VJOG = this.VJOG;
            initParamService.VAccuracy = this.VAccuracy;
            initParamService.SVelocity = this.SVelocity;
            initParamService.ATime = this.ATime;
            initParamService.DTime = this.DTime;
            initParamService.HVelocity1 = this.HVelocity1;
            initParamService.HVelocity2 = this.HVelocity2;


            initParamService.AutoOrgInterval = this.AutoOrgInterval;
            initParamService.Encoder1_mmpp = this.Encoder1_mmpp;
            initParamService.DataValidSrc = this.DataValidSrc;
            initParamService.AutoF1F3 = this.AutoF1F3;
            initParamService.ReStartDelay = this.ReStartDelay;
            initParamService.HasProfileSample = this.HasProfileSample;
            initParamService.HasHold = this.HasHold;
            initParamService.DBKeepMonth = this.DBKeepMonth;
            initParamService.DbPath = this.DbPath;
            initParamService.Apply();
            FLY.ControlLibrary.Window_Tip.Show("应用成功",
                null,
                TimeSpan.FromSeconds(2));

        }
    }
}
