コード例 #1
0
            public void StackWithNextCommand(IStackableCommand nextCommand)
            {
                var next = nextCommand as Class1;

                if (next != null)
                {
                    NextNum = next.NextNum;
                }
            }
コード例 #2
0
        private bool StackCommand(ICommand myAction)
        {
            //get the previous item off the stack
            if (UndoStack.Count > 0)
            {
                //check if the previous item is stackable
                IStackableCommand prevStackable = UndoStack.Last.Value as IStackableCommand;
                if (null != prevStackable)
                {
                    //check if the previous and current item can be stacked
                    var nextStackable = myAction as IStackableCommand;
                    if (prevStackable.CompareWithNextCommand(nextStackable))
                    {
                        //stack the previous and current item and execute it
                        prevStackable.StackWithNextCommand(nextStackable);
                        return(prevStackable.Execute());
                    }
                }
            }

            return(false);
        }
コード例 #3
0
            public bool CompareWithNextCommand(IStackableCommand nextCommand)
            {
                var next = nextCommand as Class1;

                return(next != null && next._num.Name == _num.Name);
            }