void Presenters.PreprocessingUserInteractions.IView.SetViewModel(Presenters.PreprocessingUserInteractions.IViewModel viewModel) { var updateDialog = Updaters.Create( () => viewModel.DialogData, dd => { if ((dd != null) != (dialog != null)) { if (dialog != null) { dialog.Close(); dialog = null; } else { synchronizationContext.Post(() => { if (viewModel.DialogData != null) { appWindow.BringToFront(); FilesSelectionDialog.Open(viewModel, reactive, out dialog); } }); } } else if (dialog != null && dd != null) { dialog.Update(dd); } } ); viewModel.ChangeNotification.CreateSubscription(updateDialog); }
public static void Open(IViewModel viewModel, IReactive reactive, out FilesSelectionDialog dialog) { dialog = new FilesSelectionDialog(); var listBox = dialog.checkedListBox1; var listBoxController = reactive.CreateListBoxController <IDialogItem>(listBox); dialog.listBoxController = listBoxController; listBoxController.OnSelect = s => viewModel.OnSelect(s.LastOrDefault()); listBoxController.OnUpdateRow = (item, i, oldItem) => listBox.SetItemChecked(i, item.IsChecked); listBox.ItemCheck += (s, e) => { if (!listBoxController.IsUpdating) { viewModel.OnCheck(listBoxController.Map(listBox.Items[e.Index]), e.NewValue == CheckState.Checked); } }; dialog.Update(viewModel.DialogData); viewModel.OnCloseDialog(dialog.ShowDialog() == DialogResult.OK); }
bool[] Preprocessing.IPreprocessingUserRequests.SelectItems(string prompt, string[] items) { appWindow.BringToFront(); using (var dlg = new FilesSelectionDialog()) return(dlg.Execute(prompt, items)); }