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 GiantMixScanGraph2 : UserControl
    {
        GiantMixScanGraph2Vm viewModel;
        GiantMixScanGraph2ItemParam graphparam;
        public GiantMixScanGraph2()
        {
            InitializeComponent();
        }

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

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

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

            this.DataContext = viewModel;

        }

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

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

        private void btnMarkFromTimeClick(object sender, RoutedEventArgs e)
        {
            viewModel.MarkFromTime();
        }
    }
}
