using Bro.Common.Interface; using Bro.UI.Model.Winform; using System; using Microsoft.VisualBasic; using System.Windows.Forms; using Bro.Common.PubSub; using static Bro.Common.Helper.EnumHelper; namespace Bro.UI.Config.MenuForms { [MenuNode("Config", "配置", 1, "View2", true)] public partial class FrmConfig : MenuFrmBase { public FrmConfig() { InitializeComponent(); } public override void OnProcessUpdated() { if (this.InvokeRequired) { this.BeginInvoke(new Action(OnProcessUpdated)); } else { propGrid.SelectedObject = Process?.IConfig; } } private void FrmConfig_Load(object sender, EventArgs e) { OnProcessUpdated(); } private void btnSave_Click(object sender, EventArgs e) { if (!IsLogin) { AdvancedPwdFrm pwdForm = new AdvancedPwdFrm(); pwdForm.ShowDialog(); } if (!IsLogin) { LogAsync(DateTime.Now, "保存配置前必须先登录"); return; } Process.SaveProcessConfig(propGrid.SelectedObject as IProcessConfig); LogAsync(DateTime.Now, "配置保存完成"); } private void buttonCreateConfig_Click(object sender, EventArgs e) { ProductionCodeEditForm productionCodeEditForm = new ProductionCodeEditForm(); if (productionCodeEditForm.ShowDialog(this) == DialogResult.OK) { string pCode = productionCodeEditForm.PCode; productionCodeEditForm.Dispose(); if (string.IsNullOrWhiteSpace(pCode)) { MessageBox.Show("请输入产品编码!"); return; } Process.CreateNewConfig(propGrid.SelectedObject as IProcessConfig, pCode); MessageBox.Show("创建新配置完成"); PubSubCenter.GetInstance().Publish(PubSubCenterMessageType.UpdateProductionCodes.ToString(), null, null); } } } }