using FLY.Thick.Base.IService;
using System.Windows;
using System.Windows.Controls;
using Unity;

namespace FLY.Thick.Base.UI.UiModule
{
    /// <summary>
    /// FixGraph.xaml 的交互逻辑
    /// </summary>
    public partial class FixGraph : UserControl
    {
        FixGraphVm viewModel;
        FixGraphItemParam graphparam;
        public FixGraph()
        {
            InitializeComponent();
        }
        [InjectionMethod]
        public void Init(int id, IUnityContainer container,
            IFixService fixService, ITDGageService gageService)
        {
            //查找参数
            graphparam = FixGraphParams.Current.Items.Find(p => p.ID == id);
            if (graphparam == null)
            {
                graphparam = new FixGraphItemParam() { ID = id };
                FixGraphParams.Current.Items.Add(graphparam);
                FixGraphParams.Current.Save();
            }

            //获取设备
            viewModel = new FixGraphVm();
            viewModel.Init(fixService, gageService.DynArea, graphparam);

            this.DataContext = viewModel;
        }

        private void Button_info_click(object sender, RoutedEventArgs e)
        {
            bool isPaused = viewModel.IsPaused;
            if (!isPaused)
                viewModel.IsPaused = true;
            FixGraphConfig w = new FixGraphConfig();
            w.Init(graphparam);
            w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
            w.ShowDialog();
            viewModel.IsPaused = isPaused;
        }
    }










}
