/// <summary> /// 将解耦控制块的结构体转换成列表 /// </summary> /// <param name="tempStuct">传入的结构体</param> /// <returns>返回转换后的列表</returns> public List <string> StructToList(JieOuStruct tempStuct) { List <string> tempList = new List <string>(); //解耦路数 tempList.Add(tempStuct.JieOuNum.ToString()); //解耦属性 List <string> tempAttribute = new List <string>(); foreach (List <string> element in tempStuct.JieOuAttribute) { tempAttribute.Add(String.Join(",", element.ToArray())); } tempList.Add(String.Join(";", tempAttribute.ToArray())); //解耦矩阵 List <string> Jtable = new List <string>(); for (int i = 0; i < tempStuct.JieOuNum; i++) { List <string> row = new List <string>(); for (int j = 0; j < tempStuct.JieOuNum; j++) { row.Add(tempStuct.JieOuTable[i, j]); } Jtable.Add(String.Join(",", row.ToArray())); } tempList.Add(String.Join(";", Jtable.ToArray())); return(tempList); }
/// <summary> /// 将解耦控制块的数据列表转换成结构体 /// </summary> /// <param name="tempList">传入的列表</param> /// <returns>返回转换后的结构体</returns> public JieOuStruct ListToStruct(List <string> tempList) { JieOuStruct tempStruct = new JieOuStruct(); //解耦路数 tempStruct.JieOuNum = Convert.ToInt32(tempList[0]); //解耦属性 List <List <string> > tempAttribute = new List <List <string> > (); foreach (string elementAttribute in tempList[1].Split(new char[] { ';' })) { List <string> tempRoad = new List <string>(); foreach (string element in elementAttribute.Split(new char[] { ',' })) { tempRoad.Add(element); } tempAttribute.Add(tempRoad); } tempStruct.JieOuAttribute = tempAttribute; //解耦矩阵 string[,] tempTable = new string[tempStruct.JieOuNum, tempStruct.JieOuNum]; string[] tempI = tempList[2].Split(new char[] { ';' }); for (int i = 0; i < tempStruct.JieOuNum; i++) { string[] tempJ = tempI[i].Split(new char[] { ',' }); for (int j = 0; j < tempStruct.JieOuNum; j++) { tempTable[i, j] = tempJ[j]; } } tempStruct.JieOuTable = tempTable; return(tempStruct); }
= new List <string>(new string[] { "1", "100000", "0", "50", "自动", "100", "0", "0" }); //存放新建解耦路数时的初值 /// <summary> /// 根绝传入的结构体初始化窗口的值 /// </summary> /// <param name="JStruct">传入的存放解耦控制块各值的结构体</param> public JieOuForm1(JieOuStruct JStruct) { InitializeComponent(); //结构体副本 newStruct = JStruct; //解耦路数 NumOfJieOu = JStruct.JieOuNum; LastText = JStruct.JieOuNum.ToString(); JieOuNum.Text = LastText; //解耦各路数据列表 JieOuBox = JStruct.JieOuAttribute; for (int i = 1; i <= NumOfJieOu; i++) { SelectValue.Items.Add("解耦第" + i + "路"); } SelectValue.Text = "解耦第1路"; //解耦矩阵 JieOuTable = JStruct.JieOuTable; createMatrixBox(NumOfJieOu, true); }
private int SaveNum = -1; //所保存的解耦路 #endregion Fields #region Constructors /// <summary> /// 根绝传入的结构体初始化窗口的值 /// </summary> /// <param name="JStruct">传入的存放解耦控制块各值的结构体</param> public JieOuForm1(JieOuStruct JStruct) { InitializeComponent(); //结构体副本 newStruct = JStruct; //解耦路数 NumOfJieOu = JStruct.JieOuNum; LastText = JStruct.JieOuNum.ToString(); JieOuNum.Text = LastText; //解耦各路数据列表 JieOuBox = JStruct.JieOuAttribute; for (int i = 1; i <= NumOfJieOu; i++) { SelectValue.Items.Add("解耦第" + i + "路"); } SelectValue.Text = "解耦第1路"; //解耦矩阵 JieOuTable = JStruct.JieOuTable; createMatrixBox(NumOfJieOu, true); }
/// <summary> /// 将解耦控制块的数据列表转换成结构体 /// </summary> /// <param name="tempList">传入的列表</param> /// <returns>返回转换后的结构体</returns> public JieOuStruct ListToStruct(List<string> tempList) { JieOuStruct tempStruct = new JieOuStruct(); //解耦路数 tempStruct.JieOuNum = Convert.ToInt32(tempList[0]); //解耦属性 List<List<string>> tempAttribute=new List<List<string>> (); foreach (string elementAttribute in tempList[1].Split(new char[] { ';' })) { List<string> tempRoad = new List<string>(); foreach (string element in elementAttribute.Split(new char[] { ',' })) { tempRoad.Add(element); } tempAttribute.Add(tempRoad); } tempStruct.JieOuAttribute = tempAttribute; //解耦矩阵 string[,] tempTable = new string[tempStruct.JieOuNum, tempStruct.JieOuNum]; string[] tempI = tempList[2].Split(new char[] { ';' }); for (int i = 0; i < tempStruct.JieOuNum; i++) { string[] tempJ = tempI[i].Split(new char[] { ',' }); for (int j = 0; j < tempStruct.JieOuNum; j++) { tempTable[i, j] = tempJ[j]; } } tempStruct.JieOuTable = tempTable; return tempStruct; }
/// <summary> /// 将解耦控制块的结构体转换成列表 /// </summary> /// <param name="tempStuct">传入的结构体</param> /// <returns>返回转换后的列表</returns> public List<string> StructToList(JieOuStruct tempStuct) { List<string> tempList = new List<string>(); //解耦路数 tempList.Add(tempStuct.JieOuNum.ToString()); //解耦属性 List<string> tempAttribute = new List<string>(); foreach (List<string> element in tempStuct.JieOuAttribute) { tempAttribute.Add(String.Join(",", element.ToArray())); } tempList.Add(String.Join(";",tempAttribute.ToArray())); //解耦矩阵 List<string> Jtable = new List<string>(); for (int i = 0; i < tempStuct.JieOuNum; i++) { List<string> row = new List<string>(); for (int j = 0; j < tempStuct.JieOuNum; j++) { row.Add(tempStuct.JieOuTable[i, j]); } Jtable.Add(String.Join(",", row.ToArray())); } tempList.Add(String.Join(";", Jtable.ToArray())); return tempList; }