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

📄 samplemenus.vb

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

    Protected Sub OnTileVSelected(ByVal sender As Object, ByVal e As EventArgs)
        Me.LayoutMdi(MdiLayout.TileVertical)
        OnMenuItemSelected("TileV")
    End Sub

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

    Protected Sub OnWindowMenuStart(ByVal mc As MenuCommand)
        Dim current As Form = Me.ActiveMdiChild

        ' Get collectiom of Mdi child windows
        Dim children As Form() = Me.MdiChildren

        If (children.Length > 0) Then
            ' Add a separator to the menu
            mc.MenuCommands.Add(New MenuCommand("-"))

            Dim f As Form
            For Each f In children
                Dim newMC As MenuCommand = New MenuCommand(f.Text)

                ' Is this the currently selected child?
                newMC.Checked = (current Is f)

                AddHandler newMC.Click, AddressOf OnChildSelect

                ' Add a command for this active MDI Child
                mc.MenuCommands.Add(newMC)
            Next
        End If
    End Sub

    Protected Sub OnWindowMenuEnd(ByVal mc As MenuCommand)
        Dim count As Integer = mc.MenuCommands.Count

        ' Did the OnTopMenuStart add any entries?
        If (count >= 10) Then
            ' Remove all the extras
            Dim index As Integer
            For index = 11 To count
                mc.MenuCommands.RemoveAt(10)
            Next index
        End If
    End Sub

    Protected Sub OnChildSelect(ByVal sender As Object, ByVal e As EventArgs)
        Dim childCommand As MenuCommand = sender

        ' Get name of the window to activate
        Dim name As String = childCommand.Text

        ' Get collectiom of Mdi child windows
        Dim children As Form() = Me.MdiChildren

        Dim f As Form
        For Each f In children
            ' Aha...found it
            If (f.Text = name) Then
                f.Activate()
                Exit For
            End If
        Next

        OnMenuItemSelected("ChildSelected")
    End Sub

    Protected Sub OnYesAnimateSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.Animate = Animate.Yes
        OnMenuItemSelected("Yes - Animate")
    End Sub

    Protected Sub OnYesAnimateUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.Animate = Animate.Yes)
    End Sub

    Protected Sub OnNoAnimateSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.Animate = Animate.No
        OnMenuItemSelected("No - Animate")
    End Sub

    Protected Sub OnNoAnimateUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.Animate = Animate.No)
    End Sub

    Protected Sub OnSystemAnimateSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.Animate = Animate.System
        OnMenuItemSelected("System - Animate")
    End Sub

    Protected Sub OnSystemAnimateUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.Animate = Animate.System)
    End Sub

    Protected Sub On100Selected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateTime = 100
        OnMenuItemSelected("100ms - AnimateTime")
    End Sub

    Protected Sub On100Update(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateTime = 100)
    End Sub

    Protected Sub On250Selected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateTime = 250
        OnMenuItemSelected("250ms - AnimateTime")
    End Sub

    Protected Sub On250Update(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateTime = 250)
    End Sub

    Protected Sub On1000Selected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateTime = 1000
        OnMenuItemSelected("1000ms - AnimateTime")
    End Sub

    Protected Sub On1000Update(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateTime = 1000)
    End Sub

    Protected Sub OnBlendSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateStyle = Animation.Blend
        OnMenuItemSelected("Blend - Animation")
    End Sub

    Protected Sub OnBlendUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateStyle = Animation.Blend)
    End Sub

    Protected Sub OnCenterSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateStyle = Animation.SlideCenter
        OnMenuItemSelected("Center - Animation")
    End Sub

    Protected Sub OnCenterUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateStyle = Animation.SlideCenter)
    End Sub

    Protected Sub OnPPSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateStyle = Animation.SlideHorVerPositive
        OnMenuItemSelected("+Hor +Ver - Animation")
    End Sub

    Protected Sub OnPPUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateStyle = Animation.SlideHorVerPositive)
    End Sub

    Protected Sub OnNNSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateStyle = Animation.SlideHorVerNegative
        OnMenuItemSelected("-Hor -Ver - Animation")
    End Sub

    Protected Sub OnNNUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateStyle = Animation.SlideHorVerNegative)
    End Sub

    Protected Sub OnPNSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateStyle = Animation.SlideHorPosVerNegative
        OnMenuItemSelected("+Hor -Ver - Animation")
    End Sub

    Protected Sub OnPNUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateStyle = Animation.SlideHorPosVerNegative)
    End Sub

    Protected Sub OnNPSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateStyle = Animation.SlideHorNegVerPositive
        OnMenuItemSelected("-Hor +Ver - Animation")
    End Sub

    Protected Sub OnNPUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateStyle = Animation.SlideHorNegVerPositive)
    End Sub

    Protected Sub OnSystemSelected(ByVal sender As Object, ByVal e As EventArgs)
        _topMenu.AnimateStyle = Animation.System
        OnMenuItemSelected("System - Animation")
    End Sub

    Protected Sub OnSystemUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim mc As MenuCommand = sender
        mc.Checked = (_topMenu.AnimateStyle = Animation.System)
    End Sub
