From 666cdfa1187c9d76cc44e8806153548edfef8429 Mon Sep 17 00:00:00 2001 From: GHXX Date: Fri, 29 May 2026 09:02:18 +0200 Subject: [PATCH] cleanupAdd project files. --- McsrGraphImageDownloader.csproj | 15 +++++++++++++++ McsrGraphImageDownloader.sln | 25 +++++++++++++++++++++++++ Program.cs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 McsrGraphImageDownloader.csproj create mode 100644 McsrGraphImageDownloader.sln create mode 100644 Program.cs diff --git a/McsrGraphImageDownloader.csproj b/McsrGraphImageDownloader.csproj new file mode 100644 index 0000000..07adfbe --- /dev/null +++ b/McsrGraphImageDownloader.csproj @@ -0,0 +1,15 @@ + + + + Exe + net9.0 + enable + enable + true + true + + + + + + diff --git a/McsrGraphImageDownloader.sln b/McsrGraphImageDownloader.sln new file mode 100644 index 0000000..5d51f8d --- /dev/null +++ b/McsrGraphImageDownloader.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.37216.2 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McsrGraphImageDownloader", "McsrGraphImageDownloader.csproj", "{A8D4F4FE-B5EA-48CA-98D4-337C666053F4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A8D4F4FE-B5EA-48CA-98D4-337C666053F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8D4F4FE-B5EA-48CA-98D4-337C666053F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A8D4F4FE-B5EA-48CA-98D4-337C666053F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A8D4F4FE-B5EA-48CA-98D4-337C666053F4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A55629BA-B519-4788-B13B-55C88DD1B069} + EndGlobalSection +EndGlobal diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..5df1ab7 --- /dev/null +++ b/Program.cs @@ -0,0 +1,30 @@ +using Svg; +using System.Runtime.InteropServices; +using System.Text; +using System.Text.Json; + +namespace McsrGraphImageDownloader; + +internal class Program { + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); + public const int SPI_SETDESKWALLPAPER = 20; + public const int SPIF_UPDATEINIFILE = 1; + public const int SPIF_SENDCHANGE = 2; + private const string outputFilename = "mcsrChart.png"; + + private static async Task Main(string[] args) { + using var hc = new HttpClient(); + while (true) { + var svgJson = await hc.GetStringAsync("https://mcsr.ghxx.dev/api/chart"); + var svgText = JsonDocument.Parse(svgJson).RootElement.GetProperty("data").GetString(); + var svg = SvgDocument.Open(new MemoryStream(Encoding.UTF8.GetBytes(svgText!))); + using (var bitmap = svg.Draw(1920, 1080)) { + bitmap.Save(outputFilename); + } + SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, Path.GetFullPath(outputFilename), SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); + + await Task.Delay(TimeSpan.FromMinutes(15)); + } + } +}