/// <summary> /// Allow the user to interact with the control, /// return after they click one of the action buttons. /// </summary> /// <param name="toDelete">The directories to delete if the return is true</param> /// <returns> /// true if user chose to delete, false otherwise /// </returns> public bool Wait(out HashSet <string> toDelete) { if (Platform.IsMono) { // Workaround: make sure the ListView headers are drawn Util.Invoke(DirectoriesListView, () => { DirectoriesListView.EndUpdate(); ContentsListView.EndUpdate(); }); } // Reset the task each time task = new TaskCompletionSource <bool>(); // This will block until one of the buttons calls SetResult if (task.Task.Result) { toDelete = DirectoriesListView.CheckedItems.Cast <ListViewItem>() .Select(lvi => lvi.Tag as string) .Where(s => !string.IsNullOrEmpty(s)) .ToHashSet(); return(true); } else { toDelete = null; return(false); } }
private void DirectoriesListView_ItemSelectionChanged(Object sender, ListViewItemSelectionChangedEventArgs e) { ContentsListView.Items.Clear(); ContentsListView.Items.AddRange( DirectoriesListView.SelectedItems.Cast <ListViewItem>() .SelectMany(lvi => Directory.EnumerateFileSystemEntries( lvi.Tag as string, "*", SearchOption.AllDirectories) .Select(f => new ListViewItem(instance.ToRelativeGameDir(f).Replace('/', Path.DirectorySeparatorChar)))) .ToArray()); if (DirectoriesListView.SelectedItems.Count == 0) { ContentsListView.Items.Add(SelectDirPrompt); } ContentsListView.AutoResizeColumns( ContentsListView.Items.Count > 0 ? ColumnHeaderAutoResizeStyle.ColumnContent : ColumnHeaderAutoResizeStyle.HeaderSize); OpenDirectoryButton.Enabled = DirectoriesListView.SelectedItems.Count > 0; }