private void OnProcessInput(IXApplication app, ICadApplicationInstanceProvider instProvider, List <IXDocument> input) { if (m_EnableOrdering) { var vm = new InputsSorterVM(instProvider.Descriptor); var cts = new CancellationTokenSource(); var cancellationToken = cts.Token; var src = input.ToArray(); input.Clear(); m_Host.WpfApplication.Dispatcher.Invoke(() => { var wnd = new InputsSorterWindow(); wnd.Owner = m_Host.WpfApplication.MainWindow; wnd.DataContext = vm; wnd.Loaded += async(s, e) => { try { var itemsList = await Task.Run( () => m_Sorter.Sort(src, p => vm.Progress = p, cancellationToken)); vm.LoadItems(itemsList); } catch (OperationCanceledException) { } }; var res = wnd.ShowDialog(); if (res == true) { foreach (ItemVM item in vm.InputView) { input.Add(item.Document); } } else { cts.Cancel(); throw new OperationCanceledException(); } }); } }
private void OnProcessInput(IXApplication app, List <IXDocument> input) { if (m_EnableOrdering) { var cts = new CancellationTokenSource(); var cancellationToken = cts.Token; var src = input.ToArray(); input.Clear(); ItemVM[] itemsList; using (var prg = app.CreateProgress()) { prg.SetStatus("Loading dependency tree..."); itemsList = m_Sorter.Sort(src, p => prg.Report(p), cancellationToken); } var vm = new InputsSorterVM(m_EntDesc); vm.LoadItems(itemsList); var popup = m_Host.Extension.CreatePopupWindow <InputsSorterWindow>(); popup.Control.DataContext = vm; if (popup.ShowDialog() == true) { foreach (ItemVM item in vm.InputView) { input.Add(item.Document); } } else { cts.Cancel(); throw new OperationCanceledException(); } } }