📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#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 Axvgctrl2 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 GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton
Friend WithEvents Axvgctrl3 As Axvgctrl40.Axvgctrl
Friend WithEvents ListView1 As System.Windows.Forms.ListView
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Axvgctrl1 = New Axvgctrl40.Axvgctrl
Me.Axvgctrl2 = 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.GroupBox1 = New System.Windows.Forms.GroupBox
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.Label1 = New System.Windows.Forms.Label
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.RadioButton4 = New System.Windows.Forms.RadioButton
Me.RadioButton3 = New System.Windows.Forms.RadioButton
Me.Axvgctrl3 = New Axvgctrl40.Axvgctrl
Me.ListView1 = New System.Windows.Forms.ListView
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
CType(Me.Axvgctrl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.Axvgctrl2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.GroupBox1.SuspendLayout()
Me.GroupBox2.SuspendLayout()
CType(Me.Axvgctrl3, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Axvgctrl1
'
Me.Axvgctrl1.Enabled = True
Me.Axvgctrl1.Location = New System.Drawing.Point(224, 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(344, 352)
Me.Axvgctrl1.TabIndex = 0
'
'Axvgctrl2
'
Me.Axvgctrl2.Enabled = True
Me.Axvgctrl2.Location = New System.Drawing.Point(256, 112)
Me.Axvgctrl2.Name = "Axvgctrl2"
Me.Axvgctrl2.OcxState = CType(resources.GetObject("Axvgctrl2.OcxState"), System.Windows.Forms.AxHost.State)
Me.Axvgctrl2.Size = New System.Drawing.Size(192, 192)
Me.Axvgctrl2.TabIndex = 1
Me.Axvgctrl2.Visible = False
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(16, 16)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(200, 32)
Me.Button1.TabIndex = 2
Me.Button1.Text = "新建一个刀闸,在页面上拉框"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(16, 56)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(200, 32)
Me.Button2.TabIndex = 3
Me.Button2.Text = "新建一个刀闸,拖动到页面"
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(16, 96)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(200, 32)
Me.Button3.TabIndex = 4
Me.Button3.Text = "新建一个变压器,拖动到页面"
'
'Button4
'
Me.Button4.Location = New System.Drawing.Point(16, 136)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(200, 32)
Me.Button4.TabIndex = 5
Me.Button4.Text = "用程序生成一个变压器"
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.RadioButton2)
Me.GroupBox1.Controls.Add(Me.RadioButton1)
Me.GroupBox1.Location = New System.Drawing.Point(16, 184)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(200, 80)
Me.GroupBox1.TabIndex = 6
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "嵌入还是链接"
'
'RadioButton2
'
Me.RadioButton2.Location = New System.Drawing.Point(8, 48)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.Size = New System.Drawing.Size(176, 24)
Me.RadioButton2.TabIndex = 1
Me.RadioButton2.Text = "链接方式,不能没有图库"
'
'RadioButton1
'
Me.RadioButton1.Checked = True
Me.RadioButton1.Location = New System.Drawing.Point(8, 24)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(184, 24)
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.TabStop = True
Me.RadioButton1.Text = "嵌入方式,图形可以脱离图库"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 352)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(192, 40)
Me.Label1.TabIndex = 7
Me.Label1.Text = "选中页面上上的图形,可以看到嵌入和链接的不同表现形式,链接的图形用深绿色框选中"
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.RadioButton4)
Me.GroupBox2.Controls.Add(Me.RadioButton3)
Me.GroupBox2.Location = New System.Drawing.Point(16, 272)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(200, 72)
Me.GroupBox2.TabIndex = 8
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "方便的多图库切换"
'
'RadioButton4
'
Me.RadioButton4.Location = New System.Drawing.Point(8, 40)
Me.RadioButton4.Name = "RadioButton4"
Me.RadioButton4.Size = New System.Drawing.Size(176, 24)
Me.RadioButton4.TabIndex = 1
Me.RadioButton4.Text = "使用第二个图库"
'
'RadioButton3
'
Me.RadioButton3.Checked = True
Me.RadioButton3.Location = New System.Drawing.Point(8, 16)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.Size = New System.Drawing.Size(176, 24)
Me.RadioButton3.TabIndex = 0
Me.RadioButton3.TabStop = True
Me.RadioButton3.Text = "使用第一个图库"
'
'Axvgctrl3
'
Me.Axvgctrl3.Enabled = True
Me.Axvgctrl3.Location = New System.Drawing.Point(344, 88)
Me.Axvgctrl3.Name = "Axvgctrl3"
Me.Axvgctrl3.OcxState = CType(resources.GetObject("Axvgctrl3.OcxState"), System.Windows.Forms.AxHost.State)
Me.Axvgctrl3.Size = New System.Drawing.Size(192, 192)
Me.Axvgctrl3.TabIndex = 9
Me.Axvgctrl3.Visible = False
'
'ListView1
'
Me.ListView1.LargeImageList = Me.ImageList1
Me.ListView1.Location = New System.Drawing.Point(224, 376)
Me.ListView1.Name = "ListView1"
Me.ListView1.Scrollable = False
Me.ListView1.Size = New System.Drawing.Size(344, 64)
Me.ListView1.TabIndex = 10
'
'ImageList1
'
Me.ImageList1.ImageSize = New System.Drawing.Size(64, 64)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(584, 453)
Me.Controls.Add(Me.ListView1)
Me.Controls.Add(Me.Axvgctrl3)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Axvgctrl2)
Me.Controls.Add(Me.Axvgctrl1)
Me.Name = "Form1"
Me.Text = "使用图库"
CType(Me.Axvgctrl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.Axvgctrl2, System.ComponentModel.ISupportInitialize).EndInit()
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox2.ResumeLayout(False)
CType(Me.Axvgctrl3, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub FillLib(ByVal vgctrl As Axvgctrl40.Axvgctrl)
Dim Sheet As vgctrl40.ISheet
Dim Image As System.Drawing.Bitmap
Dim ListItem As ListViewItem
Dim g As System.Drawing.Graphics
Dim hdc As System.IntPtr
Dim i As Integer
ListView1.Clear()
ImageList1.Images.Clear()
For i = 0 To vgctrl.SheetCount - 1
Sheet = vgctrl.get_Sheets(i)
ListItem = ListView1.Items.Add(Sheet.Name)
ListItem.ImageIndex = i
Image = New System.Drawing.Bitmap(64, 64)
g = System.Drawing.Graphics.FromImage(Image)
hdc = New IntPtr
hdc = g.GetHdc()
Sheet.PaintIn(hdc.ToInt32(), 64, 64)
g.ReleaseHdc(hdc)
g.Dispose()
ImageList1.Images.Add(Image)
Next i
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Axvgctrl1.Design("")
Axvgctrl2.Run("Test1.tbl")
Axvgctrl3.Run("Test2.tbl")
Axvgctrl2.Library = True
Axvgctrl1.Execute("SystemParams.GraphDriver=1") '使用Gdi+图形驱动
FillLib(Axvgctrl2)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Axvgctrl1.NewUnit("刀闸", 0)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Axvgctrl1.NewUnit("刀闸", 1)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Axvgctrl1.NewUnit("变压器", 1)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim d As vgctrl40.IElliment
d = Axvgctrl1.ActiveSheet.AddUnit("变压器", 0, 0, 0, 0) '宽度和高度为零表示默认的宽度和高度
Axvgctrl1.ActiveSheet.Selection.Clear()
Axvgctrl1.ActiveSheet.Selection.Add(d)
End Sub
Private Sub RadioButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton1.Click
Axvgctrl1.Execute("SystemParams.EllimentEmbed = true") '设置系统参数
End Sub
Private Sub RadioButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton2.Click
Axvgctrl1.Execute("SystemParams.EllimentEmbed = false") '设置系统参数
End Sub
Private Sub RadioButton4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton4.Click
FillLib(Axvgctrl3)
Axvgctrl3.Library = True
End Sub
Private Sub RadioButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton3.Click
FillLib(Axvgctrl2)
Axvgctrl2.Library = True
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -