Skip to content

Commit

Permalink
Merge pull request #39 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
Merge from Master Copy
  • Loading branch information
lilyclements authored Oct 15, 2016
2 parents d34a805 + 3782194 commit 985c5fc
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 136 deletions.
54 changes: 54 additions & 0 deletions instat/My Project/Resources.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions instat/My Project/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1549,4 +1549,22 @@
<data name="SDlog" xml:space="preserve">
<value>SDlog</value>
</data>
<data name="Population_Failures" xml:space="preserve">
<value>Population Failures</value>
</data>
<data name="Population_Successes" xml:space="preserve">
<value>Population Successes</value>
</data>
<data name="DF_1" xml:space="preserve">
<value>DF 1</value>
</data>
<data name="DF_2" xml:space="preserve">
<value>DF 2</value>
</data>
<data name="Shape_1" xml:space="preserve">
<value>Shape 1</value>
</data>
<data name="Shape_2" xml:space="preserve">
<value>Shape 2</value>
</data>
</root>
62 changes: 27 additions & 35 deletions instat/clsRecentFiles.vb
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -178,5 +171,4 @@ Public Class clsRecentFiles
End If
Next
End Sub

End Class
Loading

0 comments on commit 985c5fc

Please sign in to comment.