diff --git a/instat/dlgExportDataset.Designer.vb b/instat/dlgExportDataset.Designer.vb index aee550e6ea4..b741ebc7c64 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,63 +36,105 @@ 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.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.ucrAvailableSheets = New instat.ucrDataFrame() + 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.cboFileType = New System.Windows.Forms.ComboBox() Me.ucrBase = New instat.ucrButtons() + Me.ucrFilePath = New instat.ucrFilePath() + Me.ucrSelectorDataFrames = New instat.ucrSelectorAddRemove() + Me.ucrReceiverMultipleDataFrames = New instat.ucrReceiverMultiple() + Me.chkSaveAsSingleFile = New System.Windows.Forms.CheckBox() Me.SuspendLayout() ' - 'cmdBrowse + 'lblConfirm ' - resources.ApplyResources(Me.cmdBrowse, "cmdBrowse") - Me.cmdBrowse.Name = "cmdBrowse" - Me.cmdBrowse.UseVisualStyleBackColor = True + resources.ApplyResources(Me.lblConfirm, "lblConfirm") + Me.lblConfirm.ForeColor = System.Drawing.Color.Green + Me.lblConfirm.Name = "lblConfirm" ' - 'lblExport + 'lblDataFrames ' - resources.ApplyResources(Me.lblExport, "lblExport") - Me.lblExport.Name = "lblExport" + resources.ApplyResources(Me.lblDataFrames, "lblDataFrames") + Me.lblDataFrames.Name = "lblDataFrames" ' - 'lblConfirmText + 'lblSelectedDataFrames ' - resources.ApplyResources(Me.lblConfirmText, "lblConfirmText") - Me.lblConfirmText.Name = "lblConfirmText" + resources.ApplyResources(Me.lblSelectedDataFrames, "lblSelectedDataFrames") + Me.lblSelectedDataFrames.Name = "lblSelectedDataFrames" ' - 'ucrInputExportFile + 'lblFileExtension ' - Me.ucrInputExportFile.AddQuotesIfUnrecognised = True - Me.ucrInputExportFile.IsMultiline = False - Me.ucrInputExportFile.IsReadOnly = False - resources.ApplyResources(Me.ucrInputExportFile, "ucrInputExportFile") - Me.ucrInputExportFile.Name = "ucrInputExportFile" + resources.ApplyResources(Me.lblFileExtension, "lblFileExtension") + Me.lblFileExtension.Name = "lblFileExtension" ' - 'ucrAvailableSheets + 'cboFileType ' - Me.ucrAvailableSheets.bDropUnusedFilterLevels = False - Me.ucrAvailableSheets.bUseCurrentFilter = True - resources.ApplyResources(Me.ucrAvailableSheets, "ucrAvailableSheets") - Me.ucrAvailableSheets.Name = "ucrAvailableSheets" + 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 ' 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(s):" + Me.ucrFilePath.FolderBrowse = False + resources.ApplyResources(Me.ucrFilePath, "ucrFilePath") + Me.ucrFilePath.Name = "ucrFilePath" + Me.ucrFilePath.SelectedFileFilterIndex = 1 + ' + 'ucrSelectorDataFrames + ' + Me.ucrSelectorDataFrames.bShowHiddenColumns = False + resources.ApplyResources(Me.ucrSelectorDataFrames, "ucrSelectorDataFrames") + Me.ucrSelectorDataFrames.Name = "ucrSelectorDataFrames" + ' + '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 + ' + 'chkSaveAsSingleFile + ' + 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.lblConfirmText) - Me.Controls.Add(Me.cmdBrowse) - Me.Controls.Add(Me.ucrInputExportFile) - Me.Controls.Add(Me.ucrAvailableSheets) + Me.Controls.Add(Me.chkSaveAsSingleFile) + Me.Controls.Add(Me.cboFileType) + Me.Controls.Add(Me.lblFileExtension) + 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.ucrBase) - Me.Controls.Add(Me.lblExport) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.MaximizeBox = False Me.MinimizeBox = False @@ -104,9 +146,13 @@ 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 + Friend WithEvents ucrSelectorDataFrames As ucrSelectorAddRemove + Friend WithEvents lblDataFrames As Label + Friend WithEvents lblSelectedDataFrames As Label + Friend WithEvents ucrReceiverMultipleDataFrames As ucrReceiverMultiple + Friend WithEvents lblFileExtension As Label + Friend WithEvents cboFileType As ComboBox + Friend WithEvents chkSaveAsSingleFile As CheckBox End Class diff --git a/instat/dlgExportDataset.resx b/instat/dlgExportDataset.resx index 17f50aa4b22..89ecb4b5a9e 100644 --- a/instat/dlgExportDataset.resx +++ b/instat/dlgExportDataset.resx @@ -1,306 +1,471 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 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 - - - 91, 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 - - - 2, 0, 2, 0 - - - 148, 13 - - - 4 - - - Click Ok to Confirm the Export - - - lblConfirmText - - - 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 - - - 10, 10 - - - 0, 0, 0, 0 - - - 154, 41 - - - 0 - - - ucrAvailableSheets - - - instat.ucrDataFrame, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 3 - - - 8, 111 - - - 4, 5, 4, 5 - - - 405, 53 - - - 5 - - - ucrBase - - - instat.ucrButtons, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 4 - - - True - - - 6, 13 - - - True - - - 414, 165 - - - CenterScreen - - - Export Datasets - - - dlgExportDataset - - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + True + + + + NoControl + + + + 85, 240 + + + 2, 0, 2, 0 + + + 148, 13 + + + 4 + + + Click Ok to Confirm the Export + + + lblConfirm + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 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, 161 + + + 2, 0, 2, 0 + + + 86, 13 + + + 12 + + + Select File Type: + + + 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, 175 + + + 170, 21 + + + 4 + + + cboFileType + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + 10, 270 + + + 4, 5, 4, 5 + + + 405, 53 + + + 6 + + + ucrBase + + + instat.ucrButtons, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 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, 211 + + + 425, 26 + + + 5 + + + ucrFilePath + + + instat.ucrFilePath, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 7 + + + 10, 28 + + + 0, 0, 0, 0 + + + 216, 147 + + + 1 + + + ucrSelectorDataFrames + + + instat.ucrSelectorAddRemove, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 6 + + + True + + + 6, 13 + + + True + + + 441, 331 + + + True + + + 243, 133 + + + 111, 17 + + + 13 + + + Save as single file + + + chkSaveAsSingleFile + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + CenterScreen + + + Export Datasets + + + dlgExportDataset + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 243, 28 + + + 0, 0, 0, 0 + + + 120, 100 + + + 2 + + + ucrReceiverMultipleDataFrames + + + instat.ucrReceiverMultiple, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 3 + \ No newline at end of file diff --git a/instat/dlgExportDataset.vb b/instat/dlgExportDataset.vb index fa18fe80d90..26826c04134 100644 --- a/instat/dlgExportDataset.vb +++ b/instat/dlgExportDataset.vb @@ -14,16 +14,17 @@ ' You should have received a copy of the GNU General Public License ' along with this program. If not, see . -Imports System.IO +Imports instat Imports instat.Translations Public Class dlgExportDataset Dim bFirstLoad As Boolean = True Private bReset As Boolean = True - Private clsDefaultFunction As New RFunction - Private strCurrentFileName As String + 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 @@ -33,26 +34,31 @@ Public Class dlgExportDataset End If SetRCodeForControls(bReset) bReset = False - TestOkEnabled() End Sub Private Sub InitialiseDialog() - ucrInputExportFile.IsReadOnly = True - 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") - ucrInputExportFile.SetParameter(New RParameter("file", 1)) - - lblConfirmText.Text = "Click Ok to Confirm the Export" - lblConfirmText.ForeColor = Color.Red + 'file path control + ucrFilePath.SetPathControlParameter(New RParameter("file", 1)) End Sub Private Sub SetDefaults() clsDefaultFunction = New RFunction - ucrInputExportFile.SetName("") - ucrAvailableSheets.Reset() + ucrSelectorDataFrames.Reset() + chkSaveAsSingleFile.Checked = False + chkSaveAsSingleFile.Visible = False + cboFileType.SelectedIndex = 0 + lblConfirm.Visible = False + ucrFilePath.ResetPathControl() + clsDefaultFunction.SetPackageName("rio") clsDefaultFunction.SetRCommand("export") @@ -60,57 +66,153 @@ Public Class dlgExportDataset End Sub Private Sub SetRCodeForControls(bReset As Boolean) - SetRCode(Me, 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() - 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 ucrReceiverMultipleDataFrames.IsEmpty 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 SetDefaults() SetRCodeForControls(True) - TestOkEnabled() End Sub - Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click - 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 - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - End If - If dlgSave.ShowDialog = DialogResult.OK Then - ucrInputExportFile.SetName(dlgSave.FileName.Replace("\", "/")) - strCurrentFileName = dlgSave.FileName - End If - End Using + Private Sub ucrReceiverMultipleDataFrames_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultipleDataFrames.ControlContentsChanged + chkSaveAsSingleFile.Visible = ucrReceiverMultipleDataFrames.GetVariableNamesList().Length > 1 + ChangeFileControlsValues() + 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 ucrInputExportFile_Click(sender As Object, e As EventArgs) Handles ucrInputExportFile.Click - cmdBrowse_Click(sender, e) + 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 - Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrInputExportFile.ControlContentsChanged, ucrAvailableSheets.ControlContentsChanged + ''' + ''' 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) + 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 + 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 & 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." + End If TestOkEnabled() End Sub - Private Sub ucrAvailableSheets_DataFrameChanged(sender As Object, e As EventArgs, strPrevDataFrame As String) Handles ucrAvailableSheets.DataFrameChanged - strCurrentFileName = "" + + ''' + ''' 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 ChangeFileControlsValues() + 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() + + + 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) + End If + + '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) End Sub -End Class \ No newline at end of file + + ''' + ''' expected string format "filetype (*.ext)" + ''' + ''' + ''' + Private Function GetFilePathDialogFilterText(strText As String) As String + If String.IsNullOrEmpty(strText) Then + Return "" + End If + '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 + + ''' + ''' expected string format "filetype (*.ext)" + ''' + ''' + ''' + 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 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 fae21d03975..97ca7543720 100644 --- a/instat/dlgExportGraphAsImage.resx +++ b/instat/dlgExportGraphAsImage.resx @@ -1,318 +1,267 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - True - - - - 264, 45 - - - 84, 13 - - - 1 - - - Selected Graph: - - - lblSelectedGraph - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $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 - - - True - - - 6, 13 - - - True - - - 418, 280 - - - 92, 195 - - - - 6, 8, 6, 8 - - - 240, 21 - - - 4 - - - ucrInputFile - - - instat.ucrInputTextBox, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 0 - - - 9, 199 - - - 115, 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 - - - 210, 180 - - - 0 - - - ucrSelectorGraphAsImage - - - instat.ucrSelectorByDataFrameAddRemove, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 5 - - - 10, 223 - - - 4, 5, 4, 5 - - - 404, 52 - - - 6 - - - ucrBase - - - instat.ucrButtons, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 6 - - - CenterScreen - - - Export Graph As Image - - - dlgExportGraphAsImage - - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 265, 60 - - - 0, 0, 0, 0 - - - 120, 20 - - - 2 - - - ucrSelectedGraphReceiver - - - instat.ucrReceiverSingle, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 4 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + True + + + + 264, 45 + + + 84, 13 + + + 1 + + + Selected Graph: + + + lblSelectedGraph + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + 6, 13 + + + True + + + 418, 280 + + + 14, 195 + + + 400, 26 + + + 7 + + + ucrFilePath + + + instat.ucrFilePath, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + 10, 10 + + + + 0, 0, 0, 0 + + + 210, 180 + + + 0 + + + ucrSelectorGraphAsImage + + + instat.ucrSelectorByDataFrameAddRemove, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 3 + + + 10, 224 + + + 4, 5, 4, 5 + + + 404, 52 + + + 6 + + + ucrBase + + + instat.ucrButtons, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 4 + + + CenterScreen + + + Export Graph As Image + + + dlgExportGraphAsImage + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 265, 60 + + + 0, 0, 0, 0 + + + 120, 20 + + + 2 + + + ucrSelectedGraphReceiver + + + instat.ucrReceiverSingle, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 2 + \ No newline at end of file diff --git a/instat/dlgExportGraphAsImage.vb b/instat/dlgExportGraphAsImage.vb index 084664cb992..539ee6c50ff 100644 --- a/instat/dlgExportGraphAsImage.vb +++ b/instat/dlgExportGraphAsImage.vb @@ -36,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() @@ -50,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") @@ -60,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 @@ -77,17 +74,14 @@ Public Class dlgExportGraphAsImage TestOkEnabled() 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 + Private Sub ucrCoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrSelectedGraphReceiver.ControlContentsChanged + 'give a default suggested 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 + +End Class diff --git a/instat/dlgExportRObjects.Designer.vb b/instat/dlgExportRObjects.Designer.vb index 4024a34ecb2..5d6715e539f 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.ucrFilePath = New instat.ucrFilePath() + Me.ucrReceiverMultipleObjects = 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.SuspendLayout() ' 'lblObjects @@ -53,14 +51,25 @@ Partial Class dlgExportRObjects resources.ApplyResources(Me.lblObjects, "lblObjects") Me.lblObjects.Name = "lblObjects" ' - 'ucrReceiverObjects + 'ucrFilePath ' - 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.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" + ' + 'ucrReceiverMultipleObjects + ' + 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 ' @@ -75,34 +84,13 @@ Partial Class dlgExportRObjects resources.ApplyResources(Me.ucrBase, "ucrBase") Me.ucrBase.Name = "ucrBase" ' - 'ucrInputExportFile - ' - 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 - ' '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.ucrReceiverMultipleObjects) Me.Controls.Add(Me.ucrSelectorObjects) Me.Controls.Add(Me.ucrBase) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow @@ -115,9 +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 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 22966706d77..4164aefba4b 100644 --- a/instat/dlgExportRObjects.resx +++ b/instat/dlgExportRObjects.resx @@ -1,315 +1,267 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - True - - - - 266, 45 - - - 91, 13 - - - 1 - - - Selected Objects: - - - lblObjects - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - - - True - - - 6, 13 - - - 420, 288 - - - 92, 204 - - - - 6, 8, 6, 8 - - - 240, 23 - - - 4 - - - ucrInputExportFile - - - instat.ucrInputTextBox, 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 - - - 95, 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 - - - 210, 180 - - - 0 - - - ucrSelectorObjects - - - instat.ucrSelectorByDataFrameAddRemove, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 5 - - - 10, 232 - - - 4, 5, 4, 5 - - - 398, 52 - - - 6 - - - ucrBase - - - instat.ucrButtons, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 6 - - - CenterScreen - - - Export R Objects - - - dlgExportRObjects - - - 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 - - - instat.ucrReceiverMultiple, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 4 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + True + + + + NoControl + + + + 263, 45 + + + 91, 13 + + + 1 + + + Selected Objects: + + + lblObjects + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + 14, 199 + + + 394, 26 + + + 7 + + + ucrFilePath + + + instat.ucrFilePath, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + True + + + 6, 13 + + + 417, 288 + + + 10, 10 + + + 0, 0, 0, 0 + + + 210, 180 + + + 0 + + + ucrSelectorObjects + + + instat.ucrSelectorByDataFrameAddRemove, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 3 + + + 10, 232 + + + 4, 5, 4, 5 + + + 398, 52 + + + 6 + + + ucrBase + + + instat.ucrButtons, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 4 + + + CenterScreen + + + Export R Objects + + + dlgExportRObjects + + + 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 + + + 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 5a11063f31b..5151a9fc889 100644 --- a/instat/dlgExportRObjects.vb +++ b/instat/dlgExportRObjects.vb @@ -14,12 +14,11 @@ ' 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 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) @@ -32,76 +31,59 @@ Public Class dlgExportRObjects End If SetRCodeForControls(bReset) bReset = False - TestOkEnabled() + 'TestOkEnabled() End Sub 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() - ucrReceiverObjects.Selector = ucrSelectorObjects - ucrReceiverObjects.SetMeAsReceiver() - ucrReceiverObjects.strSelectorHeading = "Objects" - ucrReceiverObjects.SetItemType("object") - - ucrInputExportFile.SetParameter(New RParameter("file", 0)) - ucrInputExportFile.IsReadOnly = True + 'multiple reciever control that holds selected objects + 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 Private Sub SetDefaults() - clsGetObjectsFunction = New RFunction - clsSaveRDS = New RFunction + clsExport = New RFunction - ucrInputExportFile.SetName("") - ucrSelectorObjects.Reset() - clsGetObjectsFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_objects") - clsSaveRDS.SetRCommand("saveRDS") - clsSaveRDS.AddParameter("object", clsRFunctionParameter:=clsGetObjectsFunction) - ucrBase.clsRsyntax.SetBaseRFunction(clsSaveRDS) + 'reset controls + ucrSelectorObjects.Reset() 'will also reset the reciever + ucrFilePath.ResetPathControl() + + '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) - ucrInputExportFile.SetRCode(clsSaveRDS, bReset) + ucrReceiverMultipleObjects.SetRCode(clsExport, bReset) + ucrFilePath.SetPathControlRcode(clsExport, 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 ucrReceiverMultipleObjects.IsEmpty AndAlso Not String.IsNullOrEmpty(ucrSelectorObjects.strCurrentDataFrame)) End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaults() SetRCodeForControls(True) - TestOkEnabled() + 'TestOkEnabled() 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("\", "/")) - End If - End If - End Sub - - Private Sub ucrInputExportFile_Click(sender As Object, e As EventArgs) Handles ucrInputExportFile.Click - cmdBrowse_Click(sender, e) + Private Sub ucrReceiverMultipleObjects_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultipleObjects.ControlContentsChanged + '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 - 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 + +End Class 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 6d6a6faf634..fa840261ae5 100644 --- a/instat/dlgExportRWorkspace.resx +++ b/instat/dlgExportRWorkspace.resx @@ -1,417 +1,366 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 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 - - - 100, 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 - - - 76, 13 - - - 0 - - - Data Frame(s): - - - lblDataFrames - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 1 - - - True - - - 247, 45 - - - 115, 13 - - - 2 - - - Selected Data Frames: - - - lblSelectedDataFrames - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - 10, 30 - - - - 0, 0, 0, 0 - - - 213, 147 - - - 1 - - - ucrSelectorForDataFrames - - - instat.ucrSelectorAddRemove, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $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 - - - 4, 5, 4, 5 - - - 119, 20 - - - 5 - - - ucrChkGraphs - - - instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 5 - - - 10, 219 - - - 4, 5, 4, 5 - - - 128, 20 - - - 6 - - - ucrChkModels - - - instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 6 - - - 10, 167 - - - 4, 5, 4, 5 - - - 145, 20 - - - 4 - - - ucrChkMetadata - - - instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 7 - - - True - - - 6, 13 - - - True - - - 417, 335 - - - 10, 278 - - - 4, 5, 4, 5 - - - 398, 52 - - - 10 - - - ucrBase - - - instat.ucrButtons, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 9 - - - CenterScreen - - - Export R Workspace - - - dlgExportRWorkspace - - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 250, 60 - - - 0, 0, 0, 0 - - - 120, 100 - - - 3 - - - ucrReceiverMultiple - - - instat.ucrReceiverMultiple, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 8 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + True + + + + 10, 15 + + + 76, 13 + + + 0 + + + Data Frame(s): + + + lblDataFrames + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + True + + + 247, 45 + + + 115, 13 + + + 2 + + + Selected Data Frames: + + + lblSelectedDataFrames + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + 10, 30 + + + + 0, 0, 0, 0 + + + 213, 147 + + + 1 + + + ucrSelectorForDataFrames + + + instat.ucrSelectorAddRemove, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 8 + + + 10, 193 + + + 4, 5, 4, 5 + + + 119, 20 + + + 5 + + + ucrChkGraphs + + + instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 3 + + + 10, 219 + + + 4, 5, 4, 5 + + + 128, 20 + + + 6 + + + ucrChkModels + + + instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 4 + + + 10, 167 + + + 4, 5, 4, 5 + + + 145, 20 + + + 4 + + + ucrChkMetadata + + + instat.ucrCheck, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 5 + + + True + + + 6, 13 + + + True + + + 417, 335 + + + 14, 245 + + + 400, 26 + + + 11 + + + ucrFilePath + + + instat.ucrFilePath, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 0 + + + 10, 278 + + + 4, 5, 4, 5 + + + 398, 52 + + + 10 + + + ucrBase + + + instat.ucrButtons, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 7 + + + CenterScreen + + + Export R Workspace + + + dlgExportRWorkspace + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 250, 60 + + + 0, 0, 0, 0 + + + 120, 100 + + + 3 + + + ucrReceiverMultiple + + + instat.ucrReceiverMultiple, instat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 6 + \ No newline at end of file diff --git a/instat/dlgExportRWorkspace.vb b/instat/dlgExportRWorkspace.vb index 04f6b9e475e..6e9dc83abb5 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,24 +90,13 @@ Public Class dlgExportRWorkspace TestOkEnabled() 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("\", "/")) - End If - End If - End Sub - - Private Sub ucrInputExportFile_Click(sender As Object, e As EventArgs) Handles ucrInputExportFile.Click - cmdBrowse_Click(sender, e) + Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrReceiverMultiple.ControlContentsChanged + '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 - 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 +End Class 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 e4c7ca3cf67..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, 70 + 10, 63 - 4, 5, 4, 5 410, 53 - 4 @@ -142,102 +172,27 @@ $this - 4 - - - 10, 20 - - - 103, 13 - - - 0 - - - Save Data To: - - - lblSaveDataTo - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - 2 - - 125, 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 - - - 443, 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 - 511, 130 + 430, 124 CenterScreen diff --git a/instat/dlgSaveAs.vb b/instat/dlgSaveAs.vb index 528985b723d..096daa62dc3 100644 --- a/instat/dlgSaveAs.vb +++ b/instat/dlgSaveAs.vb @@ -1,116 +1,86 @@ -' R- Instat -' Copyright (C) 2015-2017 -' -' This program is free software: you can redistribute it and/or modify -' it under the terms of the GNU General Public License as published by -' the Free Software Foundation, either version 3 of the License, or -' (at your option) any later version. -' -' This program is distributed in the hope that it will be useful, -' but WITHOUT ANY WARRANTY; without even the implied warranty of -' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -' GNU General Public License for more details. -' -' 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 - Private bReset As Boolean = True - Private clsSaveFunction As New RFunction - - Private Sub dlgSaveAs_Load(sender As Object, e As EventArgs) Handles Me.Load - If bFirstLoad Then - InitialiseDialog() - bFirstLoad = False - End If - If bReset Then - SetDefaults() - End If - SetRCodeForControls(bReset) - bReset = False - autoTranslate(Me) - End Sub - - Private Sub InitialiseDialog() - ucrBase.iHelpTopicID = 332 - - ucrInputFilePath.SetParameter(New RParameter("file", 0)) - ucrInputFilePath.IsReadOnly = True - - lblConfirm.Text = "Click Ok to confirm the save" - End Sub - - Private Sub SetDefaults() - clsSaveFunction = New RFunction - - ucrInputFilePath.Reset() - ucrInputFilePath.SetName("") - - clsSaveFunction.SetRCommand("saveRDS") - clsSaveFunction.AddParameter("object", frmMain.clsRLink.strInstatDataObject) - - ucrBase.clsRsyntax.SetBaseRFunction(clsSaveFunction) - End Sub - - Private Sub SetRCodeForControls(bReset As Boolean) - SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, bReset) - TestOKEnabled() - End Sub - - Private Sub TestOKEnabled() - If Not ucrInputFilePath.IsEmpty() Then - lblConfirm.Show() - ucrBase.OKEnabled(True) - Else - lblConfirm.Hide() - ucrBase.OKEnabled(False) - End If - End Sub - - Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset - SetDefaults() - SetRCodeForControls(True) - 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.bDataSaved = True - 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() - 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 - dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory - End If - If DialogResult.OK = dlgSave.ShowDialog() Then - ucrInputFilePath.SetName(dlgSave.FileName.Replace("\", "/")) - End If - TestOKEnabled() - End Using - End Sub - - Private Sub ucrInputFilePath_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrInputFilePath.ControlContentsChanged - TestOKEnabled() - End Sub -End Class +' R- Instat +' Copyright (C) 2015-2017 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . + +Imports instat.Translations +Public Class dlgSaveAs + Private bFirstLoad As Boolean = True + Private bReset As Boolean = True + Private clsSaveFunction As New RFunction + + Private Sub dlgSaveAs_Load(sender As Object, e As EventArgs) Handles Me.Load + If bFirstLoad Then + InitialiseDialog() + bFirstLoad = False + End If + If bReset Then + SetDefaults() + End If + SetRCodeForControls(bReset) + bReset = False + autoTranslate(Me) + End Sub + + Private Sub InitialiseDialog() + ucrBase.iHelpTopicID = 332 + + ucrFilePath.SetPathControlParameter(New RParameter("file", 0)) + + lblConfirm.Visible = False + lblConfirm.ForeColor = Color.Green + End Sub + + Private Sub SetDefaults() + clsSaveFunction = New RFunction + + ucrFilePath.ResetPathControl() + + clsSaveFunction.SetRCommand("saveRDS") + clsSaveFunction.AddParameter("object", frmMain.clsRLink.strInstatDataObject) + + ucrBase.clsRsyntax.SetBaseRFunction(clsSaveFunction) + End Sub + + Private Sub SetRCodeForControls(bReset As Boolean) + ucrFilePath.SetPathControlRcode(ucrBase.clsRsyntax.clsBaseFunction, bReset) + TestOKEnabled() + End Sub + + Private Sub TestOKEnabled() + If ucrFilePath.IsEmpty() Then + lblConfirm.Visible = False + ucrBase.OKEnabled(False) + Else + lblConfirm.Visible = True + ucrBase.OKEnabled(True) + End If + End Sub + + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + SetDefaults() + SetRCodeForControls(True) + End Sub + + 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 + 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..b9855dadacb 100644 --- a/instat/ucrFilePath.vb +++ b/instat/ucrFilePath.vb @@ -14,9 +14,59 @@ ' You should have received a copy of the GNU General Public License ' 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. +''' +''' This class provides methods and fields to: +''' +''' +''' Set the parameter 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 *.*" + + ''' + ''' event raised when the file path contents has changed + ''' + Public Event FilePathChanged() + + ''' + ''' gets and sets the text property value 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 + + ''' + ''' flag used to determine whether the opened dialog prompt will be + ''' FolderBrowserDialog or SaveFileDialog + ''' + Public Property FolderBrowse As Boolean = False - Public Property LabelText() As String + ''' + ''' gets and sets the label text property value of the input textbox + ''' + Public Property FilePathLabel() As String Get Return lblName.Text End Get @@ -25,14 +75,218 @@ 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 Get - Return btnBrowse.Text + Return strFilePathDialogFilter End Get Set(ByVal value As String) - btnBrowse.Text = value + 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. + ''' 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 + ''' + ''' + Public Property DefaultFileSuggestionName As String = "" + + ''' + ''' 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 + Return PathControl().GetText() + End Get + 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 - 'todo. code logic additions + ''' + ''' 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 + ''' + ''' ucrInputTextBox + Public ReadOnly Property PathControl() As ucrInputTextBox + Get + Return ucrInputFilePath + End Get + End Property + + ''' + ''' Sets the R parameter to the path control + ''' + ''' + Public Sub SetPathControlParameter(rParameter As RParameter) + PathControl().SetParameter(rParameter) + End Sub + + ''' + ''' sets the R code to the path control + ''' + ''' + ''' + Public Sub SetPathControlRcode(clsNewCodeStructure As RCodeStructure, Optional bReset As Boolean = False) + PathControl().SetRCode(clsNewCodeStructure, bReset) + End Sub + + ''' + ''' resets the path control and and the file path + ''' + Public Sub ResetPathControl() + PathControl().Reset() + Clear() + End Sub + + Public Function IsEmpty() As Boolean + Return String.IsNullOrEmpty(FilePath) + End Function + + Public Sub Clear() + 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 + ''' + ''' + ''' + Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click + 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 + '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 + 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 + + ''' + ''' 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 + '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 = True + } + + '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