public Task <bool> ShowPicker(IDialogPickerViewModel source) { var tcs = new TaskCompletionSource <bool>(); var dialog = new PickerDialog <PickerDialogViewModel>(); var pickerViewModel = new PickerDialogViewModel(dialog, source); dialog .Show( source.Title, callback: v => tcs.TrySetResult(true), pickerViewModel, pickerCallback: v => { foreach (var selectedItem in source.SelectedItems) { v.Select(selectedItem.Row, selectedItem.Component, animated: false); } }, cancelCallback: () => tcs.TrySetResult(false)); return(tcs.Task); }
private void _previewBackground(Rectangle previewPanel) { if (_isShown) { return; } _isShown = true; PickerDialog dialog = new PickerDialog(Color); dialog.Owner = WpfUtilities.TopWindow; InitialColor = Color.ToGrfColor(); Rectangle previewPanelClosure = previewPanel; dialog.PickerControl.ColorChanged += delegate(object s, Color newColor) { previewPanelClosure.Fill = new SolidColorBrush(newColor); OnPreviewColorChanged(newColor); }; dialog.Closed += delegate { _isShown = false; if (dialog.DialogResult == false) { previewPanel.Fill = new SolidColorBrush(dialog.PickerControl.InitialColor); OnPreviewColorChanged(dialog.PickerControl.InitialColor); } else if (dialog.DialogResult) { OnColorChanged(dialog.PickerControl.SelectedColor); } }; dialog.Show(); }