From 4e99b648ffef5efed2c761cd0bd3b9f19fce370e Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Mon, 7 Aug 2023 17:46:36 -0500 Subject: [PATCH] Disable Windows-specific code on other platforms --- LANCommander/LANCommander.csproj | 16 ++++++ .../Charts/NetworkDownloadRate.razor | 2 + .../Dashboard/Charts/NetworkUploadRate.razor | 2 + .../Charts/ProcessorUtilization.razor | 2 + LANCommander/Services/GameService.cs | 46 ++++++++++-------- LANCommander/favicon.png | Bin 0 -> 1800 bytes LANCommander/wwwroot/favicon.png | Bin 0 -> 1800 bytes 7 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 LANCommander/favicon.png create mode 100644 LANCommander/wwwroot/favicon.png diff --git a/LANCommander/LANCommander.csproj b/LANCommander/LANCommander.csproj index a19fcde..5e95cfd 100644 --- a/LANCommander/LANCommander.csproj +++ b/LANCommander/LANCommander.csproj @@ -10,6 +10,16 @@ + + WINDOWS + + + LINUX + + + MACOS + + @@ -64,6 +74,12 @@ + + + PreserveNewest + + + Never diff --git a/LANCommander/Pages/Dashboard/Charts/NetworkDownloadRate.razor b/LANCommander/Pages/Dashboard/Charts/NetworkDownloadRate.razor index 310c10c..488e315 100644 --- a/LANCommander/Pages/Dashboard/Charts/NetworkDownloadRate.razor +++ b/LANCommander/Pages/Dashboard/Charts/NetworkDownloadRate.razor @@ -65,6 +65,7 @@ private async Task RefreshData() { + #if WINDOWS var category = new PerformanceCounterCategory("Network Interface"); 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); } catch { } + #endif } } diff --git a/LANCommander/Pages/Dashboard/Charts/NetworkUploadRate.razor b/LANCommander/Pages/Dashboard/Charts/NetworkUploadRate.razor index 7fcf5d2..55498a2 100644 --- a/LANCommander/Pages/Dashboard/Charts/NetworkUploadRate.razor +++ b/LANCommander/Pages/Dashboard/Charts/NetworkUploadRate.razor @@ -65,6 +65,7 @@ private async Task RefreshData() { + #if WINDOWS var category = new PerformanceCounterCategory("Network Interface"); 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); } catch { } + #endif } } diff --git a/LANCommander/Pages/Dashboard/Charts/ProcessorUtilization.razor b/LANCommander/Pages/Dashboard/Charts/ProcessorUtilization.razor index 927fb32..774bdfd 100644 --- a/LANCommander/Pages/Dashboard/Charts/ProcessorUtilization.razor +++ b/LANCommander/Pages/Dashboard/Charts/ProcessorUtilization.razor @@ -68,6 +68,7 @@ private async Task RefreshData() { + #if WINDOWS Data = Data.ShiftArrayAndInsert((double)Math.Ceiling(PerformanceCounter.NextValue()), TimerHistory); try @@ -75,5 +76,6 @@ await Chart.ChangeData(Data.Select((x, i) => new { value = x, index = i }), true); } catch { } + #endif } } diff --git a/LANCommander/Services/GameService.cs b/LANCommander/Services/GameService.cs index 32118bb..0f4b3f8 100644 --- a/LANCommander/Services/GameService.cs +++ b/LANCommander/Services/GameService.cs @@ -120,6 +120,7 @@ namespace LANCommander.Services return File.ReadAllBytes(cachedPath); else { + #if WINDOWS if (game.Archives == null || game.Archives.Count == 0) throw new FileNotFoundException(); @@ -127,31 +128,38 @@ namespace LANCommander.Services Bitmap bitmap = null; - var iconReference = ArchiveService.ReadFile(archive.ObjectKey, game.Icon); - - if (IsWinPEFile(iconReference)) + try { - var tmp = System.IO.Path.GetTempFileName(); + var iconReference = ArchiveService.ReadFile(archive.ObjectKey, game.Icon); - System.IO.File.WriteAllBytes(tmp, iconReference); - - var icon = System.Drawing.Icon.ExtractAssociatedIcon(tmp); - - bitmap = icon.ToBitmap(); - } - else - { - using (var ms = new MemoryStream(iconReference)) + if (IsWinPEFile(iconReference)) { - bitmap = (Bitmap)Bitmap.FromStream(ms); + var tmp = System.IO.Path.GetTempFileName(); + + System.IO.File.WriteAllBytes(tmp, iconReference); + + var icon = System.Drawing.Icon.ExtractAssociatedIcon(tmp); + + bitmap = icon.ToBitmap(); } + else + { + using (var ms = new MemoryStream(iconReference)) + { + bitmap = (Bitmap)Bitmap.FromStream(ms); + } + } + + var iconPng = ConvertToPng(bitmap); + + File.WriteAllBytes(cachedPath, iconPng); + + return iconPng; } + catch (Exception ex) { } + #endif - var iconPng = ConvertToPng(bitmap); - - File.WriteAllBytes(cachedPath, iconPng); - - return iconPng; + return File.ReadAllBytes("favicon.png"); } } diff --git a/LANCommander/favicon.png b/LANCommander/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..9456ec022a96c36185a3c0e6e319a054f59f4575 GIT binary patch literal 1800 zcmV+j2lx1iP)!bwCyRCwC$oJ(v}RT#(rbEiXJNGY_%2M8kNQGwz!8e$AFnix%t?v05n6Jw%r zVd6q}zBVj;MHjA2Omx9Y#Q+I0#E<}`mXX=@zb!D8wq@Yqp0EJoWx7AUFHC;(gG0ZdQ>pWOgV<5MBYkS z0S2=l%kBi5G?h<*O7e~hS<`*l1C{_u>@3`x-~a@mus)k^-BRrz$Si~ab`w}FQUg2; zW1xWVE6XBkMD)#k#s{d*G&>I|{EBn3g$EYULkZA;bs`qO!DlEd@cZzwi2XPr=yMWZ zhR!dm2r!8bN&vxG;2gx}aMQv*`)coHuT&$AA-qzMU+MzDc|9%x1GtepiSGop z?FmSR&MX9&;y4%lUg8DN77GejB(62*=3`UJaS4CeE<7-jjt27t*r+lFyocABX|2T|zz~Lm zr*WO&HWmB4v3|Z_D+ak79*yG!P?`nuVuWh*08R9SPon}P)n)-nPFhjS13JQ|Q30yd z1mLX;SJ^H+uz=3+h3J>^pg?FRhEMS`qaRq64a64A40(reRA4H<21Er=+!JsHXVeS? zXhJt?nW;V|g#&9C%I}Gz0x0eYXvStn4M<@OCxvVs#6dM@qO{~+hzg(>3i$-DG1J=Y zZ#_Sie<9ilDsGJ9jrB@#JUv9(XTAX2Ly<=bRObQGk^aKy%fFB>z;4wwtLi*}H;npu z|Ano0;3k!8ms;`p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