コード例 #1
0
        private void BaseView_OnPass(bool modal, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                dialogsService.ShowError("Value can not be empty");
                return;
            }

            var presenter = presenterFactory.Create <ResultPresenter, IResultView>(ViewKeys.Result, value);

            if (modal)
            {
                var result = (string)presenter.ShowAsModal();
                if (string.IsNullOrEmpty(result))
                {
                    dialogsService.ShowInfo("Cancelled");
                }
                else
                {
                    dialogsService.ShowInfo("Retured value: " + result);
                }
            }
            else
            {
                presenter.Show();
            }
        }
コード例 #2
0
        public MainViewModel()
        {
            var filter = new FilterPair
            {
                Extensions = "txt",
                Title      = "Text files"
            };
            var filters = new List <FilterPair>
            {
                filter
            };

            DialogActions = new ObservableCollection <DialogActionViewModel>
            {
                new DialogActionViewModel
                {
                    Title  = "Info",
                    Action = () => dialogs.ShowInfo("Sample information", "Sample information details")
                },
                new DialogActionViewModel
                {
                    Title  = "Warning",
                    Action = () => dialogs.ShowWarning("Sample warning", "Sample warning details")
                },
                new DialogActionViewModel
                {
                    Title  = "Error",
                    Action = () => dialogs.ShowError("Sample error", "Sample error details")
                },
                new DialogActionViewModel
                {
                    Title  = "Exception",
                    Action = () => dialogs.ShowException(GetException(), "Sample exception")
                },
                new DialogActionViewModel
                {
                    Title  = "Critical exception",
                    Action = () => dialogs.ShowCriticalException(GetException(), "Sample critial exception")
                },
                new DialogActionViewModel
                {
                    Title  = "Yes/no question",
                    Action = () =>
                    {
                        var result = dialogs.ShowYesNoQuestion("Sample yes no question");
                        dialogs.ShowInfo("Result: " + result);
                    }
                },
                new DialogActionViewModel
                {
                    Title  = "Custom question",
                    Action = () =>
                    {
                        var buttons = new List <CustomButton <int> >
                        {
                            new CustomButton <int>
                            {
                                Text  = "1",
                                Value = 1
                            },
                            new CustomButton <int>
                            {
                                Text  = "2",
                                Value = 2
                            },
                            new CustomButton <int>
                            {
                                Text    = "3",
                                Value   = 3,
                                Default = true
                            }
                        };
                        var result = dialogs.ShowCustomButtonsQuestion("Custom question", buttons);
                        dialogs.ShowInfo("Result: " + result);
                    }
                },
                new DialogActionViewModel
                {
                    Title  = "Open file",
                    Action = () =>
                    {
                        var result = dialogs.OpenFile("Sample open file dialog", false, null, filters);
                        dialogs.ShowInfo("Result: " + result);
                    }
                },
                new DialogActionViewModel
                {
                    Title  = "Open files",
                    Action = () =>
                    {
                        var result = dialogs.OpenFiles("Sample open files dialog", false, null, filters);
                        dialogs.ShowInfo("Result: " + result);
                    }
                },
                new DialogActionViewModel
                {
                    Title  = "Open folder",
                    Action = () =>
                    {
                        var result = dialogs.OpenFolder("Sample open folder dialog", null);
                        dialogs.ShowInfo("Result: " + result);
                    }
                },
                new DialogActionViewModel
                {
                    Title  = "Save file",
                    Action = () =>
                    {
                        var result = dialogs.SaveFile("Sample save file dialog", null, null, filter);
                        dialogs.ShowInfo("Result: " + result);
                    }
                },
            };
            SelectedAction = DialogActions.First();
        }