2016-09-27 108 views
1

我是ArcGis中的新成員。我遇到了需要在ArcGis工具欄上使用命令的要求。點擊該命令後,Windows窗體將打開並出現一個區域選擇器按鈕。點擊按鈕後,當前的表單用戶界面必須最小化,用戶將被允許繪製一個多邊形。你能幫助如何做到這一點。這是代碼。我採取了正常的窗口按鈕,並在點擊事件中寫下了下面的代碼。如何在窗體中添加arcgis按鈕

 _application = ((IApplication)_hookHelper.Hook); 
     IMxDocument pMxDoc = (IMxDocument)_application.Document; 
     IMap pMap = (IMap)pMxDoc.FocusMap; 

     IActiveView pActiveView = (IActiveView)pMap; 

     if (pActiveView == null) 
     { 
      return; 
     } 

     //// Changing the state of the Window. 
     if (this.WindowState == FormWindowState.Normal || this.WindowState == FormWindowState.Maximized) 
     { 
      this.WindowState = FormWindowState.Minimized; 
      // this.Hide(); 
     } 

     ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = pActiveView.ScreenDisplay; 
     // Constant 
     screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast 

     ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass(); 
     rgbColor.Blue = 111; 

     ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast 
     ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass(); 
     simpleFillSymbol.Color = color; 

     ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast 
     ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberRectangularPolygonClass(); 
     // ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberPolygonClass(); 
     ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol); 
     screenDisplay.SetSymbol(symbol); 
     screenDisplay.DrawPolygon(geometry); 
     screenDisplay.FinishDrawing(); 

我也沒有得到任何鼠標事件,並且UI在開始繪製多邊形時沒有最小化。任何人都可以請幫忙。

回答