Skip to content

Commit

Permalink
Merge pull request PrismLibrary#1826 from PrismLibrary/dialog-service…
Browse files Browse the repository at this point in the history
…-updates

Using Enum for IDialogResult.Result
  • Loading branch information
brianlagunas authored Jun 6, 2019
2 parents 428df87 + f124ac5 commit aee7c10
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public string Title

protected virtual void CloseDialog(string parameter)
{
bool? result = null;
ButtonResult result = ButtonResult.None;

if (parameter?.ToLower() == "true")
result = true;
result = ButtonResult.OK;
else if (parameter?.ToLower() == "false")
result = false;
result = ButtonResult.Cancel;

RequestClose?.Invoke(new DialogResult(result));
}
Expand Down
44 changes: 22 additions & 22 deletions Sandbox/Wpf/HelloWorld/HelloWorld/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,44 @@ private void ShowDialog()
//using the dialog service as-is
//_dialogService.ShowDialog("NotificationDialog", new DialogParameters($"message={message}"), r =>
//{
// if (!r.Result.HasValue)
// Title = "Result is null";
// else if (r.Result == true)
// Title = "Result is True";
// else if (r.Result == false)
// Title = "Result is False";
// if (r.Result == ButtonResult.None)
// Title = "Result is None";
// else if (r.Result == ButtonResult.OK)
// Title = "Result is OK";
// else if (r.Result == ButtonResult.Cancel)
// Title = "Result is Cancel";
// else
// Title = "What the hell did you do?";
// Title = "I Don't know what you did!?";
//});

//using custom extenions methods to simplify the app's dialogs
//_dialogService.ShowNotification(message, r =>
//{
// if (!r.Result.HasValue)
// Title = "Result is null";
// else if (r.Result == true)
// Title = "Result is True";
// else if (r.Result == false)
// Title = "Result is False";
// if (r.Result == ButtonResult.None)
// Title = "Result is None";
// else if (r.Result == ButtonResult.OK)
// Title = "Result is OK";
// else if (r.Result == ButtonResult.Cancel)
// Title = "Result is Cancel";
// else
// Title = "What the hell did you do?";
// Title = "I Don't know what you did!?";
//});

_dialogService.ShowConfirmation(message, r =>
{
if (!r.Result.HasValue)
Title = "Result is null";
else if (r.Result == true)
Title = "Result is True";
else if (r.Result == false)
Title = "Result is False";
if (r.Result == ButtonResult.None)
Title = "Result is None";
else if (r.Result == ButtonResult.OK)
Title = "Result is OK";
else if (r.Result == ButtonResult.Cancel)
Title = "Result is Cancel";
else
Title = "What the hell did you do?";
Title = "I Don't know what you did!?";
});
}
}

public static class DialogServiceEstensions
public static class DialogServiceExtensions
{
public static void ShowNotification(this IDialogService dialogService, string message, Action<IDialogResult> callBack)
{
Expand Down
14 changes: 14 additions & 0 deletions Source/Wpf/Prism.Wpf/Services/Dialogs/ButtonResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Prism.Services.Dialogs
{
public enum ButtonResult
{
Abort = 3,
Cancel = 2,
Ignore = 5,
No = 7,
None = 0,
OK = 1,
Retry = 4,
Yes = 6
}
}
1 change: 0 additions & 1 deletion Source/Wpf/Prism.Wpf/Services/Dialogs/DialogParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Prism.Services.Dialogs
{
//TODO: should we reuse the NavigationParameters? I'm not sure I want to add the regions namespace requirement for using dialogs
public class DialogParameters : NavigationParameters, IDialogParameters
{
public DialogParameters() : base() { }
Expand Down
6 changes: 3 additions & 3 deletions Source/Wpf/Prism.Wpf/Services/Dialogs/DialogResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ public class DialogResult : IDialogResult
{
public IDialogParameters Parameters { get; private set; } = new DialogParameters();

public bool? Result { get; private set; }
public ButtonResult Result { get; private set; } = ButtonResult.None;

public DialogResult() { }

public DialogResult(bool? result)
public DialogResult(ButtonResult result)
{
Result = result;
}

public DialogResult(bool? result, IDialogParameters parameters)
public DialogResult(ButtonResult result, IDialogParameters parameters)
{
Result = result;
Parameters = parameters;
Expand Down
4 changes: 2 additions & 2 deletions Source/Wpf/Prism.Wpf/Services/Dialogs/IDialogAware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public interface IDialogAware
void OnDialogOpened(IDialogParameters parameters);

/// <summary>
/// The title of the dialog that wil show in the Window title bar.
/// The title of the dialog that will show in the Window title bar.
/// </summary>
string Title { get; set; }
string Title { get; }

/// <summary>
/// Instructs the IDialogWindow to close the dialog.
Expand Down
2 changes: 1 addition & 1 deletion Source/Wpf/Prism.Wpf/Services/Dialogs/IDialogResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public interface IDialogResult
/// <summary>
/// The result of the dialog.
/// </summary>
bool? Result { get; }
ButtonResult Result { get; }
}
}
2 changes: 1 addition & 1 deletion Source/build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ stages:

- stage: deploy
displayName: Deploy Artifacts
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- deployment: MyGet
displayName: MyGet.org
Expand Down

0 comments on commit aee7c10

Please sign in to comment.