casen_xu 2013-12-24 13:09 采纳率: 100%
浏览 4228
已采纳

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()”要求对象引用

  • 写回答

1条回答 默认 最新

  • selfer520 2014-05-16 07:52
    关注
    **Form Attribute   = new Attribute(layer);
        Form.Show();** 
    

    应该是
    **Attribute Form = new Attribute(layer);
    Form.Show();

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算