End Class


Public Class MDIChild
    Inherits Form

    Protected _mdiContainer As MDIContainer
    Protected _box As RichTextBox

    Sub New(ByVal mdiContainer As MDIContainer)
        ' Remember parent Form
        _mdiContainer = mdiContainer

        ' Create a RichTextBox to fill entire client area
        _box = New RichTextBox()
        _box.Text = "Right click inside this window to show a Popup menu."
        _box.Dock = DockStyle.Fill
        _box.BorderStyle = BorderStyle.None
        AddHandler _box.MouseUp, AddressOf OnRichTextMouseUp
        Controls.Add(_box)
    End Sub

    Public Sub AppendText(ByVal text As String)
        _box.Text = _box.Text & vbCrLf & text
    End Sub

    Protected Sub OnRichTextMouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
        If e.Button = MouseButtons.Right Then
            Dim box As RichTextBox = sender

            Dim s0 As MenuCommand = New MenuCommand("Italy", _mdiContainer.Images, 0)
            Dim s1 As MenuCommand = New MenuCommand("Spain", _mdiContainer.Images, 1)
            Dim s2 As MenuCommand = New MenuCommand("Canada", _mdiContainer.Images, 2)
            Dim s3 As MenuCommand = New MenuCommand("France", _mdiContainer.Images, 3)
            Dim s4 As MenuCommand = New MenuCommand("Belgium", _mdiContainer.Images, 4)
            Dim spain0 As MenuCommand = New MenuCommand("Nerja", _mdiContainer.Images, 5)
            Dim spain1 As MenuCommand = New MenuCommand("Madrid", _mdiContainer.Images, 6)
            Dim spain2 As MenuCommand = New MenuCommand("Barcelona", _mdiContainer.Images, 0)
            Dim canada0 As MenuCommand = New MenuCommand("Toronto", _mdiContainer.Images, 5)
            Dim canada1 As MenuCommand = New MenuCommand("Montreal", _mdiContainer.Images, 6)
            Dim canada2 As MenuCommand = New MenuCommand("Belleville", _mdiContainer.Images, 0)
            Dim england As MenuCommand = New MenuCommand("England", _mdiContainer.Images, 2)
            Dim england1 As MenuCommand = New MenuCommand("London", _mdiContainer.Images, 5)
            Dim england2 As MenuCommand = New MenuCommand("Birmingham", _mdiContainer.Images, 6)
            Dim england3 As MenuCommand = New MenuCommand("Nottingham", _mdiContainer.Images, 0)

            england.MenuCommands.AddRange(New MenuCommand() {england1, england2, england3})
            s1.MenuCommands.AddRange(New MenuCommand() {spain0, spain1, spain2})
            s2.MenuCommands.AddRange(New MenuCommand() {canada0, canada1, canada2, england})

            ' Create the popup menu object
            Dim popup As PopupMenu = New PopupMenu()

            ' Define the list of menu commands
            popup.MenuCommands.AddRange(New MenuCommand() {s0, s1, s2, s3, s4})

            ' Define the properties to get appearance to match MenuControl
            popup.Style = _mdiContainer.Style

            AddHandler popup.Selected, AddressOf OnSelected
            AddHandler popup.Deselected, AddressOf OnDeselected

            ' Show it!
            popup.TrackPopup(box.PointToScreen(New Point(e.X, e.Y)))
        End If
    End Sub

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

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


⌨️ 快捷键说明

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