public void VerityThatPropertiesAreSetByConstructor()
        {
            this.viewModel = new GenericConfirmationDialogViewModel("the title", "the message");

            Assert.AreEqual("the title", viewModel.Title);
            Assert.AreEqual("the message", viewModel.Message);
        }
        public void VerifyThatNOCommandWorksAsExpected()
        {
            this.viewModel = new GenericConfirmationDialogViewModel("", "");
            this.viewModel.NoCommand.CanExecute(null);

            this.viewModel.NoCommand.Execute(null);

            Assert.IsFalse((bool)this.viewModel.DialogResult.Result.Value);
        }
コード例 #3
0
        /// <summary>
        /// Handles the Dock Panel closing event
        /// </summary>
        /// <param name="region">The region</param>
        /// <param name="regionTarget">The region target</param>
        /// <param name="s">The sender</param>
        /// <param name="e">The <see cref="ItemCancelEventArgs"/></param>
        private void OnPanelClosing(IRegion region, TabbedGroup regionTarget, object s, ItemCancelEventArgs e)
        {
            if (!e.Item.Parent.Equals(regionTarget))
            {
                return;
            }

            var docPanel = e.Item as LayoutPanel;

            if (docPanel == null)
            {
                return;
            }

            var view           = (UserControl)docPanel.Content;
            var panelViewModel = (IPanelViewModel)view.DataContext;

            if (panelViewModel == null)
            {
                return;
            }

            if (!panelViewModel.IsDirty)
            {
                return;
            }

            if (this.dialogNavigationService == null)
            {
                this.dialogNavigationService = ServiceLocator.Current.GetInstance <IDialogNavigationService>();
            }

            var confirmation =
                new GenericConfirmationDialogViewModel("Warning", MessageHelper.ClosingPanelConfirmation);
            var result = this.dialogNavigationService.NavigateModal(confirmation);

            if (result != null && result.Result.HasValue && result.Result.Value)
            {
                return;
            }

            e.Cancel = true;
        }
コード例 #4
0
        /// <summary>
        /// Handles the window's OnClosing event.
        /// </summary>
        /// <param name="args">The <see cref="CancelEventArgs"/></param>
        private void OnClosing(CancelEventArgs args)
        {
            foreach (var panelViewModel in this.DockViewModel.DockPanelViewModels)
            {
                if (panelViewModel.IsDirty)
                {
                    var confirmation = new GenericConfirmationDialogViewModel(panelViewModel.Caption, MessageHelper.ClosingPanelConfirmation);

                    if (this.dialogNavigationService.NavigateModal(confirmation)?.Result is not true)
                    {
                        args.Cancel = true;
                        break;
                    }

                    if (panelViewModel is IHaveAfterOnClosingLogic afterOnClosingViewModel)
                    {
                        afterOnClosingViewModel.AfterOnClosing();
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Executes the show or hide panel command
        /// </summary>
        protected void ExecuteShowOrHide()
        {
            if (this.IsChecked)
            {
                this.PanelViewModel = this.InstantiatePanelViewModel();
                if (this.PanelViewModel == null)
                {
                    throw new InvalidOperationException("The view-model to navigate to is null.");
                }

                this.PanelNavigationServive.Open(this.PanelViewModel, true);
            }
            else
            {
                if (this.PanelViewModel == null)
                {
                    return;
                }

                if (this.PanelViewModel.IsDirty)
                {
                    var confirmation = new GenericConfirmationDialogViewModel("Warning", MessageHelper.ClosingPanelConfirmation);
                    var result       = this.DialogNavigationService.NavigateModal(confirmation);
                    if (result != null && result.Result.HasValue && result.Result.Value)
                    {
                        this.PanelNavigationServive.Close(this.PanelViewModel, true);
                    }
                    else
                    {
                        this.IsChecked = true;
                    }
                }
                else
                {
                    this.PanelNavigationServive.Close(this.PanelViewModel, true);
                }
            }
        }