using FLY.Thick.Base.UI;
using FLY.Thick.FilmCasting.IService;
using Misc;
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;
using Unity;

namespace FLY.Thick.FilmCasting.UI.UiModule
{
    /// <summary>
    /// ColumnRangeScanGraph.xaml 的交互逻辑
    /// </summary>
    public partial class ScanGraph : UserControl
    {
        ScanGraphVm viewModel;
        ScanGraphItemParam graphparam;
        public ScanGraph()
        {
            InitializeComponent();
        }

        [InjectionMethod]
        public void Init(int id, IUnityContainer container,
            IBulkDbService bulkDbService, ParamDictionary paramDictionary, IFilmCastingProfileService calenderProfileService,
            FLY.Thick.Base.IService.IInitParamService initParamService)
        {
            //查找参数
            graphparam = ScanGraphParams.Current.Items.Find(p => p.ID == id);
            if (graphparam == null)
            {
                graphparam = new ScanGraphItemParam() { ID = id };
                ScanGraphParams.Current.Items.Add(graphparam);
                ScanGraphParams.Current.Save();
            }

            //获取设备
            viewModel = new ScanGraphVm();

            viewModel.Init(graphparam, bulkDbService, paramDictionary, calenderProfileService.Param, (IInitParamService)initParamService);

            this.DataContext = viewModel;

        }

        private void Button_info_click(object sender, RoutedEventArgs e)
        {
            if (!WdPassword.Authorize("GraphConfig"))
                return;

            WdScanGraphConfig window = new WdScanGraphConfig();
            window.Init(graphparam,viewModel);
            window.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
            window.ShowDialog();
        }
    }
}
