/// <summary> /// Requires PathValidationRequested to be handled. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Item_Click(object sender, EventArgs e) { var item = (MenuItem)sender; string txt = item.Header as string; if (txt == "Clear list") { RecentPaths.Clear(); SaveRecentFilesList(); return; } var ea = new PathValidationEventArgs() { Path = item.ToolTip as string }; PathValidationRequested?.Invoke(this, ea); if (!ea.Valid) { RemovePath(item.ToolTip as string); MessageBox.Show(Application.Current.MainWindow, $"Invalid file path removed from list: {item.ToolTip}", "Error"); } else { InsertInRecentFilesList(item.ToolTip as string); } }
/// <summary> /// Requires PathValidationRequested to be handled. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Item_Click(object sender, EventArgs e) { var item = (MenuItem)sender; string txt = item.Header as string; if (txt == "Clear list") { RecentPaths.Clear(); SaveRecentFilesList(); return; } var ea = new PathValidationEventArgs() { Path = item.ToolTip as string }; PathValidationRequested?.Invoke(this, ea); if (!ea.Valid) { RemovePath(item.ToolTip as string); } else { InsertInRecentFilesList(item.ToolTip as string); } }
private void RecentFilesMenuStrip2_PathValidationRequested(object sender, PathValidationEventArgs e) { e.Valid = MyImageFileSelector.SetImagePath(e.Path); }
private void RecentFilesMenuStrip1_PathValidationRequested( object sender, PathValidationEventArgs e) { e.Valid = MyAudioFileSelector.SetAudioPath(e.Path); }