/// <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"); } } } }
public int OnPopup(object hook) { //The incoming hook is the application, determine the number of //items by getting the recent files from the registry m_application = hook as IApplication; m_filePaths = RecentFilesRegistryHelper.GetRecentFiles(m_application); return(m_filePaths.Length); }
/// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { IComboBoxHook comboHook = hook as IComboBoxHook; if (comboHook == null) { m_enabled = false; return; } m_application = comboHook.Hook as IApplication; int cookie = 0; foreach (string fileName in RecentFilesRegistryHelper.GetRecentFiles(m_application)) { if (File.Exists(fileName)) { //Add item to list cookie = comboHook.Add(fileName); m_itemMap.Add(cookie, fileName); } } }