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

📄 sampledocking.vb

📁 Magic Library 1.7,有说明文档
💻 VB
📖 第 1 页 / 共 4 页
字号:
' *****************************************************************************
' 
'  (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 1.7	www.dotnetmagic.com
' *****************************************************************************

Imports System
Imports System.Xml
Imports System.Data
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports Crownwood.Magic.Common
Imports Crownwood.Magic.Controls
Imports Crownwood.Magic.Docking
Imports Crownwood.Magic.Menus

Public Class Form1
    Inherits System.Windows.Forms.Form

    Protected _slot1 As Byte()
    Protected _slot2 As Byte()
    Protected _count As Integer = 0
    Protected _ignoreClose As Integer = 0
    Protected _colorIndex As Integer = 0
    Protected _allowContextMenu As Boolean = True
    Protected _customContextMenu As Boolean = False
    Protected _tabsBottom As Boolean = True
    Protected _captionBars As Boolean = True
    Protected _closeButtons As Boolean = True
    Protected _style As VisualStyle
    Protected _placeHolder As MenuCommand
    Protected _manager As DockingManager
    Protected _internalImages As ImageList
    Protected _statusBar As StatusBar
    Protected _topMenu As Crownwood.Magic.Menus.MenuControl
    Protected _filler As Crownwood.Magic.Controls.TabControl
    Protected _tabAppearance As Crownwood.Magic.Controls.TabControl.VisualAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiForm

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        ' Discover which docking manager to use
        If DialogResult.Yes = MessageBox.Show("Press 'Yes' to select IDE appearance" & vbCrLf & vbCrLf & _
                                              "Press 'No' to select Plain appearance" & vbCrLf, _
                                              "Select Visual Style", MessageBoxButtons.YesNo) Then
            _style = VisualStyle.IDE
        Else
            _style = VisualStyle.Plain
        End If

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

        ' Create a strip of images by loading an embedded bitmap resource
        _internalImages = ResourceHelper.LoadBitmapStrip(Me.GetType(), _
                                                         "SampleDocking.SampleImages.bmp", _
                                                         New Size(16, 16), _
                                                         New Point(0, 0))

        Dim bs As BorderStyle

        If _style = VisualStyle.Plain Then
            bs = BorderStyle.None
        Else
            bs = BorderStyle.FixedSingle
        End If

        Dim rtb1 As RichTextBox = New RichTextBox()
        Dim rtb2 As RichTextBox = New RichTextBox()
        Dim rtb3 As RichTextBox = New RichTextBox()

        rtb1.BorderStyle = bs
        rtb2.BorderStyle = bs
        rtb3.BorderStyle = bs

        _filler = New Crownwood.Magic.Controls.TabControl()
        _filler.TabPages.Add(New Crownwood.Magic.Controls.TabPage("First", rtb1))
        _filler.TabPages.Add(New Crownwood.Magic.Controls.TabPage("Second", rtb2))
        _filler.TabPages.Add(New Crownwood.Magic.Controls.TabPage("Third", rtb3))
        _filler.Appearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument
        _filler.Dock = DockStyle.Fill
        _filler.Style = _style
        _filler.IDEPixelBorder = True
        Controls.Add(_filler)

        ' Reduce the amount of flicker that occurs when windows are redocked within
        ' the container. As this prevents unsightly backcolors being drawn in the
        ' WM_ERASEBACKGROUND that seems to occur.
        SetStyle(ControlStyles.DoubleBuffer, True)
        SetStyle(ControlStyles.AllPaintingInWmPaint, True)

        ' Create the object that manages the docking state
        _manager = New DockingManager(Me, _style)

        ' Notifications
        AddHandler _manager.ContextMenu, AddressOf OnContextMenu
        AddHandler _manager.ContentHiding, AddressOf OnContentHiding
        AddHandler _manager.TabControlCreated, AddressOf OnTabControlCreated

        ' Ensure that the RichTextBox is always the innermost control
        _manager.InnerControl = _filler

        ' Create and setup the StatusBar object
        _statusBar = New StatusBar()
        _statusBar.Dock = DockStyle.Bottom
        _statusBar.ShowPanels = True

        ' Create and setup a single panel for the StatusBar
        Dim statusBarPanel As StatusBarPanel = New StatusBarPanel()
        statusBarPanel.AutoSize = StatusBarPanelAutoSize.Spring
        _statusBar.Panels.Add(statusBarPanel)
        Controls.Add(_statusBar)

        _topMenu = CreateMenus()

        ' Ensure that docking occurs after the menu control and status bar controls
        _manager.OuterControl = _statusBar

        ' Hook into ability to customize configuration persistence
        AddHandler _manager.SaveCustomConfig, AddressOf OnSaveConfig
        AddHandler _manager.LoadCustomConfig, AddressOf OnLoadConfig
    End Sub

    '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.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.SuspendLayout()
        '
        'Form1
        '
        Me.ClientSize = New System.Drawing.Size(500, 500)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Protected Function CreateMenus() As Crownwood.Magic.Menus.MenuControl
        Dim topMenu As Crownwood.Magic.Menus.MenuControl = New Crownwood.Magic.Menus.MenuControl()
        topMenu.Style = _style
        topMenu.MultiLine = False

        Dim topManager As MenuCommand = New MenuCommand("Manager")
        Dim topConfig As MenuCommand = New MenuCommand("Config")
        Dim topSettings As MenuCommand = New MenuCommand("Settings")
        Dim topColors As MenuCommand = New MenuCommand("Colors")
        Dim topTabControls As MenuCommand = New MenuCommand("TabControls")
        topMenu.MenuCommands.AddRange(New MenuCommand() {topManager, topConfig, topSettings, topColors, topTabControls})

        ' Manager 
        Dim managerC1 As MenuCommand = New MenuCommand("Create Form", New EventHandler(AddressOf OnCreateC1))
        Dim managerC2 As MenuCommand = New MenuCommand("Create Panel", New EventHandler(AddressOf OnCreateC2))
        Dim managerC3 As MenuCommand = New MenuCommand("Create RichTextBox", New EventHandler(AddressOf OnCreateC3))
        Dim managerSep1 As MenuCommand = New MenuCommand("-")
        Dim managerC31 As MenuCommand = New MenuCommand("Create 3 in Row", New EventHandler(AddressOf OnCreateC31))
        Dim managerC32 As MenuCommand = New MenuCommand("Create 3 in Column", New EventHandler(AddressOf OnCreateC32))
        Dim managerC33 As MenuCommand = New MenuCommand("Create 3 in Window", New EventHandler(AddressOf OnCreateC33))
        Dim managerSep2 As MenuCommand = New MenuCommand("-")
        Dim managerFF As MenuCommand = New MenuCommand("Create 3 in Floating Form", New EventHandler(AddressOf OnCreateFF))
        Dim managerSep3 As MenuCommand = New MenuCommand("-")
        Dim managerClear As MenuCommand = New MenuCommand("Delete Contents", New EventHandler(AddressOf OnDeleteAll))
        Dim managerSep4 As MenuCommand = New MenuCommand("-")
        Dim managerShowAll As MenuCommand = New MenuCommand("Show All", New EventHandler(AddressOf OnShowAll))
        Dim managerHideAll As MenuCommand = New MenuCommand("Hide All", New EventHandler(AddressOf OnHideAll))
        Dim managerSep5 As MenuCommand = New MenuCommand("-")
        Dim managerInsideFill As MenuCommand = New MenuCommand("Inside Fill", New EventHandler(AddressOf OnInsideFill))
        Dim managerSep6 As MenuCommand = New MenuCommand("-")
        Dim managerExit As MenuCommand = New MenuCommand("Exit", New EventHandler(AddressOf OnExit))

        AddHandler managerInsideFill.Update, AddressOf OnUpdateInsideFill

        topManager.MenuCommands.AddRange(New MenuCommand() {managerC1, managerC2, managerC3, managerSep1, _
                                                           managerC31, managerC32, managerC33, managerSep2, _
                                                           managerFF, managerSep3, _
                                                           managerClear, managerSep4, managerShowAll, _
                                                           managerHideAll, managerSep5, managerInsideFill, _
                                                           managerSep5, managerExit})

        ' Config
        Dim configSF1 As MenuCommand = New MenuCommand("Save as Config1.xml", New EventHandler(AddressOf OnSaveFile1))
        Dim configSF2 As MenuCommand = New MenuCommand("Save as Config2.xml", New EventHandler(AddressOf OnSaveFile2))
        Dim configSep1 As MenuCommand = New MenuCommand("-")
        Dim configLF1 As MenuCommand = New MenuCommand("Load from Config1.xml", New EventHandler(AddressOf OnLoadFile1))
        Dim configLF2 As MenuCommand = New MenuCommand("Load from Config2.xml", New EventHandler(AddressOf OnLoadFile2))
        Dim configSep2 As MenuCommand = New MenuCommand("-")
        Dim configSA1 As MenuCommand = New MenuCommand("Save to byte array1", New EventHandler(AddressOf OnSaveArray1))
        Dim configSA2 As MenuCommand = New MenuCommand("Save to byte array2", New EventHandler(AddressOf OnSaveArray2))
        Dim configSep3 As MenuCommand = New MenuCommand("-")
        Dim configLA1 As MenuCommand = New MenuCommand("Load from byte array1", New EventHandler(AddressOf OnLoadArray1))
        Dim configLA2 As MenuCommand = New MenuCommand("Load from byte array2", New EventHandler(AddressOf OnLoadArray2))
        topConfig.MenuCommands.AddRange(New MenuCommand() {configSF1, configSF2, configSep1, _
                                                          configLF1, configLF2, configSep2, _
                                                          configSA1, configSA2, configSep3, _
                                                          configLA1, configLA2})

        ' Settings
        Dim settingsShow As MenuCommand = New MenuCommand("Allow Context Menu", New EventHandler(AddressOf OnContextMenuAllow))
        Dim settingsCustom As MenuCommand = New MenuCommand("Customize Context Menu", New EventHandler(AddressOf OnContextMenuCustomize))
        Dim settingsSep1 As MenuCommand = New MenuCommand("-")
        Dim settingsRSBD As MenuCommand = New MenuCommand("Default ResizeBarVector", New EventHandler(AddressOf OnResizeBarDefault))
        Dim settingsRSB1 As MenuCommand = New MenuCommand("1 Pixel ResizeBarVector", New EventHandler(AddressOf OnResizeBar1))
        Dim settingsRSB5 As MenuCommand = New MenuCommand("5 Pixel ResizeBarVector", New EventHandler(AddressOf OnResizeBar5))
        Dim settingsRSB7 As MenuCommand = New MenuCommand("7 Pixel ResizeBarVector", New EventHandler(AddressOf OnResizeBar7))
        Dim settingsSep2 As MenuCommand = New MenuCommand("-")
        Dim settingsCaptionBars As MenuCommand = New MenuCommand("Show all caption bars", New EventHandler(AddressOf OnCaptionBars))
        Dim settingsCloseButtons As MenuCommand = New MenuCommand("Show all close buttons", New EventHandler(AddressOf OnCloseButtons))
        Dim settingsSep3 As MenuCommand = New MenuCommand("-")
        Dim settingsAllow As MenuCommand = New MenuCommand("Allow all close buttons", New EventHandler(AddressOf OnAllowAllCloseButton))
        Dim settingsIgnoreAll As MenuCommand = New MenuCommand("Ignore all close buttons", New EventHandler(AddressOf OnIgnoreAllCloseButton))
        Dim settingsIgnorePanel As MenuCommand = New MenuCommand("Ignore all Panel close buttons", New EventHandler(AddressOf OnIgnoreAllPanelButton))
        Dim settingsIgnoreForm As MenuCommand = New MenuCommand("Ignore all Form close buttons", New EventHandler(AddressOf OnIgnoreAllFormButton))
        Dim settingsIgnoreTextBox As MenuCommand = New MenuCommand("Ignore all RichTextBox close buttons", New EventHandler(AddressOf OnIgnoreAllTextboxButton))
        Dim settingsSep4 As MenuCommand = New MenuCommand("-")
        Dim settingsAllowMinMax As MenuCommand = New MenuCommand("Enable Min/Max in Columns/Rows", New EventHandler(AddressOf OnAllowMinMax))
        Dim settingsSep5 As MenuCommand = New MenuCommand("-")
        Dim settingsPlainTabBorder As MenuCommand = New MenuCommand("Show Plain Tab Border", New EventHandler(AddressOf OnPlainTabBorder))

        AddHandler settingsShow.Update, AddressOf OnUpdateAllow
        AddHandler settingsCustom.Update, AddressOf OnUpdateCustomize
        AddHandler settingsRSBD.Update, AddressOf OnUpdateRSBD
        AddHandler settingsRSB1.Update, AddressOf OnUpdateRSB1
        AddHandler settingsRSB5.Update, AddressOf OnUpdateRSB5
        AddHandler settingsRSB7.Update, AddressOf OnUpdateRSB7
        AddHandler settingsCaptionBars.Update, AddressOf OnUpdateCaptionBars
        AddHandler settingsCloseButtons.Update, AddressOf OnUpdateCloseButtons
        AddHandler settingsAllow.Update, AddressOf OnUpdateAllowAll
        AddHandler settingsIgnoreAll.Update, AddressOf OnUpdateIgnoreAll
        AddHandler settingsIgnorePanel.Update, AddressOf OnUpdateIgnorePanel
        AddHandler settingsIgnoreForm.Update, AddressOf OnUpdateIgnoreForm
        AddHandler settingsIgnoreTextBox.Update, AddressOf OnUpdateIgnoreTextBox
        AddHandler settingsAllowMinMax.Update, AddressOf OnUpdateAllowMinMax
        AddHandler settingsPlainTabBorder.Update, AddressOf OnUpdatePlainTabBorder

        topSettings.MenuCommands.AddRange(new MenuCommand(){settingsShow,settingsCustom,settingsSep1,settingsRSBD, _
                                                            settingsRSB1,settingsRSB5,settingsRSB7,settingsSep2, _
                                                            settingsCaptionBars,settingsCloseButtons,settingsSep3, _
                                                            settingsAllow,settingsIgnoreAll,settingsIgnorePanel, _
                                                            settingsIgnoreForm,settingsIgnoreTextBox,settingsSep4, _
                                                            settingsAllowMinMax,settingsSep5,settingsPlainTabBorder})


        ' Colors
        Dim colorDefault As MenuCommand = New MenuCommand("System Default", New EventHandler(AddressOf OnColorDefault))
        Dim colorSlateBlue As MenuCommand = New MenuCommand("Custom - Slate Blue", New EventHandler(AddressOf OnColorSlateBlue))
        Dim colorFirebrick As MenuCommand = New MenuCommand("Custom - Firebrick", New EventHandler(AddressOf OnColorFirebrick))
        Dim colorGreen As MenuCommand = New MenuCommand("Custom - Green", New EventHandler(AddressOf OnColorGreen))

        AddHandler colorDefault.Update, AddressOf OnUpdateDefault
        AddHandler colorSlateBlue.Update, AddressOf OnUpdateSlateBlue
        AddHandler colorFirebrick.Update, AddressOf OnUpdateFirebrick
        AddHandler colorGreen.Update, AddressOf OnUpdateGreen

⌨️ 快捷键说明

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