📄 workflow.ctl
字号:
End Sub
Private Sub picCanvas_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i, j As Integer
Dim PointCount As Integer
Dim X1, X2, Y1, Y2 As Long
Dim MidPoint As POINTAPI
sb.Panels(1).Text = "X = " & X
sb.Panels(2).Text = "Y = " & Y
If mDrawFlag = True Then '画图形
If mMouseDownFlag = True Then
If mSelectFlag = 2 Then '画矩形
picCanvas.DrawMode = 2
picCanvas.DrawWidth = 1
picCanvas.DrawStyle = 1
X1 = mGoalPt.X - 300
X2 = mGoalPt.X + 300
Y1 = mGoalPt.Y - 400
Y2 = mGoalPt.Y + 400
picCanvas.Line (X2, Y2)-(X2, Y1)
picCanvas.Line (X2, Y2)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X2, Y1)
X1 = X - 300
X2 = X + 300
Y1 = Y - 400
Y2 = Y + 400
picCanvas.Line (X2, Y2)-(X2, Y1)
picCanvas.Line (X2, Y2)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X2, Y1)
ElseIf mSelectFlag = 1 Or mSelectFlag = 3 Or mSelectFlag = 4 Then '画线
picCanvas.MousePointer = 2
For i = 1 To mRectCount
j = mvarRect(i).LinkPointState(X, Y)
If j = 0 Then
Else
picCanvas.MousePointer = 11
Exit For
End If
Next i
picCanvas.DrawMode = 2
picCanvas.DrawWidth = 1
picCanvas.DrawStyle = 1
picCanvas.Line (mGoalPt.X, mGoalPt.Y)-(mSourcePt.X, mSourcePt.Y)
picCanvas.Line (X, Y)-(mSourcePt.X, mSourcePt.Y)
End If
mGoalPt.X = X
mGoalPt.Y = Y
Else '画图时段点捕捉
picCanvas.MousePointer = 2
For i = 1 To mRectCount
j = mvarRect(i).LinkPointState(X, Y)
If j = 0 Then
Else
picCanvas.MousePointer = 11
Exit For
End If
Next i
End If
ElseIf mMouseDownFlag = True Then
If mActiveFlag = True Then '移动激活的图形
If mActiveObject.ClsName = "LINE" Then
If mMoveLineInPointID > 0 Then
If mLastPointFlag = True Then
mMoveLineInPointID = mActiveObject.MidPointCount
End If
If mMoveLineInPointID = 1 Or mMoveLineInPointID = mActiveObject.MidPointCount Then
Else
mActiveObject.MoveLine 500, mMoveLineInPointID, X - mGoalPt.X, Y - mGoalPt.Y
End If
Else '选择整条线
'mActiveObject.MouseMove Button, Shift, X - mGoalPt.X, Y - mGoalPt.Y
End If
mGoalPt.X = X
mGoalPt.Y = Y
ElseIf mActiveObject.ClsName = "RECT" Then
picCanvas.DrawMode = 2
picCanvas.DrawWidth = 1
picCanvas.DrawStyle = 1
MidPoint.X = mGoalPt.X - mSourcePt.X + mActiveObject.EndPoint.X
MidPoint.Y = mGoalPt.Y - mSourcePt.Y + mActiveObject.EndPoint.Y
X1 = MidPoint.X - 300
X2 = MidPoint.X + 300
Y1 = MidPoint.Y - 400
Y2 = MidPoint.Y + 400
picCanvas.Line (X2, Y2)-(X2, Y1)
picCanvas.Line (X2, Y2)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X2, Y1)
mGoalPt.X = X
mGoalPt.Y = Y
MidPoint.X = mGoalPt.X - mSourcePt.X + mActiveObject.EndPoint.X
MidPoint.Y = mGoalPt.Y - mSourcePt.Y + mActiveObject.EndPoint.Y
X1 = MidPoint.X - 300
X2 = MidPoint.X + 300
Y1 = MidPoint.Y - 400
Y2 = MidPoint.Y + 400
picCanvas.Line (X2, Y2)-(X2, Y1)
picCanvas.Line (X2, Y2)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X2, Y1)
End If
End If
Else '选择要操作的图形
picCanvas.MousePointer = 0
mActiveFlag = False
Set mActiveObject = Nothing
Dim PrePoint, NextPoint As POINTAPI '定义前一点,定义后一点
For i = 1 To mLineCount
j = mvarLine(i).ExistState(X, Y)
PointCount = mvarLine(i).MidPointCount
If j = -1 Then
ElseIf j = 0 Then '选择整条线
picCanvas.MousePointer = 5
mActiveFlag = True
Set mActiveObject = mvarLine(i)
Exit Sub
ElseIf j = 1 Then '选择起点
picCanvas.MousePointer = 5
mActiveFlag = True
Set mActiveObject = mvarLine(i)
Exit Sub
ElseIf j = PointCount Then '选择终点
picCanvas.MousePointer = 5
mActiveFlag = True
Set mActiveObject = mvarLine(i)
Exit Sub
Else '选择中间点
PrePoint = mvarLine(i).ReturnPoint(j - 1)
NextPoint = mvarLine(i).ReturnPoint(j + 1)
If (j Mod 2) = 0 Then '选择线的中间点
If PrePoint.X = NextPoint.X Then
picCanvas.MousePointer = 9
mActiveFlag = True
Set mActiveObject = mvarLine(i)
Else
picCanvas.MousePointer = 7
mActiveFlag = True
Set mActiveObject = mvarLine(i)
End If
Exit Sub
Else '选择线的端点
picCanvas.MousePointer = 5
mActiveFlag = True
Set mActiveObject = mvarLine(i)
Exit Sub
End If
End If
Next i
For i = 1 To mRectCount
If mvarRect(i).ExistState(X, Y) Then
picCanvas.MousePointer = 5
mActiveFlag = True
Set mActiveObject = mvarRect(i)
UserControl.SetFocus
Exit For
End If
Next i
End If
End Sub
Private Sub picCanvas_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MidPoint As POINTAPI
Dim RectMidpoint As POINTAPI
Dim X1, X2, Y1, Y2 As Long
Dim i, j, k As Integer
'=============================
If mDrawFlag = False Then
mMouseDownFlag = False
If mActiveFlag = True Then
If mActiveObject.ClsName = "LINE" Then
picCanvas_Paint
mActiveObject.DrawPoint
ElseIf mActiveObject.ClsName = "RECT" Then
picCanvas.DrawMode = 2
picCanvas.DrawWidth = 1
picCanvas.DrawStyle = 1
MidPoint.X = mGoalPt.X - mSourcePt.X + mActiveObject.EndPoint.X
MidPoint.Y = mGoalPt.Y - mSourcePt.Y + mActiveObject.EndPoint.Y
X1 = MidPoint.X - 300
X2 = MidPoint.X + 300
Y1 = MidPoint.Y - 400
Y2 = MidPoint.Y + 400
picCanvas.Line (X2, Y2)-(X2, Y1)
picCanvas.Line (X2, Y2)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X2, Y1)
'移动关联线
RectMidpoint = mActiveObject.EndPoint
For i = 1 To mLineCount
If mvarLine(i).BeginPoint.X = RectMidpoint.X And mvarLine(i).BeginPoint.Y = (RectMidpoint.Y - 400) Then
'线的起点连接矩形的上中点
If mvarLine(i).MidPointCount = 3 Then
mvarLine(i).MoveLine 300, 1, X - mSourcePt.X, Y - mSourcePt.Y
Else
mvarLine(i).MoveLine 0, 1, X - mSourcePt.X, Y - mSourcePt.Y
End If
ElseIf mvarLine(i).BeginPoint.X = RectMidpoint.X And mvarLine(i).BeginPoint.Y = (RectMidpoint.Y + 400) Then
'线的起点连接矩形的下中点
If mvarLine(i).MidPointCount = 3 Then
mvarLine(i).MoveLine 300, 1, X - mSourcePt.X, Y - mSourcePt.Y
Else
mvarLine(i).MoveLine 0, 1, X - mSourcePt.X, Y - mSourcePt.Y
End If
ElseIf mvarLine(i).BeginPoint.Y = RectMidpoint.Y And mvarLine(i).BeginPoint.X = (RectMidpoint.X - 300) Then
'线的起点连接矩形的左中点
If mvarLine(i).MidPointCount = 3 Then
mvarLine(i).MoveLine 300, 1, X - mSourcePt.X, Y - mSourcePt.Y
Else
mvarLine(i).MoveLine 0, 1, X - mSourcePt.X, Y - mSourcePt.Y
End If
ElseIf mvarLine(i).BeginPoint.Y = RectMidpoint.Y And mvarLine(i).BeginPoint.X = (RectMidpoint.X + 300) Then
'线的起点连接矩形的右中点
If mvarLine(i).MidPointCount = 3 Then
mvarLine(i).MoveLine 300, 1, X - mSourcePt.X, Y - mSourcePt.Y
Else
mvarLine(i).MoveLine 0, 1, X - mSourcePt.X, Y - mSourcePt.Y
End If
ElseIf mvarLine(i).EndPoint.X = RectMidpoint.X And mvarLine(i).EndPoint.Y = (RectMidpoint.Y - 400) Then
'线的终点连接矩形的上中点
If mvarLine(i).MidPointCount = 3 Then
mvarLine(i).MoveLine 300, mvarLine(i).MidPointCount, X - mSourcePt.X, Y - mSourcePt.Y
Else
mvarLine(i).MoveLine 0, mvarLine(i).MidPointCount, X - mSourcePt.X, Y - mSourcePt.Y
End If
ElseIf mvarLine(i).EndPoint.X = RectMidpoint.X And mvarLine(i).EndPoint.Y = (RectMidpoint.Y + 400) Then
'线的终点连接矩形的下中点
If mvarLine(i).MidPointCount = 3 Then
mvarLine(i).MoveLine 300, mvarLine(i).MidPointCount, X - mSourcePt.X, Y - mSourcePt.Y
Else
mvarLine(i).MoveLine 0, mvarLine(i).MidPointCount, X - mSourcePt.X, Y - mSourcePt.Y
End If
ElseIf mvarLine(i).EndPoint.Y = RectMidpoint.Y And mvarLine(i).EndPoint.X = (RectMidpoint.X - 300) Then
'线的终点连接矩形的左中点
If mvarLine(i).MidPointCount = 3 Then
mvarLine(i).MoveLine 300, mvarLine(i).MidPointCount, X - mSourcePt.X, Y - mSourcePt.Y
Else
mvarLine(i).MoveLine 0, mvarLine(i).MidPointCount, X - mSourcePt.X, Y - mSourcePt.Y
End If
ElseIf mvarLine(i).EndPoint.Y = RectMidpoint.Y And mvarLine(i).EndPoint.X = (RectMidpoint.X + 300) Then
'线的终点连接矩形的右中点
If mvarLine(i).MidPointCount = 3 Then
mvarLine(i).MoveLine 300, mvarLine(i).MidPointCount, X - mSourcePt.X, Y - mSourcePt.Y
Else
mvarLine(i).MoveLine 0, mvarLine(i).MidPointCount, X - mSourcePt.X, Y - mSourcePt.Y
End If
End If
Next i
mActiveObject.MouseMove Button, Shift, CSng(MidPoint.X), CSng(MidPoint.Y)
picCanvas_Paint
End If
End If
Exit Sub
End If
If mMouseDownFlag = False Then Exit Sub
'============================
If mSelectFlag = 2 Then '完成节点的画图
picCanvas.DrawMode = 2
picCanvas.DrawWidth = 1
picCanvas.DrawStyle = 1
X1 = mGoalPt.X - 300
X2 = mGoalPt.X + 300
Y1 = mGoalPt.Y - 400
Y2 = mGoalPt.Y + 400
picCanvas.Line (X2, Y2)-(X2, Y1)
picCanvas.Line (X2, Y2)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X1, Y2)
picCanvas.Line (X1, Y1)-(X2, Y1)
mvarRect(mRectCount).MouseUp Button, Shift, X, Y
picCanvas_Paint
Else '完成连线的画图
picCanvas.DrawMode = 2
picCanvas.DrawWidth = 1
picCanvas.DrawStyle = 1
picCanvas.Line (mGoalPt.X, mGoalPt.Y)-(mSourcePt.X, mSourcePt.Y) 'clear line
k = 0
For i = 1 To mRectCount
j = mvarRect(i).LinkPointState(X, Y)
If j = 0 Then
ElseIf j = 1 Then '上中点
mGoalPt.X = mvarRect(i).EndPoint.X
mGoalPt.Y = mvarRect(i).EndPoint.Y - 400
k = i
Exit For
ElseIf j = 2 Then '下中点
mGoalPt.X = mvarRect(i).EndPoint.X
mGoalPt.Y = mvarRect(i).EndPoint.Y + 400
k = i
Exit For
ElseIf j = 3 Then '左中点
mGoalPt.X = mvarRect(i).EndPoint.X - 300
mGoalPt.Y = mvarRect(i).EndPoint.Y
k = i
Exit For
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -