Bing Map对于中国用户来说还是不行,很多地理位置没有标明,而且不够细致,所以立刻想到的就是Google Map,于是找了一下相关资源,在Windows Phone应用中使用Google Map其实非常简单,下面详述一下步骤:
1. 有一个封装好的DLL类库:googlemaps.dll(点击下载),这个是核心内容,在项目里首先添加该DLL的引用:

2. 添加到XAML文件中几个引用并命名
xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
xmlns:GoogleTileSource="clr-namespace:googlemaps;assembly=googlemaps"
xmlns:MSPCMCore="clr-namespace:Microsoft.Phone.Controls.Maps.Core;assembly=Microsoft.Phone.Controls.Maps"
3. 调用Google Map,这里要先简单说一下,比起iOS开发来说WP开发实在太方便了,也多亏了这个DLL写的好,只要将原有的Bing Map控件中嵌套一点内容即可,添加标签及获取地理位置完全不影响,XAML内容如下:
<my:Map x:Name="mMain" Margin="0,0,0,0" CopyrightVisibility="Collapsed" LogoVisibility="Collapsed" ScaleVisibility="Visible" CredentialsProvider="ApBXPZf5IR94SLXE8nh5FYsb5WHKrH1XPY7428-EqQudseivcWhCROIJvGmtnkAV">
<my:MapTileLayer Name="street" Margin="0,0,0,32">
<my:MapTileLayer.TileSources>
<GoogleTileSource:GoogleTile TileTypes="Street">
</GoogleTileSource:GoogleTile>
</my:MapTileLayer.TileSources>
</my:MapTileLayer>
</my:Map>
就这么简单,具体内部实现我也没研究,有兴趣的大家可以找找这个DLL的源码。
效果如下:

