[项目部]项目B组Leader(刘跃)- CeLeo ResourceManager v1.0项目完成
项目名: CeLeo ResourceManager
目前Version:1.0.0.0(基本功能已经完成,有待更新)
IDE:Visual Studio 2010
工具程序源码下载:
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
分类:
项目开发部(PD72)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架