找回密码
 立即注册

QQ登录

只需一步,快速开始

pblandscape

初级会员

19

主题

46

帖子

397

积分

初级会员

积分
397

微信认证勋章

pblandscape
初级会员   /  发表于:2017-7-5 16:17  /   查看:3479  /  回复:2
有没有撤销功能的代码可以参考。

2 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-7-5 17:57:23
沙发
您的问题我已经收到,稍后给您发个Demo
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-7-6 16:22:34
板凳
可以通过实现 IUndo 实现Undo 功能,可以直接通过ctrl z 撤销。
  1.     public partial class MainPage : UserControl
  2.     {
  3.         public MainPage()
  4.         {
  5.             InitializeComponent();
  6.         }

  7.         private void button_Click(object sender, RoutedEventArgs e)
  8.         {
  9.             var action = new SetColorAction();
  10.             gcSpreadSheet1.DoCommand(action);

  11.         }
  12.     }

  13.     public class SetColorAction : ActionBase, IUndo
  14.     {
  15.         public bool CanUndo
  16.         {
  17.             get
  18.             {
  19.                 return true;
  20.             }
  21.         }

  22.         public override bool CanExecute(object parameter)
  23.         {
  24.             return true;
  25.         }

  26.         public override void Execute(object parameter)
  27.         {
  28.             var spread = parameter as SpreadView;
  29.             this._oldColor = spread.ActiveSheet.ActiveCell.Background;
  30.             this._cellRow = spread.ActiveSheet.ActiveRowIndex;
  31.             this._cellColumn = spread.ActiveSheet.ActiveColumnIndex;
  32.             spread.ActiveSheet.Cells[this._cellRow, this._cellColumn].Background =
  33.                 new System.Windows.Media.SolidColorBrush(Colors.Red);

  34.         }

  35.         private Brush _oldColor;
  36.         private int _cellRow;
  37.         private int _cellColumn;

  38.         public void SaveState()
  39.         {
  40.         }

  41.         public bool Undo(object parameter)
  42.         {
  43.             var spread = parameter as SpreadView;
  44.             spread.ActiveSheet.Cells[this._cellRow, this._cellColumn].Background =
  45.                 this._oldColor;
  46.             return true;
  47.         }
  48.     }
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部