
using FLY.Thick.Base.UI;
using FLY.Thick.FilmCasting.Common;
using FLY.Thick.FilmCasting.IService;
using MultiLayout.UiModule;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using Unity;

namespace FLY.Thick.FilmCasting.UI.UiModule
{
    /// <summary>
    /// DynAreaFilmWidth.xaml 的交互逻辑
    /// </summary>
    public partial class DynAreaFilmWidth : UserControl
    {
        private IUnityContainer container;
        private DynArea dynArea;
        private IInitParamService initParamService;
        public DynAreaFilmWidth()
        {
            InitializeComponent();
        }

        [InjectionMethod]
        public void Init(
            IUnityContainer container,
            FLY.Thick.Base.IService.ITDGageService gageService,
            FLY.Thick.Base.IService.IInitParamService initParamService
            )
        {
            this.container = container;
            dynArea = (DynArea)gageService.DynArea;
            this.initParamService = (IInitParamService)initParamService;

            this.grid_initparam.DataContext = initParamService;
            this.DataContext = dynArea;

        }

        private void Border_Width_Click(object sender, RoutedEventArgs e)
        {
            PgBorderSearch p = new PgBorderSearch();
            container.BuildUp(p);
            MultiLayout.FlyLayoutManager.NavigationService.Navigate(p);
        }
    }

    public class DynAreaUt : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public int Width { get; set; }
        public double FilmVelocityBeforeStretching { get; set; }
        public double FilmVelocity { get; set; }
        public double FilmPosition { get; set; }
    }
    public class InitparamUt : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public bool HasVBeforeStretching { get; set; }
    }
    public class UiModule2_DynAreaFilmWidth : IUiModule2
    {
        /// <summary>
        /// 控件标题
        /// 它的值取决于culture
        /// </summary>
        public string Title => "测厚.边界查找";
        public ComponentType Type => ComponentType.DynArea;

        public bool IsUnique => true;

        /// <summary>
        /// 控件
        /// 创建时，需要给它唯一ID，让加载自己的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FrameworkElement GetComponent(int id, IUnityContainer container)
        {
            DynAreaFilmWidth graph = new DynAreaFilmWidth();
            container.BuildUp(graph);
            return graph;
        }

        /// <summary>
        /// 控件缩略图，用于编辑界面时，大致看看
        /// 创建时，需要给它唯一ID，让加载自己的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FrameworkElement GetThumbnail()
        {
            return new System.Windows.Controls.Grid();
        }


        /// <summary>
        /// 给出全部控件ID, 控件自行删除没有的参数
        /// </summary>
        /// <param name="IDs"></param>
        public void MatchParam(int[] IDs)
        {

        }
    }
}
