コード例 #1
0
ファイル: DialogService.cs プロジェクト: l1pton17/Diabetto
        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);
        }
コード例 #2
0
        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();
        }