Skip to content

Commit

Permalink
Prevent crashing in full screen mode - part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye116477 committed Dec 15, 2024
1 parent 2cbe78d commit 20f5177
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/NileUpdaterView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CommonPlugin;
using CommonPlugin.Enums;
using NileLibraryNS.Models;
using Playnite.SDK;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
Expand All @@ -13,11 +14,13 @@ namespace NileLibraryNS
/// </summary>
public partial class NileUpdaterView : UserControl
{
private IPlayniteAPI playniteAPI = API.Instance;
public Dictionary<string, UpdateInfo> UpdatesList => (Dictionary<string, UpdateInfo>)DataContext;

public NileUpdaterView()
{
InitializeComponent();
SetControlStyles();
}

private void UpdatesLB_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down Expand Up @@ -48,6 +51,22 @@ private void SelectAllBtn_Click(object sender, RoutedEventArgs e)
}
}

private void SetControlStyles()
{
var baseStyleName = "BaseTextBlockStyle";
if (playniteAPI.ApplicationInfo.Mode == ApplicationMode.Fullscreen)
{
baseStyleName = "TextBlockBaseStyle";
Resources.Add(typeof(Button), new Style(typeof(Button), null));
}

if (ResourceProvider.GetResource(baseStyleName) is Style baseStyle && baseStyle.TargetType == typeof(TextBlock))
{
var implicitStyle = new Style(typeof(TextBlock), baseStyle);
Resources.Add(typeof(TextBlock), implicitStyle);
}
}

private async void UpdateBtn_Click(object sender, RoutedEventArgs e)
{
if (UpdatesLB.SelectedItems.Count > 0)
Expand Down

0 comments on commit 20f5177

Please sign in to comment.