using Models; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace LeatherApp.UIExtend { public partial class UIDefectImage : UserControl { /// /// code,name /// public Action CodeChangeEvent; public UIDefectImage() { InitializeComponent(); init(); } private void init() { var list = Config.defectItemList.Select(x => new { code = x.Value("code"), name = x.Value("name") }).ToList(); uiComboBox1.ValueMember = "code"; uiComboBox1.DisplayMember = "name"; uiComboBox1.DataSource = list; } [Description("忽略"), Category("自定义")] public bool Checked { get { return this.uiCheckBox1.Checked; } set { this.uiCheckBox1.Checked = value; } } [Description("瑕疵"), Category("自定义")] public string Code { get { return this.uiComboBox1.SelectedValue.ToString(); } set { this.uiComboBox1.SelectedValue = value; } } [Description("瑕疵位置"), Category("自定义")] public string DefecLocation { set { this.lblLocation.Text = value; } } [Description("瑕疵图"), Category("自定义")] public Image Image { set { this.ucImageView1.loadImage(value);} } private void uiComboBox1_SelectedIndexChanged(object sender, EventArgs e) { string code = uiComboBox1.SelectedValue.ToString(); string name = uiComboBox1.Text.ToString(); if (this.Tag != null)//修改不起作用 { var item = (DefectInfo)this.Tag; item.Code = code; item.Name = name; } API.OutputDebugString("AAAAAAAAA-"+code + " " + name); CodeChangeEvent?.Invoke(code,name); } private void ucImageView1_Load(object sender, EventArgs e) { uiCheckBox1.Left = this.uiComboBox1.Left + this.uiComboBox1.Width + 5; this.lblLocation.Left = this.uiCheckBox1.Left + uiCheckBox1.Width + 5; } } }