从高中到现在,XP系统用了快10年了吧,这次终于可以能升升级,稍微与潮流靠近一点了。
不过比较遗憾的是,第一次开始使用WIN7,居然是从日文版开始。
本来WIN7使用起来一点都不熟练,再加上是日文,看起来那种累,找个东西找半天,精神需要高度集中。
今天回到家里打开家里的XP,再进到服务器安装一些软件,居然一直在把这些软件也当日文的看了,还没回过神来!!!
哎,这种初体验真是,只好慢慢熟悉慢慢习惯吧!
从高中到现在,XP系统用了快10年了吧,这次终于可以能升升级,稍微与潮流靠近一点了。
不过比较遗憾的是,第一次开始使用WIN7,居然是从日文版开始。
本来WIN7使用起来一点都不熟练,再加上是日文,看起来那种累,找个东西找半天,精神需要高度集中。
今天回到家里打开家里的XP,再进到服务器安装一些软件,居然一直在把这些软件也当日文的看了,还没回过神来!!!
哎,这种初体验真是,只好慢慢熟悉慢慢习惯吧!
我怕,怕在每天晚上用餐。
我恨,恨在每天清晨醒来。
时间,让我们拥有得越来载多。
岁月,让我们明白得越来越透。
每一颗简简单单的心灵,
到头总要被吹散得七零八落。
也许我们的心胸愈加的宽阔,
可有天突然发觉却已再无法容下自我。
——《宽容》
我想这将是一首歌,一首尚未谱曲,尚未完整的歌。
第二章 wxWidgets的安装与编译
要顺利使用wxWidgets进行开发,首页必须做好wxWidgets的安装和编译工作。由于本人只在Windows平台进行开发,所以本章只对基于Windows平台的安装和编译方法进行展开描述。
2.1下载wxWidgets源码
首先,我们需要在wxWidgets官网下载源码,作为开源项目,它的源码并没有直接存在官网,在官网Downloads栏目下它每个版本提供了两个下载连接,一个来自SourceForge,一个来自英国一个FTP镜像。在本教程中,我们使用的是最新版本2.9.4版本,所以我们在直接找到2.9.4版的安装包(名为wxMSW-2.9.4-Setup.exe)并将其保存到本地。接下来只需要运行安装包,除了确认一[……]
《跟我学wxWidgets开发》系列教程
第一章 wxWidgets介绍
首先引用官方的原译文介绍:
wxWidgets是由Julian Smart于1992年在爱丁堡大学创建成立的。一开始它只是作为一个可创建Unix和Windows操作系统可移植的项目启动的,现在它发展到了Mac平台、WinCE和很多其它工具包和平台上。贡献给该项目的开发人员数量现在有几十人,并且这个工具包有一个很强大的用户群体,包括所有来自开源开发机构的人,比如说美国在线服务公司AOL。那么,与其他跨平台的图形用户界面(GUI)工具包比起来,wxWidgets究竟有什么特别的地方呢?
wxWidgets提供单一的、易用的API接口,供你在多种平台下,用其平台的原[……]
《跟我学wxWidgets开发》系列教程
前言
为了让更多喜欢开源库的后来者方便学习和使用wxWidgets,我将根据自己的从业经验,将全程以实际操作和相关例程的方式,由浅入深的在此出一套教程,希望能切切实实地帮到大家。
本套教程背景基于Windows平台的,程序部分全部采用C++,在阅读本教程之前,也许你需要掌握有C++的相关知识,当然,如果你是用的其他版本的wxWidgets,比如wxPython、wxRuby、wxPerl,你或许也可以从本教程中获得启发。
另外,如果大家在阅读过程中有什么意见和建议,欢迎提出来,本人非常乐意与大家一起交流。
目录:
[……]
1. 我是一个硬盘。
在一个普普通通的台式机里工作。别人总认为我们是高科技白领,工作又干净又体面,似乎风光得很。也许他们是因为看到洁白漂亮的机箱才有这样的错觉吧。其实象我们这样的小台式机,工作环境狭迫,里面的灰尘吓得死人。每天生活死水一潭,工作机械重复。跑跑文字处理看看电影还凑活,真要遇到什么大软件和游戏上上下下就要忙的团团转,最后还常常要死机。
我们这一行技术变化快,差不多每过两三年就要升级换代,所以人人都很有压力而且没有安全感。每个新板卡来的时候都神采飞扬踌躇满志,几年光阴一过,就变得[……]
在大环境的条件下,现在独立博客还真的有一点无处适从的感觉。 在国外么,虽然空间便宜一点,但是不是被屏蔽就是速度慢,而且连中文搜索引擎都不爬!! 在国内么,我就一个用来记东西的地方,备案这个东西对我来说太坑了么!! 我想香港正好处于两者交界地带吧,速度、备案问题都解决,至于搜索引擎,就随他去吧。 希望能满足一下我偶尔写写东西的需求就好了!^_^ 接下来一段时间里,我会推出一些关于wxWidgets的专辑,主要是原创和翻译,希望能帮助到需要该相关技术的朋友。 在这里先号召大家多多支持开源,少一些轮子,多一点大事,嘿嘿! 我想这样能更好的推动行业发展,提升大家的地位哦!
C#调用DLL库时,参数匹配是个麻烦事,这里找了个表格,方便查询。
好像有本书,名字叫《Beginning C# Objects From Concepts to Code》,有兴趣要以找来看看。
Wtypes.h中的非托管类型 | 非托管C语言类型 | 托管类名 | 说明 |
---|---|---|---|
HANDLE | void* | System.IntPtr | 32位 |
BYTE | unsignedchar | System.Byte | 8位 |
一个用来统计asp.net项目代码行数的小工具,很简单,应该不用解释了。
这东西以后会做在我的VS插件上面,现在暂时做成单独的小程序了,比较粗糙,将就着用吧,以后会升级的!
主要代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Threading; namespace form { public partial class Form1 : Form { int files_num = 0; int all_lines = 0; int rem_lines = 0; int space_lines = 0; int except_file_num = 0; string file_ext = ".txt|.cs|.aspx|.html|.htm"; Thread work; public Form1() { InitializeComponent(); //Control.CheckForIllegalCrossThreadCalls = false; } private void button2_Click(object sender, EventArgs e) { DialogResult result=this.folderBrowserDialog1.ShowDialog(); this.textBox3.Text = this.folderBrowserDialog1.SelectedPath; } private void button1_Click(object sender, EventArgs e) { files_num = 0; all_lines = 0; rem_lines = 0; space_lines = 0; except_file_num = 0; this.progressBar1.Value = 0; if (this.textBox3.Text == "") { MessageBox.Show("请先指定项目目录!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } work = new Thread(new ThreadStart(StartWork)); work.Start(); } private void StartWork() { MethodInvoker mi = new MethodInvoker(Thread_Proc); BeginInvoke(mi); } private void Thread_Proc() { //统计文件数 CountFiles(this.textBox3.Text); this.progressBar1.Minimum = 0; this.progressBar1.Maximum = files_num; CountLines(this.textBox3.Text); } private void CountFiles(string folderPath) { DirectoryInfo selected_dir = new DirectoryInfo(folderPath); if (!selected_dir.Exists) return; FileInfo[] files = selected_dir.GetFiles(); foreach (var item in files) { files_num++; } foreach (var item in selected_dir.GetDirectories()) { CountFiles(folderPath + "\\" + item.Name); } } private void CountLines(string folderPath) { DirectoryInfo selected_dir = new DirectoryInfo(folderPath); if (!selected_dir.Exists) return; FileInfo[] files = selected_dir.GetFiles(); foreach(var file in files) { try { SetLabelValue3(folderPath+"\\"+file.Name); //判断扩展名 string[] ext=file_ext.Split('|'); string cur_ext=file.Extension; bool find=false; foreach(var item in ext) { if (cur_ext == item) { find = true; break; } } if(!find) { except_file_num++; this.progressBar1.Value++; Thread.Sleep(100); continue; } string[] lines = File.ReadAllLines(folderPath+"\\"+file.Name); CountRems(lines); foreach (var item in lines) { string tmp_item = item.Trim(); if (tmp_item == "") { space_lines++; SetLabelValue4(space_lines.ToString()); } all_lines++; SetLabelValue1(all_lines.ToString()); } } catch (Exception ex) { //以防权限等错误,本版本忽略掉不能按行读取的文件 MessageBox.Show(ex.Message); } this.progressBar1.Value++; Thread.Sleep(100); } foreach (var item in selected_dir.GetDirectories()) { CountLines(folderPath+"\\"+item.Name); } SetLabelValue3("完成!存在" + except_file_num.ToString() + "个非源码文件!"); } void CountRems(string[] lines) { //寻找 "//" 注释行 foreach (var item in lines) { string tmp_item = item.Trim(); if (tmp_item.Length > 2 && tmp_item.Substring(0, 2) == "//") { rem_lines++; SetLabelValue2(rem_lines.ToString()); } } int rem_span = 0; bool findhead=false; //寻找 "/*……*/" 注释块 foreach (var item in lines) { string tmp_item = item.Trim(); if (tmp_item.Length > 2 && tmp_item.Substring(0, 2) == "/*") { findhead = true; } if (tmp_item.Length > 2 && tmp_item.Substring(0, 2) == "*/") { findhead = false; } if (findhead) { rem_span++; rem_lines++; } } } delegate void SetLabelCallback(Label lb,string text); delegate void SetTextCallback(string text); void SetLabelValue(Label lb, string text) { if (lb.InvokeRequired) { SetLabelCallback d = new SetLabelCallback(SetLabelValue); lb.Invoke(d, new object[] { text }); } else { lb.Text = text; } lb.Refresh(); Application.DoEvents(); } void SetLabelValue1(string text) { if (this.label5.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetLabelValue1); this.label5.Invoke(d, new object[] { text }); } else { this.label5.Text = text; } this.label5.Refresh(); Application.DoEvents(); } void SetLabelValue2(string text) { if (this.label6.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetLabelValue2); this.label6.Invoke(d, new object[] { text }); } else { this.label6.Text = text; } this.label6.Refresh(); Application.DoEvents(); } void SetLabelValue3(string text) { if (this.label7.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetLabelValue3); this.label7.Invoke(d, new object[] { text }); } else { this.label7.Text = text; } this.label7.Refresh(); Application.DoEvents(); } void SetLabelValue4(string text) { if (this.label9.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetLabelValue4); this.label9.Invoke(d, new object[] { text }); } else { this.label9.Text = text; } this.label9.Refresh(); Application.DoEvents(); } void DelegateSetValue(string text) { this.label5.Text = text; this.label6.Text = text; this.label7.Text = text; this.label9.Text = text; } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { this.linkLabel1.Links[0].LinkData = "http://www.cnzui.com"; System.Diagnostics.Process.Start(e.Link.LinkData.ToString()); } } } |