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>
    /// TempScanGraph.xaml 的交互逻辑
    /// </summary>
    public partial class TempScanGraph : UserControl
    {
        TempScanGraphVm viewModel;
        TempScanGraphItemParam graphparam;
        public TempScanGraph()
        {
            InitializeComponent();
        }

        [InjectionMethod]
        public void Init(int id, IUnityContainer container,
            IBulkDbService bulkDbService, ParamDictionary paramDictionary, IFilmCastingProfileService calenderProfileService, IBoltMapFilmCastingService boltMapFilmCastingService)
        {
            //查找参数
            graphparam = TempScanGraphParams.Current.Items.Find(p => p.ID == id);
            if (graphparam == null)
            {
                graphparam = new TempScanGraphItemParam() { ID = id };
                TempScanGraphParams.Current.Items.Add(graphparam);
                TempScanGraphParams.Current.Save();
            }

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

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

            this.DataContext = viewModel;

        }

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

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