2017-09-27 22:32:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
namespace ShiftOS.Engine.Misc
|
2017-09-27 22:32:16 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-11-05 23:47:46 +00:00
|
|
|
|
/// Random class full of unassorted [but also uncategorizable] tools.
|
2017-09-27 22:32:16 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
public static class Tools
|
|
|
|
|
{
|
|
|
|
|
public static Random Rnd = new Random();
|
|
|
|
|
|
|
|
|
|
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
2017-11-05 23:47:46 +00:00
|
|
|
|
public static extern bool DestroyIcon(IntPtr handle);
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
|
|
|
|
public static Icon ToIcon(this Bitmap bm)
|
|
|
|
|
{
|
2017-11-05 23:47:46 +00:00
|
|
|
|
var tempicon = Icon.FromHandle(bm.GetHicon());
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
2017-11-05 23:47:46 +00:00
|
|
|
|
var newIcon = tempicon.Clone() as Icon;
|
2017-09-27 22:32:16 +00:00
|
|
|
|
|
|
|
|
|
//for some reason this exists
|
|
|
|
|
DestroyIcon(tempicon.Handle);
|
|
|
|
|
|
|
|
|
|
return newIcon;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-05 23:47:46 +00:00
|
|
|
|
}
|