📄 sampledocking.vb
字号:
topColors.MenuCommands.AddRange(New MenuCommand() {colorDefault, colorSlateBlue, colorFirebrick, colorGreen})
' TabControls
Dim tabsBox As MenuCommand = New MenuCommand("MultiBox", New EventHandler(AddressOf OnTabsMultiBox))
Dim tabsForm As MenuCommand = New MenuCommand("MultiForm", New EventHandler(AddressOf OnTabsMultiForm))
Dim tabsDocument As MenuCommand = New MenuCommand("MultiDocument", New EventHandler(AddressOf OnTabsMultiDocument))
Dim tabsSep1 As MenuCommand = New MenuCommand("-")
Dim tabsTop As MenuCommand = New MenuCommand("Tabs at top", New EventHandler(AddressOf OnTabsTop))
Dim tabsBottom As MenuCommand = New MenuCommand("Tabs at bottom", New EventHandler(AddressOf OnTabsBottom))
AddHandler tabsBox.Update, AddressOf OnUpdateTabsBox
AddHandler tabsForm.Update, AddressOf OnUpdateTabsForm
AddHandler tabsDocument.Update, AddressOf OnUpdateTabsDocument
AddHandler tabsTop.Update, AddressOf OnUpdateTabsTop
AddHandler tabsBottom.Update, AddressOf OnUpdateTabsBottom
topTabControls.MenuCommands.AddRange(new MenuCommand(){tabsBox,tabsForm,tabsDocument, _
tabsSep1,tabsTop,tabsBottom})
topMenu.Dock = DockStyle.Top
Controls.Add(topMenu)
Return topMenu
End Function
Protected Sub OnContextMenu(ByVal pm As PopupMenu, ByVal cea As CancelEventArgs)
' Show the PopupMenu be cancelled and not shown?
If Not _allowContextMenu Then
cea.Cancel = True
Else
If _customContextMenu Then
' Remove the Show All and Hide All commands
pm.MenuCommands.Remove(pm.MenuCommands("Show All"))
pm.MenuCommands.Remove(pm.MenuCommands("Hide All"))
' Add a custom item at the start
pm.MenuCommands.Insert(0, (New MenuCommand("Custom 1")))
pm.MenuCommands.Insert(1, (New MenuCommand("-")))
' Add a couple of custom commands at the end
pm.MenuCommands.Add(New MenuCommand("Custom 2"))
pm.MenuCommands.Add(New MenuCommand("Custom 3"))
End If
End If
End Sub
Protected Sub OnContentHiding(ByVal c As Content, ByVal cea As CancelEventArgs)
Select Case _ignoreClose
Case 0
' Allow all, do nothing
Case 1
' Ignore all, cancel
cea.Cancel = True
Case 2
' Ignore Panels
Dim p As Panel = c.Control
cea.Cancel = Not (p Is Nothing)
Case 3
' Ignore Forms
Dim f As Form = c.Control
cea.Cancel = Not (f Is Nothing)
Case 4
' Ignore RichTextBox
Dim rtb As RichTextBox = c.Control
cea.Cancel = Not (rtb Is Nothing)
End Select
End Sub
Protected Sub OnTabControlCreated(ByVal tabControl As Crownwood.Magic.Controls.TabControl)
tabControl.PositionTop = Not _tabsBottom
tabControl.Appearance = _tabAppearance
End Sub
Protected Sub OnContextMenuAllow(ByVal sender As Object, ByVal e As EventArgs)
' Toggle the display of the docking windows context menu
_allowContextMenu = (_allowContextMenu = False)
End Sub
Protected Sub OnUpdateAllow(ByVal sender As Object, ByVal e As EventArgs)
Dim allowCommand As MenuCommand = sender
allowCommand.Checked = _allowContextMenu
End Sub
Protected Sub OnContextMenuCustomize(ByVal sender As Object, ByVal e As EventArgs)
' Toggle the customization of the displayed context menu
_customContextMenu = (_customContextMenu = False)
End Sub
Protected Sub OnUpdateCustomize(ByVal sender As Object, ByVal e As EventArgs)
Dim customizeCommand As MenuCommand = sender
customizeCommand.Checked = _customContextMenu
End Sub
Protected Sub OnInsideFill(ByVal sender As Object, ByVal e As EventArgs)
If _manager.InsideFill Then
Controls.Add(_filler)
Controls.SetChildIndex(_filler, 0)
_manager.InnerControl = _filler
_manager.InsideFill = False
Else
Controls.Remove(_filler)
_manager.InnerControl = Nothing
_manager.InsideFill = True
End If
End Sub
Protected Sub OnUpdateInsideFill(ByVal sender As Object, ByVal e As EventArgs)
Dim fillCommand As MenuCommand = sender
fillCommand.Checked = _manager.InsideFill
End Sub
Protected Sub OnCreateC1(ByVal sender As Object, ByVal e As EventArgs)
' Create Content which contains a RichTextBox
Dim c As Content = _manager.Contents.Add(New DummyForm(), "Form " & _count, _internalImages, _count Mod 6)
' Increment count of created contents
_count += 1
' Setup initial state to match menu selections
DefineContentState(c)
' Setup the correct starting colors to match the menu selections
DefineControlColors(c)
' Request a new Docking window be created for the above Content on the right edge
_manager.AddContentWithState(c, State.DockRight)
End Sub
Protected Sub OnCreateC2(ByVal sender As Object, ByVal e As EventArgs)
' Create Content which contains a RichTextBox
Dim c As Content = _manager.Contents.Add(New DummyPanel(), "Panel " & _count, _internalImages, _count Mod 6)
' Increment count of created contents
_count += 1
' Setup initial state to match menu selections
DefineContentState(c)
' Setup the correct starting colors to match the menu selections
DefineControlColors(c)
' Request a new Docking window be created for the above Content on the bottom edge
_manager.AddContentWithState(c, State.DockBottom)
End Sub
Protected Sub OnCreateC3(ByVal sender As Object, ByVal e As EventArgs)
' Create Content which contains a RichTextBox
Dim c As Content = _manager.Contents.Add(New RichTextBox(), "RichTextBox " & _count, _internalImages, _count Mod 6)
' Increment count of created contents
_count += 1
AddHandler c.Control.Disposed, AddressOf OnRTBDisposed
' Setup initial state to match menu selections
DefineContentState(c)
' Setup the correct starting colors to match the menu selections
DefineControlColors(c)
' Request a new Docking window be created for the above Content on the left edge
_manager.AddContentWithState(c, State.DockLeft)
End Sub
Protected Sub OnCreateC31(ByVal sender As Object, ByVal e As EventArgs)
' Create three Content objects, one of each type
Dim cA As Content = _manager.Contents.Add(New DummyForm(), "Form " & _count, _internalImages, _count Mod 6)
Dim cB As Content = _manager.Contents.Add(New DummyPanel(), "Panel " & (_count + 1), _internalImages, _count Mod 6)
Dim cC As Content = _manager.Contents.Add(New RichTextBox(), "RichTextBox " & (_count + 2), _internalImages, _count Mod 6)
' Increment count of created contents
_count += 3
' Setup initial state to match menu selections
DefineContentState(cA)
DefineContentState(cB)
DefineContentState(cC)
' Setup the correct starting colors to match the menu selections
DefineControlColors(cA)
DefineControlColors(cB)
DefineControlColors(cC)
' Request a new Docking window be created for the first content on the bottom edge
Dim wc As WindowContent = _manager.AddContentWithState(cA, State.DockBottom)
' Add two other content into the same Zone
_manager.AddContentToZone(cB, wc.ParentZone, 1)
_manager.AddContentToZone(cC, wc.ParentZone, 2)
End Sub
Protected Sub OnCreateC32(ByVal sender As Object, ByVal e As EventArgs)
' Create three Content objects, one of each type
Dim cA As Content = _manager.Contents.Add(New DummyForm(), "Form " & _count, _internalImages, _count Mod 6)
Dim cB As Content = _manager.Contents.Add(New DummyPanel(), "Panel " & (_count + 1), _internalImages, _count Mod 6)
Dim cC As Content = _manager.Contents.Add(New RichTextBox(), "RichTextBox " & (_count + 2), _internalImages, _count Mod 6)
' Increment count of created contents
_count += 3
' Setup initial state to match menu selections
DefineContentState(cA)
DefineContentState(cB)
DefineContentState(cC)
' Setup the correct starting colors to match the menu selections
DefineControlColors(cA)
DefineControlColors(cB)
DefineControlColors(cC)
' Request a new Docking window be created for the first content on the left edge
Dim wc As WindowContent = _manager.AddContentWithState(cA, State.DockLeft)
' Add two other content into the same Zone
_manager.AddContentToZone(cB, wc.ParentZone, 1)
_manager.AddContentToZone(cC, wc.ParentZone, 2)
End Sub
Protected Sub OnCreateC33(ByVal sender As Object, ByVal e As EventArgs)
' Create three Content objects, one of each type
Dim cA As Content = _manager.Contents.Add(New DummyForm(), "Form " & _count, _internalImages, _count Mod 6)
Dim cB As Content = _manager.Contents.Add(New DummyPanel(), "Panel " & (_count + 1), _internalImages, _count Mod 6)
Dim cC As Content = _manager.Contents.Add(New RichTextBox(), "RichTextBox " & (_count + 2), _internalImages, _count Mod 6)
' Increment count of created contents
_count += 3
' Setup initial state to match menu selections
DefineContentState(cA)
DefineContentState(cB)
DefineContentState(cC)
' Setup the correct starting colors to match the menu selections
DefineControlColors(cA)
DefineControlColors(cB)
DefineControlColors(cC)
' Request a new Docking window be created for the first content on the bottom edge
Dim wc As WindowContent = _manager.AddContentWithState(cA, State.DockBottom)
' Add two other content into the same Window
_manager.AddContentToWindowContent(cB, wc)
_manager.AddContentToWindowContent(cC, wc)
End Sub
Protected Sub OnCreateFF(ByVal sender As Object, ByVal e As EventArgs)
' Create three Content objects, one of each type
Dim cA As Content = _manager.Contents.Add(New DummyForm(), "Form " & _count, _internalImages, _count Mod 6)
Dim cB As Content = _manager.Contents.Add(New DummyPanel(), "Panel " & (_count + 1), _internalImages, _count Mod 6)
Dim cC As Content = _manager.Contents.Add(New RichTextBox(), "RichTextBox " & (_count + 2), _internalImages, _count Mod 6)
' Increment count of created contents
_count += 3
' Define the initial floating form size
cA.FloatingSize = New Size(250, 450)
' Setup initial state to match menu selections
DefineContentState(cA)
DefineContentState(cB)
DefineContentState(cC)
' Setup the correct starting colors to match the menu selections
DefineControlColors(cA)
DefineControlColors(cB)
DefineControlColors(cC)
' Request a new Docking window be created for the first content on the bottom edge
Dim wc As WindowContent = _manager.AddContentWithState(cA, State.Floating)
' Add second content into the same Window
_manager.AddContentToWindowContent(cB, wc)
' Add third into same Zone
_manager.AddContentToZone(cC, wc.ParentZone, 1)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -