public void SetTestSystem(string[] temps, BusinessLogic.DomainModel.TestSystem testSystem) { TempSetting = temps; BindingTestSystem = testSystem; if (TempSetting == null || BindingTestSystem == null) { return; } gbPanel.Text = $"{BindingTestSystem.SystemName}设置"; if (BindingTestSystem.PortSetting > 0) { gbPanel.Text += $" (Port{BindingTestSystem.PortSetting})"; } else if (BindingTestSystem.PortSetting < 0) { gbPanel.Text += $" (In{-1 * BindingTestSystem.PortSetting})"; } cbSpec.ValueMember = "Key"; cbSpec.DisplayMember = "Value"; cbSpec.DataSource = new BindingCollection <KeyValuePair <string, string> >(OperatorManager.GetComputeDataSource()); cbSpec.Text = BindingTestSystem.DefaultComputeSign; //tbSetting.Text = BindingTestSystem.DefaultSetting; CreateTestSystemItemEditor(); }
public void LoadData(Guid pSystemID, Guid pTestGroupID, Action cback = null) { this.GetService <ModifyTestSystem>().ExecuteAsync( c => c.GetData(pSystemID), (result) => { if (!result.Status) { AppFramework.Context.ShowError(result.Message); this.Close(); return; } callback = cback; vm.Model.SystemID = result.Data.SystemID; vm.Model.SystemName = result.Data.SystemName; vm.Model.DisplayName = result.Data.DisplayName; vm.Model.DefaultSetting = result.Data.DefaultSetting; vm.Model.PortSetting = result.Data.PortSetting; vm.Model.OrderID = result.Data.OrderID; //设置窗体标题 if (pSystemID == Guid.Empty) { result.Data.TestGroupID = pTestGroupID; this.Text = "添加测试项"; } else { pTestGroupID = result.Data.TestGroupID; this.Text = $"修改测试项 - {result.Data.SystemName}"; } vm.Render(panelContent, new Padding(0, 15, 15, 0), "30%", true, (name, control) => { if (name == "OrderID") { (control as NumericUpDown).Maximum = 10000; } }, (name, control) => { switch (name) { case "SystemTypeID": (control as ComboBox).UpdateDataSource(MeasuringManager.GetCalculateDataSource(), result.Data.SystemTypeID, (value) => { vm.Model.SystemTypeID = value; }); break; case "DefaultComputeSign": (control as ComboBox).UpdateDataSource(OperatorManager.GetComputeDataSource(), result.Data.DefaultComputeSign, (value) => { vm.Model.DefaultComputeSign = value; }); break; case "TestGroupID": var cb = (control as ComboBox); this.GetService <ModifyTestSystem>().ExecuteAsync(c => c.GetTestGroupDataSource(pTestGroupID) , (source) => { if (!source.Status) { return; } cb.UpdateDataSource(source.Data, result.Data.TestGroupID, (value) => { vm.Model.TestGroupID = value; }); }); break; case "TemperatureSetting": var ds4 = new BindingList <KeyValuePair <int, string> >(); ds4.Add(new KeyValuePair <int, string>(0, "多温度测试")); ds4.Add(new KeyValuePair <int, string>(1, "常温测试")); (control as ComboBox).UpdateDataSource(ds4, result.Data.TemperatureSetting, (value) => { vm.Model.TemperatureSetting = value; }); break; } }); }); }
public void LoadData(Guid pSpecItemID, SpecItem specitem, string tempSetting, Action <SpecItem> cback) { callback = cback; vm.Model.SpecItemID = specitem.SpecItemID; vm.Model.SeqID = specitem.SeqID; vm.Model.SystemID = specitem.SystemID; vm.Model.ItemName = specitem.ItemName; vm.Model.TestTemp = specitem.TestTemp; vm.Model.TestInfo = specitem.TestInfo; vm.Model.ComputeSetting = specitem.ComputeSetting; vm.Model.OrderID = specitem.OrderID; //设置窗体标题 if (pSpecItemID == Guid.Empty) { this.Text = $"添加{ModifySpecItem.ItemName}"; } else { this.Text = $"修改{ModifySpecItem.ItemName} - {specitem.ItemName}"; } var temps = tempSetting.Split(","); vm.Render(panelContent, new Padding(0, 15, 15, 0), "100%", true, (name, control) => { switch (name) { case "TestTemp": var ds1 = (control as ComboBox).DataSource as BindingList <KeyValuePair <string, string> >; foreach (var temp in temps) { if (string.IsNullOrEmpty(temp)) { continue; } ds1.Add(new KeyValuePair <string, string>(temp, temp)); } break; case "ItemName": control.Enabled = false; break; case "ComputeSetting": var data = vm.Model.ComputeSetting.FromJsonString <Dictionary <int, ComputeSettingItem> >(); if (data == null) { return; } control.Visible = false; var left = control.Left; var top = control.Top; cbSpec = new ComboBox() { FormattingEnabled = true, Location = new Point(left, top), Name = "cbSpec", Size = new Size(76, 20), ValueMember = "Key", DisplayMember = "Value", DataSource = new BindingCollection <KeyValuePair <string, string> >(OperatorManager.GetComputeDataSource()) }; panelContent.Controls.Add(cbSpec); top += 30; var r = 0; foreach (var resultitem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult) { var lbSpec = new Label() { Name = string.Format("lbSpec{0}", resultitem.ResultID), AutoSize = true, Location = new Point(left, top + 5 + 30 * r), Text = resultitem.ResultName }; var tbSpec = new TextBox() { Name = string.Format("tbSpec{0}", resultitem.ResultID), Size = new Size(100, 21), Location = new Point(left + 115, top + 30 * r), }; panelContent.Controls.Add(lbSpec); panelContent.Controls.Add(tbSpec); tbSpecs[resultitem.ResultID] = tbSpec; r++; } foreach (var item in data) { cbSpec.Text = item.Value.ComputeSign; if (tbSpecs.ContainsKey(item.Key)) { tbSpecs[item.Key].Text = item.Value.ComputeValue; } } break; } }, null); }