From 122e4101e7348aa4f20485d50609c1f10c91b1bc Mon Sep 17 00:00:00 2001 From: Jesus Date: Fri, 17 Apr 2020 21:28:22 -0700 Subject: [PATCH 1/3] Added Documentation for Dialogs Added documentation for every Dialog file except IDialogParameters/DialogParameters due to #2064 --- .../Services/Dialogs/ButtonResult.cs | 29 ++++++++- src/Wpf/Prism.Wpf/Services/Dialogs/Dialog.cs | 39 +++++++++++- .../Services/Dialogs/DialogResult.cs | 22 +++++++ .../Services/Dialogs/DialogService.cs | 60 ++++++++++++++++++- .../Services/Dialogs/DialogWindow.xaml.cs | 8 ++- .../Services/Dialogs/IDialogAware.cs | 11 ++-- .../Services/Dialogs/IDialogResult.cs | 6 +- .../Services/Dialogs/IDialogService.cs | 31 +++++----- .../Services/Dialogs/IDialogWindow.cs | 40 +++++++++++++ .../Dialogs/IDialogWindowExtensions.cs | 10 +++- 10 files changed, 231 insertions(+), 25 deletions(-) diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/ButtonResult.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/ButtonResult.cs index 102f61bda1..eeaa6eaa62 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/ButtonResult.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/ButtonResult.cs @@ -1,14 +1,41 @@ namespace Prism.Services.Dialogs { + /// + /// The result of the dialog. + /// public enum ButtonResult { + /// + /// Abort. + /// Abort = 3, + /// + /// Cancel. + /// Cancel = 2, + /// + /// Ignore. + /// Ignore = 5, + /// + /// No. + /// No = 7, + /// + /// No result returned. + /// None = 0, + /// + /// OK. + /// OK = 1, - Retry = 4, + /// + /// Retry. + /// + Retry = 4, + /// + /// Yes. + /// Yes = 6 } } diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/Dialog.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/Dialog.cs index 5b5c11667f..79ca52bb96 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/Dialog.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/Dialog.cs @@ -1,31 +1,66 @@ -using System; -using System.Windows; +using System.Windows; namespace Prism.Services.Dialogs { + /// + /// This class contains attached properties. + /// public class Dialog { + /// + /// Identifies the WindowStyle attached property. + /// + /// + /// This attached property is used to specify the style of a . + /// public static readonly DependencyProperty WindowStyleProperty = DependencyProperty.RegisterAttached("WindowStyle", typeof(Style), typeof(Dialog), new PropertyMetadata(null)); + /// + /// Gets the value for the attached property. + /// + /// The target element. + /// The attached to the element. public static Style GetWindowStyle(DependencyObject obj) { return (Style)obj.GetValue(WindowStyleProperty); } + /// + /// Sets the attached property. + /// + /// The target element. + /// The Style to attach. public static void SetWindowStyle(DependencyObject obj, Style value) { obj.SetValue(WindowStyleProperty, value); } + /// + /// Identifies the WindowStartupLocation attached property. + /// + /// + /// This attached property is used to specify the startup location of a . + /// The default startup location is WindowStartupLocation.CenterOwner. + /// public static readonly DependencyProperty WindowStartupLocationProperty = DependencyProperty.RegisterAttached("WindowStartupLocation", typeof(WindowStartupLocation), typeof(Dialog), new UIPropertyMetadata(WindowStartupLocation.CenterOwner, OnWindowStartupLocationChanged)); + /// + /// Gets the value for the attached property. + /// + /// The target element. + /// The attached to the element. public static WindowStartupLocation GetWindowStartupLocation(DependencyObject obj) { return (WindowStartupLocation)obj.GetValue(WindowStartupLocationProperty); } + /// + /// Sets the attached property. + /// + /// The target element. + /// The WindowStartupLocation to attach. public static void SetWindowStartupLocation(DependencyObject obj, WindowStartupLocation value) { obj.SetValue(WindowStartupLocationProperty, value); diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs index 83c3aafdc8..967707f874 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs @@ -1,18 +1,40 @@ namespace Prism.Services.Dialogs { + /// + /// An that contains passed to the dialog + /// and the of the dialog. + /// public class DialogResult : IDialogResult { + /// + /// The parameters passed to the dialog. + /// public IDialogParameters Parameters { get; private set; } = new DialogParameters(); + /// + /// The result of the dialog. + /// public ButtonResult Result { get; private set; } = ButtonResult.None; + /// + /// Initializes a new instance of the class. + /// public DialogResult() { } + /// + /// Initializes a new instance of the class. + /// + /// The result of the dialog. public DialogResult(ButtonResult result) { Result = result; } + /// + /// Initializes a new instance of the class. + /// + /// The result of the dialog. + /// The parameters passed to the dialog. public DialogResult(ButtonResult result, IDialogParameters parameters) { Result = result; diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogService.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogService.cs index 60c2d0e1e2..7db4e0894f 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogService.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogService.cs @@ -7,30 +7,66 @@ namespace Prism.Services.Dialogs { + /// + /// Implements to show modal and non-modal dialogs. + /// + /// + /// The dialog's ViewModel must implement IDialogAware. + /// public class DialogService : IDialogService { private readonly IContainerExtension _containerExtension; + /// + /// Initializes a new instance of the class. + /// + /// public DialogService(IContainerExtension containerExtension) { _containerExtension = containerExtension; } + /// + /// Shows a non-modal dialog. + /// + /// The name of the dialog to show. + /// The parameters to pass to the dialog. + /// The action to perform when the dialog is closed. public void Show(string name, IDialogParameters parameters, Action callback) { ShowDialogInternal(name, parameters, callback, false); } + /// + /// Shows a non-modal dialog. + /// + /// The name of the dialog to show. + /// The parameters to pass to the dialog. + /// The action to perform when the dialog is closed. + /// The name of the hosting window registered with the IContainerRegistry. public void Show(string name, IDialogParameters parameters, Action callback, string windowName) { ShowDialogInternal(name, parameters, callback, false, windowName); } + /// + /// Shows a modal dialog. + /// + /// The name of the dialog to show. + /// The parameters to pass to the dialog. + /// The action to perform when the dialog is closed. public void ShowDialog(string name, IDialogParameters parameters, Action callback) { ShowDialogInternal(name, parameters, callback, true); } + /// + /// Shows a modal dialog. + /// + /// The name of the dialog to show. + /// The parameters to pass to the dialog. + /// The action to perform when the dialog is closed. + /// The name of the hosting window registered with the IContainerRegistry. public void ShowDialog(string name, IDialogParameters parameters, Action callback, string windowName) { ShowDialogInternal(name, parameters, callback, true, windowName); @@ -48,6 +84,11 @@ void ShowDialogInternal(string name, IDialogParameters parameters, Action + /// Create a new + /// + /// The name of the hosting window registered with the IContainerRegistry. + /// The created . protected virtual IDialogWindow CreateDialogWindow(string name) { if (string.IsNullOrWhiteSpace(name)) @@ -56,6 +97,12 @@ protected virtual IDialogWindow CreateDialogWindow(string name) return _containerExtension.Resolve(name); } + /// + /// Configure content. + /// + /// The name of the dialog to show. + /// The hosting window. + /// The parameters to pass to the dialog. protected virtual void ConfigureDialogWindowContent(string dialogName, IDialogWindow window, IDialogParameters parameters) { var content = _containerExtension.Resolve(dialogName); @@ -72,6 +119,11 @@ protected virtual void ConfigureDialogWindowContent(string dialogName, IDialogWi MvvmHelpers.ViewAndViewModelAction(viewModel, d => d.OnDialogOpened(parameters)); } + /// + /// Configure and events. + /// + /// The hosting window. + /// The action to perform when the dialog is closed. protected virtual void ConfigureDialogWindowEvents(IDialogWindow dialogWindow, Action callback) { Action requestCloseHandler = null; @@ -117,6 +169,12 @@ protected virtual void ConfigureDialogWindowEvents(IDialogWindow dialogWindow, A dialogWindow.Closed += closedHandler; } + /// + /// Configure properties. + /// + /// The hosting window. + /// The dialog to show. + /// The dialog's ViewModel. protected virtual void ConfigureDialogWindowProperties(IDialogWindow window, FrameworkElement dialogContent, IDialogAware viewModel) { var windowStyle = Dialog.GetWindowStyle(dialogContent); @@ -124,7 +182,7 @@ protected virtual void ConfigureDialogWindowProperties(IDialogWindow window, Fra window.Style = windowStyle; window.Content = dialogContent; - window.DataContext = viewModel; //we want the host window and the dialog to share the same data contex + window.DataContext = viewModel; //we want the host window and the dialog to share the same data context if (window.Owner == null) window.Owner = Application.Current?.Windows.OfType().FirstOrDefault(x => x.IsActive); diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogWindow.xaml.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogWindow.xaml.cs index c1ce278ea4..e336555ea4 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogWindow.xaml.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogWindow.xaml.cs @@ -3,12 +3,18 @@ namespace Prism.Services.Dialogs { /// - /// Interaction logic for DialogWindow.xaml + /// Prism's default dialog host. /// public partial class DialogWindow : Window, IDialogWindow { + /// + /// The of the dialog. + /// public IDialogResult Result { get; set; } + /// + /// Initializes a new instance of the class. + /// public DialogWindow() { InitializeComponent(); diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogAware.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogAware.cs index 13ec74a99d..7117f5776d 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogAware.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogAware.cs @@ -2,12 +2,15 @@ namespace Prism.Services.Dialogs { + /// + /// Interface that provides dialog functions and events to ViewModels. + /// public interface IDialogAware { /// /// Determines if the dialog can be closed. /// - /// True: close the dialog; False: the dialog will not close + /// If true the dialog can be closed. If false the dialog will not close. bool CanCloseDialog(); /// @@ -18,16 +21,16 @@ public interface IDialogAware /// /// Called when the dialog is opened. /// - /// The parameters passed to the dialog + /// The parameters passed to the dialog. void OnDialogOpened(IDialogParameters parameters); /// - /// The title of the dialog that will show in the Window title bar. + /// The title of the dialog that will show in the window title bar. /// string Title { get; } /// - /// Instructs the IDialogWindow to close the dialog. + /// Instructs the to close the dialog. /// event Action RequestClose; } diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs index cf6bd07fdc..28656a2dc1 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs @@ -1,9 +1,13 @@ namespace Prism.Services.Dialogs { + /// + /// Contains passed to the dialog + /// and the of the dialog. + /// public interface IDialogResult { /// - /// The parameters from the dialog + /// The parameters passed to the dialog. /// IDialogParameters Parameters { get; } diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogService.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogService.cs index ec53bfa375..390a140a51 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogService.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogService.cs @@ -2,41 +2,44 @@ namespace Prism.Services.Dialogs { + /// + /// Interface to show modal and non-modal dialogs. + /// public interface IDialogService { /// - /// Shows a non-modal dialog + /// Shows a non-modal dialog. /// - /// The name of the dialog to show - /// The parameters to pass to the dialog + /// The name of the dialog to show. + /// The parameters to pass to the dialog. /// The action to perform when the dialog is closed. void Show(string name, IDialogParameters parameters, Action callback); /// - /// Shows a non-modal dialog + /// Shows a non-modal dialog. /// - /// The name of the dialog to show - /// The parameters to pass to the dialog + /// The name of the dialog to show. + /// The parameters to pass to the dialog. /// The action to perform when the dialog is closed. - /// The name of the hosting window registered with the IContainerRegistry + /// The name of the hosting window registered with the IContainerRegistry. void Show(string name, IDialogParameters parameters, Action callback, string windowName); /// - /// Shows a modal dialog + /// Shows a modal dialog. /// - /// The name of the dialog to show - /// The parameters to pass to the dialog + /// The name of the dialog to show. + /// The parameters to pass to the dialog. /// The action to perform when the dialog is closed. void ShowDialog(string name, IDialogParameters parameters, Action callback); /// - /// Shows a modal dialog + /// Shows a modal dialog. /// - /// The name of the dialog to show - /// The parameters to pass to the dialog + /// The name of the dialog to show. + /// The parameters to pass to the dialog. /// The action to perform when the dialog is closed. - /// The name of the hosting window registered with the IContainerRegistry + /// The name of the hosting window registered with the IContainerRegistry. void ShowDialog(string name, IDialogParameters parameters, Action callback, string windowName); } } diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindow.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindow.cs index d7140118af..10ebc7708a 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindow.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindow.cs @@ -4,28 +4,68 @@ namespace Prism.Services.Dialogs { + /// + /// Interface for a dialog hosting window + /// public interface IDialogWindow { + /// + /// Dialog content. + /// object Content { get; set; } + /// + /// Close the window. + /// void Close(); + /// + /// The window's owner. + /// Window Owner { get; set; } + /// + /// Show a non-modal dialog. + /// void Show(); + /// + /// Show a modal dialog. + /// + /// bool? ShowDialog(); + /// + /// The data context of the window. + /// + /// + /// The data context must implement . + /// object DataContext { get; set; } + /// + /// Called when the window is loaded. + /// event RoutedEventHandler Loaded; + /// + /// Called when the window is closed. + /// event EventHandler Closed; + /// + /// Called when the window is closing. + /// event CancelEventHandler Closing; + /// + /// The result of the dialog. + /// IDialogResult Result { get; set; } + /// + /// The window style. + /// Style Style { get; set; } } } diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindowExtensions.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindowExtensions.cs index d52d36e5d0..45aa5c7adb 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindowExtensions.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindowExtensions.cs @@ -1,10 +1,18 @@ namespace Prism.Services.Dialogs { + /// + /// extensions. + /// internal static class IDialogWindowExtensions { + /// + /// Get the ViewModel from a . + /// + /// to get ViewModel from. + /// ViewModel as a . internal static IDialogAware GetDialogViewModel(this IDialogWindow dialogWindow) { return (IDialogAware)dialogWindow.DataContext; } } -} +} \ No newline at end of file From 09c154f35c5e7623d1bee73aa83bf3c2c53c5c7e Mon Sep 17 00:00:00 2001 From: Jesus Date: Fri, 17 Apr 2020 21:30:21 -0700 Subject: [PATCH 2/3] Forgot a single period --- src/Wpf/Prism.Wpf/Services/Dialogs/DialogService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogService.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogService.cs index 7db4e0894f..6ca3512880 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogService.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogService.cs @@ -85,7 +85,7 @@ void ShowDialogInternal(string name, IDialogParameters parameters, Action - /// Create a new + /// Create a new . /// /// The name of the hosting window registered with the IContainerRegistry. /// The created . From 646cf1c87765e7a67f39ca75b6c805a4fa900407 Mon Sep 17 00:00:00 2001 From: Jesus Date: Sat, 18 Apr 2020 19:58:43 -0700 Subject: [PATCH 3/3] Reverted IDialogResult and DialogResult comments --- src/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs | 6 +++--- src/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs | 4 ++-- src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindow.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs index 967707f874..f0c9a8c5ef 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs @@ -1,13 +1,13 @@ namespace Prism.Services.Dialogs { /// - /// An that contains passed to the dialog + /// An that contains from the dialog /// and the of the dialog. /// public class DialogResult : IDialogResult { /// - /// The parameters passed to the dialog. + /// The parameters from the dialog. /// public IDialogParameters Parameters { get; private set; } = new DialogParameters(); @@ -34,7 +34,7 @@ public DialogResult(ButtonResult result) /// Initializes a new instance of the class. /// /// The result of the dialog. - /// The parameters passed to the dialog. + /// The parameters from the dialog. public DialogResult(ButtonResult result, IDialogParameters parameters) { Result = result; diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs index 28656a2dc1..0e4228a6be 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs @@ -1,13 +1,13 @@ namespace Prism.Services.Dialogs { /// - /// Contains passed to the dialog + /// Contains from the dialog /// and the of the dialog. /// public interface IDialogResult { /// - /// The parameters passed to the dialog. + /// The parameters from the dialog. /// IDialogParameters Parameters { get; } diff --git a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindow.cs b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindow.cs index 10ebc7708a..69905d6a9d 100644 --- a/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindow.cs +++ b/src/Wpf/Prism.Wpf/Services/Dialogs/IDialogWindow.cs @@ -5,7 +5,7 @@ namespace Prism.Services.Dialogs { /// - /// Interface for a dialog hosting window + /// Interface for a dialog hosting window. /// public interface IDialogWindow {