From 2c16ade92f056feb3de8b80c774bf4149b557d6f Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Tue, 31 Aug 2021 20:01:02 +0200 Subject: [PATCH] Revert "Revert [Feature] Update to .NET 5 (#157), version 1.0.18.0" --- Config/Config.cs | 41 ++++++++-------------------- SystemTrayMenu.csproj | 62 ++++++++++++++++++++++++++++++------------- UserInterface/Menu.cs | 1 + 3 files changed, 55 insertions(+), 49 deletions(-) diff --git a/Config/Config.cs b/Config/Config.cs index 2584da5..680b9de 100644 --- a/Config/Config.cs +++ b/Config/Config.cs @@ -12,7 +12,7 @@ namespace SystemTrayMenu using System.Text; using System.Windows.Forms; using Microsoft.Win32; - using SkiaSharp; + using Svg; using SystemTrayMenu.Properties; using SystemTrayMenu.UserInterface.FolderBrowseDialog; using SystemTrayMenu.Utilities; @@ -259,12 +259,12 @@ namespace SystemTrayMenu htmlColorCodeIcons = Settings.Default.ColorIcons; } - AppColors.BitmapOpenFolder = ReadSvg(Properties.Resources.ic_fluent_folder_arrow_right_48_regular, htmlColorCodeIcons, 20); - AppColors.BitmapPin = ReadSvg(Properties.Resources.ic_fluent_pin_48_regular, htmlColorCodeIcons, 20); - AppColors.BitmapPinActive = ReadSvg(Properties.Resources.ic_fluent_pin_48_filled, htmlColorCodeIcons, 20); - AppColors.BitmapSearch = ReadSvg(Properties.Resources.ic_fluent_search_48_regular, htmlColorCodeIcons, 20); - AppColors.BitmapFoldersCount = ReadSvg(Properties.Resources.ic_fluent_folder_48_regular, htmlColorCodeIcons, 18); - AppColors.BitmapFilesCount = ReadSvg(Properties.Resources.ic_fluent_document_48_regular, htmlColorCodeIcons, 18); + AppColors.BitmapOpenFolder = ReadSvg(Properties.Resources.ic_fluent_folder_arrow_right_48_regular, htmlColorCodeIcons); + AppColors.BitmapPin = ReadSvg(Properties.Resources.ic_fluent_pin_48_regular, htmlColorCodeIcons); + AppColors.BitmapPinActive = ReadSvg(Properties.Resources.ic_fluent_pin_48_filled, htmlColorCodeIcons); + AppColors.BitmapSearch = ReadSvg(Properties.Resources.ic_fluent_search_48_regular, htmlColorCodeIcons); + AppColors.BitmapFoldersCount = ReadSvg(Properties.Resources.ic_fluent_folder_48_regular, htmlColorCodeIcons); + AppColors.BitmapFilesCount = ReadSvg(Properties.Resources.ic_fluent_document_48_regular, htmlColorCodeIcons); colorAndCode.HtmlColorCode = Settings.Default.ColorSearchField; colorAndCode.Color = Color.FromArgb(255, 255, 255); @@ -428,36 +428,17 @@ namespace SystemTrayMenu } } - private static Bitmap ReadSvg(byte[] byteArray, string htmlColorCode, int size = 18) + private static Bitmap ReadSvg(byte[] byteArray, string htmlColorCode) { - int factorToMakeSharper = 2; - size = (int)(size * factorToMakeSharper * Scaling.Factor); string str = Encoding.UTF8.GetString(byteArray); str = str.Replace("#585858", htmlColorCode); byteArray = Encoding.UTF8.GetBytes(str); using (var stream = new MemoryStream(byteArray)) { - var bitmap = new SKBitmap(size, size); - var canvas = new SKCanvas(bitmap); - canvas.Clear(SKColors.Transparent); - - // load the SVG - var svg = new SkiaSharp.Extended.Svg.SKSvg(new SKSize(size, size)); - svg.Load(stream); - - // draw the SVG to the bitmap - canvas.DrawPicture(svg.Picture); - SKImage sKImage = SKImage.FromBitmap(bitmap); - - SKData skData = sKImage.Encode(SKEncodedImageFormat.Png, 100); - - using (var ms = new MemoryStream()) - { - skData.SaveTo(ms); - ms.Position = 0; - return new Bitmap(ms); - } + var svgDocument = SvgDocument.Open(stream); + svgDocument.Color = new SvgColourServer(Color.Black); + return svgDocument.Draw(); } } diff --git a/SystemTrayMenu.csproj b/SystemTrayMenu.csproj index 0756644..68fa80e 100644 --- a/SystemTrayMenu.csproj +++ b/SystemTrayMenu.csproj @@ -1,16 +1,28 @@ - - + - WinExe netcoreapp3.1 win-x64 true x64 + WinExe + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + true + true false x64;x86;AnyCPU Debug;Release;ReleasePackage - SystemTrayMenu - SystemTrayMenu SystemTrayMenu.Program @@ -121,47 +133,47 @@ True True - + lang.it-IT.resx True True - + lang.nl-NL.resx True True - + lang.pt-BR.resx True True - + lang.cs-CZ.resx True True - + lang.zh-CN.resx True True - + lang.ja-JP.resx True True - + lang.ko-KR.resx True True - + lang.ru-RU.resx True True - + lang.vi-VN.resx True True @@ -195,19 +207,19 @@ ResXFileCodeGenerator lang.es-ES.Designer.cs - + ResXFileCodeGenerator lang.it-IT.Designer.cs - + ResXFileCodeGenerator lang.nl-NL.Designer.cs - + ResXFileCodeGenerator lang.pt-BR.Designer.cs - + ResXFileCodeGenerator lang.cs-CZ.Designer.cs @@ -248,16 +260,28 @@ True + + + False + Microsoft .NET Framework 4.7.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + all runtime; build; native; contentfiles; analyzers; buildtransitive - all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index ba5ee27..5b3f879 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -11,6 +11,7 @@ namespace SystemTrayMenu.UserInterface using System.IO; using System.Reflection; using System.Windows.Forms; + using Svg; using SystemTrayMenu.DataClasses; using SystemTrayMenu.DllImports; using SystemTrayMenu.Helpers;