Пример #1
0
        public Answer ShowDialog(IViewFor<IDialogViewModel<Answer>> view, IDialogViewModel<Answer> viewModel)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }

            view.ViewModel = viewModel;

            var dialog = view as Window;
            if (dialog == null)
            {
                throw new InvalidOperationException("View must derive from System.Windows.Window.");
            }

            dialog.Owner = _parent;
            dialog.ShowDialog();

            return viewModel.Response;
        }
 public bool? ShowDialog(IDialogViewModel viewModel)
 {
     DialogViewModelWindow window = new DialogViewModelWindow(viewModel);
     window.Owner = Application.Current.MainWindow;
     window.SizeToContent = SizeToContent.WidthAndHeight;
     window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     return window.ShowDialog().GetValueOrDefault(false);
 }
Пример #3
0
 public void Show(IDialogViewModel viewModel)
 {
     ViewModels.Add(viewModel);
       viewModel.IsShown = true;
       if (!viewModel.IsShown) return;
       viewModel.PropertyChanged += ViewModelOnPropertyChanged;
       IsShown = true;
 }
Пример #4
0
 public void Close(IDialogViewModel viewModel)
 {
     if (!viewModel.CanClose()) return;
       ViewModels.Remove(viewModel);
       viewModel.PropertyChanged -= ViewModelOnPropertyChanged;
       viewModel.IsShown = false;
       if (ViewModels.Count == 0)
     IsShown = false;
 }
        public DialogViewModelWindow(IDialogViewModel dialogViewModel)
        {
            this.ViewModel = dialogViewModel;
            Content = dialogViewModel;
            ContentRendered += DialogViewModelWindow_ContentRendered;

            if (!dialogViewModel.IsClosable)
            {
                SourceInitialized += DialogViewModelWindow_SourceInitialized;
                this.KeyDown += DialogViewModelWindow_KeyDown;
            }

            this.Loaded += DialogViewModelWindow_Loaded;

        }
        public void Show(IDialogViewModel view, object content, Action<object> onClosed = null)
        {
            _disposer.Disposable = Disposable.Empty;
                view.DialogContent = content;
                view.IsDialogOpen = true;

                var closedCallback = view.WhenValueChanged(v => v.IsDialogOpen, false)
                    .Where(isOpen => !isOpen)
                    .Subscribe(_ => _disposer.Disposable = Disposable.Empty);

                _disposer.Disposable = Disposable.Create(() =>
                {
                    closedCallback.Dispose();
                    view.IsDialogOpen = false;
                    onClosed?.Invoke(view.DialogContent);
                });
        }
Пример #7
0
        public static void Run(string title, UserControl view, IDialogViewModel viewModel, Action<object> callback = null, bool modal = true)
        {
            if (view == null)
                throw new ArgumentNullException("view");
            if (viewModel == null)
                throw new ArgumentNullException("viewModel");

            DialogView dialog = new DialogView();
            dialog.Title = title;
            dialog.View = view;
            dialog.Model = viewModel;
            dialog.SubmitText = viewModel.SubmitText;
            dialog.CancelText = viewModel.CancelText;
            dialog.ShowCancel = viewModel.IsCancelable && !string.IsNullOrWhiteSpace(viewModel.CancelText);

            if (modal) {
                dialog.ShowCallback(callback);
            } else {
                dialog.Show();
            }
        }
Пример #8
0
 /// <summary>
 /// Tries to close a view associated with the view model
 /// </summary>
 /// <param name="viewModel">The viewmodel to that was assigned to the window's data context</param>
 /// <returns>Returns true if successfully closed, otherwise false</returns>
 /// <exception cref="ArgumentNullException">Parameter <paramref name="viewModel"/> is null</exception>
 public static bool TryClose(this IDialogViewModel viewModel) => Navigator.Current.TryClose(viewModel);
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlaylistMapper"/> class.
        /// </summary>
        /// <param name="dialogViewModel">The dialog view model.</param>
        public PlaylistMapper(ViewModelServiceContainer container, IMediaItemMapper mediaItemMapper, IDialogViewModel dialogViewModel, IValidator <Playlist> validator)
            : base(container, validator)
        {
            _dialogViewModel = dialogViewModel ?? throw new ArgumentNullException(nameof(dialogViewModel), $"{nameof(dialogViewModel)} {Resources.IsRequired}");
            _mediaItemMapper = mediaItemMapper ?? throw new ArgumentNullException(nameof(mediaItemMapper), $"{nameof(mediaItemMapper)} {Resources.IsRequired}");

            InitializeMapper();
        }
