Skip to content

Commit

Permalink
更新 v3.0.40
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed Apr 17, 2023
1 parent ab8d593 commit 2fd6514
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions CoolapkUWP/CoolapkUWP/Helpers/ThemeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@ public static ElementTheme ActualTheme
{
get
{
return CurrentApplicationWindow?.Dispatcher?.HasThreadAccess == true
? CurrentApplicationWindow?.Content is FrameworkElement rootElement
&& rootElement.RequestedTheme != ElementTheme.Default
? rootElement.RequestedTheme
: SettingsHelper.Get<ElementTheme>(SettingsHelper.SelectedAppTheme)
: UIHelper.AwaitByTaskCompleteSource(() =>
CurrentApplicationWindow?.Dispatcher?.AwaitableRunAsync(() =>
CurrentApplicationWindow?.Content is FrameworkElement _rootElement
&& _rootElement.RequestedTheme != ElementTheme.Default
? _rootElement.RequestedTheme
: SettingsHelper.Get<ElementTheme>(SettingsHelper.SelectedAppTheme),
CoreDispatcherPriority.High));
return CurrentApplicationWindow == null
? SettingsHelper.Get<ElementTheme>(SettingsHelper.SelectedAppTheme)
: CurrentApplicationWindow.Dispatcher.HasThreadAccess
? CurrentApplicationWindow.Content is FrameworkElement rootElement
&& rootElement.RequestedTheme != ElementTheme.Default
? rootElement.RequestedTheme
: SettingsHelper.Get<ElementTheme>(SettingsHelper.SelectedAppTheme)
: UIHelper.AwaitByTaskCompleteSource(() =>
CurrentApplicationWindow.Dispatcher.AwaitableRunAsync(() =>
CurrentApplicationWindow.Content is FrameworkElement _rootElement
&& _rootElement.RequestedTheme != ElementTheme.Default
? _rootElement.RequestedTheme
: SettingsHelper.Get<ElementTheme>(SettingsHelper.SelectedAppTheme),
CoreDispatcherPriority.High));
}
}

Expand All @@ -53,22 +55,24 @@ public static ElementTheme RootTheme
{
return CurrentApplicationWindow == null
? ElementTheme.Default
: CurrentApplicationWindow.Dispatcher.HasThreadAccess
: CurrentApplicationWindow.Dispatcher.HasThreadAccess
? CurrentApplicationWindow.Content is FrameworkElement rootElement
? rootElement.RequestedTheme
: ElementTheme.Default
: UIHelper.AwaitByTaskCompleteSource(() =>
CurrentApplicationWindow.Dispatcher.AwaitableRunAsync(() =>
CurrentApplicationWindow.Content is FrameworkElement _rootElement
? _rootElement.RequestedTheme
: ElementTheme.Default,
CoreDispatcherPriority.High));
: UIHelper.AwaitByTaskCompleteSource(() =>
CurrentApplicationWindow.Dispatcher.AwaitableRunAsync(() =>
CurrentApplicationWindow.Content is FrameworkElement _rootElement
? _rootElement.RequestedTheme
: ElementTheme.Default,
CoreDispatcherPriority.High));
}
set
{
_ = CurrentApplicationWindow?.Dispatcher?.AwaitableRunAsync(() =>
if (CurrentApplicationWindow == null) { return; }

_ = CurrentApplicationWindow.Dispatcher.AwaitableRunAsync(() =>
{
if (CurrentApplicationWindow?.Content is FrameworkElement rootElement)
if (CurrentApplicationWindow.Content is FrameworkElement rootElement)
{
rootElement.RequestedTheme = value;
}
Expand Down

0 comments on commit 2fd6514

Please sign in to comment.