?? c# mapx之一--黑暗之痕.htm
字號:
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"><FONT
size=3><FONT color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>在上一章里我們試著做了一個將地圖放大的應用程序.在這章里,我們將接觸到更多的工具,并介紹自定義工具.
</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; mso-outline-level: 1"><SPAN
lang=EN-US
style="FONT-FAMILY: 宋體; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt"><FONT
size=3><FONT color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>MapX為開發人員提供一系列的工具,這些工具的作用各有不同,我們通過開發一個應用程序來了解這些工具的作用,至于這些工具的具體說明,可以在MapX的幫助文檔中,通過查找"Available
Standard Tools"</FONT></FONT></SPAN><SPAN lang=EN-US
style="FONT-FAMILY: 宋體"><FONT color=#444444 size=3>
看到相應的解釋.一些MapX的相關資料也有介紹. </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"><SPAN
lang=EN-US style="FONT-FAMILY: 宋體"><FONT size=3><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>在.Net編程環境中新建一個C#的WindeosApplication(Windows應用程序)項目,然后在菜單中選擇”項目/添加引用”,打開如下圖的窗口,在窗口中選擇COM標簽,在組件名稱列表中雙擊MapInfo
MapX V5.單擊"確認"按鈕,將Map5控件加入到.Net的工具箱中. </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; mso-outline-level: 1"><SPAN
lang=EN-US style="FONT-FAMILY: 宋體"><FONT size=3><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>接著,將MapInfo MapX V5
控件畫到窗體上,再在窗體上畫一個ComboBox控件comboBox1.如下圖: </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; mso-outline-level: 1"
align=center><FONT color=#444444 size=3></FONT><SPAN
lang=EN-US style="FONT-FAMILY: 宋體"><SHAPETYPE
id=_x0000_t75 coordsize="21600,21600" o:spt="75"
o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
filled="f" stroked="f"><STROKE
joinstyle="miter"></STROKE><FORMULAS><F
eqn="if lineDrawn pixelLineWidth 0"></F><F
eqn="sum @0 1 0"></F><F eqn="sum 0 0 @1"></F><F
eqn="prod @2 1 2"></F><F
eqn="prod @3 21600 pixelWidth"></F><F
eqn="prod @3 21600 pixelHeight"></F><F
eqn="sum @0 0 1"></F><F eqn="prod @6 1 2"></F><F
eqn="prod @7 21600 pixelWidth"></F><F
eqn="sum @8 21600 0"></F><F
eqn="prod @7 21600 pixelHeight"></F><F
eqn="sum @10 21600 0"></F></FORMULAS><PATH
o:extrusionok="f" gradientshapeok="t"
o:connecttype="rect"></PATH><LOCK v:ext="edit"
aspectratio="t"></LOCK></SHAPETYPE><SHAPE
id=_x0000_i1025 style="WIDTH: 342pt; HEIGHT: 258pt"
type="#_x0000_t75"><IMAGEDATA
src="file:///D:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/msoclip1/01/clip_image001.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; mso-outline-level: 1"><SPAN
lang=EN-US style="FONT-FAMILY: 宋體"><FONT size=3><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>雙擊設計窗體,編寫</FONT></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 size=3>Form1_Load代碼如下: </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"><SPAN
lang=EN-US
style="FONT-SIZE: 9pt; FONT-FAMILY: 新宋體; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'"><SPAN
style="mso-tab-count: 2"><FONT color=#444444
size=3>
</FONT></SPAN></SPAN><SPAN lang=EN-US
style="FONT-FAMILY: 宋體">
<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"><FONT
color=#444444>private</FONT></SPAN><SPAN
lang=EN-US
style="FONT-FAMILY: 宋體; mso-bidi-font-size: 9.0pt; mso-font-kerning: 0pt"><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"><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"><SPAN
style="mso-tab-count: 1"><FONT
color=#444444>
</FONT></SPAN><B><I><FONT color=#444444>ArrayList
ToolsList=<SPAN style="COLOR: blue">new</SPAN>
ArrayList(); </FONT>
<P><FONT color=#444444></FONT></P></I></B></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"><FONT
color=#444444> </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-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"><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>ToolsList.Add(MapXLib.ToolConstants.miArrowTool);
</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-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"><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>ToolsList.Add(MapXLib.ToolConstants.miCenterTool);
</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-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"><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>ToolsList.Add(MapXLib.ToolConstants.miLabelTool);
</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-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"><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>ToolsList.Add(MapXLib.ToolConstants.miPanTool);
</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-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"><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>ToolsList.Add(MapXLib.ToolConstants.miPolygonSelectTool);
</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-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"><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>ToolsList.Add(MapXLib.ToolConstants.miRadiusSelectTool);
</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-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"><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
</SPAN>ToolsList.Add(MapXLib.ToolConstants.miSymbolTool);
</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-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"><FONT
color=#444444><SPAN
style="mso-tab-count: 1">
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -