Example #1
0
        /// <inheritdoc />
        public void Show(IDialogModel dialogModel)
        {
            var dialog = CreateDialogWindow(dialogModel);

            _windowStack.Push(dialog);
            dialog.Show();
        }
        public static bool?ShowDialog(Window owner, IDialogModel model)
        {
            var headerViewModel = new DialogHeaderMessageViewModel(model.Message);
            IDialogFooterViewModel footerViewModel;

            if (model.Buttons == DialogButtons.YesNo)
            {
                footerViewModel = new DialogFooterYesNoViewModel(model.Buttons);
            }
            else if (model.Buttons == DialogButtons.Ok)
            {
                footerViewModel = new DialogFooterOkViewModel(model.Buttons);
            }
            else
            {
                throw new NotImplementedException("This type of buttons is not implemented yet");
            }

            var dialogViewModel = new DialogViewModel(model.Caption,
                                                      headerViewModel,
                                                      footerViewModel);

            var dialog = new DialogWindow()
            {
                DataContext = dialogViewModel,
                Owner       = owner
            };

            return(dialog.ShowDialog());
        }
Example #3
0
        public static Task <bool?> ShowDialogAsync(IDialogModel model)
        {
            return(GO.Dispatch(delegate {
                var dialog = new GenericDialog {
                };

                dialog.NotifyWindowManager();

                return dialog.ShowDialogWithModelAsync(model);
            }));
        }
        public void ShowDialogAsync <T>(IDialogModel model, Action closed = null) where T : IDialogWindow, new()
        {
            IDialogWindow dialog = CreateDialog <T>(model, closed);

            if (model.IsModal)
            {
                ShowModalDialog(dialog);
            }
            else
            {
                ShowModalessDialog(dialog);
            }
        }
        public void ShowDialog <T>(IDialogModel model, Action closed = null) where T : IDialogWindow, new()
        {
            IDialogWindow dialog = CreateDialog <T>(model, closed);

            if (model.IsModal)
            {
                dialog.ShowDialog();
            }
            else
            {
                dialog.Show();
            }
        }
Example #6
0
        private Window CreateDialogWindow(IDialogModel dialogModel)
        {
            var window = new DialogWindow
            {
                DataContext = dialogModel
            };

            window.SetBinding(Window.TitleProperty, new Binding(nameof(dialogModel.Title))
            {
                Mode = BindingMode.OneWay,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            return(window);
        }
Example #7
0
        public async Task <bool?> ShowDialogWithModelAsync(IDialogModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model), $"{nameof(model)} is null.");
            }

            Model = model;

            var result = await Dispatcher.InvokeAsync(ShowDialog);

            Model = null;

            return(result);
        }
        private IDialogWindow CreateDialog <T>(IDialogModel model, Action closed) where T : IDialogWindow, new()
        {
            IDialogWindow dialog = new T
            {
                Model = model
            };

            model.IsShown       = true;
            model.RequestClose += (s, e) => dialog.Close();

            if (closed != null)
            {
                dialog.Closed += (s, e) => closed();
            }

            return(dialog);
        }
Example #9
0
        /// <inheritdoc />
        public bool?ShowDialog(IDialogModel dialogModel)
        {
            var dialog = CreateDialogWindow(dialogModel);

            if (_windowStack.Any())
            {
                dialog.Owner = _windowStack.Peek();
                dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            }
            _windowStack.Push(dialog);

            try
            {
                return(dialog.ShowDialog());
            }
            finally
            {
                _windowStack.Pop();
            }
        }
Example #10
0
        public bool?ShowDialog(IDialogModel dataContext, Style style)
        {
            DialogWindow dialog = CreateDialog(dataContext, style, true);

            return(dialog.ShowDialog());
        }
Example #11
0
 public bool?ShowDialog(IDialogModel dataContext)
 {
     return(ShowDialog(dataContext, null));
 }
Example #12
0
        public void Show(IDialogModel dataContext, Style style)
        {
            DialogWindow dialog = CreateDialog(dataContext, style, false);

            dialog.Show();
        }
Example #13
0
 public void Show(IDialogModel dataContext)
 {
     Show(dataContext, null);
 }