gis地图界面利用栈实现撤销重做操作

 

操作类

public class operate
{
private Stack<IElement> nows = new Stack<IElement>();
private IElement nl;
private IElement xElement;

public operate()
{

}

//撤销
public void rollback(Stack<IElement> history, IMapControl3 axmap, IGraphicsContainer pgra)
{
nl=history.Pop();
pgra.DeleteElement(nl);
axmap.ActiveView.Refresh();
}

//进入重做栈
public Stack<IElement> fallbackstack()
{
nows.Push(nl);
return nows;
}

//重做
public Stack<IElement> fallback(IMapControl3 axmap, IGraphicsContainer pgra)
{
xElement = nows.Pop();
pgra.AddElement(xElement, 0);
axmap.ActiveView.Refresh();
return nows;
}

//进入撤消栈
public Stack<IElement> rollbackstack(Stack<IElement> history)
{
history.Push(xElement);
return history;
}


}

//界面命令

private Stack<IElement> history;//撤销
private Stack<IElement> now;//重做
private ESRI.ArcGIS.Controls.IMapControl3 m_mapControl = null;
private operate oper;
private IGraphicsContainer pgra;

private void 撤销ToolStripMenuItem_Click(object sender, EventArgs e)
{
oper.rollback(history, m_mapControl, pgra);
now = oper.fallbackstack();
}

private void 重做ToolStripMenuItem_Click(object sender, EventArgs e)
{
now = oper.fallback(m_mapControl, pgra);
history = oper.rollbackstack(history);
}

转载于:https://www.cnblogs.com/lxc-binary/archive/2013/05/16/3081186.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值