From be1f70e6dcd3775e2a3f029551391e56753c9f54 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Thu, 29 Oct 2020 14:44:13 +0300 Subject: [PATCH 1/3] made recent files to display when recent files have loaded optimised the clsRecentFiles, removed unnecessary calls of refreshing displayed recent files --- instat/clsRecentFiles.vb | 331 +++++++++++++++++++++------------------ instat/frmMain.vb | 7 +- instat/ucrDataView.vb | 7 + 3 files changed, 188 insertions(+), 157 deletions(-) diff --git a/instat/clsRecentFiles.vb b/instat/clsRecentFiles.vb index fe11885ed6e..0171ccd264c 100644 --- a/instat/clsRecentFiles.vb +++ b/instat/clsRecentFiles.vb @@ -16,7 +16,7 @@ Imports System.IO Public Class clsRecentFiles - Public mnuItems As New List(Of Form) + Public lstRecentDialogs As New List(Of Form) Private strRecentFilesPath As String Private mnuTbShowLast10 As ToolStripDropDownItem Private mnuFile As ToolStripMenuItem @@ -24,7 +24,7 @@ Public Class clsRecentFiles 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) + Private lstRecentOpenedFiles As New List(Of String) ''' ''' stores reference to the the data view window used in frmMain. @@ -32,6 +32,10 @@ Public Class clsRecentFiles ''' Private ucrDataViewWindow As ucrDataView + Public Sub New(strAppDataPath As String) + strRecentFilesPath = Path.Combine(strAppDataPath, "recent.mru") + End Sub + Public Sub setToolStripItems(dfMnuFile As ToolStripMenuItem, dfMnuFileIcon As ToolStripSplitButton, dfMnuToolStripDropdown As ToolStripDropDownItem, dfSepStart As ToolStripSeparator, dfSepEnd As ToolStripSeparator) mnuFile = dfMnuFile mnuFileIcon = dfMnuFileIcon @@ -46,177 +50,196 @@ Public Class clsRecentFiles Me.ucrDataViewWindow = ucrDataViewWindow End Sub + ''' + ''' loads the list of last saved recent opened files + ''' Public Sub checkOnLoad() - 'Checks for the existence of the file on form load - ' load recently opened files - strRecentFilesPath = Path.Combine(frmMain.strAppDataPath, "recent.mru") - If (File.Exists(strRecentFilesPath)) Then - ' read file - 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 - ' strListMRU.Add(sPath) - 'End If - strListMRU.Add(sPath) - End If - Next + 'checks for the existence of the file path + If Not File.Exists(strRecentFilesPath) Then + Exit Sub End If - ' display the recently opened files if there are any items to display in the file - UpdateItemsMenu() + + 'read file contents + Dim arrStrPaths() As String = File.ReadAllLines(strRecentFilesPath) + For Each strPath As String In arrStrPaths + If Not String.IsNullOrEmpty(strPath) 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 + ' strListMRU.Add(sPath) + 'End If + lstRecentOpenedFiles.Add(strPath) + End If + Next + 'display the recently opened files if there are any items to display in the file + UpdateRecentFilesMenuItems() End Sub + ''' + ''' saves the list of recent opened files on form close + ''' Public Sub saveOnClose() - Dim sPath As String - - strRecentFilesPath = Path.Combine(frmMain.strAppDataPath, "recent.mru") - 'saves the list of opened files on form close - ' save MRU - delete existing files first + 'overwite any existing contents of the file File.WriteAllText(strRecentFilesPath, "") - 'Write each item to the file... - For Each sPath In strListMRU - File.AppendAllText(strRecentFilesPath, sPath & Environment.NewLine) + 'write each item to the file... + For Each strPath As String In lstRecentOpenedFiles + File.AppendAllText(strRecentFilesPath, strPath & Environment.NewLine) Next End Sub - Public Sub addToMenu(ByVal tempObj As Object) - Dim dialog As Form 'store reccently opened dialogs - Dim path As String 'to store recently opened files - If TypeOf (tempObj) Is Form AndAlso mnuItems IsNot Nothing Then - dialog = tempObj + ''' + ''' adds the form or file path passed object to menu items + ''' + ''' accepts objects of type Form or File Path + Public Sub addToMenu(formOrFilePathObj As Object) + If TypeOf formOrFilePathObj Is Form Then + Dim frmDialog As Form = DirectCast(formOrFilePathObj, Form) 'Checks for existance, else add it to the beginning - If mnuItems.Contains(dialog) Then mnuItems.Remove(dialog) + If lstRecentDialogs.Contains(frmDialog) Then lstRecentDialogs.Remove(frmDialog) 'adds to the list - mnuItems.Add(dialog) - 'checks that only 1o items are allowed - While mnuItems.Count > 10 - mnuItems.RemoveAt(0) - End While + lstRecentDialogs.Add(frmDialog) + 'checks that only 10 items are allowed + If lstRecentDialogs.Count > 10 Then + lstRecentDialogs.RemoveAt(0) + End If + 'update recent dialogs menu items + UpdateRecentDialogsMenuItems() Else - path = tempObj - If strListMRU.Contains(path) Then strListMRU.Remove(path) - ' add to MRU list.. - strListMRU.Add(path) + Dim strFilePath As String = formOrFilePathObj + 'remove file if it exists(helps with making sure displayed file names are rearranged) + lstRecentOpenedFiles.Remove(strFilePath) + 'add to recent opened files list.. + lstRecentOpenedFiles.Add(strFilePath) 'make sure there are only ever 30 items... 'todo. add this to the general options on the number of recently files to show - While strListMRU.Count > 30 - strListMRU.RemoveAt(0) + While lstRecentOpenedFiles.Count > 30 + lstRecentOpenedFiles.RemoveAt(0) End While + 'update recent files menu items + UpdateRecentFilesMenuItems() End If + End Sub - 'updates the interfaces - UpdateItemsMenu() + ''' + ''' updates the menu toolstrip to show the last 10 opened dialogs + ''' + Public Sub UpdateRecentDialogsMenuItems() + 'exit sub if last 10 toolstrip or list of last 10 dialogs are not initialised + If mnuTbShowLast10 Is Nothing Then + Exit Sub + End If + 'remove the menu items of recent opened dialogs + For i As Integer = mnuTbShowLast10.DropDownItems.Count - 1 To 0 Step -1 + If mnuTbShowLast10.DropDownItems(i).Tag IsNot Nothing AndAlso mnuTbShowLast10.DropDownItems(i).Tag.ToString().StartsWith("Last") Then + mnuTbShowLast10.DropDownItems.RemoveAt(i) + End If + Next + + 'the add and displays menu items (_in reverse order) for dialogs + For icounter As Integer = lstRecentDialogs.Count - 1 To 0 Step -1 + 'creates new toolstripitem, displaying name of the dialog + Dim clsItem As New ToolStripMenuItem(lstRecentDialogs(icounter).Text) + 'sets the tag + clsItem.Tag = "Last" + AddHandler clsItem.Click, AddressOf OnMnuLastRecentDialog_Click + 'insert into the dropdownitems + 'mnuTbShowLast10.DropDownItems.Insert(mnuTbShowLast10.DropDownItems.Count - 1, clsItem) + mnuTbShowLast10.DropDownItems.Add(clsItem) + Next End Sub - Private Sub UpdateItemsMenu() - 'clears the menu items first - Dim clsItems As New List(Of ToolStripItem) - If mnuTbShowLast10 IsNot Nothing AndAlso mnuFile IsNot Nothing AndAlso mnuFileIcon IsNot Nothing AndAlso clsItems IsNot Nothing AndAlso mnuItems IsNot Nothing AndAlso strListMRU IsNot Nothing Then - 'temp collection for recent dialogs - For Each clsMenu As ToolStripItem In mnuTbShowLast10.DropDownItems - If Not clsMenu.Tag Is Nothing Then - If (clsMenu.Tag.ToString().StartsWith("Last")) Then - clsItems.Add(clsMenu) - End If - End If - Next - 'temp collection for recent files - For Each clsMenu As ToolStripItem In mnuFile.DropDownItems - If Not clsMenu.Tag Is Nothing Then - If (clsMenu.Tag.ToString().StartsWith("MRU:")) Then - clsItems.Add(clsMenu) - End If - End If - Next - 'temp collection for recent files - For Each clsMenu As ToolStripItem In mnuFileIcon.DropDownItems - If Not clsMenu.Tag Is Nothing Then - If (clsMenu.Tag.ToString().StartsWith("MRU:")) Then - clsItems.Add(clsMenu) - End If - End If - Next - 'go through the list and remove each from the menu - For Each clsMenu As ToolStripItem In clsItems - mnuTbShowLast10.DropDownItems.Remove(clsMenu) - mnuFile.DropDownItems.Remove(clsMenu) - mnuFileIcon.DropDownItems.Remove(clsMenu) - Next + ''' + ''' updates menu toolstrip and ucrDataView to show the recent files opened + ''' + Public Sub UpdateRecentFilesMenuItems() + 'exit sub if file toolstrip or file icon toolstrip are not initialised + If mnuFile Is Nothing OrElse mnuFileIcon Is Nothing Then + Exit Sub + End If - 'displays items (_in reverse order) for dialogs - For icounter As Integer = mnuItems.Count - 1 To 0 Step -1 - Dim dialog As Form = mnuItems(icounter) - 'creates new toolstripitem, displaying name of the dialog - Dim clsItem As New ToolStripMenuItem(dialog.Text) - 'sets the tag - clsItem.Tag = "Last" - AddHandler clsItem.Click, AddressOf mnuFile_Click - 'insert into the dropdownitems - mnuTbShowLast10.DropDownItems.Insert(mnuTbShowLast10.DropDownItems.Count - 1, clsItem) - Next + Dim strPath As String + Dim strFileName As String - 'remove all the data view window recent file menu items - ucrDataViewWindow.ClearRecentFileMenuItems() + 'remove all displaced recent files from the menu items + For i As Integer = mnuFile.DropDownItems.Count - 1 To 0 Step -1 + If mnuFile.DropDownItems(i).Tag IsNot Nothing AndAlso mnuFile.DropDownItems(i).Tag.ToString().StartsWith("MRU:") Then + mnuFile.DropDownItems.RemoveAt(i) + End If + Next + + For i As Integer = mnuFileIcon.DropDownItems.Count - 1 To 0 Step -1 + If mnuFileIcon.DropDownItems(i).Tag IsNot Nothing AndAlso mnuFileIcon.DropDownItems(i).Tag.ToString().StartsWith("MRU:") Then + mnuFileIcon.DropDownItems.RemoveAt(i) + End If + Next - 'then displays items (_in reverse order) for recent files - Dim strPath As String - Dim strFileName As String - For iCounter As Integer = strListMRU.Count - 1 To 0 Step -1 - strPath = strListMRU(iCounter) - Try - strFileName = Path.GetFileName(strPath) - ' create new ToolStripItem, displaying the name of the file... - Dim clsItem As New ToolStripMenuItem(strFileName) - Dim clsItemIcon As New ToolStripMenuItem(strFileName) - clsItem.ToolTipText = strPath - clsItemIcon.ToolTipText = strPath - ' set the tag - identifies the ToolStripItem as an MRU item and - ' contains the full path so it can be opened later... - clsItem.Tag = "MRU:" & strPath - clsItemIcon.Tag = "MRU:" & strPath - ' hook into the click event handler so we can open the file later... - AddHandler clsItem.Click, AddressOf mnuFileMRU_Click - AddHandler clsItemIcon.Click, AddressOf mnuFileMRU_Click - ' insert into DropDownItems list... - mnuFile.DropDownItems.Insert(mnuFile.DropDownItems.Count - 1, clsItem) - mnuFileIcon.DropDownItems.Insert(mnuFileIcon.DropDownItems.Count, clsItemIcon) + 'remove all the data view window recent file menu items + ucrDataViewWindow.ClearRecentFileMenuItems() - 'set and insert the data view window recent files menu items - Dim linkMenuItem As New LinkLabel - linkMenuItem.Text = strFileName - linkMenuItem.Tag = strPath 'path used when the link is clicked + 'then add and displays items (_in reverse order) for recent files + For iCounter As Integer = lstRecentOpenedFiles.Count - 1 To 0 Step -1 + Try + strPath = lstRecentOpenedFiles(iCounter) + strFileName = Path.GetFileName(strPath) + ' create new ToolStripItem, displaying the name of the file... + Dim clsItem As New ToolStripMenuItem(strFileName) + Dim clsItemIcon As New ToolStripMenuItem(strFileName) + clsItem.ToolTipText = strPath + clsItemIcon.ToolTipText = strPath + ' set the tag - will be used to identify the ToolStripItem as an most recent(MRU) item + ' and contains the full path so it can be opened later + clsItem.Tag = "MRU:" & strPath + clsItemIcon.Tag = "MRU:" & strPath + ' hook into the click event handler so we can open the file later... + AddHandler clsItem.Click, AddressOf OnMnuRecentOpenedFile_Click + AddHandler clsItemIcon.Click, AddressOf OnMnuRecentOpenedFile_Click + ' insert into DropDownItems list... + mnuFile.DropDownItems.Insert(mnuFile.DropDownItems.Count - 1, clsItem) + mnuFileIcon.DropDownItems.Insert(mnuFileIcon.DropDownItems.Count, clsItemIcon) - ucrDataViewWindow.InsertRecentFileMenuItems(linkMenuItem) + 'set and insert the data view window recent files menu items + Dim linkMenuItem As New LinkLabel + linkMenuItem.Text = strFileName + linkMenuItem.Tag = strPath 'path used when the link is clicked - 'attach link click event handler for opening the file - AddHandler linkMenuItem.Click, AddressOf mnuFileMRU_Click + ucrDataViewWindow.InsertRecentFileMenuItems(linkMenuItem) - 'if recent files are more than 5 then just the "more" link label and exit loop - If strListMRU.Count - iCounter > 4 Then - linkMenuItem = New LinkLabel - linkMenuItem.Text = "More ..." - linkMenuItem.Tag = "" - ucrDataViewWindow.InsertRecentFileMenuItems(linkMenuItem) - AddHandler linkMenuItem.Click, AddressOf mnuFileMRU_Click - Exit For - End If - Catch ex As Exception - 'TODO it would be good to remove the invalid line from the file in this case - End Try - Next + 'attach link click event handler for opening the file + AddHandler linkMenuItem.Click, AddressOf OnMnuRecentOpenedFile_Click - ' show separator - 'frmMain.sepEndMRU.Visible = True + 'if recent files are more than 5 then just the "more" link label and exit loop + If lstRecentOpenedFiles.Count - iCounter >= 5 Then + linkMenuItem = New LinkLabel + linkMenuItem.Text = "More ..." + linkMenuItem.Tag = "" + ucrDataViewWindow.InsertRecentFileMenuItems(linkMenuItem) + AddHandler linkMenuItem.Click, AddressOf OnMnuRecentOpenedFile_Click + Exit For + End If + Catch ex As Exception + 'TODO it would be good to remove the invalid line from the file in this case + End Try + Next + + 'show separator + If lstRecentOpenedFiles.Count > 0 Then sepStart.Visible = True sepEnd.Visible = True + Else + sepStart.Visible = False + sepEnd.Visible = False End If + End Sub - Private Sub mnuFileMRU_Click(ByVal sender As Object, ByVal e As EventArgs) + ''' + ''' raised when menu item of recent opened file is clicked + ''' + ''' ToolStripItem or LinkLabel only + ''' + Private Sub OnMnuRecentOpenedFile_Click(ByVal sender As Object, ByVal e As EventArgs) Dim strFilePath As String = "" If TypeOf sender Is ToolStripItem Then @@ -231,26 +254,26 @@ Public Class clsRecentFiles End If If File.Exists(strFilePath) 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.strFileToOpenOn = strFilePath dlgImportDataset.ShowDialog() Else 'removes the path to the non existent file If DialogResult.Yes = MessageBox.Show(frmMain, "File not accessible. It may have been renamed, moved or deleted." & Environment.NewLine & Environment.NewLine & "Would you like to remove this file from the list?", "Cannot access file", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) Then - strListMRU.RemoveAt(strListMRU.FindLastIndex(Function(value As String) - Return value.Contains(sender.ToString) - End Function)) - 'updates the interfaces - UpdateItemsMenu() + lstRecentOpenedFiles.Remove(strFilePath) + 'update recent file menu items controls to not show the file name and path + UpdateRecentFilesMenuItems() End If End If End Sub - Private Sub mnuFile_Click(ByVal sender As Object, ByVal e As EventArgs) - For Each dfTemp As Form In mnuItems - If dfTemp.Text = sender.ToString Then + ''' + ''' raised when last dialog menu item is clicked + ''' + ''' ToolStripMenuItem + ''' + Private Sub OnMnuLastRecentDialog_Click(ByVal sender As Object, ByVal e As EventArgs) + For Each dfTemp As Form In lstRecentDialogs + If dfTemp.Text = DirectCast(sender, ToolStripMenuItem).Text Then dfTemp.ShowDialog() Exit Sub End If @@ -265,8 +288,8 @@ Public Class clsRecentFiles ucrDataViewWindow.ClearRecentFileMenuItems() 'displays items (_in reverse order) for recent files Dim strPath As String - For iCounter As Integer = strListMRU.Count - 1 To 0 Step -1 - strPath = strListMRU(iCounter) + For iCounter As Integer = lstRecentOpenedFiles.Count - 1 To 0 Step -1 + strPath = lstRecentOpenedFiles(iCounter) Try Dim linkMenuItem As New LinkLabel linkMenuItem.Text = Path.GetFileName(strPath) @@ -275,7 +298,7 @@ Public Class clsRecentFiles ucrDataViewWindow.InsertRecentFileMenuItems(linkMenuItem) 'attach link event handler for opening the file - AddHandler linkMenuItem.Click, AddressOf mnuFileMRU_Click + AddHandler linkMenuItem.Click, AddressOf OnMnuRecentOpenedFile_Click Catch ex As Exception 'TODO it would be good to remove the invalid line from the file in this case End Try diff --git a/instat/frmMain.vb b/instat/frmMain.vb index a8dd518d3db..b11b8fd9746 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -30,7 +30,7 @@ Public Class frmMain Public strAppDataPath As String Public strInstatOptionsFile As String = "Options.bin" Public clsInstatOptions As InstatOptions - Public clsRecentItems As New clsRecentFiles + Public clsRecentItems As clsRecentFiles Public strCurrentDataFrame As String Public dlgLastDialog As Form Public strSaveFilePath As String = "" @@ -121,6 +121,7 @@ Public Class frmMain AddHandler System.Windows.Forms.Application.Idle, AddressOf Application_Idle 'Sets up the Recent items + clsRecentItems = New clsRecentFiles(strAppDataPath) clsRecentItems.setToolStripItems(mnuFile, mnuTbOpen, mnuTbLast10Dialogs, sepStart, sepEnd) clsRecentItems.SetDataViewWindow(ucrDataViewer) 'checks existence of MRU list @@ -511,8 +512,8 @@ Public Class frmMain End Sub Private Sub EditLastDialogueToolStrip_Click(sender As Object, e As EventArgs) Handles mnuTbEditLastDialog.Click - If clsRecentItems.mnuItems.Count > 0 Then - clsRecentItems.mnuItems.Last.ShowDialog() + If clsRecentItems.lstRecentDialogs.Count > 0 Then + clsRecentItems.lstRecentDialogs.Last.ShowDialog() End If End Sub diff --git a/instat/ucrDataView.vb b/instat/ucrDataView.vb index d9306920b9d..fb6a5b7ce52 100644 --- a/instat/ucrDataView.vb +++ b/instat/ucrDataView.vb @@ -55,6 +55,7 @@ Public Class ucrDataView grdData.SetSettings(unvell.ReoGrid.WorksheetSettings.Edit_AutoFormatCell, False) grdData.SheetTabWidth = 450 SetRFunctions() + HideOrShowRecentPanel() End Sub 'Protected Overrides Sub OnFormClosing(ByVal e As FormClosingEventArgs) @@ -887,6 +888,7 @@ Public Class ucrDataView ''' Public Sub ClearRecentFileMenuItems() panelRecentMenuItems.Controls.Clear() + HideOrShowRecentPanel() End Sub ''' @@ -919,6 +921,11 @@ Public Class ucrDataView lblMenuItemPath.Height = 13 lblMenuItemPath.AutoSize = True panelRecentMenuItems.Controls.Add(lblMenuItemPath) + HideOrShowRecentPanel() + End Sub + + Private Sub HideOrShowRecentPanel() + lblRecent.Visible = panelRecentMenuItems.Controls.Count > 0 End Sub Private Sub linkHelpIntroduction_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles linkHelpIntroduction.LinkClicked From 7a28611817bf4b800b1d37e7a156c17df8ff32c8 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Tue, 3 Nov 2020 23:22:19 +0300 Subject: [PATCH 2/3] Update instat/clsRecentFiles.vb Co-authored-by: lloyddewit <57253949+lloyddewit@users.noreply.github.com> --- instat/clsRecentFiles.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/clsRecentFiles.vb b/instat/clsRecentFiles.vb index 0171ccd264c..3492ce213ce 100644 --- a/instat/clsRecentFiles.vb +++ b/instat/clsRecentFiles.vb @@ -137,7 +137,7 @@ Public Class clsRecentFiles End If Next - 'the add and displays menu items (_in reverse order) for dialogs + 'then add and display menu items (in reverse order) for dialogs For icounter As Integer = lstRecentDialogs.Count - 1 To 0 Step -1 'creates new toolstripitem, displaying name of the dialog Dim clsItem As New ToolStripMenuItem(lstRecentDialogs(icounter).Text) From b71a579157f6c44945e4986628d1b5d84fd0f529 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Wed, 4 Nov 2020 13:10:43 +0300 Subject: [PATCH 3/3] changed addToMenu --- instat/clsRecentFiles.vb | 58 +++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/instat/clsRecentFiles.vb b/instat/clsRecentFiles.vb index 3492ce213ce..41a4ae23e9d 100644 --- a/instat/clsRecentFiles.vb +++ b/instat/clsRecentFiles.vb @@ -89,36 +89,38 @@ Public Class clsRecentFiles End Sub ''' - ''' adds the form or file path passed object to menu items + ''' adds the form to menu items ''' - ''' accepts objects of type Form or File Path - Public Sub addToMenu(formOrFilePathObj As Object) - If TypeOf formOrFilePathObj Is Form Then - Dim frmDialog As Form = DirectCast(formOrFilePathObj, Form) - 'Checks for existance, else add it to the beginning - If lstRecentDialogs.Contains(frmDialog) Then lstRecentDialogs.Remove(frmDialog) - 'adds to the list - lstRecentDialogs.Add(frmDialog) - 'checks that only 10 items are allowed - If lstRecentDialogs.Count > 10 Then - lstRecentDialogs.RemoveAt(0) - End If - 'update recent dialogs menu items - UpdateRecentDialogsMenuItems() - Else - Dim strFilePath As String = formOrFilePathObj - 'remove file if it exists(helps with making sure displayed file names are rearranged) - lstRecentOpenedFiles.Remove(strFilePath) - 'add to recent opened files list.. - lstRecentOpenedFiles.Add(strFilePath) - 'make sure there are only ever 30 items... - 'todo. add this to the general options on the number of recently files to show - While lstRecentOpenedFiles.Count > 30 - lstRecentOpenedFiles.RemoveAt(0) - End While - 'update recent files menu items - UpdateRecentFilesMenuItems() + ''' form to add to menu items + Public Sub addToMenu(frmDialog As Form) + 'Checks for existance, else add it to the beginning + If lstRecentDialogs.Contains(frmDialog) Then lstRecentDialogs.Remove(frmDialog) + 'adds to the list + lstRecentDialogs.Add(frmDialog) + 'checks that only 10 items are allowed + If lstRecentDialogs.Count > 10 Then + lstRecentDialogs.RemoveAt(0) End If + 'update recent dialogs menu items + UpdateRecentDialogsMenuItems() + End Sub + + ''' + ''' adds the file path to menu items + ''' + ''' file path to add to menu items + Public Sub addToMenu(strFilePath As String) + 'remove file if it exists(helps with making sure displayed file names are rearranged) + lstRecentOpenedFiles.Remove(strFilePath) + 'add to recent opened files list.. + lstRecentOpenedFiles.Add(strFilePath) + 'make sure there are only ever 30 items... + 'todo. add this to the general options on the number of recently files to show + While lstRecentOpenedFiles.Count > 30 + lstRecentOpenedFiles.RemoveAt(0) + End While + 'update recent files menu items + UpdateRecentFilesMenuItems() End Sub '''