摘要: 配置既然选择了TCP协议,那么从WP7手机连接到TCP服务器,必须要知道服务器的IP和端口。为了方便服务器端口使用固定的8012端口。那么WP7至少需要在手机上存储IP地址字符串。Windows Phone 本地数据存储Windows Phone 应用程序可以使用独立存储将数据储存到手机本地。应用程序可以通过三种方式储存数据:设置:使用 IsolatedStorageSettings 类将数据存储为键/值对。文件和文件夹:使用 IsolatedStorageFile 类存储文件和文件夹。本地数据库:7.1新增,只能支持LINQ TO SQL ,不能写SQL语句。本地存储IP数据因为我只需要存储 阅读全文
posted @ 2012-01-26 11:18 kiminozo 阅读(906) 评论(0) 推荐(0) 编辑
摘要: TCP服务器服务器类图这里模仿了WebFrom的IHttpHandler,我设计了一个ITcpHandler提供给ServiceListener让外部解析。实现类是KeyMethodHandler。报文TcpContext包含了TcpRequest和TcpResponse,TcpRequest和消息报文结构相同,增加了从Socket获取的TcpEndpoint,TcpResponse仅仅只是回调状态和消息(暂时没有使用)。ServiceListener、BufferManager、SocketAsyncEventArgsPool和MDSN上标准的例子接近,原则上都是为了重用Buffer和Soc 阅读全文
posted @ 2012-01-25 16:12 kiminozo 阅读(1234) 评论(2) 推荐(0) 编辑
摘要: WP7支持的通信方式1. HTTP协议主要是由WebClient或HttpWebRequest两个类提供,直接封装HTTP协议访问Web站点。最常用的通信方式。2. WCFWCF作为MS大力推广的通信方案非常强大,但是到了WP7上就变成了太监,只支持简单的BasicHttpBinding而且还有非常多的限制。3 Socket7.1SDK里新增的通信方式,支持TCP和UDP但只能使用异步的SocketAsyncEventArgs事件方式,也有不少限制。选择通信方式因为同时需要考虑到服务器端的实现,在服务器端尽量精简,最好不要有什么IIS之类大型依赖。对应是服务器端实现方式如下:HTTP协议Htt 阅读全文
posted @ 2012-01-25 15:21 kiminozo 阅读(1586) 评论(1) 推荐(0) 编辑
摘要: 控件功能分析圆形控件 能识别顺时针、逆时针滑动的手势,并能识别滑动速度。系统提供的相关事件OnManipulationStarted滑动开始手按下OnManipulationDelta滑动中手按住并移动OnManipulationCompleted滑动完成手放开这3个事件是实现滑动的必要事件,因为EventArgs提供了手的XY坐标已经移动速度,不过遗憾要识别顺时针需要自己实现。识别顺时针滑动识别了顺时针,反之就能识别逆时针,但如何识别顺时针滑动呢,其实这个问题困扰了我不少时间,首先看看默认的坐标轴结构图:用红色刷子表示手势,貌似没有找到突破口,光从X和Y的变化没有什么参考的地方。必须要换一下 阅读全文
posted @ 2012-01-25 14:38 kiminozo 阅读(1932) 评论(1) 推荐(2) 编辑
摘要: 界面设计回顾一下按钮清单:播放控制播放/暂停Space停止F4快进Right快退Left快进X2Control+Right快退X2Control+Left快进X3Alt+Right快退X3Alt+Left音量放大Up缩小Down静音M节目下一个PageDown上一个PageUp基本上就是把这些按钮布置到480*800的屏幕上。快进按钮设计不过有个地方有点不舒服,就是快进、快退居然有3套,而且功能相似只是速度不同,如果像这样摆放6个按钮一定很不爽。之前再说点题外话,就是为什么没有用拖动进度条的方式。因为实现起来比较麻烦,需要API或者Windows消息。加上现在播放器大部分有断点续播,我不能设计 阅读全文
posted @ 2012-01-25 13:55 kiminozo 阅读(1676) 评论(0) 推荐(0) 编辑
摘要: 思考既然决定了开发一款手机遥控器,那么首先确定开发的功能和实现方式。实现方式暂定以在PC端模拟键盘的方式触发快捷键。功能需求首先是遥控器上的按钮。首先是我用的播放器是PotPlayer64,常用的就是快进、后退、播放/暂停、下一文件、音量等。参考了自己的电视遥控器,感觉换台什么的为主,在这里实用性不强,我也不需要换台。然后是DVD遥控器,播放操作基本还是可以,不过上下左右之类的貌似也没有什么用。总结了一下,还是简单的设计,不常用的这个版本先不实现。下面是按钮清单和对应的播放器快捷键:播放控制播放/暂停Space停止F4快进Right快退Left快进X2Control+Right快退X2Cont 阅读全文
posted @ 2012-01-25 13:14 kiminozo 阅读(1368) 评论(0) 推荐(0) 编辑
摘要: 前言几个月前买了一部三星的Omnia7,对WP7的系统特别有好感,加上本身就是.net个程序员,想着以后也可以自己开发点小程序。1月初公司里某项目正在搞令人恶心的CMMI3标准,我天天都在开会或者写概要设计和详细设计的文档,没怎么碰代码感觉手生,决定回家学习WP7开发。学习的过程学习的过程嘛,现在WP7的学习资源真的很少,买了一本《Windows Phone 7 高级编程》,其实我一直不怎么喜欢红皮书,感觉都是点到位置,只教方法不教原理,这本也让我很失望,不过拿来入门还是将就一下,至少能从中学习到WP7的一些大概情况。其次嘛,MSDN还是最好的在线学习的地方,Windows Phone 开发已 阅读全文
posted @ 2012-01-25 12:32 kiminozo 阅读(1474) 评论(3) 推荐(0) 编辑
摘要: 随着上次对Emit的研究,对MSIL和Emit有了进一步了解,不过为了更好地实现Aop需要自己定义委托,但是Emit定义委托就没有类这么容易理解,在多次对照IL代码后,终于成功的实现了自定义委托Delegate。 阅读全文
posted @ 2011-12-20 15:04 kiminozo 阅读(2628) 评论(1) 推荐(3) 编辑
摘要: 最近在研究Emit,发现其实Emit很简单,但是IL很难,还好以前学习过汇编研究了很久才把指令搞清楚. 首先就来看看需要实现一个简单的Aop需要的类: 阅读全文
posted @ 2011-12-17 16:03 kiminozo 阅读(3431) 评论(6) 推荐(4) 编辑
摘要: 在编写NUnit测试的时候有时候需要对非公有有成员进行测试,每个方法都通过反射还是比较麻烦而且不美观。在4.0中可以借助DLR创建一个访问器Accessor动态获取私有成员直接调用。 阅读全文
posted @ 2011-12-14 17:03 kiminozo 阅读(1135) 评论(1) 推荐(2) 编辑
摘要: static string ConvertToChinese(double x) { string s = x.ToString("#L#E#D#C#K#E#D#C#J#E#D#C#I#E#D#C#H#E#D#C#G#E#D#C#F#E#D#C#.0B0A"); string d = Regex.Replace(s, @"((?<=-|^)[^1-9]*)|((?'z'0)[0A-E]*((?=[1-9])|(?'-z'(?=[F-L\.]|$))))|((?'b'[F-L])(?'z'0)[0 阅读全文
posted @ 2011-08-29 16:54 kiminozo 阅读(366) 评论(0) 推荐(0) 编辑
摘要: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes below two million. int[] numbers = Enumerable.Range(1, 2000000).ToArray(); int prime = 2; int nextPrime = 2; int nextPrimePow2 = 2 * 2; for (int i = 1; nextPrime... 阅读全文
posted @ 2011-08-28 17:33 kiminozo 阅读(361) 评论(0) 推荐(0) 编辑
摘要: A Pythagorean triplet is a set of three natural numbers, a b c, for which,a2 + b2 = c2For example, 32 + 42 = 9 + 16 = 25 = 52.There exists exactly one Pythagorean triplet for which a + b + c = 1000.Find the product abc. for (int b = 0; b < 500; b++) { for (int ... 阅读全文
posted @ 2011-08-28 17:32 kiminozo 阅读(322) 评论(0) 推荐(0) 编辑
摘要: Find the greatest product of five consecutive digits in the 1000-digit number. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244 阅读全文
posted @ 2011-08-28 17:31 kiminozo 阅读(540) 评论(0) 推荐(0) 编辑
摘要: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10 001st prime number?class Program { private static List<long> primes = new List<long>(10000000); static void Main(string[] args) { primes.Add(2); ... 阅读全文
posted @ 2011-08-28 17:30 kiminozo 阅读(228) 评论(0) 推荐(0) 编辑
摘要: The sum of the squares of the first ten natural numbers is,12 + 22 + ... + 102 = 385The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2 = 552 = 3025Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 385 = . 阅读全文
posted @ 2011-08-28 17:28 kiminozo 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?internal class Program { private static void Main(string[] args) { /*... 阅读全文
posted @ 2011-08-28 17:25 kiminozo 阅读(642) 评论(0) 推荐(0) 编辑
摘要: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99.Find the largest palindrome made from the product of two 3-digit numbers.class Program { static void Main(string[] args) { /* ... 阅读全文
posted @ 2011-08-28 17:24 kiminozo 阅读(340) 评论(0) 推荐(0) 编辑
摘要: The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number 600851475143 ?class Program { private static List<long> primes = new List<long>(10000); static void Main(string[] args) { /* * The prime factors of 13195 are 5... 阅读全文
posted @ 2011-08-28 17:23 kiminozo 阅读(291) 评论(0) 推荐(0) 编辑
摘要: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-value 阅读全文
posted @ 2011-08-28 17:21 kiminozo 阅读(316) 评论(0) 推荐(0) 编辑
摘要: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000. long result = 0; for (int i = 0; i < 1000; i++) { if (i%3 ==... 阅读全文
posted @ 2011-08-28 17:14 kiminozo 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 首先是2个相同的类class ClassA { public int Id { get; set; } public string Name { get; set; } } class ClassB { public int Id { get; set; } public string Name { get; set; } }然后自定义访问者,将ParameterExpression全部换成另一个类的public class MyVisitor<SourceT,DescT> : ExpressionVisitor { private readonly ParameterExpres 阅读全文
posted @ 2011-08-02 17:24 kiminozo 阅读(587) 评论(0) 推荐(0) 编辑
摘要: 今天看到打印质数的各种算法的文章,突发奇想实现了其较好的算法的Linq版实现。引用算法如下。一、初始化如下列表。 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二、把第一个数(2)取出来,去掉所有可以被2整除的数。 2 3 5 7 9 11 13 15 17 19 21 23 25 27 29三、取第二个数(3),去掉所有可以被 3整除的数。 2 3 5 7 11 13 17 19 23 25 29四、取第三个数(5),因为4已经被去除了,再去掉所有可以被5整除的数。 2 3 5 7 阅读全文
posted @ 2011-02-24 10:15 kiminozo 阅读(466) 评论(0) 推荐(0) 编辑
摘要: ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_Processor"); int count = 0;//核心数 foreach (ManagementObject obj in searcher.Get()) { object cores = obj["NumberOfCores"]; if (cores == null) ... 阅读全文
posted @ 2010-12-14 15:56 kiminozo 阅读(2888) 评论(1) 推荐(0) 编辑
摘要: [代码] arr[i] = i; }Random r = new Random();Array.Sort<int>(arr, (x, y) => r.Next(-1, 2));//重写排序方式,lamda表达式委托,随机返回大于1,等于0,小于-1 foreach (var item in arr){ Console.WriteLine(item);}时间复杂度900+ 无法忍受... 阅读全文
posted @ 2009-06-24 11:29 kiminozo 阅读(1180) 评论(3) 推荐(1) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { B<string> b = new B<string&g... 阅读全文
posted @ 2009-05-30 12:34 kiminozo 阅读(483) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace SimpleVariance{ class Animal { } class Cat: Animal { } class Program { // To understand what the new CoVar... 阅读全文
posted @ 2009-05-30 12:15 kiminozo 阅读(655) 评论(0) 推荐(0) 编辑
摘要: 同一台电脑测试 SQL2000Sp4 企业版 vs SQL2005 企业版--CREATE TABLE [TestTable] (-- [ID] [int] IDENTITY (1, 1) NOT NULL ,-- [FirstName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,-- [LastName] [nvarchar] (100) ... 阅读全文
posted @ 2007-08-17 11:47 kiminozo 阅读(155) 评论(0) 推荐(0) 编辑