hahaaluo
路人甲
路人甲
  • 注册日期2006-08-05
  • 发帖数146
  • QQ
  • 铜币591枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1673回复:3

我做了个查找的.........

楼主#
更多 发布于:2006-09-11 20:23
<P>最近看到帮助有个Find Samples的 就想也做一个,不过运行Find Samples时都不行,请高手们  帮忙看看   帮个忙  ,谢谢你们~~~~~~~</P>
喜欢0 评分0
hahaaluo
路人甲
路人甲
  • 注册日期2006-08-05
  • 发帖数146
  • QQ
  • 铜币591枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-09-11 20:27
<P>using System;<BR>using System.Drawing;<BR>using System.Collections;<BR>using System.ComponentModel;<BR>using System.Windows.Forms;<BR>using System.Data;<BR>using System.IO;<BR>using ESRI.ArcGIS.SystemUI;<BR>using ESRI.ArcGIS.ArcReaderControl;</P>
<P>namespace Find<BR>{<BR> /// <summary><BR> /// Summary description for Form1.<BR> /// </summary><BR> public class Form1 : System.Windows.Forms.Form<BR> {<BR>  public System.Windows.Forms.Button cmdLoad;<BR>  public System.Windows.Forms.TextBox txbPath;<BR>  public System.Windows.Forms.Label Label1;<BR>  public System.Windows.Forms.Label Label6;<BR>  public System.Windows.Forms.Label Label5;<BR>  public System.Windows.Forms.Label Label3;<BR>  public System.Windows.Forms.Label Label2;<BR>  public System.Windows.Forms.ComboBox cboLayers;<BR>  public System.Windows.Forms.Button cmdFlicker;<BR>  public System.Windows.Forms.Button cmdFlash;<BR>  public System.Windows.Forms.Button cmdFindNext;<BR>  public System.Windows.Forms.Button cmdFind;<BR>  private ArcReaderSearchDef m_SearchDef;<BR>  private IARFeatureCursor m_FeatureCursor;<BR>  private IARFeature m_Feature;<BR>  private System.Collections.SortedList m_LayerCollection = new System.Collections.SortedList();<BR>  private ESRI.ArcGIS.ArcReaderControl.AxArcReaderControl axArcReaderControl2;<BR>  /// <summary><BR>  /// Required designer variable.<BR>  /// </summary><BR>  private System.ComponentModel.Container components = null;</P>
<P>  public Form1()<BR>  {<BR>   //<BR>   // Required for Windows Form Designer support<BR>   //<BR>   InitializeComponent();</P>
<P>   //<BR>   // TOD Add any constructor code after InitializeComponent call<BR>   //<BR>  }</P>
<P>  /// <summary><BR>  /// Clean up any resources being used.<BR>  /// </summary><BR>  protected override void Dispose( bool disposing )<BR>  {<BR>   if( disposing )<BR>   {<BR>    if (components != null)<BR>    {<BR>     components.Dispose();<BR>    }<BR>   }<BR>   base.Dispose( disposing );<BR>  }</P>
<P>  #region Windows Form Designer generated code<BR>  /// <summary><BR>  /// Required method for Designer support - do not modify<BR>  /// the contents of this method with the code editor.<BR>  /// </summary><BR>  private void InitializeComponent()<BR>  {<BR>   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));<BR>   this.cmdLoad = new System.Windows.Forms.Button();<BR>   this.txbPath = new System.Windows.Forms.TextBox();<BR>   this.Label1 = new System.Windows.Forms.Label();<BR>   this.Label6 = new System.Windows.Forms.Label();<BR>   this.Label5 = new System.Windows.Forms.Label();<BR>   this.Label3 = new System.Windows.Forms.Label();<BR>   this.Label2 = new System.Windows.Forms.Label();<BR>   this.cboLayers = new System.Windows.Forms.ComboBox();<BR>   this.cmdFlicker = new System.Windows.Forms.Button();<BR>   this.cmdFlash = new System.Windows.Forms.Button();<BR>   this.cmdFindNext = new System.Windows.Forms.Button();<BR>   this.cmdFind = new System.Windows.Forms.Button();<BR>   this.axArcReaderControl2 = new ESRI.ArcGIS.ArcReaderControl.AxArcReaderControl();<BR>   ((System.ComponentModel.ISupportInitialize)(this.axArcReaderControl2)).BeginInit();<BR>   this.SuspendLayout();<BR>   // <BR>   // cmdLoad<BR>   // <BR>   this.cmdLoad.BackColor = System.Drawing.SystemColors.Control;<BR>   this.cmdLoad.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.cmdLoad.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.cmdLoad.ForeColor = System.Drawing.SystemColors.ControlText;<BR>   this.cmdLoad.Location = new System.Drawing.Point(470, 9);<BR>   this.cmdLoad.Name = "cmdLoad";<BR>   this.cmdLoad.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.cmdLoad.Size = new System.Drawing.Size(98, 27);<BR>   this.cmdLoad.TabIndex = 3;<BR>   this.cmdLoad.Text = "Load PMF";<BR>   this.cmdLoad.Click += new System.EventHandler(this.cmdLoad_Click);<BR>   // <BR>   // txbPath<BR>   // <BR>   this.txbPath.AcceptsReturn = true;<BR>   this.txbPath.AutoSize = false;<BR>   this.txbPath.BackColor = System.Drawing.SystemColors.Window;<BR>   this.txbPath.Cursor = System.Windows.Forms.Cursors.IBeam;<BR>   this.txbPath.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.txbPath.ForeColor = System.Drawing.SystemColors.WindowText;<BR>   this.txbPath.Location = new System.Drawing.Point(10, 9);<BR>   this.txbPath.MaxLength = 0;<BR>   this.txbPath.Name = "txbPath";<BR>   this.txbPath.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.txbPath.Size = new System.Drawing.Size(452, 27);<BR>   this.txbPath.TabIndex = 2;<BR>   this.txbPath.Text = "";<BR>   // <BR>   // Label1<BR>   // <BR>   this.Label1.BackColor = System.Drawing.SystemColors.Control;<BR>   this.Label1.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.Label1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.Label1.ForeColor = System.Drawing.SystemColors.Highlight;<BR>   this.Label1.Location = new System.Drawing.Point(586, 129);<BR>   this.Label1.Name = "Label1";<BR>   this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.Label1.Size = new System.Drawing.Size(241, 27);<BR>   this.Label1.TabIndex = 16;<BR>   this.Label1.Text = "5) Loop though any other features that were found.";<BR>   // <BR>   // Label6<BR>   // <BR>   this.Label6.BackColor = System.Drawing.SystemColors.Control;<BR>   this.Label6.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.Label6.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.Label6.ForeColor = System.Drawing.SystemColors.Highlight;<BR>   this.Label6.Location = new System.Drawing.Point(586, 69);<BR>   this.Label6.Name = "Label6";<BR>   this.Label6.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.Label6.Size = new System.Drawing.Size(241, 18);<BR>   this.Label6.TabIndex = 15;<BR>   this.Label6.Text = "3) Enter a search string to find.";<BR>   // <BR>   // Label5<BR>   // <BR>   this.Label5.BackColor = System.Drawing.SystemColors.Control;<BR>   this.Label5.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.Label5.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.Label5.ForeColor = System.Drawing.SystemColors.Highlight;<BR>   this.Label5.Location = new System.Drawing.Point(586, 95);<BR>   this.Label5.Name = "Label5";<BR>   this.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.Label5.Size = new System.Drawing.Size(241, 27);<BR>   this.Label5.TabIndex = 14;<BR>   this.Label5.Text = "4) Flash or flicker the found feature.";<BR>   // <BR>   // Label3<BR>   // <BR>   this.Label3.BackColor = System.Drawing.SystemColors.Control;<BR>   this.Label3.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.Label3.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.Label3.ForeColor = System.Drawing.SystemColors.Highlight;<BR>   this.Label3.Location = new System.Drawing.Point(586, 43);<BR>   this.Label3.Name = "Label3";<BR>   this.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.Label3.Size = new System.Drawing.Size(241, 18);<BR>   this.Label3.TabIndex = 13;<BR>   this.Label3.Text = "2) Select a layer to search.";<BR>   // <BR>   // Label2<BR>   // <BR>   this.Label2.BackColor = System.Drawing.SystemColors.Control;<BR>   this.Label2.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.Label2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.Label2.ForeColor = System.Drawing.SystemColors.Highlight;<BR>   this.Label2.Location = new System.Drawing.Point(586, 9);<BR>   this.Label2.Name = "Label2";<BR>   this.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.Label2.Size = new System.Drawing.Size(241, 27);<BR>   this.Label2.TabIndex = 12;<BR>   this.Label2.Text = "1) Enter a valid file path and load the PMF.";<BR>   // <BR>   // cboLayers<BR>   // <BR>   this.cboLayers.BackColor = System.Drawing.SystemColors.Window;<BR>   this.cboLayers.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.cboLayers.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.cboLayers.ForeColor = System.Drawing.SystemColors.WindowText;<BR>   this.cboLayers.Items.AddRange(new object[] {<BR>                 "Layer",<BR>                 "Field"});<BR>   this.cboLayers.Location = new System.Drawing.Point(586, 207);<BR>   this.cboLayers.Name = "cboLayers";<BR>   this.cboLayers.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.cboLayers.Size = new System.Drawing.Size(231, 22);<BR>   this.cboLayers.TabIndex = 17;<BR>   // <BR>   // cmdFlicker<BR>   // <BR>   this.cmdFlicker.BackColor = System.Drawing.SystemColors.Control;<BR>   this.cmdFlicker.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.cmdFlicker.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.cmdFlicker.ForeColor = System.Drawing.SystemColors.ControlText;<BR>   this.cmdFlicker.Location = new System.Drawing.Point(701, 310);<BR>   this.cmdFlicker.Name = "cmdFlicker";<BR>   this.cmdFlicker.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.cmdFlicker.Size = new System.Drawing.Size(116, 36);<BR>   this.cmdFlicker.TabIndex = 21;<BR>   this.cmdFlicker.Text = "Flicker Feature";<BR>   this.cmdFlicker.Click += new System.EventHandler(this.cmdFlicker_Click);<BR>   // <BR>   // cmdFlash<BR>   // <BR>   this.cmdFlash.BackColor = System.Drawing.SystemColors.Control;<BR>   this.cmdFlash.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.cmdFlash.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.cmdFlash.ForeColor = System.Drawing.SystemColors.ControlText;<BR>   this.cmdFlash.ImageAlign = System.Drawing.ContentAlignment.TopCenter;<BR>   this.cmdFlash.Location = new System.Drawing.Point(586, 310);<BR>   this.cmdFlash.Name = "cmdFlash";<BR>   this.cmdFlash.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.cmdFlash.Size = new System.Drawing.Size(116, 36);<BR>   this.cmdFlash.TabIndex = 20;<BR>   this.cmdFlash.Text = "Flash Feature";<BR>   this.cmdFlash.Click += new System.EventHandler(this.cmdFlash_Click);<BR>   // <BR>   // cmdFindNext<BR>   // <BR>   this.cmdFindNext.BackColor = System.Drawing.SystemColors.Control;<BR>   this.cmdFindNext.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.cmdFindNext.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.cmdFindNext.ForeColor = System.Drawing.SystemColors.ControlText;<BR>   this.cmdFindNext.ImageAlign = System.Drawing.ContentAlignment.TopCenter;<BR>   this.cmdFindNext.Location = new System.Drawing.Point(701, 250);<BR>   this.cmdFindNext.Name = "cmdFindNext";<BR>   this.cmdFindNext.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.cmdFindNext.Size = new System.Drawing.Size(116, 44);<BR>   this.cmdFindNext.TabIndex = 19;<BR>   this.cmdFindNext.Text = "Find Next";<BR>   this.cmdFindNext.TextAlign = System.Drawing.ContentAlignment.BottomCenter;<BR>   this.cmdFindNext.Click += new System.EventHandler(this.cmdFindNext_Click);<BR>   // <BR>   // cmdFind<BR>   // <BR>   this.cmdFind.BackColor = System.Drawing.SystemColors.Control;<BR>   this.cmdFind.Cursor = System.Windows.Forms.Cursors.Default;<BR>   this.cmdFind.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<BR>   this.cmdFind.ForeColor = System.Drawing.SystemColors.ControlText;<BR>   this.cmdFind.ImageAlign = System.Drawing.ContentAlignment.TopCenter;<BR>   this.cmdFind.Location = new System.Drawing.Point(586, 250);<BR>   this.cmdFind.Name = "cmdFind";<BR>   this.cmdFind.RightToLeft = System.Windows.Forms.RightToLeft.No;<BR>   this.cmdFind.Size = new System.Drawing.Size(116, 44);<BR>   this.cmdFind.TabIndex = 18;<BR>   this.cmdFind.Text = "Find";<BR>   this.cmdFind.TextAlign = System.Drawing.ContentAlignment.BottomCenter;<BR>   this.cmdFind.Click += new System.EventHandler(this.cmdFind_Click);<BR>   // <BR>   // axArcReaderControl2<BR>   // <BR>   this.axArcReaderControl2.Location = new System.Drawing.Point(8, 48);<BR>   this.axArcReaderControl2.Name = "axArcReaderControl2";<BR>   this.axArcReaderControl2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axArcReaderControl2.OcxState")));<BR>   this.axArcReaderControl2.Size = new System.Drawing.Size(536, 384);<BR>   this.axArcReaderControl2.TabIndex = 22;<BR>   // <BR>   // Form1<BR>   // <BR>   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);<BR>   this.ClientSize = new System.Drawing.Size(835, 506);<BR>   this.Controls.Add(this.axArcReaderControl2);<BR>   this.Controls.Add(this.cmdFlicker);<BR>   this.Controls.Add(this.cmdFlash);<BR>   this.Controls.Add(this.cmdFindNext);<BR>   this.Controls.Add(this.cmdFind);<BR>   this.Controls.Add(this.cboLayers);<BR>   this.Controls.Add(this.Label1);<BR>   this.Controls.Add(this.Label6);<BR>   this.Controls.Add(this.Label5);<BR>   this.Controls.Add(this.Label3);<BR>   this.Controls.Add(this.Label2);<BR>   this.Controls.Add(this.cmdLoad);<BR>   this.Controls.Add(this.txbPath);<BR>   this.Name = "Form1";<BR>   this.Text = "Form1";<BR>   this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);<BR>   this.Load += new System.EventHandler(this.Form1_Load);<BR>   ((System.ComponentModel.ISupportInitialize)(this.axArcReaderControl2)).EndInit();<BR>   this.ResumeLayout(false);</P>
<P>  }<BR>  #endregion</P>
<P>  /// <summary><BR>  /// The main entry point for the application.<BR>  /// </summary><BR>  [STAThread]<BR>  static void Main()<BR>  {<BR>   Application.Run(new Form1());<BR>  }</P>
<P>  private void Form1_Load(object sender, System.EventArgs e)<BR>  {<BR>   //Load button images<BR>//   System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap (GetType().Assembly.GetManifestResourceStream(GetType(), "find.bmp"));<BR>//   bitmap.MakeTransparent(System.Drawing.Color.Teal);<BR>//   cmdFind.Image = bitmap;<BR>//   cmdFindNext.Image = bitmap;<BR>   cmdFindNext.Enabled = false;<BR>   cmdFlash.Enabled = false;<BR>   cmdFlicker.Enabled = false;<BR>  }</P>
<P>  private void cmdFind_Click(object sender, System.EventArgs e)<BR>  {<BR>   cmdFindNext.Enabled = false;<BR>   cmdFlash.Enabled = false;<BR>   cmdFlicker.Enabled = false;</P>
<P>   //Determine whether a document is loaded<BR>   if (axArcReaderControl2.CurrentViewType == esriARViewType.esriARViewTypeNone)<BR>   {<BR>    MessageBox.Show("You must load a document!");<BR>    return;<BR>   }</P>
<P>   //Determine whether permission to search layers<BR>   if (axArcReaderControl2.HasDocumentPermission(esriARDocumentPermissions.esriARDocumentPermissionsQueryFeatures) == false)<BR>   {<BR>    MessageBox.Show("You do not have permission to search for features!");<BR>    return;<BR>   }</P>
<P><BR>  <BR>   //Get IARLayer interface<BR>   int index = m_LayerCollection.IndexOfKey(cboLayers.SelectedItem.ToString());<BR>   IARLayer layer = (IARLayer) m_LayerCollection.GetByIndex(index);</P>
<P>   //Get string to search for from the user<BR>   InputFormResult res = InputForm.ShowModal(this,"Enter a string to find: (The search is case sensitive)","Find", "");</P>
<P>   if (res.Result == DialogResult.Cancel) return;<BR>   string sFind = res.InputString;<BR>   if (sFind.Trim() == "") return;</P>
<P>   //Get IARFeatureCursor interface. Because there is no 'WhereClause' set<BR>   //yet this feature cursor will conatin all the features in the layer.<BR>   m_SearchDef = new ArcReaderSearchDefClass();<BR>   m_FeatureCursor = layer.SearchARFeatures(m_SearchDef);<BR>   //Get IARFeature interface by looping to the first feature in the cursor<BR>   m_Feature = m_FeatureCursor.NextARFeature();</P>
<P>   string sWhereClause = "";</P>
<P>   //Loop through the feature's fields to find the field names of any string<BR>   //fields. Build up a 'WhereClause' using the field names and the users string.<BR>   for (int i = 0; i <= m_Feature.FieldCount - 1; i++)<BR>   {<BR>    if (m_Feature.get_FieldType(i) == esriARFieldType.esriARFieldTypeString)<BR>    {<BR>     if (sWhereClause == "")<BR>     {<BR>      sWhereClause = m_Feature.get_FieldName(i) + " Like '" + sFind + "'";<BR>     }<BR>     else<BR>     {<BR>      sWhereClause = sWhereClause + " OR " + m_Feature.get_FieldName(i) + " Like '" + sFind + "'";<BR>     }<BR>    }<BR>   }</P>
<P>   //Set the search definiton WhereClause<BR>   m_SearchDef.WhereClause = sWhereClause;<BR>   //Get IARFeatureCursor interface by searching the layer<BR>   m_FeatureCursor = layer.SearchARFeatures(m_SearchDef);<BR>   //Get IARFeature interface by looping to the first feature in the cursor<BR>   m_Feature = m_FeatureCursor.NextARFeature();</P>
<P>   if (m_Feature == null)<BR>   {<BR>    MessageBox.Show("No features found!");<BR>    return;<BR>   }<BR>   else<BR>   {<BR>    m_Feature.ZoomTo();<BR>    axArcReaderControl2.ARPageLayout.FocusARMap.Refresh(true);<BR>    cmdFindNext.Enabled = true;<BR>    cmdFlash.Enabled = true;<BR>    cmdFlicker.Enabled = true;<BR>   }<BR>  }</P>
<P>  private void cmdFindNext_Click(object sender, System.EventArgs e)<BR>  {<BR>   //Get IARFeature interface by looping to the next feature in the cursor<BR>   m_Feature = m_FeatureCursor.NextARFeature();</P>
<P>   if (m_Feature == null)<BR>   {<BR>    MessageBox.Show("No more features found!");<BR>    cmdFindNext.Enabled = false;<BR>    cmdFlash.Enabled = false;<BR>    cmdFlicker.Enabled = false;<BR>   }<BR>   else<BR>   {<BR>    m_Feature.ZoomTo();<BR>    axArcReaderControl2.ARPageLayout.FocusARMap.Refresh(true);<BR>   }<BR>  }</P>
<P>  private void cmdFlash_Click(object sender, System.EventArgs e)<BR>  {<BR>   m_Feature.Flash();<BR>  }</P>
<P>  private void cmdFlicker_Click(object sender, System.EventArgs e)<BR>  {<BR>   m_Feature.Flicker();<BR>  }</P>
<P>  private void cmdLoad_Click(object sender, System.EventArgs e)<BR>  {<BR>   //Load the specified pmf<BR>   if (txbPath.Text == "")<BR>   {<BR>    return;<BR>   }<BR>   if (axArcReaderControl2.CheckDocument(txbPath.Text) == true)<BR>   {<BR>    axArcReaderControl2.LoadDocument(txbPath.Text,"");<BR>   }<BR>   else<BR>   {<BR>    MessageBox.Show("This document cannot be loaded!");<BR>   }<BR>  }</P>
<P>  private void DisplayLayerNames()<BR>  {<BR>   //Clear previous<BR>   cboLayers.Items.Clear();<BR>   for (int i = 0; i <= m_LayerCollection.Count; i++)<BR>   {<BR>    m_LayerCollection.Remove((1));<BR>   }</P>
<P>   //Loop through each layer in the focus map<BR>   for (int i = 0; i <= axArcReaderControl2.ARPageLayout.FocusARMap.ARLayerCount - 1; i++)<BR>   {<BR>    IARLayer layer = axArcReaderControl2.ARPageLayout.FocusARMap.get_ARLayer(i);<BR>    if (layer.IsGroupLayer == false)<BR>    {<BR>     //If the layer is searchable add layer<BR>     //to collection, and name to combo box<BR>     if (layer.Searchable == true)<BR>     {<BR>      cboLayers.Items.Add(axArcReaderControl2.ARPageLayout.FocusARMap.get_ARLayer(i).Name);<BR>      m_LayerCollection.Add(layer.Name, layer);<BR>     }<BR>    }<BR>    else<BR>    {<BR>     //Loop though each layer in the group layer<BR>     for (int j = 0; j <= layer.ARLayerCount - 1; j++)<BR>     {<BR>      //If the layer is searchable add layer<BR>      //to collection, and name to combo box<BR>      if (layer.get_ChildARLayer(j).Searchable == true)<BR>      {<BR>       cboLayers.Items.Add(layer.get_ChildARLayer(j).Name);<BR>       m_LayerCollection.Add(layer.get_ChildARLayer(j).Name, layer.get_ChildARLayer(j) );<BR>      }<BR>     }<BR>    }<BR>   }</P>
<P>   //Select the first layer in the combo box<BR>   if (cboLayers.Items.Count != 0)<BR>   {<BR>    cmdFind.Enabled = true;<BR>    cboLayers.SelectedIndex = 0;<BR>   }<BR>   else<BR>   {<BR>    cmdFind.Enabled = false;<BR>   }<BR>  }</P>
<P>  private void axArcReaderControl1_OnCurrentViewChanged(object sender, ESRI.ArcGIS.ArcReaderControl.IARControlEvents_OnCurrentViewChangedEvent e)<BR>  {<BR>   //Set the current tool to none selected<BR>   if (axArcReaderControl2.CurrentViewType != esriARViewType.esriARViewTypeNone)<BR>   {<BR>    if (axArcReaderControl2.CurrentARTool != esriARTool.esriARToolNoneSelected)<BR>    {<BR>     axArcReaderControl2.CurrentARTool = esriARTool.esriARToolNoneSelected;<BR>    }<BR>   }<BR>  }</P>
<P>  private void axArcReaderControl1_OnDocumentLoaded(object sender, ESRI.ArcGIS.ArcReaderControl.IARControlEvents_OnDocumentLoadedEvent e)<BR>  {<BR>   //Update layer list<BR>   DisplayLayerNames();<BR>  }</P>
<P>  private void axArcReaderControl1_OnFocusARMapChanged(object sender, ESRI.ArcGIS.ArcReaderControl.IARControlEvents_OnFocusARMapChangedEvent e)<BR>  {<BR>   //Update layer list<BR>   DisplayLayerNames();<BR>  }</P>
<P>  private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)<BR>  {<BR>   //Release COM objects<BR>   ESRI.ArcGIS.Utility.COMSupport.AOUninitialize.Shutdown();<BR>  }<BR> }<BR>}<BR>这是例子的代码给你们附上, <FONT color=#f73809>int index = m_LayerCollection.IndexOfKey(cboLayers.SelectedItem.ToString());<BR>   IARLayer layer = (IARLayer) m_LayerCollection.GetByIndex(index);</FONT><FONT color=#000000>到这里的时候出错了 不知道哪里出了问题</FONT></P>
举报 回复(0) 喜欢(0)     评分
hahaaluo
路人甲
路人甲
  • 注册日期2006-08-05
  • 发帖数146
  • QQ
  • 铜币591枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2006-09-11 20:29
请各位都来看看帮帮忙呀  小弟,谢过了~~~~~~~
举报 回复(0) 喜欢(0)     评分
hsghxm
路人甲
路人甲
  • 注册日期2004-10-27
  • 发帖数517
  • QQ4604052
  • 铜币1枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2006-09-12 09:22
<img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em08.gif" />
MSN:hsghxm@163.com QQ:4604052 (很少用,最好别加) Email:hsghxm@163.com 我的BOLG:http://www.gisempire.com/blog/user1/864/index.htm
举报 回复(0) 喜欢(0)     评分
游客

返回顶部