http://www.xueit.com/windowsphone7/show-9764-2.aspx
posted @ 2011-10-08 13:04 Kingly 阅读(96) 评论(4)
编辑
Windows Phone 7手指画图应用 - FingerPaint
http://www.silverlightchina.net/html/wp7/resource/2010/1030/3037.html
自制手机界面切换效果(持续更新)
http://www.silverlightchina.net/html/wp7/resource/2011/0816/9791.html
[被遗弃的小指]监控宝Windows Phone 7客户端
http://www.gwewe.com/dev/featured/1009140752.html
windows phone使用google地图
http://www.cnblogs.com/WilsonWu/archive/2011/09/26/2192364.html
posted @ 2011-10-08 12:25 Kingly 阅读(48) 评论(0)
编辑
《从入门到精通:Windows Phone 7应用开发》
http://www.gwewe.com/dev/download/1012110069.html
posted @ 2011-10-08 11:33 Kingly 阅读(69) 评论(0)
编辑
http://bbs.51cto.com/archiver/tid-863385.html
void microphone_BufferReady(object sender, EventArgs e)
{
this.Dispatcher.BeginInvoke(() =>
{
microphone.GetData(buffer);
stream.Write(buffer, 0, buffer.Length);
TimeSpan tsTemp = timer.Elapsed;
TextBlockSeconds.Text = tsTemp.Hours.ToString().PadLeft(2, '0') + ":" + tsTemp.Minutes.ToString().PadLeft(2, '0') + ":" + tsTemp.Seconds.ToString().PadLeft(2, '0');
if(timer.Elapsed.Seconds >5)
DoStop();
});
}
private void ButtonRecord_Click(object sender, RoutedEventArgs e)
{
DisableRecordButton();
timer = new Stopwatch();
timer.Start();
stream = new MemoryStream();
TextBlockSeconds.Text = "00:00:00";
TextBlockStatus.Text = "Recording: ";
microphone.BufferDuration = TimeSpan.FromMilliseconds(500);
buffer = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)];
microphone.BufferReady += new EventHandler<EventArgs>(microphone_BufferReady);
microphone.Start();
}
private void DoStop()
{
if (timer.IsRunning)
timer.Stop();
if (microphone.State == MicrophoneState.Started)
{
microphone.Stop();
TextBlockStatus.Text = "Stopped: Ready to save";
}
else
{
TextBlockStatus.Text = "Ready: ";
}
TextBlockSeconds.Text = string.Empty;
EnableRecordButton();
}
http://www.cnblogs.com/zhangyafeng/archive/2009/12/10/1621213.html
http://www.devdiv.com/thread-23384-1-1.html
流媒体播放
http://www.silverlightchina.net/html/zhuantixilie/winphone7/2011/0930/10757.html
http://www.silverlightchina.net/plus/search.php?kwtype=0&keyword=%D2%F4%C6%B5&searchtype=titlekeyword
http://www.silverlightchina.net/plus/search.php?kwtype=0&keyword=Audio&searchtype=titlekeyword
http://www.silverlightchina.net/html/developer/silverlight/2010/0521/1166.html
http://www.cnblogs.com/imobiler/archive/2010/12/23/1914353.html
posted @ 2011-10-08 11:18 Kingly 阅读(24) 评论(0)
编辑
http://www.blogjava.net/JAVA-HE/archive/2007/02/07/98527.html
对两种情况,这个文件不需要修改:
1 import org.xml.sax.Attributes;
2 import org.xml.sax.helpers.DefaultHandler;
3 import org.xml.sax.SAXException;
4 import java.util.Properties;
5
6 public class ConfigParser extends DefaultHandler
7 {
8 ////定义一个Properties 用来存放 dbhost dbuser dbpassword的值
9 private Properties props;
10
11 private String currentSet;
12 private String currentName;
13 private StringBuffer currentValue = new StringBuffer();
14 //构建器初始化props
15 public ConfigParser()
16 {
17 this.props = new Properties();
18 }
19 public Properties getProps()
20 {
21 return this.props;
22 }
23
24
25 //定义开始解析元素的方法. 这里是将<xxx>中的名称xxx提取出来.
26 public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
27 {
28 currentValue.delete(0, currentValue.length());
29 this.currentName =qName;
30 }
31 //这里是将<xxx></xxx>之间的值加入到currentValue
32 public void characters(char[] ch, int start, int length) throws SAXException
33 {
34 currentValue.append(ch, start, length);
35 }
36 //在遇到</xxx>结束后,将之前的名称和值一一对应保存在props中
37 public void endElement(String uri, String localName, String qName) throws SAXException
38 {
39 props.put(qName.toLowerCase(), currentValue.toString().trim());
40 //System.out.println(qName.toLowerCase() + " " + currentValue.toString().trim());
41 }
42 }
43
这个文件中注释 与注释之间的是对不同情况的对比:
1 import java.net.URL;
2 import java.util.Properties;
3 import javax.xml.parsers.SAXParser;
4 import javax.xml.parsers.SAXParserFactory;
5
6 public class ParseXML
7 {
8 //定义一个Properties 用来存放标签值
9 private Properties props;
10 public Properties getProps()
11 {
12 return this.props;
13 }
14 public void parse(String filename) throws Exception
15 {
16 //将解析器对象化
17 try
18 {
19 ConfigParser handler = new ConfigParser();
20 //获取SAX工厂对象
21 SAXParserFactory factory = SAXParserFactory.newInstance();
22 factory.setNamespaceAware(false);
23 factory.setValidating(false);
24 //获取SAX解析
25 SAXParser parser = factory.newSAXParser();
26
27 /////////////////////////////////////////////////////////////////////////////
28 //对字符串解析:
29 // InputSource is = new InputSource ();
30 // StringReader xmlStr = new StringReader (filename);
31 // is.setCharacterStream (xmlStr);
32 // parser.parse (is,handler);
33 ////////////////////////////////////////////////////////////////////////////
34
35 ////////////////////////////////////////////////////////////////////////////
36 // 对文件解析:
37 URL confURL = getClass().getResource(filename);
38 if(confURL == null) System.out.println("error");
39
40 //将解析器和解析对象xml联系起来,开始解析
41 parser.parse(confURL.toString(), handler);
42 /////////////////////////////////////////////////////////////////////////
43 props = handler.getProps();
44 }
45 catch(Exception e)
46 {
47 System.out.println (e.toString ());
48 }
49 }
50 }
51
52
测试程序:
1 import java.util.*;
2
3 public class Main
4 {
5 static ParseXML px = new ParseXML ();
6 public static void main (String[] args)
7 {
8 //load_properties (); //解析xml文件
9 load_properStr(); //解析字符串用这个方法
10 String issuccessful = (String) getObject ("result");
11 String objRequestID = (String) getObject ("msg");
12 System.out.println ("issuccessful ::"+issuccessful);
13 System.out.println ("objRequestID ::"+objRequestID);
14
15 }
16
17 public static void load_properStr ()
18 {
19
20 String str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
21 "<response>"+
22 "<result>0</result>"+
23 "<msg>47F42A2D578</msg>"+
24 "</response>";
25 try
26 {
27 px.parse (str);
28 }
29 catch (Exception ex)
30 {
31 ex.printStackTrace ();
32 }
33
34 }
35 public static void load_properties ()
36 {
37 try
38 {
39 px.parse ("/properties.xml");
40 }
41 catch (Exception ex)
42 {
43 ex.printStackTrace ();
44 }
45 }
46 public static Object getObject (String keyname)
47 {
48 return px.getProps ().getProperty (keyname);
49 }
50 }
51
Silverlight中XmlReader解析XML的流程
在Silverlight 1.1中,C#只能用XmlReader这样一个非常轻量级的东西来解析XML,因此稍有不慎就会出现很多非常奇怪的错误,在这里对XML的解析做一个简单的流程介绍吧。
在对流式XML的解析中,XmlReader对XML节点进行一些区分,这些节点的类型包括:
引用内容:
public enum XmlNodeType
{
None = 0,
Element = 1,
Attribute = 2,
Text = 3,
CDATA = 4,
EntityReference = 5,
Entity = 6,
ProcessingInstruction = 7,
Comment = 8,
Document = 9,
DocumentType = 10,
DocumentFragment = 11,
Notation = 12,
Whitespace = 13,
SignificantWhitespace = 14,
EndElement = 15,
EndEntity = 16,
XmlDeclaration = 17,
}
其中常用到的有Element、Attribite、Text、CDATA、EndElement等。其中Element类型的节点为“<item>”形式,EndElement的的节点为“</item>”形式,而Text类型则可以为一对标记之间的文本内容或者节点之间的空格、换行等。
了解了这些,我们再来看怎么从一个XML文件流中找出自己想要的数据。首先假设有一个这样的XML数据流,其XML结构如下:
引用内容:
<root>
<item>
<Title>网球王子</Title>
<Catalog>热门动漫</Catalog>
<Author>OOboy.net</Author>
<Email />
<Modified>Thu, 16 Aug 2007 09:39:19 GMT</Modified>
</item>
<item>
<Title>越狱</Title>
<Catalog>海外剧场</Catalog>
<Author>OOboy.net</Author>
<Email />
<Modified>Thu, 16 Aug 2007 09:39:19 GMT</Modified>
</item>
</root>
我们用XmlReader的Create方法从这个Stream中创建了一个XmlReader对象,现在我们解析出想要的数据——item项目中的各个子项:Title、Catalog、Author、Email、Modified。
解析过程在下面代码的注释中:
引用内容:
//reader是一个XmlReader实例
//开始读取流,直到读完为止
//reader.Read()每次读取一个XML节点(XML节点的描述在本文开头)
while (reader.Read())
{
//如果该节点是一个开始节点,而且节点的名称叫做item
//那么我们继续读取item子树
if ((reader.IsStartElement()) && (reader.LocalName == "item"))
{
//创建一个新的Item对象,后面把数据保存到Item对象中
Item item = new Item();
//继续读取Item下面的内容
using (XmlReader itemReader = reader.ReadSubtree())
{
//开始读取Item下面的内容,知道读完Item子树为止
//当碰到节点</item>时会跳出循环
while (itemReader.Read())
{
//如果找到一个Element,我们就读取其中的值
//用这种节点可以忽略空格、回车等等
if (itemReader.NodeType == XmlNodeType.Element)
{
//如果是空节点,比如上文中的<Email />这样的节点
//此时读取下一个节点,否则会出错
if (itemReader.IsEmptyElement)
{
continue;
}
//如果不是空节点
//把节点的name记录下来
string nodeName = itemReader.Name;
//读取节点内地文本节点
itemReader.Read();
if (itemReader.NodeType == XmlNodeType.Text)
{
//根据节点的name,把值保存到Item对应的属性中
switch (nodeName.ToUpper())
{
case "TITLE":
item.title = itemReader.Value;
break;
case "CATALOG":
item.catalog = itemReader.Value;
break;
case "AUTHOR":
item.author = itemReader.Value;
break;
case "EMAIL":
item.email = itemReader.Value;
break;
case "MODIFIED":
item.modified = itemReader.Value;
break;
}
}
//读取完成,再读结束节点End Element
itemReader.Read();
}
}
}
}
}
/*
string xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><bookstore><book genre='novel' ISBN='10-861003-324'><title>The Handmaid's Tale</title><price>19.95</price></book><book genre='novel' ISBN='1-861001-57-5'><title>Pride And Prejudice</title><price>24.95</price></book></bookstore>";
*/
public string GetXmlStrings(string xmlString)
{
StringBuilder output = new StringBuilder();
// Load the file and ignore all white space.
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
using (XmlReader reader = XmlReader.Create(new StringReader(xmlString), settings))
{
while (reader.Read())
{
if ((reader.IsStartElement()) && (reader.LocalName == "book")) //读取Table的显示名称和Tabel的名称
{
using (XmlReader reader1 = reader.ReadSubtree())
{
if (reader1.ReadToDescendant("book"))
{
while (reader1.Read())
{
if (reader1.NodeType == System.Xml.XmlNodeType.Element)
{
//当前节点不是空值
if (!reader1.IsEmptyElement)
{
string nodeName = reader1.Name;
reader1.Read();
if (reader1.NodeType == System.Xml.XmlNodeType.Text)
{
output.AppendLine(nodeName + "=" + reader1.Value);
}
reader1.Read();
}
}
}
}
}
}
}
}
return output.ToString();
}
http://www.iwms.net/n679c12.aspx
http://www.ehelper.com.cn/blog/post/csharp-xml.html
http://hi.baidu.com/sophyishere/blog/item/ffc31c2e36ed1ae18a139936.html
http://qkhhwxfqqq.blog.163.com/blog/static/12653894520102299858788/
http://www.591cto.com/wangluokaifa/XML/2011/0721/25988.html
http://my.oschina.net/duluo180/blog/9888
http://www.diybl.com/course/4_webprogram/xml/xml_js/2008324/106496.html
http://msdn.microsoft.com/zh-cn/library/system.xml.xmlreader.movetonextattribute(v=VS.95)
posted @ 2011-10-08 10:45 Kingly 阅读(317) 评论(0)
编辑