Professional Documents
Culture Documents
Lap Trinh ArcGIS Engine Control
Lap Trinh ArcGIS Engine Control
Developer Kit v ArcGIS Engine Runtime. N l mt th vin gip pht trin cc ng dng
c lp bng cc ngn ng lp trnh thng thng nh C#, C++, Java, VB6, VB.NET, VC++.
C 2 loi: ArcGIS Engine Developer Kit v ArcGIS Engine Runtime. ArcGIS Engine
Developer Kit cn cho ngi lp trnh (developer). ArcGIS Engine Runtime cn cho ngi s
dng (client). Tc l nu bn l developer pht trin ng dng th trn my phi c ArcGIS
Engine Developer Kit. Sau khi pht trin ng dng xong, khi chuyn giao th client phi c
ArcGIS Engine Runtime. ArcGIS Engine Runtime th r hn ArcGIS Engine Developer Kit.
Tuy nhin nu developer hoc client c sn ArcGIS th khng cn mua/ci thm ArcGIS
Engine Developer Kit hay ArcGIS Engine Runtime na.
Ngoi ra, nu khi lp trnh m bn c s dng th vin ca cc extension nh Spatial Analyst
th client cng phi mua thm ArcGIS Engine Runtime - Spatial Extension.
Line dowload: [You must be registered and logged in to see this link.]
Ti Sn ca
TruongDinhNguyen
ArcGIS Engine
Vit bi VidaGIS
Th hai, 29 Thng 12 2008 15:43
ArcGIS Engine l phn mm pht trin to ra cc ng dng
GIS da trn yu cu c th v c chy trn Desktop.
ArcGIS Engine l b li bao gm cc hp phn xy dng
cc sn phm ArcGIS Desktop. Vi ArcGIS Engine, bn c
th xy dng mt ng dng ring bit hoc phn m rng ca
nhng ng dng sn c cung cp gii php khng gian cho
c ngi dng GIS ln ngi khng s dng GIS.
ArcGIS Engine cung cp nhng giao din lp trnh nh (APIs) cho COM, .NET, Java, v
C++. APIs khng ch bao gm nhng ti liu chi tit m cn c hng lot cc hp phn lm
cho cc nh lp trnh vin d dng hn trong vic xy dng mt ng dng ArcGIS.
ArcGIS Engine cung cp:
Tit kim chi ph trong khi s dng: ch mt license ArcGIS Engine Runtime hay mt
ArcGIS Desktop trn mt my
Ngn ng chun nh COM, .NET, Java, and C++ v nn Windows, Linux, Solaris
Click here (1) to get the sample associated with this walkthrough.
Development licensing Deployment licensing
Engine Developer Kit
Engine Runtime
ArcView
ArcEditor
ArcInfo
Additional Requirements
While no experience with other ESRI software is required, previous experience with
ArcObjects and a basic understanding of ArcGIS applications, such as ArcMap and
ArcCatalog are recommended.
Access to the sample data and code that comes with this scenario.
In this topic
Project description
Concepts
Design
Implementation
o
Deployment
Additional resources
Project description
This document demonstrates the steps required to create a GIS application for viewing preauthored ESRI map documents (*.mxd).
Concepts
This scenario is implemented using the Microsoft Visual Studio .NET development
environment and uses the ESRI interop assemblies to host the ArcGIS Engine controls inside
.NET Windows controls in a .NET form. These interoperability assemblies act as a bridge
between the unmanaged code of the Component Object Model (COM) and the managed .NET
code. Any references to the members of the COM ArcGIS Engine controls are routed to the
interop assemblies and forwarded to the actual COM object. Likewise, responses from the
COM object are routed to the interop assembly and forwarded to the .NET application. Each
ArcGIS Engine control has events, properties, and methods that can be accessed once
embedded within a container, such as a .NET form. The objects and functionality in each
control can be combined with other ESRI ArcObjects and custom controls to create
customized end user applications.
The scenario has been written in both C# and Visual Basic .NET. Many developers will feel
more comfortable with Visual Basic .NET, as the code looks familiar to Visual Basic 6.0,
while the syntax of the C# programming language will be familiar to Java and C++
programmers. Whichever development environment you use, your future success with the
ArcGIS Engine controls depends on your skill in both the programming environment and
ArcObjects.
The MapControl, PageLayoutControl, TOCControl and ToolbarControl are used in this
scenario to provide the user interface of the application, and the LicenseControl is used to
configure the application with an appropriate license. The ArcGIS Engine controls are used in
conjunction with other ArcObjects and control commands by the developer to create a GIS
map viewing application.
Design
The scenario has been designed to highlight how the ArcGIS Engine controls interact with
each other and to expose a part of each ArcGIS Engine control's object model to the
developer.
Each .NET ArcGIS Engine control has a set of property pages that can be accessed once the
control is embedded in a .NET form. These property pages provide shortcuts to a selection of
a control's properties and methods and allow a developer to build an application without
writing any code. This scenario does not use the property pages but rather builds up the
application programmatically.
The ArcGIS Engine controls and libraries used in this scenario are as follows:
ESRI.ArcGIS.ADF
ESRI.ArcGIS.AxControls
ESRI.ArcGIS.Carto
ESRI.ArcGIS.Controls
ESRI.ArcGIS.Display
ESRI.ArcGIS.Geometry
ESRI.ArcGIS.Output
ESRI.ArcGIS.System
ESRI.ArcGIS.SystemUI
1. Start Visual Studio .NET and create either a new Visual C# or Visual Basic Windows
Application project from the New Project dialog box.
2. Name the project Controls and browse to a location to save the project.
3. In the Toolbox click ArcGIS Windows Forms to display the ArcGIS Engine controls.
If there is no ArcGIS Windows Forms, right-click the Toolbox and click Choose Items
from the context menu.
4. In the Choose Toolbox Items dialog box, click the .NET Framework Components tab
and check AxLicenseControl, AxMapControl, AxPageLayoutControl,
AxTOCControl, and AxToolbarControl, then click OK. The controls will now appear
in the Toolbox. See the following screen shot:
The ESRI .NET assemblies will be used to instantiate and make calls on the objects in the
ESRI object libraries from your C# or VB.NET project using the COM interoperability
services provided by the .NET Framework.
Embedding the ArcGIS Engine controls in a container
Before you can access each control's properties, methods, and events, each control needs
embedding in a .NET container. Once the controls are embedded in the form, they will shape
the application's user interface.
[VB.NET]
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.SystemUI
Imports ESRI.ArcGIS.esriSystem
License initialization using the LicenseControl
To successfully deploy this application on another machine, the application must configure a
license. First, it must check that a product license is available and second, it must initialize the
product license. If this license configuration fails, the application cannot run. License
configuration can be performed either by using the LicenseControl or by programmatically
using the AoInitialize object. For the purpose of this application, the LicenseControl will be
used to handle license configuration.
When developing a stand-alone executable using ArcObjects, it is the responsibility of the
application to check and configure the licensing options. A license can be configured using
either the LicenseControl or the AoInitialize class and the IAoInitialize interface it
implements, that is designed to support license configuration. License initialization must be
performed at application start time, before any ArcObjects functionality is accessed. Failure to
do so will result in application errors.
1. Open the .NET form in design mode.
2. Right-click the LicenseControl and click ActiveX-Properties to open the
LicenseControl property pages.
3. Under Products, select the ArcGIS Engine check box and select Shutdown this
application if the selected licenses are not available check box, then click OK. See the
following screen shot:
The LicenseControl will appear on a form at design time so that it can be selected and its
property pages viewed. However, at run time the LicenseControl is invisible so its position on
the form is irrelevant.
This application can be initialized with an ArcGIS Engine license but you may optionally
initialize the application with a higher product license. For example, if you select the ArcGIS
Engine license and the ArcView license check boxes, the LicenseControl will initially try to
initialize the application with an ArcGIS Engine license (the lower license). If that license is
not available, the LicenseControl will try to initialize the application with an ArcView license
(the next higher level license selected). If no product licenses are available, then the
application will fail to initialize.
In this application the LicenseControl will handle license initialization failure. If the
application cannot be initialized with an ArcGIS Engine product license, a License Failure
dialog box appears before the application is automatically shut down. Alternatively, a
developer can handle license initialization failure using the ILicenseControl interface
members to obtain information on the nature of the failure before the application is
programmatically shut down.
Loading map documents into the PageLayoutControl and MapControl
Individual data layers or pre-authored map documents can be loaded into the MapControl and
PageLayoutControl. You can either load the sample map document that is provided or you
can load your own map document. Later, you will add a command to browse to a map
document.
1. Select the Form_Load event and enter the code in the following code example (you
may need to alter the relative path to the map document or substitute the file name if
you are using your own map document):
[C#]
private void MapViewer_Load(object sender, System.EventArgs e)
{
//Load a pre-authored map document into the PageLayoutControl using relative paths.
string fileName = @
"..\..\..\..\data\GulfOfStLawrence\Gulf_of_St._Lawrence.mxd";
if (axPageLayoutControl1.CheckMxFile(fileName))
axPageLayoutControl1.LoadMxFile(fileName, "");
}
[VB.NET]
Private Sub MapViewer_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Load a pre-authored map document into the PageLayoutControl using realative
paths.
Dim sFileName As String =
"..\..\..\..\data\GulfOfStLawrence\Gulf_of_St._Lawrence.mxd"
If AxPageLayoutControl1.CheckMxFile(sFileName) Then
AxPageLayoutControl1.LoadMxFile(sFileName)
End If
End Sub
2. Display the form in design mode and select axPageLayoutControl1 from the
Properties window and display the PageLayoutControl events. Double-click the
OnPageLayoutReplaced event to add an event handler to the code window. See the
following screen shot:
10
}
[VB.NET]
Private Sub AxPageLayoutControl1_OnPageLayoutReplaced(ByVal sender As
System.Object, ByVal e As
ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnPageLayoutReplacedEvent)
Handles AxPageLayoutControl1.OnPageLayoutReplaced
'Load the same pre-authored map document into the MapControl.
AxMapControl1.LoadMxFile(AxPageLayoutControl1.DocumentFilename)
'Set the extent of the MapControl to the full extent of the data.
AxMapControl1.Extent = AxMapControl1.FullExtent
End Sub
Setting the TOCControl and ToolbarControl buddy controls
For the purpose of this application, the TOCControl and ToolbarControl will work in
conjunction with the PageLayoutControl, rather than the MapControl. To do this, the
PageLayoutControl must be set as the buddy control. The TOCControl uses the buddy
control's ActiveView to populate itself with maps, layers, and symbols, while any command,
tool, menu or palette items present on the ToolbarControl will interact with the buddy
control's display.
1. In the Form_Load event, type the following code before the load document code:
[C#]
private void MapViewer_Load(object sender, System.EventArgs e)
{
//Set buddy controls.
axTOCControl1.SetBuddyControl(axPageLayoutControl1);
axToolbarControl1.SetBuddyControl(axPageLayoutControl1);
//Load a pre-authored map document into the PageLayoutControl using relative paths.
}
[VB.NET]
Private Sub MapViewer_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Set buddy controls.
AxTOCControl1.SetBuddyControl(AxPageLayoutControl1)
11
AxToolbarControl1.SetBuddyControl(AxPageLayoutControl1)
12
1. Display the form in design mode and select axPageLayoutControl1 from the
Properties window. Click the Anchor property and anchor the PageLayoutControl to
the top, left, bottom, and right of the form. See the following screen shot:
2. Repeat to anchor the MapControl to the top, left, and bottom of the form. See the
following screen shot:
3. Display the form in design mode and select the form from the Properties window and
display the form events. Double-click the ResizeBegin event to add an event handler
to the code window.
4. In the Form_ResizeBegin event, enter the following code to draw a stretchy bitmap in
the PageLayoutControl and MapControl whenever the form is resized:
[C#]
private void MapViewer_ResizeBegin(object sender, EventArgs e)
{
//Suppress data redraw and draw bitmap instead.
axMapControl1.SuppressResizeDrawing(true, 0);
axPageLayoutControl1.SuppressResizeDrawing(true, 0);
}
[VB.NET]
Private Sub MapViewer_ResizeBegin(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.ResizeBegin
'Suppress data redraw and draw bitmap instead.
AxMapControl1.SuppressResizeDrawing(True, 0)
AxPageLayoutControl1.SuppressResizeDrawing(True, 0)
End Sub
13
5. Display the form in design mode and select the form from the Properties window and
display the form events. Double-click the ResizeEnd event to add an event handler to
the code window.
6. In the Form_ResizeEnd event, enter the following code to stop drawing a stretchy
bitmap in the PageLayoutControl and MapControl:
[C#]
private void MapViewer_ResizeEnd(object sender, EventArgs e)
{
//Stop bitmap draw and draw data.
axMapControl1.SuppressResizeDrawing(false, 0);
axPageLayoutControl1.SuppressResizeDrawing(false, 0);
}
[VB.NET]
Private Sub MapViewer_ResizeEnd(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.ResizeEnd
'Stop bitmap draw and draw data.
AxMapControl1.SuppressResizeDrawing(False, 0)
AxPageLayoutControl1.SuppressResizeDrawing(False, 0)
End Sub
7. Build and run the application, then try to resize the form.
Adding commands to the ToolbarControl
ArcGIS Engine comes with more than 230 commands and tools that work directly with the
MapControl, PageLayoutControl, and ToolbarControl. These commands and tools provide
you with a lot of frequently used GIS functionality for map navigation, map inquiry, graphics
management, and feature selection. In addition, there are commands and tools to work with
the ArcGIS Engine extensions. You will now add some of these commands and tools to your
application to work with the PageLayoutControl.
1. In the Form_Load event add the following code before the set buddy controls code:
[C#]
private void MapViewer_Load(object sender, EventArgs e)
{
//Add generic commands.
14
axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsAddDataCommand", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
//Add page layout navigation commands.
axToolbarControl1.AddItem("esriControls.ControlsPageZoomInTool", - 1, - 1,
true, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsPageZoomOutTool", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsPagePanTool", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsPageZoomWholePageCommand",
1, - 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
//Add map navigation commands.
axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", - 1, - 1,
true, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", - 1,
- 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem(
"esriControls.ControlsMapZoomToLastExtentBackCommand", - 1, - 1, false, 0,
esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem(
"esriControls.ControlsMapZoomToLastExtentForwardCommand", - 1, - 1, false,
0, esriCommandStyles.esriCommandStyleIconOnly);
//Add map inquiry commands.
axToolbarControl1.AddItem("esriControls.ControlsMapIdentifyTool", - 1, - 1,
true, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapFindCommand", - 1, - 1,
15
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapMeasureTool", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
16
AxToolbarControl1.AddItem("esriControls.ControlsMapZoomToLastExtentForwardC
ommand", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
'Add map inquiry commands.
AxToolbarControl1.AddItem("esriControls.ControlsMapIdentifyTool", -1, -1, True,
0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsMapFindCommand", -1, -1,
False, 0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsMapMeasureTool", -1, -1,
False, 0, esriCommandStyles.esriCommandStyleIconOnly)
17
[C#]
public partial class MapViewer: Form
{
//The pop-up menu.
private IToolbarMenu m_ToolbarMenu;
}
[VB.NET]
Public Class MapViewer
'The pop-up menu.
Private m_pToolbarMenu As IToolbarMenu
End Class
2. Add the following code to the Form_Load event after the code, add the commands to
the ToolbarControl but before the set buddy controls code.
[C#]
private void MapViewer_Load(object sender, EventArgs e)
{
//Add map inquiry commands.
18
19
20
5. Build and run the application. Right-click the PageLayoutControl's display area
to show the pop-up menu and navigate around the page layout. See the following
screen shot:
21
toolbarPalette.AddItem("esriControls.ControlsNewMarkerTool", - 1, - 1);
toolbarPalette.AddItem("esriControls.ControlsNewLineTool", - 1, - 1);
toolbarPalette.AddItem("esriControls.ControlsNewCircleTool", - 1, - 1);
toolbarPalette.AddItem("esriControls.ControlsNewEllipseTool", - 1, - 1);
toolbarPalette.AddItem("esriControls.ControlsNewRectangleTool", - 1, - 1);
toolbarPalette.AddItem("esriControls.ControlsNewPolygonTool", - 1, - 1);
//Add the ToolbarPalette to the ToolbarControl.
axToolbarControl1.AddItem(toolbarPalette, 0, - 1, false, 0,
esriCommandStyles.esriCommandStyleIconOnly);
22
2. Build and run the application. Use the palette on the ToolbarControl to add graphic
elements to the PageLayoutControl's display. See the following screen shot:
[C#]
private void MapViewer_Load(object sender, EventArgs e)
{
//Set label editing to manual.
axTOCControl1.LabelEdit = esriTOCControlEdit.esriTOCControlManual;
}
[VB.NET]
23
24
1. Add the following member variables to the class below the pop-up menu variable:
[C#]
public partial class MapViewer: Form
{
//The envelope drawn on the MapControl.
private IEnvelope m_Envelope;
//The symbol used to draw the envelope on the MapControl.
private Object m_FillSymbol;
//The PageLayoutControl's focus map events.
private ITransformEvents_Event m_transformEvents;
private ITransformEvents_VisibleBoundsUpdatedEventHandler visBoundsUpdatedE;
25
}
[VB.NET]
Public Class MapViewer
26
27
}
[VB.NET]
Private Sub MapViewer_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Create the symbol used on the MapControl.
CreateOverviewSymbol()
End Sub
4. Add the following OnVisibleBoundsUpdated function. This function will be linked to
an event raised when the extent of the map is changed, and is used to set the envelope
to the new visible bounds of the map. By refreshing the MapControl, you force it to
redraw the shape on its display.
[C#]
private void OnVisibleBoundsUpdated(IDisplayTransformation sender, bool
sizeChanged)
{
//Set the extent to the new visible extent.
m_Envelope = sender.VisibleBounds;
//Refresh the MapControl's foreground phase.
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground,
null, null);
}
[VB.NET]
Private Sub OnVisibleBoundsUpdated(ByVal sender As IDisplayTransformation,
ByVal sizeChanged As Boolean)
'Set the extent to the new visible extent.
m_pEnvelope = sender.VisibleBounds
'Refresh the MapControl's foreground phase.
AxMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground,
Nothing, Nothing)
End Sub
28
29
[C#]
private void axMapControl1_OnAfterDraw(object sender,
IMapControlEvents2_OnAfterDrawEvent e)
{
if (m_Envelope == null)
return ;
30
[VB.NET]
Private Sub AxMapControl1_OnAfterDraw(ByVal sender As System.Object, ByVal e
As ESRI.ArcGIS.Controls.IMapControlEvents2_OnAfterDrawEvent) Handles
AxMapControl1.OnAfterDraw
If m_pEnvelope Is Nothing Then Exit Sub
31
Navigating around the focus map using the map navigation tools will change the extent of the
focus map in the PageLayoutControl and cause the MapControl to update. Navigating around
the page layout with the page layout navigation tools will change the extent of the page layout
(not the extent of the focus map in the PageLayoutControl), so the MapControl will not
update.
Creating a custom tool
Creating custom commands and tools to work with the MapControl and PageLayoutControl
is very similar to creating commands for the ESRI ArcMap application that you may have
done previously. You will create a custom tool that adds a text element containing today's
date to the PageLayoutControl at the location of a mouse click. However, you will create the
command to work with the MapControl and ToolbarControl, as well as the
PageLayoutControl.
32
using ESRI.ArcGIS.Geometry;
[VB.NET]
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.Geometry
10. Update the code in the AddDateTool class constructor as shown in the following code
example:
The class constructor is a method that is called when the class is created. It can be used to set
up members of the class. In C# the constructor method has the same name as the class. It
differs from other methods in that it has no return type.
Instead of implementing the Bitmap, Caption, Category, Name, Message, and ToolTip
methods individually, you can set the values that should be returned from these methods and
rely on the BaseTool class to provide the implementation for these methods. The other
members will be left to return the default values as implemented by the BaseTool class.
[C#]
public AddDateTool()
{
base.m_category = "CustomMapViewer";
base.m_caption = "Add Date";
base.m_message = "Adds a date element to the active view";
base.m_toolTip = "Add Date";
base.m_name = "CustomMapViewer_AddDateTool";
try
{
string bitmapResourceName = GetType().Name + ".bmp";
base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
base.m_cursor = new Cursor(GetType(), GetType().Name + ".cur");
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
}
}
33
[VB.NET]
Public Sub New()
MyBase.New()
MyBase.m_category = "CustomMapViewer"
MyBase.m_caption = "Add Date"
MyBase.m_message = "Adds a date element to the active view"
MyBase.m_toolTip = "Add Date"
MyBase.m_name = "CustomMapViewer_AddDateTool"
Try
Dim bitmapResourceName As String = Me.GetType().Name + ".bmp"
MyBase.m_bitmap = New Bitmap(Me.GetType(), bitmapResourceName)
MyBase.m_cursor = New Cursor(Me.GetType(), Me.GetType().Name + ".cur")
Catch ex As Exception
System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap")
End Try
End Sub
11. Navigate to the overridden OnCreate method and look at the code.
The ICommand.OnCreate method is passed a handle or hook to the application that the
command will work with. In this case, it can be a MapControl, PageLayoutControl,
ToolbarControl, or the ArcMap application. Rather than adding code into the
OnCreate method to determine the type of hook that is being passed to the command, the
HookHelper is used to handle this. A command or tool needs to know how to handle the hook
it gets passed, so a check is needed to determine the type of ArcGIS Engine control that has
been passed. The HookHelper is used to hold the hook and return the ActiveView regardless
of the type of hook (in this case a MapControl, PageLayoutControl, ToolbarControl, or
ArcMap).
12. Navigate to the overridden OnMouseDown event and add the following code:
[C#]
public override void OnMouseDown(int Button, int Shift, int X, int Y)
{
//Get the active view.
IActiveView activeView = m_hookHelper.ActiveView;
34
35
pTextSymbol.Size = 25
36
14. In the Controls Windows Application project that you created at the beginning of this
scenario, add the following code before the ToolbarPalette code:
[C#]
private void MapViewer_Load(object sender, EventArgs e)
{
//Add map inquiry commands.
37
[C#]
public partial class MapViewer: Form
{
//The CustomizeDialog used by the ToolbarControl.
private ICustomizeDialog m_CustomizeDialog;
//The CustomizeDialog start event.
private ICustomizeDialogEvents_OnStartDialogEventHandler startDialogE;
//The CustomizeDialog close event.
private ICustomizeDialogEvents_OnCloseDialogEventHandler closeDialogE;
}
38
[VB.NET]
Public Class MapViewer
'The CustomizeDialog used by the ToolbarControl.
Private m_pCustomizeDialog As ICustomizeDialog
'The CustomizeDialog start event.
Private startDialogE As ICustomizeDialogEvents_OnStartDialogEventHandler
'The CustomizeDialog close event.
Private closeDialogE As ICustomizeDialogEvents_OnCloseDialogEventHandler
End Class
2. Create a new function called CreateCustomizeDialog. This is where you will create
the Customize dialog box by adding the following code to the function:
[C#]
private void CreateCustomizeDialog()
{
//Create a new Customize dialog box.
m_CustomizeDialog = new CustomizeDialogClass();
//Set the title.
m_CustomizeDialog.DialogTitle = "Customize ToolbarControl Items";
//Show the Add from File button.
m_CustomizeDialog.ShowAddFromFile = true;
//Set the ToolbarControl that new items will be added to.
m_CustomizeDialog.SetDoubleClickDestination(axToolbarControl1);
39
closeDialogE;
}
[VB.NET]
Private Sub CreateCustomizeDialog()
'Create a new Customize dialog box.
m_pCustomizeDialog = New CustomizeDialogClass()
'Set the title.
m_pCustomizeDialog.DialogTitle = "Customize ToolbarControl Items"
'Show the Add from File button.
m_pCustomizeDialog.ShowAddFromFile = True
'Set the ToolbarControl that new items will be added to.
m_pCustomizeDialog.SetDoubleClickDestination(AxToolbarControl1)
40
[VB.NET]
Private Sub MapViewer_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Create the Customize dialog box for the ToolbarControl.
CreateCustomizeDialog()
41
End Sub
7. Add the following OnStartDialog and OnCloseDialog event handlers. These functions
will be wired to events raised whenever the Customize dialog box is opened or closed.
[C#]
private void OnStartDialog()
{
axToolbarControl1.Customize = true;
}
42
10. Stop customizing the application. Use the select tool to move the text element
containing today's date.
Saving and loading ToolbarControl items
The contents of a ToolbarControl can be persisted into a user's profile when an application
exits to preserve any customizations made to the ToolbarControl by the end user. An
application can load the persisted contents back into the ToolbarControl at application start
time. You will persist the contents of the ToolbarControl into a file located in the same
directory as the applications executing assembly.
1. Create a new function called SaveToolbarControlItems. This is where you will persist
the contents of the ToolbarControl by adding the following code to the function:
[C#]
private void SaveToolbarControlItems(string filePath)
{
//Create a MemoryBlobStream.
IBlobStream blobStream = new MemoryBlobStreamClass();
//Get the IStream interface.
IStream stream = blobStream;
43
44
}
[VB.NET]
Private Sub LoadToolbarControlItems(ByVal filePath)
'Create a MemoryBlobStream.
Dim blobStream As IBlobStream
blobStream = New MemoryBlobStreamClass
'Get the IStream interface.
Dim stream As IStream
stream = blobStream
'Load the stream from the file.
blobStream.LoadFromFile(filePath)
'Load the stream into the ToolbarControl.
AxToolbarControl1.LoadItems(stream)
End Sub
3. Display the form in design mode and select the form from the Properties window and
display the form events. Double-click the FormClosing event to add an event handler
to the code window.
4. In the FormClosing event, enter the following code to persist the contents of the
ToolbarControl into a file at the same location as the executing assembly. You may
need to substitute "Controls.exe" with the name of your executable.
[C#]
private void MapViewer_FormClosing(object sender, FormClosingEventArgs e)
{
//Get file name to persist the ToolbarControl.
String filePath = System.Reflection.Assembly.GetExecutingAssembly()
.Location.Replace("Controls.exe", "") + @"\PersistedItems.txt";
//Persist ToolbarControl contents.
SaveToolbarControlItems(filePath);
}
[VB.NET]
Private Sub MapViewer_FormClosing(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
45
46
1, - 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
//Add map navigation commands.
axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", - 1, - 1,
true, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapFullExtentCommand", - 1,
- 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem(
"esriControls.ControlsMapZoomToLastExtentBackCommand", - 1, - 1, false, 0,
esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem(
"esriControls.ControlsMapZoomToLastExtentForwardCommand", - 1, - 1, false,
0, esriCommandStyles.esriCommandStyleIconOnly);
//Add map inquiry commands.
axToolbarControl1.AddItem("esriControls.ControlsMapIdentifyTool", - 1, - 1,
true, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapFindCommand", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
axToolbarControl1.AddItem("esriControls.ControlsMapMeasureTool", - 1, - 1,
false, 0, esriCommandStyles.esriCommandStyleIconOnly);
//Add custom AddDateTool.
axToolbarControl1.AddItem("Commands.AddDateTool", - 1, - 1, false, 0,
esriCommandStyles.esriCommandStyleIconAndText);
47
toolbarPalette.AddItem("esriControls.ControlsNewEllipseTool", - 1, - 1);
toolbarPalette.AddItem("esriControls.ControlsNewRectangleTool", - 1, - 1);
toolbarPalette.AddItem("esriControls.ControlsNewPolygonTool", - 1, - 1);
//Add the ToolbarPalette to the ToolbarControl.
axToolbarControl1.AddItem(toolbarPalette, 0, - 1, false, 0,
esriCommandStyles.esriCommandStyleIconOnly);
}
[VB.NET]
'Get file name used to persist the ToolbarControl.
Dim filePath As String
filePath =
System.Reflection.Assembly.GetExecutingAssembly.Location.Replace("Controls.exe",
"") & "\PersistedItems.txt"
If System.IO.File.Exists(filePath) Then
LoadToolbarControlItems(filePath)
Else
'Add generic commands.
AxToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, -1,
False, 0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsAddDataCommand", -1, -1,
False, 0, esriCommandStyles.esriCommandStyleIconOnly)
'Add page layout navigation commands.
AxToolbarControl1.AddItem("esriControls.ControlsPageZoomInTool", -1, -1, True,
0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsPageZoomOutTool", -1, -1,
False, 0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsPagePanTool", -1, -1, False, 0,
esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsPageZoomWholePageCommand",
-1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
'Add map navigation commands.
AxToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", -1, -1, True,
0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", -1, -1,
False, 0, esriCommandStyles.esriCommandStyleIconOnly)
48
49
8. Restart the application. The customizations you made to the ToolbarControl will be
reflected in the application.
Printing the page layout
The PageLayoutControl encapsulates the page layout that manages the page that can be sent
to any available printer. You will add code to allow users to send output to the system default
printer.
1. Display the form in design mode and select MenuStrip control on the form.
2. Click Type Here and type File to create a File menu.
3. On the File menu click Type Here and type Print to create a menu item.
4. Double click the Print menu item to add an event handler to the code window.
5. In the PrintToolStripMenuItem_Click event, enter the following code to send the
page to the printer:
[C#]
private void printToolStripMenuItem_Click(object sender, EventArgs e)
{
//Exit if there is no system default printer.
if (axPageLayoutControl1.Printer == null)
{
MessageBox.Show("Unable to print!", "No default printer");
return ;
}
50
51
Deployment
To successfully deploy this application on a user's machine:
The application's executable and the .dll and .tlb files containing the custom command
will need to be deployed on the user's machine. The Assembly Registration tool
(RegAsm.exe) must be used to add information about the custom class to the registry.
The user's machine will need an installation of the ArcGIS Engine Runtime and a
standard ArcGIS Engine license.
The user's machine will need an installation of the Microsoft .NET Framework 2.0.
Additional resources
The following resources may help you understand and apply the concepts and techniques
presented in this scenario:
Additional documentation is available in the ArcGIS Engine SDK for the Microsoft
.NET Framework. This includes component help, object model diagrams, and samples
to help you get started.
ESRI Developer Network (EDN) Web site provides the most up-to-date information
for ArcGIS developers including updated samples and technical documents. See
http://edn.esri.com.
ESRI online discussion forums provide invaluable assistance from other ArcGIS
developers. See http://support.esri.com and click the User Forums tab.
52
Microsoft documentation is also available for the Visual Studio .NET development
environment. See http://msdn.com.
See Also:
How to write your first MapControl application
53
- Creating a palette of tools from the commands and adding it to the ToolbarControl
- Managing the way map and layer labels are edited in the TOCControl using the LabelEdit
property and the ITOCControlEvents.OnEndLabelEdit event
- Using the MapControl as an overview window by using the DrawShape method to highlight
the current extent of data in the PageLayoutControl
- Creating a custom Add Date command that works with the PageLayoutControl,
ToolbarControl, and MapControl
- Customizing the ToolbarControl with the Customize property and displaying the
CustomizeDialog to the end user at runtime
- Persisting the ToolbarControl items using the SaveItems and LoadItems methods
- Printing the contents of the PageLayoutControl using the PrintPageLayout method
Development licensing Deployment licensing
Engine Developer Kit
Engine Runtime
ArcView
ArcEditor
ArcInfo
How to use
See Using the samples for help on compiling, setting up the debugger, and running the sample
(either an exe or dll).
Using the ArcGIS samples
SummaryEach sample provides a description of how to get that particular sample to work, but
there are common tasks you need, which you are assumed to be familiar with. These include
opening the solution, compiling, setting up for debugging, running the sample, and
unregistering it when you are done.
In this topic
About using the ArcGIS samples
Opening solution files
Compiling samples
Debugging samples
Debugging DLLs
Running samples
54
Running EXEs
Running DLLs
Unregistering DLLs
About using the ArcGIS samples
The ArcGIS Software Developer Kits (SDKs) contain a number of samples for you to use.
Each sample has an associated README file that provides the steps for using that
sample. This file is located in the help system or in HyperText Markup Language (HTML)
format on disk in the sample's folder. However, there are a few steps that must be taken for all
samples. The following first two steps are common to all samples:
Opening solution files
Compiling samples
The next steps (debugging and running the sample) differ based on the type of sample
you use. The following are the sample types:
Sample type
Description
Executables
Class libraries Create .dll files that are used through other
and
applications, such as ArcMap or a controls
components
application. Some examples of dynamic-link
libraries (DLLs) are commands, tools,
extensions, custom layers, custom renderers, and
custom symbols.
Debugging samples (optional step)
Running samples
Running EXEs
Unregistering DLLs
When you are done using a sample's DLL, you can unregister it.
Visual Studio settingsThe first time you start Visual Studio 2005, you are prompted to
choose development settings. Choosing different settings changes the options displayed in
Visual Studio. Unless specified, dialog boxes and menu commands discussed in this
55
document are defined based on the general development settings in Visual Studio
2005 Professional Edition.
Opening solution files
In Windows Explorer, browse to the sample's location on disk. The location will be in <Your
ArcGIS install location>/DeveloperKit/SamplesNET (Desktop or Engine folder or both) with
the folder name in the README file. Open the C# or VB.NET version and double-click the
solution file (.sln) to open in Visual Studio 2005. See the following screen shot:
In the installed developer help system, the sample's location is in the sample's
README file at the bottom of the document.
If opening a sample downloaded from the ESRI Developer Network (EDN) Web site,
the README files will be found where you saved the ZIP file.
Compiling samples
In the opened Visual Studio 2005 solution for the sample, choose Build Solution from the
Build menu or press F6 to compile the sample.
Some samples can have code updates or edits you need to make, such as pointing the
sample to data located on your machine. These steps are highlighted in the README's How
to use section and should be completed before you compile.
Debugging samples
This step is optional, as samples do not require debugging. However, stepping through the
code of the sample to see what it is doing can be beneficial. To view what is happening, set
breakpoints in the opened Visual Studio 2005 project so that code execution stops. To set
breakpoints, click the border in Visual Studio next to the line of code where you want a
breakpoint placed. If you want to debug an EXE, you can at this point. If you want to debug a
DLL, set up the external application to use for debugging. For more information, see
Debugging DLLs.
56
Before starting a debugging session, make sure the active configuration is set to Debug. Start
the project by choosing Start Debugging on the Debug menu or press F5. The application (the
.exe or the external one that was set for the .dll) launches. Interact as directed by the How to
use steps in the README and outlined in Running samples. As you hit the breakpoints that
were set, focus switches back to Visual Studio.
Debugging DLLs
Since a DLL is used through another application, you must set up Visual Studio to use that
application as the debugging start action if you want to debug the DLL code. Access the
opened sample project in Visual Studio 2005. If there is a Properties entry in the Solution
Explorer, double-click it. If not, click the Project menu and select <Project name>
Properties. When the property pages open, click the Debug tab and, in the Start Action
section, choose Start external program; be sure to choose Debug in the Configuration dropdown list.
Next, set the external program that you want to use. The README file helps you figure out
which of the following options you should choose:
ArcGIS Desktop SDKIf the sample creates a DLL that only works with ArcMap,
ArcCatalog, ArcGlobe, or ArcScene, set the external application to the ArcGIS
application where the custom class is used. Browse to the location of the .exe for that
application, located in <your ArcGIS install location>/Bin (for example, <your
ArcGIS install location>/Bin/ArcMap.exe).
ArcGIS Engine SDKIf the sample creates a .dll that works in a controls
application, browse to the location of the controls application to use. If you do not
have one, refer to the help topics under the following nodes in the ArcGIS Engine
SDK: Building solutions with ArcGIS Engine using .NET, Working with ArcGIS
components, ArcGIS Engine controls.
If you are working with a sample command or tool that can be added to ArcMap or a
controls application, use the previous ArcGIS Desktop SDK or ArcGIS Engine
SDK option, depending on the one you have installed.
If you are using Visual C# 2005 Express Edition or Visual Basic 2005 Express Edition, you
cannot debug DLLs because these versions do not have the option to start an external
application for debugging.
Running samples
Now that you have opened and compiled the sample, it is ready to use. Refer to the Additional
Requirements and How to use sections of the sample's README file to see if you need to
take additional steps before using the sample (adding specific data, starting an edit session,
and so on).
Running EXEs
An executable sample can be used like any .exe on your machine by double-clicking the
compiled .exe in Windows Explorer. Alternatively, you can run the .exe in debug mode as
discussed in Debugging samples.
57
Running DLLs
If the sample produces a DLL, this indicates that the sample will provide custom classes to
extend ArcGIS applications, such as a custom command. The sample's README
file indicates the applicationone of the ArcGIS applications or a custom onethe custom
class should be used with. To use it, start the application and follow the README steps for
using the sample.
DLLs need to be registered with the Component Object Model (COM) and can require
registering classes to component categories. The sample code takes care of this registration,
and the samples will be registered appropriately at compile time.
Adding commands or tools to a toolbar
Running a command or tool DLL involves adding it to a toolbar. The sample's README
file indicates the kind of toolbar the command or tool works with and provides both the
category the command or tool is in and the name of the command or tool. The following
outlines the necessary steps to take based on the kind of toolbar the command or tool works
with:
An ArcGIS Desktop application (ArcMap, ArcCatalog, ArcGlobe, or ArcScene):
1. Run the application the tool or command works with.
2. Click the Tools menu and choose Customize to open the Customize dialog
box.
3. Click the Commands tab.
4. Click the command or tool in the Categories pane.
5. In the Commands pane, click the command or tool. Drag and drop the
command or tool and place it on the toolbar.
An ArcGIS Engine controls application (on the ToolbarControl):
58
ToolbarControl1.AddItem sProgID
2. Add the command or tool through the ToolbarControl property pages:
a. In the design view of the application, right-click the ToolbarControl.
b. On the property page, click the Items tab, then click the Add button to
open the Control Commands dialog box.
c. Click the command or tool category in the Categories pane.
d. In the Commands pane, click the command or tool. Double-click the
command or tool, or drag and drop it on the toolbar on the Items tab of
the property page.
The Allow run time customization of the ToolbarControl is a recommended sample that is
used to test sample tools and commands (only applies to ArcGIS Engine). The sample needs
to be placed on a ToolbarControl that is buddied with a MapControl. The following is the
sample's location:
<your ArcGIS install
location>/DeveloperKit/SamplesNET/Engine/ToolbarControlCustomization
If you have not used this sample, choose the C# or VB.NET version of the sample and
compile it, then browse to and launch the created .exe.
1. Click the Customize check box to open the Control Commands dialog box and click
the Commands tab.
2. Choose the category the command is in from the Categories pane, click the command
or tool from the Commands pane, then drag and drop it on the application's toolbar.
For one of the ArcGIS Desktop applications or a controls applicationdepending on
what you have installed on your machinefollow the previous steps for ArcGIS
Desktop or ArcGIS Engine.
Unregistering DLLs
You can unregister a DLL sample from your machine when you are done. To unregister
a DLL, use the Assembly Registration Tool (regasm.exe) with the command line flag
/unregister; for example, regasm MySample.dll/unregister.
Regasm.exe can be found in %windir%\Microsoft.NET\Framework\v2.0.xxxx (where xxxx is
the build number of the .NET framework you are using).
On the taskbar, click Start and click Run. In the Run dialog box, type cmd to get a command
prompt.
See Also:
Sample: Allow run time customization of the ToolbarControl (Engine only)
59
22.Form file.
(view code)
Controls/AssemblyInfo.cs
Assembly information.
(view code)
Controls/AssemblyInfo.vb
Assembly information.
60
See Also:
Building a map viewing application using the ArcGIS Engine controls
22.
Building a MapViewer application using the ArcGIS Engine controls
Controls\MapViewer.vb
' Copyright 2006 ESRI
'
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
'
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
'
' See the use restrictions.
'
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.SystemUI
Imports ESRI.ArcGIS.esriSystem
61
62
63
64
AxToolbarControl1.SetBuddyControl(AxPageLayoutControl1)
'Load a pre-authored map document into the PageLayoutControl using realative paths
Dim sFileName As String =
"..\..\..\..\data\GulfOfStLawrence\Gulf_of_St._Lawrence.mxd"
If AxPageLayoutControl1.CheckMxFile(sFileName) Then
AxPageLayoutControl1.LoadMxFile(sFileName)
End If
End Sub
65
66
pColor.RGB = RGB(255, 0, 0)
'Get the ILine symbol interface
Dim pOutline As ILineSymbol
pOutline = New SimpleLineSymbolClass
'Set the line symbol properties
pOutline.Width = 1.5
pOutline.Color = pColor
'Get the ISimpleFillSymbol interface
m_pFillSymbol = New SimpleFillSymbolClass
'Set the fill symbol properties
m_pFillSymbol.Outline = pOutline
m_pFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow
End Sub
67
AxMapControl1.DrawShape(m_pEnvelope, m_pFillSymbol)
End If
End Sub
68
69
blobStream.LoadFromFile(filePath)
'Load the stream into the ToolbarControl
AxToolbarControl1.LoadItems(stream)
End Sub
End Class
70
33.
Building a MapViewer application using the ArcGIS Engine controls
Commands\AddDateTool.vb
' Copyright 2006 ESRI
'
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
'
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
'
' See the use restrictions.
'
Imports System.Runtime.InteropServices
Imports System.Drawing
Imports ESRI.ArcGIS.ADF.BaseClasses
Imports ESRI.ArcGIS.ADF.CATIDs
Imports ESRI.ArcGIS.Controls
Imports System.Windows.Forms
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.Geometry
71
End Sub
<ComUnregisterFunction(), ComVisibleAttribute(False)> _
Public Shared Sub UnregisterFunction(ByVal registerType As Type)
' Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType)
End Sub
72
End Sub
#End Region
#End Region
MyBase.m_category = "CustomMapViewer"
MyBase.m_caption = "Add Date"
MyBase.m_message = "Adds a date element to the active view"
MyBase.m_toolTip = "Add Date"
MyBase.m_name = "CustomMapViewer_AddDateTool"
Try
Dim bitmapResourceName As String = Me.GetType().Name + ".bmp"
MyBase.m_bitmap = New Bitmap(Me.GetType(), bitmapResourceName)
MyBase.m_cursor = New Cursor(Me.GetType(), Me.GetType().Name + ".cur")
Catch ex As Exception
System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap")
End Try
End Sub
73
End If
End Sub
74
75
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.SystemUI
Imports ESRI.ArcGIS.esriSystem
76
77
78
'Load a pre-authored map document into the PageLayoutControl using realative paths
79
End Sub
80
AxPageLayoutControl1.SuppressResizeDrawing(True, 0)
End Sub
81
82
83
End Sub
84
End Sub
End Class
85
55
Building a MapViewer application using the ArcGIS Engine controls
Commands\AddDateTool.vb
' Copyright 2006 ESRI
'
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
'
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
'
' See the use restrictions.
'
Imports System.Runtime.InteropServices
Imports System.Drawing
Imports ESRI.ArcGIS.ADF.BaseClasses
Imports ESRI.ArcGIS.ADF.CATIDs
Imports ESRI.ArcGIS.Controls
Imports System.Windows.Forms
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Display
Imports ESRI.ArcGIS.Geometry
86
End Sub
<ComUnregisterFunction(), ComVisibleAttribute(False)> _
Public Shared Sub UnregisterFunction(ByVal registerType As Type)
' Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType)
End Sub
87
End Sub
#End Region
#End Region
MyBase.m_category = "CustomMapViewer"
MyBase.m_caption = "Add Date"
MyBase.m_message = "Adds a date element to the active view"
MyBase.m_toolTip = "Add Date"
MyBase.m_name = "CustomMapViewer_AddDateTool"
Try
Dim bitmapResourceName As String = Me.GetType().Name + ".bmp"
MyBase.m_bitmap = New Bitmap(Me.GetType(), bitmapResourceName)
MyBase.m_cursor = New Cursor(Me.GetType(), Me.GetType().Name + ".cur")
Catch ex As Exception
System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap")
End Try
End Sub
88
End If
End Sub
89
90
91