|
@@ -1,12 +1,12 @@
|
|
|
Attribute VB_Name = "lines"
|
|
|
-'// 代码写到这里吧,视频结束
|
|
|
+'// This is free and unencumbered software released into the public domain.
|
|
|
+'// For more information, please refer to https://github.com/hongwenjun
|
|
|
+
|
|
|
Sub start()
|
|
|
LinesForm.Show 0
|
|
|
End Sub
|
|
|
|
|
|
Public Function Nodes_DrawLines()
|
|
|
- On Error GoTo ErrorHandler
|
|
|
- API.BeginOpt
|
|
|
Dim sr As ShapeRange, sr_tmp As New ShapeRange, sr_lines As New ShapeRange
|
|
|
Dim s As Shape, sh As Shape
|
|
|
Dim nr As NodeRange
|
|
@@ -28,9 +28,13 @@ Public Function Nodes_DrawLines()
|
|
|
Set Line = DrawLine(sr(1), sr(2))
|
|
|
sr_lines.Add Line
|
|
|
End If
|
|
|
-
|
|
|
- sr_tmp.Sort "@shape1.left < @shape2.left"
|
|
|
-
|
|
|
+
|
|
|
+#If VBA7 Then
|
|
|
+ sr_tmp.Sort "@shape1.left < @shape2.left"
|
|
|
+#Else
|
|
|
+ Set sr_tmp = X4_Sort_ShapeRange(sr_tmp, stlx)
|
|
|
+#End If
|
|
|
+
|
|
|
'// 使用 Count 遍历 shaperange 这种情况方便点
|
|
|
For i = 1 To sr_tmp.Count - 1
|
|
|
Set Line = DrawLine(sr_tmp(i), sr_tmp(i + 1))
|
|
@@ -39,19 +43,15 @@ Public Function Nodes_DrawLines()
|
|
|
|
|
|
sr_tmp.Delete
|
|
|
sr_lines.CreateSelection
|
|
|
-ErrorHandler:
|
|
|
- API.EndOpt
|
|
|
End Function
|
|
|
|
|
|
-
|
|
|
Public Function Draw_Multiple_Lines(hv As cdrAlignType)
|
|
|
- On Error GoTo ErrorHandler
|
|
|
- API.BeginOpt
|
|
|
Dim sr As ShapeRange, sr_lines As New ShapeRange
|
|
|
Set sr = ActiveSelectionRange
|
|
|
|
|
|
If sr.Count < 2 Then Exit Function
|
|
|
|
|
|
+#If VBA7 Then
|
|
|
If hv = cdrAlignVCenter Then
|
|
|
'// 从左到右排序
|
|
|
sr.Sort "@shape1.left < @shape2.left"
|
|
@@ -59,18 +59,24 @@ Public Function Draw_Multiple_Lines(hv As cdrAlignType)
|
|
|
'// 从上到下排序
|
|
|
sr.Sort "@shape1.top < @shape2.top"
|
|
|
End If
|
|
|
-
|
|
|
+#Else
|
|
|
+ '// X4_Sort_ShapeRange for CorelDRAW X4
|
|
|
+ If hv = cdrAlignVCenter Then
|
|
|
+ Set sr = X4_Sort_ShapeRange(sr, stlx)
|
|
|
+ ElseIf hv = cdrAlignHCenter Then
|
|
|
+ Set sr = X4_Sort_ShapeRange(sr, stty)
|
|
|
+ End If
|
|
|
+
|
|
|
+#End If
|
|
|
+
|
|
|
For i = 1 To sr.Count - 1 Step 2
|
|
|
Set Line = DrawLine(sr(i), sr(i + 1))
|
|
|
sr_lines.Add Line
|
|
|
Next
|
|
|
|
|
|
sr_lines.CreateSelection
|
|
|
-ErrorHandler:
|
|
|
- API.EndOpt
|
|
|
End Function
|
|
|
|
|
|
-
|
|
|
Public Function FirtLineTool()
|
|
|
Dim sr As ShapeRange
|
|
|
Set sr = ActiveSelectionRange
|
|
@@ -85,15 +91,9 @@ Private Function DrawLine(ByVal s1 As Shape, ByVal s2 As Shape) As Shape
|
|
|
|
|
|
End Function
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-Sub Test()
|
|
|
+Private Sub Test()
|
|
|
ActiveDocument.Unit = cdrMillimeter
|
|
|
-
|
|
|
- Set Rect = ActiveLayer.CreateRectangle(0, 0, 30, 30)
|
|
|
- Set ell = ActiveLayer.CreateEllipse2(50, 50, 10, 10)
|
|
|
-
|
|
|
- Set Line = DrawLine(Rect, ell)
|
|
|
-
|
|
|
+ Set Rect = ActiveLayer.CreateRectangle(0, 0, 30, 30)
|
|
|
+ Set ell = ActiveLayer.CreateEllipse2(50, 50, 10, 10)
|
|
|
+ Set Line = DrawLine(Rect, ell)
|
|
|
End Sub
|