From 8506ea08479aaab334abd55405e77e191295d631 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 30 Jun 2020 02:50:04 +0300 Subject: [PATCH 01/26] Feature enhancements to 4 dialogs. dlgExportDataset dlgExportGraphAsImage dlgExportRObjects dlgExportRWorkspace dlgSaveAs --- instat/dlgExportDataset.vb | 21 +++++++++------------ instat/dlgExportGraphAsImage.vb | 24 +++++++++++++++++------- instat/dlgExportRObjects.vb | 31 ++++++++++++++++++------------- instat/dlgExportRWorkspace.vb | 31 ++++++++++++++++++------------- instat/dlgSaveAs.vb | 25 +++++++------------------ 5 files changed, 69 insertions(+), 63 deletions(-) diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index fa18fe80d90..56a7d1445f3 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -20,7 +20,7 @@ Public Class dlgExportDataset Dim bFirstLoad As Boolean = True Private bReset As Boolean = True Private clsDefaultFunction As New RFunction - Private strCurrentFileName As String + Private Sub dlgExportDataset_Load(sender As Object, e As EventArgs) Handles Me.Load autoTranslate(Me) @@ -85,32 +85,29 @@ Public Class dlgExportDataset End Sub Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click + Dim strCurrentFilePathName As String = ucrInputExportFile.GetText() Using dlgSave As New SaveFileDialog dlgSave.Title = "Export File Dialog" dlgSave.Filter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html" - If Not String.IsNullOrEmpty(strCurrentFileName) Then - dlgSave.FileName = Path.GetFileName(strCurrentFileName) - dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFileName) - Else - dlgSave.FileName = ucrAvailableSheets.cboAvailableDataFrames.Text + If String.IsNullOrEmpty(strCurrentFilePathName) Then + dlgSave.FileName = ucrAvailableSheets.strCurrDataFrame dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory + Else + dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) + dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) End If If dlgSave.ShowDialog = DialogResult.OK Then ucrInputExportFile.SetName(dlgSave.FileName.Replace("\", "/")) - strCurrentFileName = dlgSave.FileName + strCurrentFilePathName = dlgSave.FileName End If End Using End Sub - Private Sub ucrInputExportFile_Click(sender As Object, e As EventArgs) Handles ucrInputExportFile.Click - cmdBrowse_Click(sender, e) - End Sub - Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrInputExportFile.ControlContentsChanged, ucrAvailableSheets.ControlContentsChanged TestOkEnabled() End Sub Private Sub ucrAvailableSheets_DataFrameChanged(sender As Object, e As EventArgs, strPrevDataFrame As String) Handles ucrAvailableSheets.DataFrameChanged - strCurrentFileName = "" + ucrInputExportFile.SetName("") 'clears the ucrinput contents. End Sub End Class \ No newline at end of file diff --git a/instat/dlgExportGraphAsImage.vb b/instat/dlgExportGraphAsImage.vb index 084664cb992..fedf36e8059 100644 --- a/instat/dlgExportGraphAsImage.vb +++ b/instat/dlgExportGraphAsImage.vb @@ -14,6 +14,7 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . +Imports System.IO Imports instat.Translations Public Class dlgExportGraphAsImage Private bFirstload As Boolean = True @@ -78,13 +79,22 @@ Public Class dlgExportGraphAsImage End Sub Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click - Dim dlgSelectFile As New SaveFileDialog - dlgSelectFile.Title = "Save Graph As Image" - dlgSelectFile.Filter = "JPEG (*.jpeg)|*.jpeg|PNG(*.png)|*.png|BitMaP(*.bmp)|*.bmp|EPS(*.eps)|*.eps|PostScript(*.ps)|*.ps|SVG(*.svg)|*.svg|WMF(*.wmf)|*.wmf|PDF(*.pdf)|*.pdf" - dlgSelectFile.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - If dlgSelectFile.ShowDialog() = DialogResult.OK Then - ucrInputFile.SetName(dlgSelectFile.FileName.Replace("\", "/")) - End If + Dim strCurrentFilePathName As String = ucrInputFile.GetText() + Using dlgSave As New SaveFileDialog + dlgSave.Title = "Save Graph As Image" + dlgSave.Filter = "JPEG (*.jpeg)|*.jpeg|PNG(*.png)|*.png|BitMaP(*.bmp)|*.bmp|EPS(*.eps)|*.eps|PostScript(*.ps)|*.ps|SVG(*.svg)|*.svg|WMF(*.wmf)|*.wmf|PDF(*.pdf)|*.pdf" + If String.IsNullOrEmpty(strCurrentFilePathName) Then + dlgSave.FileName = ucrSelectedGraphReceiver.GetVariableNames(bWithQuotes:=False) 'give a suggestive name (from the reciver) + dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory + Else + strCurrentFilePathName = strCurrentFilePathName.Replace("/", "\") + dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) + dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) 'use the previous path as initial dir + End If + If DialogResult.OK = dlgSave.ShowDialog() Then + ucrInputFile.SetName(dlgSave.FileName.Replace("\", "/")) 'R uses / slashes for file paths. so \ needs to be replaced + End If + End Using End Sub Private Sub ucrCoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrSelectedGraphReceiver.ControlContentsChanged, ucrInputFile.ControlContentsChanged diff --git a/instat/dlgExportRObjects.vb b/instat/dlgExportRObjects.vb index 5a11063f31b..0b2c03a8ded 100644 --- a/instat/dlgExportRObjects.vb +++ b/instat/dlgExportRObjects.vb @@ -85,20 +85,25 @@ Public Class dlgExportRObjects End Sub Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click - Dim dlgSave As New SaveFileDialog - - dlgSave.Title = "Export R Objects" - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - dlgSave.Filter = "Serialized R Objects (*.rds)|*.rds" - If dlgSave.ShowDialog = DialogResult.OK Then - If dlgSave.FileName <> "" Then - ucrInputExportFile.SetName(Path.GetFullPath(dlgSave.FileName).ToString.Replace("\", "/")) + Dim strCurrentFilePathName As String = ucrInputExportFile.GetText() + Using dlgSave As New SaveFileDialog + dlgSave.Title = "Export R Objects" + dlgSave.Filter = "Serialized R Objects (*.rds)|*.rds" + If String.IsNullOrEmpty(strCurrentFilePathName) Then + 'ucrReceiverObjects is a multireceiver. So give a suggestive name if it has 1 item only + If ucrReceiverObjects.GetVariableNamesList().Length = 1 Then + dlgSave.FileName = ucrReceiverObjects.GetVariableNames(bWithQuotes:=False) + End If + dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory + Else + strCurrentFilePathName = strCurrentFilePathName.Replace("/", "\") + dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) + dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) 'use the previous path as initial dir End If - End If - End Sub - - Private Sub ucrInputExportFile_Click(sender As Object, e As EventArgs) Handles ucrInputExportFile.Click - cmdBrowse_Click(sender, e) + If DialogResult.OK = dlgSave.ShowDialog() Then + ucrInputExportFile.SetName(dlgSave.FileName.Replace("\", "/")) 'R uses / slashes for file paths. so \ needs to be replaced + End If + End Using End Sub Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverObjects.ControlContentsChanged, ucrSelectorObjects.ControlContentsChanged, ucrInputExportFile.ControlContentsChanged diff --git a/instat/dlgExportRWorkspace.vb b/instat/dlgExportRWorkspace.vb index 04f6b9e475e..744dad86c4a 100644 --- a/instat/dlgExportRWorkspace.vb +++ b/instat/dlgExportRWorkspace.vb @@ -92,20 +92,25 @@ Public Class dlgExportRWorkspace End Sub Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click - Dim dlgSave As New SaveFileDialog - - dlgSave.Title = "Export R Workspace" - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - dlgSave.Filter = "Saved R Objects (*.RData)|*.RData" - If dlgSave.ShowDialog = DialogResult.OK Then - If dlgSave.FileName <> "" Then - ucrInputExportFile.SetName(Path.GetFullPath(dlgSave.FileName).ToString.Replace("\", "/")) + Dim strCurrentFilePathName As String = ucrInputExportFile.GetText() + Using dlgSave As New SaveFileDialog + dlgSave.Title = "Export R Workspace" + dlgSave.Filter = "Saved R Objects (*.RData)|*.RData" + If String.IsNullOrEmpty(strCurrentFilePathName) Then + 'ucrReceiverMultiple is a multireceiver. So give a suggestive name if it has 1 item only + If ucrReceiverMultiple.GetVariableNamesList().Length = 1 Then + dlgSave.FileName = ucrReceiverMultiple.GetVariableNames(bWithQuotes:=False) + End If + dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory + Else + strCurrentFilePathName = strCurrentFilePathName.Replace("/", "\") + dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) + dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) 'use the previous path as initial dir End If - End If - End Sub - - Private Sub ucrInputExportFile_Click(sender As Object, e As EventArgs) Handles ucrInputExportFile.Click - cmdBrowse_Click(sender, e) + If DialogResult.OK = dlgSave.ShowDialog() Then + ucrInputExportFile.SetName(dlgSave.FileName.Replace("\", "/")) 'R uses / slashes for file paths. so \ needs to be replaced + End If + End Using End Sub Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrInputExportFile.ControlContentsChanged, ucrReceiverMultiple.ControlContentsChanged diff --git a/instat/dlgSaveAs.vb b/instat/dlgSaveAs.vb index b70dc31f500..66c3acde13d 100644 --- a/instat/dlgSaveAs.vb +++ b/instat/dlgSaveAs.vb @@ -80,32 +80,21 @@ Public Class dlgSaveAs frmMain.clsRecentItems.addToMenu(Replace(ucrInputFilePath.GetText(), "/", "\")) End Sub - Private Sub cmdEditorSave_Click(sender As Object, e As EventArgs) Handles cmdChooseFile.Click - SelectFileToSave() - End Sub - - Private Sub ucrInputFilePath_Click(sender As Object, e As EventArgs) Handles ucrInputFilePath.Click - If ucrInputFilePath.IsEmpty() Then - SelectFileToSave() - End If - End Sub - - Private Sub SelectFileToSave() - Dim strCurrentFileName As String = ucrInputFilePath.GetText() + Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdChooseFile.Click + Dim strCurrentFilePathName As String = ucrInputFilePath.GetText() Using dlgSave As New SaveFileDialog dlgSave.Title = "Save Data File" dlgSave.Filter = "RDS Data file (*.RDS)|*.RDS" - If Not String.IsNullOrEmpty(strCurrentFileName) Then - strCurrentFileName = strCurrentFileName.Replace("/", "\") - dlgSave.FileName = Path.GetFileName(strCurrentFileName) - dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFileName) - Else + If String.IsNullOrEmpty(strCurrentFilePathName) Then dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory + Else + strCurrentFilePathName = strCurrentFilePathName.Replace("/", "\") + dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) + dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) End If If DialogResult.OK = dlgSave.ShowDialog() Then ucrInputFilePath.SetName(dlgSave.FileName.Replace("\", "/")) End If - TestOKEnabled() End Using End Sub From 64889c65f6f03562cd1fd6d4d7006fa83b2351aa Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 1 Jul 2020 02:59:11 +0300 Subject: [PATCH 02/26] design changes --- instat/dlgExportDataset.Designer.vb | 2 +- instat/dlgExportDataset.resx | 10 +++++----- instat/dlgExportDataset.vb | 1 - instat/dlgExportGraphAsImage.resx | 10 +++++----- instat/dlgExportRObjects.resx | 10 +++++----- instat/dlgExportRWorkspace.resx | 10 +++++----- instat/dlgSaveAs.resx | 12 ++++++------ 7 files changed, 27 insertions(+), 28 deletions(-) diff --git a/instat/dlgExportDataset.Designer.vb b/instat/dlgExportDataset.Designer.vb index aee550e6ea4..43b0e9f22fb 100644 --- a/instat/dlgExportDataset.Designer.vb +++ b/instat/dlgExportDataset.Designer.vb @@ -67,7 +67,7 @@ Partial Class dlgExportDataset ' Me.ucrInputExportFile.AddQuotesIfUnrecognised = True Me.ucrInputExportFile.IsMultiline = False - Me.ucrInputExportFile.IsReadOnly = False + Me.ucrInputExportFile.IsReadOnly = True resources.ApplyResources(Me.ucrInputExportFile, "ucrInputExportFile") Me.ucrInputExportFile.Name = "ucrInputExportFile" ' diff --git a/instat/dlgExportDataset.resx b/instat/dlgExportDataset.resx index 2733bdf532e..8713de1326c 100644 --- a/instat/dlgExportDataset.resx +++ b/instat/dlgExportDataset.resx @@ -123,7 +123,7 @@ - 429, 48 + 401, 48 62, 23 @@ -151,10 +151,10 @@ NoControl - 2, 53 + 7, 54 - 91, 13 + 62, 13 6 @@ -208,7 +208,7 @@ 0 - 102, 50 + 74, 50 6, 8, 6, 8 @@ -289,7 +289,7 @@ True - 494, 165 + 468, 165 CenterScreen diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index 56a7d1445f3..0d544b7249d 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -21,7 +21,6 @@ Public Class dlgExportDataset Private bReset As Boolean = True Private clsDefaultFunction As New RFunction - Private Sub dlgExportDataset_Load(sender As Object, e As EventArgs) Handles Me.Load autoTranslate(Me) If bFirstLoad Then diff --git a/instat/dlgExportGraphAsImage.resx b/instat/dlgExportGraphAsImage.resx index 751ecde9eda..a6c654f1b7b 100644 --- a/instat/dlgExportGraphAsImage.resx +++ b/instat/dlgExportGraphAsImage.resx @@ -147,7 +147,7 @@ 3 - 380, 194 + 323, 194 75, 23 @@ -180,10 +180,10 @@ True - 455, 280 + 413, 280 - 128, 195 + 74, 195 @@ -208,10 +208,10 @@ 0 - 7, 199 + 8, 199 - 115, 13 + 64, 13 6 diff --git a/instat/dlgExportRObjects.resx b/instat/dlgExportRObjects.resx index 14a68fbc024..bd63ac6aa2b 100644 --- a/instat/dlgExportRObjects.resx +++ b/instat/dlgExportRObjects.resx @@ -153,10 +153,10 @@ 6, 13 - 428, 288 + 414, 288 - 100, 204 + 79, 204 @@ -181,7 +181,7 @@ 0 - 355, 203 + 334, 203 62, 23 @@ -205,10 +205,10 @@ 1 - -1, 206 + 10, 208 - 95, 13 + 65, 13 3 diff --git a/instat/dlgExportRWorkspace.resx b/instat/dlgExportRWorkspace.resx index e429cd43871..beddb898eed 100644 --- a/instat/dlgExportRWorkspace.resx +++ b/instat/dlgExportRWorkspace.resx @@ -119,7 +119,7 @@ - 357, 251 + 319, 251 81, 23 @@ -144,10 +144,10 @@ 3 - 3, 255 + 8, 256 - 100, 13 + 60, 13 6 @@ -247,7 +247,7 @@ 10 - 112, 252 + 74, 252 6, 8, 6, 8 @@ -352,7 +352,7 @@ True - 440, 338 + 413, 338 10, 281 diff --git a/instat/dlgSaveAs.resx b/instat/dlgSaveAs.resx index e4c7ca3cf67..3730341a6b5 100644 --- a/instat/dlgSaveAs.resx +++ b/instat/dlgSaveAs.resx @@ -119,7 +119,7 @@ - 10, 70 + 10, 55 @@ -145,10 +145,10 @@ 4 - 10, 20 + 9, 20 - 103, 13 + 78, 13 0 @@ -169,7 +169,7 @@ 2 - 125, 17 + 91, 17 6, 8, 6, 8 @@ -193,7 +193,7 @@ 1 - 443, 17 + 409, 17 65, 21 @@ -247,7 +247,7 @@ 6, 13 - 511, 130 + 475, 110 CenterScreen From f0ac078bcf9412d7f2c9f054211b2f12ac808163 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Fri, 10 Jul 2020 01:30:13 +0300 Subject: [PATCH 03/26] click event addition --- instat/dlgExportDataset.vb | 4 ++++ instat/dlgExportGraphAsImage.vb | 4 ++++ instat/dlgExportRObjects.vb | 4 ++++ instat/dlgExportRWorkspace.vb | 4 ++++ instat/dlgSaveAs.vb | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index 0d544b7249d..ce995dfaa94 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -102,6 +102,10 @@ Public Class dlgExportDataset End Using End Sub + Private Sub ucrInputExportFile_Click() Handles ucrInputExportFile.ControlClicked + cmdBrowse.PerformClick() + End Sub + Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrInputExportFile.ControlContentsChanged, ucrAvailableSheets.ControlContentsChanged TestOkEnabled() End Sub diff --git a/instat/dlgExportGraphAsImage.vb b/instat/dlgExportGraphAsImage.vb index fedf36e8059..c78e64c2a41 100644 --- a/instat/dlgExportGraphAsImage.vb +++ b/instat/dlgExportGraphAsImage.vb @@ -97,6 +97,10 @@ Public Class dlgExportGraphAsImage End Using End Sub + Private Sub ucrInputFile_Click() Handles ucrInputFile.ControlClicked + cmdBrowse.PerformClick() + End Sub + Private Sub ucrCoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrSelectedGraphReceiver.ControlContentsChanged, ucrInputFile.ControlContentsChanged TestOkEnabled() End Sub diff --git a/instat/dlgExportRObjects.vb b/instat/dlgExportRObjects.vb index 0b2c03a8ded..f2447a9db8d 100644 --- a/instat/dlgExportRObjects.vb +++ b/instat/dlgExportRObjects.vb @@ -106,6 +106,10 @@ Public Class dlgExportRObjects End Using End Sub + Private Sub ucrInputExportFile_Click() Handles ucrInputExportFile.ControlClicked + cmdBrowse.PerformClick() + End Sub + Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverObjects.ControlContentsChanged, ucrSelectorObjects.ControlContentsChanged, ucrInputExportFile.ControlContentsChanged TestOkEnabled() End Sub diff --git a/instat/dlgExportRWorkspace.vb b/instat/dlgExportRWorkspace.vb index 744dad86c4a..9a48a862212 100644 --- a/instat/dlgExportRWorkspace.vb +++ b/instat/dlgExportRWorkspace.vb @@ -113,6 +113,10 @@ Public Class dlgExportRWorkspace End Using End Sub + Private Sub ucrInputExportFile_Click() Handles ucrInputExportFile.ControlClicked + cmdBrowse.PerformClick() + End Sub + Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrInputExportFile.ControlContentsChanged, ucrReceiverMultiple.ControlContentsChanged TestOkEnabled() End Sub diff --git a/instat/dlgSaveAs.vb b/instat/dlgSaveAs.vb index 66c3acde13d..ff1c23d6165 100644 --- a/instat/dlgSaveAs.vb +++ b/instat/dlgSaveAs.vb @@ -98,6 +98,10 @@ Public Class dlgSaveAs End Using End Sub + Private Sub ucrInputFilePath_Click() Handles ucrInputFilePath.ControlClicked + cmdChooseFile.PerformClick() + End Sub + Private Sub ucrInputFilePath_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrInputFilePath.ControlContentsChanged TestOKEnabled() End Sub From c45304efcdb5109748a7dd510e3312656c087bdd Mon Sep 17 00:00:00 2001 From: patowhiz Date: Mon, 10 Aug 2020 17:51:46 +0300 Subject: [PATCH 04/26] ucrInputFile Code addition, export dialogs code and dlgSaveAs dialogs code changes --- instat/dlgExportDataset.Designer.vb | 54 ++++----- instat/dlgExportDataset.resx | 142 +++++++---------------- instat/dlgExportDataset.vb | 58 +++------ instat/dlgExportGraphAsImage.Designer.vb | 39 +++---- instat/dlgExportGraphAsImage.resx | 87 +++----------- instat/dlgExportGraphAsImage.vb | 44 ++----- instat/dlgExportRObjects.Designer.vb | 42 +++---- instat/dlgExportRObjects.resx | 87 +++----------- instat/dlgExportRObjects.vb | 47 ++------ instat/dlgExportRWorkspace.Designer.vb | 42 +++---- instat/dlgExportRWorkspace.resx | 109 +++++------------ instat/dlgExportRWorkspace.vb | 49 +++----- instat/dlgSaveAs.Designer.vb | 49 +++----- instat/dlgSaveAs.resx | 137 ++++++++-------------- instat/dlgSaveAs.vb | 51 +++----- instat/ucrFilePath.Designer.vb | 17 +-- instat/ucrFilePath.vb | 99 +++++++++++++++- 17 files changed, 406 insertions(+), 747 deletions(-) diff --git a/instat/dlgExportDataset.Designer.vb b/instat/dlgExportDataset.Designer.vb index 43b0e9f22fb..329ffd47274 100644 --- a/instat/dlgExportDataset.Designer.vb +++ b/instat/dlgExportDataset.Designer.vb @@ -39,37 +39,16 @@ Partial Class dlgExportDataset _ Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(dlgExportDataset)) - Me.cmdBrowse = New System.Windows.Forms.Button() - Me.lblExport = New System.Windows.Forms.Label() - Me.lblConfirmText = New System.Windows.Forms.Label() - Me.ucrInputExportFile = New instat.ucrInputTextBox() + Me.lblConfirm = New System.Windows.Forms.Label() Me.ucrAvailableSheets = New instat.ucrDataFrame() Me.ucrBase = New instat.ucrButtons() + Me.ucrFilePath = New instat.ucrFilePath() Me.SuspendLayout() ' - 'cmdBrowse + 'lblConfirm ' - resources.ApplyResources(Me.cmdBrowse, "cmdBrowse") - Me.cmdBrowse.Name = "cmdBrowse" - Me.cmdBrowse.UseVisualStyleBackColor = True - ' - 'lblExport - ' - resources.ApplyResources(Me.lblExport, "lblExport") - Me.lblExport.Name = "lblExport" - ' - 'lblConfirmText - ' - resources.ApplyResources(Me.lblConfirmText, "lblConfirmText") - Me.lblConfirmText.Name = "lblConfirmText" - ' - 'ucrInputExportFile - ' - Me.ucrInputExportFile.AddQuotesIfUnrecognised = True - Me.ucrInputExportFile.IsMultiline = False - Me.ucrInputExportFile.IsReadOnly = True - resources.ApplyResources(Me.ucrInputExportFile, "ucrInputExportFile") - Me.ucrInputExportFile.Name = "ucrInputExportFile" + resources.ApplyResources(Me.lblConfirm, "lblConfirm") + Me.lblConfirm.Name = "lblConfirm" ' 'ucrAvailableSheets ' @@ -83,16 +62,25 @@ Partial Class dlgExportDataset resources.ApplyResources(Me.ucrBase, "ucrBase") Me.ucrBase.Name = "ucrBase" ' + 'ucrFilePath + ' + Me.ucrFilePath.DefaultFileSuggestionName = "" + Me.ucrFilePath.FilePath = "" + Me.ucrFilePath.FilePathBrowseText = "Browse" + Me.ucrFilePath.FilePathDialogFilter = resources.GetString("ucrFilePath.FilePathDialogFilter") + Me.ucrFilePath.FilePathDialogTitle = "Export Data File" + Me.ucrFilePath.FilePathLabel = "Export File:" + resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") + Me.ucrFilePath.Name = "ucrFilePath" + ' 'dlgExportDataset ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.Controls.Add(Me.lblConfirmText) - Me.Controls.Add(Me.cmdBrowse) - Me.Controls.Add(Me.ucrInputExportFile) + Me.Controls.Add(Me.ucrFilePath) + Me.Controls.Add(Me.lblConfirm) Me.Controls.Add(Me.ucrAvailableSheets) Me.Controls.Add(Me.ucrBase) - Me.Controls.Add(Me.lblExport) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False @@ -104,9 +92,7 @@ Partial Class dlgExportDataset End Sub Friend WithEvents ucrBase As ucrButtons - Friend WithEvents cmdBrowse As Button - Friend WithEvents lblExport As Label Friend WithEvents ucrAvailableSheets As ucrDataFrame - Friend WithEvents ucrInputExportFile As ucrInputTextBox - Friend WithEvents lblConfirmText As Label + Friend WithEvents lblConfirm As Label + Friend WithEvents ucrFilePath As ucrFilePath End Class diff --git a/instat/dlgExportDataset.resx b/instat/dlgExportDataset.resx index 2f9b99f15d9..10512276e8e 100644 --- a/instat/dlgExportDataset.resx +++ b/instat/dlgExportDataset.resx @@ -117,122 +117,44 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - NoControl - - - - 332, 55 - - - 75, 23 - - - 3 - - - Browse - - - cmdBrowse - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - NoControl - - - 9, 60 - - - 62, 13 - - - 1 - - - Export File: - - - lblExport - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 5 - - + True - + + NoControl - - 85, 85 + + + 85, 88 - + 2, 0, 2, 0 - + 148, 13 - + 4 - + Click Ok to Confirm the Export - - lblConfirmText + + lblConfirm - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 0 - - - 90, 56 - - - 6, 8, 6, 8 - - - 240, 21 - - - 2 - - - ucrInputExportFile - - - instat.ucrInputTextBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 2 + + 1 - 10, 10 + 10, 5 0, 0, 0, 0 @@ -253,7 +175,7 @@ $this - 3 + 2 8, 111 @@ -277,7 +199,31 @@ $this - 4 + 3 + + + Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html + + + 11, 54 + + + 403, 26 + + + 1 + + + ucrFilePath + + + instat.ucrFilePath, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 True @@ -289,7 +235,7 @@ True - 414, 165 + 421, 170 CenterScreen diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index ce995dfaa94..13a6df66c83 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -14,7 +14,6 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . -Imports System.IO Imports instat.Translations Public Class dlgExportDataset Dim bFirstLoad As Boolean = True @@ -36,22 +35,24 @@ Public Class dlgExportDataset End Sub Private Sub InitialiseDialog() - ucrInputExportFile.IsReadOnly = True + ucrAvailableSheets.SetParameter(New RParameter("x", 0)) ucrAvailableSheets.SetParameterIsRFunction() ucrAvailableSheets.SetText("Data Frame to Export:") - ucrInputExportFile.SetParameter(New RParameter("file", 1)) + ucrFilePath.SetPathControlParameter(New RParameter("file", 1)) - lblConfirmText.Text = "Click Ok to Confirm the Export" - lblConfirmText.ForeColor = Color.Red + lblConfirm.Visible = False + lblConfirm.ForeColor = Color.Green End Sub Private Sub SetDefaults() clsDefaultFunction = New RFunction - ucrInputExportFile.SetName("") ucrAvailableSheets.Reset() + ucrFilePath.ResetPathControl() + ucrFilePath.DefaultFileSuggestionName = ucrAvailableSheets.strCurrDataFrame 'set suggestive name from selected data frame + clsDefaultFunction.SetPackageName("rio") clsDefaultFunction.SetRCommand("export") @@ -59,22 +60,19 @@ Public Class dlgExportDataset End Sub Private Sub SetRCodeForControls(bReset As Boolean) - SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrAvailableSheets.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrFilePath.SetPathControlRcode(ucrBase.clsRsyntax.clsBaseFunction, bReset) End Sub Private Sub TestOkEnabled() - If Not ucrInputExportFile.IsEmpty AndAlso ucrAvailableSheets.cboAvailableDataFrames.Text <> "" Then - ucrBase.OKEnabled(True) - Else - ucrBase.OKEnabled(False) - End If - If Not ucrInputExportFile.IsEmpty() Then - lblConfirmText.Show() + If Not ucrFilePath.IsEmpty AndAlso Not String.IsNullOrEmpty(ucrAvailableSheets.strCurrDataFrame) Then ucrBase.OKEnabled(True) + lblConfirm.Visible = True Else - lblConfirmText.Hide() ucrBase.OKEnabled(False) + lblConfirm.Visible = False End If + End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset @@ -83,34 +81,14 @@ Public Class dlgExportDataset TestOkEnabled() End Sub - Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click - Dim strCurrentFilePathName As String = ucrInputExportFile.GetText() - Using dlgSave As New SaveFileDialog - dlgSave.Title = "Export File Dialog" - dlgSave.Filter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html" - If String.IsNullOrEmpty(strCurrentFilePathName) Then - dlgSave.FileName = ucrAvailableSheets.strCurrDataFrame - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - Else - dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) - dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) - End If - If dlgSave.ShowDialog = DialogResult.OK Then - ucrInputExportFile.SetName(dlgSave.FileName.Replace("\", "/")) - strCurrentFilePathName = dlgSave.FileName - End If - End Using + Private Sub ucrAvailableSheets_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrAvailableSheets.ControlValueChanged + 'give a suggestive name from selected data frame + ucrFilePath.DefaultFileSuggestionName = ucrAvailableSheets.strCurrDataFrame + ucrFilePath.Clear() 'clears the file path contents. End Sub - Private Sub ucrInputExportFile_Click() Handles ucrInputExportFile.ControlClicked - cmdBrowse.PerformClick() - End Sub - - Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrInputExportFile.ControlContentsChanged, ucrAvailableSheets.ControlContentsChanged + Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged TestOkEnabled() End Sub - Private Sub ucrAvailableSheets_DataFrameChanged(sender As Object, e As EventArgs, strPrevDataFrame As String) Handles ucrAvailableSheets.DataFrameChanged - ucrInputExportFile.SetName("") 'clears the ucrinput contents. - End Sub End Class \ No newline at end of file diff --git a/instat/dlgExportGraphAsImage.Designer.vb b/instat/dlgExportGraphAsImage.Designer.vb index 47641fd28b7..16046ebbab2 100644 --- a/instat/dlgExportGraphAsImage.Designer.vb +++ b/instat/dlgExportGraphAsImage.Designer.vb @@ -40,12 +40,10 @@ Partial Class dlgExportGraphAsImage Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(dlgExportGraphAsImage)) Me.lblSelectedGraph = New System.Windows.Forms.Label() - Me.cmdBrowse = New System.Windows.Forms.Button() Me.ucrSelectedGraphReceiver = New instat.ucrReceiverSingle() Me.ucrSelectorGraphAsImage = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() - Me.lblExport = New System.Windows.Forms.Label() - Me.ucrInputFile = New instat.ucrInputTextBox() + Me.ucrFilePath = New instat.ucrFilePath() Me.SuspendLayout() ' 'lblSelectedGraph @@ -53,12 +51,6 @@ Partial Class dlgExportGraphAsImage resources.ApplyResources(Me.lblSelectedGraph, "lblSelectedGraph") Me.lblSelectedGraph.Name = "lblSelectedGraph" ' - 'cmdBrowse - ' - resources.ApplyResources(Me.cmdBrowse, "cmdBrowse") - Me.cmdBrowse.Name = "cmdBrowse" - Me.cmdBrowse.UseVisualStyleBackColor = True - ' 'ucrSelectedGraphReceiver ' Me.ucrSelectedGraphReceiver.frmParent = Me @@ -81,26 +73,23 @@ Partial Class dlgExportGraphAsImage resources.ApplyResources(Me.ucrBase, "ucrBase") Me.ucrBase.Name = "ucrBase" ' - 'lblExport - ' - resources.ApplyResources(Me.lblExport, "lblExport") - Me.lblExport.Name = "lblExport" - ' - 'ucrInputFile + 'ucrFilePath ' - Me.ucrInputFile.AddQuotesIfUnrecognised = True - Me.ucrInputFile.IsMultiline = False - Me.ucrInputFile.IsReadOnly = True - resources.ApplyResources(Me.ucrInputFile, "ucrInputFile") - Me.ucrInputFile.Name = "ucrInputFile" + Me.ucrFilePath.DefaultFileSuggestionName = "" + Me.ucrFilePath.FilePath = "" + Me.ucrFilePath.FilePathBrowseText = "Browse" + Me.ucrFilePath.FilePathDialogFilter = "JPEG (*.jpeg)|*.jpeg|PNG(*.png)|*.png|BitMaP(*.bmp)|*.bmp|EPS(*.eps)|*.eps|PostSc" & + "ript(*.ps)|*.ps|SVG(*.svg)|*.svg|WMF(*.wmf)|*.wmf|PDF(*.pdf)|*.pdf" + Me.ucrFilePath.FilePathDialogTitle = "Save Graph As Image" + Me.ucrFilePath.FilePathLabel = "Export File:" + resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") + Me.ucrFilePath.Name = "ucrFilePath" ' 'dlgExportGraphAsImage ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.Controls.Add(Me.ucrInputFile) - Me.Controls.Add(Me.lblExport) - Me.Controls.Add(Me.cmdBrowse) + Me.Controls.Add(Me.ucrFilePath) Me.Controls.Add(Me.lblSelectedGraph) Me.Controls.Add(Me.ucrSelectedGraphReceiver) Me.Controls.Add(Me.ucrSelectorGraphAsImage) @@ -117,8 +106,6 @@ Partial Class dlgExportGraphAsImage Friend WithEvents ucrBase As ucrButtons Friend WithEvents ucrSelectorGraphAsImage As ucrSelectorByDataFrameAddRemove Friend WithEvents ucrSelectedGraphReceiver As ucrReceiverSingle - Friend WithEvents cmdBrowse As Button Friend WithEvents lblSelectedGraph As Label - Friend WithEvents lblExport As Label - Friend WithEvents ucrInputFile As ucrInputTextBox + Friend WithEvents ucrFilePath As ucrFilePath End Class diff --git a/instat/dlgExportGraphAsImage.resx b/instat/dlgExportGraphAsImage.resx index 82405cc125e..97ca7543720 100644 --- a/instat/dlgExportGraphAsImage.resx +++ b/instat/dlgExportGraphAsImage.resx @@ -144,31 +144,7 @@ $this - 3 - - - 334, 194 - - - 75, 23 - - - 5 - - - Browse - - - cmdBrowse - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 + 1 True @@ -182,58 +158,31 @@ 418, 280 - - 92, 195 - - - - 6, 8, 6, 8 + + 14, 195 - - 240, 21 + + 400, 26 - - 4 + + 7 - - ucrInputFile + + ucrFilePath - - instat.ucrInputTextBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + instat.ucrFilePath, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - + $this - + 0 - - 9, 199 - - - 64, 13 - - - 3 - - - Export File: - - - lblExport - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - 10, 10 + 0, 0, 0, 0 @@ -253,10 +202,10 @@ $this - 5 + 3 - 10, 223 + 10, 224 4, 5, 4, 5 @@ -277,7 +226,7 @@ $this - 6 + 4 CenterScreen @@ -313,6 +262,6 @@ $this - 4 + 2 \ No newline at end of file diff --git a/instat/dlgExportGraphAsImage.vb b/instat/dlgExportGraphAsImage.vb index c78e64c2a41..ba0772ca2c2 100644 --- a/instat/dlgExportGraphAsImage.vb +++ b/instat/dlgExportGraphAsImage.vb @@ -14,7 +14,6 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . -Imports System.IO Imports instat.Translations Public Class dlgExportGraphAsImage Private bFirstload As Boolean = True @@ -37,7 +36,8 @@ Public Class dlgExportGraphAsImage Private Sub InitialiseDialog() ucrBase.iHelpTopicID = 556 - ucrInputFile.SetParameter(New RParameter("filename", 0)) + + ucrFilePath.SetPathControlParameter(New RParameter("filename", 0)) ucrSelectedGraphReceiver.SetParameter(New RParameter("plot", 1)) ucrSelectedGraphReceiver.SetParameterIsRFunction() @@ -51,9 +51,8 @@ Public Class dlgExportGraphAsImage Private Sub SetDefaults() clsggSave = New RFunction - ucrInputFile.Reset() ucrSelectorGraphAsImage.Reset() - ucrInputFile.SetName("") + ucrFilePath.ResetPathControl() clsggSave.SetPackageName("ggplot2") clsggSave.SetRCommand("ggsave") @@ -61,15 +60,12 @@ Public Class dlgExportGraphAsImage End Sub Private Sub SetRCodeForControls(bReset As Boolean) - SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrSelectorGraphAsImage.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrFilePath.SetPathControlRcode(ucrBase.clsRsyntax.clsBaseFunction, bReset) End Sub Private Sub TestOkEnabled() - If Not ucrSelectedGraphReceiver.IsEmpty AndAlso Not ucrInputFile.IsEmpty Then - ucrBase.OKEnabled(True) - Else - ucrBase.OKEnabled(False) - End If + ucrBase.OKEnabled(Not ucrSelectedGraphReceiver.IsEmpty AndAlso Not ucrFilePath.IsEmpty) End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset @@ -78,30 +74,14 @@ Public Class dlgExportGraphAsImage TestOkEnabled() End Sub - Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click - Dim strCurrentFilePathName As String = ucrInputFile.GetText() - Using dlgSave As New SaveFileDialog - dlgSave.Title = "Save Graph As Image" - dlgSave.Filter = "JPEG (*.jpeg)|*.jpeg|PNG(*.png)|*.png|BitMaP(*.bmp)|*.bmp|EPS(*.eps)|*.eps|PostScript(*.ps)|*.ps|SVG(*.svg)|*.svg|WMF(*.wmf)|*.wmf|PDF(*.pdf)|*.pdf" - If String.IsNullOrEmpty(strCurrentFilePathName) Then - dlgSave.FileName = ucrSelectedGraphReceiver.GetVariableNames(bWithQuotes:=False) 'give a suggestive name (from the reciver) - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - Else - strCurrentFilePathName = strCurrentFilePathName.Replace("/", "\") - dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) - dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) 'use the previous path as initial dir - End If - If DialogResult.OK = dlgSave.ShowDialog() Then - ucrInputFile.SetName(dlgSave.FileName.Replace("\", "/")) 'R uses / slashes for file paths. so \ needs to be replaced - End If - End Using - End Sub - - Private Sub ucrInputFile_Click() Handles ucrInputFile.ControlClicked - cmdBrowse.PerformClick() + Private Sub ucrCoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrSelectedGraphReceiver.ControlContentsChanged + 'give a suggestive name from the receiver + ucrFilePath.DefaultFileSuggestionName = ucrSelectedGraphReceiver.GetVariableNames(bWithQuotes:=False) + TestOkEnabled() End Sub - Private Sub ucrCoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrSelectedGraphReceiver.ControlContentsChanged, ucrInputFile.ControlContentsChanged + Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged TestOkEnabled() End Sub + End Class \ No newline at end of file diff --git a/instat/dlgExportRObjects.Designer.vb b/instat/dlgExportRObjects.Designer.vb index 4024a34ecb2..3e2bc5a8b8a 100644 --- a/instat/dlgExportRObjects.Designer.vb +++ b/instat/dlgExportRObjects.Designer.vb @@ -19,7 +19,7 @@ Partial Class dlgExportRObjects Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -36,16 +36,14 @@ Partial Class dlgExportRObjects '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 Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(dlgExportRObjects)) Me.lblObjects = New System.Windows.Forms.Label() Me.ucrReceiverObjects = New instat.ucrReceiverMultiple() Me.ucrSelectorObjects = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() - Me.ucrInputExportFile = New instat.ucrInputTextBox() - Me.lblExportFile = New System.Windows.Forms.Label() - Me.cmdBrowse = New System.Windows.Forms.Button() + Me.ucrFilePath = New instat.ucrFilePath() Me.SuspendLayout() ' 'lblObjects @@ -75,32 +73,22 @@ Partial Class dlgExportRObjects resources.ApplyResources(Me.ucrBase, "ucrBase") Me.ucrBase.Name = "ucrBase" ' - 'ucrInputExportFile + 'ucrFilePath ' - Me.ucrInputExportFile.AddQuotesIfUnrecognised = True - Me.ucrInputExportFile.IsMultiline = False - Me.ucrInputExportFile.IsReadOnly = False - resources.ApplyResources(Me.ucrInputExportFile, "ucrInputExportFile") - Me.ucrInputExportFile.Name = "ucrInputExportFile" - ' - 'lblExportFile - ' - resources.ApplyResources(Me.lblExportFile, "lblExportFile") - Me.lblExportFile.Name = "lblExportFile" - ' - 'cmdBrowse - ' - resources.ApplyResources(Me.cmdBrowse, "cmdBrowse") - Me.cmdBrowse.Name = "cmdBrowse" - Me.cmdBrowse.UseVisualStyleBackColor = True + Me.ucrFilePath.DefaultFileSuggestionName = "" + Me.ucrFilePath.FilePath = "" + Me.ucrFilePath.FilePathBrowseText = "Browse" + Me.ucrFilePath.FilePathDialogFilter = "Serialized R Objects (*.rds)|*.rds" + Me.ucrFilePath.FilePathDialogTitle = "Export R Objects" + Me.ucrFilePath.FilePathLabel = "Export File:" + resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") + Me.ucrFilePath.Name = "ucrFilePath" ' 'dlgExportRObjects ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.Controls.Add(Me.ucrInputExportFile) - Me.Controls.Add(Me.cmdBrowse) - Me.Controls.Add(Me.lblExportFile) + Me.Controls.Add(Me.ucrFilePath) Me.Controls.Add(Me.lblObjects) Me.Controls.Add(Me.ucrReceiverObjects) Me.Controls.Add(Me.ucrSelectorObjects) @@ -117,7 +105,5 @@ Partial Class dlgExportRObjects Friend WithEvents ucrSelectorObjects As ucrSelectorByDataFrameAddRemove Friend WithEvents ucrReceiverObjects As ucrReceiverMultiple Friend WithEvents lblObjects As Label - Friend WithEvents ucrInputExportFile As ucrInputTextBox - Friend WithEvents lblExportFile As Label - Friend WithEvents cmdBrowse As Button + Friend WithEvents ucrFilePath As ucrFilePath End Class diff --git a/instat/dlgExportRObjects.resx b/instat/dlgExportRObjects.resx index ebc04a49472..2a759e88330 100644 --- a/instat/dlgExportRObjects.resx +++ b/instat/dlgExportRObjects.resx @@ -144,7 +144,7 @@ $this - 3 + 1 True @@ -153,84 +153,33 @@ 6, 13 - 420, 288 + 417, 288 - - 92, 204 + + 14, 199 - - - 6, 8, 6, 8 + + 394, 26 - - 240, 23 - - - 4 + + 7 - - ucrInputExportFile + + ucrFilePath - - instat.ucrInputTextBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + instat.ucrFilePath, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - + $this - + 0 - - 333, 203 - - - 75, 23 - - - 5 - - - Browse - - - cmdBrowse - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - 9, 206 - - - 65, 13 - - - 3 - - - Export File: - - - lblExportFile - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - 10, 10 + 0, 0, 0, 0 @@ -250,7 +199,7 @@ $this - 5 + 3 10, 232 @@ -274,7 +223,7 @@ $this - 6 + 4 CenterScreen @@ -310,6 +259,6 @@ $this - 4 + 2 \ No newline at end of file diff --git a/instat/dlgExportRObjects.vb b/instat/dlgExportRObjects.vb index f2447a9db8d..7e9c7e2d77c 100644 --- a/instat/dlgExportRObjects.vb +++ b/instat/dlgExportRObjects.vb @@ -14,7 +14,6 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . -Imports System.IO Imports instat.Translations Public Class dlgExportRObjects Private bFirstLoad As Boolean = True @@ -48,16 +47,17 @@ Public Class dlgExportRObjects ucrReceiverObjects.strSelectorHeading = "Objects" ucrReceiverObjects.SetItemType("object") - ucrInputExportFile.SetParameter(New RParameter("file", 0)) - ucrInputExportFile.IsReadOnly = True + ucrFilePath.SetPathControlParameter(New RParameter("file", 0)) + End Sub Private Sub SetDefaults() clsGetObjectsFunction = New RFunction clsSaveRDS = New RFunction - ucrInputExportFile.SetName("") ucrSelectorObjects.Reset() + ucrFilePath.ResetPathControl() + clsGetObjectsFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_objects") clsSaveRDS.SetRCommand("saveRDS") clsSaveRDS.AddParameter("object", clsRFunctionParameter:=clsGetObjectsFunction) @@ -67,15 +67,11 @@ Public Class dlgExportRObjects Private Sub SetRCodeForControls(bReset As Boolean) ucrSelectorObjects.SetRCode(clsGetObjectsFunction, bReset) ucrReceiverObjects.SetRCode(clsGetObjectsFunction, bReset) - ucrInputExportFile.SetRCode(clsSaveRDS, bReset) + ucrFilePath.SetPathControlRcode(clsSaveRDS, bReset) End Sub Private Sub TestOkEnabled() - If Not ucrInputExportFile.IsEmpty AndAlso Not ucrReceiverObjects.IsEmpty AndAlso ucrSelectorObjects.ucrAvailableDataFrames.cboAvailableDataFrames.Text <> "" Then - ucrBase.OKEnabled(True) - Else - ucrBase.OKEnabled(False) - End If + ucrBase.OKEnabled(Not ucrFilePath.IsEmpty AndAlso Not ucrReceiverObjects.IsEmpty AndAlso Not String.IsNullOrEmpty(ucrSelectorObjects.strCurrentDataFrame)) End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset @@ -84,33 +80,14 @@ Public Class dlgExportRObjects TestOkEnabled() End Sub - Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click - Dim strCurrentFilePathName As String = ucrInputExportFile.GetText() - Using dlgSave As New SaveFileDialog - dlgSave.Title = "Export R Objects" - dlgSave.Filter = "Serialized R Objects (*.rds)|*.rds" - If String.IsNullOrEmpty(strCurrentFilePathName) Then - 'ucrReceiverObjects is a multireceiver. So give a suggestive name if it has 1 item only - If ucrReceiverObjects.GetVariableNamesList().Length = 1 Then - dlgSave.FileName = ucrReceiverObjects.GetVariableNames(bWithQuotes:=False) - End If - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - Else - strCurrentFilePathName = strCurrentFilePathName.Replace("/", "\") - dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) - dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) 'use the previous path as initial dir - End If - If DialogResult.OK = dlgSave.ShowDialog() Then - ucrInputExportFile.SetName(dlgSave.FileName.Replace("\", "/")) 'R uses / slashes for file paths. so \ needs to be replaced - End If - End Using - End Sub - - Private Sub ucrInputExportFile_Click() Handles ucrInputExportFile.ControlClicked - cmdBrowse.PerformClick() + Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverObjects.ControlContentsChanged, ucrSelectorObjects.ControlContentsChanged + 'ucrReceiverObjects is a multireceiver. So give a suggestive name if it has 1 item only + ucrFilePath.DefaultFileSuggestionName = If(ucrReceiverObjects.GetVariableNamesList().Length = 1, ucrReceiverObjects.GetVariableNames(bWithQuotes:=False), "") + TestOkEnabled() End Sub - Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverObjects.ControlContentsChanged, ucrSelectorObjects.ControlContentsChanged, ucrInputExportFile.ControlContentsChanged + Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged TestOkEnabled() End Sub + End Class \ No newline at end of file diff --git a/instat/dlgExportRWorkspace.Designer.vb b/instat/dlgExportRWorkspace.Designer.vb index aa0dd3eace7..ee90b80096d 100644 --- a/instat/dlgExportRWorkspace.Designer.vb +++ b/instat/dlgExportRWorkspace.Designer.vb @@ -39,30 +39,17 @@ Partial Class dlgExportRWorkspace _ Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(dlgExportRWorkspace)) - Me.cmdBrowse = New System.Windows.Forms.Button() - Me.lblExport = New System.Windows.Forms.Label() Me.lblDataFrames = New System.Windows.Forms.Label() Me.lblSelectedDataFrames = New System.Windows.Forms.Label() Me.ucrSelectorForDataFrames = New instat.ucrSelectorAddRemove() - Me.ucrInputExportFile = New instat.ucrInputTextBox() Me.ucrChkGraphs = New instat.ucrCheck() Me.ucrChkModels = New instat.ucrCheck() Me.ucrChkMetadata = New instat.ucrCheck() Me.ucrReceiverMultiple = New instat.ucrReceiverMultiple() Me.ucrBase = New instat.ucrButtons() + Me.ucrFilePath = New instat.ucrFilePath() Me.SuspendLayout() ' - 'cmdBrowse - ' - resources.ApplyResources(Me.cmdBrowse, "cmdBrowse") - Me.cmdBrowse.Name = "cmdBrowse" - Me.cmdBrowse.UseVisualStyleBackColor = True - ' - 'lblExport - ' - resources.ApplyResources(Me.lblExport, "lblExport") - Me.lblExport.Name = "lblExport" - ' 'lblDataFrames ' resources.ApplyResources(Me.lblDataFrames, "lblDataFrames") @@ -79,14 +66,6 @@ Partial Class dlgExportRWorkspace resources.ApplyResources(Me.ucrSelectorForDataFrames, "ucrSelectorForDataFrames") Me.ucrSelectorForDataFrames.Name = "ucrSelectorForDataFrames" ' - 'ucrInputExportFile - ' - Me.ucrInputExportFile.AddQuotesIfUnrecognised = True - Me.ucrInputExportFile.IsMultiline = False - Me.ucrInputExportFile.IsReadOnly = False - resources.ApplyResources(Me.ucrInputExportFile, "ucrInputExportFile") - Me.ucrInputExportFile.Name = "ucrInputExportFile" - ' 'ucrChkGraphs ' Me.ucrChkGraphs.Checked = False @@ -119,15 +98,24 @@ Partial Class dlgExportRWorkspace resources.ApplyResources(Me.ucrBase, "ucrBase") Me.ucrBase.Name = "ucrBase" ' + 'ucrFilePath + ' + Me.ucrFilePath.DefaultFileSuggestionName = "" + Me.ucrFilePath.FilePath = "" + Me.ucrFilePath.FilePathBrowseText = "Browse" + Me.ucrFilePath.FilePathDialogFilter = "Saved R Objects (*.RData)|*.RData" + Me.ucrFilePath.FilePathDialogTitle = "Export R Workspace" + Me.ucrFilePath.FilePathLabel = "Export File:" + resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") + Me.ucrFilePath.Name = "ucrFilePath" + ' 'dlgExportRWorkspace ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.ucrFilePath) Me.Controls.Add(Me.lblSelectedDataFrames) Me.Controls.Add(Me.lblDataFrames) - Me.Controls.Add(Me.ucrInputExportFile) - Me.Controls.Add(Me.cmdBrowse) - Me.Controls.Add(Me.lblExport) Me.Controls.Add(Me.ucrChkGraphs) Me.Controls.Add(Me.ucrChkModels) Me.Controls.Add(Me.ucrChkMetadata) @@ -148,10 +136,8 @@ Partial Class dlgExportRWorkspace Friend WithEvents ucrChkGraphs As ucrCheck Friend WithEvents ucrChkModels As ucrCheck Friend WithEvents ucrChkMetadata As ucrCheck - Friend WithEvents ucrInputExportFile As ucrInputTextBox - Friend WithEvents cmdBrowse As Button - Friend WithEvents lblExport As Label Friend WithEvents lblDataFrames As Label Friend WithEvents lblSelectedDataFrames As Label Friend WithEvents ucrSelectorForDataFrames As ucrSelectorAddRemove + Friend WithEvents ucrFilePath As ucrFilePath End Class diff --git a/instat/dlgExportRWorkspace.resx b/instat/dlgExportRWorkspace.resx index 18b37b31a32..fa840261ae5 100644 --- a/instat/dlgExportRWorkspace.resx +++ b/instat/dlgExportRWorkspace.resx @@ -117,59 +117,11 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 333, 247 - - - 75, 23 - - - 9 - - - Browse - - - cmdBrowse - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - 9, 251 - - - 60, 13 - - - 7 - - - Export File: - - - lblExport - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 4 - True + 10, 15 @@ -192,7 +144,7 @@ $this - 1 + 2 True @@ -219,7 +171,7 @@ $this - 0 + 1 10, 30 @@ -244,32 +196,8 @@ $this - 10 - - - 92, 248 - - - 6, 8, 6, 8 - - - 240, 23 - - 8 - - ucrInputExportFile - - - instat.ucrInputTextBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 2 - 10, 193 @@ -292,7 +220,7 @@ $this - 5 + 3 10, 219 @@ -316,7 +244,7 @@ $this - 6 + 4 10, 167 @@ -340,7 +268,7 @@ $this - 7 + 5 True @@ -354,6 +282,27 @@ 417, 335 + + 14, 245 + + + 400, 26 + + + 11 + + + ucrFilePath + + + instat.ucrFilePath, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + 10, 278 @@ -376,7 +325,7 @@ $this - 9 + 7 CenterScreen @@ -412,6 +361,6 @@ $this - 8 + 6 \ No newline at end of file diff --git a/instat/dlgExportRWorkspace.vb b/instat/dlgExportRWorkspace.vb index 9a48a862212..9da0ecddc5f 100644 --- a/instat/dlgExportRWorkspace.vb +++ b/instat/dlgExportRWorkspace.vb @@ -14,7 +14,6 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . -Imports System.IO Imports instat.Translations Public Class dlgExportRWorkspace Private bFirstLoad As Boolean = True @@ -36,7 +35,6 @@ Public Class dlgExportRWorkspace Private Sub InitialiseDialog() ucrBase.iHelpTopicID = 555 - ucrInputExportFile.IsReadOnly = True ucrReceiverMultiple.SetParameter(New RParameter("data_names", 0)) ucrReceiverMultiple.SetParameterIsString() @@ -44,7 +42,7 @@ Public Class dlgExportRWorkspace ucrReceiverMultiple.strSelectorHeading = "Data Frames" ucrReceiverMultiple.SetItemType("dataframe") - ucrInputExportFile.SetParameter(New RParameter("file", 1)) + ucrFilePath.SetPathControlParameter(New RParameter("file", 1)) ucrChkMetadata.SetParameter(New RParameter("include_metadata", 2)) ucrChkMetadata.SetText("Include Metadata") @@ -65,7 +63,7 @@ Public Class dlgExportRWorkspace Private Sub SetDefaults() clsDefaultFunction = New RFunction - ucrInputExportFile.SetName("") + ucrFilePath.ResetPathControl() ucrSelectorForDataFrames.Reset() ucrReceiverMultiple.SetMeAsReceiver() @@ -74,15 +72,16 @@ Public Class dlgExportRWorkspace End Sub Private Sub SetRCodeForControls(bReset As Boolean) - SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, bReset) + 'ucrSelectorForDataFrames.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) 'todo. check if needed + ucrReceiverMultiple.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrChkMetadata.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrChkGraphs.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrChkModels.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrFilePath.SetPathControlRcode(ucrBase.clsRsyntax.clsBaseFunction, bReset) End Sub Private Sub TestOkEnabled() - If Not ucrInputExportFile.IsEmpty AndAlso Not ucrReceiverMultiple.IsEmpty Then - ucrBase.OKEnabled(True) - Else - ucrBase.OKEnabled(False) - End If + ucrBase.OKEnabled(Not ucrFilePath.IsEmpty AndAlso Not ucrReceiverMultiple.IsEmpty) End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset @@ -91,33 +90,13 @@ Public Class dlgExportRWorkspace TestOkEnabled() End Sub - Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click - Dim strCurrentFilePathName As String = ucrInputExportFile.GetText() - Using dlgSave As New SaveFileDialog - dlgSave.Title = "Export R Workspace" - dlgSave.Filter = "Saved R Objects (*.RData)|*.RData" - If String.IsNullOrEmpty(strCurrentFilePathName) Then - 'ucrReceiverMultiple is a multireceiver. So give a suggestive name if it has 1 item only - If ucrReceiverMultiple.GetVariableNamesList().Length = 1 Then - dlgSave.FileName = ucrReceiverMultiple.GetVariableNames(bWithQuotes:=False) - End If - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - Else - strCurrentFilePathName = strCurrentFilePathName.Replace("/", "\") - dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) - dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) 'use the previous path as initial dir - End If - If DialogResult.OK = dlgSave.ShowDialog() Then - ucrInputExportFile.SetName(dlgSave.FileName.Replace("\", "/")) 'R uses / slashes for file paths. so \ needs to be replaced - End If - End Using - End Sub - - Private Sub ucrInputExportFile_Click() Handles ucrInputExportFile.ControlClicked - cmdBrowse.PerformClick() + Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultiple.ControlContentsChanged + 'ucrReceiverMultiple is a multireceiver. So give a suggestive name if it has 1 item only + ucrFilePath.DefaultFileSuggestionName = If(ucrReceiverMultiple.GetVariableNamesList().Length = 1, ucrReceiverMultiple.GetVariableNames(bWithQuotes:=False), "") + TestOkEnabled() End Sub - Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrInputExportFile.ControlContentsChanged, ucrReceiverMultiple.ControlContentsChanged + Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged TestOkEnabled() End Sub End Class \ No newline at end of file diff --git a/instat/dlgSaveAs.Designer.vb b/instat/dlgSaveAs.Designer.vb index 5dae51a9efc..fc7dfd91955 100644 --- a/instat/dlgSaveAs.Designer.vb +++ b/instat/dlgSaveAs.Designer.vb @@ -39,50 +39,37 @@ Partial Class dlgSaveAs Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(dlgSaveAs)) - Me.ucrBase = New instat.ucrButtons() - Me.lblSaveDataTo = New System.Windows.Forms.Label() - Me.ucrInputFilePath = New instat.ucrInputTextBox() - Me.cmdChooseFile = New System.Windows.Forms.Button() Me.lblConfirm = New System.Windows.Forms.Label() + Me.ucrBase = New instat.ucrButtons() + Me.ucrFilePath = New instat.ucrFilePath() Me.SuspendLayout() ' + 'lblConfirm + ' + resources.ApplyResources(Me.lblConfirm, "lblConfirm") + Me.lblConfirm.Name = "lblConfirm" + ' 'ucrBase ' resources.ApplyResources(Me.ucrBase, "ucrBase") Me.ucrBase.Name = "ucrBase" ' - 'lblSaveDataTo - ' - resources.ApplyResources(Me.lblSaveDataTo, "lblSaveDataTo") - Me.lblSaveDataTo.Name = "lblSaveDataTo" + 'ucrFilePath ' - 'ucrInputFilePath - ' - Me.ucrInputFilePath.AddQuotesIfUnrecognised = True - Me.ucrInputFilePath.IsMultiline = False - Me.ucrInputFilePath.IsReadOnly = False - resources.ApplyResources(Me.ucrInputFilePath, "ucrInputFilePath") - Me.ucrInputFilePath.Name = "ucrInputFilePath" - ' - 'cmdChooseFile - ' - resources.ApplyResources(Me.cmdChooseFile, "cmdChooseFile") - Me.cmdChooseFile.Name = "cmdChooseFile" - Me.cmdChooseFile.UseVisualStyleBackColor = True - ' - 'lblConfirm - ' - resources.ApplyResources(Me.lblConfirm, "lblConfirm") - Me.lblConfirm.Name = "lblConfirm" + Me.ucrFilePath.FilePath = "" + Me.ucrFilePath.FilePathBrowseText = "Browse" + Me.ucrFilePath.FilePathDialogFilter = "RDS Data file (*.RDS)|*.RDS" + Me.ucrFilePath.FilePathDialogTitle = "Save Data File" + Me.ucrFilePath.FilePathLabel = "Save Data To:" + resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") + Me.ucrFilePath.Name = "ucrFilePath" ' 'dlgSaveAs ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.ucrFilePath) Me.Controls.Add(Me.lblConfirm) - Me.Controls.Add(Me.ucrInputFilePath) - Me.Controls.Add(Me.lblSaveDataTo) - Me.Controls.Add(Me.cmdChooseFile) Me.Controls.Add(Me.ucrBase) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False @@ -95,8 +82,6 @@ Partial Class dlgSaveAs End Sub Friend WithEvents ucrBase As ucrButtons - Friend WithEvents lblSaveDataTo As Label - Friend WithEvents ucrInputFilePath As ucrInputTextBox - Friend WithEvents cmdChooseFile As Button Friend WithEvents lblConfirm As Label + Friend WithEvents ucrFilePath As ucrFilePath End Class diff --git a/instat/dlgSaveAs.resx b/instat/dlgSaveAs.resx index 3730341a6b5..7e6cf3c407a 100644 --- a/instat/dlgSaveAs.resx +++ b/instat/dlgSaveAs.resx @@ -117,18 +117,48 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + + NoControl + + + 96, 40 + + + 140, 13 + + + 3 + + + Click Ok to confirm the save + + + lblConfirm + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + - 10, 55 + 10, 63 - 4, 5, 4, 5 410, 53 - 4 @@ -142,102 +172,27 @@ $this - 4 - - - 9, 20 - - - 78, 13 - - - 0 - - - Save Data To: - - - lblSaveDataTo - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - 2 - - 91, 17 + + 10, 9 - - 6, 8, 6, 8 + + 419, 26 - - 316, 21 + + 7 - - 1 + + ucrFilePath - - ucrInputFilePath + + instat.ucrFilePath, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - instat.ucrInputTextBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - + $this - - 1 - - - 409, 17 - - - 65, 21 - - - 2 - - - Browse - - - cmdChooseFile - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - True - - - 96, 45 - - - 0, 13 - - - 3 - - - lblConfirm - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - + 0 @@ -247,7 +202,7 @@ 6, 13 - 475, 110 + 430, 124 CenterScreen diff --git a/instat/dlgSaveAs.vb b/instat/dlgSaveAs.vb index ff1c23d6165..e71158b5fc7 100644 --- a/instat/dlgSaveAs.vb +++ b/instat/dlgSaveAs.vb @@ -14,7 +14,6 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . -Imports System.IO Imports instat.Translations Public Class dlgSaveAs Private bFirstLoad As Boolean = True @@ -37,17 +36,16 @@ Public Class dlgSaveAs Private Sub InitialiseDialog() ucrBase.iHelpTopicID = 332 - ucrInputFilePath.SetParameter(New RParameter("file", 0)) - ucrInputFilePath.IsReadOnly = True + ucrFilePath.SetPathControlParameter(New RParameter("file", 0)) - lblConfirm.Text = "Click Ok to confirm the save" + lblConfirm.Visible = False + lblConfirm.ForeColor = Color.Green End Sub Private Sub SetDefaults() clsSaveFunction = New RFunction - ucrInputFilePath.Reset() - ucrInputFilePath.SetName("") + ucrFilePath.ResetPathControl() clsSaveFunction.SetRCommand("saveRDS") clsSaveFunction.AddParameter("object", frmMain.clsRLink.strInstatDataObject) @@ -56,17 +54,17 @@ Public Class dlgSaveAs End Sub Private Sub SetRCodeForControls(bReset As Boolean) - SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrFilePath.SetPathControlRcode(ucrBase.clsRsyntax.clsBaseFunction, bReset) TestOKEnabled() End Sub Private Sub TestOKEnabled() - If Not ucrInputFilePath.IsEmpty() Then - lblConfirm.Show() - ucrBase.OKEnabled(True) - Else - lblConfirm.Hide() + If ucrFilePath.IsEmpty() Then + lblConfirm.Visible = False ucrBase.OKEnabled(False) + Else + lblConfirm.Visible = True + ucrBase.OKEnabled(True) End If End Sub @@ -76,33 +74,12 @@ Public Class dlgSaveAs End Sub Private Sub ucrBase_ClickOk(sender As Object, e As EventArgs) Handles ucrBase.ClickOk - frmMain.strSaveFilePath = ucrInputFilePath.GetText() - frmMain.clsRecentItems.addToMenu(Replace(ucrInputFilePath.GetText(), "/", "\")) + frmMain.strSaveFilePath = ucrFilePath.FilePath + frmMain.clsRecentItems.addToMenu(Replace(ucrFilePath.FilePath, "/", "\")) End Sub - Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdChooseFile.Click - Dim strCurrentFilePathName As String = ucrInputFilePath.GetText() - Using dlgSave As New SaveFileDialog - dlgSave.Title = "Save Data File" - dlgSave.Filter = "RDS Data file (*.RDS)|*.RDS" - If String.IsNullOrEmpty(strCurrentFilePathName) Then - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - Else - strCurrentFilePathName = strCurrentFilePathName.Replace("/", "\") - dlgSave.FileName = Path.GetFileName(strCurrentFilePathName) - dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFilePathName) - End If - If DialogResult.OK = dlgSave.ShowDialog() Then - ucrInputFilePath.SetName(dlgSave.FileName.Replace("\", "/")) - End If - End Using - End Sub - - Private Sub ucrInputFilePath_Click() Handles ucrInputFilePath.ControlClicked - cmdChooseFile.PerformClick() - End Sub - - Private Sub ucrInputFilePath_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrInputFilePath.ControlContentsChanged + Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged TestOKEnabled() End Sub + End Class diff --git a/instat/ucrFilePath.Designer.vb b/instat/ucrFilePath.Designer.vb index 6495abe1bf8..3769d36ee24 100644 --- a/instat/ucrFilePath.Designer.vb +++ b/instat/ucrFilePath.Designer.vb @@ -45,23 +45,24 @@ Partial Class ucrFilePath 'ucrInputFilePath ' Me.ucrInputFilePath.AddQuotesIfUnrecognised = True - Me.ucrInputFilePath.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.ucrInputFilePath.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.ucrInputFilePath.IsMultiline = False Me.ucrInputFilePath.IsReadOnly = True - Me.ucrInputFilePath.Location = New System.Drawing.Point(56, 2) + Me.ucrInputFilePath.Location = New System.Drawing.Point(77, 2) Me.ucrInputFilePath.Margin = New System.Windows.Forms.Padding(6, 8, 6, 8) Me.ucrInputFilePath.Name = "ucrInputFilePath" - Me.ucrInputFilePath.Size = New System.Drawing.Size(240, 23) - Me.ucrInputFilePath.TabIndex = 7 + Me.ucrInputFilePath.Size = New System.Drawing.Size(260, 23) + Me.ucrInputFilePath.TabIndex = 2 ' 'btnBrowse ' Me.btnBrowse.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.btnBrowse.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.btnBrowse.Location = New System.Drawing.Point(297, 1) + Me.btnBrowse.Location = New System.Drawing.Point(338, 1) Me.btnBrowse.Name = "btnBrowse" Me.btnBrowse.Size = New System.Drawing.Size(50, 23) - Me.btnBrowse.TabIndex = 8 + Me.btnBrowse.TabIndex = 3 Me.btnBrowse.Text = "Browse" Me.btnBrowse.UseVisualStyleBackColor = True ' @@ -72,7 +73,7 @@ Partial Class ucrFilePath Me.lblName.Location = New System.Drawing.Point(2, 6) Me.lblName.Name = "lblName" Me.lblName.Size = New System.Drawing.Size(50, 13) - Me.lblName.TabIndex = 6 + Me.lblName.TabIndex = 1 Me.lblName.Text = "Save As:" ' 'ucrFilePath @@ -83,7 +84,7 @@ Partial Class ucrFilePath Me.Controls.Add(Me.btnBrowse) Me.Controls.Add(Me.lblName) Me.Name = "ucrFilePath" - Me.Size = New System.Drawing.Size(351, 26) + Me.Size = New System.Drawing.Size(392, 26) Me.ResumeLayout(False) Me.PerformLayout() diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index d1db9f09ab9..16250009d55 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -14,9 +14,23 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . +Imports System.IO Public Class ucrFilePath + 'event raised when the file path contents has changed + Public Event FilePathChanged() - Public Property LabelText() As String + 'gets and sets the text propert of the browse button. + Public Property FilePathBrowseText() As String + Get + Return btnBrowse.Text + End Get + Set(ByVal value As String) + btnBrowse.Text = value + End Set + End Property + + 'gets and sets the label of the input textbox + Public Property FilePathLabel() As String Get Return lblName.Text End Get @@ -25,14 +39,89 @@ Public Class ucrFilePath End Set End Property - Public Property BrowseText() As String + 'used to set the title of the SaveFileDialog prompt + Public Property FilePathDialogTitle As String = "Save As" + + 'used to set the allowed file filters or file extensions + Public Property FilePathDialogFilter As String = "All Files *.*" + + 'used to set the suggestive name if no file name was set before + Public Property DefaultFileSuggestionName As String = "" + + 'gets or sets the input file path + Public Property FilePath() As String Get - Return btnBrowse.Text + Return GetPathControl().GetText() End Get Set(ByVal value As String) - btnBrowse.Text = value + 'first replace backward slashed with forward slashes cause of R path formats + GetPathControl().SetName(value.Replace("\", "/")) + RaiseEvent FilePathChanged() End Set End Property - 'todo. code logic additions + ''' + ''' gets the control that contains the input file path and name + ''' + ''' ucrInputTextBox + Public Function GetPathControl() As ucrInputTextBox + Return ucrInputFilePath + End Function + + ''' + ''' Sets the R parameter to the path control + ''' + ''' + Public Sub SetPathControlParameter(rParamter As RParameter) + GetPathControl().SetParameter(rParamter) + End Sub + + ''' + ''' sets the R code to the path control + ''' + ''' + ''' + Public Sub SetPathControlRcode(clsNewCodeStructure As RCodeStructure, Optional bReset As Boolean = False) + GetPathControl().SetRCode(clsNewCodeStructure, bReset) + End Sub + + ''' + ''' resets the path control and and the file path + ''' + Public Sub ResetPathControl() + GetPathControl().Reset() + Clear() + End Sub + + Public Function IsEmpty() As Boolean + Return String.IsNullOrEmpty(FilePath) + End Function + + Public Sub Clear() + FilePath = "" + End Sub + + Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click + Using dlgSave As New SaveFileDialog + dlgSave.Title = FilePathDialogTitle + dlgSave.Filter = FilePathDialogFilter + If IsEmpty() Then + dlgSave.FileName = DefaultFileSuggestionName + dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory + Else + 'use the file path in windows backslash convention format + Dim strFilePathInWindowsFormat As String = FilePath.Replace("/", "\") + dlgSave.FileName = Path.GetFileName(strFilePathInWindowsFormat) + dlgSave.InitialDirectory = Path.GetDirectoryName(strFilePathInWindowsFormat) + End If + If DialogResult.OK = dlgSave.ShowDialog() Then + FilePath = dlgSave.FileName + End If + End Using + End Sub + + Private Sub ucrInputFilePath_Click(sender As Object, e As EventArgs) Handles ucrInputFilePath.Click + btnBrowse.PerformClick() + End Sub + End Class From d2b5886c9b533e1b56f6a379fb954e88c24d446b Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 26 Aug 2020 18:06:09 +0300 Subject: [PATCH 05/26] remembering filter and comments additions --- instat/ucrFilePath.vb | 58 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 16250009d55..48cccab2ebc 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -15,11 +15,32 @@ ' along with this program. If not, see . Imports System.IO + +'''-------------------------------------------------------------------------------------------- +''' +''' An object of this class represents a file path custom control that inherits System.Windows.Forms.UserControl +''' and is used to select the file name and path to be used in saving a file +''' +''' +''' set the parameter of the path control +''' +''' +''' set the R code structure of the path control +''' +''' +''' Optional. Set a default suggestive name +''' +''' +''' Public Class ucrFilePath - 'event raised when the file path contents has changed + ''' + ''' event raised when the file path contents has changed + ''' Public Event FilePathChanged() - 'gets and sets the text propert of the browse button. + ''' + ''' gets and sets the text property value of the browse button. + ''' Public Property FilePathBrowseText() As String Get Return btnBrowse.Text @@ -29,7 +50,9 @@ Public Class ucrFilePath End Set End Property - 'gets and sets the label of the input textbox + ''' + ''' gets and sets the label text property value of the input textbox + ''' Public Property FilePathLabel() As String Get Return lblName.Text @@ -39,16 +62,24 @@ Public Class ucrFilePath End Set End Property - 'used to set the title of the SaveFileDialog prompt + ''' + ''' used to set the title of the SaveFileDialog prompt + ''' Public Property FilePathDialogTitle As String = "Save As" 'used to set the allowed file filters or file extensions Public Property FilePathDialogFilter As String = "All Files *.*" - 'used to set the suggestive name if no file name was set before + ''' + ''' used to set the suggestive name if no file name was set before + ''' + ''' Public Property DefaultFileSuggestionName As String = "" - 'gets or sets the input file path + ''' + ''' gets or sets the input file path + ''' Used by the SaveFileDiaolog prompt to 'remember' last selected file name and directory + ''' Public Property FilePath() As String Get Return GetPathControl().GetText() @@ -60,6 +91,13 @@ Public Class ucrFilePath End Set End Property + ''' + ''' gets or sets the last selected filter index. + ''' used by the SaveFileDiaolog prompt to 'remember' last selected file type filter + ''' this is used internally only + ''' + Private iFileFilterIndex As Integer + ''' ''' gets the control that contains the input file path and name ''' @@ -101,6 +139,12 @@ Public Class ucrFilePath FilePath = "" End Sub + ''' + ''' opens a SaveFileDialog prompt thats allows user to specify file name and path + ''' to be used in saving a file + ''' + ''' + ''' Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click Using dlgSave As New SaveFileDialog dlgSave.Title = FilePathDialogTitle @@ -113,9 +157,11 @@ Public Class ucrFilePath Dim strFilePathInWindowsFormat As String = FilePath.Replace("/", "\") dlgSave.FileName = Path.GetFileName(strFilePathInWindowsFormat) dlgSave.InitialDirectory = Path.GetDirectoryName(strFilePathInWindowsFormat) + dlgSave.FilterIndex = iFileFilterIndex End If If DialogResult.OK = dlgSave.ShowDialog() Then FilePath = dlgSave.FileName + iFileFilterIndex = dlgSave.FilterIndex End If End Using End Sub From 535888687b0eec126649bcf725f7709e79c389b5 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Mon, 31 Aug 2020 13:18:35 +0300 Subject: [PATCH 06/26] Update instat/dlgExportDataset.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/dlgExportDataset.vb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index 13a6df66c83..4d13ed2432e 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -51,7 +51,8 @@ Public Class dlgExportDataset ucrAvailableSheets.Reset() ucrFilePath.ResetPathControl() - ucrFilePath.DefaultFileSuggestionName = ucrAvailableSheets.strCurrDataFrame 'set suggestive name from selected data frame + ucrFilePath.DefaultFileSuggestionName = ucrAvailableSheets.strCurrDataFrame 'set default suggested name from selected data frame + clsDefaultFunction.SetPackageName("rio") clsDefaultFunction.SetRCommand("export") @@ -91,4 +92,4 @@ Public Class dlgExportDataset TestOkEnabled() End Sub -End Class \ No newline at end of file +End Class From 4d882799573565bed07e12abea5f78b854077700 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Mon, 31 Aug 2020 13:39:06 +0300 Subject: [PATCH 07/26] Apply suggestions from code review Stephen comments suggestions Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/dlgExportGraphAsImage.vb | 4 ++-- instat/dlgExportRObjects.vb | 4 ++-- instat/dlgExportRWorkspace.vb | 4 ++-- instat/ucrFilePath.vb | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/instat/dlgExportGraphAsImage.vb b/instat/dlgExportGraphAsImage.vb index ba0772ca2c2..539ee6c50ff 100644 --- a/instat/dlgExportGraphAsImage.vb +++ b/instat/dlgExportGraphAsImage.vb @@ -75,7 +75,7 @@ Public Class dlgExportGraphAsImage End Sub Private Sub ucrCoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrSelectedGraphReceiver.ControlContentsChanged - 'give a suggestive name from the receiver + 'give a default suggested name from the receiver ucrFilePath.DefaultFileSuggestionName = ucrSelectedGraphReceiver.GetVariableNames(bWithQuotes:=False) TestOkEnabled() End Sub @@ -84,4 +84,4 @@ Public Class dlgExportGraphAsImage TestOkEnabled() End Sub -End Class \ No newline at end of file +End Class diff --git a/instat/dlgExportRObjects.vb b/instat/dlgExportRObjects.vb index 7e9c7e2d77c..f3b60510bd2 100644 --- a/instat/dlgExportRObjects.vb +++ b/instat/dlgExportRObjects.vb @@ -81,7 +81,7 @@ Public Class dlgExportRObjects End Sub Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverObjects.ControlContentsChanged, ucrSelectorObjects.ControlContentsChanged - 'ucrReceiverObjects is a multireceiver. So give a suggestive name if it has 1 item only + 'ucrReceiverObjects is a multireceiver. So give a default suggested name if it has 1 item only ucrFilePath.DefaultFileSuggestionName = If(ucrReceiverObjects.GetVariableNamesList().Length = 1, ucrReceiverObjects.GetVariableNames(bWithQuotes:=False), "") TestOkEnabled() End Sub @@ -90,4 +90,4 @@ Public Class dlgExportRObjects TestOkEnabled() End Sub -End Class \ No newline at end of file +End Class diff --git a/instat/dlgExportRWorkspace.vb b/instat/dlgExportRWorkspace.vb index 9da0ecddc5f..6e9dc83abb5 100644 --- a/instat/dlgExportRWorkspace.vb +++ b/instat/dlgExportRWorkspace.vb @@ -91,7 +91,7 @@ Public Class dlgExportRWorkspace End Sub Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultiple.ControlContentsChanged - 'ucrReceiverMultiple is a multireceiver. So give a suggestive name if it has 1 item only + 'ucrReceiverMultiple is a multireceiver. So give a default suggested name if it has 1 item only ucrFilePath.DefaultFileSuggestionName = If(ucrReceiverMultiple.GetVariableNamesList().Length = 1, ucrReceiverMultiple.GetVariableNames(bWithQuotes:=False), "") TestOkEnabled() End Sub @@ -99,4 +99,4 @@ Public Class dlgExportRWorkspace Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged TestOkEnabled() End Sub -End Class \ No newline at end of file +End Class diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 48cccab2ebc..8278d6c755c 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -28,7 +28,7 @@ Imports System.IO ''' set the R code structure of the path control ''' ''' -''' Optional. Set a default suggestive name +''' Optional. Set a default suggested name ''' ''' ''' @@ -71,14 +71,14 @@ Public Class ucrFilePath Public Property FilePathDialogFilter As String = "All Files *.*" ''' - ''' used to set the suggestive name if no file name was set before + ''' used to set the suggested name if no file name was set before ''' ''' Public Property DefaultFileSuggestionName As String = "" ''' - ''' gets or sets the input file path - ''' Used by the SaveFileDiaolog prompt to 'remember' last selected file name and directory + ''' gets or sets the input file path used by the SaveFileDiaolog prompt to 'remember' the + ''' last selected file name and directory ''' Public Property FilePath() As String Get From f0b9216bd94e950e3c6eeb94f8266d431196dd7f Mon Sep 17 00:00:00 2001 From: patowhiz Date: Mon, 31 Aug 2020 13:50:09 +0300 Subject: [PATCH 08/26] changed getter metod to PathControl property --- instat/ucrFilePath.vb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 8278d6c755c..75ddbef1c67 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -82,11 +82,11 @@ Public Class ucrFilePath ''' Public Property FilePath() As String Get - Return GetPathControl().GetText() + Return PathControl().GetText() End Get Set(ByVal value As String) 'first replace backward slashed with forward slashes cause of R path formats - GetPathControl().SetName(value.Replace("\", "/")) + PathControl().SetName(value.Replace("\", "/")) RaiseEvent FilePathChanged() End Set End Property @@ -102,16 +102,18 @@ Public Class ucrFilePath ''' gets the control that contains the input file path and name ''' ''' ucrInputTextBox - Public Function GetPathControl() As ucrInputTextBox - Return ucrInputFilePath - End Function + Public ReadOnly Property PathControl() As ucrInputTextBox + Get + Return ucrInputFilePath + End Get + End Property ''' ''' Sets the R parameter to the path control ''' ''' Public Sub SetPathControlParameter(rParamter As RParameter) - GetPathControl().SetParameter(rParamter) + PathControl().SetParameter(rParamter) End Sub ''' @@ -120,14 +122,14 @@ Public Class ucrFilePath ''' ''' Public Sub SetPathControlRcode(clsNewCodeStructure As RCodeStructure, Optional bReset As Boolean = False) - GetPathControl().SetRCode(clsNewCodeStructure, bReset) + PathControl().SetRCode(clsNewCodeStructure, bReset) End Sub ''' ''' resets the path control and and the file path ''' Public Sub ResetPathControl() - GetPathControl().Reset() + PathControl().Reset() Clear() End Sub From 8718135cd0c966be73c982da249ad176afcaf29f Mon Sep 17 00:00:00 2001 From: patowhiz Date: Sat, 5 Sep 2020 22:07:19 +0300 Subject: [PATCH 09/26] Export R objects in RData --- instat/dlgExportRObjects.Designer.vb | 24 ++++++++++----------- instat/dlgExportRObjects.resx | 26 +++++++++++++--------- instat/dlgExportRObjects.vb | 32 ++++++++++++---------------- 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/instat/dlgExportRObjects.Designer.vb b/instat/dlgExportRObjects.Designer.vb index 3e2bc5a8b8a..6af436ab17e 100644 --- a/instat/dlgExportRObjects.Designer.vb +++ b/instat/dlgExportRObjects.Designer.vb @@ -40,10 +40,10 @@ Partial Class dlgExportRObjects Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(dlgExportRObjects)) Me.lblObjects = New System.Windows.Forms.Label() + Me.ucrFilePath = New instat.ucrFilePath() Me.ucrReceiverObjects = New instat.ucrReceiverMultiple() Me.ucrSelectorObjects = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() - Me.ucrFilePath = New instat.ucrFilePath() Me.SuspendLayout() ' 'lblObjects @@ -51,6 +51,17 @@ Partial Class dlgExportRObjects resources.ApplyResources(Me.lblObjects, "lblObjects") Me.lblObjects.Name = "lblObjects" ' + 'ucrFilePath + ' + Me.ucrFilePath.DefaultFileSuggestionName = "" + Me.ucrFilePath.FilePath = "" + Me.ucrFilePath.FilePathBrowseText = "Browse" + Me.ucrFilePath.FilePathDialogFilter = "Saved R objects (*.RData)|*.RData|Serialized R Objects (*.rds)|*.rds" + Me.ucrFilePath.FilePathDialogTitle = "Export R Objects" + Me.ucrFilePath.FilePathLabel = "Export File:" + resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") + Me.ucrFilePath.Name = "ucrFilePath" + ' 'ucrReceiverObjects ' Me.ucrReceiverObjects.frmParent = Me @@ -73,17 +84,6 @@ Partial Class dlgExportRObjects resources.ApplyResources(Me.ucrBase, "ucrBase") Me.ucrBase.Name = "ucrBase" ' - 'ucrFilePath - ' - Me.ucrFilePath.DefaultFileSuggestionName = "" - Me.ucrFilePath.FilePath = "" - Me.ucrFilePath.FilePathBrowseText = "Browse" - Me.ucrFilePath.FilePathDialogFilter = "Serialized R Objects (*.rds)|*.rds" - Me.ucrFilePath.FilePathDialogTitle = "Export R Objects" - Me.ucrFilePath.FilePathLabel = "Export File:" - resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") - Me.ucrFilePath.Name = "ucrFilePath" - ' 'dlgExportRObjects ' resources.ApplyResources(Me, "$this") diff --git a/instat/dlgExportRObjects.resx b/instat/dlgExportRObjects.resx index 2a759e88330..ad1c28a3dcf 100644 --- a/instat/dlgExportRObjects.resx +++ b/instat/dlgExportRObjects.resx @@ -121,6 +121,10 @@ True + + + NoControl + 266, 45 @@ -146,15 +150,6 @@ 1 - - True - - - 6, 13 - - - 417, 288 - 14, 199 @@ -176,10 +171,18 @@ 0 + + True + + + 6, 13 + + + 417, 288 + 10, 10 - 0, 0, 0, 0 @@ -225,6 +228,9 @@ 4 + + NoControl + CenterScreen diff --git a/instat/dlgExportRObjects.vb b/instat/dlgExportRObjects.vb index f3b60510bd2..fe274061fe8 100644 --- a/instat/dlgExportRObjects.vb +++ b/instat/dlgExportRObjects.vb @@ -18,7 +18,7 @@ Imports instat.Translations Public Class dlgExportRObjects Private bFirstLoad As Boolean = True Private bReset As Boolean = True - Private clsGetObjectsFunction, clsSaveRDS As New RFunction + Private clsExport As RFunction Private Sub dlgExportRObjects_Load(sender As Object, e As EventArgs) Handles MyBase.Load autoTranslate(Me) @@ -37,37 +37,33 @@ Public Class dlgExportRObjects Private Sub InitialiseDialog() ucrBase.iHelpTopicID = 554 - ucrSelectorObjects.SetParameter(New RParameter("data_name", 1)) - ucrSelectorObjects.ucrAvailableDataFrames.SetParameterIsString() - - ucrReceiverObjects.SetParameter(New RParameter("object_name", 2)) - ucrReceiverObjects.SetParameterIsString() + 'multiple reciever control that holds selected objects + ucrReceiverObjects.SetParameter(New RParameter("x", 0)) + ucrReceiverObjects.SetParameterIsRFunction() ucrReceiverObjects.Selector = ucrSelectorObjects ucrReceiverObjects.SetMeAsReceiver() ucrReceiverObjects.strSelectorHeading = "Objects" ucrReceiverObjects.SetItemType("object") - - ucrFilePath.SetPathControlParameter(New RParameter("file", 0)) - + 'file path control that holds the file path and name + ucrFilePath.SetPathControlParameter(New RParameter("file", 1)) End Sub Private Sub SetDefaults() - clsGetObjectsFunction = New RFunction - clsSaveRDS = New RFunction + clsExport = New RFunction + 'reset controls ucrSelectorObjects.Reset() ucrFilePath.ResetPathControl() - clsGetObjectsFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_objects") - clsSaveRDS.SetRCommand("saveRDS") - clsSaveRDS.AddParameter("object", clsRFunctionParameter:=clsGetObjectsFunction) - ucrBase.clsRsyntax.SetBaseRFunction(clsSaveRDS) + 'set R command and base function + clsExport.SetPackageName("rio") + clsExport.SetRCommand("export") + ucrBase.clsRsyntax.SetBaseRFunction(clsExport) End Sub Private Sub SetRCodeForControls(bReset As Boolean) - ucrSelectorObjects.SetRCode(clsGetObjectsFunction, bReset) - ucrReceiverObjects.SetRCode(clsGetObjectsFunction, bReset) - ucrFilePath.SetPathControlRcode(clsSaveRDS, bReset) + ucrReceiverObjects.SetRCode(clsExport, bReset) + ucrFilePath.SetPathControlRcode(clsExport, bReset) End Sub Private Sub TestOkEnabled() From bfa4ce915d2b8cb526b62eb987dcaa03cec4aa19 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Mon, 7 Sep 2020 18:31:03 +0300 Subject: [PATCH 10/26] extending dialog export dataset --- instat/dlgExportDataset.Designer.vb | 60 ++++++++-- instat/dlgExportDataset.resx | 170 ++++++++++++++++++++++----- instat/dlgExportDataset.vb | 46 ++++++-- instat/dlgExportRObjects.Designer.vb | 20 ++-- instat/dlgExportRObjects.resx | 23 ++-- instat/dlgExportRObjects.vb | 20 ++-- instat/ucrFilePath.vb | 8 +- 7 files changed, 256 insertions(+), 91 deletions(-) diff --git a/instat/dlgExportDataset.Designer.vb b/instat/dlgExportDataset.Designer.vb index 329ffd47274..bca20946fe6 100644 --- a/instat/dlgExportDataset.Designer.vb +++ b/instat/dlgExportDataset.Designer.vb @@ -19,7 +19,7 @@ Partial Class dlgExportDataset Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -36,13 +36,17 @@ Partial Class dlgExportDataset '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 Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(dlgExportDataset)) Me.lblConfirm = New System.Windows.Forms.Label() - Me.ucrAvailableSheets = New instat.ucrDataFrame() Me.ucrBase = New instat.ucrButtons() Me.ucrFilePath = New instat.ucrFilePath() + Me.ucrSelectorDataFrames = New instat.ucrSelectorAddRemove() + Me.lblDataFrames = New System.Windows.Forms.Label() + Me.lblSelectedDataFrames = New System.Windows.Forms.Label() + Me.ucrReceiverMultipleDataFrames = New instat.ucrReceiverMultiple() + Me.ucrChkSaveAsSingleFile = New instat.ucrCheck() Me.SuspendLayout() ' 'lblConfirm @@ -50,13 +54,6 @@ Partial Class dlgExportDataset resources.ApplyResources(Me.lblConfirm, "lblConfirm") Me.lblConfirm.Name = "lblConfirm" ' - 'ucrAvailableSheets - ' - Me.ucrAvailableSheets.bDropUnusedFilterLevels = False - Me.ucrAvailableSheets.bUseCurrentFilter = True - resources.ApplyResources(Me.ucrAvailableSheets, "ucrAvailableSheets") - Me.ucrAvailableSheets.Name = "ucrAvailableSheets" - ' 'ucrBase ' resources.ApplyResources(Me.ucrBase, "ucrBase") @@ -73,13 +70,48 @@ Partial Class dlgExportDataset resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") Me.ucrFilePath.Name = "ucrFilePath" ' + 'ucrSelectorDataFrames + ' + Me.ucrSelectorDataFrames.bShowHiddenColumns = False + resources.ApplyResources(Me.ucrSelectorDataFrames, "ucrSelectorDataFrames") + Me.ucrSelectorDataFrames.Name = "ucrSelectorDataFrames" + ' + 'lblDataFrames + ' + resources.ApplyResources(Me.lblDataFrames, "lblDataFrames") + Me.lblDataFrames.Name = "lblDataFrames" + ' + 'lblSelectedDataFrames + ' + resources.ApplyResources(Me.lblSelectedDataFrames, "lblSelectedDataFrames") + Me.lblSelectedDataFrames.Name = "lblSelectedDataFrames" + ' + 'ucrReceiverMultipleDataFrames + ' + Me.ucrReceiverMultipleDataFrames.frmParent = Me + resources.ApplyResources(Me.ucrReceiverMultipleDataFrames, "ucrReceiverMultipleDataFrames") + Me.ucrReceiverMultipleDataFrames.Name = "ucrReceiverMultipleDataFrames" + Me.ucrReceiverMultipleDataFrames.Selector = Nothing + Me.ucrReceiverMultipleDataFrames.strNcFilePath = "" + Me.ucrReceiverMultipleDataFrames.ucrSelector = Nothing + ' + 'ucrChkSaveAsSingleFile + ' + Me.ucrChkSaveAsSingleFile.Checked = True + resources.ApplyResources(Me.ucrChkSaveAsSingleFile, "ucrChkSaveAsSingleFile") + Me.ucrChkSaveAsSingleFile.Name = "ucrChkSaveAsSingleFile" + ' 'dlgExportDataset ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(Me.ucrChkSaveAsSingleFile) + Me.Controls.Add(Me.ucrReceiverMultipleDataFrames) + Me.Controls.Add(Me.lblSelectedDataFrames) + Me.Controls.Add(Me.lblDataFrames) + Me.Controls.Add(Me.ucrSelectorDataFrames) Me.Controls.Add(Me.ucrFilePath) Me.Controls.Add(Me.lblConfirm) - Me.Controls.Add(Me.ucrAvailableSheets) Me.Controls.Add(Me.ucrBase) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False @@ -92,7 +124,11 @@ Partial Class dlgExportDataset End Sub Friend WithEvents ucrBase As ucrButtons - Friend WithEvents ucrAvailableSheets As ucrDataFrame Friend WithEvents lblConfirm As Label Friend WithEvents ucrFilePath As ucrFilePath + Friend WithEvents ucrSelectorDataFrames As ucrSelectorAddRemove + Friend WithEvents lblDataFrames As Label + Friend WithEvents lblSelectedDataFrames As Label + Friend WithEvents ucrReceiverMultipleDataFrames As ucrReceiverMultiple + Friend WithEvents ucrChkSaveAsSingleFile As ucrCheck End Class diff --git a/instat/dlgExportDataset.resx b/instat/dlgExportDataset.resx index 10512276e8e..6c76b2e104e 100644 --- a/instat/dlgExportDataset.resx +++ b/instat/dlgExportDataset.resx @@ -127,7 +127,7 @@ - 85, 88 + 92, 237 2, 0, 2, 0 @@ -151,34 +151,10 @@ $this - 1 - - - 10, 5 - - - 0, 0, 0, 0 - - - 154, 41 - - - 0 - - - ucrAvailableSheets - - - instat.ucrDataFrame, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 2 + 6 - 8, 111 + 10, 259 4, 5, 4, 5 @@ -199,13 +175,13 @@ $this - 3 + 7 Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html - 11, 54 + 8, 203 403, 26 @@ -223,7 +199,94 @@ $this - 0 + 5 + + + 10, 28 + + + 0, 0, 0, 0 + + + 216, 147 + + + 6 + + + ucrSelectorDataFrames + + + instat.ucrSelectorAddRemove, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 4 + + + True + + + NoControl + + + 8, 10 + + + 2, 0, 2, 0 + + + 70, 13 + + + 7 + + + Data Frames: + + + lblDataFrames + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + True + + + NoControl + + + 250, 10 + + + 115, 13 + + + 8 + + + Selected Data Frames: + + + lblSelectedDataFrames + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 True @@ -235,7 +298,28 @@ True - 421, 170 + 417, 319 + + + 12, 175 + + + 214, 20 + + + 10 + + + ucrChkSaveAsSingleFile + + + instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 CenterScreen @@ -249,4 +333,28 @@ System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 253, 28 + + + 0, 0, 0, 0 + + + 120, 100 + + + 9 + + + ucrReceiverMultipleDataFrames + + + instat.ucrReceiverMultiple, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 1 + \ No newline at end of file diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index 4d13ed2432e..013c0f0300b 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -14,6 +14,7 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . +Imports instat Imports instat.Translations Public Class dlgExportDataset Dim bFirstLoad As Boolean = True @@ -36,12 +37,24 @@ Public Class dlgExportDataset Private Sub InitialiseDialog() - ucrAvailableSheets.SetParameter(New RParameter("x", 0)) - ucrAvailableSheets.SetParameterIsRFunction() - ucrAvailableSheets.SetText("Data Frame to Export:") + 'ucrAvailableSheets.SetParameter(New RParameter("x", 0)) + 'ucrAvailableSheets.SetParameterIsRFunction() + 'ucrAvailableSheets.SetText("Data Frame to Export:") + + + 'multiple reciever control that holds selected objects + ucrReceiverMultipleDataFrames.SetParameter(New RParameter("x", 0)) + ucrReceiverMultipleDataFrames.SetParameterIsRFunction() + ucrReceiverMultipleDataFrames.Selector = ucrSelectorDataFrames + ucrReceiverMultipleDataFrames.SetMeAsReceiver() + ucrReceiverMultipleDataFrames.strSelectorHeading = "Data Frames" + ucrReceiverMultipleDataFrames.SetItemType("dataframe") + ucrFilePath.SetPathControlParameter(New RParameter("file", 1)) + ucrChkSaveAsSingleFile.Text = "Save as single file" + lblConfirm.Visible = False lblConfirm.ForeColor = Color.Green End Sub @@ -49,9 +62,10 @@ Public Class dlgExportDataset Private Sub SetDefaults() clsDefaultFunction = New RFunction - ucrAvailableSheets.Reset() + ucrSelectorDataFrames.Reset() + ucrChkSaveAsSingleFile.Checked = True + ucrChkSaveAsSingleFile.Visible = False ucrFilePath.ResetPathControl() - ucrFilePath.DefaultFileSuggestionName = ucrAvailableSheets.strCurrDataFrame 'set default suggested name from selected data frame clsDefaultFunction.SetPackageName("rio") @@ -61,12 +75,12 @@ Public Class dlgExportDataset End Sub Private Sub SetRCodeForControls(bReset As Boolean) - ucrAvailableSheets.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + ucrReceiverMultipleDataFrames.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) ucrFilePath.SetPathControlRcode(ucrBase.clsRsyntax.clsBaseFunction, bReset) End Sub Private Sub TestOkEnabled() - If Not ucrFilePath.IsEmpty AndAlso Not String.IsNullOrEmpty(ucrAvailableSheets.strCurrDataFrame) Then + If Not ucrFilePath.IsEmpty AndAlso Not ucrReceiverMultipleDataFrames.IsEmpty Then ucrBase.OKEnabled(True) lblConfirm.Visible = True Else @@ -82,10 +96,20 @@ Public Class dlgExportDataset TestOkEnabled() End Sub - Private Sub ucrAvailableSheets_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrAvailableSheets.ControlValueChanged - 'give a suggestive name from selected data frame - ucrFilePath.DefaultFileSuggestionName = ucrAvailableSheets.strCurrDataFrame - ucrFilePath.Clear() 'clears the file path contents. + Private Sub ucrReceiverMultipleDataFrames_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultipleDataFrames.ControlContentsChanged + 'give a suggestive name from selected data frame and change the file filter accordingly + If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length = 1 Then + ucrChkSaveAsSingleFile.Visible = False + ucrFilePath.DefaultFileSuggestionName = ucrReceiverMultipleDataFrames.GetVariableNames(bWithQuotes:=False) + ucrFilePath.FilePathDialogFilter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html" + Else + ucrChkSaveAsSingleFile.Visible = True + ucrFilePath.DefaultFileSuggestionName = "" + ucrFilePath.FilePathDialogFilter = "Excel files (*.xlsx)|*.xlsx|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|HTML(*.html)|*.html" + End If + + 'clear the file path contents. + ucrFilePath.Clear() End Sub Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged diff --git a/instat/dlgExportRObjects.Designer.vb b/instat/dlgExportRObjects.Designer.vb index 6af436ab17e..5d6715e539f 100644 --- a/instat/dlgExportRObjects.Designer.vb +++ b/instat/dlgExportRObjects.Designer.vb @@ -41,7 +41,7 @@ Partial Class dlgExportRObjects Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(dlgExportRObjects)) Me.lblObjects = New System.Windows.Forms.Label() Me.ucrFilePath = New instat.ucrFilePath() - Me.ucrReceiverObjects = New instat.ucrReceiverMultiple() + Me.ucrReceiverMultipleObjects = New instat.ucrReceiverMultiple() Me.ucrSelectorObjects = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() Me.SuspendLayout() @@ -62,14 +62,14 @@ Partial Class dlgExportRObjects resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") Me.ucrFilePath.Name = "ucrFilePath" ' - 'ucrReceiverObjects + 'ucrReceiverMultipleObjects ' - Me.ucrReceiverObjects.frmParent = Me - resources.ApplyResources(Me.ucrReceiverObjects, "ucrReceiverObjects") - Me.ucrReceiverObjects.Name = "ucrReceiverObjects" - Me.ucrReceiverObjects.Selector = Nothing - Me.ucrReceiverObjects.strNcFilePath = "" - Me.ucrReceiverObjects.ucrSelector = Nothing + Me.ucrReceiverMultipleObjects.frmParent = Me + resources.ApplyResources(Me.ucrReceiverMultipleObjects, "ucrReceiverMultipleObjects") + Me.ucrReceiverMultipleObjects.Name = "ucrReceiverMultipleObjects" + Me.ucrReceiverMultipleObjects.Selector = Nothing + Me.ucrReceiverMultipleObjects.strNcFilePath = "" + Me.ucrReceiverMultipleObjects.ucrSelector = Nothing ' 'ucrSelectorObjects ' @@ -90,7 +90,7 @@ Partial Class dlgExportRObjects Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.Controls.Add(Me.ucrFilePath) Me.Controls.Add(Me.lblObjects) - Me.Controls.Add(Me.ucrReceiverObjects) + Me.Controls.Add(Me.ucrReceiverMultipleObjects) Me.Controls.Add(Me.ucrSelectorObjects) Me.Controls.Add(Me.ucrBase) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow @@ -103,7 +103,7 @@ Partial Class dlgExportRObjects End Sub Friend WithEvents ucrBase As ucrButtons Friend WithEvents ucrSelectorObjects As ucrSelectorByDataFrameAddRemove - Friend WithEvents ucrReceiverObjects As ucrReceiverMultiple + Friend WithEvents ucrReceiverMultipleObjects As ucrReceiverMultiple Friend WithEvents lblObjects As Label Friend WithEvents ucrFilePath As ucrFilePath End Class diff --git a/instat/dlgExportRObjects.resx b/instat/dlgExportRObjects.resx index ad1c28a3dcf..4164aefba4b 100644 --- a/instat/dlgExportRObjects.resx +++ b/instat/dlgExportRObjects.resx @@ -127,7 +127,7 @@ - 266, 45 + 263, 45 91, 13 @@ -228,9 +228,6 @@ 4 - - NoControl - CenterScreen @@ -243,28 +240,28 @@ System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 267, 60 - + 0, 0, 0, 0 - + 120, 100 - + 2 - - ucrReceiverObjects + + ucrReceiverMultipleObjects - + instat.ucrReceiverMultiple, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - + $this - + 2 \ No newline at end of file diff --git a/instat/dlgExportRObjects.vb b/instat/dlgExportRObjects.vb index fe274061fe8..fc1246da1d2 100644 --- a/instat/dlgExportRObjects.vb +++ b/instat/dlgExportRObjects.vb @@ -38,12 +38,12 @@ Public Class dlgExportRObjects ucrBase.iHelpTopicID = 554 'multiple reciever control that holds selected objects - ucrReceiverObjects.SetParameter(New RParameter("x", 0)) - ucrReceiverObjects.SetParameterIsRFunction() - ucrReceiverObjects.Selector = ucrSelectorObjects - ucrReceiverObjects.SetMeAsReceiver() - ucrReceiverObjects.strSelectorHeading = "Objects" - ucrReceiverObjects.SetItemType("object") + ucrReceiverMultipleObjects.SetParameter(New RParameter("x", 0)) + ucrReceiverMultipleObjects.SetParameterIsRFunction() + ucrReceiverMultipleObjects.Selector = ucrSelectorObjects + ucrReceiverMultipleObjects.SetMeAsReceiver() + ucrReceiverMultipleObjects.strSelectorHeading = "Objects" + ucrReceiverMultipleObjects.SetItemType("object") 'file path control that holds the file path and name ucrFilePath.SetPathControlParameter(New RParameter("file", 1)) End Sub @@ -62,12 +62,12 @@ Public Class dlgExportRObjects End Sub Private Sub SetRCodeForControls(bReset As Boolean) - ucrReceiverObjects.SetRCode(clsExport, bReset) + ucrReceiverMultipleObjects.SetRCode(clsExport, bReset) ucrFilePath.SetPathControlRcode(clsExport, bReset) End Sub Private Sub TestOkEnabled() - ucrBase.OKEnabled(Not ucrFilePath.IsEmpty AndAlso Not ucrReceiverObjects.IsEmpty AndAlso Not String.IsNullOrEmpty(ucrSelectorObjects.strCurrentDataFrame)) + ucrBase.OKEnabled(Not ucrFilePath.IsEmpty AndAlso Not ucrReceiverMultipleObjects.IsEmpty AndAlso Not String.IsNullOrEmpty(ucrSelectorObjects.strCurrentDataFrame)) End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset @@ -76,9 +76,9 @@ Public Class dlgExportRObjects TestOkEnabled() End Sub - Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverObjects.ControlContentsChanged, ucrSelectorObjects.ControlContentsChanged + Private Sub ucrReceiverMultipleObjects_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultipleObjects.ControlContentsChanged 'ucrReceiverObjects is a multireceiver. So give a default suggested name if it has 1 item only - ucrFilePath.DefaultFileSuggestionName = If(ucrReceiverObjects.GetVariableNamesList().Length = 1, ucrReceiverObjects.GetVariableNames(bWithQuotes:=False), "") + ucrFilePath.DefaultFileSuggestionName = If(ucrReceiverMultipleObjects.GetVariableNamesList().Length = 1, ucrReceiverMultipleObjects.GetVariableNames(bWithQuotes:=False), "") TestOkEnabled() End Sub diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 75ddbef1c67..16d6789f194 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -94,9 +94,9 @@ Public Class ucrFilePath ''' ''' gets or sets the last selected filter index. ''' used by the SaveFileDiaolog prompt to 'remember' last selected file type filter - ''' this is used internally only + ''' and by dialogs to know selected filter index ''' - Private iFileFilterIndex As Integer + Public SelectedFileFilterIndex As Integer ''' ''' gets the control that contains the input file path and name @@ -159,11 +159,11 @@ Public Class ucrFilePath Dim strFilePathInWindowsFormat As String = FilePath.Replace("/", "\") dlgSave.FileName = Path.GetFileName(strFilePathInWindowsFormat) dlgSave.InitialDirectory = Path.GetDirectoryName(strFilePathInWindowsFormat) - dlgSave.FilterIndex = iFileFilterIndex + dlgSave.FilterIndex = SelectedFileFilterIndex End If If DialogResult.OK = dlgSave.ShowDialog() Then FilePath = dlgSave.FileName - iFileFilterIndex = dlgSave.FilterIndex + SelectedFileFilterIndex = dlgSave.FilterIndex End If End Using End Sub From 70c145e73dba370f50154565e1e86dd1e95f18bc Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 10 Sep 2020 11:01:05 +0300 Subject: [PATCH 11/26] export data sets, export R objects, path control changes --- instat/dlgExportDataset.Designer.vb | 63 ++++-- instat/dlgExportDataset.resx | 295 +++++++++++++++++++--------- instat/dlgExportDataset.vb | 120 ++++++++--- instat/dlgExportRObjects.vb | 8 +- instat/ucrFilePath.vb | 151 +++++++++++--- 5 files changed, 466 insertions(+), 171 deletions(-) diff --git a/instat/dlgExportDataset.Designer.vb b/instat/dlgExportDataset.Designer.vb index bca20946fe6..f5ce95ac8c1 100644 --- a/instat/dlgExportDataset.Designer.vb +++ b/instat/dlgExportDataset.Designer.vb @@ -40,20 +40,46 @@ Partial Class dlgExportDataset Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(dlgExportDataset)) Me.lblConfirm = New System.Windows.Forms.Label() + Me.lblDataFrames = New System.Windows.Forms.Label() + Me.lblSelectedDataFrames = New System.Windows.Forms.Label() + Me.lblFileExtension = New System.Windows.Forms.Label() + Me.cboFileExtension = New System.Windows.Forms.ComboBox() Me.ucrBase = New instat.ucrButtons() Me.ucrFilePath = New instat.ucrFilePath() Me.ucrSelectorDataFrames = New instat.ucrSelectorAddRemove() - Me.lblDataFrames = New System.Windows.Forms.Label() - Me.lblSelectedDataFrames = New System.Windows.Forms.Label() Me.ucrReceiverMultipleDataFrames = New instat.ucrReceiverMultiple() - Me.ucrChkSaveAsSingleFile = New instat.ucrCheck() + Me.chkSaveAsSingleFile = New System.Windows.Forms.CheckBox() Me.SuspendLayout() ' 'lblConfirm ' resources.ApplyResources(Me.lblConfirm, "lblConfirm") + Me.lblConfirm.ForeColor = System.Drawing.Color.Green Me.lblConfirm.Name = "lblConfirm" ' + 'lblDataFrames + ' + resources.ApplyResources(Me.lblDataFrames, "lblDataFrames") + Me.lblDataFrames.Name = "lblDataFrames" + ' + 'lblSelectedDataFrames + ' + resources.ApplyResources(Me.lblSelectedDataFrames, "lblSelectedDataFrames") + Me.lblSelectedDataFrames.Name = "lblSelectedDataFrames" + ' + 'lblFileExtension + ' + resources.ApplyResources(Me.lblFileExtension, "lblFileExtension") + Me.lblFileExtension.Name = "lblFileExtension" + ' + 'cboFileExtension + ' + Me.cboFileExtension.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList + Me.cboFileExtension.FormattingEnabled = True + Me.cboFileExtension.Items.AddRange(New Object() {resources.GetString("cboFileExtension.Items"), resources.GetString("cboFileExtension.Items1"), resources.GetString("cboFileExtension.Items2"), resources.GetString("cboFileExtension.Items3"), resources.GetString("cboFileExtension.Items4"), resources.GetString("cboFileExtension.Items5"), resources.GetString("cboFileExtension.Items6"), resources.GetString("cboFileExtension.Items7"), resources.GetString("cboFileExtension.Items8"), resources.GetString("cboFileExtension.Items9"), resources.GetString("cboFileExtension.Items10"), resources.GetString("cboFileExtension.Items11"), resources.GetString("cboFileExtension.Items12"), resources.GetString("cboFileExtension.Items13"), resources.GetString("cboFileExtension.Items14"), resources.GetString("cboFileExtension.Items15"), resources.GetString("cboFileExtension.Items16")}) + resources.ApplyResources(Me.cboFileExtension, "cboFileExtension") + Me.cboFileExtension.Name = "cboFileExtension" + ' 'ucrBase ' resources.ApplyResources(Me.ucrBase, "ucrBase") @@ -66,7 +92,8 @@ Partial Class dlgExportDataset Me.ucrFilePath.FilePathBrowseText = "Browse" Me.ucrFilePath.FilePathDialogFilter = resources.GetString("ucrFilePath.FilePathDialogFilter") Me.ucrFilePath.FilePathDialogTitle = "Export Data File" - Me.ucrFilePath.FilePathLabel = "Export File:" + Me.ucrFilePath.FilePathLabel = "Export File(s):" + Me.ucrFilePath.FolderBrowse = False resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") Me.ucrFilePath.Name = "ucrFilePath" ' @@ -76,16 +103,6 @@ Partial Class dlgExportDataset resources.ApplyResources(Me.ucrSelectorDataFrames, "ucrSelectorDataFrames") Me.ucrSelectorDataFrames.Name = "ucrSelectorDataFrames" ' - 'lblDataFrames - ' - resources.ApplyResources(Me.lblDataFrames, "lblDataFrames") - Me.lblDataFrames.Name = "lblDataFrames" - ' - 'lblSelectedDataFrames - ' - resources.ApplyResources(Me.lblSelectedDataFrames, "lblSelectedDataFrames") - Me.lblSelectedDataFrames.Name = "lblSelectedDataFrames" - ' 'ucrReceiverMultipleDataFrames ' Me.ucrReceiverMultipleDataFrames.frmParent = Me @@ -95,17 +112,21 @@ Partial Class dlgExportDataset Me.ucrReceiverMultipleDataFrames.strNcFilePath = "" Me.ucrReceiverMultipleDataFrames.ucrSelector = Nothing ' - 'ucrChkSaveAsSingleFile + 'chkSaveAsSingleFile ' - Me.ucrChkSaveAsSingleFile.Checked = True - resources.ApplyResources(Me.ucrChkSaveAsSingleFile, "ucrChkSaveAsSingleFile") - Me.ucrChkSaveAsSingleFile.Name = "ucrChkSaveAsSingleFile" + resources.ApplyResources(Me.chkSaveAsSingleFile, "chkSaveAsSingleFile") + Me.chkSaveAsSingleFile.Checked = True + Me.chkSaveAsSingleFile.CheckState = System.Windows.Forms.CheckState.Checked + Me.chkSaveAsSingleFile.Name = "chkSaveAsSingleFile" + Me.chkSaveAsSingleFile.UseVisualStyleBackColor = True ' 'dlgExportDataset ' resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.Controls.Add(Me.ucrChkSaveAsSingleFile) + Me.Controls.Add(Me.chkSaveAsSingleFile) + Me.Controls.Add(Me.cboFileExtension) + Me.Controls.Add(Me.lblFileExtension) Me.Controls.Add(Me.ucrReceiverMultipleDataFrames) Me.Controls.Add(Me.lblSelectedDataFrames) Me.Controls.Add(Me.lblDataFrames) @@ -130,5 +151,7 @@ Partial Class dlgExportDataset Friend WithEvents lblDataFrames As Label Friend WithEvents lblSelectedDataFrames As Label Friend WithEvents ucrReceiverMultipleDataFrames As ucrReceiverMultiple - Friend WithEvents ucrChkSaveAsSingleFile As ucrCheck + Friend WithEvents lblFileExtension As Label + Friend WithEvents cboFileExtension As ComboBox + Friend WithEvents chkSaveAsSingleFile As CheckBox End Class diff --git a/instat/dlgExportDataset.resx b/instat/dlgExportDataset.resx index 6c76b2e104e..8f775552094 100644 --- a/instat/dlgExportDataset.resx +++ b/instat/dlgExportDataset.resx @@ -127,7 +127,7 @@ - 92, 237 + 92, 241 2, 0, 2, 0 @@ -151,10 +151,178 @@ $this - 6 + 8 + + + True + + + NoControl + + + 8, 10 + + + 2, 0, 2, 0 + + + 70, 13 + + + 7 + + + Data Frames: + + + lblDataFrames + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + True + + + NoControl + + + 240, 10 + + + 115, 13 + + + 8 + + + Selected Data Frames: + + + lblSelectedDataFrames + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + True + + + NoControl + + + 242, 170 + + + 2, 0, 2, 0 + + + 195, 13 + + + 12 + + + Select File Extension For Selected Files: + + + lblFileExtension + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + .csv + + + .xlsx + + + .tsv + + + .psv + + + .feather + + + .fwf + + + .rds + + + .RData + + + .json + + + .yml + + + .dta + + + .sav + + + .dbf + + + .arff + + + .R + + + .xml + + + .html + + + 245, 184 + + + 133, 21 + + + 4 + + + cboFileExtension + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 - 10, 259 + 10, 261 4, 5, 4, 5 @@ -163,7 +331,7 @@ 405, 53 - 5 + 6 ucrBase @@ -175,19 +343,19 @@ $this - 7 + 9 Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html - 8, 203 + 8, 211 - 403, 26 + 425, 26 - 1 + 5 ucrFilePath @@ -199,7 +367,7 @@ $this - 5 + 7 10, 28 @@ -211,7 +379,7 @@ 216, 147 - 6 + 1 ucrSelectorDataFrames @@ -223,70 +391,7 @@ $this - 4 - - - True - - - NoControl - - - 8, 10 - - - 2, 0, 2, 0 - - - 70, 13 - - - 7 - - - Data Frames: - - - lblDataFrames - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - True - - - NoControl - - - 250, 10 - - - 115, 13 - - - 8 - - - Selected Data Frames: - - - lblSelectedDataFrames - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 + 6 True @@ -298,29 +403,39 @@ True - 417, 319 + 441, 318 + + + True + + + 243, 133 - - 12, 175 + + 160, 30 - - 214, 20 + + 13 - - 10 + + Save as single file +(Excel, RDS, RData, HTML) - - ucrChkSaveAsSingleFile + + chkSaveAsSingleFile - - instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - + 0 + + NoControl + CenterScreen @@ -334,7 +449,7 @@ System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 253, 28 + 243, 28 0, 0, 0, 0 @@ -343,7 +458,7 @@ 120, 100 - 9 + 2 ucrReceiverMultipleDataFrames @@ -355,6 +470,6 @@ $this - 1 + 3 \ No newline at end of file diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index 013c0f0300b..e346b7898d9 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -19,7 +19,7 @@ Imports instat.Translations Public Class dlgExportDataset Dim bFirstLoad As Boolean = True Private bReset As Boolean = True - Private clsDefaultFunction As New RFunction + Private clsDefaultFunction As RFunction Private Sub dlgExportDataset_Load(sender As Object, e As EventArgs) Handles Me.Load autoTranslate(Me) @@ -32,16 +32,9 @@ Public Class dlgExportDataset End If SetRCodeForControls(bReset) bReset = False - TestOkEnabled() End Sub Private Sub InitialiseDialog() - - 'ucrAvailableSheets.SetParameter(New RParameter("x", 0)) - 'ucrAvailableSheets.SetParameterIsRFunction() - 'ucrAvailableSheets.SetText("Data Frame to Export:") - - 'multiple reciever control that holds selected objects ucrReceiverMultipleDataFrames.SetParameter(New RParameter("x", 0)) ucrReceiverMultipleDataFrames.SetParameterIsRFunction() @@ -50,24 +43,21 @@ Public Class dlgExportDataset ucrReceiverMultipleDataFrames.strSelectorHeading = "Data Frames" ucrReceiverMultipleDataFrames.SetItemType("dataframe") - + 'file path control ucrFilePath.SetPathControlParameter(New RParameter("file", 1)) - ucrChkSaveAsSingleFile.Text = "Save as single file" - - lblConfirm.Visible = False - lblConfirm.ForeColor = Color.Green End Sub Private Sub SetDefaults() clsDefaultFunction = New RFunction ucrSelectorDataFrames.Reset() - ucrChkSaveAsSingleFile.Checked = True - ucrChkSaveAsSingleFile.Visible = False + chkSaveAsSingleFile.Checked = True + chkSaveAsSingleFile.Visible = False + cboFileExtension.SelectedIndex = 0 + lblConfirm.Visible = False ucrFilePath.ResetPathControl() - clsDefaultFunction.SetPackageName("rio") clsDefaultFunction.SetRCommand("export") @@ -75,8 +65,12 @@ Public Class dlgExportDataset End Sub Private Sub SetRCodeForControls(bReset As Boolean) - ucrReceiverMultipleDataFrames.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset) - ucrFilePath.SetPathControlRcode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + 'done this way because, the selected base function could be a command string or clsDefaultFunction. + 'so we don't want to reset the controls if command string was the base function on reloading the form + If bReset Then + ucrReceiverMultipleDataFrames.SetRCode(clsDefaultFunction, bReset) + ucrFilePath.SetPathControlRcode(clsDefaultFunction, bReset) + End If End Sub Private Sub TestOkEnabled() @@ -87,33 +81,97 @@ Public Class dlgExportDataset ucrBase.OKEnabled(False) lblConfirm.Visible = False End If - End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaults() SetRCodeForControls(True) - TestOkEnabled() End Sub Private Sub ucrReceiverMultipleDataFrames_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultipleDataFrames.ControlContentsChanged - 'give a suggestive name from selected data frame and change the file filter accordingly - If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length = 1 Then - ucrChkSaveAsSingleFile.Visible = False + chkSaveAsSingleFile.Visible = ucrReceiverMultipleDataFrames.GetVariableNamesList().Length > 1 + SetSaveAsSeparateFilesControlsVisibilty() + ucrFilePath.Clear() 'will raise event FilePathChanged + ChangeFilePathControlSettings() + End Sub + + ''' + ''' this event will always be called when changes happen to the core controls of the form; + ''' receiver, file path, save as single checkbox + ''' + Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged + 'if no or single data frame selected or save as single checked then just set the base function to the default + If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length <= 1 OrElse chkSaveAsSingleFile.Checked Then + ucrBase.clsRsyntax.SetBaseRFunction(clsDefaultFunction) + Else + 'else, create a string command for exporting separate files to a directory. + 'note, as of 09/09/2020 rio didn't support exporting separate files in 1 command see issue ##5590 + Dim lstItems As String() = ucrReceiverMultipleDataFrames.GetVariableNamesList(bWithQuotes:=False) + Dim strCommand As String = "" + For Each strItem In lstItems + strCommand = strCommand & "rio::export( x = data_book$get_data_frame(data_name=""" & strItem & """), file = """ & ucrFilePath.FilePath & "/" & strItem & cboFileExtension.Text & """)" & Environment.NewLine + Next + ucrBase.clsRsyntax.SetCommandString(strCommand) + End If + TestOkEnabled() + End Sub + + Private Sub ucrMultipleFilesControls_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverMultipleDataFrames.ControlContentsChanged + SetSaveAsSeparateFilesControlsVisibilty() + ChangeFilePathControlSettings() + ucrFilePath.Clear() 'will raise event FilePathChanged + End Sub + + Private Sub chkSaveAsSingleFile_CheckedChanged(sender As Object, e As EventArgs) Handles chkSaveAsSingleFile.CheckedChanged + SetSaveAsSeparateFilesControlsVisibilty() + ChangeFilePathControlSettings() + ucrFilePath.Clear() 'will raise event FilePathChanged + End Sub + + Private Sub cboFileExtension_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboFileExtension.SelectedIndexChanged + ChangeFilePathControlSettings() + ucrFilePath.Clear() 'will raise event FilePathChanged + End Sub + + ''' + ''' changes the file path control settings; + ''' FolderBrowse, DefaultFileSuggestionName, FilePathDialogFilter + ''' the changed settings determine the behaviour of the file path contro + ''' + Private Sub ChangeFilePathControlSettings() + ucrFilePath.FolderBrowse = False 'set file path control to open default SaveFileDialog prompt + ucrFilePath.DefaultFileSuggestionName = "" + ucrFilePath.FilePathDialogFilter = "" + ucrFilePath.SelectedFileFilterIndex = 0 + + 'if its a single data frame selected. Just set file path settings to defaults and exit sub + If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length <= 1 Then ucrFilePath.DefaultFileSuggestionName = ucrReceiverMultipleDataFrames.GetVariableNames(bWithQuotes:=False) ucrFilePath.FilePathDialogFilter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html" - Else - ucrChkSaveAsSingleFile.Visible = True - ucrFilePath.DefaultFileSuggestionName = "" - ucrFilePath.FilePathDialogFilter = "Excel files (*.xlsx)|*.xlsx|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|HTML(*.html)|*.html" + Exit Sub End If - 'clear the file path contents. - ucrFilePath.Clear() + 'if multiple data frames have been selected then do the following + If chkSaveAsSingleFile.Checked Then + 'if checkbox is visible and checked, set the file extension filter to 3 file types; .xlsx,rds,rData + ucrFilePath.FilePathDialogFilter = "Excel files (*.xlsx)|*.xlsx|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|HTML(*.html)|*.html" + Else + 'if checkbox not checked, set file path control to open folder browser dialog prompt instead of save file dialog prompt + ucrFilePath.FolderBrowse = True + End If End Sub - Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged - TestOkEnabled() + ''' + ''' changes the visibilty of the save as separate files controls; lblFileExtension, cboFileExtension + ''' + Private Sub SetSaveAsSeparateFilesControlsVisibilty() + lblFileExtension.Visible = False + cboFileExtension.Visible = False + If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length > 1 AndAlso Not chkSaveAsSingleFile.Checked Then + lblFileExtension.Visible = True + cboFileExtension.Visible = True + End If End Sub + End Class diff --git a/instat/dlgExportRObjects.vb b/instat/dlgExportRObjects.vb index fc1246da1d2..5151a9fc889 100644 --- a/instat/dlgExportRObjects.vb +++ b/instat/dlgExportRObjects.vb @@ -31,7 +31,7 @@ Public Class dlgExportRObjects End If SetRCodeForControls(bReset) bReset = False - TestOkEnabled() + 'TestOkEnabled() End Sub Private Sub InitialiseDialog() @@ -52,7 +52,7 @@ Public Class dlgExportRObjects clsExport = New RFunction 'reset controls - ucrSelectorObjects.Reset() + ucrSelectorObjects.Reset() 'will also reset the reciever ucrFilePath.ResetPathControl() 'set R command and base function @@ -73,11 +73,11 @@ Public Class dlgExportRObjects Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaults() SetRCodeForControls(True) - TestOkEnabled() + 'TestOkEnabled() End Sub Private Sub ucrReceiverMultipleObjects_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultipleObjects.ControlContentsChanged - 'ucrReceiverObjects is a multireceiver. So give a default suggested name if it has 1 item only + 'give a default suggested name if only a single object is selected object ucrFilePath.DefaultFileSuggestionName = If(ucrReceiverMultipleObjects.GetVariableNamesList().Length = 1, ucrReceiverMultipleObjects.GetVariableNames(bWithQuotes:=False), "") TestOkEnabled() End Sub diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 16d6789f194..86a4f28b72e 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -33,6 +33,8 @@ Imports System.IO ''' ''' Public Class ucrFilePath + Private bFirstLoad As Boolean = True + ''' ''' event raised when the file path contents has changed ''' @@ -50,6 +52,12 @@ Public Class ucrFilePath End Set End Property + ''' + ''' flag used to determine whether the opened dialog prompt will be + ''' FolderBrowserDialog or SaveFileDialog + ''' + Public Property FolderBrowse As Boolean = False + ''' ''' gets and sets the label text property value of the input textbox ''' @@ -67,9 +75,18 @@ Public Class ucrFilePath ''' Public Property FilePathDialogTitle As String = "Save As" - 'used to set the allowed file filters or file extensions + ''' + ''' used to set the allowed file filters or file extensions + ''' Public Property FilePathDialogFilter As String = "All Files *.*" + ''' + ''' gets or sets the last selected filter index. + ''' used by the SaveFileDiaolog prompt to 'remember' last selected file type filter + ''' and by dialogs to know selected filter index + ''' + Public Property SelectedFileFilterIndex As Integer + ''' ''' used to set the suggested name if no file name was set before ''' @@ -77,8 +94,8 @@ Public Class ucrFilePath Public Property DefaultFileSuggestionName As String = "" ''' - ''' gets or sets the input file path used by the SaveFileDiaolog prompt to 'remember' the - ''' last selected file name and directory + ''' gets or sets the input file path used by the FolderBrowseDialog or SaveFileDialog prompt + ''' also sets PreviousSelectedWindowsFilePath to 'remember' the last selected file name and directory ''' Public Property FilePath() As String Get @@ -87,16 +104,20 @@ Public Class ucrFilePath Set(ByVal value As String) 'first replace backward slashed with forward slashes cause of R path formats PathControl().SetName(value.Replace("\", "/")) + If value <> "" Then + 'to be safe, always replace the forward slashes with back slashes. values will be used by vb.net sialog prompts + PreviousSelectedWindowsFilePath = value.Replace("/", "\") + End If RaiseEvent FilePathChanged() End Set End Property ''' - ''' gets or sets the last selected filter index. - ''' used by the SaveFileDiaolog prompt to 'remember' last selected file type filter - ''' and by dialogs to know selected filter index - ''' - Public SelectedFileFilterIndex As Integer + ''' gets or sets the previously set path. This is never cleared when sub clear() is called. + ''' its used internally to set initial directories of the folder or save dialogs prompts even when path was extenally cleared + ''' the path will always be in windows backslash convention format i.e uses "\" instead of "/" + ''' + Private Property PreviousSelectedWindowsFilePath As String = "" ''' ''' gets the control that contains the input file path and name @@ -141,6 +162,14 @@ Public Class ucrFilePath FilePath = "" End Sub + + Private Sub ucrFilePath_Load(sender As Object, e As EventArgs) Handles Me.Load + If bFirstLoad Then + AddButtonInFilePathControlTextbox() + bFirstLoad = False + End If + End Sub + ''' ''' opens a SaveFileDialog prompt thats allows user to specify file name and path ''' to be used in saving a file @@ -148,28 +177,98 @@ Public Class ucrFilePath ''' ''' Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click - Using dlgSave As New SaveFileDialog - dlgSave.Title = FilePathDialogTitle - dlgSave.Filter = FilePathDialogFilter - If IsEmpty() Then - dlgSave.FileName = DefaultFileSuggestionName - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - Else - 'use the file path in windows backslash convention format - Dim strFilePathInWindowsFormat As String = FilePath.Replace("/", "\") - dlgSave.FileName = Path.GetFileName(strFilePathInWindowsFormat) - dlgSave.InitialDirectory = Path.GetDirectoryName(strFilePathInWindowsFormat) - dlgSave.FilterIndex = SelectedFileFilterIndex - End If - If DialogResult.OK = dlgSave.ShowDialog() Then - FilePath = dlgSave.FileName - SelectedFileFilterIndex = dlgSave.FilterIndex - End If - End Using + If FolderBrowse Then + Using dlgFolderBrowse As New FolderBrowserDialog + If String.IsNullOrEmpty(PreviousSelectedWindowsFilePath) Then + dlgFolderBrowse.SelectedPath = frmMain.clsInstatOptions.strWorkingDirectory + Else + 'use the file path in windows backslash convention format + dlgFolderBrowse.SelectedPath = Path.GetDirectoryName(PreviousSelectedWindowsFilePath) + End If + If DialogResult.OK = dlgFolderBrowse.ShowDialog() Then + FilePath = dlgFolderBrowse.SelectedPath + 'reset the filter index(start index is 1). its safer to, just incase save dialog is used later + SelectedFileFilterIndex = 1 + End If + End Using + Else + Using dlgSaveFile As New SaveFileDialog + dlgSaveFile.Title = FilePathDialogTitle + dlgSaveFile.Filter = FilePathDialogFilter + If String.IsNullOrEmpty(PreviousSelectedWindowsFilePath) Then + dlgSaveFile.FileName = DefaultFileSuggestionName + dlgSaveFile.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory + Else + 'if there is no current file path and there is a default suggested name, then use the default suggestion + 'else check if previous selected path has an extension to determine if the previous path included a file name and use it + If IsEmpty() AndAlso Not String.IsNullOrEmpty(DefaultFileSuggestionName) Then + dlgSaveFile.FileName = DefaultFileSuggestionName + ElseIf Not String.IsNullOrEmpty(Path.GetExtension(PreviousSelectedWindowsFilePath)) Then + dlgSaveFile.FileName = Path.GetFileNameWithoutExtension(PreviousSelectedWindowsFilePath) + End If + + dlgSaveFile.InitialDirectory = Path.GetDirectoryName(PreviousSelectedWindowsFilePath) + dlgSaveFile.FilterIndex = SelectedFileFilterIndex + + End If + If DialogResult.OK = dlgSaveFile.ShowDialog() Then + FilePath = dlgSaveFile.FileName + SelectedFileFilterIndex = dlgSaveFile.FilterIndex + End If + End Using + End If End Sub Private Sub ucrInputFilePath_Click(sender As Object, e As EventArgs) Handles ucrInputFilePath.Click btnBrowse.PerformClick() End Sub + Private Sub AddButtonInFilePathControlTextbox() + Dim btnViewMore As New Button + 'add the button to the comment textbox first + 'PathControl.txtInput.Controls.Clear() + PathControl.txtInput.Controls.Add(btnViewMore) + + 'then set the button properties + btnViewMore.Text = ":::" 'temp. This will be shown as centered. + btnViewMore.Size = New Size(25, PathControl.txtInput.ClientSize.Height + 2) + btnViewMore.TextAlign = ContentAlignment.TopCenter + btnViewMore.FlatStyle = FlatStyle.Standard + btnViewMore.FlatAppearance.BorderSize = 0 + btnViewMore.Cursor = Cursors.Default + btnViewMore.Dock = DockStyle.Right + btnViewMore.BackColor = btnBrowse.BackColor + btnViewMore.UseVisualStyleBackColor = True + + 'set the button event handler + AddHandler btnViewMore.Click, Sub() + 'shows a popup that displays the whole file path + Dim objPopup As New clsPopup + Dim txtShowFilePath As New TextBox With { + .Multiline = True, + .ScrollBars = ScrollBars.Vertical, + .WordWrap = False + } + + 'attach event handlers that allow editing of the poped up text + AddHandler txtShowFilePath.LostFocus, Sub() + FilePath = txtShowFilePath.Text + End Sub + AddHandler txtShowFilePath.KeyDown, Sub(sender As Object, e As KeyEventArgs) + If e.Control AndAlso e.KeyCode = Keys.Enter Then + FilePath = txtShowFilePath.Text + objPopup.Hide() + End If + End Sub + 'set the contents control and show the popup + objPopup.SetContentControl(txtShowFilePath) + objPopup.SetSize(ucrInputFilePath.Width, ucrInputFilePath.Height + 100) + objPopup.Show(ucrInputFilePath) + txtShowFilePath.Text = FilePath + txtShowFilePath.SelectionStart = FilePath.Length + End Sub + + End Sub + + End Class From f266f2b95263cc93deb99f174338beaa067481d2 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 10 Sep 2020 11:39:40 +0300 Subject: [PATCH 12/26] more code additions --- instat/dlgExportDataset.vb | 1 - instat/ucrFilePath.vb | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index e346b7898d9..aff40a08128 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -142,7 +142,6 @@ Public Class dlgExportDataset ucrFilePath.FolderBrowse = False 'set file path control to open default SaveFileDialog prompt ucrFilePath.DefaultFileSuggestionName = "" ucrFilePath.FilePathDialogFilter = "" - ucrFilePath.SelectedFileFilterIndex = 0 'if its a single data frame selected. Just set file path settings to defaults and exit sub If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length <= 1 Then diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 86a4f28b72e..6c2ee69907c 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -34,6 +34,7 @@ Imports System.IO ''' Public Class ucrFilePath Private bFirstLoad As Boolean = True + Private strFilePathDialogFilter As String = "All Files *.*" ''' ''' event raised when the file path contents has changed @@ -78,7 +79,17 @@ Public Class ucrFilePath ''' ''' used to set the allowed file filters or file extensions ''' - Public Property FilePathDialogFilter As String = "All Files *.*" + Public Property FilePathDialogFilter As String + Get + Return strFilePathDialogFilter + End Get + Set(ByVal value As String) + strFilePathDialogFilter = value + 'reset the filter index(start index is 1). + 'its safer To, just incase number of filters set are different from previously set + SelectedFileFilterIndex = 1 + End Set + End Property ''' ''' gets or sets the last selected filter index. @@ -162,7 +173,6 @@ Public Class ucrFilePath FilePath = "" End Sub - Private Sub ucrFilePath_Load(sender As Object, e As EventArgs) Handles Me.Load If bFirstLoad Then AddButtonInFilePathControlTextbox() @@ -223,6 +233,9 @@ Public Class ucrFilePath btnBrowse.PerformClick() End Sub + ''' + ''' adds the button for showing popup used to view the whole file path + ''' Private Sub AddButtonInFilePathControlTextbox() Dim btnViewMore As New Button 'add the button to the comment textbox first From d80e390949a1e5900fd224eedb71590b0f1cc42f Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 10 Sep 2020 11:58:21 +0300 Subject: [PATCH 13/26] additional extensions --- instat/dlgExportDataset.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index aff40a08128..a74d5597511 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -146,7 +146,7 @@ Public Class dlgExportDataset 'if its a single data frame selected. Just set file path settings to defaults and exit sub If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length <= 1 Then ucrFilePath.DefaultFileSuggestionName = ucrReceiverMultipleDataFrames.GetVariableNames(bWithQuotes:=False) - ucrFilePath.FilePathDialogFilter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html" + ucrFilePath.FilePathDialogFilter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html|Matlab(*.mat)|*.mat|sas(*.sas7bdat)|*.sas7bdat" Exit Sub End If From 0b5493547bdc2d4a2e7b5e7adf69bfd73cb156ed Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 10 Sep 2020 12:12:48 +0300 Subject: [PATCH 14/26] added extensions --- instat/dlgExportDataset.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index a74d5597511..ac03998a21b 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -146,7 +146,7 @@ Public Class dlgExportDataset 'if its a single data frame selected. Just set file path settings to defaults and exit sub If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length <= 1 Then ucrFilePath.DefaultFileSuggestionName = ucrReceiverMultipleDataFrames.GetVariableNames(bWithQuotes:=False) - ucrFilePath.FilePathDialogFilter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html|Matlab(*.mat)|*.mat|sas(*.sas7bdat)|*.sas7bdat" + ucrFilePath.FilePathDialogFilter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html|Matlab(*.mat)|*.mat|SAS(*.sas7bdat)|*.sas7bdat" Exit Sub End If From b47e3be6a3182673f1251fa78051b6c4fd17e84d Mon Sep 17 00:00:00 2001 From: patowhiz Date: Mon, 28 Sep 2020 11:28:12 +0300 Subject: [PATCH 15/26] added the SAS XPORT extension --- instat/dlgExportDataset.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index ac03998a21b..9c320146ded 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -146,7 +146,7 @@ Public Class dlgExportDataset 'if its a single data frame selected. Just set file path settings to defaults and exit sub If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length <= 1 Then ucrFilePath.DefaultFileSuggestionName = ucrReceiverMultipleDataFrames.GetVariableNames(bWithQuotes:=False) - ucrFilePath.FilePathDialogFilter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html|Matlab(*.mat)|*.mat|SAS(*.sas7bdat)|*.sas7bdat" + ucrFilePath.FilePathDialogFilter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html|Matlab(*.mat)|*.mat|SAS(*.sas7bdat)|*.sas7bdat|SAS XPORT(*.xpt)|*.xpt" Exit Sub End If From 110008f9748d7dade1b3f9c1bc3a46b94e175f20 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 13 Oct 2020 09:07:01 +0300 Subject: [PATCH 16/26] added word wrapping of text contents --- instat/ucrFilePath.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 6c2ee69907c..ab9f6312178 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -260,7 +260,7 @@ Public Class ucrFilePath Dim txtShowFilePath As New TextBox With { .Multiline = True, .ScrollBars = ScrollBars.Vertical, - .WordWrap = False + .WordWrap = True } 'attach event handlers that allow editing of the poped up text From e6d1af2978575d1c64ddaf13f1c645ef8a772dbc Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 14 Oct 2020 20:52:17 +0300 Subject: [PATCH 17/26] added warning text when exporting multiple data frames as separate files --- instat/dlgExportDataset.Designer.vb | 1 + instat/dlgExportDataset.resx | 9 +++------ instat/dlgExportDataset.vb | 6 +++++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/instat/dlgExportDataset.Designer.vb b/instat/dlgExportDataset.Designer.vb index f5ce95ac8c1..db505a89091 100644 --- a/instat/dlgExportDataset.Designer.vb +++ b/instat/dlgExportDataset.Designer.vb @@ -96,6 +96,7 @@ Partial Class dlgExportDataset Me.ucrFilePath.FolderBrowse = False resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") Me.ucrFilePath.Name = "ucrFilePath" + Me.ucrFilePath.SelectedFileFilterIndex = 1 ' 'ucrSelectorDataFrames ' diff --git a/instat/dlgExportDataset.resx b/instat/dlgExportDataset.resx index 8f775552094..eb7cb8743ca 100644 --- a/instat/dlgExportDataset.resx +++ b/instat/dlgExportDataset.resx @@ -127,7 +127,7 @@ - 92, 241 + 85, 240 2, 0, 2, 0 @@ -322,7 +322,7 @@ 1 - 10, 261 + 10, 270 4, 5, 4, 5 @@ -403,7 +403,7 @@ True - 441, 318 + 441, 331 True @@ -433,9 +433,6 @@ 0 - - NoControl - CenterScreen diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index 9c320146ded..24b1bd6391b 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -22,7 +22,9 @@ Public Class dlgExportDataset Private clsDefaultFunction As RFunction Private Sub dlgExportDataset_Load(sender As Object, e As EventArgs) Handles Me.Load - autoTranslate(Me) + 'temporarily commented out because it overwrites lblConfirm text contents + 'autoTranslate(Me) + If bFirstLoad Then InitialiseDialog() bFirstLoad = False @@ -103,6 +105,7 @@ Public Class dlgExportDataset 'if no or single data frame selected or save as single checked then just set the base function to the default If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length <= 1 OrElse chkSaveAsSingleFile.Checked Then ucrBase.clsRsyntax.SetBaseRFunction(clsDefaultFunction) + lblConfirm.Text = "Click Ok to Confirm the Export" Else 'else, create a string command for exporting separate files to a directory. 'note, as of 09/09/2020 rio didn't support exporting separate files in 1 command see issue ##5590 @@ -112,6 +115,7 @@ Public Class dlgExportDataset strCommand = strCommand & "rio::export( x = data_book$get_data_frame(data_name=""" & strItem & """), file = """ & ucrFilePath.FilePath & "/" & strItem & cboFileExtension.Text & """)" & Environment.NewLine Next ucrBase.clsRsyntax.SetCommandString(strCommand) + lblConfirm.Text = "Files with similar names will be overwritten if they already exist." & Environment.NewLine & "Click Ok to Confirm the Export." End If TestOkEnabled() End Sub From 3956fbca9fff98315c748c29264db8a5884b36f4 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 14 Oct 2020 22:24:53 +0300 Subject: [PATCH 18/26] changed confirmation text to @rdstern suggestion. --- instat/dlgExportDataset.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index 24b1bd6391b..bb70fb3f6b5 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -105,7 +105,7 @@ Public Class dlgExportDataset 'if no or single data frame selected or save as single checked then just set the base function to the default If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length <= 1 OrElse chkSaveAsSingleFile.Checked Then ucrBase.clsRsyntax.SetBaseRFunction(clsDefaultFunction) - lblConfirm.Text = "Click Ok to Confirm the Export" + lblConfirm.Text = "Click Ok to Confirm the Export." Else 'else, create a string command for exporting separate files to a directory. 'note, as of 09/09/2020 rio didn't support exporting separate files in 1 command see issue ##5590 @@ -115,7 +115,7 @@ Public Class dlgExportDataset strCommand = strCommand & "rio::export( x = data_book$get_data_frame(data_name=""" & strItem & """), file = """ & ucrFilePath.FilePath & "/" & strItem & cboFileExtension.Text & """)" & Environment.NewLine Next ucrBase.clsRsyntax.SetCommandString(strCommand) - lblConfirm.Text = "Files with similar names will be overwritten if they already exist." & Environment.NewLine & "Click Ok to Confirm the Export." + lblConfirm.Text = "Files with the same names will be overwritten." & Environment.NewLine & "Click Ok to Confirm the Export." End If TestOkEnabled() End Sub From caa93d5c3614863438116aa2fe34c0dccbc07f3f Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 27 Oct 2020 12:01:07 +0300 Subject: [PATCH 19/26] Update instat/ucrFilePath.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrFilePath.vb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index ab9f6312178..23a77b8b46f 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -18,20 +18,24 @@ Imports System.IO '''-------------------------------------------------------------------------------------------- ''' -''' An object of this class represents a file path custom control that inherits System.Windows.Forms.UserControl -''' and is used to select the file name and path to be used in saving a file +''' An object of this class represents a file path custom control that inherits +''' System.Windows.Forms.UserControl and is used to select the file name and path to be used in +''' saving a file. +''' +''' This class provides methods and fields to: ''' ''' -''' set the parameter of the path control +''' Set the parameter of the path control ''' ''' -''' set the R code structure of the path control +''' Set the R code structure of the path control ''' ''' ''' Optional. Set a default suggested name ''' ''' ''' +'''-------------------------------------------------------------------------------------------- Public Class ucrFilePath Private bFirstLoad As Boolean = True Private strFilePathDialogFilter As String = "All Files *.*" From 4a3c612fcd9e95cedb9fe43eb0ef605800283590 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 27 Oct 2020 12:01:55 +0300 Subject: [PATCH 20/26] Update instat/ucrFilePath.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/ucrFilePath.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 23a77b8b46f..3fb8a684a1d 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -148,8 +148,8 @@ Public Class ucrFilePath ''' Sets the R parameter to the path control ''' ''' - Public Sub SetPathControlParameter(rParamter As RParameter) - PathControl().SetParameter(rParamter) + Public Sub SetPathControlParameter(rParameter As RParameter) + PathControl().SetParameter(rParameter) End Sub ''' From 1f8629d609bd88fb45031bd1eaac995d89babba2 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 27 Oct 2020 12:51:58 +0300 Subject: [PATCH 21/26] comment change --- instat/ucrFilePath.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 3fb8a684a1d..318d96088f1 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -147,7 +147,7 @@ Public Class ucrFilePath ''' ''' Sets the R parameter to the path control ''' - ''' + ''' Public Sub SetPathControlParameter(rParameter As RParameter) PathControl().SetParameter(rParameter) End Sub From 37b337dfd67cd12ed4ebfb55c90ec02a96d6cb21 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 27 Oct 2020 12:54:49 +0300 Subject: [PATCH 22/26] empty file name comment addition --- instat/ucrFilePath.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/instat/ucrFilePath.vb b/instat/ucrFilePath.vb index 318d96088f1..b9855dadacb 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -215,6 +215,7 @@ Public Class ucrFilePath Else 'if there is no current file path and there is a default suggested name, then use the default suggestion 'else check if previous selected path has an extension to determine if the previous path included a file name and use it + 'else leave the FileName as empty(it's the default) If IsEmpty() AndAlso Not String.IsNullOrEmpty(DefaultFileSuggestionName) Then dlgSaveFile.FileName = DefaultFileSuggestionName ElseIf Not String.IsNullOrEmpty(Path.GetExtension(PreviousSelectedWindowsFilePath)) Then From e143366a38d5acd9afa049724b2fb84ac12ec89f Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 2 Dec 2020 11:48:36 +0300 Subject: [PATCH 23/26] added the merged saving functionality --- instat/dlgSaveAs.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/instat/dlgSaveAs.vb b/instat/dlgSaveAs.vb index 45e5a403016..096daa62dc3 100644 --- a/instat/dlgSaveAs.vb +++ b/instat/dlgSaveAs.vb @@ -76,6 +76,7 @@ Public Class dlgSaveAs Private Sub ucrBase_ClickOk(sender As Object, e As EventArgs) Handles ucrBase.ClickOk frmMain.strSaveFilePath = ucrFilePath.FilePath frmMain.clsRecentItems.addToMenu(Replace(ucrFilePath.FilePath, "/", "\")) + frmMain.bDataSaved = True End Sub Private Sub ucrFilePath_FilePathChanged() Handles ucrFilePath.FilePathChanged From b4ec475b82d96a1e743159c81fd2d9eee0846572 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Mon, 18 Jan 2021 16:19:09 +0300 Subject: [PATCH 24/26] implemented suggested changess --- instat/dlgExportDataset.Designer.vb | 18 ++--- instat/dlgExportDataset.resx | 63 ++++++++------- instat/dlgExportDataset.vb | 117 ++++++++++++++++++---------- 3 files changed, 117 insertions(+), 81 deletions(-) diff --git a/instat/dlgExportDataset.Designer.vb b/instat/dlgExportDataset.Designer.vb index db505a89091..b741ebc7c64 100644 --- a/instat/dlgExportDataset.Designer.vb +++ b/instat/dlgExportDataset.Designer.vb @@ -43,7 +43,7 @@ Partial Class dlgExportDataset Me.lblDataFrames = New System.Windows.Forms.Label() Me.lblSelectedDataFrames = New System.Windows.Forms.Label() Me.lblFileExtension = New System.Windows.Forms.Label() - Me.cboFileExtension = New System.Windows.Forms.ComboBox() + Me.cboFileType = New System.Windows.Forms.ComboBox() Me.ucrBase = New instat.ucrButtons() Me.ucrFilePath = New instat.ucrFilePath() Me.ucrSelectorDataFrames = New instat.ucrSelectorAddRemove() @@ -72,13 +72,13 @@ Partial Class dlgExportDataset resources.ApplyResources(Me.lblFileExtension, "lblFileExtension") Me.lblFileExtension.Name = "lblFileExtension" ' - 'cboFileExtension + 'cboFileType ' - Me.cboFileExtension.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList - Me.cboFileExtension.FormattingEnabled = True - Me.cboFileExtension.Items.AddRange(New Object() {resources.GetString("cboFileExtension.Items"), resources.GetString("cboFileExtension.Items1"), resources.GetString("cboFileExtension.Items2"), resources.GetString("cboFileExtension.Items3"), resources.GetString("cboFileExtension.Items4"), resources.GetString("cboFileExtension.Items5"), resources.GetString("cboFileExtension.Items6"), resources.GetString("cboFileExtension.Items7"), resources.GetString("cboFileExtension.Items8"), resources.GetString("cboFileExtension.Items9"), resources.GetString("cboFileExtension.Items10"), resources.GetString("cboFileExtension.Items11"), resources.GetString("cboFileExtension.Items12"), resources.GetString("cboFileExtension.Items13"), resources.GetString("cboFileExtension.Items14"), resources.GetString("cboFileExtension.Items15"), resources.GetString("cboFileExtension.Items16")}) - resources.ApplyResources(Me.cboFileExtension, "cboFileExtension") - Me.cboFileExtension.Name = "cboFileExtension" + Me.cboFileType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList + Me.cboFileType.FormattingEnabled = True + Me.cboFileType.Items.AddRange(New Object() {resources.GetString("cboFileType.Items"), resources.GetString("cboFileType.Items1"), resources.GetString("cboFileType.Items2"), resources.GetString("cboFileType.Items3"), resources.GetString("cboFileType.Items4"), resources.GetString("cboFileType.Items5"), resources.GetString("cboFileType.Items6"), resources.GetString("cboFileType.Items7"), resources.GetString("cboFileType.Items8"), resources.GetString("cboFileType.Items9"), resources.GetString("cboFileType.Items10"), resources.GetString("cboFileType.Items11"), resources.GetString("cboFileType.Items12"), resources.GetString("cboFileType.Items13"), resources.GetString("cboFileType.Items14"), resources.GetString("cboFileType.Items15"), resources.GetString("cboFileType.Items16")}) + resources.ApplyResources(Me.cboFileType, "cboFileType") + Me.cboFileType.Name = "cboFileType" ' 'ucrBase ' @@ -126,7 +126,7 @@ Partial Class dlgExportDataset resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.Controls.Add(Me.chkSaveAsSingleFile) - Me.Controls.Add(Me.cboFileExtension) + Me.Controls.Add(Me.cboFileType) Me.Controls.Add(Me.lblFileExtension) Me.Controls.Add(Me.ucrReceiverMultipleDataFrames) Me.Controls.Add(Me.lblSelectedDataFrames) @@ -153,6 +153,6 @@ Partial Class dlgExportDataset Friend WithEvents lblSelectedDataFrames As Label Friend WithEvents ucrReceiverMultipleDataFrames As ucrReceiverMultiple Friend WithEvents lblFileExtension As Label - Friend WithEvents cboFileExtension As ComboBox + Friend WithEvents cboFileType As ComboBox Friend WithEvents chkSaveAsSingleFile As CheckBox End Class diff --git a/instat/dlgExportDataset.resx b/instat/dlgExportDataset.resx index eb7cb8743ca..67876d13f7c 100644 --- a/instat/dlgExportDataset.resx +++ b/instat/dlgExportDataset.resx @@ -223,19 +223,19 @@ NoControl - 242, 170 + 242, 161 2, 0, 2, 0 - 195, 13 + 86, 13 12 - Select File Extension For Selected Files: + Select File Type: lblFileExtension @@ -249,76 +249,76 @@ 2 - + .csv - + .xlsx - + .tsv - + .psv - + .feather - + .fwf - + .rds - + .RData - + .json - + .yml - + .dta - + .sav - + .dbf - + .arff - + .R - + .xml - + .html - - 245, 184 + + 245, 175 - + 133, 21 - + 4 - - cboFileExtension + + cboFileType - + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - + 1 @@ -412,14 +412,13 @@ 243, 133 - 160, 30 + 111, 17 13 - Save as single file -(Excel, RDS, RData, HTML) + Save as single file chkSaveAsSingleFile diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index bb70fb3f6b5..7cca467a53b 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -20,6 +20,7 @@ Public Class dlgExportDataset Dim bFirstLoad As Boolean = True Private bReset As Boolean = True Private clsDefaultFunction As RFunction + Private bSupressFileValuesChange As Boolean = False Private Sub dlgExportDataset_Load(sender As Object, e As EventArgs) Handles Me.Load 'temporarily commented out because it overwrites lblConfirm text contents @@ -54,9 +55,9 @@ Public Class dlgExportDataset clsDefaultFunction = New RFunction ucrSelectorDataFrames.Reset() - chkSaveAsSingleFile.Checked = True + chkSaveAsSingleFile.Checked = False chkSaveAsSingleFile.Visible = False - cboFileExtension.SelectedIndex = 0 + cboFileType.SelectedIndex = 0 lblConfirm.Visible = False ucrFilePath.ResetPathControl() @@ -92,9 +93,8 @@ Public Class dlgExportDataset Private Sub ucrReceiverMultipleDataFrames_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultipleDataFrames.ControlContentsChanged chkSaveAsSingleFile.Visible = ucrReceiverMultipleDataFrames.GetVariableNamesList().Length > 1 - SetSaveAsSeparateFilesControlsVisibilty() + ChangeFileControlsValues() ucrFilePath.Clear() 'will raise event FilePathChanged - ChangeFilePathControlSettings() End Sub ''' @@ -108,11 +108,11 @@ Public Class dlgExportDataset lblConfirm.Text = "Click Ok to Confirm the Export." Else 'else, create a string command for exporting separate files to a directory. - 'note, as of 09/09/2020 rio didn't support exporting separate files in 1 command see issue ##5590 + 'note, as of 09/09/2020 rio didn't support exporting separate files in 1 command see issue #5590 Dim lstItems As String() = ucrReceiverMultipleDataFrames.GetVariableNamesList(bWithQuotes:=False) Dim strCommand As String = "" For Each strItem In lstItems - strCommand = strCommand & "rio::export( x = data_book$get_data_frame(data_name=""" & strItem & """), file = """ & ucrFilePath.FilePath & "/" & strItem & cboFileExtension.Text & """)" & Environment.NewLine + strCommand = strCommand & "rio::export( x = data_book$get_data_frame(data_name=""" & strItem & """), file = """ & ucrFilePath.FilePath & "/" & strItem & GetSelectedExtension(cboFileType.SelectedItem) & """)" & Environment.NewLine Next ucrBase.clsRsyntax.SetCommandString(strCommand) lblConfirm.Text = "Files with the same names will be overwritten." & Environment.NewLine & "Click Ok to Confirm the Export." @@ -120,61 +120,98 @@ Public Class dlgExportDataset TestOkEnabled() End Sub - Private Sub ucrMultipleFilesControls_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverMultipleDataFrames.ControlContentsChanged - SetSaveAsSeparateFilesControlsVisibilty() - ChangeFilePathControlSettings() - ucrFilePath.Clear() 'will raise event FilePathChanged - End Sub - Private Sub chkSaveAsSingleFile_CheckedChanged(sender As Object, e As EventArgs) Handles chkSaveAsSingleFile.CheckedChanged - SetSaveAsSeparateFilesControlsVisibilty() - ChangeFilePathControlSettings() + ChangeFileControlsValues() ucrFilePath.Clear() 'will raise event FilePathChanged End Sub - Private Sub cboFileExtension_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboFileExtension.SelectedIndexChanged - ChangeFilePathControlSettings() + Private Sub cboFileExtension_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboFileType.SelectedIndexChanged + 'ChangeFileControlsValues() ucrFilePath.Clear() 'will raise event FilePathChanged + ucrFilePath.FilePathDialogFilter = GetFilePathDialogFilterText(cboFileType.SelectedItem) End Sub ''' - ''' changes the file path control settings; - ''' FolderBrowse, DefaultFileSuggestionName, FilePathDialogFilter + ''' changes the file path and cboFileType control values; + ''' the FolderBrowse, DefaultFileSuggestionName, FilePathDialogFilter, selectable file types ''' the changed settings determine the behaviour of the file path contro ''' - Private Sub ChangeFilePathControlSettings() + Private Sub ChangeFileControlsValues() + If bSupressFileValuesChange Then + Exit Sub + End If + + bSupressFileValuesChange = True + Dim strPrevSelectedFileType As String = cboFileType.SelectedItem + Dim iSelectedDataFrames As Integer = ucrReceiverMultipleDataFrames.GetVariableNamesList().Length ucrFilePath.FolderBrowse = False 'set file path control to open default SaveFileDialog prompt ucrFilePath.DefaultFileSuggestionName = "" ucrFilePath.FilePathDialogFilter = "" + cboFileType.Items.Clear() + - 'if its a single data frame selected. Just set file path settings to defaults and exit sub - If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length <= 1 Then + ucrFilePath.FolderBrowse = iSelectedDataFrames > 1 AndAlso Not chkSaveAsSingleFile.Checked + + If iSelectedDataFrames > 1 AndAlso chkSaveAsSingleFile.Checked Then + 'file types currently supported insaving of multiple files into a single file + cboFileType.Items.Add("Excel files (*.xlsx)") + cboFileType.Items.Add("Serialized r objects (*.rds)") + cboFileType.Items.Add("Saved r objects (*.RData)") + cboFileType.Items.Add("HTML (*.html)") + Else + 'file types supported + cboFileType.Items.Add("Comma separated file (*.csv)") + cboFileType.Items.Add("Excel files (*.xlsx)") + cboFileType.Items.Add("TAB-separated data (*.tsv)") + cboFileType.Items.Add("Pipe-separated data (*.psv)") + cboFileType.Items.Add("Feather r / Python interchange format (*.feather)") + cboFileType.Items.Add("Fixed-Width format data (*.fwf)") + cboFileType.Items.Add("Serialized r objects (*.rds)") + cboFileType.Items.Add("Saved r objects (*.RData)") + cboFileType.Items.Add("JSON (*.json)") + cboFileType.Items.Add("YAML (*.yml)") + cboFileType.Items.Add("Stata (*.dta)") + cboFileType.Items.Add("SPSS (*.sav)") + cboFileType.Items.Add("XBASE database files (*.dbf)") + cboFileType.Items.Add("Weka Attribute - Relation File Format (*.arff)") + cboFileType.Items.Add("r syntax object (*.R)") + cboFileType.Items.Add("Xml (*.xml)") + cboFileType.Items.Add("HTML (*.html)") + cboFileType.Items.Add("Matlab (*.mat)") + cboFileType.Items.Add("SAS (*.sas7bdat)") + cboFileType.Items.Add("SAS XPORT (*.xpt)") + + 'set the default suggested name ucrFilePath.DefaultFileSuggestionName = ucrReceiverMultipleDataFrames.GetVariableNames(bWithQuotes:=False) - ucrFilePath.FilePathDialogFilter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html|Matlab(*.mat)|*.mat|SAS(*.sas7bdat)|*.sas7bdat|SAS XPORT(*.xpt)|*.xpt" - Exit Sub End If - 'if multiple data frames have been selected then do the following - If chkSaveAsSingleFile.Checked Then - 'if checkbox is visible and checked, set the file extension filter to 3 file types; .xlsx,rds,rData - ucrFilePath.FilePathDialogFilter = "Excel files (*.xlsx)|*.xlsx|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|HTML(*.html)|*.html" - Else - 'if checkbox not checked, set file path control to open folder browser dialog prompt instead of save file dialog prompt - ucrFilePath.FolderBrowse = True + 'previous selected file type may not be there in the current combobox items + cboFileType.SelectedItem = strPrevSelectedFileType + If String.IsNullOrEmpty(cboFileType.SelectedItem) Then + cboFileType.SelectedIndex = 0 End If + + ucrFilePath.FilePathDialogFilter = GetFilePathDialogFilterText(cboFileType.SelectedItem) + bSupressFileValuesChange = False + End Sub - ''' - ''' changes the visibilty of the save as separate files controls; lblFileExtension, cboFileExtension - ''' - Private Sub SetSaveAsSeparateFilesControlsVisibilty() - lblFileExtension.Visible = False - cboFileExtension.Visible = False - If ucrReceiverMultipleDataFrames.GetVariableNamesList().Length > 1 AndAlso Not chkSaveAsSingleFile.Checked Then - lblFileExtension.Visible = True - cboFileExtension.Visible = True + Private Function GetFilePathDialogFilterText(strText As String) As String + If String.IsNullOrEmpty(strText) Then + Return "" End If - End Sub + 'example of required format; Excel files (*.xlsx)|*.xlsx + Dim arrStr() As String = strText.Split({"(", ")"}, StringSplitOptions.RemoveEmptyEntries) + Return arrStr(0) & "(" & arrStr(1) & ")|" & arrStr(1) + End Function + + Private Function GetSelectedExtension(strText As String) As String + If String.IsNullOrEmpty(strText) Then + Return "" + End If + 'example of required format;.xlsx + Return strText.Split({"(", "*", ")"}, StringSplitOptions.RemoveEmptyEntries)(1) + End Function End Class From dbe52b8c9cdac7a62334769f7060f6ef533f3234 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Mon, 18 Jan 2021 16:33:35 +0300 Subject: [PATCH 25/26] added comments and removed redundant code --- instat/dlgExportDataset.vb | 39 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index 7cca467a53b..26826c04134 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -20,7 +20,6 @@ Public Class dlgExportDataset Dim bFirstLoad As Boolean = True Private bReset As Boolean = True Private clsDefaultFunction As RFunction - Private bSupressFileValuesChange As Boolean = False Private Sub dlgExportDataset_Load(sender As Object, e As EventArgs) Handles Me.Load 'temporarily commented out because it overwrites lblConfirm text contents @@ -48,7 +47,6 @@ Public Class dlgExportDataset 'file path control ucrFilePath.SetPathControlParameter(New RParameter("file", 1)) - End Sub Private Sub SetDefaults() @@ -97,6 +95,16 @@ Public Class dlgExportDataset ucrFilePath.Clear() 'will raise event FilePathChanged End Sub + Private Sub chkSaveAsSingleFile_CheckedChanged(sender As Object, e As EventArgs) Handles chkSaveAsSingleFile.CheckedChanged + ChangeFileControlsValues() + ucrFilePath.Clear() 'will raise event FilePathChanged + End Sub + + Private Sub cboFileExtension_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboFileType.SelectedIndexChanged + ucrFilePath.Clear() 'will raise event FilePathChanged + ucrFilePath.FilePathDialogFilter = GetFilePathDialogFilterText(cboFileType.SelectedItem) + End Sub + ''' ''' this event will always be called when changes happen to the core controls of the form; ''' receiver, file path, save as single checkbox @@ -120,16 +128,6 @@ Public Class dlgExportDataset TestOkEnabled() End Sub - Private Sub chkSaveAsSingleFile_CheckedChanged(sender As Object, e As EventArgs) Handles chkSaveAsSingleFile.CheckedChanged - ChangeFileControlsValues() - ucrFilePath.Clear() 'will raise event FilePathChanged - End Sub - - Private Sub cboFileExtension_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboFileType.SelectedIndexChanged - 'ChangeFileControlsValues() - ucrFilePath.Clear() 'will raise event FilePathChanged - ucrFilePath.FilePathDialogFilter = GetFilePathDialogFilterText(cboFileType.SelectedItem) - End Sub ''' ''' changes the file path and cboFileType control values; @@ -137,11 +135,6 @@ Public Class dlgExportDataset ''' the changed settings determine the behaviour of the file path contro ''' Private Sub ChangeFileControlsValues() - If bSupressFileValuesChange Then - Exit Sub - End If - - bSupressFileValuesChange = True Dim strPrevSelectedFileType As String = cboFileType.SelectedItem Dim iSelectedDataFrames As Integer = ucrReceiverMultipleDataFrames.GetVariableNamesList().Length ucrFilePath.FolderBrowse = False 'set file path control to open default SaveFileDialog prompt @@ -192,10 +185,13 @@ Public Class dlgExportDataset End If ucrFilePath.FilePathDialogFilter = GetFilePathDialogFilterText(cboFileType.SelectedItem) - bSupressFileValuesChange = False - End Sub + ''' + ''' expected string format "filetype (*.ext)" + ''' + ''' + ''' Private Function GetFilePathDialogFilterText(strText As String) As String If String.IsNullOrEmpty(strText) Then Return "" @@ -206,6 +202,11 @@ Public Class dlgExportDataset End Function + ''' + ''' expected string format "filetype (*.ext)" + ''' + ''' + ''' Private Function GetSelectedExtension(strText As String) As String If String.IsNullOrEmpty(strText) Then Return "" From efaff893993e0d5e1ebfaa9ac2adc841cc4746ef Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 23 Feb 2021 23:05:50 +0300 Subject: [PATCH 26/26] enlarged combobox --- instat/dlgExportDataset.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgExportDataset.resx b/instat/dlgExportDataset.resx index 67876d13f7c..89ecb4b5a9e 100644 --- a/instat/dlgExportDataset.resx +++ b/instat/dlgExportDataset.resx @@ -304,7 +304,7 @@ 245, 175 - 133, 21 + 170, 21 4