예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 bool[] Preprocessing.IPreprocessingUserRequests.SelectItems(string prompt, string[] items)
 {
     appWindow.BringToFront();
     using (var dlg = new FilesSelectionDialog())
         return(dlg.Execute(prompt, items));
 }