Developing with .NET


Summary
This section includes summary information the .NET Framework and why it is important to an ArcGIS Explorer developer. It is not necessary to have a complete and full understanding of the .NET framework in order to develop customizations; however, increased understanding will aid in your ability to create customizations using .NET.

For further information about the supported .NET development environment for ArcGIS Explorer, Microsoft Visual Studio, see the Using Visual Studio topic.

The .NET Framework

The Microsoft .NET Framework is a platform for building, deploying, and running Web Services and applications. It provides a highly productive, standards-based, multi-language environment for integrating existing investments with next-generation applications and services as well as the agility to solve the challenges of deployment and operation of Internet-scale applications.
The .NET Framework consists of three main interrelated pieces:
  • The common language runtime (CLR) which is the runtime environment for .NET code.
  • A hierarchical set of unified class libraries called the Base Class Libraries (BCL) which provide a wide range of built-in functionality, such as drawing, maths, and communication functionality, user interface components, and much more.
  • A componentized version of Active Server Pages called ASP.NET.
For more information about the .NET Framework, refer to the Microsoft Developer Network (MSDN) website at http://msdn.microsoft.com.

Targeting Framework Versions

Different, concurrent versions of the .NET Framework are available.
ArcGIS Explorer supports the .NET Framework version 3.5 SP1, which is a prerequisite to install ArcGIS Explorer (the ArcGIS Explorer SDK for Microsoft .NET Framework has ArcGIS Explorer as a prerequisite).
Later versions of the .NET Framework exist; however, you should not rely on these later versions being present on other machines to which you deploy customizations.
If you need to introduce dependencies on other versions of the .NET Framework, you will need to ensure that the requisite Framework installations are present on any machines to which you deploy your customizations. This issue is particularly relevant given the multi-targeting ability of Visual Studio 2008 and Visual Studio 2010, the supported development environments.
Using .NET Framework 3.5 Capabilities
The .NET Framework 3.5 contains several new capabilities that you may wish to make use of when developing Add-ins using the ArcGIS Explorer SDK, see MSDNs What's New in the .NET Framework page for more information.
Windows Presentation Foundation (WPF) was introduced at the 3.0 release, and although ArcGIS Explorer uses Windows Forms technology there is no reason why you cannot make use of WPF within your Add-ins. A good example is provided by the WPF Overview Map Add-in which is hosted on the ArcGIS Explorer Resource Center.
An important new feature of the 3.5 release is Language Integrated Query (LINQ) that essentially adds formal query capabilities into Microsoft .NET-based programming languages. The code example below shows how you could make use of a LINQ query to find all point graphics which are tagged to a specific group. Note that the example also demonstrates two other .NET 3.5 features:
  • Concise object initialization using the {} syntax 
  • Implicit variable declaration (var keyword in c#)
[C#]
//Creat some geometries
ESRI.ArcGISExplorer.Geometry.Point pnt1 = new
    ESRI.ArcGISExplorer.Geometry.Point(1, 1);
ESRI.ArcGISExplorer.Geometry.Point pnt2 = new
    ESRI.ArcGISExplorer.Geometry.Point(1, 2);
ESRI.ArcGISExplorer.Geometry.Point pnt3 = new
    ESRI.ArcGISExplorer.Geometry.Point(2, 2);
ESRI.ArcGISExplorer.Geometry.Point pnt4 = new
    ESRI.ArcGISExplorer.Geometry.Point(2, 1);
Polyline line1 = new Polyline(new List < ESRI.ArcGISExplorer.Geometry.Point > 
{
    pnt1, pnt2, pnt3, pnt4
}

);
Polygon pgon1 = new Polygon(new List < ESRI.ArcGISExplorer.Geometry.Point > 
{
    pnt1, pnt2, pnt3, pnt4
}

);
pgon1.Close();
//Create some graphics
List < Graphic > graphics = new List < Graphic > ()
{
    new Graphic
    {
        Geometry = pnt1, Label = "Point 1", Tag = "Group1"
    }
    , new Graphic
    {
        Geometry = pnt2, Label = "Point 2", Tag = "Group2"
    }
    , new Graphic
    {
        Geometry = pnt3, Label = "Point 3", Tag = "Group1"
    }
    , new Graphic
    {
        Geometry = line1, Label = "Line 1", Tag = "Group1"
    }
    , new Graphic
    {
        Geometry = pgon1, Label = "Polygon 1", Tag = "Group3"
    }
};
//Add the graphics to the map display
ESRI.ArcGISExplorer.Mapping.MapDisplay disp =
    ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay;
disp.Graphics.Add(graphics);
//Perform LINQ query to find all the point graphics which are in Group 1
var pointGraphicsTaggedInGroup1 = from graphic in disp.Graphics where(
    (graphic.Geometry.GeometryType == GeometryType.Point) && 
    (graphic.Tag.ToString() == "Group1"))select graphic;
//Iterate and print out the results, which are:
//Point 1, Group1
//Point 3, Group1
foreach (var graphic in pointGraphicsTaggedInGroup1)
{
    System.Diagnostics.Debug.Print(graphic.Label + ", " + graphic.Tag.ToString()
                                   );
}
[VB.NET]
'Creat some geometries
Dim pnt1 As New ESRI.ArcGISExplorer.Geometry.Point(1, 1)
Dim pnt2 As New ESRI.ArcGISExplorer.Geometry.Point(1, 2)
Dim pnt3 As New ESRI.ArcGISExplorer.Geometry.Point(2, 2)
Dim pnt4 As New ESRI.ArcGISExplorer.Geometry.Point(2, 1)
Dim pointsList As New List(Of ESRI.ArcGISExplorer.Geometry.Point)()
pointsList.Add(pnt1)
pointsList.Add(pnt2)
pointsList.Add(pnt3)
pointsList.Add(pnt4)
Dim line1 As New Polyline(pointsList)
Dim pgon1 As New Polygon(pointsList)
pgon1.Close()
'Create some graphics
Dim graphics As New List(Of Graphic)()
graphics.Add(New Graphic() With {.Geometry = pnt1, .Label = "Point 1", .Tag = "Group1"})
graphics.Add(New Graphic() With {.Geometry = pnt2, .Label = "Point 2", .Tag = "Group2"})
graphics.Add(New Graphic() With {.Geometry = pnt3, .Label = "Point 3", .Tag = "Group1"})
graphics.Add(New Graphic() With {.Geometry = line1, .Label = "Line 1", .Tag = "Group1"})
graphics.Add(New Graphic() With {.Geometry = pgon1, .Label = "Polygon 1", .Tag = "Group3"})
'Add the graphics to the map display
Dim disp As ESRI.ArcGISExplorer.Mapping.MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay
disp.Graphics.Add(Graphics)
'Perform LINQ query to find all the point graphics which are in Group 1
Dim pointGraphicsTaggedInGroup1 = From graphic In disp.Graphics _
                                  Where ((graphic.Geometry.GeometryType = GeometryType.Point) AndAlso (graphic.Tag.ToString() = "Group1")) _
                                  Select graphic
'Iterate and print out the results, which are:
'Point 1, Group1
'Point 3, Group1
For Each grphic As Graphic In pointGraphicsTaggedInGroup1
    System.Diagnostics.Debug.Print((Convert.ToString(grphic.Label) & ", ") + grphic.Tag.ToString())
Next
The Visual Studio Tools for ArcGIS Explorer wizard automatically adds the appropriate assembly references to an Add-in project and using (C#)/ Imports (VB.NET) statements to a class to support LINQ queries.

Development Environments for the .NET Framework

ArcGIS Explorer supports development with all editions of Microsoft Visual Studio 2008 Service Pack 1 (SP1) and Microsoft Visual Studio 2010; this is a prerequisite for installing the ArcGIS Explorer SDK for Microsoft .NET Framework.
Development with other .NET environments is not supported by ESRI; this includes previous versions of Microsoft Visual Studio, as the help system and tools which are essential components of the SDK require Microsoft Visual Studio 2008 or 2010 in order to be installed.
If you do not have Microsoft Visual Studio 2008 SP1 or 2010, you may wish to download and install the free Express editions, Microsoft Visual C# Express or Microsoft Visual Basic Express, which are supported by ArcGIS Explorer.
See the Using Visual Studio topic for more information.