/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { string[] recentFilePaths = RecentFilesRegistryHelper.GetRecentFiles(m_application); if (recentFilePaths.Length > 0) { //Populate the form with the files FormRecentFiles recentFileForm = new FormRecentFiles(); recentFileForm.PopulateFileList(recentFilePaths); //Set up parent window for modal dialog using Application's hWnd NativeWindow parentWindow = new NativeWindow(); parentWindow.AssignHandle(new IntPtr(m_application.hWnd)); //Show dialog and open file if necessary if (recentFileForm.ShowDialog(parentWindow) == DialogResult.OK) { string path = recentFileForm.lstFiles.SelectedItem.ToString(); if (System.IO.File.Exists(path)) { m_application.OpenDocument(path); } else { MessageBox.Show(string.Format("'{0}' cannot be found", path), "File doesn't exist"); } } } }