using FLY.UI.Module;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;

namespace ThickTcpUiInWindow.UIModule
{
    /// <summary>
    /// DynAreaIO.xaml 的交互逻辑
    /// </summary>
    public partial class DynAreaIO : UserControl
    {

        TDGage gage;
        public DynAreaIO()
        {
            InitializeComponent();
        }


        public void Init(int id)
        {
            //获取设备
            gage = Application.Current.Properties["Gage"] as TDGage;
            this.DataContext = gage.mDynAreaService.mDynArea;
        }
        protected virtual void Border_IO_Click(object sender, RoutedEventArgs e)
        {
            if (DynAreaIOParams.Current.IODespWindowType != null)
            {
                Window w = Activator.CreateInstance(DynAreaIOParams.Current.IODespWindowType) as Window;
                w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
                w.ShowDialog();
            }
        }
    }

    public class UIModule_DynAreaIO : IUIModule
    {
        /// <summary>
        /// 控件标题
        /// 它的值取决于culture
        /// </summary>
        public string Title
        {
            get
            {
                return Application.Current.FindResource("strDynAreaIO") as string;
            }
        }

        /// <summary>
        /// 控件
        /// 创建时，需要给它唯一ID，让加载自己的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FrameworkElement GetComponent(int id)
        {
            DynAreaIO graph = new DynAreaIO();
            graph.Init(id);
            return graph;
        }

        /// <summary>
        /// 控件缩略图，用于编辑界面时，大致看看
        /// 创建时，需要给它唯一ID，让加载自己的数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FrameworkElement GetThumbnail(int id)
        {
            return new System.Windows.Controls.Grid();
        }


        /// <summary>
        /// 给出全部控件ID, 控件自行删除没有的参数
        /// </summary>
        /// <param name="IDs"></param>
        public void MatchParam(int[] IDs)
        {
           
        }
    }

    /// <summary>
    /// 全部扫描图的参数
    /// </summary>
    public class DynAreaIOParams
    {
        public Type IODespWindowType = null;
        static DynAreaIOParams()
        {

        }

        static DynAreaIOParams current = null;
        public static DynAreaIOParams Current
        {
            get
            {
                if (current == null)
                {
                    current = new DynAreaIOParams();
                }
                return current;
            }
        }

        public DynAreaIOParams()
        {
            IODespWindowType = typeof(Window_IOTip);
        }
    }
}
