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

📄 sampleform.vb

📁 Magic Library 1.7,有说明文档
💻 VB
📖 第 1 页 / 共 2 页
字号:
' *****************************************************************************
' 
'  (c) Crownwood Consulting Limited 2002 
'  All rights reserved. The software and associated documentation 
'  supplied hereunder are the proprietary information of Crownwood Consulting 
'  Limited, Haxey, North Lincolnshire, England and are supplied subject to 
'  licence terms.
' 
'  Magic Version 2.7	www.dotnetmagic.com
' *****************************************************************************

Imports Crownwood.Magic.Menus
Imports Crownwood.Magic.Common
Imports Crownwood.Magic.Controls
Imports Crownwood.Magic.Docking

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Private _count As Int32 = 1
    Private _image As Int32 = -1
    Private _global As RichTextBox
    Private _manager As DockingManager

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Create menu options
        CreateMenu()

        ' Define the docking windows
        CreateDockingWindows()

        ' Create some initial tab pages inside each group
        CreateInitialPages()
    End Sub

    Protected Sub CreateMenu()
        ' Create top level commands
        Dim pages As MenuCommand = CreatePages()
        Dim persist As MenuCommand = CreatePersistence()
        Dim tabsMode As MenuCommand = CreateTabsMode()

        ' Add top level commands
        MenuControl1.MenuCommands.AddRange(New MenuCommand() {pages, persist, tabsMode})
    End Sub

    Protected Function CreatePages() As MenuCommand
        Dim pages As New MenuCommand("Pages")

        ' Create pages sub commands
        Dim add As New MenuCommand("Add")
        Dim remove As New MenuCommand("Remove")

        AddHandler add.Click, AddressOf OnAddPage
        AddHandler remove.Click, AddressOf OnRemovePage

        pages.MenuCommands.AddRange(New MenuCommand() {add, remove})

        ' Enable/disable the remove option as appropriate
        AddHandler pages.PopupStart, AddressOf OnPages

        Return pages
    End Function

    Protected Function CreatePersistence() As MenuCommand
        Dim persist As New MenuCommand("Persistence")

        ' Create Persistence sub commands
        Dim saveG1 As New MenuCommand("Save Group1")
        Dim loadG1 As New MenuCommand("Load Group1")
        Dim sep1 As New MenuCommand("-")
        Dim saveG2 As New MenuCommand("Save Group2")
        Dim loadG2 As New MenuCommand("Load Group2")
        Dim sep2 As New MenuCommand("-")
        Dim saveG3 As New MenuCommand("Save Group3")
        Dim loadG3 As New MenuCommand("Load Group3")

        AddHandler saveG1.Click, AddressOf OnSaveG1
        AddHandler loadG1.Click, AddressOf OnLoadG1
        AddHandler saveG2.Click, AddressOf OnSaveG2
        AddHandler loadG2.Click, AddressOf OnLoadG2
        AddHandler saveG3.Click, AddressOf OnSaveG3
        AddHandler loadG3.Click, AddressOf OnLoadG3

        persist.MenuCommands.AddRange(New MenuCommand() {saveG1, loadG1, sep1, _
                                                         saveG2, loadG2, sep2, _
                                                         saveG3, loadG3})

        Return persist
    End Function

    Protected Function CreateTabsMode() As MenuCommand
        Dim tabsMode As New MenuCommand("DisplayMode")

        ' Create modes sub commands
        Dim hideAll As New MenuCommand("Hide All")
        Dim showAll As New MenuCommand("Show All")
        Dim showActiveLeaf As New MenuCommand("Show Active Leaf")
        Dim showMouseOver As New MenuCommand("Show Mouse Over")
        Dim showActiveAndMouseOver As New MenuCommand("Show Active And Mouse Over")

        AddHandler hideAll.Click, AddressOf OnHideAll
        AddHandler showAll.Click, AddressOf OnShowAll
        AddHandler showActiveLeaf.Click, AddressOf OnShowActiveLeaf
        AddHandler showMouseOver.Click, AddressOf OnShowMouseOver
        AddHandler showActiveAndMouseOver.Click, AddressOf OnShowActiveAndMouseOver

        tabsMode.MenuCommands.AddRange(New MenuCommand() {hideAll, showAll, showActiveLeaf, _
                                                          showMouseOver, showActiveAndMouseOver})

        ' Set correct check mark when menu opened
        AddHandler tabsMode.PopupStart, AddressOf OnDisplayMode

        Return tabsMode
    End Function

    Protected Sub CreateDockingWindows()
        ' Create the docking manager instance
        _manager = New DockingManager(Me, VisualStyle.IDE)

        ' Define innner/outer controls for correct docking operation
        _manager.InnerControl = TabControl1
        _manager.OuterControl = StatusBar1

        ' Create the tree control
        Dim tv As TreeView = New DragTree()
        tv.Nodes.Add(New TreeNode("First"))
        tv.Nodes.Add(New TreeNode("Second"))
        tv.Nodes.Add(New TreeNode("Third"))
        tv.Nodes.Add(New TreeNode("Fourth"))

        ' Create a rich text box for the second content
        _global = New RichTextBox()

        ' Create content instances
        Dim c1 As Content = _manager.Contents.Add(tv, "TreeView")
        Dim c2 As Content = _manager.Contents.Add(_global, "Another Window")

        ' Add to the display on the left hand side
        Dim wc As WindowContent = _manager.AddContentWithState(c1, State.DockLeft)

        ' Add at the bottom of the same column
        _manager.AddContentToZone(c2, wc.ParentZone, 1)
    End Sub

    Protected Sub CreateInitialPages()
        CreateInitialPagesGroup1()
        CreateInitialPagesGroup2()
        CreateInitialPagesGroup3()
    End Sub

    Protected Sub CreateInitialPagesGroup1()
        ' Access the default leaf group
        Dim tgl As TabGroupLeaf = CType(TabbedGroups1.RootSequence(0), TabGroupLeaf)

        ' Create two pages for the leaf
        Dim tp1 As Crownwood.Magic.Controls.TabPage = New Crownwood.Magic.Controls.TabPage("Page" & _count, New RichTextBox(), NextImage())
        Dim tp2 As Crownwood.Magic.Controls.TabPage = New Crownwood.Magic.Controls.TabPage("Page" & (_count + 1), New RichTextBox(), NextImage())
        _count += 2

        ' Add a two pages to the leaf
        tgl.TabPages.Add(tp1)
        tgl.TabPages.Add(tp2)
    End Sub

    Protected Sub CreateInitialPagesGroup2()
        ' Access the default leaf group
        Dim tgl1 As TabGroupLeaf = CType(TabbedGroups2.RootSequence(0), TabGroupLeaf)

        ' Add a new leaf group in the same sequence
        Dim tgl2 As TabGroupLeaf = TabbedGroups2.RootSequence.AddNewLeaf()

        ' Add a two pages to the leaf
        tgl1.TabPages.Add(NewTabPage())
        tgl2.TabPages.Add(NewTabPage())
    End Sub

    Protected Sub CreateInitialPagesGroup3()
        ' Change direction to opposite
        TabbedGroups3.RootSequence.Direction = Direction.Vertical

        ' Access the default leaf group
        Dim tgl1 As TabGroupLeaf = CType(TabbedGroups3.RootSequence(0), TabGroupLeaf)

        ' Add a new leaf group in the same sequence
        Dim tgl2 As TabGroupLeaf = TabbedGroups3.RootSequence.AddNewLeaf()

        ' Add a two pages to the leaf
        tgl1.TabPages.Add(NewTabPage())
        tgl2.TabPages.Add(NewTabPage())
    End Sub

    Protected Function NextImage() As Int32
        _image += 1
        If _image > 8 Then _image = 0
        Return _image
    End Function

    Protected Function NewTabPage() As Crownwood.Magic.Controls.TabPage
        Dim newPage As Crownwood.Magic.Controls.TabPage = New Crownwood.Magic.Controls.TabPage("Page" & _count, New RichTextBox(), NextImage())
        _count += 1
        Return newPage
    End Function

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Private WithEvents groupTabs As System.Windows.Forms.ImageList
    Private WithEvents mainTabs As System.Windows.Forms.ImageList
    Friend WithEvents MenuControl1 As Crownwood.Magic.Menus.MenuControl
    Friend WithEvents TabControl1 As Crownwood.Magic.Controls.TabControl
    Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
    Friend WithEvents TabPage1 As Crownwood.Magic.Controls.TabPage
    Friend WithEvents TabPage2 As Crownwood.Magic.Controls.TabPage
    Friend WithEvents TabPage3 As Crownwood.Magic.Controls.TabPage
    Friend WithEvents TabbedGroups1 As Crownwood.Magic.Controls.TabbedGroups
    Friend WithEvents TabbedGroups2 As Crownwood.Magic.Controls.TabbedGroups
    Friend WithEvents TabbedGroups3 As Crownwood.Magic.Controls.TabbedGroups
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.groupTabs = New System.Windows.Forms.ImageList(Me.components)
        Me.mainTabs = New System.Windows.Forms.ImageList(Me.components)
        Me.MenuControl1 = New Crownwood.Magic.Menus.MenuControl()
        Me.TabControl1 = New Crownwood.Magic.Controls.TabControl()
        Me.TabPage1 = New Crownwood.Magic.Controls.TabPage()
        Me.TabbedGroups1 = New Crownwood.Magic.Controls.TabbedGroups()
        Me.TabPage2 = New Crownwood.Magic.Controls.TabPage()
        Me.TabbedGroups2 = New Crownwood.Magic.Controls.TabbedGroups()
        Me.TabPage3 = New Crownwood.Magic.Controls.TabPage()
        Me.TabbedGroups3 = New Crownwood.Magic.Controls.TabbedGroups()
        Me.StatusBar1 = New System.Windows.Forms.StatusBar()
        Me.TabPage1.SuspendLayout()
        CType(Me.TabbedGroups1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.TabPage2.SuspendLayout()
        CType(Me.TabbedGroups2, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.TabPage3.SuspendLayout()
        CType(Me.TabbedGroups3, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'groupTabs
        '
        Me.groupTabs.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
        Me.groupTabs.ImageSize = New System.Drawing.Size(16, 16)
        Me.groupTabs.ImageStream = CType(resources.GetObject("groupTabs.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.groupTabs.TransparentColor = System.Drawing.Color.Transparent
        '
        'mainTabs
        '
        Me.mainTabs.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
        Me.mainTabs.ImageSize = New System.Drawing.Size(16, 16)
        Me.mainTabs.ImageStream = CType(resources.GetObject("mainTabs.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.mainTabs.TransparentColor = System.Drawing.Color.Transparent
        '
        'MenuControl1
        '
        Me.MenuControl1.AnimateStyle = Crownwood.Magic.Menus.Animation.System
        Me.MenuControl1.AnimateTime = 100
        Me.MenuControl1.Cursor = System.Windows.Forms.Cursors.Arrow
        Me.MenuControl1.Direction = Crownwood.Magic.Common.Direction.Horizontal
        Me.MenuControl1.Dock = System.Windows.Forms.DockStyle.Top
        Me.MenuControl1.Font = New System.Drawing.Font("Tahoma", 11.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World)
        Me.MenuControl1.HighlightTextColor = System.Drawing.SystemColors.MenuText
        Me.MenuControl1.Name = "MenuControl1"
        Me.MenuControl1.Size = New System.Drawing.Size(440, 25)
        Me.MenuControl1.Style = Crownwood.Magic.Common.VisualStyle.IDE
        Me.MenuControl1.TabIndex = 0
        Me.MenuControl1.TabStop = False
        Me.MenuControl1.Text = "MenuControl1"
        '
        'TabControl1
        '
        Me.TabControl1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.TabControl1.HideTabsMode = Crownwood.Magic.Controls.TabControl.HideTabsModes.ShowAlways
        Me.TabControl1.ImageList = Me.mainTabs
        Me.TabControl1.Location = New System.Drawing.Point(0, 25)
        Me.TabControl1.Name = "TabControl1"
        Me.TabControl1.SelectedIndex = 0
        Me.TabControl1.SelectedTab = Me.TabPage1
        Me.TabControl1.Size = New System.Drawing.Size(440, 366)
        Me.TabControl1.TabIndex = 1
        Me.TabControl1.TabPages.AddRange(New Crownwood.Magic.Controls.TabPage() {Me.TabPage1, Me.TabPage2, Me.TabPage3})
        '
        'TabPage1
        '
        Me.TabPage1.Controls.AddRange(New System.Windows.Forms.Control() {Me.TabbedGroups1})
        Me.TabPage1.ImageIndex = 0
        Me.TabPage1.Name = "TabPage1"
        Me.TabPage1.Size = New System.Drawing.Size(440, 341)
        Me.TabPage1.TabIndex = 0
        Me.TabPage1.Title = "Group1"
        '
        'TabbedGroups1
        '
        Me.TabbedGroups1.ActiveLeaf = Nothing
        Me.TabbedGroups1.AllowDrop = True
        Me.TabbedGroups1.AtLeastOneLeaf = True
        Me.TabbedGroups1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.TabbedGroups1.ImageList = Me.groupTabs
        Me.TabbedGroups1.Name = "TabbedGroups1"
        Me.TabbedGroups1.ProminentLeaf = Nothing
        Me.TabbedGroups1.ResizeBarColor = System.Drawing.SystemColors.Control
        Me.TabbedGroups1.Size = New System.Drawing.Size(440, 341)
        Me.TabbedGroups1.TabIndex = 0
        '
        'TabPage2
        '
        Me.TabPage2.Controls.AddRange(New System.Windows.Forms.Control() {Me.TabbedGroups2})
        Me.TabPage2.ImageIndex = 1
        Me.TabPage2.Name = "TabPage2"
        Me.TabPage2.Selected = False
        Me.TabPage2.Size = New System.Drawing.Size(440, 341)
        Me.TabPage2.TabIndex = 1
        Me.TabPage2.Title = "Group2"
        '
        'TabbedGroups2
        '
        Me.TabbedGroups2.ActiveLeaf = Nothing
        Me.TabbedGroups2.AllowDrop = True
        Me.TabbedGroups2.AtLeastOneLeaf = True
        Me.TabbedGroups2.Dock = System.Windows.Forms.DockStyle.Fill
        Me.TabbedGroups2.ImageList = Me.groupTabs
        Me.TabbedGroups2.Name = "TabbedGroups2"
        Me.TabbedGroups2.ProminentLeaf = Nothing
        Me.TabbedGroups2.ResizeBarColor = System.Drawing.SystemColors.Control

⌨️ 快捷键说明

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