diff --git a/instat/My Project/Resources.Designer.vb b/instat/My Project/Resources.Designer.vb index 35f82a67757..a96d05fa4be 100644 --- a/instat/My Project/Resources.Designer.vb +++ b/instat/My Project/Resources.Designer.vb @@ -984,6 +984,24 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to DF 1. + ''' + Friend ReadOnly Property DF_1() As String + Get + Return ResourceManager.GetString("DF_1", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to DF 2. + ''' + Friend ReadOnly Property DF_2() As String + Get + Return ResourceManager.GetString("DF_2", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Display. ''' @@ -2868,6 +2886,24 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Population Failures. + ''' + Friend ReadOnly Property Population_Failures() As String + Get + Return ResourceManager.GetString("Population_Failures", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Population Successes. + ''' + Friend ReadOnly Property Population_Successes() As String + Get + Return ResourceManager.GetString("Population_Successes", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Prepare. ''' @@ -3579,6 +3615,24 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Shape 1. + ''' + Friend ReadOnly Property Shape_1() As String + Get + Return ResourceManager.GetString("Shape_1", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Shape 2. + ''' + Friend ReadOnly Property Shape_2() As String + Get + Return ResourceManager.GetString("Shape_2", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Sheet name. ''' diff --git a/instat/My Project/Resources.resx b/instat/My Project/Resources.resx index 788ac74c48e..82f88991791 100644 --- a/instat/My Project/Resources.resx +++ b/instat/My Project/Resources.resx @@ -1549,4 +1549,22 @@ SDlog + + Population Failures + + + Population Successes + + + DF 1 + + + DF 2 + + + Shape 1 + + + Shape 2 + \ No newline at end of file diff --git a/instat/clsRecentFiles.vb b/instat/clsRecentFiles.vb index 44c702631cc..511f334256c 100644 --- a/instat/clsRecentFiles.vb +++ b/instat/clsRecentFiles.vb @@ -1,12 +1,11 @@ Imports System.IO Public Class clsRecentFiles Public mnuItems As New List(Of Form) - Dim strRecentFiles As String = "Recent_Files\recent.mru" - Dim mnuTbShowLast10 As ToolStripDropDownItem - Dim mnuFile As ToolStripMenuItem - Dim sepStart As ToolStripSeparator - Dim sepEnd As ToolStripSeparator - + Private strRecentFilesPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RInstat\recent.mru") + Private mnuTbShowLast10 As ToolStripDropDownItem + Private mnuFile As ToolStripMenuItem + Private sepStart As ToolStripSeparator + Private sepEnd As ToolStripSeparator ' declare a variable to contain the most recent opened items Private strListMRU As New List(Of String) @@ -19,22 +18,15 @@ Public Class clsRecentFiles sepEnd.Visible = False End Sub - Private ReadOnly Property MRUPath() As String - 'Reads the path where the list of MRU are stored - Get - ' returns a path in the static folder, but with a '.mru' extension - Return Path.GetFullPath(frmMain.strStaticPath & "\" & strRecentFiles) - End Get - End Property - Public Sub checkOnLoad() - 'Checks for the existe3nce of the file on form load + 'Checks for the existence of the file on form load ' load recently opened files - If (File.Exists(MRUPath)) Then + If (File.Exists(strRecentFilesPath)) Then ' read file - Dim sPaths() As String = File.ReadAllLines(MRUPath) + Dim sPaths() As String = File.ReadAllLines(strRecentFilesPath) For Each sPath As String In sPaths If Not String.IsNullOrEmpty(sPath) Then + ' Disabled this so that you can still see files that don't exist in the list ' only add files that still exist... 'If File.Exists(sPath) Then ' ' add to the list of recently opened files @@ -45,22 +37,19 @@ Public Class clsRecentFiles Next End If ' display the recently opened files if there are any items to display in the file - If strListMRU.Count > 0 Then UpdateItemsMenu() + UpdateItemsMenu() End Sub Public Sub saveOnClose() - ' temp disabled to prevent error accessing file - ' TODO look up app config and Setting file as alternatives + Dim sPath As String 'saves the list of opened files on form close ' save MRU - delete existing files first - 'If File.Exists(MRUPath) Then - 'File.WriteAllText(MRUPath, "") - 'End If - ' write each item to the file... - 'For Each sPath As String In strListMRU - 'File.AppendAllText(MRUPath, sPath & vbCrLf) - 'Next + File.WriteAllText(strRecentFilesPath, "") + 'Write each item to the file... + For Each sPath In strListMRU + File.AppendAllText(strRecentFilesPath, sPath & vbCrLf) + Next End Sub Public Sub addToMenu(ByVal tempObj As Object) @@ -153,20 +142,24 @@ Public Class clsRecentFiles End Sub Private Sub mnuFileMRU_Click(ByVal sender As Object, ByVal e As EventArgs) + Dim iResult As Integer + If File.Exists(DirectCast(sender, ToolStripItem).Tag.ToString().Substring(4)) Then 'dlgImportDataset.SetFilePath(DirectCast(sender, ToolStripItem).Tag.ToString().Substring(4)) 'dlgImportDataset.SetDataName(Path.GetFileNameWithoutExtension(sender.ToString)) 'Not working as I would like because of the changes made to the Import Dataset + dlgImportDataset.strFilePathToUseOnLoad = DirectCast(sender, ToolStripItem).Tag.ToString().Substring(4) dlgImportDataset.ShowDialog() - Else - MessageBox.Show(frmMain, "The file has either been moved or deleted", "Error trying to open file") + iResult = MessageBox.Show(frmMain, "Error: File not accessible. It may have been renamed, moved or deleted." & vbNewLine & vbNewLine & "Would you like to remove this file from the list?", "Error accessing file", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) 'removes the path to the non existent file - strListMRU.RemoveAt(strListMRU.FindLastIndex(Function(value As String) - Return value.Contains(sender.ToString) - End Function)) - 'updates the interfaces - UpdateItemsMenu() + If iResult = DialogResult.Yes Then + strListMRU.RemoveAt(strListMRU.FindLastIndex(Function(value As String) + Return value.Contains(sender.ToString) + End Function)) + 'updates the interfaces + UpdateItemsMenu() + End If End If End Sub @@ -178,5 +171,4 @@ Public Class clsRecentFiles End If Next End Sub - End Class diff --git a/instat/dlgImportDataset.vb b/instat/dlgImportDataset.vb index bbb91d0046e..2fa11678ed2 100644 --- a/instat/dlgImportDataset.vb +++ b/instat/dlgImportDataset.vb @@ -30,6 +30,7 @@ Public Class dlgImportDataset Dim bCanImport As Boolean Dim bComponentsInitialised As Boolean Public bStartOpenDialog As Boolean + Public strFilePathToUseOnLoad As String Public Sub New() @@ -52,7 +53,8 @@ Public Class dlgImportDataset bCanImport = True bComponentsInitialised = True bStartOpenDialog = True - ucrInputName.bSuggestEditOnLeave = True + ucrInputName.bSuggestEditOnLeave = True + strFilePathToUseOnLoad = "" End Sub Private Sub dlgImportDataset_Load(sender As Object, e As EventArgs) Handles MyBase.Load @@ -65,9 +67,12 @@ Public Class dlgImportDataset SetRDSDefaults() bFirstLoad = False End If - If bStartOpenDialog Then + If strFilePathToUseOnLoad <> "" Then + SetDialogWithFile(strFilePathToUseOnLoad) + bStartOpenDialog = False + ElseIf bStartOpenDialog Then GetFileFromOpenDialog() - bStartOpenDialog = False + bStartOpenDialog = False End If TestOkEnabled() End Sub @@ -135,9 +140,6 @@ Public Class dlgImportDataset #Region "Import options" 'Loads the open dialog on load and click Public Sub GetFileFromOpenDialog() - Dim strFilePath As String = "" - Dim strFileName As String = "" - Dim strFileExt As String = "" Using dlgOpen As New OpenFileDialog If bFromLibrary Then dlgOpen.Title = "Import from library" @@ -159,81 +161,7 @@ Public Class dlgImportDataset ucrInputName.Reset() 'checks if the file name is not blank' If dlgOpen.FileName <> "" Then - strFileName = Path.GetFileNameWithoutExtension(dlgOpen.FileName) - strFilePath = Replace(dlgOpen.FileName, "\", "/") - strFileExt = Path.GetExtension(strFilePath) - ucrInputFilePath.SetName(strFilePath) - grdDataPreview.Show() - txtPreview.Show() - ucrInputName.Show() - lblName.Show() - If strFileExt = ".RDS" Then - clsReadRDS.SetRCommand("readRDS") - clsReadRDS.AddParameter("file", Chr(34) & strFilePath & Chr(34)) - 'TODO This needs to be different when RDS is a data frame - 'need to be able to detect RDS as data.frame/Instat Object - clsReadRDS.SetAssignTo("new_RDS") - grpExcel.Hide() - grpCSV.Hide() - grpRDS.Show() - txtPreview.Text = "" - txtPreview.Enabled = False - grdDataPreview.Enabled = False - ucrBase.clsRsyntax.clsBaseFunction.ClearParameters() - ucrBase.clsRsyntax.SetBaseRFunction(clsImportRDS) - ucrBase.clsRsyntax.AddParameter("data_RDS", clsRFunctionParameter:=clsReadRDS) - strFileType = "RDS" - ucrInputName.Hide() - lblName.Hide() - 'ucrInputName.SetName(strFileName, bSilent:=True) - ElseIf strFileExt = ".csv" Then - clsReadCSV.SetRCommand("rio::import") - clsReadCSV.AddParameter("file", Chr(34) & strFilePath & Chr(34)) - ucrBase.clsRsyntax.SetBaseRFunction(clsReadCSV) - grpRDS.Hide() - grpExcel.Hide() - grpCSV.Show() - txtPreview.Enabled = True - grdDataPreview.Enabled = True - strFileType = "csv" - ucrInputName.SetName(strFileName, bSilent:=True) - RefreshFilePreview() - ucrInputName.Focus() - ElseIf strFileExt = ".xlsx" OrElse strFileExt = ".xls" Then - clsReadXL.SetRCommand("rio::import") - clsReadXL.AddParameter("file", Chr(34) & strFilePath & Chr(34)) - ucrBase.clsRsyntax.SetBaseRFunction(clsReadXL) - grpCSV.Hide() - grpRDS.Hide() - grpExcel.Show() - txtPreview.Text = "" - txtPreview.Enabled = False - grdDataPreview.Enabled = True - If strFileExt = ".xlsx" Then - strFileType = "xlsx" - clsReadXL.AddParameter("readxl", "FALSE") - Else - strFileType = "xls" - clsReadXL.RemoveParameterByName("readxl") - End If - FillExcelSheetsAndRegions(strFilePath) - ucrInputName.Focus() - 'ucrInputName.SetName(strFileName, bSilent:=True) - Else - strFileType = strFileExt.Substring(1) - ucrBase.clsRsyntax.clsBaseFunction.ClearParameters() - ucrBase.clsRsyntax.SetFunction("rio::import") - ucrBase.clsRsyntax.AddParameter("file", Chr(34) & strFilePath & Chr(34)) - grpCSV.Hide() - grpExcel.Hide() - grpRDS.Hide() - grdDataPreview.Show() - txtPreview.Hide() - ucrInputName.SetName(strFileName, bSilent:=True) - ucrInputName.Focus() - End If - RefreshFilePreview() - RefreshFrameView() + SetDialogWithFile(dlgOpen.FileName) End If Else If bFromLibrary Then @@ -254,6 +182,89 @@ Public Class dlgImportDataset End Using End Sub + Public Sub SetDialogWithFile(strFilePath As String) + Dim strFileExt As String + Dim strFileName As String + + strFileName = Path.GetFileNameWithoutExtension(strFilePath) + strFilePath = Replace(strFilePath, "\", "/") + strFileExt = Path.GetExtension(strFilePath) + + strFileExt = Path.GetExtension(strFilePath) + ucrInputFilePath.SetName(strFilePath) + grdDataPreview.Show() + txtPreview.Show() + ucrInputName.Show() + lblName.Show() + If strFileExt = ".RDS" Then + clsReadRDS.SetRCommand("readRDS") + clsReadRDS.AddParameter("file", Chr(34) & strFilePath & Chr(34)) + 'TODO This needs to be different when RDS is a data frame + 'need to be able to detect RDS as data.frame/Instat Object + clsReadRDS.SetAssignTo("new_RDS") + grpExcel.Hide() + grpCSV.Hide() + grpRDS.Show() + txtPreview.Text = "" + txtPreview.Enabled = False + grdDataPreview.Enabled = False + ucrBase.clsRsyntax.clsBaseFunction.ClearParameters() + ucrBase.clsRsyntax.SetBaseRFunction(clsImportRDS) + ucrBase.clsRsyntax.AddParameter("data_RDS", clsRFunctionParameter:=clsReadRDS) + strFileType = "RDS" + ucrInputName.Hide() + lblName.Hide() + 'ucrInputName.SetName(strFileName, bSilent:=True) + ElseIf strFileExt = ".csv" Then + clsReadCSV.SetRCommand("rio::import") + clsReadCSV.AddParameter("file", Chr(34) & strFilePath & Chr(34)) + ucrBase.clsRsyntax.SetBaseRFunction(clsReadCSV) + grpRDS.Hide() + grpExcel.Hide() + grpCSV.Show() + txtPreview.Enabled = True + grdDataPreview.Enabled = True + strFileType = "csv" + ucrInputName.SetName(strFileName, bSilent:=True) + RefreshFilePreview() + ucrInputName.Focus() + ElseIf strFileExt = ".xlsx" OrElse strFileExt = ".xls" Then + clsReadXL.SetRCommand("rio::import") + clsReadXL.AddParameter("file", Chr(34) & strFilePath & Chr(34)) + ucrBase.clsRsyntax.SetBaseRFunction(clsReadXL) + grpCSV.Hide() + grpRDS.Hide() + grpExcel.Show() + txtPreview.Text = "" + txtPreview.Enabled = False + grdDataPreview.Enabled = True + If strFileExt = ".xlsx" Then + strFileType = "xlsx" + clsReadXL.AddParameter("readxl", "FALSE") + Else + strFileType = "xls" + clsReadXL.RemoveParameterByName("readxl") + End If + FillExcelSheetsAndRegions(strFilePath) + ucrInputName.Focus() + 'ucrInputName.SetName(strFileName, bSilent:=True) + Else + strFileType = strFileExt.Substring(1) + ucrBase.clsRsyntax.clsBaseFunction.ClearParameters() + ucrBase.clsRsyntax.SetFunction("rio::import") + ucrBase.clsRsyntax.AddParameter("file", Chr(34) & strFilePath & Chr(34)) + grpCSV.Hide() + grpExcel.Hide() + grpRDS.Hide() + grdDataPreview.Show() + txtPreview.Hide() + ucrInputName.SetName(strFileName, bSilent:=True) + ucrInputName.Focus() + End If + RefreshFilePreview() + RefreshFrameView() + End Sub + #End Region #Region "File Preview options" @@ -745,7 +756,7 @@ Public Class dlgImportDataset Private Sub ucrBase_ClickOk(sender As Object, e As EventArgs) Handles ucrBase.ClickOk ' add the item to the MRU (Most Recently Used) list... 'Disabled until implemented correctly - 'frmMain.clsRecentItems.addToMenu(ucrInputFilePath.GetText()) + frmMain.clsRecentItems.addToMenu(Replace(ucrInputFilePath.GetText(), "/", "\")) If strFileType = "RDS" Then frmMain.strSaveFilePath = ucrInputFilePath.GetText() End If diff --git a/instat/dlgRandomSample.designer.vb b/instat/dlgRandomSample.designer.vb index a0feac78962..7fda9244478 100644 --- a/instat/dlgRandomSample.designer.vb +++ b/instat/dlgRandomSample.designer.vb @@ -42,7 +42,7 @@ Partial Class dlgRandomSample 'lblSampleSize ' Me.lblSampleSize.AutoSize = True - Me.lblSampleSize.Location = New System.Drawing.Point(256, 85) + Me.lblSampleSize.Location = New System.Drawing.Point(256, 81) Me.lblSampleSize.Name = "lblSampleSize" Me.lblSampleSize.Size = New System.Drawing.Size(65, 13) Me.lblSampleSize.TabIndex = 10 @@ -52,7 +52,7 @@ Partial Class dlgRandomSample 'lblNumberofSamples ' Me.lblNumberofSamples.AutoSize = True - Me.lblNumberofSamples.Location = New System.Drawing.Point(256, 57) + Me.lblNumberofSamples.Location = New System.Drawing.Point(256, 54) Me.lblNumberofSamples.Name = "lblNumberofSamples" Me.lblNumberofSamples.Size = New System.Drawing.Size(99, 13) Me.lblNumberofSamples.TabIndex = 10 @@ -62,16 +62,16 @@ Partial Class dlgRandomSample 'lblPrefixColumnName ' Me.lblPrefixColumnName.AutoSize = True - Me.lblPrefixColumnName.Location = New System.Drawing.Point(9, 226) + Me.lblPrefixColumnName.Location = New System.Drawing.Point(6, 224) Me.lblPrefixColumnName.Name = "lblPrefixColumnName" - Me.lblPrefixColumnName.Size = New System.Drawing.Size(119, 13) + Me.lblPrefixColumnName.Size = New System.Drawing.Size(122, 13) Me.lblPrefixColumnName.TabIndex = 15 Me.lblPrefixColumnName.Tag = "Prefix_For_New_Columns" - Me.lblPrefixColumnName.Text = "Prefix For New Columns" + Me.lblPrefixColumnName.Text = "Prefix For New Columns:" ' 'nudNumberOfSamples ' - Me.nudNumberOfSamples.Location = New System.Drawing.Point(361, 54) + Me.nudNumberOfSamples.Location = New System.Drawing.Point(361, 50) Me.nudNumberOfSamples.Minimum = New Decimal(New Integer() {1, 0, 0, 0}) Me.nudNumberOfSamples.Name = "nudNumberOfSamples" Me.nudNumberOfSamples.Size = New System.Drawing.Size(35, 20) @@ -80,7 +80,7 @@ Partial Class dlgRandomSample ' 'nudSeed ' - Me.nudSeed.Location = New System.Drawing.Point(331, 23) + Me.nudSeed.Location = New System.Drawing.Point(335, 24) Me.nudSeed.Name = "nudSeed" Me.nudSeed.Size = New System.Drawing.Size(35, 20) Me.nudSeed.TabIndex = 18 @@ -88,7 +88,7 @@ Partial Class dlgRandomSample 'chkSetSeed ' Me.chkSetSeed.AutoSize = True - Me.chkSetSeed.Location = New System.Drawing.Point(258, 25) + Me.chkSetSeed.Location = New System.Drawing.Point(259, 25) Me.chkSetSeed.Name = "chkSetSeed" Me.chkSetSeed.Size = New System.Drawing.Size(70, 17) Me.chkSetSeed.TabIndex = 19 @@ -99,17 +99,17 @@ Partial Class dlgRandomSample 'lblNewColumnName ' Me.lblNewColumnName.AutoSize = True - Me.lblNewColumnName.Location = New System.Drawing.Point(10, 226) + Me.lblNewColumnName.Location = New System.Drawing.Point(7, 224) Me.lblNewColumnName.Name = "lblNewColumnName" - Me.lblNewColumnName.Size = New System.Drawing.Size(98, 13) + Me.lblNewColumnName.Size = New System.Drawing.Size(101, 13) Me.lblNewColumnName.TabIndex = 21 Me.lblNewColumnName.Tag = "New_Column_Name" - Me.lblNewColumnName.Text = "New Column Name" + Me.lblNewColumnName.Text = "New Column Name:" ' 'ucrNewColumnName ' Me.ucrNewColumnName.IsReadOnly = False - Me.ucrNewColumnName.Location = New System.Drawing.Point(134, 221) + Me.ucrNewColumnName.Location = New System.Drawing.Point(131, 221) Me.ucrNewColumnName.Name = "ucrNewColumnName" Me.ucrNewColumnName.Size = New System.Drawing.Size(145, 21) Me.ucrNewColumnName.TabIndex = 20 @@ -117,7 +117,7 @@ Partial Class dlgRandomSample 'ucrPrefixNewColumns ' Me.ucrPrefixNewColumns.IsReadOnly = False - Me.ucrPrefixNewColumns.Location = New System.Drawing.Point(134, 222) + Me.ucrPrefixNewColumns.Location = New System.Drawing.Point(131, 222) Me.ucrPrefixNewColumns.Name = "ucrPrefixNewColumns" Me.ucrPrefixNewColumns.Size = New System.Drawing.Size(145, 21) Me.ucrPrefixNewColumns.TabIndex = 16 @@ -125,7 +125,7 @@ Partial Class dlgRandomSample 'ucrSampleSize ' Me.ucrSampleSize.clsDataFrameSelector = Nothing - Me.ucrSampleSize.Location = New System.Drawing.Point(331, 81) + Me.ucrSampleSize.Location = New System.Drawing.Point(327, 77) Me.ucrSampleSize.Name = "ucrSampleSize" Me.ucrSampleSize.Size = New System.Drawing.Size(53, 23) Me.ucrSampleSize.TabIndex = 13 diff --git a/instat/dlgRandomSample.vb b/instat/dlgRandomSample.vb index c4a2ed9c30c..a8b55546b31 100644 --- a/instat/dlgRandomSample.vb +++ b/instat/dlgRandomSample.vb @@ -59,11 +59,16 @@ Public Class dlgRandomSample SetNumberOfSamplesParameters() chkSetSeed.Checked = False nudSeed.Value = 1 + ucrDistWithParameters.SetParameters() SetSeedParameters() End Sub Private Sub ReopenDialog() SetAssignTo() + End Sub + + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + SetDefaults() End Sub Private Sub ucrDataFrameSelector_DataFrameChanged(sender As Object, e As EventArgs, strPrevDataFrame As String) Handles ucrSelectorRandomSamples.DataFrameChanged diff --git a/instat/ucrDistributions.vb b/instat/ucrDistributions.vb index dbea540e2cb..1aa82ea2261 100644 --- a/instat/ucrDistributions.vb +++ b/instat/ucrDistributions.vb @@ -254,7 +254,7 @@ Public Class ucrDistributions clsWeibullDist.strQFunctionName = "qweibull" clsWeibullDist.strDFunctionName = "dweibull" clsWeibullDist.bIsContinuous = True - clsWeibullDist.AddParameter("shape", "Shape") + clsWeibullDist.AddParameter("shape", "Shape", 1) clsWeibullDist.AddParameter("scale", "Scale", 1) lstAllDistributions.Add(clsWeibullDist) @@ -316,8 +316,8 @@ Public Class ucrDistributions clsBetaDist.strQFunctionName = "qbeta" clsBetaDist.strDFunctionName = "dbeta" clsBetaDist.bIsContinuous = True - clsBetaDist.AddParameter("shape1", "a", 1) - clsBetaDist.AddParameter("shape2", "b", 1) + clsBetaDist.AddParameter("shape1", "Shape1", 1) + clsBetaDist.AddParameter("shape2", "Shape2", 1) lstAllDistributions.Add(clsBetaDist) 'Negative Binomial Distribution @@ -384,8 +384,8 @@ Public Class ucrDistributions clsFDist.strPFunctionName = "pf" clsFDist.strQFunctionName = "qf" clsFDist.strDFunctionName = "df" - clsFDist.AddParameter("df1", "DF", 1) - clsFDist.AddParameter("df2", "DF", 1) + clsFDist.AddParameter("df1", "DF1", 1) + clsFDist.AddParameter("df2", "DF2", 1) lstAllDistributions.Add(clsFDist) 'Hypergeometric Distribution