Disable Windows-specific code on other platforms

This commit is contained in:
Pat Hartl 2023-08-07 17:46:36 -05:00
parent 2106ca6a1d
commit 4e99b648ff
7 changed files with 49 additions and 19 deletions

View file

@ -10,6 +10,16 @@
<Content Remove="wwwroot\js\Upload.ts" /> <Content Remove="wwwroot\js\Upload.ts" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))">
<DefineConstants>WINDOWS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))">
<DefineConstants>LINUX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))">
<DefineConstants>MACOS</DefineConstants>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AntDesign" Version="0.15.4" /> <PackageReference Include="AntDesign" Version="0.15.4" />
<PackageReference Include="AntDesign.Charts" Version="0.3.1" /> <PackageReference Include="AntDesign.Charts" Version="0.3.1" />
@ -64,6 +74,12 @@
<TypeScriptCompile Include="wwwroot\js\Upload.ts" /> <TypeScriptCompile Include="wwwroot\js\Upload.ts" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="favicon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<TypeScriptCompile Update="wwwroot\js\Upload.ts"> <TypeScriptCompile Update="wwwroot\js\Upload.ts">
<CopyToOutputDirectory>Never</CopyToOutputDirectory> <CopyToOutputDirectory>Never</CopyToOutputDirectory>

View file

@ -65,6 +65,7 @@
private async Task RefreshData() private async Task RefreshData()
{ {
#if WINDOWS
var category = new PerformanceCounterCategory("Network Interface"); var category = new PerformanceCounterCategory("Network Interface");
foreach (var instance in category.GetInstanceNames()) foreach (var instance in category.GetInstanceNames())
@ -83,5 +84,6 @@
await Chart.ChangeData(Data.SelectMany(x => x.Value.Select((y, i) => new { value = y, index = i, series = x.Key })), true); await Chart.ChangeData(Data.SelectMany(x => x.Value.Select((y, i) => new { value = y, index = i, series = x.Key })), true);
} }
catch { } catch { }
#endif
} }
} }

View file

@ -65,6 +65,7 @@
private async Task RefreshData() private async Task RefreshData()
{ {
#if WINDOWS
var category = new PerformanceCounterCategory("Network Interface"); var category = new PerformanceCounterCategory("Network Interface");
foreach (var instance in category.GetInstanceNames()) foreach (var instance in category.GetInstanceNames())
@ -83,5 +84,6 @@
await Chart.ChangeData(Data.SelectMany(x => x.Value.Select((y, i) => new { value = y, index = i, series = x.Key })), true); await Chart.ChangeData(Data.SelectMany(x => x.Value.Select((y, i) => new { value = y, index = i, series = x.Key })), true);
} }
catch { } catch { }
#endif
} }
} }

View file

@ -68,6 +68,7 @@
private async Task RefreshData() private async Task RefreshData()
{ {
#if WINDOWS
Data = Data.ShiftArrayAndInsert((double)Math.Ceiling(PerformanceCounter.NextValue()), TimerHistory); Data = Data.ShiftArrayAndInsert((double)Math.Ceiling(PerformanceCounter.NextValue()), TimerHistory);
try try
@ -75,5 +76,6 @@
await Chart.ChangeData(Data.Select((x, i) => new { value = x, index = i }), true); await Chart.ChangeData(Data.Select((x, i) => new { value = x, index = i }), true);
} }
catch { } catch { }
#endif
} }
} }

View file

@ -120,6 +120,7 @@ namespace LANCommander.Services
return File.ReadAllBytes(cachedPath); return File.ReadAllBytes(cachedPath);
else else
{ {
#if WINDOWS
if (game.Archives == null || game.Archives.Count == 0) if (game.Archives == null || game.Archives.Count == 0)
throw new FileNotFoundException(); throw new FileNotFoundException();
@ -127,6 +128,8 @@ namespace LANCommander.Services
Bitmap bitmap = null; Bitmap bitmap = null;
try
{
var iconReference = ArchiveService.ReadFile(archive.ObjectKey, game.Icon); var iconReference = ArchiveService.ReadFile(archive.ObjectKey, game.Icon);
if (IsWinPEFile(iconReference)) if (IsWinPEFile(iconReference))
@ -153,6 +156,11 @@ namespace LANCommander.Services
return iconPng; return iconPng;
} }
catch (Exception ex) { }
#endif
return File.ReadAllBytes("favicon.png");
}
} }
private static bool IsWinPEFile(byte[] file) private static bool IsWinPEFile(byte[] file)

BIN
LANCommander/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB