private void cmdOpen_Click(object sender, System.EventArgs e)
{
//Open a file dialog for selecting map documents
openFileDialog1.Title = "Select Published Map Document";
openFileDialog1.Filter = "Published Map Documents (*.pmf)|*.pmf";
openFileDialog1.ShowDialog();
//Exit if no map document is selected
string sFilePath = openFileDialog1.FileName;
if (sFilePath == "") return;
//Load the specified pmf
if (axArcReaderControl1.CheckDocument(sFilePath) == true)
{
axArcReaderControl1.LoadDocument(sFilePath,"");
}
else
{
System.Windows.Forms.MessageBox.Show("This document cannot be loaded!");
return;
}
//Disable search & map tools
cboLayers.Items.Clear();
cboFields.Items.Clear();
EnableSearchTools (false);
EnableMeetHighlightTools (false);
EnableFailHighlightTools (false);
//Determine whether permission to search layers and query field values
bool bqueryFeatures = axArcReaderControl1.HasDocumentPermission(esriARDocumentPermissions.esriARDocumentPermissionsQueryFeatures);
bool bqueryValues = axArcReaderControl1.HasDocumentPermission(esriARDocumentPermissions.esriARDocumentPermissionsQueryValues);
if (bqueryFeatures==false || bqueryValues==false)
{
System.Windows.Forms.MessageBox.Show("The selected Document does not have Query Permissions.");
return;
}
//Add map layers to combo and store in HashTable with combo index
m_LayersIndex = new Hashtable();
ARPopulateComboWithMapLayers(cboLayers, m_LayersIndex);
//Select first searchable layer
for(int i=0; i <= cboLayers.Items.Count-1; i++)
{
ARLayer arLayer = (ARLayer)m_LayersIndex[i];
if (arLayer.Searchable==true)
{
cboLayers.SelectedIndex=i;
break;
}
}
//Enable Search & Map Tools
EnableSearchTools(true);
EnableMapTools(true);
}
private void ARPopulateComboWithMapLayers(ComboBox Layers, System.Collections.Hashtable LayersIndex)