📄 sampleform.vb
字号:
Me.TabbedGroups2.Size = New System.Drawing.Size(440, 341)
Me.TabbedGroups2.TabIndex = 0
'
'TabPage3
'
Me.TabPage3.Controls.AddRange(New System.Windows.Forms.Control() {Me.TabbedGroups3})
Me.TabPage3.ImageIndex = 2
Me.TabPage3.Name = "TabPage3"
Me.TabPage3.Selected = False
Me.TabPage3.Size = New System.Drawing.Size(440, 341)
Me.TabPage3.TabIndex = 2
Me.TabPage3.Title = "Group3"
'
'TabbedGroups3
'
Me.TabbedGroups3.ActiveLeaf = Nothing
Me.TabbedGroups3.AllowDrop = True
Me.TabbedGroups3.AtLeastOneLeaf = True
Me.TabbedGroups3.Dock = System.Windows.Forms.DockStyle.Fill
Me.TabbedGroups3.ImageList = Me.groupTabs
Me.TabbedGroups3.Name = "TabbedGroups3"
Me.TabbedGroups3.ProminentLeaf = Nothing
Me.TabbedGroups3.ResizeBarColor = System.Drawing.SystemColors.Control
Me.TabbedGroups3.Size = New System.Drawing.Size(440, 341)
Me.TabbedGroups3.TabIndex = 0
'
'StatusBar1
'
Me.StatusBar1.Location = New System.Drawing.Point(0, 391)
Me.StatusBar1.Name = "StatusBar1"
Me.StatusBar1.Size = New System.Drawing.Size(440, 22)
Me.StatusBar1.TabIndex = 2
Me.StatusBar1.Text = "StatusBar1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(440, 413)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TabControl1, Me.MenuControl1, Me.StatusBar1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.TabPage1.ResumeLayout(False)
CType(Me.TabbedGroups1, System.ComponentModel.ISupportInitialize).EndInit()
Me.TabPage2.ResumeLayout(False)
CType(Me.TabbedGroups2, System.ComponentModel.ISupportInitialize).EndInit()
Me.TabPage3.ResumeLayout(False)
CType(Me.TabbedGroups3, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Protected Sub OnPages(ByVal pages As MenuCommand)
Dim tc As Crownwood.Magic.Controls.TabControl
' Find the active tab control in the selected group
If (TabControl1.SelectedIndex = 0) Then
If Not (TabbedGroups1.ActiveLeaf Is Nothing) Then
tc = CType(TabbedGroups1.ActiveLeaf.GroupControl, Crownwood.Magic.Controls.TabControl)
End If
Else
If (TabControl1.SelectedIndex = 1) Then
If Not (TabbedGroups2.ActiveLeaf Is Nothing) Then
tc = CType(TabbedGroups2.ActiveLeaf.GroupControl, Crownwood.Magic.Controls.TabControl)
End If
Else
If Not (TabbedGroups3.ActiveLeaf Is Nothing) Then
tc = CType(TabbedGroups3.ActiveLeaf.GroupControl, Crownwood.Magic.Controls.TabControl)
End If
End If
End If
' Did we find a current tab control?
If (Not (tc Is Nothing) And Not (tc.SelectedTab Is Nothing)) Then
pages.MenuCommands(1).Enabled = True
Else
pages.MenuCommands(1).Enabled = False
End If
End Sub
Protected Sub OnAddPage(ByVal sender As Object, ByVal e As EventArgs)
If (TabControl1.SelectedIndex = 0) Then
If Not (TabbedGroups1.ActiveLeaf Is Nothing) Then
TabbedGroups1.ActiveLeaf.TabPages.Add(NewTabPage())
End If
Else
If (TabControl1.SelectedIndex = 1) Then
If Not (TabbedGroups2.ActiveLeaf Is Nothing) Then
TabbedGroups2.ActiveLeaf.TabPages.Add(NewTabPage())
End If
Else
If Not (TabbedGroups3.ActiveLeaf Is Nothing) Then
TabbedGroups3.ActiveLeaf.TabPages.Add(NewTabPage())
End If
End If
End If
End Sub
Protected Sub OnRemovePage(ByVal sender As Object, ByVal e As EventArgs)
Dim tc As Crownwood.Magic.Controls.TabControl
' Find the active tab control in the selected group
If (TabControl1.SelectedIndex = 0) Then
If Not (TabbedGroups1.ActiveLeaf Is Nothing) Then
tc = CType(TabbedGroups1.ActiveLeaf.GroupControl, Crownwood.Magic.Controls.TabControl)
End If
Else
If (TabControl1.SelectedIndex = 1) Then
If Not (TabbedGroups2.ActiveLeaf Is Nothing) Then
tc = CType(TabbedGroups2.ActiveLeaf.GroupControl, Crownwood.Magic.Controls.TabControl)
End If
Else
If Not (TabbedGroups3.ActiveLeaf Is Nothing) Then
tc = CType(TabbedGroups3.ActiveLeaf.GroupControl, Crownwood.Magic.Controls.TabControl)
End If
End If
End If
' Did we find a current tab control?
If Not (tc Is Nothing) Then
' Does it have a selected tab?
If Not (tc.SelectedTab Is Nothing) Then
' Remove the page
tc.TabPages.Remove(tc.SelectedTab)
End If
End If
End Sub
Protected Sub OnSaveG1(ByVal sender As Object, ByVal e As EventArgs)
TabbedGroups1.SaveConfigToFile("Group1.xml")
End Sub
Protected Sub OnLoadG1(ByVal sender As Object, ByVal e As EventArgs)
Try
TabbedGroups1.LoadConfigFromFile("Group1.xml")
Finally
End Try
End Sub
Protected Sub OnSaveG2(ByVal sender As Object, ByVal e As EventArgs)
TabbedGroups2.SaveConfigToFile("Group2.xml")
End Sub
Protected Sub OnLoadG2(ByVal sender As Object, ByVal e As EventArgs)
Try
TabbedGroups2.LoadConfigFromFile("Group2.xml")
Finally
End Try
End Sub
Protected Sub OnSaveG3(ByVal sender As Object, ByVal e As EventArgs)
TabbedGroups3.SaveConfigToFile("Group3.xml")
End Sub
Protected Sub OnLoadG3(ByVal sender As Object, ByVal e As EventArgs)
Try
TabbedGroups3.LoadConfigFromFile("Group3.xml")
Finally
End Try
End Sub
Protected Sub OnDisplayMode(ByVal tabsMode As MenuCommand)
' Default all the commands to not being checked
Dim mc As MenuCommand
For Each mc In tabsMode.MenuCommands
mc.Checked = False
Next
Select Case TabbedGroups1.DisplayTabMode
Case TabbedGroups.DisplayTabModes.HideAll
tabsMode.MenuCommands(0).Checked = True
Case TabbedGroups.DisplayTabModes.ShowAll
tabsMode.MenuCommands(1).Checked = True
Case TabbedGroups.DisplayTabModes.ShowActiveLeaf
tabsMode.MenuCommands(2).Checked = True
Case TabbedGroups.DisplayTabModes.ShowMouseOver
tabsMode.MenuCommands(3).Checked = True
Case TabbedGroups.DisplayTabModes.ShowActiveAndMouseOver
tabsMode.MenuCommands(4).Checked = True
End Select
End Sub
Protected Sub OnHideAll(ByVal sender As Object, ByVal e As EventArgs)
TabbedGroups1.DisplayTabMode = TabbedGroups.DisplayTabModes.HideAll
TabbedGroups2.DisplayTabMode = TabbedGroups.DisplayTabModes.HideAll
TabbedGroups3.DisplayTabMode = TabbedGroups.DisplayTabModes.HideAll
End Sub
Protected Sub OnShowAll(ByVal sender As Object, ByVal e As EventArgs)
TabbedGroups1.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowAll
TabbedGroups2.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowAll
TabbedGroups3.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowAll
End Sub
Protected Sub OnShowActiveLeaf(ByVal sender As Object, ByVal e As EventArgs)
TabbedGroups1.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowActiveLeaf
TabbedGroups2.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowActiveLeaf
TabbedGroups3.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowActiveLeaf
End Sub
Protected Sub OnShowMouseOver(ByVal sender As Object, ByVal e As EventArgs)
TabbedGroups1.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowMouseOver
TabbedGroups2.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowMouseOver
TabbedGroups3.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowMouseOver
End Sub
Protected Sub OnShowActiveAndMouseOver(ByVal sender As Object, ByVal e As EventArgs)
TabbedGroups1.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowActiveAndMouseOver
TabbedGroups2.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowActiveAndMouseOver
TabbedGroups3.DisplayTabMode = TabbedGroups.DisplayTabModes.ShowActiveAndMouseOver
End Sub
Private Sub PageSaving(ByVal tg As Crownwood.Magic.Controls.TabbedGroups, _
ByVal e As Crownwood.Magic.Controls.TGPageSavingEventArgs) _
Handles TabbedGroups1.PageSaving, TabbedGroups2.PageSaving, TabbedGroups3.PageSaving
' Persist the text box contents
e.XmlOut.WriteCData(CType(e.TabPage.Control, RichTextBox).Text)
End Sub
Private Sub PageLoading(ByVal tg As Crownwood.Magic.Controls.TabbedGroups, _
ByVal e As Crownwood.Magic.Controls.TGPageLoadingEventArgs) _
Handles TabbedGroups1.PageLoading, TabbedGroups2.PageLoading, TabbedGroups3.PageLoading
' Read back the text box contents
CType(e.TabPage.Control, RichTextBox).Text = e.XmlIn.ReadString()
End Sub
Private Sub GlobalSaving(ByVal tg As Crownwood.Magic.Controls.TabbedGroups, _
ByVal xmlOut As System.Xml.XmlTextWriter) _
Handles TabbedGroups1.GlobalSaving, TabbedGroups2.GlobalSaving, TabbedGroups3.GlobalSaving
' Persist the global text box contents
xmlOut.WriteCData(_global.Text)
End Sub
Private Sub GlobalLoading(ByVal tg As Crownwood.Magic.Controls.TabbedGroups, _
ByVal xmlIn As System.Xml.XmlTextReader) _
Handles TabbedGroups1.GlobalLoading, TabbedGroups2.GlobalLoading, TabbedGroups3.GlobalLoading
' Read back the global text box contents
_global.Text = xmlIn.ReadString()
End Sub
Private Sub TabControlCreated(ByVal tg As Crownwood.Magic.Controls.TabbedGroups, _
ByVal tc As Crownwood.Magic.Controls.TabControl) _
Handles TabbedGroups1.TabControlCreated, TabbedGroups2.TabControlCreated, TabbedGroups3.TabControlCreated
' This is where you change the tab control defaults when a new tab control is created
End Sub
Private Sub ExternalDrop(ByVal tg As Crownwood.Magic.Controls.TabbedGroups, _
ByVal tgl As Crownwood.Magic.Controls.TabGroupLeaf, _
ByVal tc As Crownwood.Magic.Controls.TabControl, _
ByVal dp As Crownwood.Magic.Controls.TabbedGroups.DragProvider) _
Handles TabbedGroups1.ExternalDrop, TabbedGroups2.ExternalDrop, TabbedGroups3.ExternalDrop
' Create a new tab page
Dim tp As Crownwood.Magic.Controls.TabPage = NewTabPage()
' Define the text in this control
CType(tp.Control, RichTextBox).Text = "Dragged from node '" & CType(dp.Tag, String) & "'"
' We want the new page to become selected
tp.Selected = True
' Add new page into the destination tab control
tgl.TabPages.Add(tp)
End Sub
#End Region
Private Sub TabControl1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectionChanged
End Sub
End Class
Public Class DragTree
Inherits TreeView
Protected _leftDown As Boolean
Protected _leftPoint As System.Drawing.Point
Protected _leftNode As TreeNode
Sub New()
_leftDown = False
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
' Only interested in the left button
If (e.Button = MouseButtons.Left) Then
Dim n As TreeNode = Me.GetNodeAt(New Point(e.X, e.Y))
' Are we selecting a valid node?
If Not (n Is Nothing) Then
' Might be start of a drag, so remember details
_leftNode = n
_leftDown = True
_leftPoint = New Point(e.X, e.Y)
' Must capture the mouse
Me.Capture = True
Me.Focus()
End If
End If
MyBase.OnMouseDown(e)
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
' Are we monitoring for a drag operation?
If (_leftDown) Then
Dim dragRect As Rectangle = New Rectangle(_leftPoint, New Size(0, 0))
' Create rectangle for drag start
dragRect.Inflate(SystemInformation.DoubleClickSize)
' Has mouse been dragged outside of rectangle?
If (Not dragRect.Contains(New Point(e.X, e.Y))) Then
' Create an object the TabbedGroups control understands
Dim dp As TabbedGroups.DragProvider = New TabbedGroups.DragProvider()
' Box the node name as the parameter for passing across
dp.Tag = CType(_leftNode.Text, Object)
' Must start a drag operation
DoDragDrop(dp, DragDropEffects.Copy)
' Cancel any further drag events until mouse is pressed again
_leftDown = False
_leftNode = Nothing
End If
End If
MyBase.OnMouseMove(e)
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
Select Case m.Msg
Case CType(Crownwood.Magic.Win32.Msgs.WM_LBUTTONUP, Int32)
' Remembering drag info?
If (_leftDown) Then
' Cancel any drag attempt
_leftDown = False
_leftNode = Nothing
End If
End Select
MyBase.WndProc(m)
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -