Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensured logical layout and correct toggling of Script, Metadata, Data and Output windows #8504

Merged
merged 6 commits into from
Sep 14, 2023
206 changes: 126 additions & 80 deletions instat/frmMain.vb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ Public Class frmMain
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

'set controls layout
SetupInitialLayout()

clsOutputLogger = New clsOutputLogger
clsRLink = New RLink(clsOutputLogger)
If RuntimeInformation.IsOSPlatform(OSPlatform.Windows) Then
Expand Down Expand Up @@ -128,8 +132,6 @@ Public Class frmMain

ucrOutput.SetLogger(clsOutputLogger)

SetToDefaultLayout()

'---------------------------------------
'set up R-Instat options (settings)
'load any saved options if available
Expand Down Expand Up @@ -218,6 +220,114 @@ Public Class frmMain
isMaximised = True 'Need to get the windowstate when the application is loaded
End Sub

Private Sub SetupInitialLayout()
'splOverall has 2 panels
'splOverall.Panel1 contains splExtraWindows
'splOverall.Panel2 contains splDataOutput

'splExtraWindows has 2 panels
'splExtraWindows.Panel1 contains splMetadata
'splExtraWindows.Panel2 contains script window

'splMetadata has 2 panels
'splMetadata.Panel1 contains data frame
'splMetadata.Panel2 contains column metadata

'splDataOutput has 2 panels
'splDataOutput.Panel1 contains data viewer window
'splDataOutput.Panel2 contains output window

'collaspe all the panels initially (on application startup)
splOverall.Panel1Collapsed = True
splOverall.Panel2Collapsed = True

splExtraWindows.Panel1Collapsed = True
splExtraWindows.Panel2Collapsed = True

splMetadata.Panel1Collapsed = True
splMetadata.Panel2Collapsed = True

splDataOutput.Panel1Collapsed = True
splDataOutput.Panel2Collapsed = True

SetToDefaultLayout()
End Sub

Private Sub SetToDefaultLayout()
splOverall.SplitterDistance = splOverall.Height / 4
splDataOutput.SplitterDistance = splDataOutput.Width / 2
splExtraWindows.SplitterDistance = splExtraWindows.Width / 2
splMetadata.SplitterDistance = splMetadata.Width / 2

mnuViewDataView.Checked = True
mnuViewOutput.Checked = True
mnuViewDataFrameMetadata.Checked = False
mnuViewColumnMetadata.Checked = False
mnuViewLogScript.Checked = False
mnuViewSwapDataAndMetadata.Checked = False
mnuColumnMetadat.Checked = False
mnuDataFrameMetadat.Checked = False

mnuTbDataView.Checked = True
mnuOutputWindow.Checked = True
mnuLogScript.Checked = False
UpdateLayout()
End Sub

Public Sub UpdateLayout()

If Not mnuViewDataView.Checked _
AndAlso Not mnuViewOutput.Checked _
AndAlso Not mnuViewColumnMetadata.Checked _
AndAlso Not mnuViewDataFrameMetadata.Checked _
AndAlso Not mnuViewLogScript.Checked _
AndAlso Not mnuViewSwapDataAndMetadata.Checked Then
splOverall.Hide()
Else
splOverall.Show()

'determine splOverall contents visibility

'-------------------------------
'determine splOverall.Panel1 and it's contents visibility

If mnuViewColumnMetadata.Checked OrElse mnuViewDataFrameMetadata.Checked OrElse mnuViewLogScript.Checked Then
'expand panel 1
splOverall.Panel1Collapsed = False
'change splOverall.Panel1Collapsed contents visibilty
If mnuViewColumnMetadata.Checked OrElse mnuViewDataFrameMetadata.Checked Then
splMetadata.Panel1Collapsed = Not mnuViewColumnMetadata.Checked
splMetadata.Panel2Collapsed = Not mnuViewDataFrameMetadata.Checked
splExtraWindows.Panel1Collapsed = False
Else
splExtraWindows.Panel1Collapsed = True
End If
'expand panel 2 based on log script menu item checked status
splExtraWindows.Panel2Collapsed = Not mnuViewLogScript.Checked
Else
splOverall.Panel1Collapsed = True
End If
'-------------------------------

