📄 gpstracerappwmce5.aspx.htm
字号:
(Convert.ToInt32(latitude.Substring(latitude.Length - <span class="code-digit">9</span>, <span class="code-digit">2</span>))) * <span class="code-digit">3600</span>;
aPoint.Y +=
(Convert.ToInt32(longitude.Substring(longitude.Length - <span class="code-digit">9</span>, <span class="code-digit">2</span>))) * <span class="code-digit">3600</span>;
m_points.Add(aPoint);
draw();
}
<span class="code-keyword">public</span> <span class="code-keyword">void</span> draw()
{
<span class="code-keyword">float</span> xTo = <span class="code-digit">0</span>;
<span class="code-keyword">float</span> xFrom = <span class="code-digit">0</span>;
<span class="code-keyword">float</span> yTo = <span class="code-digit">0</span>;
<span class="code-keyword">float</span> yFrom = <span class="code-digit">0</span>;
<span class="code-keyword">for</span> (<span class="code-keyword">int</span> i = m_drawded; i < m_points.Count; i++)
{
xTo = (m_points[i].X - m_points[<span class="code-digit">0</span>].X) / m_scale + m_center.X;
xFrom = (m_points[i - <span class="code-digit">1</span>].X -
m_points[<span class="code-digit">0</span>].X) / m_scale + m_center.X;
yTo = (m_points[i].Y - m_points[<span class="code-digit">0</span>].Y) / m_scale + m_center.Y;
yFrom = (m_points[i - <span class="code-digit">1</span>].Y - m_points[<span class="code-digit">0</span>].Y) /
m_scale + m_center.Y;
m_g.DrawLine(m_linePen, (<span class="code-keyword">int</span>)xTo, (<span class="code-keyword">int</span>)yTo,
(<span class="code-keyword">int</span>)xFrom, (<span class="code-keyword">int</span>)yFrom);
m_g.DrawEllipse(m_pointPen,
<span class="code-keyword">new</span> Rectangle((<span class="code-keyword">int</span>)xFrom - <span class="code-digit">2</span>,
(<span class="code-keyword">int</span>)yFrom - <span class="code-digit">2</span>, <span class="code-digit">4</span>, <span class="code-digit">4</span>));
}
m_g.DrawEllipse(m_lastPointPen,
<span class="code-keyword">new</span> Rectangle((<span class="code-keyword">int</span>)xTo - <span class="code-digit">2</span>, (<span class="code-keyword">int</span>)yTo - <span class="code-digit">2</span>, <span class="code-digit">4</span>, <span class="code-digit">4</span>));
m_drawded++;
}</pre>
<p>At the end, you can see the <code>loadPath(...)</code> and <code>savePath</code> methods. These methods are called by the form that asks the user the filename/location from the windows form dialog <code>m_mapper.loatPath(openFileDialog1.FileName); m_mapper.savePath(saveFileDialog1.FileName);</code>. So this simply loads/saves the <code><span class="code-keyword">private</span> List<span class="code-keyword"><</span>POINT<span class="code-keyword">></span> m_points;</code> from/to a file. </p>
<div class="SmallText" id="premain9" style="width: 100%;"><img preid="9" src="GpsTracerAppWMCE5.aspx_files/minus.gif" id="preimg9" height="9" width="9"><span preid="9" style="margin-bottom: 0pt;" id="precollapse9"> Collapse</span></div><pre style="margin-top: 0pt;" id="pre9" lang="cs"> <span class="code-keyword">public</span> <span class="code-keyword">void</span> loatPath(<span class="code-SDKkeyword">String</span> filename)
{
StreamReader sr = <span class="code-keyword">new</span> StreamReader(filename);
m_points.Clear();
<span class="code-keyword">int</span> n = <span class="code-digit">0</span>;
Point p = <span class="code-keyword">new</span> Point();
<span class="code-keyword">while</span> (!sr.EndOfStream)
{
<span class="code-SDKkeyword">String</span> readed = sr.ReadLine();
p.X = Convert.ToInt32(readed);
readed = sr.ReadLine();
p.Y = Convert.ToInt32(readed);
m_points.Add(p);
n++;
}
m_drawded = <span class="code-digit">1</span>;
sr.Close();
clearAndDraw();
}
<span class="code-keyword">public</span> <span class="code-keyword">void</span> savePath(<span class="code-SDKkeyword">String</span> filename)
{
StreamWriter sw = <span class="code-keyword">new</span> StreamWriter(filename);
<span class="code-keyword">foreach</span> (Point p <span class="code-keyword">in</span> m_points)
{
sw.WriteLine(Convert.ToString(p.X));
sw.WriteLine(Convert.ToString(p.Y));
}
sw.Flush();
sw.Close();
}</pre>
<h2>Points of interest</h2>
<p>I know that this is a simple project for a skilled developer, but I
want to demonstrate that the device development is very simple with
VisualStudio2005 and CompactFramework 2.0. It's my first project on the
great CodeProject website, so please contact me if you have any doubts
or proposals. I'm always available for collaboration. </p>
<h2>History</h2>
<ul>
<li>Start of development: 8/7/2006 </li>
<li>First release: 8/9/2006 </li>
<li>Second release : 8/10/2006
<ul>
<li>Added Center function </li>
<li>Now demo mode run without GPS or any serial port </li>
<li>Some and various fix </li>
</ul>
</li>
<li>Article edited and posted to the main CodeProject.com article base: 5/22/2007 </li>
</ul>
<!-- Article Ends -->
<!-- Main Page Contents End -->
</div>
</span>
<h2>About the Author</h2>
<table border="0" cellpadding="0" cellspacing="5" width="100%">
<tbody><tr valign="top">
<td id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberPhotoTable" style="width: 155px;" valign="top">
<b><a id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberProfileLink" href="http://www.codeproject.com/script/Membership/Profiles.aspx?mid=2675454">leonardosalvatore</a></b><br><br>
<center><img id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberPhoto" src="GpsTracerAppWMCE5.aspx_files/CC50BF45-6E86-4407-93BD-EC87A31AB0D8.jpg" style="border-width: 0px;"></center><br>
<span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberType" class="SmallText"></span>
</td>
<td>
<br>
<table>
<tbody><tr id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_jobTitleRow">
<td class="SmallText" nowrap="nowrap">Occupation: </td>
<td width="100%"><span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberJobTitle" class="SmallText">Web Developer</span></td>
</tr>
<tr id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_locationRow">
<td class="SmallText">Location: </td>
<td width="100%"><span id="ctl00_AboutAuthorRptr_ctl00_AboutAuthor_memberLocation" class="SmallText"><img src="GpsTracerAppWMCE5.aspx_files/IT.gif" alt="Italy" height="11" width="16"> Italy</span></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<br>
<table id="ctl00_PopularArticlesRow" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr valign="top">
<td style="width: 100%;">
<h2>Other popular Mobile Development articles:</h2><ul><li><a href="http://www.codeproject.com/KB/mobile/WritingGPSApplications2.aspx">Writing Your Own GPS Applications: Part 2</a><div class="SmallText">In
part two of the series, the author of "GPS.NET" teaches developers how
to write GPS applications suitable for the real world by mastering GPS
precision concepts. Source code includes a working NMEA interpreter and
sample high-precision application in C# and VB.NET.</div></li><li><a href="http://www.codeproject.com/KB/mobile/tvremote.aspx">Pocket PC TV Remote Control</a><div class="SmallText">An article describing how to use the IR port on a pocket PC to control a TV.</div></li><li><a href="http://www.codeproject.com/KB/mobile/CfPocket1945.aspx">Pocket 1945 - A C# .NET CF Shooter</a><div class="SmallText">An article on Pocket PC game development</div></li><li><a href="http://www.codeproject.com/KB/mobile/irdamobile.aspx">Infrared Communication with your Mobile Phone</a><div class="SmallText">Learn how to make your Pocket PC speak with your mobile phone.</div></li><li><a href="http://www.codeproject.com/KB/mobile/PocketBeamer.aspx">C# Remote Control using the Audio Port</a><div class="SmallText">This
article describes the development of C# code that allows you to send
consumer IR codes from your mobile device using the audio port.</div></li></ul>
<h2></h2>
</td>
<td>
<iframe src="GpsTracerAppWMCE5.aspx_files/ServeHTML.htm" border="0" frameborder="0" height="250" scrolling="no" width="300"></iframe>
</td>
</tr>
</tbody></table>
<div id="ctl00_AddTo" style="margin: 10px;">
<script language="JavaScript" type="text/javascript">
var addtoMethod=1;
var AddURL = document.location.href;
var AddTitle = escape(document.title);
DrawLinks(100, 0, "SmallText Bold", "AddTo")
</script><span class="SmallText Bold">Add this article to: </span> <a class="AddTo" title="Add this page to Del.icio.us" onclick="return addto(0);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Delicious.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Digg" onclick="return addto(1);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Digg.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Google" onclick="return addto(2);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Google.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Spurl" onclick="return addto(3);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Spurl.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Blink" onclick="return addto(4);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Blink.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Furl" onclick="return addto(5);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Furl.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Simpy" onclick="return addto(6);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Simpy.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Yahoo! MyWeb" onclick="return addto(7);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Yahoo.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Technorati" onclick="return addto(8);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Technorati.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Reddit" onclick="return addto(9);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Reddit.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Windows Live" onclick="return addto(10);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Live.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Newsvine" onclick="return addto(11);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_Newsvine.png" align="absmiddle" border="0" height="16" width="16"></a> <a class="AddTo" title="Add this page to Stumbleupon" onclick="return addto(12);" href="#"><img src="GpsTracerAppWMCE5.aspx_files/AddTo_stumbleupon.png" align="absmiddle" border="0" height="16" width="16"></a>
</div>
<table id="ctl00_RateArticleRow" class="RatingBar" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td><a href="#_top">Article Top</a></td>
<td align="right"><form name="aspnetForm" method="post" action="GpsTracerAppWMCE5.aspx" id="aspnetForm" style="margin: 0pt; padding: 0pt;">
<div>
<input name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEwMDUyNjYzMjhkZDx5Ze5oDpE763qDENKgMTHg7Dwi" type="hidden">
</div>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td style="white-space: nowrap;" class="SmallText" align="right">
<table>
<tbody><tr>
<td id="ctl00_RateArticle_RateText" style="padding-right: 5px;"><i><b>Rate this Article for us!</b></i></td>
<td id="ctl00_RateArticle_StartForm" align="right"><i> Poor</i></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -