[项目部]项目B组Leader(刘跃)- CeLeo ResourceManager v1.0项目完成

项目名: CeLeo ResourceManager

目前Version:1.0.0.0(基本功能已经完成,有待更新)

IDE:Visual Studio 2010

工具程序源码下载:

      ResourceFile源码下载

DLL类库程序源码下载:

      DLL源码下载

Helper文档在执行文件内体现。

 

顺便说下读取资源图片的DLL的代码,做这个DLL目的是为了生成的资源文件便于在其他项目中使用,其中用构造函数的参数接受资源文件路径,调用GetImage()方法可以获得资源文件里的Image[];在其中的GetImage方法中依旧用到了StreamReader和MemoryStream,可以参考查看资源文件窗体的代码,部分代码为:

 1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using System.IO;
5 using System.Drawing;
6 using System.Windows.Forms;
7
8 namespace LoadResourceFile
9 {
10 public class LoadImage
11 {
12
13 int count;
14 int[] c;
15 byte[][] img;
16 Image[] image;
17 MemoryStream ms;
18 string path;
19
20 public LoadImage(string p)
21 {
22 path = p;
23 }
24
25 public Image[] GetImage()
26 {
27 try
28 {
29 StreamReader sr = new StreamReader(path);
30 string temp = sr.ReadLine();
31 if (temp.IndexOf("(<--|") != -1 && temp.IndexOf("|-->)") != -1)
32 {
33 temp = temp.Replace("(<--|", "");
34 temp = temp.Replace("|-->)", "");
35 count = Convert.ToInt32(temp);
36 }
37 img = new byte[count][];
38 string[] t = new string[count];
39 c = new int[count];
40 for (int i = 0; i < count; i++)
41 {
42 t[i] = sr.ReadLine();
43 if (t[i].IndexOf("(<--|") != -1 && t[i].IndexOf("|-->)") != -1)
44 {
45 t[i] = t[i].Replace("(<--|", "");
46 t[i] = t[i].Replace("|-->)", "");
47 c[i] = Convert.ToInt32(t[i]);
48 }
49 img[i] = new byte[c[i]];
50 for (int j = 0; j < c[i]; j++)
51 {
52 img[i][j] = Convert.ToByte(sr.ReadLine());
53 }
54 }
55 sr.Close();
56 image = new Image[count];
57 for (int i = 0; i < count; i++)
58 {
59 ms = new MemoryStream(img[i], 0, c[i]);
60 image[i] = Image.FromStream(ms);
61 }
62 return image;
63 }
64 catch
65 {
66 MessageBox.Show("获取资源文件出错!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
67 return null;
68 }
69 }
70
71 }
72 }

 

 

 Demo片段如下:

 

ResourceFile 的version1.0.0.0已经完成,近期准备做五子棋游戏,计划1-3天内写出计算机落子算法,并利用空余时间优化改良ResourceFile,争取提升版本到Version1.5.0.0

posted on 2011-11-07 12:00  信息科学-腾讯校园之星协会联盟(ISA-TCS)  阅读(595)  评论(9编辑  收藏  举报