WIP Panel Manager

This commit is contained in:
Jonathan Jenne 2019-03-08 15:00:47 +01:00
parent 3ee971fd14
commit e7e6d73411
13 changed files with 388 additions and 35 deletions

View File

@ -0,0 +1,104 @@
Imports DevExpress.XtraBars.Docking
Imports DevExpress.XtraBars.Docking2010
Imports DevExpress.XtraBars.Docking2010.Views
Imports DevExpress.XtraBars.Docking2010.Views.Tabbed
Imports DigitalData.Modules.Logging
Public Class ClassPanelManager
Private _logger As Logger
Private _logConfig As LogConfig
Private _documentManager As DocumentManager
Private _dockManager As DockManager
Private _view As TabbedView
Private _panels As New List(Of DockPanel)
Private _documents As New List(Of Document)
Public Sub New(LogConfig As LogConfig, DocumentManager As DocumentManager, DockManager As DockManager)
Try
Dim oView = DocumentManager.View
_logConfig = LogConfig
_logger = LogConfig.GetLogger()
_documentManager = DocumentManager
_dockManager = DockManager
_view = oView
AddHandler oView.DocumentAdded, AddressOf View_DocumentAdded
AddHandler oView.DocumentClosed, AddressOf View_DocumentClosed
AddHandler oView.DocumentClosing, AddressOf View_DocumentClosing
AddHandler oView.DocumentActivated, AddressOf View_DocumentActivated
AddHandler oView.DocumentDeactivated, AddressOf View_DocumentDeactivated
Catch ex As Exception
_logger.Error(ex)
Throw ex
End Try
End Sub
Private Sub View_DocumentDeactivated(sender As Object, e As DocumentEventArgs)
' Maybe hide panels for this form
End Sub
Private Sub View_DocumentActivated(sender As Object, e As DocumentEventArgs)
Dim oDocument As BaseDocument = e.Document
If oDocument Is Nothing Then
Exit Sub
End If
' Show Panels for this form
End Sub
Private Sub View_DocumentClosing(sender As Object, e As DocumentCancelEventArgs)
' close all related panels
For Each oPanel As DockPanel In _dockManager.Panels
Dim oTag As Integer = oPanel.Tag
If oTag = e.Document.Control.GetHashCode() Then
oPanel.Close()
End If
Next
End Sub
Private Sub View_DocumentClosed(sender As Object, e As DocumentEventArgs)
' remove event handlers
_documents.Remove(e.Document)
End Sub
Private Sub View_DocumentAdded(sender As Object, e As DocumentEventArgs)
' Only Ribbon Forms can have panels!
If TypeOf e.Document.Control IsNot BaseRibbonForm Then
Exit Sub
End If
' Don't open panels for the same form twice!
If _documents.Contains(e.Document) Then
Exit Sub
End If
_documents.Add(e.Document)
Dim oForm As BaseRibbonForm = e.Document.Control
Dim oInitialPanelInfo As List(Of PanelInfo) = oForm.GetInitialPanels()
' TODO: determine how much panels at most can be added
' check if initial panels should be loaded
For Each oPanelInfo As PanelInfo In oInitialPanelInfo
' Create the control
Dim oControl = oPanelInfo.InnerControl
oControl.Dock = DockStyle.Fill
' Create the panel and add the control
Dim oPanel = _dockManager.AddPanel(oPanelInfo.Position)
oPanel.Tag = oForm.GetHashCode
oPanel.Text = oPanelInfo.Caption
oPanel.Controls.Add(oControl)
Next
' TODO: establish communication channel to load panels on-demand
End Sub
End Class

View File

