コード例 #1
0
 private void ModifySelectionExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     if (e.Parameter == null) return;
     if (e.Parameter.ToString().ToLowerInvariant().Equals("selectall"))
     {
         ListViewExplorer.SelectedItems.Clear();
         ListViewExplorer.Items.Cast<FileSystemInfo>()
             .AsParallel()
             .ForAll(info => { Dispatcher.InvokeAsync(()=> { ListViewExplorer.SelectedItems.Add(info); }); });
     }
     else
     {
         var fs = new FileSystemInfo[ListViewExplorer.SelectedItems.Count];
         ListViewExplorer.SelectedItems.CopyTo(fs, 0);
         if (fs.Length > 0)
         {
             ListViewExplorer.SelectedItems.Clear();
             ListViewExplorer.Items.Cast<FileSystemInfo>()
                 .AsParallel()
                 .ForAll(info =>
                 {
                     if (!fs.Contains(info))
                     {
                         Dispatcher.InvokeAsync(() => { ListViewExplorer.SelectedItems.Add(info); });
                     }
                 });
         }
     }
 }