-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
113 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using MaterialDesignThemes.Wpf; | ||
using Stylet; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace MultiFunPlayer.Common.Controls | ||
{ | ||
public class DialogHelper | ||
{ | ||
private static DialogHelper Instance { get; set; } | ||
private IViewManager ViewManager { get; } | ||
|
||
public DialogHelper(IViewManager viewManager) | ||
{ | ||
Instance = this; | ||
ViewManager = viewManager; | ||
} | ||
|
||
public static Task ShowOnUIThreadAsync(object model, string dialogName) | ||
=> _ = Execute.OnUIThreadAsync(async () => await ShowAsync(model, dialogName)); | ||
|
||
public static async Task<object> ShowAsync(object model, string dialogName) | ||
{ | ||
var view = Instance.ViewManager.CreateAndBindViewForModelIfNecessary(model); | ||
var session = DialogHost.GetDialogSession(dialogName); | ||
var sessionContext = (session?.Content as FrameworkElement)?.DataContext; | ||
if (model.Equals(sessionContext)) | ||
return null; | ||
|
||
if (DialogHost.IsDialogOpen(dialogName)) | ||
DialogHost.Close(dialogName); | ||
|
||
(model as IScreenState)?.Activate(); | ||
var result = await DialogHost.Show(view, dialogName).ConfigureAwait(true); | ||
(model as IScreenState)?.Deactivate(); | ||
return result; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
MultiFunPlayer/Common/Controls/ViewModels/ErrorMessageDialogViewModel.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Stylet; | ||
|
||
namespace MultiFunPlayer.Common.Controls.ViewModels | ||
{ | ||
public class ErrorMessageDialogViewModel : Screen | ||
{ | ||
public string Message { get; } | ||
|
||
public ErrorMessageDialogViewModel(string message) => Message = message; | ||
|
||
public override bool Equals(object obj) | ||
=> obj != null && GetType() == obj.GetType() && GetHashCode() == obj.GetHashCode(); | ||
|
||
public override int GetHashCode() => Message.GetHashCode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.