@ -134,6 +134,7 @@
<Compile Include="ClassDragDrop.vb" />
<Compile Include="ClassErrorHandler.vb" />
<Compile Include="ClassLayout.vb" />
<Compile Include="ClassPanelManager.vb" />
<Compile Include="ClassService.vb" />
<Compile Include="ClassTimer.vb" />
<Compile Include="ClassUIConfig.vb" />
@ -146,6 +147,20 @@
<Compile Include="frmSearch.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="Panels\BasePanel.Designer.vb">
<DependentUpon>BasePanel.vb</DependentUpon>
</Compile>
<Compile Include="Panels\BasePanel.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Panels\DocumentPanel.Designer.vb">
<DependentUpon>DocumentPanel.vb</DependentUpon>
</Compile>
<Compile Include="Panels\DocumentPanel.vb">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Panels\IPanel.vb" />
<Compile Include="Panels\PanelInfo.vb" />
<Compile Include="_TEST\DockManagerTest.Designer.vb">
<DependentUpon>DockManagerTest.vb</DependentUpon>
</Compile>
@ -291,6 +306,9 @@
<EmbeddedResource Include="frmSearch.resx">
<DependentUpon>frmSearch.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Panels\DocumentPanel.resx">
<DependentUpon>DocumentPanel.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="_TEST\DockManagerTest.resx">
<DependentUpon>DockManagerTest.vb</DependentUpon>
</EmbeddedResource>

View File

