diff --git a/EDMI_ClientSuite/ClassPanelManager.vb b/EDMI_ClientSuite/ClassPanelManager.vb index b740f3d1..803751bb 100644 --- a/EDMI_ClientSuite/ClassPanelManager.vb +++ b/EDMI_ClientSuite/ClassPanelManager.vb @@ -13,7 +13,6 @@ Public Class ClassPanelManager 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) @@ -38,28 +37,55 @@ Public Class ClassPanelManager End Try End Sub - - Private Sub View_DocumentDeactivated(sender As Object, e As DocumentEventArgs) + Dim oDocument As BaseDocument = e.Document + Dim oHashcode As Integer = oDocument.Control.GetHashCode + + If oDocument Is Nothing Then + Exit Sub + End If + ' Maybe hide panels for this form + For Each oPanel As DockPanel In _dockManager.Panels + Dim oTag As Integer = oPanel.Tag + + If oTag = oHashcode Then + oPanel.Hide() + End If + Next End Sub Private Sub View_DocumentActivated(sender As Object, e As DocumentEventArgs) Dim oDocument As BaseDocument = e.Document + Dim oHashcode As Integer = oDocument.Control.GetHashCode 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 + If oTag = oHashcode Then + oPanel.Show() + End If + Next + End Sub + + Private Sub View_DocumentClosing(sender As Object, e As DocumentCancelEventArgs) + Dim oDocument As BaseDocument = e.Document + Dim oHashcode As Integer = oDocument.Control.GetHashCode + + If oDocument Is Nothing Then + Exit Sub + End If + + ' close all related panels. + For Each oPanel As DockPanel In _dockManager.Panels + Dim oTag As Integer = oPanel.Tag + + If oTag = oHashcode Then oPanel.Close() End If Next @@ -84,16 +110,14 @@ Public Class ClassPanelManager _documents.Add(e.Document) Dim oForm As BaseRibbonForm = e.Document.Control + Dim oFormHash As Integer = oForm.GetHashCode 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 panel - Dim oPanel = _dockManager.AddPanel(oPanelInfo.Position) - ' create the control - Dim oControl As BasePanel = GetPanelControl(oPanelInfo) + Dim oControl As BasePanel = GetPanelControl(oPanelInfo, oFormHash) If oControl Is Nothing Then Dim oPanelType = oPanelInfo.PanelControl.GetType.ToString @@ -101,14 +125,21 @@ Public Class ClassPanelManager Continue For End If - ' configure the panel + ' create panel + Dim oPanel = _dockManager.AddPanel(oPanelInfo.Position) + + ' configure panel oPanel.Options.ShowCloseButton = oPanelInfo.CanBeClosed oPanel.Options.ShowAutoHideButton = oPanelInfo.CanBePinned oPanel.Options.ShowMaximizeButton = oPanelInfo.CanBeMaximized oPanel.Options.AllowFloating = oPanelInfo.CanBeUndocked - ' hashcode is needed to know which form a panel belongs to - oPanel.Tag = oForm.GetHashCode + ' relation is defined through HashCode of form saved in Tag property of panel + ' + ' Form Panel + ' GetHashCode --------> Tag + ' + oPanel.Tag = oFormHash oPanel.Text = oPanelInfo.Title oPanel.Controls.Add(oControl) Next @@ -116,7 +147,7 @@ Public Class ClassPanelManager ' TODO: establish communication channel to load panels on-demand End Sub - Private Function GetPanelControl(PanelInfo As PanelInfo) As BasePanel + Private Function GetPanelControl(PanelInfo As PanelInfo, FormHash As Integer) As BasePanel If TypeOf PanelInfo.PanelControl Is DocumentPanel Then Dim oPanelControl As DocumentPanel = DirectCast(PanelInfo.PanelControl, DocumentPanel) oPanelControl.Datasource = PanelInfo.Datasource diff --git a/EDMI_ClientSuite/Panels/BasePanel.vb b/EDMI_ClientSuite/Panels/BasePanel.vb index 86707bbc..46978bc6 100644 --- a/EDMI_ClientSuite/Panels/BasePanel.vb +++ b/EDMI_ClientSuite/Panels/BasePanel.vb @@ -1,4 +1,8 @@ Public Class BasePanel - Public Property Caption As String + Public ReadOnly Property OwnerForm As Integer + Get + Return Parent?.Parent?.Tag + End Get + End Property End Class diff --git a/EDMI_ClientSuite/Panels/DocumentPanel.vb b/EDMI_ClientSuite/Panels/DocumentPanel.vb index a1ac3cf3..beca791e 100644 --- a/EDMI_ClientSuite/Panels/DocumentPanel.vb +++ b/EDMI_ClientSuite/Panels/DocumentPanel.vb @@ -20,7 +20,9 @@ Public Class DocumentPanel Private Sub GridViewMain_RowClick(sender As Object, e As RowClickEventArgs) Handles GridViewMain.RowClick If e.Button = MouseButtons.Left And e.Clicks = 2 Then - MsgBox("Open Preview") + MsgBox($"Open Preview for form {OwnerForm}") + + 'TODO: Open Preview Panel for OwnerForm End If End Sub End Class