public static DialogResult SelectFile(Tasker tasker, string[] files) { if (tasker.HostForm.Disposing) { return(DialogResult.Cancel); } if (tasker.HostForm.InvokeRequired) { return((DialogResult)tasker.HostForm.Invoke(new Func <Tasker, string[], DialogResult>(SelectFile), new object[] { tasker, files })); } try { using (var form = new SelectFileForm(files)) { tasker.PushState(Tasker.State.Paused); var result = form.ShowDialog(); tasker.PopState(); selectedFile = form.listBoxFiles.SelectedItem != null?form.listBoxFiles.SelectedItem.ToString() : null; return(result); } } catch (InvalidOperationException) { } return(DialogResult.Cancel); }
private void editReview_Click(object sender, EventArgs e) { string path = $"{Directory.GetCurrentDirectory().Replace("bin\\", string.Empty).Replace("Debug", string.Empty).Replace("Release", string.Empty)}\\CodeReviews\\"; IList <string> paths = Directory.GetFiles(path, "*.crw"); paths = paths.Select(x => x.Replace(path, string.Empty)).ToList(); var form = new SelectFileForm(paths, m_CodeReview); form.ShowDialog(); }
DialogResult SelectFile(string[] files) { var form = new SelectFileForm(files); var result = form.ShowDialog(); if (form.listBoxFiles.SelectedItem != null) { selectedFile = form.listBoxFiles.SelectedItem.ToString(); } else { selectedFile = null; } return(result); }