⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c# mapx之一--黑暗之痕.htm

📁 C#中使用DirectX编程,lsdgfdlksgnfzvnbzn
💻 HTM
📖 第 1 页 / 共 5 页
字号:
                        style="mso-tab-count: 1"><FONT color=#444444 
                        size=3>&nbsp;&nbsp;&nbsp; </FONT></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P class=MsoNormal 
                        style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                        color=#444444 size=3>下面</FONT><SPAN lang=EN-US><FONT 
                        color=#444444 size=3>,通过一个在地图上测距的例子,来介绍一下如何在C#下自定义MapX工具 
                        </FONT>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                        size=3><FONT color=#444444><SPAN 
                        style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; 
                        </SPAN>如前所述建立一个C#的Windows应用程序并将Mapinfo MapX V5 
                        控件加到窗体上.并加入一个Button控件button1.将button1的Text属性改为"测距",再在窗口中放上两个Label控件label1,label2,将它们的Text属性设置为""空字符串,如下图: 
                        </FONT></FONT>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P class=MsoNormal 
                        style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" 
                        align=center><FONT color=#444444 size=3></FONT><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><SHAPE 
                        id=_x0000_i1026 style="WIDTH: 5in; HEIGHT: 276pt" 
                        type="#_x0000_t75"><IMAGEDATA 
                        src="file:///D:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msoclip1/01/clip_image003.png" 
                        o:title="测距程序界面"></IMAGEDATA></SHAPE>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><SPAN 
                        style="mso-tab-count: 1"><FONT color=#444444 
                        size=3>&nbsp;&nbsp;&nbsp; </FONT></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                        color=#444444 size=3>&nbsp; </FONT>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P class=MsoNormal 
                        style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1"><FONT 
                        size=3><FONT color=#444444><SPAN lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><SPAN 
                        style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; 
                        </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体">双击设计窗体<SPAN 
                        lang=EN-US>,编写</SPAN></SPAN></FONT></FONT><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                        color=#444444 size=3>Form1_Load代码如下: </FONT>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P>
                        <TABLE 
                        style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-alt: solid windowtext .5pt" 
                        cellSpacing=0 cellPadding=0 border=1>
                          <TBODY>
                          <TR>
                            <TD 
                            style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 426.1pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent" 
                            vAlign=top width=568>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" 
                              align=left><SPAN lang=EN-US 
                              style="COLOR: blue; FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444>private</FONT></SPAN><SPAN 
                              lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444> <SPAN 
                              style="COLOR: blue">void</SPAN> Form1_Load(<SPAN 
                              style="COLOR: blue">object</SPAN> sender, 
                              System.EventArgs e) </FONT>
                              <P><FONT color=#444444></FONT></P></SPAN>
                              <P><FONT color=#444444></FONT></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" 
                              align=left><SPAN lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444>{ </FONT>
                              <P><FONT color=#444444></FONT></P></SPAN>
                              <P><FONT color=#444444></FONT></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" 
                              align=left><B><I><SPAN lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444>axMap1.CreateCustomTool(100,MapXLib.ToolTypeConstants.miToolTypePoly, 
                              </FONT>
                              <P><FONT color=#444444></FONT></P></SPAN></I></B>
                              <P><FONT color=#444444></FONT></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 126.5pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 12.0; mso-char-indent-size: 10.5pt" 
                              align=left><B><I><SPAN lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444>MapXLib.CursorConstants.miCrossCursor,<SPAN 
                              style="COLOR: blue">null</SPAN>,<SPAN 
                              style="COLOR: blue">null</SPAN>,<SPAN 
                              style="COLOR: blue">null</SPAN>);</FONT></SPAN></I></B><SPAN 
                              lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444> </FONT>
                              <P><FONT color=#444444></FONT></P></SPAN>
                              <P><FONT color=#444444></FONT></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt; mso-outline-level: 1"><SPAN 
                              lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444>} </FONT>
                              <P><FONT color=#444444></FONT></P></SPAN>
                              <P><FONT 
                        color=#444444></FONT></P></TD></TR></TBODY></TABLE></P>
                        <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                        size=3><FONT color=#444444><SPAN 
                        style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; 
                        </SPAN>在加载窗口的时候,我们定义了一个工具.它的编号是100(不要和MapX本身的工具编号重复),它的类型是一个多义线,采用十字光标. 
                        </FONT></FONT>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                        size=3><FONT color=#444444><SPAN 
                        style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; 
                        </SPAN>关于此函数的用法,建议查看MapX的开发手册和相关资料. </FONT></FONT>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                        size=3><FONT color=#444444><SPAN 
                        style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; 
                        </SPAN>现在我们定义了一个编号为100的工具,可以在程序中使用它了.双击设计窗体中的button1,编写它的Click事件处理代码如下: 
                        </FONT></FONT>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P>
                        <TABLE 
                        style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-alt: solid windowtext .5pt" 
                        cellSpacing=0 cellPadding=0 border=1>
                          <TBODY>
                          <TR>
                            <TD 
                            style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 426.1pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent" 
                            vAlign=top width=568>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" 
                              align=left><SPAN lang=EN-US 
                              style="COLOR: blue; FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444>private</FONT></SPAN><SPAN 
                              lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444> <SPAN 
                              style="COLOR: blue">void</SPAN> 
                              button1_Click(<SPAN 
                              style="COLOR: blue">object</SPAN> sender, 
                              System.EventArgs e) </FONT>
                              <P><FONT color=#444444></FONT></P></SPAN>
                              <P><FONT color=#444444></FONT></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" 
                              align=left><SPAN lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444>{ </FONT>
                              <P><FONT color=#444444></FONT></P></SPAN>
                              <P><FONT color=#444444></FONT></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" 
                              align=left><SPAN lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><SPAN 
                              style="mso-tab-count: 1"><FONT 
                              color=#444444>&nbsp;&nbsp;&nbsp; 
                              </FONT></SPAN><B><I><FONT 
                              color=#444444>axMap1.CurrentTool=(MapXLib.ToolConstants)100; 
                              </FONT>
                              <P><FONT color=#444444></FONT></P></I></B></SPAN>
                              <P><FONT color=#444444></FONT></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                              color=#444444>} </FONT>
                              <P><FONT color=#444444></FONT></P></SPAN>
                              <P><FONT 
                        color=#444444></FONT></P></TD></TR></TBODY></TABLE></P>
                        <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                        size=3><FONT color=#444444><SPAN 
                        style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; 
                        </SPAN>现在编译运行,单击button1,就可以在地图上使用这个工具了.但是还有一部分重要的代码没有完成:测距! 
                        </FONT></FONT>
                        <P><FONT color=#444444 size=3></FONT></P></SPAN>
                        <P><FONT color=#444444 size=3></FONT></P>
                        <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN 
                        lang=EN-US 
                        style="FONT-FAMILY: 新宋体; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><FONT 
                        size=3><FONT color=#444444><SPAN 
                        style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; 
                        </SPAN>完成测距功能的代码在C#使用MapX开发GIS中非常具有代表性,也比较有难度.我在首次使用C#+MapX开发GIS的时候,被这

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -