程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> arcgis engine10 0 c#-ArcGIS Engine10.0 顯示屬性表的時候不成功,代碼最後兩行有問題,已標注,求解。

arcgis engine10 0 c#-ArcGIS Engine10.0 顯示屬性表的時候不成功,代碼最後兩行有問題,已標注,求解。

編輯:編程綜合問答
ArcGIS Engine10.0 顯示屬性表的時候不成功,代碼最後兩行有問題,已標注,求解。

源碼:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geodatabase;

namespace GIS_Design
{
public partial class Form1 : Form
{
public Form1()
{
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

        InitializeComponent();
    }



    private void axMapControl1_OnMapReplaced(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMapReplacedEvent e)
    {
        if (axMapControl1.LayerCount > 0)
        {
            axMapControl2.Map = new MapClass();
            for (int i = 0; i <= axMapControl1.Map.LayerCount - 1; i++)
            {
                axMapControl2.AddLayer(axMapControl1.get_Layer(i));
            }
            axMapControl2.Extent = axMapControl1.Extent;
            axMapControl2.Refresh();
        }
    }

    private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
    {
        // 得到新范圍
        IEnvelope pEnvelope = (IEnvelope)e.newEnvelope;
        IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
        IActiveView pActiveView = pGraphicsContainer as IActiveView;
        //在繪制前,清除axMapControl2中的任何圖形元素
        pGraphicsContainer.DeleteAllElements();

        IRectangleElement pRectangleEle = new RectangleElementClass();
        IElement pElement = pRectangleEle as IElement;
        pElement.Geometry = pEnvelope;
        //設置鷹眼圖中的紅線框
        IRgbColor pColor = new RgbColorClass();
        pColor.Red = 255;
        pColor.Green = 0;
        pColor.Blue = 0;
        pColor.Transparency = 255;
        //產生一個線符號對象
        ILineSymbol pOutline = new SimpleLineSymbolClass();
        pOutline.Width = 3;
        pOutline.Color = pColor;
        //設置顏色屬性
        pColor = new RgbColorClass();
        pColor.Red = 255;
        pColor.Green = 0;
        pColor.Blue = 0;
        pColor.Transparency = 0;
        //設置填充符號的屬性
        IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

        pFillSymbol.Color = pColor;
        pFillSymbol.Outline = pOutline;
        IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;
        pFillShapeEle.Symbol = pFillSymbol;
        pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
        pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
    }       
    private void axMapControl2_OnMouseMove(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e)
    {

        if (e.button == 1)
        {
            IPoint pPoint = new ESRI.ArcGIS.Geometry.Point();
        pPoint.PutCoords(e.mapX, e.mapY);
        axMapControl1.CenterAt(pPoint);
        axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
    }

    private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
    {

        if (axMapControl2.Map.LayerCount > 0)
        {
            if (e.button == 1)
            {
                IPoint pPoint = new ESRI.ArcGIS.Geometry.Point();
                pPoint.PutCoords(e.mapX, e.mapY);
                axMapControl1.CenterAt(pPoint);
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
            else if (e.button == 2)
            {
                IEnvelope pEnv = axMapControl2.TrackRectangle();
                axMapControl1.Extent = pEnv;
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
        }
    }

    private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
    {

    }
    ILayer layer = new FeatureLayerClass();
    private void axTOCControl1_OnMouseDown_1(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e)
    {
        this.axTOCControl1.ContextMenuStrip = null;
        IBasicMap map = new MapClass();

        System.Object other = null;
        System.Object index = null;
        ESRI.ArcGIS.Controls.esriTOCControlItem item = ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemNone;
        this.axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index);
        if (item == ESRI.ArcGIS.Controls.esriTOCControlItem.esriTOCControlItemLayer && e.button == 2)
        {
            System.Drawing.Point pt = new System.Drawing.Point();
            pt.X = e.x;
            pt.Y = e.y;
            pt = this.axTOCControl1.PointToScreen(pt);
            this.contextMenuStrip4.Show(pt);
        }
    }
    private void OpenAttribute_Click(object sender, EventArgs e)
    {
         **Form Attribute   = new Attribute(layer);
        Form.Show();**  
    }        
}

}
錯誤 CS0144: 無法創建抽象類或接口“System.Attribute”的實例
錯誤 CS0120: 非靜態的字段、方法或屬性“System.Windows.Forms.Control.Show()”要求對象引用

最佳回答:


**Form Attribute   = new Attribute(layer);
    Form.Show();** 

應該是
**Attribute Form = new Attribute(layer);
Form.Show();

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved