⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sampledocking.vb

📁 Magic Library 1.7,有说明文档
💻 VB
📖 第 1 页 / 共 4 页
字号:
    End Sub

    Protected Sub OnUpdateSlateBlue(ByVal sender As Object, ByVal e As EventArgs)
        Dim updateCommand As MenuCommand = sender
        updateCommand.Checked = (_colorIndex = 1)
    End Sub

    Protected Sub OnColorFirebrick(ByVal sender As Object, ByVal e As EventArgs)
        ' Remember the new color scheme selected
        _colorIndex = 2

        Me.BackColor = Color.Firebrick

        ' Define the menu/status bars
        _topMenu.TextColor = Color.White
        _topMenu.BackColor = Color.Firebrick
        _topMenu.HighlightTextColor = Color.White
        _topMenu.HighlightBackColor = Color.Firebrick
        _topMenu.SelectedBackColor = Color.Orange
        _topMenu.Font = New Font("Sans Serif", 12.0F)

        ' Define the TabControl appearance
        _filler.TextColor = Color.White
        _filler.BackColor = Color.Firebrick
        _filler.Font = New Font("Sans Serif", 12.0F)

        If _style = VisualStyle.IDE Then
            _topMenu.SelectedTextColor = Color.Black
        Else
            _topMenu.SelectedTextColor = Color.White
        End If

        ' Define docking window colors
        _manager.BackColor = Color.Firebrick
        _manager.InactiveTextColor = Color.White
        _manager.ActiveColor = Color.Orange
        _manager.ActiveTextColor = Color.Black
        _manager.ResizeBarColor = Color.Firebrick
        _manager.CaptionFont = New Font("Sans Serif", 12.0F)
        _manager.TabControlFont = New Font("Sans Serif", 10.0F)

        ' Need to manually update the colors of created Panels/Forms
        Dim c As Content
        For Each c In _manager.Contents
            DefineControlColors(c)
        Next
    End Sub

    Protected Sub OnUpdateFirebrick(ByVal sender As Object, ByVal e As EventArgs)
        Dim updateCommand As MenuCommand = sender
        updateCommand.Checked = (_colorIndex = 2)
    End Sub

    Protected Sub OnColorGreen(ByVal sender As Object, ByVal e As EventArgs)
        ' Remember the new color scheme selected
        _colorIndex = 3

        ' Define main Form back color
        Me.BackColor = Color.PaleGreen

        ' Define the menu/status bars
        _topMenu.TextColor = Color.Black
        _topMenu.BackColor = Color.PaleGreen
        _topMenu.SelectedBackColor = Color.DarkSlateGray
        _topMenu.Font = New Font("Arial", 9.0F)

        ' Define the TabControl appearance
        _filler.TextColor = Color.Black
        _filler.BackColor = Color.PaleGreen
        _filler.Font = New Font("Arial", 9.0F)

        If _style = VisualStyle.IDE Then
            _topMenu.HighlightTextColor = Color.Black
            _topMenu.HighlightBackColor = Color.PaleGreen
            _topMenu.SelectedTextColor = Color.White
        Else
            _topMenu.HighlightTextColor = Color.White
            _topMenu.HighlightBackColor = Color.DarkSlateGray
            _topMenu.SelectedBackColor = Color.PaleGreen
        End If

        ' Define docking window colors
        _manager.BackColor = Color.PaleGreen
        _manager.InactiveTextColor = Color.Black
        _manager.ActiveColor = Color.DarkSlateGray
        _manager.ActiveTextColor = Color.White
        _manager.ResizeBarColor = Color.DarkSeaGreen
        _manager.CaptionFont = New Font("Arial", 9.0F)
        _manager.TabControlFont = New Font("Arial", 9.0F)

        ' Need to manually update the colors of created Panels/Forms
        Dim c As Content
        For Each c In _manager.Contents
            DefineControlColors(c)
        Next
    End Sub

    Protected Sub OnUpdateGreen(ByVal sender As Object, ByVal e As EventArgs)
        Dim updateCommand As MenuCommand = sender
        updateCommand.Checked = (_colorIndex = 3)
    End Sub

    Protected Sub OnTabsMultiBox(ByVal sender As Object, ByVal e As EventArgs)
        _tabAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiBox
        UpdateAllTabControls()
    End Sub

    Protected Sub OnUpdateTabsBox(ByVal sender As Object, ByVal e As EventArgs)
        Dim updateCommand As MenuCommand = sender
        updateCommand.Checked = (_tabAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiBox)
    End Sub

    Protected Sub OnTabsMultiForm(ByVal sender As Object, ByVal e As EventArgs)
        _tabAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiForm
        UpdateAllTabControls()
    End Sub

    Protected Sub OnUpdateTabsForm(ByVal sender As Object, ByVal e As EventArgs)
        Dim updateCommand As MenuCommand = sender
        updateCommand.Checked = (_tabAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiForm)
    End Sub

    Protected Sub OnTabsMultiDocument(ByVal sender As Object, ByVal e As EventArgs)
        _tabAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument
        UpdateAllTabControls()
    End Sub

    Protected Sub OnUpdateTabsDocument(ByVal sender As Object, ByVal e As EventArgs)
        Dim updateCommand As MenuCommand = sender
        updateCommand.Checked = (_tabAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument)
    End Sub

    Protected Sub OnTabsTop(ByVal sender As Object, ByVal e As EventArgs)
        _tabsBottom = False
        UpdateAllTabControls()
    End Sub

    Protected Sub OnUpdateTabsTop(ByVal sender As Object, ByVal e As EventArgs)
        Dim updateCommand As MenuCommand = sender
        updateCommand.Checked = Not _tabsBottom
    End Sub

    Protected Sub OnTabsBottom(ByVal sender As Object, ByVal e As EventArgs)
        _tabsBottom = True
        UpdateAllTabControls()
    End Sub

    Protected Sub UpdateAllTabControls()
        Dim c As Content
        For Each c In _manager.Contents
            If Not (c.ParentWindowContent Is Nothing) Then
                Dim wct As WindowContentTabbed = c.ParentWindowContent

                If Not (wct Is Nothing) Then
                    wct.TabControl.Appearance = _tabAppearance
                    wct.TabControl.PositionTop = Not _tabsBottom
                End If
            End If
        Next
    End Sub

    Protected Sub OnUpdateTabsBottom(ByVal sender As Object, ByVal e As EventArgs)
        Dim updateCommand As MenuCommand = sender
        updateCommand.Checked = _tabsBottom
    End Sub

    Protected Sub OnRTBDisposed(ByVal sender As Object, ByVal e As EventArgs)
        Console.WriteLine("OnRTBDisposed")
    End Sub

    Protected Sub OnSaveConfig(ByVal xmlOut As XmlTextWriter)
        ' Add an extra node into the config to store some useless information
        xmlOut.WriteStartElement("MyCustomElement")
        xmlOut.WriteAttributeString("UselessData1", "Hello")
        xmlOut.WriteAttributeString("UselessData2", "World!")
        xmlOut.WriteEndElement()
    End Sub

    Protected Sub OnLoadConfig(ByVal xmlIn As XmlTextReader)
        ' We are expecting our custom element to be the current one
        If xmlIn.Name = "MyCustomElement" Then
            ' Read in both the expected attributes
            Dim attr1 As String = xmlIn.GetAttribute(0)
            Dim attr2 As String = xmlIn.GetAttribute(1)

            ' Must move past our element
            xmlIn.Read()
        End If
    End Sub

