ab56a9bcf7
SVN-Revision: r240
132 lines
3.9 KiB
C#
132 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using Lskj.Main.Properties;
|
|
using Lskj.Util;
|
|
|
|
namespace Lskj.Main.Model
|
|
{
|
|
/// <summary>
|
|
/// 资源图片管理类
|
|
/// </summary>
|
|
public static class BitMapHelper
|
|
{
|
|
#region 本地资源文件
|
|
/// <summary>
|
|
/// 获取本地资源文件
|
|
/// </summary>
|
|
/// <param name="mapEnum"></param>
|
|
/// <returns></returns>
|
|
public static Bitmap getBitmap(BitMapEnum mapEnum)
|
|
{
|
|
Bitmap bitmap = null;
|
|
try
|
|
{
|
|
FileStream fs = File.OpenRead(getBitMapPath(mapEnum)); //OpenRead
|
|
|
|
int filelength = (int)fs.Length; //获得文件长度
|
|
Byte[] image = new Byte[filelength]; //建立一个字节数组
|
|
fs.Read(image, 0, filelength); //按字节流读取
|
|
Image result = Image.FromStream(fs);
|
|
fs.Close();
|
|
|
|
bitmap = new Bitmap(result);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
switch (mapEnum)
|
|
{
|
|
case BitMapEnum.loginbg:
|
|
bitmap = Resources.newlogin;
|
|
break;
|
|
case BitMapEnum.submenubg:
|
|
bitmap = Resources.sub_backgroud;
|
|
break;
|
|
case BitMapEnum.submenubg_tip:
|
|
bitmap = Resources.sub_tip_backgound;
|
|
break;
|
|
case BitMapEnum.logobg:
|
|
bitmap = Resources.logo;
|
|
break;
|
|
case BitMapEnum.logo2bg:
|
|
bitmap = Resources.logo;
|
|
break;
|
|
}
|
|
}
|
|
return bitmap;
|
|
}
|
|
/// <summary>
|
|
/// 获取文件路径
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private static string getBitMapPath(BitMapEnum mapEnum)
|
|
{
|
|
string bitmapPath = string.Empty;
|
|
switch (mapEnum)
|
|
{
|
|
case BitMapEnum.loginbg:
|
|
bitmapPath = BitMapType.Loginbg;
|
|
break;
|
|
case BitMapEnum.submenubg:
|
|
bitmapPath = BitMapType.Submenubg;
|
|
break;
|
|
case BitMapEnum.submenubg_tip:
|
|
bitmapPath = BitMapType.Submenubg_tip;
|
|
break;
|
|
case BitMapEnum.logobg:
|
|
bitmapPath = BitMapType.Logobg;
|
|
break;
|
|
case BitMapEnum.logo2bg:
|
|
bitmapPath = BitMapType.Logo2bg;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return PubUtil.BitMapPath + bitmapPath;
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// 图片存放地址
|
|
/// </summary>
|
|
public static class BitMapType
|
|
{
|
|
/// <summary>
|
|
/// 登录背景图
|
|
/// </summary>
|
|
public static string Loginbg = @"Login\newlogin.png";
|
|
/// <summary>
|
|
/// 子系统背景图
|
|
/// </summary>
|
|
public static string Submenubg = @"Submenu\submenu.png";
|
|
/// <summary>
|
|
/// 子系统背景图提示
|
|
/// </summary>
|
|
public static string Submenubg_tip = @"Submenu\submenu_tip.png";
|
|
/// <summary>
|
|
/// logo背景图
|
|
/// </summary>
|
|
public static string Logobg = @"Main\logo.png";
|
|
/// <summary>
|
|
/// logo2背景图
|
|
/// </summary>
|
|
public static string Logo2bg = @"Main2\logo.png";
|
|
}
|
|
/// <summary>
|
|
/// 图片类型
|
|
/// </summary>
|
|
public enum BitMapEnum
|
|
{
|
|
loginbg,
|
|
submenubg,
|
|
submenubg_tip,
|
|
logobg,
|
|
logo2bg
|
|
}
|
|
}
|