Пример #10
0
 IDialog IView.CreateDialog(IDialogViewModel value)
 {
     viewModel = value;
     return(this);
 }
        public void Show(Project project, ICodeRepositoryService codeRepService)
        {
            Project = project;
            this.codeRepService = codeRepService;

            NewRepName = FormatFolderString(Project.ClientName) + "-" + FormatFolderString(Project.ProjectName);
            IsCreateRepChecked = true;
            CodeReps = null;
            codeRep = null;
            ReturnMessage = null;

            window = dialogs.NewDialog(String.Format(Properties.Resources.Create_N_repository, codeRepService.RepositoryTypeName), View);
            window.Show();
        }
Пример #12
0
 /// <summary>
 /// Promts a dialog depending on the data context
 /// </summary>
 /// <param name="dataContext">The data context of the dialog</param>
 /// <returns>The result of the dialog</returns>
 protected virtual bool ShowDialogInternal(IDialogViewModel dataContext)
 {
     ModalDialog dlg = new ModalDialog
     {
         DataContext = dataContext,
         Owner =
                 Application.Current.MainWindow != null && Application.Current.MainWindow.IsActive
                     ? Application.Current.MainWindow
                     : null
     };
     return dlg.ShowDialog() == true;
 }
Пример #13
0
 public static void SetDialogDataContext([NotNull] DependencyObject attachingElement, IDialogViewModel value) => attachingElement.SetValue(Dialog.DialogDataContextProperty, value);
        public void Show()
        {
            if (View.IsVisible)
                return;

            if (EditingArtifact == null)
                EditingArtifact = new Artifact() { ArtifactUId = Guid.NewGuid().ToString() };

            Canceled = true;

            window = dialogs.NewDialog(Properties.Resources.Links_AND_Resources, View);
            window.Show();
        }
Пример #15
0
        public DialogResult <TResponse> In(IDialogViewModel <TResponse> dialogViewModel)
        {
            _locateVM = () => dialogViewModel;

            return(this);
        }
Пример #16
0
 public void Close <TArg, TResult>(IDialogViewModel <TArg, TResult> viewModel)
 {
     _dialogsDisplayRegistry.CloseDialog(viewModel);
 }
Пример #17
0
 public void ShowDialog(IDialogViewModel viewModel, IOwnerViewModel ownerViewModel = null)
 {
   if (ownerViewModel == null)
     ownerViewModel = m_rootView;
   ownerViewModel.DialogViewModel.Show(viewModel);
 }
Пример #18
0
 public void CloseDialog(IDialogViewModel viewModel, IOwnerViewModel ownerViewModel = null)
 {
   if (ownerViewModel == null)
     ownerViewModel = m_rootView;
   ownerViewModel.DialogViewModel.CloseCommand.Execute(viewModel);
 }
Пример #19
0
        private async Task ShowDialogAsync(IDialogViewModel viewmodel)
        {
            var message = new DialogMessage(viewmodel);

            await this.Messenger.RaiseAsync(message);
        }
Пример #20
0
 public void Show(Project project)
 {
     this.project = project;
     window = dialogs.NewDialog(Properties.Resources.Hour_costs, View);
     window.Show();
 }
Пример #21
0
 void IDialog.SetViewModel(IDialogViewModel value)
 {
     this.viewModel = value;
     SetPageVisibility(viewModel.UpdatesAndFeedbackPageVisibile, updatesAndFeedbackTabPage);
     SetPageVisibility(viewModel.PluginPageVisible, pluginsTabPage);
 }