'-------------------------------
'determine splOverall.Panel2 and it's contents visibility

If mnuViewDataView.Checked OrElse mnuViewOutput.Checked Then
splDataOutput.Panel1Collapsed = Not mnuViewDataView.Checked
splDataOutput.Panel2Collapsed = Not mnuViewOutput.Checked
splOverall.Panel2Collapsed = False
Else
splOverall.Panel2Collapsed = True
End If
'-------------------------------


End If
mnuTbDataView.Checked = mnuViewDataView.Checked
mnuOutputWindow.Checked = mnuViewOutput.Checked
mnuLogScript.Checked = mnuViewLogScript.Checked
End Sub

Private Function GetSavedRInstatOptions() As InstatOptions
Dim clsInstatOptions As InstatOptions = Nothing
Dim strFilePath As String = Path.Combine(strAppDataPath, strInstatOptionsFile)
Expand Down Expand Up @@ -426,29 +536,21 @@ Public Class frmMain
End If
End Sub



Private Sub SetToDefaultLayout()
splOverall.SplitterDistance = splOverall.Height / 4
splDataOutput.SplitterDistance = splDataOutput.Width / 2
splExtraWindows.SplitterDistance = splExtraWindows.Width / 2
splMetadata.SplitterDistance = splMetadata.Width / 2

mnuViewDataView.Checked = True
mnuViewOutput.Checked = True
mnuViewDataFrameMetadata.Checked = False
mnuViewColumnMetadata.Checked = False
mnuViewLogScript.Checked = False
mnuViewSwapDataAndMetadata.Checked = False
mnuColumnMetadat.Checked = False
mnuDataFrameMetadat.Checked = False

mnuTbDataView.Checked = True
mnuOutputWindow.Checked = True
mnuLogScript.Checked = False
UpdateLayout()
Private Sub UpdateSwapDataAndMetadata()
If mnuViewSwapDataAndMetadata.Checked Then
splDataOutput.Panel1.Controls.Add(ucrColumnMeta)
splMetadata.Panel1.Controls.Add(ucrDataViewer)
mnuViewColumnMetadata.Text = "Data View"
mnuViewDataView.Text = "Column Metadata"
Else
splDataOutput.Panel1.Controls.Add(ucrDataViewer)
splMetadata.Panel1.Controls.Add(ucrColumnMeta)
mnuViewColumnMetadata.Text = "Column Metadata"
mnuViewDataView.Text = "Data View"
End If
End Sub


Public Sub SaveInstatOptions(strFilePath As String)
Dim serializer As New BinaryFormatter()

Expand Down Expand Up @@ -550,62 +652,6 @@ Public Class frmMain
dlgName.ShowDialog()
End Sub

Public Sub UpdateLayout()
If Not mnuViewDataView.Checked _
AndAlso Not mnuViewOutput.Checked _
AndAlso Not mnuViewColumnMetadata.Checked _
AndAlso Not mnuViewDataFrameMetadata.Checked _
AndAlso Not mnuViewLogScript.Checked _
AndAlso Not mnuViewSwapDataAndMetadata.Checked Then
splOverall.Hide()
Else
splOverall.Show()
If mnuViewDataView.Checked OrElse mnuViewOutput.Checked Then
splOverall.Panel2Collapsed = False
splDataOutput.Panel1Collapsed = Not mnuViewDataView.Checked
splDataOutput.Panel2Collapsed = Not mnuViewOutput.Checked
Else
splOverall.Panel2Collapsed = True
End If
If mnuViewColumnMetadata.Checked _
OrElse mnuViewDataFrameMetadata.Checked _
OrElse mnuViewLogScript.Checked Then
splOverall.Panel1Collapsed = False
If mnuViewColumnMetadata.Checked OrElse mnuViewDataFrameMetadata.Checked Then
splExtraWindows.Panel1Collapsed = False
splMetadata.Panel1Collapsed = Not mnuViewColumnMetadata.Checked
splMetadata.Panel2Collapsed = Not mnuViewDataFrameMetadata.Checked
Else
splExtraWindows.Panel1Collapsed = True
End If
If mnuViewLogScript.Checked Then
splExtraWindows.Panel2Collapsed = False
Else
splExtraWindows.Panel2Collapsed = True
End If
Else
splOverall.Panel1Collapsed = True
End If
End If
mnuTbDataView.Checked = mnuViewDataView.Checked
mnuOutputWindow.Checked = mnuViewOutput.Checked
mnuLogScript.Checked = mnuViewLogScript.Checked
End Sub

