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

📄 samplemenus.vb

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

        ' Setup the left column details
        england.MenuCommands.ExtraText = "English"
        england.MenuCommands.ExtraTextColor = Color.White
        england.MenuCommands.ExtraBackColor = Color.DarkBlue
        england.MenuCommands.ExtraFont = New Font("Times New Roman", 12.0F, fs)
        s1.MenuCommands.ExtraText = "Spanish"
        s1.MenuCommands.ExtraTextColor = Color.DarkRed
        s1.MenuCommands.ExtraBackColor = Color.Orange
        s1.MenuCommands.ExtraFont = New Font("Times New Roman", 12.0F, fs)
        s2.MenuCommands.ExtraText = "Canadian"
        s2.MenuCommands.ExtraTextColor = Color.White
        s2.MenuCommands.ExtraBackColor = Color.DarkRed
        s2.MenuCommands.ExtraFont = New Font("Times New Roman", 12.0F, fs)
        mc1.MenuCommands.ExtraText = "Countries"
        mc1.MenuCommands.ExtraTextColor = Color.White
        mc1.MenuCommands.ExtraBackColor = Color.SlateGray
        mc1.MenuCommands.ExtraFont = New Font("Times New Roman", 12.0F, fs)
    End Sub

    Protected Sub CreateMovieMenus(ByVal mc1 As MenuCommand, ByVal mc2 As MenuCommand)
        ' Create menu commands
        Dim movie0 As MenuCommand = New MenuCommand("Dr No", _images, 0, New EventHandler(AddressOf OnGenericSelect))
        Dim movie1 As MenuCommand = New MenuCommand("Goldfinger", _images, 1, New EventHandler(AddressOf OnGenericSelect))
        Dim movie2 As MenuCommand = New MenuCommand("Goldeneye", _images, 2, New EventHandler(AddressOf OnGenericSelect))
        Dim movie3 As MenuCommand = New MenuCommand("-")
        Dim movie4 As MenuCommand = New MenuCommand("Live and Let Die", _images, 3, New EventHandler(AddressOf OnGenericSelect))
        Dim movie5 As MenuCommand = New MenuCommand("Man with the Golden Gun", _images, 4, New EventHandler(AddressOf OnGenericSelect))
        Dim movie6 As MenuCommand = New MenuCommand("License Revoked", _images, 5, New EventHandler(AddressOf OnGenericSelect))
        Dim movie7 As MenuCommand = New MenuCommand("Diamonds are Forever", _images, 6, New EventHandler(AddressOf OnGenericSelect))
        Dim movie8 As MenuCommand = New MenuCommand("From Russia with Love", _images, 0, New EventHandler(AddressOf OnGenericSelect))

        ' Change default properties of some items
        movie0.Infrequent = True
        movie1.Infrequent = True
        movie5.Infrequent = True
        movie7.Infrequent = True
        movie8.Infrequent = True

        mc1.MenuCommands.AddRange(New MenuCommand() {movie0, movie1, movie2, movie3, movie4, movie5, movie6, movie7, movie8})
        mc2.MenuCommands.AddRange(New MenuCommand() {movie0, movie1, movie2, movie3, movie4, movie5, movie6, movie7, movie8})

        ' Setup the left column details
        mc1.MenuCommands.ExtraText = "Bond Films"
        mc1.MenuCommands.ExtraFont = New Font("Garamond", 12.0F, FontStyle.Bold)
        mc1.MenuCommands.ExtraBackBrush = New LinearGradientBrush(New Point(0, 0), New Point(100, 100), _
                                                                  Color.LightGreen, Color.DarkGreen)
    End Sub

    Protected Sub SetupStatusBar()
        ' Create and setup the StatusBar object
        _status = New StatusBar()
        _status.Dock = DockStyle.Bottom
        _status.ShowPanels = True

        ' Create and setup a single panel for the StatusBar
        _statusBarPanel = New StatusBarPanel()
        _statusBarPanel.AutoSize = StatusBarPanelAutoSize.Spring
        _status.Panels.Add(_statusBarPanel)

        Controls.Add(_status)
    End Sub

    Public Sub SetStatusBarText(ByVal text As String)
        _statusBarPanel.Text = text
    End Sub

    Public ReadOnly Property Images() As ImageList
        Get
            Images = _images
        End Get
    End Property

    Public ReadOnly Property Style() As VisualStyle
        Get
            Style = _topMenu.Style
        End Get
    End Property

    Protected Sub OnSelected(ByVal mc As MenuCommand)
        SetStatusBarText("Selection over " & mc.Description)
    End Sub

    Protected Sub OnDeselected(ByVal mc As MenuCommand)
        SetStatusBarText("")
    End Sub

    Protected Sub OnMenuItemSelected(ByVal name As String)
        Dim child As MDIChild = Me.ActiveMdiChild

        If Not (child Is Nothing) Then
            child.AppendText(name)
        End If
    End Sub

    Protected Sub OnGenericSelect(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        OnMenuItemSelected(mc.Text)
    End Sub

    Protected Sub OnIDEUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.Style = VisualStyle.IDE)
    End Sub

    Protected Sub OnIDESelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.Style = VisualStyle.IDE
        OnMenuItemSelected("IDE")
    End Sub

    Protected Sub OnPlainUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.Style = VisualStyle.Plain)
    End Sub

    Protected Sub OnPlainSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.Style = VisualStyle.Plain
        OnMenuItemSelected("Plain")
    End Sub

    Protected Sub OnPlainAsBlockUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = _topMenu.PlainAsBlock
    End Sub

    Protected Sub OnPlainAsBlockSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.PlainAsBlock = Not _topMenu.PlainAsBlock
        OnMenuItemSelected("PlainAsBlock")
    End Sub

    Protected Sub OnMultiLineUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = _topMenu.MultiLine
    End Sub

    Protected Sub OnMultiLineSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.MultiLine = Not _topMenu.MultiLine
        OnMenuItemSelected("MultiLine")
    End Sub

    Protected Sub OnDockLeftSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.Dock = DockStyle.Left
        OnMenuItemSelected("DockLeft")
    End Sub

    Protected Sub OnDockLeftUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.Dock = DockStyle.Left)
    End Sub

    Protected Sub OnDockTopSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.Dock = DockStyle.Top
        OnMenuItemSelected("DockTop")
    End Sub

    Protected Sub OnDockTopUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.Dock = DockStyle.Top)
    End Sub

    Protected Sub OnDockRightSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.Dock = DockStyle.Right
        OnMenuItemSelected("DockRight")
    End Sub

    Protected Sub OnDockRightUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.Dock = DockStyle.Right)
    End Sub

    Protected Sub OnDockBottomSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.Dock = DockStyle.Bottom
        OnMenuItemSelected("DockBottom")
    End Sub

    Protected Sub OnDockBottomUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.Dock = DockStyle.Bottom)
    End Sub

    Protected Sub OnExit(ByVal sender As Object, ByVal e As EventArgs)
        Close()
    End Sub

    Protected Sub OnNewWindowSelected(ByVal sender As Object, ByVal e As EventArgs)
        Dim child As MDIChild = New MDIChild(Me)

        child.MdiParent = Me
        child.Size = New Size(130, 130)
        child.Text = "Child" & _count
        child.Show()

        _count += 1

        OnMenuItemSelected("NewWindow")
    End Sub

    Protected Sub OnCloseWindowUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Enabled = Not (Me.ActiveMdiChild Is Nothing)
    End Sub

    Protected Sub OnCloseWindowSelected(ByVal sender As Object, ByVal e As EventArgs)
        ' Close just the curren mdi child window
        Me.ActiveMdiChild.Close()
        OnMenuItemSelected("CloseWindow")
    End Sub

    Protected Sub OnCloseAllUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Enabled = Not (Me.ActiveMdiChild Is Nothing)
    End Sub

    Protected Sub OnCloseAllSelected(ByVal sender As Object, ByVal e As EventArgs)
        Dim mdiCommand As MenuCommand = sender

        Dim child As MDIChild
        For Each child In Controls
            child.Close()
        Next

        OnMenuItemSelected("CloseAll")
    End Sub

    Protected Sub OnNextSelected(ByVal sender As Object, ByVal e As EventArgs)
        Dim current As Form = Me.ActiveMdiChild

        If Not (current Is Nothing) Then
            ' Get collectiom of Mdi child windows
            Dim children As Form() = Me.MdiChildren

            ' Find position of the window after the current one
            Dim newPos As Integer = Array.LastIndexOf(children, current) + 1

            ' Check for moving off the end of list, wrap back to start
            If (newPos = children.Length) Then
                newPos = 0
            End If

            children(newPos).Activate()
        End If

        OnMenuItemSelected("Next")
    End Sub

    Protected Sub OnPreviousSelected(ByVal sender As Object, ByVal e As EventArgs)
        Dim current As Form = Me.ActiveMdiChild

        If Not (current Is Nothing) Then
            ' Get collectiom of Mdi child windows
            Dim children As Form() = Me.MdiChildren

            ' Find position of the window after the current one
            Dim newPos As Integer = Array.LastIndexOf(children, current) - 1

            ' Check for moving off the start of list, wrap back to end
            If (newPos < 0) Then
                newPos = children.Length - 1
            End If

            children(newPos).Activate()
        End If

        OnMenuItemSelected("Previous")
    End Sub

    Protected Sub OnNextPreviousUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Enabled = (Me.MdiChildren.Length > 1)
    End Sub

    Protected Sub OnCascadeSelected(ByVal sender As Object, ByVal e As EventArgs)
        Me.LayoutMdi(MdiLayout.Cascade)
        OnMenuItemSelected("Cascade")
    End Sub

    Protected Sub OnTileHSelected(ByVal sender As Object, ByVal e As EventArgs)
        Me.LayoutMdi(MdiLayout.TileHorizontal)
        OnMenuItemSelected("TileH")

⌨️ 快捷键说明

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