Пример #22
0
        public virtual Task <bool?> ShowDialog <TChoice>(IDialogViewModel <TChoice> dialogViewModel, IDialogSettings settings)
        {
            OnUIThread(async() => await _windowManager.ShowDialogAsync(dialogViewModel, null, ConvertToDictionary(settings)));

            return(Task.FromResult(dialogViewModel.DialogResult));
        }
Пример #23
0
 public static bool TryGetDialog(IDialogViewModel viewModel, out Window dialog) => Dialog.ViewModelToDialogMap.TryGetValue(viewModel, out dialog);
Пример #24
0
 public ShowDialogCommand(IDialogViewModel viewModel)
 {
     _ViewModel = viewModel;
 }
Пример #25
0
 /// <summary>
 /// Promts a dialog depending on the data context
 /// </summary>
 /// <param name="dataContext">The data context of the dialog</param>
 /// <returns>The result of the dialog</returns>
 public bool ShowDialog(IDialogViewModel dataContext)
 {
     return ShowDialogInternal(dataContext);
 }
Пример #26
0
 public bool?ShowModal(IDialogViewModel dialogViewModel)
 {
     return(new Dialog(dialogViewModel).ShowDialog());
 }
 private void Show(Task task)
 {
     Task = task;
     TaskWasFinished = false;
     dialog = dialogs.NewDialog(Properties.Resources.Finish_this_task, View);
     dialog.Show();
 }
Пример #28
0
 private void ShowDialog(IDialogViewModel vm)
 {
     Contract.Requires(vm != null);
     vm.OnDialogResult((result) => Modal = null);
     Modal = vm;
 }
Пример #29
0
 IDialogView IView.CreateDialog(IDialogViewModel dialogViewModel, IEnumerable <string> tags, string initiallyFocusedTag)
 {
     return(new AllTagsDialog(viewModel.ChangeNotification, dialogViewModel, tags, initiallyFocusedTag));
 }
Пример #30
0
        public void Show()
        {
            if (View.IsVisible)
                return;

            SelectedRole = Roles.FirstOrDefault();
            Allocation = 0;

            window = dialogs.NewDialog(Properties.Resources.Join_this_project, View);
            window.Show();
        }
Пример #31
0
        private static void AddDialog(IDialogViewModel viewModel, IDialogViewModelCollection collection, Window owner)
        {
            // find the global resource that has been keyed to this view model type
            var resource = Application.Current.TryFindResource(viewModel.GetType());

            if (resource == null)
            {
                return;
            }

            // is this resource a presenter?
            if (IsAssignableToGenericType(resource.GetType(), typeof(IDialogBoxPresenter <>)))
            {
                resource.GetType().GetMethod("Show").Invoke(resource, new object[] { viewModel, owner });
                collection.Remove(viewModel);
            }

            // is this resource a dialog box window?
            else if (resource is Window)
            {
                var userViewModel = viewModel as IUserDialogViewModel;
                if (userViewModel == null)
                {
                    return;
                }
                var dialog = resource as Window;
                dialog.DataContext           = userViewModel;
                DialogBoxes[userViewModel]   = dialog;
                userViewModel.DialogClosing += (sender, args) =>
                                               collection.Remove(sender as IUserDialogViewModel);
                dialog.Closing += (sender, args) =>
                {
                    if (!(bool)dialog.GetValue(ClosingProperty))
                    {
                        dialog.SetValue(ClosingProperty, true);
                        userViewModel.RequestClose();
                        if (!(bool)dialog.GetValue(ClosedProperty))
                        {
                            args.Cancel = true;
                            dialog.SetValue(ClosingProperty, false);
                        }
                    }
                };
                dialog.Closed += (sender, args) =>
                {
                    Debug.Assert(DialogBoxes.ContainsKey(userViewModel));
                    DialogBoxes.Remove(userViewModel);
                    return;
                };
                dialog.Owner = owner;
                if (userViewModel.IsModal)
                {
                    try
                    {
                        dialog.ShowDialog();
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e.Message);
                    }
                }
                else
                {
                    dialog.Show();
                }
            }
        }
Пример #32
0
 public SecondTabViewModel(IDialogViewModel dialogViewModel, IWindowManager windowsManager)
 {
     _dialogViewModel = dialogViewModel;
     _windowsManager = windowsManager;
 }