代码如下:并且还提示当前上下文不存在m_enabled;m_app
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Framework;
using ESRI.ArcGIS.ArcMapUI;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
namespace MyZoomInAddinyxy
{
public class MyZoomInAddin : ESRI.ArcGIS.Desktop.AddIns.Button
{
public class ZoomInCsharp : ICommand
{
private IApplication m_app;
private bool m_enabled;
private System.Drawing.Bitmap m_bitmap;
private IntPtr m_hBitmap;
}
public void OnCreate(object hook)
{
if (hook != null)
{
if (hook is IMxApplication)
{
m_app = (IApplication)hook;
m_enabled = true;
}
}
}
public void OnClick()
{
IMxDocument mxDoc = (IMxDocument)m_app.Document;
IActiveView activeView = mxDoc.ActiveView;
IEnvelope currExtent = (IEnvelope)activeView.Extent;
currExtent.Expand(0.5D, 0.5D, true);
activeView.Extent = currExtent;
activeView.Refresh();
}
public string Caption
{
get
{
return "Zoom In x 0.5 C#";
}
}
public string Category
{
get
{
return "Developer Samples";
}
}
public bool Checked
{
get
{
return false;
}
}
public bool Enabled
{
get
{
return m_enabled;
}
}
public string Message
{
get
{
return "Zooms the display to half the current extent.";
}
}
public string Name
{
get
{
return "Developer Samples_Zoom In C#";
}
}
public string Tooltip
{
get
{
return "Zoom In x 0.5 C#";
}
}
public int HelpContextID
{
get
{
// TODO: Add ZoomIn.HelpContextID getter implementation
return 0;
}
}
public string HelpFile
{
get
{
// TODO: Add ZoomIn.HelpFile getter implementation
return null;
}
}
}
}
}