📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim DaozhaGroup As vgctrl40.IGroup
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents Axvgctrl1 As Axvgctrl40.Axvgctrl
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button5 As System.Windows.Forms.Button
Friend WithEvents Button6 As System.Windows.Forms.Button
Friend WithEvents Button7 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Axvgctrl1 = New Axvgctrl40.Axvgctrl
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.Button4 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.Button5 = New System.Windows.Forms.Button
Me.Button6 = New System.Windows.Forms.Button
Me.Button7 = New System.Windows.Forms.Button
CType(Me.Axvgctrl1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Axvgctrl1
'
Me.Axvgctrl1.Enabled = True
Me.Axvgctrl1.Location = New System.Drawing.Point(16, 16)
Me.Axvgctrl1.Name = "Axvgctrl1"
Me.Axvgctrl1.OcxState = CType(resources.GetObject("Axvgctrl1.OcxState"), System.Windows.Forms.AxHost.State)
Me.Axvgctrl1.Size = New System.Drawing.Size(440, 464)
Me.Axvgctrl1.TabIndex = 0
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(464, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(160, 32)
Me.Button1.TabIndex = 1
Me.Button1.Text = "得到页面上图形总数"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(464, 56)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(160, 32)
Me.Button2.TabIndex = 2
Me.Button2.Text = "得到刀闸总数"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(464, 96)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(160, 32)
Me.Button3.TabIndex = 3
Me.Button3.Text = "循环遍历每一个图形"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(464, 136)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(160, 32)
Me.Button4.TabIndex = 4
Me.Button4.Text = "循环遍历每一个刀闸"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(464, 352)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(160, 128)
Me.Label1.TabIndex = 5
Me.Label1.Text = "在这个例子中,您可以看到图形是如何被遍历访问的,图形是如何分组的。通过对不同类型的图形进行分组,您便可以更清晰地建立对图形的管理。图形单元组是允许动态管理的,可以" & _
"添加、删除单元,可以同时建立多个单元组。"
'
'Button5
'
Me.Button5.Location = New System.Drawing.Point(464, 176)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(160, 32)
Me.Button5.TabIndex = 6
Me.Button5.Text = "建立红色箭头单元组"
'
'Button6
'
Me.Button6.Location = New System.Drawing.Point(464, 216)
Me.Button6.Name = "Button6"
Me.Button6.Size = New System.Drawing.Size(160, 32)
Me.Button6.TabIndex = 7
Me.Button6.Text = "清空红色箭头单元组"
'
'Button7
'
Me.Button7.Location = New System.Drawing.Point(464, 256)
Me.Button7.Name = "Button7"
Me.Button7.Size = New System.Drawing.Size(160, 32)
Me.Button7.TabIndex = 8
Me.Button7.Text = "删除红色箭头单元组"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(640, 493)
Me.Controls.Add(Me.Button7)
Me.Controls.Add(Me.Button6)
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Axvgctrl1)
Me.Name = "Form1"
Me.Text = "图形的管理"
CType(Me.Axvgctrl1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Axvgctrl1.Design("Test.tbl")
DaozhaGroup = Axvgctrl1.ActiveSheet.GroupByName("DaozhaGroup")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(Axvgctrl1.ActiveSheet.UnitCount.ToString(), MsgBoxStyle.Information)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox(DaozhaGroup.UnitCount.ToString(), MsgBoxStyle.Information)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim i As Integer
Dim d As vgctrl40.IUnit
For i = 1 To Axvgctrl1.ActiveSheet.UnitCount '遍历页面上所有的图形
d = Axvgctrl1.ActiveSheet.Units(i - 1) '取得指定序号的图形
Axvgctrl1.ActiveSheet.Selection.Clear() '清空选择组
Axvgctrl1.ActiveSheet.Selection.Add(d) '选中某个图形
MsgBox("第" + i.ToString() + "个图形,名叫: " + d.Name, MsgBoxStyle.Information)
Next i
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim i As Integer
Dim d As vgctrl40.IUnit
For i = 1 To DaozhaGroup.UnitCount
d = DaozhaGroup.Units(i - 1)
Axvgctrl1.ActiveSheet.Selection.Clear()
Axvgctrl1.ActiveSheet.Selection.Add(d)
MsgBox("第" + i.ToString() + "个图形,名叫: " + d.Name, MsgBoxStyle.Information)
Next i
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim d1, d2 As vgctrl40.ILine
Dim JiantouGroup As vgctrl40.IGroup
d1 = Axvgctrl1.ActiveSheet.UnitByName("折线3")
d2 = Axvgctrl1.ActiveSheet.UnitByName("折线4")
Axvgctrl1.ActiveSheet.Selection.Clear()
Axvgctrl1.ActiveSheet.Selection.Add(d1)
Axvgctrl1.ActiveSheet.Selection.Add(d2)
JiantouGroup = Axvgctrl1.ActiveSheet.AddGroup()
JiantouGroup.Name = "红色箭头单元组"
MsgBox("箭头单元组建立!里面有两个单元,文件保存时,这个单元组将被保存。")
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim d1, d2 As vgctrl40.ILine
Dim JiantouGroup As vgctrl40.IGroup
d1 = Axvgctrl1.ActiveSheet.UnitByName("折线3")
d2 = Axvgctrl1.ActiveSheet.UnitByName("折线4")
JiantouGroup = Axvgctrl1.ActiveSheet.GroupByName("红色箭头单元组")
If Not (JiantouGroup Is Nothing) Then
JiantouGroup.Remove(d1)
JiantouGroup.Remove(d2)
'不过清空单元组,用JiantouGroup.Clear()即可。
MsgBox("红色箭头单元组现在还有" + JiantouGroup.UnitCount.ToString() + "个图形")
Else
MsgBox("您还没有建立这个单元组")
End If
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim JiantouGroup As vgctrl40.IGroup
JiantouGroup = Axvgctrl1.ActiveSheet.GroupByName("红色箭头单元组")
If Not (JiantouGroup Is Nothing) Then
Axvgctrl1.ActiveSheet.DeleteGroup(JiantouGroup)
MsgBox("现在已经删除了红色箭头单元组,现在页面上有" + Axvgctrl1.ActiveSheet.GroupCount.ToString() + "个单元组")
Else
MsgBox("没有红色箭头单元组")
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -