-
-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show a bar alert when Xe graphics are detected
Relates to: #606
- Loading branch information
Showing
8 changed files
with
140 additions
and
2 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
21 changes: 21 additions & 0 deletions
21
src/SyncTrayzor/Pages/BarAlerts/IntelXeGraphicsAlertView.xaml
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,21 @@ | ||
<UserControl x:Class="SyncTrayzor.Pages.BarAlerts.IntelXeGraphicsAlertView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:s="https://github.com/canton7/Stylet" | ||
xmlns:l="clr-namespace:SyncTrayzor.Localization" | ||
xmlns:local="clr-namespace:SyncTrayzor.Pages.BarAlerts" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800" | ||
d:DataContext="{d:DesignInstance local:IntelXeGraphicsAlertViewModel}"> | ||
<StackPanel> | ||
<TextBlock TextWrapping="Wrap" | ||
Text="{l:Loc BarAlertsView_IntelXeGraphics_AlertText}"/> | ||
<TextBlock> | ||
<Hyperlink Command="{s:Action Dismiss}"> | ||
<TextBlock Text="{l:Loc BarAlertsView_IntelXeGraphics_DismissLink}"/> | ||
</Hyperlink> | ||
</TextBlock> | ||
</StackPanel> | ||
</UserControl> |
22 changes: 22 additions & 0 deletions
22
src/SyncTrayzor/Pages/BarAlerts/IntelXeGraphicsAlertViewModel.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,22 @@ | ||
using Stylet; | ||
using SyncTrayzor.Services.Config; | ||
|
||
namespace SyncTrayzor.Pages.BarAlerts | ||
{ | ||
public class IntelXeGraphicsAlertViewModel : Screen, IBarAlert | ||
{ | ||
private readonly IConfigurationProvider configurationProvider; | ||
|
||
public AlertSeverity Severity => AlertSeverity.Info; | ||
|
||
public IntelXeGraphicsAlertViewModel(IConfigurationProvider configurationProvider) | ||
{ | ||
this.configurationProvider = configurationProvider; | ||
} | ||
|
||
public void Dismiss() | ||
{ | ||
this.configurationProvider.AtomicLoadAndSave(config => config.HideIntelXeWarningMessage = true); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using NLog; | ||
using System; | ||
using System.Management; | ||
|
||
namespace SyncTrayzor.Services | ||
{ | ||
public class GraphicsCardDetector | ||
{ | ||
private static readonly Logger logger = LogManager.GetCurrentClassLogger(); | ||
|
||
private bool? _isIntelXe; | ||
public bool IsIntelXe | ||
{ | ||
get | ||
{ | ||
if (this._isIntelXe == null) | ||
this._isIntelXe = GetIsIntelXe(); | ||
return this._isIntelXe.Value; | ||
} | ||
} | ||
|
||
private static bool GetIsIntelXe() | ||
{ | ||
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController"); | ||
foreach (ManagementObject obj in searcher.Get()) | ||
{ | ||
if (obj["CurrentBitsPerPixel"] != null && obj["CurrentHorizontalResolution"] != null) | ||
{ | ||
string name = obj["Name"]?.ToString(); | ||
if (name.IndexOf("Intel", StringComparison.OrdinalIgnoreCase) >= 0 && | ||
name.IndexOf(" Xe ", StringComparison.OrdinalIgnoreCase) >= 0) | ||
{ | ||
logger.Info($"Graphics card: {name}"); | ||
return true; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
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