温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:简单WEB流程图组件Demo源码
当前文件:
WorkFlowChartDemo/WorkFlowChart_Source/WorkFlowChart/WorkFlowChart.cs[10K,2009-6-12 11:58:39],打开代码结构图
WorkFlowChartDemo/WorkFlowChart_Source/WorkFlowChart/WorkFlowChart.cs[10K,2009-6-12 11:58:39],打开代码结构图1namespace WorkFlowChart 2
{ 3
using System; 4
using System.Collections.Generic; 5
using System.Drawing; 6
using System.Xml; 7
8
public class WorkFlowChart 9
{ 10
private object _dataSource; 11
private Dictionary<string, AbstractNode> _dicNodes = new Dictionary<string, AbstractNode>(); 12
private Graphics _g; 13
private int _h = 30; 14
private int _w = 30; 15
private int _x = 0; 16
private int _y = 0; 17
18
private void DrawChart(XmlDocument xmlDoc, Graphics g, int x, int y, int w, int h) 19
{ 20
string CS$4$0001; 21
XmlNode root = xmlDoc.SelectSingleNode("root"); 22
XmlNode xnAttributes = root.SelectSingleNode("Attributes"); 23
XmlNode xnTaskNodes = root.SelectSingleNode("TaskNodes"); 24
XmlNode xnLines = root.SelectSingleNode("Lines"); 25
int TaskWidth = 120; 26
if (w != 0) 27
{ 28
TaskWidth = w; 29
} 30
else 31
{ 32
TaskWidth = Convert.ToInt32(xnAttributes.SelectSingleNode("Width").InnerText); 33
} 34
int TaskHeight = 60; 35
if (h != 0) 36
{ 37
TaskHeight = h; 38
} 39
else 40
{ 41
TaskHeight = Convert.ToInt32(xnAttributes.SelectSingleNode("Height").InnerText); 42
} 43
this.W = TaskWidth; 44
this.H = TaskHeight; 45
int TaskCount = 0; 46
if (xnTaskNodes != null) 47
{ 48
TaskCount = xnTaskNodes.ChildNodes.Count; 49
} 50
int LineCount = 0; 51
if (xnLines != null) 52
{ 53
LineCount = xnLines.ChildNodes.Count; 54
} 55
this.G = g; 56
g.FillRectangle(Brushes.White, new Rectangle(0, 0, 800, TaskCount * (TaskHeight + 110))); 57
if (TaskCount > 0) 58
{ 59
for (int i = 0; i < TaskCount; i++) 60
{ 61
XmlNode xmlNode = xnTaskNodes.ChildNodes[i]; 62
CS$4$0001 = xmlNode.SelectSingleNode("TaskType").InnerText.ToLower(); 63
if (CS$4$0001 != null) 64
{ 65
if (!(CS$4$0001 == "start")) 66
{ 67
if (CS$4$0001 == "end") 68
{ 69
goto Label_0192; 70
} 71
if (CS$4$0001 == "normal") 72
{ 73
goto Label_01A0; 74
} 75
if (CS$4$0001 == "mulapprove") 76
{ 77
goto Label_01B8; 78
} 79
} 80
else 81
{ 82
this.DrawStart(x, y, xmlNode); 83
y = (y + h) + 50; 84
} 85
} 86
goto Label_01D2; 87
Label_0192: 88
this.DrawEnd(x, y, xmlNode); 89
goto Label_01D2; 90
Label_01A0: 91
this.DrawNormal(x, y, xmlNode); 92
y = (y + h) + 50; 93
goto Label_01D2; 94
Label_01B8: 95
this.DrawMulApprove(x, y, xmlNode); 96
y = (y + h) + 70; 97
Label_01D2:; 98
} 99
} 100
NodeAttributes nodeattributes = new NodeAttributes(); 101
nodeattributes.Pen = new Pen(Color.Black); 102
if (LineCount > 0) 103
{ 104
for (int j = 0; j < LineCount; j++) 105
{ 106
XmlNode lineNode = xnLines.ChildNodes[j]; 107
string startCode = lineNode.SelectSingleNode("LineStart").InnerText; 108
string endCode = lineNode.SelectSingleNode("LineEnd").InnerText; 109
CS$4$0001 = lineNode.SelectSingleNode("LineType").InnerText.ToLower(); 110
if (CS$4$0001 != null) 111
{ 112
if (!(CS$4$0001 == "back")) 113
{ 114
if (CS$4$0001 == "break") 115
{ 116
goto Label_02BA; 117
} 118
} 119
else 120
{ 121
try 122
{ 123
nodeattributes.BackAdd(this._dicNodes[startCode], this._dicNodes[endCode]); 124
} 125
catch 126
{ 127
} 128
} 129
} 130
continue; 131
Label_02BA: 132
try 133
{ 134
nodeattributes.BreakAdd(this._dicNodes[startCode], this._dicNodes[endCode]); 135
} 136
catch 137
{ 138
} 139
} 140
nodeattributes.Draw(g); 141
} 142
} 143
144
private void DrawEnd(int x, int y, XmlNode xmlNode) 145
{ 146
string TaskCode = xmlNode.SelectSingleNode("TaskCode").InnerText; 147
NodeEnd nodes = new NodeEnd(); 148
nodes.X = (x + (this.W / 2)) - 15; 149
nodes.Y = (y + (this.H / 2)) - 30; 150
nodes.Draw(this.G); 151
if (!this._dicNodes.ContainsKey(TaskCode)) 152
{ 153
this._dicNodes.Add(TaskCode, nodes); 154
} 155
} 156
157
private void DrawMulApprove(int x, int y, XmlNode xmlNode) 158
{ 159
string TaskCode = xmlNode.SelectSingleNode("TaskCode").InnerText; 160
NodeContain nodes = new NodeContain(); 161
nodes.X = x; 162
nodes.Y = y; 163
nodes.W = this.W; 164
nodes.H = this.H; 165
nodes.BoderRange = 2; 166
XmlNodeList subList = xmlNode.SelectNodes("Task"); 167
if (subList.Count > 0) 168
{ 169
for (int i = 0; i < subList.Count; i++) 170
{ 171
XmlNode xmlNodeSub = subList[i]; 172
int titleCount = xmlNodeSub.SelectSingleNode("Title").ChildNodes.Count; 173
string taskStatus = xmlNodeSub.SelectSingleNode("TaskStatus").InnerText; 174
string[] arrText = new string[titleCount]; 175
for (int j = 0; j < titleCount; j++) 176
{ 177
arrText[j] = xmlNodeSub.SelectSingleNode("Title").ChildNodes[j].InnerText; 178
} 179
NodeLeaf node = new NodeLeaf(); 180
node.X = x; 181
node.Y = y; 182
node.W = this.W; 183
node.H = this.H; 184
node.BoderRange = 2; 185
node.TaskStatus = taskStatus; 186
node.ArrText = arrText; 187
nodes.Add(node); 188
} 189
} 190
nodes.Draw(this.G); 191
if (!this._dicNodes.ContainsKey(TaskCode)) 192
{ 193
this._dicNodes.Add(TaskCode, nodes); 194
} 195
} 196
197
private void DrawNormal(int x, int y, XmlNode xmlNode) 198
{ 199
string TaskCode = xmlNode.SelectSingleNode("TaskCode").InnerText; 200
int titleCount = xmlNode.SelectSingleNode("Title").ChildNodes.Count; 201
string[] arrText = new string[titleCount]; 202
for (int i = 0; i < titleCount; i++) 203
{ 204
arrText[i] = xmlNode.SelectSingleNode("Title").ChildNodes[i].InnerText; 205
} 206
string taskStatus = xmlNode.SelectSingleNode("TaskStatus").InnerText; 207
NodeLeaf nodes = new NodeLeaf(); 208
nodes.X = x; 209
nodes.Y = y; 210
nodes.W = this.W; 211
nodes.H = this.H; 212
nodes.BoderRange = 2; 213
nodes.TaskStatus = taskStatus; 214
nodes.ArrText = arrText; 215
nodes.Draw(this.G); 216
if (!this._dicNodes.ContainsKey(TaskCode)) 217
{ 218
this._dicNodes.Add(TaskCode, nodes); 219
} 220
} 221
222
private void DrawStart(int x, int y, XmlNode xmlNode) 223
{ 224
string TaskCode = xmlNode.SelectSingleNode("TaskCode").InnerText; 225
NodeStart nodes = new NodeStart(); 226
nodes.X = (x + (this.W / 2)) - 15; 227
nodes.Y = y + (this.H / 2); 228
nodes.Draw(this.G); 229
if (!this._dicNodes.ContainsKey(TaskCode)) 230
{ 231
this._dicNodes.Add(TaskCode, nodes); 232
} 233
} 234
235
public void DrawXmlPath(string xmlPath, Graphics g, int x, int y, int w, int h) 236
{ 237
XmlDocument xmlDoc = new XmlDocument(); 238
xmlDoc.Load(xmlPath); 239
this.DrawChart(xmlDoc, g, x, y, w, h); 240
} 241
242
public void DrawXmlString(string xmlString, Graphics g, int x, int y, int w, int h) 243
{ 244
XmlDocument xmlDoc = new XmlDocument(); 245
xmlDoc.LoadXml(xmlString); 246
this.DrawChart(xmlDoc, g, x, y, w, h); 247
} 248
249
public object DataSource 250
{ 251
get 252
{ 253
return this._dataSource; 254
} 255
set 256
{ 257
this._dataSource = value; 258
} 259
} 260
261
public Graphics G 262
{ 263
get 264
{ 265
return this._g; 266
} 267
set 268
{ 269
this._g = value; 270
} 271
} 272
273
public int H 274
{ 275
get 276
{ 277
return this._h; 278
} 279
set 280
{ 281
this._h = value; 282
} 283
} 284
285
public int W 286
{ 287
get 288
{ 289
return this._w; 290
} 291
set 292
{ 293
this._w = value; 294
} 295
} 296
297
public int X 298
{ 299
get 300
{ 301
return this._x; 302
} 303
set 304
{ 305
this._x = value; 306
} 307
} 308
309
public int Y 310
{ 311
get 312
{ 313
return this._y; 314
} 315
set 316
{ 317
this._y = value; 318
} 319
} 320
} 321
} 322
323






}
}