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 CompareGraph : UserControl
    {
        CompareGraphVm viewModel;
        CompareGraphItemParam graphparam;
        public CompareGraph()
        {
            InitializeComponent();
        }

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

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

            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;

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