Make_SIZE.frm 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. VERSION 5.00
  2. Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Make_SIZE
  3. Caption = "Make Size Simple"
  4. ClientHeight = 1515
  5. ClientLeft = 45
  6. ClientTop = 390
  7. ClientWidth = 3690
  8. OleObjectBlob = "Make_SIZE.frx":0000
  9. StartUpPosition = 1 'CenterOwner
  10. End
  11. Attribute VB_Name = "Make_SIZE"
  12. Attribute VB_GlobalNameSpace = False
  13. Attribute VB_Creatable = False
  14. Attribute VB_PredeclaredId = True
  15. Attribute VB_Exposed = False
  16. Private Sub UserForm_Initialize()
  17. With Tis
  18. .BackColor = RGB(0, 150, 255)
  19. .BorderColor = RGB(30, 150, 255)
  20. .ForeColor = RGB(255, 255, 255)
  21. End With
  22. LNG_CODE = API.GetLngCode
  23. Me.Caption = i18n("Make Size Simple", LNG_CODE)
  24. Init_Translations Me, LNG_CODE
  25. End Sub
  26. Private Function button_move_in(t)
  27. With t
  28. .BackColor = RGB(0, 150, 255)
  29. .BorderColor = RGB(30, 150, 255)
  30. .ForeColor = RGB(255, 255, 255)
  31. End With
  32. End Function
  33. Private Function command_button(t As Label)
  34. With t
  35. .BackColor = RGB(240, 240, 240)
  36. .BorderColor = RGB(100, 100, 100)
  37. .ForeColor = RGB(0, 0, 0)
  38. End With
  39. End Function
  40. Private Sub CheckBox1_Click()
  41. If CheckBox1 Then CheckBox4 = False
  42. End Sub
  43. Private Sub CheckBox2_Click()
  44. If CheckBox2 Then CheckBox4 = False
  45. End Sub
  46. Private Sub CheckBox3_Click()
  47. If CheckBox3 Then CheckBox1 = False: CheckBox2 = False: CheckBox4 = False
  48. End Sub
  49. Private Sub CheckBox4_Click()
  50. If CheckBox4 Then CheckBox1 = False: CheckBox2 = False: CheckBox3 = False
  51. End Sub
  52. Private Sub Frame1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  53. Call command_button(bt_MakeSize)
  54. Call command_button(bt_Del)
  55. End Sub
  56. Private Sub SpinButton1_SpinDown()
  57. Select_Font_Sub_Size
  58. End Sub
  59. Private Sub SpinButton1_SpinUp()
  60. Select_Font_Add_Size
  61. End Sub
  62. Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
  63. Select_Font_Size
  64. End Sub
  65. Private Sub bt_MakeSize_Click()
  66. If CheckBox1 Or CheckBox2 Then Call Dimension_width_and_height
  67. If CheckBox3 Then Call Mark_line_length
  68. If CheckBox4 Then Call Dimension_line_length
  69. End Sub
  70. Private Sub bt_MakeSize_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  71. Call button_move_in(bt_MakeSize)
  72. End Sub
  73. Private Sub bt_Del_Click()
  74. Delete_callout
  75. End Sub
  76. Private Sub bt_Del_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  77. Call button_move_in(bt_Del)
  78. End Sub
  79. Private Sub Dimension_width_and_height()
  80. ActiveDocument.Unit = cdrMillimeter
  81. Dim s As Shape, st1 As Shape, st2 As Shape
  82. Set s = ActiveShape
  83. If s Is Nothing Then Exit Sub
  84. Optimization = True '优化启动
  85. For Each s In ActiveSelection.Shapes
  86. If CheckBox1 Then
  87. Set st1 = ActiveLayer.CreateArtisticText(s.LeftX, s.TopY + 4, Round(s.SizeWidth, 0) & "mm", , , "微软雅黑", TextBox1.value, , , , cdrCenterAlignment)
  88. st1.text.Story.CharSpacing = 0 '字符间距
  89. st1.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  90. st1.Move s.SizeWidth / 2, 0
  91. st1.name = "Text" ' 设置名
  92. Set sox = ActiveLayer.CreateLineSegment(s.LeftX, s.TopY + 3, s.RightX, s.TopY + 3)
  93. sox.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  94. sox.name = "line"
  95. Set sox1 = ActiveLayer.CreateLineSegment(s.LeftX, s.TopY + 1, s.LeftX, s.TopY + 3)
  96. sox1.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  97. sox1.name = "line"
  98. Set sox2 = ActiveLayer.CreateLineSegment(s.RightX, s.TopY + 1, s.RightX, s.TopY + 3)
  99. sox2.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  100. sox2.name = "line"
  101. s.CreateSelection
  102. End If
  103. If CheckBox2 Then
  104. Set st2 = ActiveLayer.CreateArtisticText(s.LeftX - 4, s.BottomY, Round(s.SizeHeight, 0) & "mm", , , "微软雅黑", TextBox1.value, , , , cdrCenterAlignment)
  105. st2.text.Story.CharSpacing = 0 '字符间距
  106. st2.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  107. st2.Rotate 90
  108. st2.Move -st2.SizeWidth / 2, s.SizeHeight / 2
  109. st2.name = "Text" ' 设置名
  110. Set soy = ActiveLayer.CreateLineSegment(s.LeftX - 3, s.BottomY, s.LeftX - 3, s.TopY)
  111. soy.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  112. soy.name = "line"
  113. Set soy1 = ActiveLayer.CreateLineSegment(s.LeftX - 1, s.BottomY, s.LeftX - 3, s.BottomY)
  114. soy1.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  115. soy1.name = "line"
  116. Set soy2 = ActiveLayer.CreateLineSegment(s.LeftX - 1, s.TopY, s.LeftX - 3, s.TopY)
  117. soy2.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  118. soy2.name = "line"
  119. s.CreateSelection
  120. End If
  121. Next
  122. Optimization = False '优化关闭
  123. ActiveWindow.Refresh '刷新文档窗口
  124. End Sub
  125. Private Sub Dimension_line_length()
  126. ActiveDocument.Unit = cdrMillimeter
  127. Dim s As Shape, s1 As Shape, s2 As Shape, sc As Shape, st1 As Shape, st2 As Shape
  128. Set s = ActiveShape
  129. If s Is Nothing Then Exit Sub
  130. Optimization = True '优化启动
  131. For Each s In ActiveSelection.Shapes
  132. If s.Type <> cdrTextShape Then
  133. s.Copy
  134. Set sc = ActiveLayer.Paste
  135. sc.ConvertToCurves
  136. sc.Curve.Nodes.all.BreakApart
  137. sc.BreakApart
  138. For Each s1 In ActiveSelection.Shapes
  139. Set st1 = ActiveLayer.CreateArtisticText(0, 0, Round(s1.Curve.Length, 0), , , , TextBox1.value)
  140. st1.text.Story.CharSpacing = 0 '字符间距
  141. st1.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  142. st1.text.FitToPath s1
  143. ' 获取或设置文本与路径的偏移量
  144. st1.Effects(1).TextOnPath.Offset = s1.Curve.Length * 0.5 - st1.SizeWidth * 0.55
  145. ' 获取或设置文本与路径的距离
  146. st1.Effects(1).TextOnPath.DistanceFromPath = 1
  147. st1.name = "Text" ' 设置名
  148. s1.Outline.SetNoOutline
  149. s1.OrderToBack
  150. s1.name = "line"
  151. Next
  152. Set st2 = ActiveLayer.CreateArtisticText(s.RightX + 3, s.BottomY, "单位:mm", , , "微软雅黑", TextBox1.value)
  153. st2.text.Story.CharSpacing = 0 '字符间距
  154. st2.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  155. st2.name = "Text" ' 设置名
  156. End If
  157. Next
  158. Optimization = False '优化关闭
  159. ActiveWindow.Refresh '刷新文档窗口
  160. End Sub
  161. Private Sub Mark_line_length()
  162. ActiveDocument.Unit = cdrMillimeter
  163. Dim s As Shape, st1 As Shape
  164. Set s = ActiveShape
  165. If s Is Nothing Then Exit Sub
  166. Optimization = True '优化启动
  167. For Each s In ActiveSelection.Shapes
  168. If s.Type <> cdrTextShape Then
  169. X = s.LeftX
  170. Y = s.BottomY
  171. Set st1 = ActiveLayer.CreateArtisticText(X, Y, "线条长:" & Round(s.DisplayCurve.Length, 0) & "mm", , , "微软雅黑", TextBox1.value, , , , cdrLeftAlignment)
  172. st1.text.Story.CharSpacing = 0 '字符间距
  173. st1.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  174. st1.Move 0, -st1.SizeHeight * 2
  175. st1.name = "Text" ' 设置名
  176. s.CreateSelection
  177. End If
  178. Next
  179. Optimization = False '优化关闭
  180. ActiveWindow.Refresh '刷新文档窗口
  181. End Sub
  182. Private Sub Select_Font_Add_Size()
  183. Dim s As Shape
  184. Optimization = True '优化启动
  185. If TextBox1.value > 0 Then
  186. TextBox1.value = TextBox1.value + 1
  187. For Each s In ActiveSelection.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ")
  188. s.text.Story.size = s.text.Story.size + 1
  189. Next
  190. End If
  191. Optimization = False '优化关闭
  192. ActiveWindow.Refresh '刷新文档窗口
  193. End Sub
  194. Private Sub Select_Font_Sub_Size()
  195. Dim s As Shape
  196. Optimization = True '优化启动
  197. If TextBox1.value > 0 Then
  198. TextBox1.value = TextBox1.value - 1
  199. For Each s In ActiveSelection.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ")
  200. s.text.Story.size = s.text.Story.size - 1
  201. Next
  202. End If
  203. Optimization = False '优化关闭
  204. ActiveWindow.Refresh '刷新文档窗口
  205. End Sub
  206. Private Sub Select_Font_Size()
  207. Dim s As Shape
  208. Optimization = True '优化启动
  209. If TextBox1.value > 0 Then
  210. For Each s In ActiveSelection.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ")
  211. s.text.Story.size = TextBox1.value
  212. Next
  213. End If
  214. Optimization = False '优化关闭
  215. ActiveWindow.Refresh '刷新文档窗口
  216. End Sub
  217. Private Sub Delete_callout()
  218. If ActiveSelection.Shapes.Count > 0 Then
  219. ActiveSelection.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ").Delete
  220. ActiveSelection.Shapes.FindShapes(Query:="@Name='line' ").Delete
  221. Else
  222. ActivePage.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ").Delete
  223. ActivePage.Shapes.FindShapes(Query:="@Name='line' ").Delete
  224. End If
  225. End Sub