From a25baf08203237fc2eeeb4b7ca720f7d47f8a666 Mon Sep 17 00:00:00 2001 From: John T Date: Wed, 27 Sep 2017 18:32:16 -0400 Subject: added desktop and some small additions and changes to shiftwm --- ShiftOS.Engine/Tools.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ShiftOS.Engine/Tools.cs (limited to 'ShiftOS.Engine/Tools.cs') diff --git a/ShiftOS.Engine/Tools.cs b/ShiftOS.Engine/Tools.cs new file mode 100644 index 0000000..eca7b59 --- /dev/null +++ b/ShiftOS.Engine/Tools.cs @@ -0,0 +1,32 @@ +using System; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Runtime.InteropServices; +using ImageMagick; + +namespace ShiftOS.Engine +{ + /// + /// Random class full of unassorted [but also uncategorizable] tools. + /// + public static class Tools + { + public static Random Rnd = new Random(); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public extern static bool DestroyIcon(IntPtr handle); + + public static Icon ToIcon(this Bitmap bm) + { + Icon tempicon = Icon.FromHandle(bm.GetHicon()); + + Icon newIcon = tempicon.Clone() as Icon; + + //for some reason this exists + DestroyIcon(tempicon.Handle); + + return newIcon; + } + } +} -- cgit v1.2.3