private void panelWorkFlow_MouseMove(object sender, MouseEventArgs e) { if (isReadOnly) { return; } if (mouseDownCursor.X == e.X && mouseDownCursor.Y == e.Y) { return; } if (this.panelWorkFlow.Capture) { if (selectedObj is WorkTache) { //画线 if (tempLine != null) { int x = selectedObj.Left + selectedObj.Width / 2; int y = selectedObj.Top + selectedObj.Height / 2; tempLine.SetPoint(x, y, e.X, e.Y); } //移动环节 else { if (TestHit(selectedObj, e.X, e.Y)) { return; } if (selectedObj is WorkTache) { SetPositon(selectedObj, e.X, e.Y); //移动环节 //移动环节关联的线 WorkTache wt = selectedObj as WorkTache; if (wt.FlowLine1 != null) { wt.FlowLine1.SetPoint(); } if (wt.FlowLine2 != null) { wt.FlowLine2.SetPoint(); } } } } } mouseDownCursor.X = e.X; mouseDownCursor.Y = e.Y; }
/// <summary> /// 选中环节中点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void wt_RadioMouseDown(object sender, MouseEventArgs e) { if (isReadOnly) { return; } if (sender is WorkTache) { WorkTache w = sender as WorkTache; selectedObj = w; w.Selected = true; tempLine = new FlowLine(); tempLine.SetPoint(w.Left + w.Width / 2, w.Top + w.Height / 2, w.Left + w.Width / 2 + 1, w.Top + w.Height / 2 + 1); this.panelWorkFlow.Controls.Add(tempLine); Refresh(); this.panelWorkFlow.Capture = true; } }
/// <summary> /// 将线关联到环节 /// </summary> /// <param name="endTache"></param> private FlowLine ConnectionLineToTache(WorkTache startTache, WorkTache endTache, string currentTacheId = "") { if (startTache == null || endTache == null) { return(null); } if (!(startTache is WorkTache)) { return(null); } if (startTache.TacheType == WorkTacheType.End) { this.ShowWarning("结束环节不能够作为流程起点!"); return(null); } else if (startTache.FlowLine2 != null) { this.ShowWarning("该环节已经流出!"); return(null); } if (endTache.TacheType == WorkTacheType.Begin) { this.ShowWarning("开始环节不能作为流程终点!"); return(null); } else if (endTache.FlowLine1 != null) { this.ShowWarning("该环节已经流入!"); return(null); } if (startTache.IsRelatedTo(endTache)) { //this.ShowWarning("环节已经存在关联,请重新选择环节!"); return(null); } if (IsClosedLoop(startTache, endTache)) { this.ShowWarning("流程不能形成闭环!"); return(null); } FlowLine line = new FlowLine(); line.KeyDown += new KeyEventHandler(control_KeyDown); line.MouseClick += new MouseEventHandler(flowLine_MouseClick); line.SetPoint(startTache, endTache); if (startTache.TacheInfo.IsNextLineDashed) { //未达到的环节虚线、灰色图标表示 line.LineStyle = DashStyle.Dash; endTache.TacheType = WorkTacheType.Gray; if (startTache.TacheInfo.Id == currentTacheId) { startTache.TacheType = WorkTacheType.Current; } } //设置环节关联的线 startTache.FlowLine2 = line; endTache.FlowLine1 = line; this.panelWorkFlow.Controls.Add(line); return(line); }