最近在做一个杭州石油的项目开发一个小系统。

1.命令必须是 ICommand 的派生类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using MapGIS.PluginEngine;
using System.Windows.Forms;
using MapGIS.Scene3D; namespace ThreeDimenModeling
{
class IsoheightModeling : ICommand
{
//应用框架对象
IApplication hock = null;
//场景视图控件
SceneControl sceneCtrl = null; #region ICommand成员 public Bitmap Bitmap
{
get { return null; }
} public string Caption
{
get { return "等高线建模"; }
} public string Category
{
get { return "ThreeDimenModeling"; }
} public bool Checked
{
get { return false; }
} public bool Enabled
{
get { return true; }
} public string Message
{
get { return ""; }
} public string Name
{
get { return "等高线建模"; }
} public string Tooltip
{
get { return ""; }
} public void OnClick()
{
sceneCtrl = (this.hock.ActiveContentsView as ISceneContentsView).SceneControl;
IsoheightModelingForm IsoHeiMoForm = new IsoheightModelingForm(sceneCtrl );
if (IsoHeiMoForm.ShowDialog() != DialogResult.OK) return;
}
public void OnCreate(IApplication hook)
{
if (hook != null)
{
this.hock = hook;
this.hock.StateManager.StateChangedEvent += new StateChangedHandler(StateManager_StateChangedEvent);
}
}
void StateManager_StateChangedEvent(object sender, StateEventArgs e)
{
this.hock.PluginContainer.PluginEnable(this, false);
bool bEnable = false;
if (this.hock.ActiveContentsView != null && this.hock.ActiveContentsView is ISceneContentsView)
{
//当存在当前编辑状态的图层时,才可以进行查询
SceneControl ctr = (this.hock.ActiveContentsView as ISceneContentsView).SceneControl;
if (ctr != null && ctr.GetSceneNum() > 0)
{
bEnable = true;
}
}
this.hock.PluginContainer.PluginEnable(this, bEnable);
return;
}
private void PluginContainer_ContentsViewClosingEvent(IContentsView contentsView, ContentsViewClosingEventArgs args)
{
if (contentsView is ISceneContentsView)
{
SceneControl ctr = (this.hock.ActiveContentsView as ISceneContentsView).SceneControl;
}
}
#endregion
}
}

2.弹出Form

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 MapGIS.Scene3D; namespace ThreeDimenModeling
{
public partial class IsoheightModelingForm : Form
{
//场景控件
SceneControl sceneCtrl = null; public IsoheightModelingForm(SceneControl sCtrl )
{
InitializeComponent();
this.sceneCtrl = sCtrl;
}
}
}
05-11 18:17