Private Sub UpdateSwapDataAndMetadata()
If mnuViewSwapDataAndMetadata.Checked Then
splDataOutput.Panel1.Controls.Add(ucrColumnMeta)
splMetadata.Panel1.Controls.Add(ucrDataViewer)
mnuViewColumnMetadata.Text = "Data View"
mnuViewDataView.Text = "Column Metadata"
Else
splDataOutput.Panel1.Controls.Add(ucrDataViewer)
splMetadata.Panel1.Controls.Add(ucrColumnMeta)
mnuViewColumnMetadata.Text = "Column Metadata"
mnuViewDataView.Text = "Data View"
End If
End Sub

Private Sub mnuWindowDataFrame_Click(sender As Object, e As EventArgs) Handles mnuViewDataFrameMetadata.Click
mnuViewDataFrameMetadata.Checked = Not mnuViewDataFrameMetadata.Checked
mnuDataFrameMetadat.Checked = mnuViewDataFrameMetadata.Checked
Expand Down Expand Up @@ -640,7 +686,7 @@ Public Class frmMain
End Sub

Private Sub mnuPrepareSheetColumnMetadata_Click(sender As Object, e As EventArgs) Handles mnuViewColumnMetadata.Click
mnuViewColumnMetadata.Checked = True
mnuViewColumnMetadata.Checked = Not mnuViewColumnMetadata.Checked
UpdateLayout()
End Sub

Expand Down
74 changes: 41 additions & 33 deletions instat/ucrColumnMetadata.vb
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@ Public Class ucrColumnMetadata
Private _Refreshed As Boolean = False
Private bWideDataSetPromptResponse As DialogResult = DialogResult.None

Public WriteOnly Property DataBook() As clsDataBook
Set(ByVal value As clsDataBook)
_clsDataBook = value
_grid.DataBook = value
End Set
End Property
Public Sub New()

' This call is required by the designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.
SetupInitialLayoutAndGrid()
End Sub

Private Sub frmVariables_Load(sender As Object, e As EventArgs) Handles Me.Load
loadForm()
Private Sub ucrColumnMetadata_Load(sender As Object, e As EventArgs) Handles Me.Load
mnuInsertColsAfter.Visible = False
mnuInsertColsBefore.Visible = False
autoTranslate(Me)
End Sub

Private Sub ucrColumnMetadata_VisibleChanged(sender As Object, e As EventArgs) Handles Me.VisibleChanged
Expand All @@ -54,6 +56,37 @@ Public Class ucrColumnMetadata
RefreshGridData()
End Sub

Private Sub SetupInitialLayoutAndGrid()
lstNonEditableColumns.AddRange({"class", "labels", "Is_Hidden", "Is_Key", "Is_Calculated", "Has_Dependants", "Dependent_Columns", "Calculated_By", "Dependencies", "Colour"})

