public void ProccessString(String buffer) { receiveMessage = buffer; if (string.IsNullOrEmpty(receiveMessage)) { return; } try { string[] vals = receiveMessage.Split(new string[] { "##" }, StringSplitOptions.RemoveEmptyEntries); string taskmgrName = vals[0]; string taskName = vals[1]; TaskBean tb = this.GetTask(taskmgrName, taskName); tb.status = vals[2]; tb.userinfo = vals[3]; } catch (System.Exception ex) { return; } this.pnlCanvas.Invalidate(); }
public TaskBean GetTask(string mgrname, string taskname) { int mgrcount = taskMgrs.Count; bool isFind = false; TaskBean tb = null; for (int i = 0; i < mgrcount; i++) { TaskMgrBean tmb = (TaskMgrBean)taskMgrs[i]; if (tmb.name.Equals(mgrname)) { isFind = true; tb = new TaskBean(); tb.name = taskname; tb.status = tb.userinfo = ""; tmb.tasks.Add(tb); break; } } if (!isFind) { TaskMgrBean tmb = new TaskMgrBean(); tmb.name = mgrname; tmb.status = tmb.userinfo = ""; taskMgrs.Add(tmb); tb = new TaskBean(); tb.name = taskname; tb.status = tb.userinfo = ""; tmb.tasks.Add(tb); tmb.height = curHeight; } return(tb); }
public void DrawTask(Graphics grap) { grap.Clear(Color.White); float w = this.pnlCanvas.Width * 1.0f; float h = this.pnlCanvas.Height * 1.0f; int count = taskMgrs.Count; for (int i = 0; i < count; i++) { float x = cellWidth * i + 10; TaskMgrBean tmb = (TaskMgrBean)taskMgrs[i]; float tmby = tmb.height + 10; if (tmby + 5 >= offsetY && tmby - 5 < offsetY + h || curHeight < h) { if (x + cellWidth >= offsetX && x - cellWidth < offsetX + w || curWidth < w) { grap.DrawString(String.Format("{0} {1} {2}", tmb.name, tmb.status, tmb.userinfo), ftTaskMgr, brhTaskMgr, x - offsetX, tmby - offsetY); } } int taskcount = tmb.tasks.Count; for (int j = 0; j < taskcount; j++) { TaskBean tb = (TaskBean)tmb.tasks[j]; float y = 30 * j + 20 + 10 + tmb.height; if (y + 5 >= offsetY && y - 5 < offsetY + h || curHeight < h) { if (x + cellWidth >= offsetX && x - cellWidth < offsetX + w || curWidth < w) { grap.DrawString(String.Format("{0} {1} {2}", tb.name, tb.status, tb.userinfo), ftTask, brhTasks, x - offsetX, y - offsetY); if (tb.status.IndexOf("RUNNING") != -1) { grap.DrawLine(new Pen(new SolidBrush(Color.Blue)), x - offsetX, y + ftTask.Height / 2.0f - offsetY, x - offsetX, y + ftTask.Height / 2.0f + 15 - offsetY); } if (tb.status.IndexOf("FINISHED") != -1) { grap.DrawLine(new Pen(new SolidBrush(Color.Blue)), x - offsetX, y + ftTask.Height / 2.0f - offsetY, x - offsetX, y + ftTask.Height / 2.0f - 15 - offsetY); } } } if (j == taskcount - 1) { curHeight = 30 * j + 20 + tmb.height; } realH = curHeight + 10; } if (i == count - 1) { curWidth = cellWidth * i; realW = curWidth + 10; } } if (realH > h) { if (this.vsbPanel.Enabled == false) { this.vsbPanel.Enabled = true; } this.vsbPanel.Maximum = (int)(realH + 0.5f); } if (realW > w) { if (this.hsbPanel.Enabled == false) { this.hsbPanel.Enabled = true; } this.hsbPanel.Maximum = (int)(realW + 0.5f); } }