End Class

Public Class DummyForm
    Inherits Form

    Private _dummy1 As Button = New Button()
    Private _dummy2 As Button = New Button()
    Private _dummyBox As GroupBox = New GroupBox()
    Private _dummy3 As RadioButton = New RadioButton()
    Private _dummy4 As RadioButton = New RadioButton()

    Sub New()
        _dummy1.Text = "Button 1"
        _dummy1.Size = New Size(90, 25)
        _dummy1.Location = New Point(10, 10)

        _dummy2.Text = "Button 2"
        _dummy2.Size = New Size(90, 25)
        _dummy2.Location = New Point(110, 10)

        _dummyBox.Text = "Form GroupBox"
        _dummyBox.Size = New Size(125, 67)
        _dummyBox.Location = New Point(10, 45)

        _dummy3.Text = "RadioButton 3"
        _dummy3.Size = New Size(110, 22)
        _dummy3.Location = New Point(10, 20)

        _dummy4.Text = "RadioButton 4"
        _dummy4.Size = New Size(110, 22)
        _dummy4.Location = New Point(10, 42)
        _dummy4.Checked = True

        _dummyBox.Controls.AddRange(New Control() {_dummy3, _dummy4})

        Controls.AddRange(New Control() {_dummy1, _dummy2, _dummyBox})

        Dim c As Component = Me
        AddHandler c.Disposed, AddressOf OnFormDisposed

        ' Define then control to be selected when activated for first time
        Me.ActiveControl = _dummy4
    End Sub

    Protected Sub OnFormDisposed(ByVal sender As Object, ByVal e As EventArgs)
        Console.WriteLine("OnFormDisposed")
    End Sub

End Class

Public Class DummyPanel
    Inherits Panel

    Private _dummyBox As GroupBox = New GroupBox()
    Private _dummy3 As RadioButton = New RadioButton()
    Private _dummy4 As RadioButton = New RadioButton()

    Sub New()
        _dummyBox.Text = "Panel GroupBox"
        _dummyBox.Size = New Size(125, 67)
        _dummyBox.Location = New Point(10, 10)

        _dummy3.Text = "RadioButton 3"
        _dummy3.Size = New Size(110, 22)
        _dummy3.Location = New Point(10, 20)

        _dummy4.Text = "RadioButton 4"
        _dummy4.Size = New Size(110, 22)
        _dummy4.Location = New Point(10, 42)
        _dummy4.Checked = True

        _dummyBox.Controls.AddRange(New Control() {_dummy3, _dummy4})

        Dim c As Component = Me
        AddHandler c.Disposed, AddressOf OnPanelDisposed

        Controls.AddRange(New Control() {_dummyBox})
    End Sub

    Protected Sub OnPanelDisposed(ByVal sender As Object, ByVal e As EventArgs)
        Console.WriteLine("OnPanelDisposed")
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -