Skip to content

Commit

Permalink
Merge pull request #1082 from ricaun/patch-2
Browse files Browse the repository at this point in the history
Update UiApplication.cs
  • Loading branch information
pomianowski authored May 12, 2024
2 parents 22c4dc1 + 7a95878 commit 493d1e0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Wpf.Ui/UiApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,22 @@ public class UiApplication
/// </summary>
public UiApplication(Application application)
{
if (application is null)
{
return;
}

if (!ApplicationHasResources(application))
{
return;
}

_application = application;

System.Diagnostics.Debug.WriteLine(
$"INFO | {typeof(UiApplication)} application is {_application}",
"Wpf.Ui"
);
}

/// <summary>
Expand Down Expand Up @@ -111,4 +126,11 @@ public void Shutdown()
{
_application?.Shutdown();
}

private static bool ApplicationHasResources(Application application)
{
return application.Resources.MergedDictionaries
.Where(e => e.Source is not null)
.Any(e => e.Source.ToString().ToLower().Contains(Appearance.ApplicationThemeManager.LibraryNamespace));
}
}

0 comments on commit 493d1e0

Please sign in to comment.