Z字型流程图
需要画出如图的"z"字型流程图
分析得出:
奇数行的顺序为:由小到大.
偶数行的顺序为:由大到小
于是自己写了一个,顺便使用一个VML画箭头
void DataBind()![]() { List<TestChart> list = new List<TestChart>(); for (int i = 0; i <15; i++)![]() { TestChart tc = new TestChart![]() { StrImagePath = "image/user.jpg", StrDescription = "描述: " + (i + 1),// + string.Format(vmlLine, left), NodeSN = (i + 1) }; list.Add(tc); } MyData(list); } ![]() /**//// <summary> /// 画流程图 /// </summary> /// <param name="list"></param> void MyData(List<TestChart> list)![]() { string responseText = ""; string vmlLine = " <v:line strokeweight='3px' Style='LEFT:0px; POSITION:relative;' to='100,0' strokeColor='blue' fillcolor='blue'><v:stroke EndArrow='Classic' > </v:stroke></v:line>"; string vmlBrLine = "<v:line strokeweight='3px' Style='LEFT:10px;TOP:5PX POSITION:relative;' to='0,20' strokeColor='blue' fillcolor='blue'><v:stroke EndArrow='Classic'> </v:stroke></v:line>"; string reverseLine = " <v:line strokeweight='3px' Style='LEFT:0px; POSITION:relative;' to='100,0' strokeColor='blue' fillcolor='blue'><v:stroke StartArrow='Classic'> </v:stroke></v:line>"; //一行显示多少个 int middle = 4; int allCount = list.Count; int rowCount = 1; int iPageTotal = (allCount + middle - 1) / middle; string firefox = Request.UserAgent; if (firefox.Contains("Firefox"))![]() { vmlBrLine = "↓"; vmlLine = "---------→"; reverseLine = "←--------"; } StringBuilder table = new StringBuilder("<table>"); for (int i = 0; i < allCount; i++)![]() { if (rowCount % 2 != 0) //奇数行 顺行![]() { int oddNumber = (i + (middle)); int nowNumber = 0; if (oddNumber > allCount) oddNumber = allCount ; table.Append("<tr>"); //最后一行 if (i == (allCount - 1))![]() { table.Append("<td><font color='red'>" + list[i].NodeSN + "</font> " + "<img src='" + list[i].StrImagePath + "'/>" + list[i].StrDescription + "</td></tr>"); break; } for (int j = i; j < oddNumber; j++)![]() { if (j != (oddNumber -1))![]() { table.Append("<td><font color='red'>" + list[j].NodeSN + "</font> " + "<img src='" + list[j].StrImagePath + "'/>" + list[j].StrDescription + vmlLine+"</td>"); } else![]() { table.Append("<td><font color='red'>" + list[j].NodeSN + "</font> " + "<img src='" + list[j].StrImagePath + "'/>" + list[j].StrDescription+"</td>"); } nowNumber = j; } i = nowNumber; //最后一行不显示向下的箭头 if(rowCount!=iPageTotal) table.Append("</tr><tr><td colspan='" + middle + "' align='right' style='padding-right:30px'>" + vmlBrLine + "</td></tr>"); } if (rowCount % 2 == 0) //偶数行 逆行![]() { int even = (i + middle-1); int end = even - (middle); string test = ""; table.Append("<tr>"); for (int j = even; j > end; j--)![]() { if (j >= allCount)![]() { table.Append("<td> </td>"); responseText += ("" + test); } else![]() {![]() if ((j - 1) == (end))![]() { table.Append("<Td><font color='green'>" + list[j].NodeSN + "</font> " + "<img src='" + list[j].StrImagePath + "'/>" + list[j].StrDescription+"</td>"); } else![]() { table.Append ("<td><font color='green'>" + list[j].NodeSN + "</font> " + "<img src='" + list[j].StrImagePath + "'/>" + list[j].StrDescription + reverseLine+"</td>"); } } } i = even; if (rowCount<iPageTotal)![]() { table.Append("</tr><tr><td colspan='" + middle + "' align='left'>" + vmlBrLine + "</td></tr>"); } else table.Append("</tr>"); } if ((rowCount) == iPageTotal) break; rowCount++;![]() } table.Append("</table>"); testLine.InnerHtml = table.ToString(); } struct TestChart![]() { private string _strImagePath; private string _strDescription; private int _nodeSN;![]() /**//// <summary> /// 图片路径 /// </summary> public string StrImagePath![]() {![]() get { return _strImagePath; }![]() set { _strImagePath = value; } }![]() /**//// <summary> /// 描述 /// </summary> public string StrDescription![]() {![]() get { return _strDescription; }![]() set { _strDescription = value; } }![]() /**//// <summary> /// 序号 /// </summary> public int NodeSN![]() {![]() get { return _nodeSN; }![]() set { _nodeSN = value; } }![]() } |
|
结果如图:
|



List
}
}
浙公网安备 33010602011771号