using System; using System.Collections.Generic; using System.Linq; using System.Text; using Mesnac.Action.Base; using System.Windows.Forms; using System.Xml; using System.IO; using Mesnac.Controls.Base; using Mesnac.Controls.Default; namespace Mesnac.Action.Feeding.Qingquan.Sys { /// ///加载。。。 /// public class CommonConfigLoad : FeedingAction, IAction { public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 XmlDocument dom = new XmlDocument(); string componentsConfigFile = Mesnac.Basic.RunSchema.Instance.FilePath(); //Path.Combine(Application.StartupPath, this._runSchemaFilePath); dom.Load(componentsConfigFile); foreach (XmlNode node in dom.DocumentElement.ChildNodes) { if (node.Name == "add") { List controllist = GetAllMCControls(); string key = node.Attributes["key"].InnerText.ToString(); IBaseControl control = controllist.Where(t => t.MCKey!=null && t.MCKey.ToLower() == key.ToLower()).FirstOrDefault(); if (control != null) { control.MCValue = node.Attributes["value"].InnerText.ToString(); } } } } } /// /// 保存配置 /// public class CommonConfigSave : FeedingAction, IAction { //private string _runSchemaFilePath = "Data\\MCProject\\RunSchema.xml"; //运行结构配置文件路径 public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 XmlDocument dom = new XmlDocument(); string componentsConfigFile = Mesnac.Basic.RunSchema.Instance.FilePath(); //Path.Combine(Application.StartupPath, this._runSchemaFilePath); dom.Load(componentsConfigFile); foreach (IBaseControl bc in GetAllMCControls()) { if (bc.MCKey == null) continue; bool Isexists = false; foreach (XmlNode node in dom.DocumentElement.ChildNodes) { if (node.Name == "add") { if (node.Attributes["key"].InnerText.ToString().ToLower() == bc.MCKey.ToLower()) { Isexists = true; XmlElement xe = node as XmlElement; xe.SetAttribute("value", bc.MCValue.ToString()); } } } if (!Isexists)//如果不存在新增 { XmlElement rootxe = dom.DocumentElement; XmlElement xe = dom.CreateElement("add");//创建一个节点 xe.SetAttribute("key", bc.MCKey);//设置该节点的属性 xe.SetAttribute("value", bc.MCValue.ToString()); rootxe.AppendChild(xe); } dom.Save(componentsConfigFile); base.Language(6); } } } public class CommonConfigCheck1 : FeedingAction, IAction { public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 MCCheckBox mccheckbox = runtime.Sender as MCCheckBox; if (mccheckbox.Checked) { IBaseControl BC=GetMCControlByKey("TMQDK").FirstOrDefault(); if (BC != null) BC.MCEnabled = mccheckbox.Checked; IBaseControl BC1 = GetMCControlByKey("TXBTL").FirstOrDefault(); if (BC1 != null) BC1.MCEnabled = mccheckbox.Checked; IBaseControl BC2 = GetMCControlByKey("SJW").FirstOrDefault(); if (BC2 != null) BC2.MCEnabled = mccheckbox.Checked; IBaseControl BC3 = GetMCControlByKey("TZW").FirstOrDefault(); if (BC3 != null) BC3.MCEnabled = mccheckbox.Checked; IBaseControl BC4 = GetMCControlByKey("JYFS").FirstOrDefault(); if (BC4 != null) BC4.MCEnabled = mccheckbox.Checked; IBaseControl BC5 = GetMCControlByKey("XSSJPF").FirstOrDefault(); if (BC5 != null) BC5.MCEnabled = mccheckbox.Checked; IBaseControl BC6 = GetMCControlByKey("TCSSRMA").FirstOrDefault(); if (BC6 != null) BC6.MCEnabled = mccheckbox.Checked; IBaseControl BC7 = GetMCControlByKey("SYDG").FirstOrDefault(); if (BC7 != null) BC7.MCEnabled = mccheckbox.Checked; } } } public class CommonConfigSelectedChange1 : FeedingAction, IAction { public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 MCCombobox mccombobox = runtime.Sender as MCCombobox; if (mccombobox.MCValue.ToString() == "0") { Control c = GetControlById("MCLabel21"); if (c != null) c.Visible = false; Control c1 = GetControlById("MCTextBox9"); if (c1 != null) c1.Visible = false; Control c2 = GetControlById("Panel1"); if (c2 != null) c2.Visible = false; Control c3 = GetControlById("Panel2"); if (c3 != null) c3.Visible = false; Control c4 = GetControlById("MCLabel27"); if (c4 != null) c4.Visible = false; Control c5 = GetControlById("MCTextBox10"); if (c5 != null) c5.Visible = false; } if (mccombobox.MCValue.ToString() == "1" || mccombobox.MCValue.ToString() == "2") { Control c = GetControlById("MCLabel21"); if (c != null) c.Visible = true; Control c1 = GetControlById("MCTextBox9"); if (c1 != null) c1.Visible = true; Control c2 = GetControlById("Panel1"); if (c2 != null) c2.Visible = false; Control c3 = GetControlById("Panel2"); if (c3 != null) c3.Visible = false; Control c4 = GetControlById("MCLabel27"); if (c4 != null) c4.Visible = false; Control c5 = GetControlById("MCTextBox10"); if (c5 != null) c5.Visible = false; } if (mccombobox.MCValue.ToString() == "3" || mccombobox.MCValue.ToString() == "4" || mccombobox.MCValue.ToString() == "6" || mccombobox.MCValue.ToString() == "8") { Control c = GetControlById("MCLabel21"); if (c != null) c.Visible = false; Control c1 = GetControlById("MCTextBox9"); if (c1 != null) c1.Visible = false; Control c2 = GetControlById("Panel1"); if (c2 != null) c2.Visible = true; Control c3 = GetControlById("Panel2"); if (c3 != null) c3.Visible = false; Control c4 = GetControlById("MCLabel27"); if (c4 != null) c4.Visible = false; Control c5 = GetControlById("MCTextBox10"); if (c5 != null) c5.Visible = false; } if (mccombobox.MCValue.ToString() == "5") { Control c = GetControlById("MCLabel21"); if (c != null) c.Visible = true; Control c1 = GetControlById("MCTextBox9"); if (c1 != null) c1.Visible = true; Control c2 = GetControlById("Panel1"); if (c2 != null) c2.Visible = false; Control c3 = GetControlById("Panel2"); if (c3 != null) c3.Visible = false; Control c4 = GetControlById("MCLabel27"); if (c4 != null) c4.Visible = true; Control c5 = GetControlById("MCTextBox10"); if (c5 != null) c5.Visible = true; } if (mccombobox.MCValue.ToString() == "7") { Control c = GetControlById("MCLabel21"); if (c != null) c.Visible = false; Control c1 = GetControlById("MCTextBox9"); if (c1 != null) c1.Visible = false; Control c2 = GetControlById("Panel1"); if (c2 != null) c2.Visible = false; Control c3 = GetControlById("Panel2"); if (c3 != null) c3.Visible = true; Control c4 = GetControlById("MCLabel27"); if (c4 != null) c4.Visible = false; Control c5 = GetControlById("MCTextBox10"); if (c5 != null) c5.Visible = false; } } } }