@ -1,4 +1,5 @@
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraBars.Docking
Imports DevExpress.XtraBars.Ribbon
Imports DigitalData.Modules.Logging
''' <summary>
@ -10,6 +11,8 @@ Imports DigitalData.Modules.Logging
'''
''' ...
''' End Class
'''
''' Only BaseRibbonForms can have panels attached to it!
''' </summary>
Public Class BaseRibbonForm
Inherits RibbonForm
@ -30,6 +33,10 @@ Public Class BaseRibbonForm
' depends on a global var like My.LogConfig
' you might need to check for its existence with ?
End Sub
Public Overridable Function GetInitialPanels() As List(Of PanelInfo)
Return New List(Of PanelInfo)
End Function
End Class

View File

@ -0,0 +1,29 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class BasePanel
Inherits System.Windows.Forms.UserControl
'UserControl überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Wird vom Windows Form-Designer benötigt.
Private components As System.ComponentModel.IContainer
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
End Sub
End Class

View File

@ -0,0 +1,3 @@
Public Class BasePanel
End Class

View File

@ -0,0 +1,61 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class DocumentPanel
Inherits System.Windows.Forms.UserControl
'UserControl überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Wird vom Windows Form-Designer benötigt.
Private components As System.ComponentModel.IContainer
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.GridControl1 = New DevExpress.XtraGrid.GridControl()
Me.GridView1 = New DevExpress.XtraGrid.Views.Grid.GridView()
CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.GridView1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'GridControl1
'
Me.GridControl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.GridControl1.Location = New System.Drawing.Point(0, 0)
Me.GridControl1.MainView = Me.GridView1
Me.GridControl1.Name = "GridControl1"
Me.GridControl1.Size = New System.Drawing.Size(1027, 383)
Me.GridControl1.TabIndex = 0
Me.GridControl1.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridView1})
'
'GridView1
'
Me.GridView1.GridControl = Me.GridControl1
Me.GridView1.Name = "GridView1"
'
'DocumentPanel
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Controls.Add(Me.GridControl1)
Me.Name = "DocumentPanel"
Me.Size = New System.Drawing.Size(1027, 383)
CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.GridView1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents GridControl1 As DevExpress.XtraGrid.GridControl
Friend WithEvents GridView1 As DevExpress.XtraGrid.Views.Grid.GridView
End Class

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,12 @@
Imports DevExpress.XtraGrid
Public Class DocumentPanel
Inherits BasePanel
Private Sub DocumentPanel_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim oGridPatcher As New ClassControlPatcher(Of GridControl)(Me)
oGridPatcher.
ProcessContainer(AddressOf GridControlDefaults.DefaultGridSettings).
ProcessContainer(AddressOf GridControlDefaults.ReadOnlyGridSettings)
End Sub
End Class

View File

@ -0,0 +1,3 @@
Public Interface IPanel
ReadOnly Property PanelName As String
End Interface

View File

@ -0,0 +1,7 @@
Imports DevExpress.XtraBars.Docking
Public Class PanelInfo
Public Caption As String
Public InnerControl As BasePanel
Public Position As DockingStyle
End Class

View File

@ -8,8 +8,10 @@ Imports DevExpress.LookAndFeel
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraBars.Docking
Imports DevExpress.XtraGrid
Imports DevExpress.XtraBars.Docking2010.Views
Public Class frmMain
Private _PanelManager As ClassPanelManager
Private _Timer As ClassTimer
Private _Loading As Boolean = True
@ -44,6 +46,9 @@ Public Class frmMain
_Timer = New ClassTimer(My.LogConfig, Me, My.SysConfig.HeartbeatInterval)
AddHandler _Timer.OnlineChanged, AddressOf HandleOnlineChanged
' Initialize Panel Manager
_PanelManager = New ClassPanelManager(My.LogConfig, DocumentManager, DockManager)
' Show Service Status Label
SetOnlineLabel()
@ -192,6 +197,8 @@ Public Class frmMain
End Sub
Private Sub MainNav_SelectedItemChanging(sender As Object, e As DevExpress.XtraBars.Navigation.SelectedItemChangingEventArgs) Handles MainNav.SelectedItemChanging
Select Case e.Item.Name
Case NavbarItemHome.Name
Dim oForm As New frmHome()
@ -201,35 +208,6 @@ Public Class frmMain
Dim oForm As New frmSearch()
oForm.MdiParent = DocumentManager.MdiParent
oForm.Show()
Dim oSearchPanel = DockManager.AddPanel(DockingStyle.Bottom)
oSearchPanel.Options.ShowCloseButton = False
oSearchPanel.Options.ShowAutoHideButton = False
oSearchPanel.Text = "Search " & New Random().Next()
oSearchPanel.Controls.Add(New GridControl With {.Dock = DockStyle.Fill})
Dim oSearchPanel2 = DockManager.AddPanel(DockingStyle.Bottom)
oSearchPanel2.Options.ShowCloseButton = False
oSearchPanel2.Options.ShowAutoHideButton = False
oSearchPanel2.Text = "Search " & New Random().Next()
oSearchPanel2.Controls.Add(New GridControl With {.Dock = DockStyle.Fill})
oSearchPanel2.DockTo(oSearchPanel)
AddHandler oForm.FormClosed, Sub()
oSearchPanel.Close()
oSearchPanel2.Close()
End Sub
'AddHandler oForm.Deactivate, Sub()
' oSearchPanel.Visibility = DockVisibility.Hidden
' oSearchPanel2.Visibility = DockVisibility.Hidden
' End Sub
'AddHandler oForm.Activated, Sub()
' oSearchPanel2.Visibility = DockVisibility.Visible
' oSearchPanel.Visibility = DockVisibility.Visible
' End Sub
End Select
e.Cancel = True

View File

@ -1,6 +1,6 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmSearch
Inherits DevExpress.XtraBars.Ribbon.RibbonForm
Inherits BaseRibbonForm
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _

View File

@ -1,4 +1,6 @@
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraBars.Docking
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraGrid
Public Class frmSearch
Private Sub frmSearch_Load(sender As Object, e As EventArgs) Handles Me.Load
@ -10,8 +12,17 @@ Public Class frmSearch
ImageListBoxControl1.Items.Add(oItem)
Next
End Sub
Public Overrides Function GetInitialPanels() As List(Of PanelInfo)
Dim oList = MyBase.GetInitialPanels()
oList.Add(New PanelInfo() With {
.Caption = "Search",
.InnerControl = New DocumentPanel(),
.Position = DockingStyle.Bottom
})
Return oList
End Function
End Class