'DEBUG
' If True Then
If RuntimeInformation.IsOSPlatform(OSPlatform.Linux) Then
_grid = ucrLinuxGrid
tlpTableContainer.ColumnStyles(0).SizeType = SizeType.Percent
tlpTableContainer.ColumnStyles(0).Width = 100
tlpTableContainer.ColumnStyles(1).SizeType = SizeType.Absolute
tlpTableContainer.ColumnStyles(1).Width = 0
Else
_grid = ucrReoGrid
tlpTableContainer.ColumnStyles(0).SizeType = SizeType.Absolute
tlpTableContainer.ColumnStyles(0).Width = 0
tlpTableContainer.ColumnStyles(1).SizeType = SizeType.Percent
tlpTableContainer.ColumnStyles(1).Width = 100
End If
_grid.SetNonEditableColumns(lstNonEditableColumns)
_grid.SetContextmenuStrips(Nothing, cellContextMenuStrip, columnContextMenuStrip, statusColumnMenu)
AddHandler _grid.EditValue, AddressOf EditValue
AddHandler _grid.DeleteLabels, AddressOf DeleteLables
End Sub

Public WriteOnly Property DataBook() As clsDataBook
Set(ByVal value As clsDataBook)
_clsDataBook = value
_grid.DataBook = value
End Set
End Property

Private Function GetCurrentDataFrameFocus() As clsDataFrame
Return _clsDataBook.GetDataFrame(_grid.CurrentWorksheet.Name)
End Function
Expand Down Expand Up @@ -129,31 +162,6 @@ Public Class ucrColumnMetadata
End If
End Sub

Private Sub loadForm()
lstNonEditableColumns.AddRange({"class", "labels", "Is_Hidden", "Is_Key", "Is_Calculated", "Has_Dependants", "Dependent_Columns", "Calculated_By", "Dependencies", "Colour"})

'DEBUG
' If True Then
If RuntimeInformation.IsOSPlatform(OSPlatform.Linux) Then
_grid = ucrLinuxGrid
tlpTableContainer.ColumnStyles(0).SizeType = SizeType.Percent
tlpTableContainer.ColumnStyles(0).Width = 100
tlpTableContainer.ColumnStyles(1).SizeType = SizeType.Absolute
tlpTableContainer.ColumnStyles(1).Width = 0
Else
_grid = ucrReoGrid
tlpTableContainer.ColumnStyles(0).SizeType = SizeType.Absolute
tlpTableContainer.ColumnStyles(0).Width = 0
tlpTableContainer.ColumnStyles(1).SizeType = SizeType.Percent
tlpTableContainer.ColumnStyles(1).Width = 100
End If
_grid.SetNonEditableColumns(lstNonEditableColumns)
_grid.SetContextmenuStrips(Nothing, cellContextMenuStrip, columnContextMenuStrip, statusColumnMenu)
AddHandler _grid.EditValue, AddressOf EditValue
AddHandler _grid.DeleteLabels, AddressOf DeleteLables
autoTranslate(Me)
End Sub

Public Sub SetCurrentDataFrame(strDataName As String)
_grid.SetCurrentDataFrame(strDataName)
End Sub
Expand Down
23 changes: 15 additions & 8 deletions instat/ucrDataFrameMetadata.vb
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,28 @@ Public Class ucrDataFrameMetadata
Private clsViewDataFrame As New RFunction
Private clsGetDataFrame As New RFunction

Public Sub New()
' This call is required by the designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.
SetupInitialLayoutAndGrid()
End Sub
Private Sub ucrDataFrameMetadata_Load(sender As Object, e As EventArgs) Handles Me.Load
clsViewDataFrame.SetRCommand("View")
clsGetDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame")
clsHideDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$append_to_dataframe_metadata")
End Sub


Public WriteOnly Property DataBook() As clsDataBook
Set(ByVal value As clsDataBook)
_clsDataBook = value
_grid.DataBook = value
End Set
End Property

Private Sub frmMetaData_Load(sender As Object, e As EventArgs) Handles Me.Load
LoadForm()
clsViewDataFrame.SetRCommand("View")
clsGetDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame")
clsHideDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$append_to_dataframe_metadata")
End Sub

Private Sub LoadForm()
Private Sub SetupInitialLayoutAndGrid()
lstNonEditableColumns.AddRange({"class", "Is_Hidden", "Row_Count", "Column_Count", "Is_Linkable", "Is_Calculated"})

'Debug
Expand Down
Loading
Loading