
///////////////////////////////////////////////////////////////////////////////  
//文件名称: WinProductType.xaml
//文件描述: 产品类型信息
//创 建 者: xls
//创建日期: 2018/5/23 23:29:57
//版 本 号：1.0.0.0
////////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Windows;
using Com.FirmLib.UI.Common;
using Com.FirmLib.UI.Manufacturer.Model;
using FWindSoft.Wpf;
using FWindSoft.Wpf.Controls;

namespace Com.FirmLib.UI.Manufacturer
{
    /// <summary>
    /// WinProductType.xaml 的交互逻辑
    /// </summary>
    public partial class WinProductType : NChildWindow
    {
        private VmProductType m_Vm;
        public WinProductType():this(new VmProductType())
        {          
        }
        public WinProductType(VmProductType vm)
        {
            InitializeComponent();          
            this.m_Vm = vm;
            this.m_Vm.SetRefView(this);
          
            this.DataContext = this.m_Vm;
        }

        protected override void LoadData(LoadParameter parameter)
        {
            TryCatchWrapper.Handled(() => this.m_Vm.Init(parameter));
            try
            {
                this.Title = string.Format("[{0}-{1}]{2}", this.m_Vm.Brand.Name, this.m_Vm.Product.Name, "型号");

                var columns = DataGrid.CreateColumns(this.m_Vm.RefDefinitions, "Parameters", InfoPointTemplateParse.CreateTemplateManager());
                columns.ForEach(c =>
                {
                    DataGridDragCopyOptions.SetCanColumnDragCopy(c, true);
                    c.Width = c.Header.ToString().Length * 16 + 40;
                    c.MinWidth = 80;
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }
        #region 界面关联事件
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {

                if (this.HasError())
                {
                    //MessageShow.Infomation("请修改错误输入项");
                    return;
                }             
            }
            catch (Exception ex)
            {
                //MessageShow.Show(ex);
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
        #endregion
       
    }
}
