コード例 #1
0
        /// <summary>
        /// 重做
        /// </summary>
        public virtual void Redo()
        {
            if (!this.CanRedo)
            {
                return;
            }
            ICmd cmd = cmdHistories[++CurrentPosition];

            cmd.Excute();
        }
コード例 #2
0
 /// <summary>
 /// 执行
 /// </summary>
 /// <param name="cmd">命令</param>
 /// <param name="record">是否记录</param>
 public virtual void Excute(ICmd cmd, bool record = true)
 {
     if (cmd != null)
     {
         cmd.Initialize();
         cmd.Excute();
         if (record)
         {
             if (this.CurrentPosition + 1 != this.cmdHistories.Count)
             {
                 cmdHistories.RemoveRange(this.CurrentPosition + 1, this.cmdHistories.Count - this.CurrentPosition - 1);
             }
             cmdHistories.Add(cmd);
             this.CurrentPosition++;
         }
     }
 }