STKX组件实现c#与stk的集成
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
STK X Tutorial - C#
In this exercise you will gain hands-on experience using STK X to embed STK functionality in a container application created with C#.
N OTE:Except where otherwise noted, the instructions in this tutorial are
applicable whether you are using Visual Studio 2005 or Visual
(2003). All pictures are of the Visual Studio 2005 interface.
C ONTENTS
CREATE THE PROJECT (1)
ADD THE STK X CONTROLS TO THE TOOLBOX (1)
SEND COMMANDS TO STK X (2)
ADD ZOOM IN/OUT TO THE MAP CONTROL (4)
RESPOND TO EVENTS RAISED BY STK X (5)
ADD MAP PICKING (8)
SET STK X PROPERTIES (9)
Create the project
1)Start Visual Studio.
2)From the File menu, select New, and then Project….
3)Select Visual C# as the Project type and the Windows Application template. Enter a
project name and location of your choice.
4)The Form1.cs windows form is opened in Design mode.
Add the STK X controls to the Toolbox
1)If the Toolbox is not already displayed, select it from the View menu.
2)Go to the General section of the toolbox, and right-click in the toolbox background.
3)In the context menu, select Choose Items… (or Add/Remove Items… if you are
using Visual 2003).
STK X Tutorial – C# 1
4)In the Choose Toolbox Items dialog (Customize Toolbox in Visual
2003), select the COM Components tab.
5)Check AGI Globe Control 8 and AGI Map Control 8in the list of controls, and click
OK to close the dialog.
6)The AGI Map Control and AGI Globe Control now appear in the Toolbox under
the General tab:
Send commands to STK X
1)Drag the AGI Globe Control onto Form1.cs. Place and size the control it so that it
approximately fills the right-hand portion of the form. Then drag the AGI Map
Control onto the left-hand portion of the form, sizing it so that it leaves some space
for other controls to be added.
STK X Tutorial – C# 2
2)Add 3 buttons and a label to the form, arranged as shown here:
STK X Tutorial – C# 3
N OTE:If you are using Visual 2003, the label may appear larger,
since it does not automatically resize by default as it does in Visual Studio
2005.
3)Change the Text property for the top button to New Scenario.
4)Double-click the New Scenario button in the Designer to expose the code for its
Click event handler.
5)Modify the button1_Click method by adding the following line:
this.axAgUiAx2DCntrl1.Application.ExecuteCommand("New / Scenario
Test");
6)Build and run the application.
7)Click the New Scenario button. It may take a few minutes for the results to display.
8)Move the mouse in the Globe window to rotate the globe (holding down the left
mouse button) or zoom in and out on it (holding down the right mouse button).
Add Zoom In/Out to the Map control
1)Change the Text properties of the remaining 2 buttons to Zoom In and Zoom Out.
2)Double-click on the Zoom In button to expose the code for the click event handler.
STK X Tutorial – C# 4