c# xml 参数配置表的使用

使用简介

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
实际使用界面

在这里插入图片描述

配置表管理界面

在这里插入图片描述

进入

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;using Sunny.UI;
using System.Xml;
using System.IO;
        public ModuleGrid(){InitializeComponent();uipanelMain.AutoScroll = true;//防止内容过多 当显示不下的时候 可以有滚轮//DisplayData();//这个在这里使用不知道为什么就是报错 显示未将对象设置引用到对象实例  我直接放最开始调用//MessageBox.Show("kai ");}

在这里插入图片描述

        public static ModuleGrid modgrid;private void uiButton1_Click(object sender, EventArgs e){modgrid = new ModuleGrid();modgrid.Show();ModuleGrid.DisplayData();//这个函数的作用就是新增我们需要的框的控件}
       private static int width = 360;private static int height = 254;private static List<GridContent> list;public static string path = Directory.GetCurrentDirectory()+ "\\ParameterSet\\grid.xml";public static void DisplayData(){try{list = new List<GridContent>();XmlDocument doc = new XmlDocument();doc.Load(path);XmlNodeList nodeList = doc.SelectNodes("/person/list");//xPath相关手册,找节点person的listint index = 1;foreach (XmlNode node in nodeList){string no = node.Attributes["no"].Value;string modeName = node.SelectSingleNode("modeName").InnerText;//MessageBox.Show("modeName:" + modeName);GridContent grid = new GridContent();grid.No = no;list.Add(grid);addUIItem(index, modeName);//UI增加index++;}}catch (Exception ex){log.SaveLog(@"报告模板异常:" + ex.Message);}}
 class GridContent{private string modeName;private string no;public string ModeName{get{return modeName;}set{modeName = value;}}public string No{get{return no;}set{no = value;}}}
private static void addUIItem(int index, string modeName){//1724 -50 - 4*width =   78UIPanel paneln = new UIPanel();int curIndex = index / 4;int mod = index % 4;int pointX = (width + 65) * (mod) + 25;int pointY = curIndex * (height) + (curIndex + 1) * 25;paneln.Location = new Point(pointX, pointY);paneln.Size = new Size(width, height);paneln.FillColor = Color.White;paneln.RectColor = ColorTranslator.FromHtml("#D6D6D6");UILabel label = new UILabel();label.AutoSize = false;label.Text = modeName;label.Location = new Point(40, 20);label.Size = new Size(300, 90);label.Font = new System.Drawing.Font("微软雅黑", 16F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));label.TextAlign = ContentAlignment.MiddleCenter;UIButton btnDel = new UIButton();btnDel.Size = new Size(100, 50);btnDel.Location = new Point(50, 170);btnDel.Font = new System.Drawing.Font("微软雅黑", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));btnDel.FillColor = Color.White;btnDel.RectColor = ColorTranslator.FromHtml("#D6D6D6");btnDel.ForeColor = ColorTranslator.FromHtml("#333333");btnDel.Text = "删除";btnDel.Tag = list[index - 1].No;btnDel.Click += new System.EventHandler(btnDel_Click);UIButton btnEdit = new UIButton();btnEdit.Size = new Size(100, 50);btnEdit.Location = new Point(220, 170);btnEdit.Font = new System.Drawing.Font("微软雅黑", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));btnEdit.FillColor = Color.White;btnEdit.RectColor = ColorTranslator.FromHtml("#D6D6D6");btnEdit.ForeColor = ColorTranslator.FromHtml("#333333");btnEdit.Text = "编辑";btnEdit.Tag = list[index - 1].No;btnEdit.Click += new EventHandler(btnEdit_Click);paneln.Controls.Add(label);paneln.Controls.Add(btnDel);paneln.Controls.Add(btnEdit);Form1.modgrid.uipanelMain.Controls.Add(paneln);}

确定和返回按键

this.Close();

新增项的按键

在进入的addUIItem函数里面添加的

在这里插入图片描述

编辑

 private static void btnEdit_Click(object sender, EventArgs e){UIButton btn = (UIButton)sender;string no = btn.Tag.ToString();//  new AddModule("edit", no, uipanelMain).Show();AddModule frm = new AddModule("edit", no, Form1.modgrid.uipanelMain);    frm.Show();Form1.modgrid.Hide();//如果是关闭 那么下次是无法show的}

删除

 private static void btnDel_Click(object sender, EventArgs e){UIButton btn = (UIButton)sender;string no = btn.Tag.ToString();delUI();delGridItem(no);//this.Invalidate();//this.Refresh();}public static void delUI(){int index = 0;for (int i = list.Count() - 1; i >= 0; i--){index = (i + 1);Form1.modgrid.uipanelMain.Controls.RemoveAt(index);}}private static void delGridItem(string no){XmlDocument doc = new XmlDocument();doc.Load(path);XmlElement root = doc.DocumentElement;XmlNodeList xmlNodeList = doc.SelectNodes("/person/list[@no='" + no + "']");foreach (XmlNode xmlNode in xmlNodeList){xmlNode.ParentNode.RemoveChild(xmlNode);}doc.Save(path);DisplayData();}

新增一个
在这里插入图片描述

        private void uiPanel3_Click(object sender, EventArgs e){OpenAddModule();}private void pictureBox2_Click(object sender, EventArgs e){OpenAddModule();}private void uiLabel3_Click(object sender, EventArgs e){OpenAddModule();}public static void OpenAddModule(){AddModule frm = new AddModule("add", "", Form1.modgrid.uipanelMain);frm.Show();Form1.modgrid.Hide();//如果是关闭 那么下次是无法show的}

页面传递讲解

        public static void OpenAddModule(){AddModule frm = new AddModule("add", "", Form1.modgrid.uipanelMain);frm.Show();Form1.modgrid.Hide();//如果是关闭 那么下次是无法show的}

要打开的界面 给他一个带参数的构造函数就可以了

        string no;UIPanel uipanel;string type;public static string path = Directory.GetCurrentDirectory() + "\\ParameterSet\\grid.xml";public AddModule(string type, string no, UIPanel uipanel)//这三个参数都是自己新加的 不然是没有参数的 用于上一页面传入参数进来{InitializeComponent();this.no = no;this.type = type;this.uipanel = uipanel;if (type.Equals("add")){labelTItle.Text = "新增配置表";}else if (type.Equals("edit")){try{labelTItle.Text = "编辑配置表";//赋值XmlDocument doc = new XmlDocument();doc.Load(path);XmlNodeList xmlNodeList = doc.SelectNodes("/person/list[@no='" + no + "']");XmlNode node = xmlNodeList[0];tmodelName.Text = node.SelectSingleNode("modeName").InnerText;clientTextBox.Text = node.SelectSingleNode("client").InnerText;hardwareTextBox.Text = node.SelectSingleNode("hardware").InnerText;softwareTextBox.Text = node.SelectSingleNode("software").InnerText;tongshuTextBox.Text = node.SelectSingleNode("tongshu").InnerText;kongshuTextBox.Text = node.SelectSingleNode("kongshu").InnerText;TMCuiTextBox.Text = node.SelectSingleNode("tmc").InnerText;typeuiTextBox.Text = node.SelectSingleNode("type").InnerText;order1TextBox.Text = node.SelectSingleNode("order1").InnerText;order2TextBox.Text = node.SelectSingleNode("order2").InnerText;order3TextBox.Text = node.SelectSingleNode("order3").InnerText;order4TextBox.Text = node.SelectSingleNode("order4").InnerText;order5TextBox.Text = node.SelectSingleNode("order5").InnerText;order6TextBox.Text = node.SelectSingleNode("order6").InnerText;order7TextBox.Text = node.SelectSingleNode("order7").InnerText;order8TextBox.Text = node.SelectSingleNode("order8").InnerText;order9TextBox.Text = node.SelectSingleNode("order9").InnerText;order10TextBox.Text = node.SelectSingleNode("order10").InnerText;order11TextBox.Text = node.SelectSingleNode("order11").InnerText;order12TextBox.Text = node.SelectSingleNode("order12").InnerText;order13TextBox.Text = node.SelectSingleNode("order13").InnerText;}catch (Exception ex){log.SaveLog(ex.ToString());throw;}}}

新增页面

在这里插入图片描述

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using Sunny.UI;

构造函数

可以进行参数的传递

        string no;UIPanel uipanel;string type;public static string path = Directory.GetCurrentDirectory() + "\\ParameterSet\\grid.xml";public AddModule(string type, string no, UIPanel uipanel)//这三个参数都是自己新加的 不然是没有参数的 用于上一页面传入参数进来{InitializeComponent();this.no = no;this.type = type;this.uipanel = uipanel;if (type.Equals("add")){labelTItle.Text = "新增配置表";}else if (type.Equals("edit")){try{labelTItle.Text = "编辑配置表";//赋值XmlDocument doc = new XmlDocument();doc.Load(path);XmlNodeList xmlNodeList = doc.SelectNodes("/person/list[@no='" + no + "']");XmlNode node = xmlNodeList[0];tmodelName.Text = node.SelectSingleNode("modeName").InnerText;clientTextBox.Text = node.SelectSingleNode("client").InnerText;hardwareTextBox.Text = node.SelectSingleNode("hardware").InnerText;softwareTextBox.Text = node.SelectSingleNode("software").InnerText;tongshuTextBox.Text = node.SelectSingleNode("tongshu").InnerText;kongshuTextBox.Text = node.SelectSingleNode("kongshu").InnerText;TMCuiTextBox.Text = node.SelectSingleNode("tmc").InnerText;typeuiTextBox.Text = node.SelectSingleNode("type").InnerText;order1TextBox.Text = node.SelectSingleNode("order1").InnerText;order2TextBox.Text = node.SelectSingleNode("order2").InnerText;order3TextBox.Text = node.SelectSingleNode("order3").InnerText;order4TextBox.Text = node.SelectSingleNode("order4").InnerText;order5TextBox.Text = node.SelectSingleNode("order5").InnerText;order6TextBox.Text = node.SelectSingleNode("order6").InnerText;order7TextBox.Text = node.SelectSingleNode("order7").InnerText;order8TextBox.Text = node.SelectSingleNode("order8").InnerText;order9TextBox.Text = node.SelectSingleNode("order9").InnerText;order10TextBox.Text = node.SelectSingleNode("order10").InnerText;order11TextBox.Text = node.SelectSingleNode("order11").InnerText;order12TextBox.Text = node.SelectSingleNode("order12").InnerText;order13TextBox.Text = node.SelectSingleNode("order13").InnerText;}catch (Exception ex){log.SaveLog(ex.ToString());throw;}}}

load函数

进行一次自动的指令到指令名称的转换。如果该指令不等于0的话就进行一次转换

 private void AddModule_Load(object sender, EventArgs e){try{if (order1TextBox.Text != "0"){order1uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order1TextBox.Text.Substring(0, order1TextBox.Text.IndexOf('*'))));//log.SaveLog("指令转换1字符串:" + order1TextBox.Text.Substring(0, order1TextBox.Text.IndexOf('*')));//for (int i = 0; i < 5; i++)//{//    log.SaveLog("转字节{i}:" + Form1.strToToHexByte(order1TextBox.Text.Substring(0, order1TextBox.Text.IndexOf('*')))[i]);//}}if (order2TextBox.Text != "0"){order2uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order2TextBox.Text.Substring(0, order2TextBox.Text.IndexOf('*'))));}if (order3TextBox.Text != "0"){order3uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order3TextBox.Text.Substring(0, order3TextBox.Text.IndexOf('*'))));}if (order4TextBox.Text != "0"){order4uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order4TextBox.Text.Substring(0, order4TextBox.Text.IndexOf('*'))));}if (order5TextBox.Text != "0"){order5uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order5TextBox.Text.Substring(0, order5TextBox.Text.IndexOf('*'))));}if (order6TextBox.Text != "0"){order6uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order6TextBox.Text.Substring(0, order6TextBox.Text.IndexOf('*'))));}if (order7TextBox.Text != "0"){order7uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order7TextBox.Text.Substring(0, order7TextBox.Text.IndexOf('*'))));}if (order8TextBox.Text != "0"){order8uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order8TextBox.Text.Substring(0, order8TextBox.Text.IndexOf('*'))));}if (order9TextBox.Text != "0"){order9uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order9TextBox.Text.Substring(0, order9TextBox.Text.IndexOf('*'))));}if (order10TextBox.Text != "0"){order10uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order10TextBox.Text.Substring(0, order10TextBox.Text.IndexOf('*'))));}if (order11TextBox.Text != "0"){order11uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order11TextBox.Text.Substring(0, order11TextBox.Text.IndexOf('*'))));}if (order12TextBox.Text != "0"){order12uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order12TextBox.Text.Substring(0, order12TextBox.Text.IndexOf('*'))));}if (order13TextBox.Text != "0"){order13uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order13TextBox.Text.Substring(0, order13TextBox.Text.IndexOf('*'))));}}catch (Exception ex){log.SaveLog("配置表转换报错:" + ex.Message);}}

字符串转字节

        public static byte[] strToToHexByte(string hexString){hexString = hexString.Replace(" ", "");//去掉空格if ((hexString.Length % 2) != 0)hexString += " ";byte[] returnBytes = new byte[hexString.Length / 2];//字符串两个就是一个十六进制数for (int i = 0; i < returnBytes.Length; i++)returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);return returnBytes;}

根据第二个字节进行对应指令的查找

public static string judgeFun(byte[] a){string orderName = "0";if (a[2] == 1){orderName = "恢复出厂设置";}else if (a[2] == 2) {  orderName = "设置本机地址"; }else if (a[2] == 3) { orderName = "读取本机地址"; }else if (a[2] == 4) { orderName = "设置波特率"; }else if (a[2] == 5) { orderName = "复位"; }else if (a[2] == 6) { orderName = "切换通道"; }else if (a[2] == 7) { orderName = "读当前通道"; }else if (a[2] == 8) { orderName = "读版本"; }else if (a[2] == 9) { orderName = "设置CRC校验"; }else if (a[2] == 0xA) { orderName = "查询最大通道"; }else if (a[2] == 0xB) { orderName = "设置最大通道"; }else if (a[2] == 0xC) { orderName = "查正向补偿"; }else if (a[2] == 0xE) { orderName = "查反向补偿"; }else if (a[2] == 10) { orderName = "查通讯方式"; }else if (a[2] == 11) { orderName = "设置通讯方式";}else if (a[2] == 12) {orderName = "查电机最小速度";}else if (a[2] == 13) {orderName = "设置电机最小速度";}else if (a[2] == 14) {orderName = "查电机最大速度";}else if (a[2] == 15) {orderName = "设置电机最大速度";}else if (a[2] == 16) {orderName = "查丢步报错阈值";}else if (a[2] == 17) {orderName = "设置丢步报错阈值";}else if (a[2] == 80) {orderName = "常规报错";}else if (a[2] == 81) {orderName = "电机正向失步";}else if (a[2] == 82) {orderName = "电机反向失步";}else if (a[2] == 83) {orderName = "异常断电未归零";}else if (a[2] == 18) {orderName = "查磁场强度";}else if (a[2] == 19) {orderName = "磁编校准";}return orderName;}

确定按钮

 private void uiButton1_Click(object sender, EventArgs e){XmlDocument doc = new XmlDocument();if (type.Equals("add")){log.SaveLog(@"新增模板");DateTime dt = new DateTime();dt = System.DateTime.Now;//此处的大小写必须完全按照如下才能输出长日期长时间,时间为24小时制式,hh:mm:ss格式输出12小时制式时间string no = dt.ToString("yyyyMMddHHmmss");if (!File.Exists(path)){//新建一个xml文档//1、实例化一个XmlDocumentXmlDeclaration xnode = doc.CreateXmlDeclaration("1.0", "UTF-8", "");doc.AppendChild(xnode);XmlElement root = doc.CreateElement("person");doc.AppendChild(root);XmlElement newElement = doc.CreateElement("list");newElement.SetAttribute("no", no);//添加属性root.AppendChild(newElement);XmlElement modeName = doc.CreateElement("modeName");modeName.InnerText = tmodelName.Text;newElement.AppendChild(modeName);XmlElement client = doc.CreateElement("client");client.InnerText = clientTextBox.Text;newElement.AppendChild(client);XmlElement hardware = doc.CreateElement("hardware");hardware.InnerText = hardwareTextBox.Text;newElement.AppendChild(hardware);XmlElement software = doc.CreateElement("software");software.InnerText = softwareTextBox.Text;newElement.AppendChild(software);XmlElement tongshu = doc.CreateElement("tongshu");tongshu.InnerText = tongshuTextBox.Text;newElement.AppendChild(tongshu);XmlElement kongshu = doc.CreateElement("kongshu");kongshu.InnerText = kongshuTextBox.Text;newElement.AppendChild(kongshu);XmlElement TMC = doc.CreateElement("tmc");TMC.InnerText = tongshuTextBox.Text;newElement.AppendChild(TMC);XmlElement type = doc.CreateElement("type");type.InnerText = kongshuTextBox.Text;newElement.AppendChild(type);XmlElement order1 = doc.CreateElement("order1");order1.InnerText = order1TextBox.Text;newElement.AppendChild(order1);XmlElement order2 = doc.CreateElement("order2");order2.InnerText = order2TextBox.Text;newElement.AppendChild(order2);XmlElement order3 = doc.CreateElement("order3");order3.InnerText = order3TextBox.Text;newElement.AppendChild(order3);XmlElement order4 = doc.CreateElement("order4");order4.InnerText = order4TextBox.Text;newElement.AppendChild(order4);XmlElement order5 = doc.CreateElement("order5");order5.InnerText = order5TextBox.Text;newElement.AppendChild(order5);XmlElement order6= doc.CreateElement("order6");order6.InnerText = order6TextBox.Text;newElement.AppendChild(order6);XmlElement order7 = doc.CreateElement("order7");order7.InnerText = order7TextBox.Text;newElement.AppendChild(order7);XmlElement order8 = doc.CreateElement("order8");order8.InnerText = order8TextBox.Text;newElement.AppendChild(order8);XmlElement order9 = doc.CreateElement("order9");order9.InnerText = order9TextBox.Text;newElement.AppendChild(order9);XmlElement order10 = doc.CreateElement("order10");order10.InnerText = order10TextBox.Text;newElement.AppendChild(order10);XmlElement order11 = doc.CreateElement("order11");order11.InnerText = order11TextBox.Text;newElement.AppendChild(order11);XmlElement order12 = doc.CreateElement("order12");order12.InnerText = order12TextBox.Text;newElement.AppendChild(order12);XmlElement order13 = doc.CreateElement("order13");order13.InnerText = order13TextBox.Text;newElement.AppendChild(order13);root.AppendChild(newElement);doc.Save(path);//注意这个的save路径是需要加上 .xml的this.Close();Form1.modgrid.Show();}else{doc.Load(path);XmlElement root = doc.DocumentElement;XmlElement newElement = doc.CreateElement("list");newElement.SetAttribute("no", no);//添加属性root.AppendChild(newElement);XmlElement modeName = doc.CreateElement("modeName");modeName.InnerText = tmodelName.Text;newElement.AppendChild(modeName);XmlElement client = doc.CreateElement("client");client.InnerText = clientTextBox.Text;newElement.AppendChild(client);XmlElement hardware = doc.CreateElement("hardware");hardware.InnerText = hardwareTextBox.Text;newElement.AppendChild(hardware);XmlElement software = doc.CreateElement("software");software.InnerText = softwareTextBox.Text;newElement.AppendChild(software);XmlElement tongshu = doc.CreateElement("tongshu");tongshu.InnerText = tongshuTextBox.Text;newElement.AppendChild(tongshu);XmlElement kongshu = doc.CreateElement("kongshu");kongshu.InnerText = kongshuTextBox.Text;newElement.AppendChild(kongshu);XmlElement TMC = doc.CreateElement("tmc");TMC.InnerText = tongshuTextBox.Text;newElement.AppendChild(TMC);XmlElement type = doc.CreateElement("type");type.InnerText = kongshuTextBox.Text;newElement.AppendChild(type);XmlElement order1 = doc.CreateElement("order1");order1.InnerText = order1TextBox.Text;newElement.AppendChild(order1);XmlElement order2 = doc.CreateElement("order2");order2.InnerText = order2TextBox.Text;newElement.AppendChild(order2);XmlElement order3 = doc.CreateElement("order3");order3.InnerText = order3TextBox.Text;newElement.AppendChild(order3);XmlElement order4 = doc.CreateElement("order4");order4.InnerText = order4TextBox.Text;newElement.AppendChild(order4);XmlElement order5 = doc.CreateElement("order5");order5.InnerText = order5TextBox.Text;newElement.AppendChild(order5);XmlElement order6 = doc.CreateElement("order6");order6.InnerText = order6TextBox.Text;newElement.AppendChild(order6);XmlElement order7 = doc.CreateElement("order7");order7.InnerText = order7TextBox.Text;newElement.AppendChild(order7);XmlElement order8 = doc.CreateElement("order8");order8.InnerText = order8TextBox.Text;newElement.AppendChild(order8);XmlElement order9 = doc.CreateElement("order9");order9.InnerText = order9TextBox.Text;newElement.AppendChild(order9);XmlElement order10 = doc.CreateElement("order10");order10.InnerText = order10TextBox.Text;newElement.AppendChild(order10);XmlElement order11 = doc.CreateElement("order11");order11.InnerText = order11TextBox.Text;newElement.AppendChild(order11);XmlElement order12 = doc.CreateElement("order12");order12.InnerText = order12TextBox.Text;newElement.AppendChild(order12);XmlElement order13 = doc.CreateElement("order13");order13.InnerText = order13TextBox.Text;newElement.AppendChild(order13);root.AppendChild(newElement);this.Close();Form1.modgrid.Show();}}else if (type.Equals("edit")){log.SaveLog(@"编辑模板");doc.Load(path);XmlNodeList xmlNodeList = doc.SelectNodes("/person/list[@no='" + no + "']");xmlNodeList[0].SelectSingleNode("modeName").InnerText = tmodelName.Text;xmlNodeList[0].SelectSingleNode("client").InnerText = clientTextBox.Text;xmlNodeList[0].SelectSingleNode("hardware").InnerText = hardwareTextBox.Text;xmlNodeList[0].SelectSingleNode("software").InnerText = softwareTextBox.Text;xmlNodeList[0].SelectSingleNode("tongshu").InnerText = tongshuTextBox.Text;xmlNodeList[0].SelectSingleNode("kongshu").InnerText = kongshuTextBox.Text;xmlNodeList[0].SelectSingleNode("tmc").InnerText = TMCuiTextBox.Text;xmlNodeList[0].SelectSingleNode("type").InnerText = typeuiTextBox.Text;xmlNodeList[0].SelectSingleNode("order1").InnerText = order1TextBox.Text;xmlNodeList[0].SelectSingleNode("order2").InnerText = order2TextBox.Text;xmlNodeList[0].SelectSingleNode("order3").InnerText = order3TextBox.Text;xmlNodeList[0].SelectSingleNode("order4").InnerText = order4TextBox.Text;xmlNodeList[0].SelectSingleNode("order5").InnerText = order5TextBox.Text;xmlNodeList[0].SelectSingleNode("order6").InnerText = order6TextBox.Text;xmlNodeList[0].SelectSingleNode("order7").InnerText = order7TextBox.Text;xmlNodeList[0].SelectSingleNode("order8").InnerText = order8TextBox.Text;xmlNodeList[0].SelectSingleNode("order9").InnerText = order9TextBox.Text;xmlNodeList[0].SelectSingleNode("order10").InnerText = order10TextBox.Text;xmlNodeList[0].SelectSingleNode("order11").InnerText = order11TextBox.Text;xmlNodeList[0].SelectSingleNode("order12").InnerText = order12TextBox.Text;xmlNodeList[0].SelectSingleNode("order13").InnerText = order13TextBox.Text;}doc.Save(path);ModuleGrid.delUI();ModuleGrid.DisplayData();this.Close();Form1.modgrid.Show();}

返回

        private void uiButton2_Click(object sender, EventArgs e){this.Close();Form1.modgrid.Show();}

转换

 private void uiButton3_Click(object sender, EventArgs e){try{if (order1TextBox.Text!="0"){order1uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order1TextBox.Text.Substring(0, order1TextBox.Text.IndexOf('*'))));//log.SaveLog("指令转换1字符串:" + order1TextBox.Text.Substring(0, order1TextBox.Text.IndexOf('*')));//for (int i = 0; i < 5; i++)//{//    log.SaveLog("转字节{i}:" + Form1.strToToHexByte(order1TextBox.Text.Substring(0, order1TextBox.Text.IndexOf('*')))[i]);//}}if (order2TextBox.Text != "0"){order2uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order2TextBox.Text.Substring(0, order2TextBox.Text.IndexOf('*'))));}             if (order3TextBox.Text != "0"){order3uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order3TextBox.Text.Substring(0, order3TextBox.Text.IndexOf('*'))));}if (order4TextBox.Text != "0"){order4uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order4TextBox.Text.Substring(0, order4TextBox.Text.IndexOf('*'))));}if (order5TextBox.Text != "0"){order5uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order5TextBox.Text.Substring(0, order5TextBox.Text.IndexOf('*'))));}if (order6TextBox.Text != "0"){order6uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order6TextBox.Text.Substring(0, order6TextBox.Text.IndexOf('*'))));}if (order7TextBox.Text != "0"){order7uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order7TextBox.Text.Substring(0, order7TextBox.Text.IndexOf('*'))));}if (order8TextBox.Text != "0"){order8uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order8TextBox.Text.Substring(0, order8TextBox.Text.IndexOf('*'))));}if (order9TextBox.Text != "0"){order9uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order9TextBox.Text.Substring(0, order9TextBox.Text.IndexOf('*'))));}if (order10TextBox.Text != "0"){order10uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order10TextBox.Text.Substring(0, order10TextBox.Text.IndexOf('*'))));}if (order11TextBox.Text != "0"){order11uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order11TextBox.Text.Substring(0, order11TextBox.Text.IndexOf('*'))));}if (order12TextBox.Text != "0"){order12uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order12TextBox.Text.Substring(0, order12TextBox.Text.IndexOf('*'))));}if (order13TextBox.Text != "0"){order13uiLabel.Text = Form1.judgeFun(Form1.strToToHexByte(order13TextBox.Text.Substring(0, order13TextBox.Text.IndexOf('*'))));}}catch (Exception ex){log.SaveLog("配置表转换报错:" + ex.Message);}}

使用界面

在这里插入图片描述

读配置表

private void uiButton6_Click(object sender, EventArgs e){try{string str = uiComboBox1.Text.Trim();index = 0;if (str == String.Empty){MessageBox.Show("请先选择配置表");return;}else{//发送指令string no = "0";XmlDocument doc = new XmlDocument();doc.Load(AddModule.path);XmlNodeList nodeList = doc.SelectNodes("/person/list");//xPath相关手册,找节点person的list    foreach (XmlNode node1 in nodeList){string modeName = node1.SelectSingleNode("modeName").InnerText;if (modeName == uiComboBox1.Text){no = node1.Attributes["no"].Value;break;}else{continue;}}if (no == "0"){return;MessageBox.Show("未读取到配置表");}xmlNodeList = doc.SelectNodes("/person/list[@no='" + no + "']");node = xmlNodeList[0];label2.Text= "客户:"+node.SelectSingleNode("client").InnerText;label3.Text = "TMC/磁编:" + node.SelectSingleNode("tmc").InnerText;label4.Text = "型号:" + node.SelectSingleNode("type").InnerText;label5.Text = "通数:" + node.SelectSingleNode("tongshu").InnerText;uiButton4.Enabled = true;uiButton8.Enabled = true;tableFlag = true;}}catch (Exception ex){throw;}}

选择配置按钮点击

在这里插入图片描述
更新一下有哪些配置表

        private void uiComboBox1_ButtonClick(object sender, EventArgs e){ UpdateCfgTable();}
 public static string path = Directory.GetCurrentDirectory()+ "\\ParameterSet\\grid.xml";public void UpdateCfgTable(){XmlDocument doc = new XmlDocument();doc.Load(ModuleGrid.path);XmlNodeList nodeList = doc.SelectNodes("/person/list");//xPath相关手册,找节点person的listuiComboBox1.Items.Clear();foreach (XmlNode node in nodeList){string modeName = node.SelectSingleNode("modeName").InnerText;uiComboBox1.Items.Add(modeName);uiComboBox1.Text = modeName;}}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/161826.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Spring Cloud】网关Gateway的请求过滤工厂RequestRateLimiterGatewayFilterFactory

概念 关于微服务网关Gateway中有几十种过滤工厂&#xff0c;这一篇博文记录的是关于请求限流过滤工厂&#xff0c;也就是标题中的RequestRateLimiterGatewayFilterFactory。这个路由过滤工厂是用来判断当前请求是否应该被处理&#xff0c;如果不会被处理就会返回HTTP状态码为42…

linux部署gitlab

1. 配置yum源&#xff1a; vim /etc/yum.repos.d/gitlab-ce.repo [gitlab-ce] nameGitlab CE Repository baseurlhttps://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/ gpgcheck0 enabled1 2. 更新本地缓存 sudo yum install -y gitlab-ce 3. 安装相关依赖 yum …

从理论到实践,实时湖仓功能架构设计与落地实战

在上篇文章中&#xff0c;我们向大家解释了为什么实时湖仓是当前企业数字化转型过程中的解决之道&#xff0c;介绍了实时计算和数据湖结合的应用场景。&#xff08;“数据驱动”时代&#xff0c;企业为什么需要实时湖仓&#xff1f;&#xff09; 在这篇文章中&#xff0c;我们…

Java模拟双向链表,增删操作

public static void main(String[] args) {ArrayList arrayList new ArrayList();Node zhangsan new Node("张三");Node lisi new Node("李四");Node wanger new Node("王二");//模拟双向链表&#xff0c;将表中元素依次连接起来zhangsan.ne…

米哈游、复旦发布,具备感知、大脑、行动的大语言模型“智能体”

ChatGPT等大语言模型展示了前所未有的创造能力&#xff0c;但距AGI&#xff08;通用人工智能&#xff09;还有很大的距离&#xff0c;缺少自主决策、记忆存储、规划等拟人化能力。 为了探索大语言模型向AGI演变&#xff0c;进化成超越人类的超级人工智能&#xff0c;米哈游与复…

汽车上的A/C按键是做什么用的?

汽车上的A/C按键是做什么用的? 汽车上的a/c 键是空调制冷开关。A/C是空调的缩写&#xff0c;它的全称是air condition&#xff0c;理解为空气调节。它通过空调压缩机的不同运转方式来达到制冷或制暖的目的。 打开a/c 按键之后&#xff0c;因为空调压缩机是靠发动机工作的&…

Linux上Docker的安装以及作为非运维人员应当掌握哪些Docker命令

目录 前言 1、安装步骤 2、理解镜像和容器究竟是什么意思 2.1、为什么我们要知道什么是镜像&#xff0c;什么是容器&#xff1f; 2.2、什么是镜像&#xff1f; 2.3、什么是容器&#xff1f; 2.4、Docker在做什么&#xff1f; 2.5、什么是镜像仓库&#xff1f; 2、Dock…

求臻医学:实体肿瘤FDA/NMPA新获批抗癌药物/适应症盘点

肿瘤分子靶向治疗发展迅速&#xff0c;随着研究的深入开展&#xff0c;多款靶向药物及免疫药物获批。求臻医学根据美国食品药品监督管理局&#xff08;FDA&#xff09;公布信息、中国国家药品监督管理局&#xff08;NMPA&#xff09;发布的药品批准证明文件&#xff0c;以及各公…

尚硅谷Flink(二)DStream API

目录 &#x1f320;不会点 &#x1fa90;DataStream API ​编辑 &#x1f320; 执行环境 创建执行环境 执行模式 触发程序执行 &#x1f320;源算子 准备基础类型 从集合中读取数据 从文件读取数据 从 Socket 读取数据 从 Kafka 读取数据 &#xff08;没学过&#xff09; …

2.2 如何使用FlinkSQL读取写入到文件系统(HDFS\Local\Hive)

目录 1、文件系统 SQL 连接器 2、如何指定文件系统类型 3、如何指定文件格式 4、读取文件系统 4.1 开启 目录监控 4.2 可用的 Metadata 5、写出文件系统 5.1 创建分区表 5.2 滚动策略、文件合并、分区提交 5.3 指定 Sink Parallelism 6、示例_通过FlinkSQL读取kafk…

【Python从入门到进阶】39、使用Selenium自动验证滑块登录

接上篇《38、selenium关于Chrome handless的基本使用》 上一篇我们介绍了selenium中有关Chrome的无头版浏览器Chrome Handless的使用。本篇我们使用selenium做一些常见的复杂验证功能&#xff0c;首先我们来讲解如何进行滑块自动验证的操作。 一、测试用例介绍 我们要通过sel…

C# Winform编程(5)菜单和菜单组件

菜单和菜单组件 添加菜单编辑菜单 添加菜单 将MenuStrip控件拖拽到Form窗体顶部添加菜单 编辑菜单 添加菜单项&#xff0c;编辑菜单属性等功能。 右键单击已添加的菜单项可以弹出右键菜单&#xff1a; 可以设置菜单图标&#xff0c;使能菜单&#xff0c;显示快捷键、转换菜…

C语言初学者工具选择:vscode + MSYS2 + cmake 搭建 C环境

文章目录 前言1. MSYS2 安装1. 下载安装包2. 安装3. pacman 换清华大学源4. 安装 mingw-w64 toolchain 和 cmake ninja5. 将 toolchain 加入系统环境变量 2. 设置 vscode1. 必要的插件2. 一个简单的 vscode cmake 项目 最后C数据结构与算法CMake 前言 网上关于使用 vscode 配…

【计算机网络】网络原理

目录 1.网络的发展 2.协议 3.OSI七层网络模型 4.TCP/IP五层网络模型及作用 5.经典面试题 6.封装和分用 发送方(封装) 接收方(分用) 1.网络的发展 路由器&#xff1a;路由指的是最佳路径的选择。一般家用的是5个网口&#xff0c;1个WAN口4个LAN口(口&#xff1a;端口)。可…

如何修改运行中的docker容器的端口映射

一、必须先关闭docker服务 systemctl stop docker二、修改容器的hostconfig.json 文件 路径&#xff1a;vim /var/lib/docker/containers/容器id/hostconfig.json 修改 PortBindings 属性&#xff0c;如下图&#xff1a; 然后保存 三、修改config.v2.json 文件 路径&#…

[机缘参悟-110] :一个IT人对面具的理解:职业面具戴久了,就会忘记原本真实的自己,一个人是忠于职位,还是忠于内心?

目录 一、职业面具戴久了&#xff0c;就会忘记原本真实的自己 二、霸王别姬 三、没有对错&#xff0c;各走各路 3.1 程蝶衣&#xff1a;戏里戏外&#xff0c;忠于角色 3.2 段小楼&#xff1a;戏里戏外&#xff0c;角色分明 3.3 没有对错&#xff0c;各走各路 四、职场中…

Linux文件管理与用户管理

一、查看文件内容 1、回顾之前的命令 cat命令、tac命令、head命令、tail命令、扩展&#xff1a;tail -f动态查看一个文件的内容 2、more分屏显示文件内容&#xff08;了解&#xff09; 基本语法&#xff1a; # more 文件名称 特别注意&#xff1a;more命令在加载文件时并不…

本地安装telepresence,访问K8S集群 Mac(m1) 非管理員

kubeconfig 一&#xff0e;安装telepresence 1.安装 Telepresence Quickstart | Telepresence &#xff08;1&#xff09;brew install datawire/blackbird/telepresence 2.配置 目录kubectl 将使用默认的 kubeconfig 文件&#xff1a;$HOME/.kube/config 创建文件夹&…

分享一个比对图片是否一致的小工具(来源: github)

运行效果图: 官网: GitHub - codingfishman/image-diff: 一个方便的图片对比工具一个方便的图片对比工具. Contribute to codingfishman/image-diff development by creating an account on GitHub.https://github.com/codingfishman/image-diff 优缺点: 1.采用比对各色块是…

idea 里 没有svn选项的处理办法

总结一下没有svn选项的几种情况&#xff1a; 情况1&#xff1a;IntelliJ IDEA打开带SVN信息的项目不显示SVN信息&#xff0c;项目右键SVN以及图标还有Changes都不显示解决方法 在VCS菜单中有个开关&#xff0c;叫Enabled Version Control Integration&#xff0c;在打开的窗口…