MobileWalkthroughPPCNET
Form1.cs
// 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 use restrictions at /arcgis/developerkit/userestrictions.
//
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Text;
using
System.Windows.Forms;
using
ESRI.ArcGIS.Mobile;
namespace
MobilePocketPCApp
{
public
partial class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private void
radioButton1_CheckedChanged(object
sender, EventArgs e)
{
map1.CurrentMapAction = panMapAction1;
}
private void
radioButton2_CheckedChanged(object
sender, EventArgs e)
{
map1.CurrentMapAction = zoomInMapAction1;
}
private void
radioButton3_CheckedChanged(object
sender, EventArgs e)
{
map1.CurrentMapAction = zoomOutMapAction1;
}
private void
radioButton4_CheckedChanged(object
sender, EventArgs e)
{
map1.CurrentMapAction = null;
}
private void
map1_MouseDown(object
sender, MapMouseEventArgs e)
{
if
(map1.CurrentMapAction != null
)
return;
Cursor.Current = Cursors.WaitCursor;
MapMouseEventArgs me = e as
MapMouseEventArgs;
Envelope qEnv = new
Envelope(me.MapCoordinate, me.MapCoordinate);
int
mapTolerance = map1.ToMap(3);
qEnv.Resize(mapTolerance, mapTolerance);
QueryFilter qFilter = new
QueryFilter(qEnv, EsriGeometricRelationship.Intersect);
string
txtResult = "Identify Results: ";
int
intFields;
foreach
(MapLayer lyr in
map1.MapLayers)
{
FeatureLayer featLayerDT = lyr.Layer as
FeatureLayer;
if
(featLayerDT == null
)
continue;
txtResult += "\r\nLayer " + featLayerDT.Name;
using
(FeatureDataReader featReader = featLayerDT.GetDataReader(qFilter))
{
intFields = featReader.FieldCount;
while
(featReader.Read())
{
for
(int
i = 0; i < intFields; i++)
txtResult += "\r\n" + featReader.GetName(i) + ": " + featReader.GetValue(i).ToString();
}
}
}
Cursor.Current = Cursors.Default;
MessageBox.Show(txtResult);
}
private void
Form1_Load(object
sender, EventArgs e)
{
if
(!mapCache1.IsValid)
{
MessageBox.Show("Map Cache is not valid!");
return;
}
try
{
mapCache1.Open();
}
catch
{
MessageBox.Show("Cannot open map cache");
}
}
}
}