2013-02-18 10:59:43 +03:00
|
|
|
using System.Drawing;
|
|
|
|
using System.IO;
|
|
|
|
|
2013-05-20 02:17:32 +03:00
|
|
|
namespace NzbDrone.Core.Notifications.Xbmc
|
2011-07-09 21:19:33 +03:00
|
|
|
{
|
|
|
|
public class ResourceManager
|
|
|
|
{
|
2013-02-18 10:59:43 +03:00
|
|
|
public static Icon GetIcon(string Name)
|
2011-07-09 21:19:33 +03:00
|
|
|
{
|
2013-02-18 10:59:43 +03:00
|
|
|
Stream stm = typeof(ResourceManager).Assembly.GetManifestResourceStream(string.Format("NzbDrone.Core.{0}.ico", Name));
|
2011-07-09 21:19:33 +03:00
|
|
|
if (stm == null) return null;
|
2013-02-18 10:59:43 +03:00
|
|
|
return new Icon(stm);
|
2011-07-09 21:19:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public static byte[] GetRawData(string Name)
|
|
|
|
{
|
|
|
|
byte[] data;
|
2013-02-18 10:59:43 +03:00
|
|
|
using (Stream stm = typeof(ResourceManager).Assembly.GetManifestResourceStream(string.Format("NzbDrone.Core.{0}.ico", Name)))
|
2011-07-09 21:19:33 +03:00
|
|
|
{
|
|
|
|
if (stm == null) return null;
|
|
|
|
data = new byte[stm.Length];
|
|
|
|
stm.Read(data, 0, data.Length);
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static byte[] GetRawLogo(string Name)
|
|
|
|
{
|
|
|
|
byte[] data;
|
2013-02-18 10:59:43 +03:00
|
|
|
using (Stream stm = typeof(ResourceManager).Assembly.GetManifestResourceStream(string.Format("NzbDrone.Core.{0}", Name)))
|
2011-07-09 21:19:33 +03:00
|
|
|
{
|
|
|
|
if (stm == null) return null;
|
|
|
|
data = new byte[stm.Length];
|
|
|
|
stm.Read(data, 0, data.Length);
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2013-02-18 10:59:43 +03:00
|
|
|
public static Bitmap GetIconAsImage(string Name)
|
2011-07-09 21:19:33 +03:00
|
|
|
{
|
2013-02-18 10:59:43 +03:00
|
|
|
Stream stm = typeof(ResourceManager).Assembly.GetManifestResourceStream(string.Format("NzbDrone.Core.{0}.ico", Name));
|
2011-07-09 21:19:33 +03:00
|
|
|
if (stm == null) return null;
|
2013-02-18 10:59:43 +03:00
|
|
|
Bitmap bmp;
|
|
|
|
using (Icon ico = new Icon(stm))
|
2011-07-09 21:19:33 +03:00
|
|
|
{
|
2013-02-18 10:59:43 +03:00
|
|
|
bmp = new Bitmap(ico.Width, ico.Height);
|
|
|
|
using (Graphics g = Graphics.FromImage(bmp))
|
2011-07-09 21:19:33 +03:00
|
|
|
{
|
|
|
|
g.DrawIcon(ico, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|