Exemplo n.º 1
0
        private void UndoRedo()
        {
            int index = 0;

            //Loop through each element and write the contents of the matching momento back into the element
            foreach (Label label in Labels)
            {
                //Get a momento of the label in its current state
                LabelMomento momento = new LabelMomento(label);

                //Write the momento into the element and save the new momento
                _momentos[index].WriteItem(label);
                _momentos[index] = momento;

                index++;
            }
        }
Exemplo n.º 2
0
        //Implementation
        public override void Execute()
        {
            if (Labels == null)
            {
                return;
            }

            //Create the momentos of the current labels
            _momentos = new List <LabelMomento>();

            //Loop through and add a momento for each label
            foreach (Label label in _labels)
            {
                LabelMomento momento = new LabelMomento(label);
                _momentos.Add(momento);
            }

            //Make comand lower case
            string command = CommandText.ToLower();

            switch (command)
            {
            case "bold":
                Controller.Suspend();
                DoCommandText(true, false, false, false);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "italic":
                Controller.Suspend();
                DoCommandText(false, true, false, false);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "strikeout":
                Controller.Suspend();
                DoCommandText(false, false, true, false);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "underline":
                Controller.Suspend();
                DoCommandText(false, false, false, true);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "align left":
                Controller.Suspend();
                DoCommandAlign(true, false, false);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "align center":
                Controller.Suspend();
                DoCommandAlign(false, true, false);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "align right":
                Controller.Suspend();
                DoCommandAlign(false, false, true);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "align top":
                Controller.Suspend();
                DoCommandVerticalAlign(true, false, false);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "align middle":
                Controller.Suspend();
                DoCommandVerticalAlign(false, true, false);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "align bottom":
                Controller.Suspend();
                DoCommandVerticalAlign(false, false, true);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "font":
                Controller.Suspend();
                DoCommandFont(Controller.Model.SelectedShapes(), CommandValue);
                Controller.Resume();
                Controller.Invalidate();
                break;

            case "font size":
                Controller.Suspend();
                DoCommandFontSize(Controller.Model.SelectedShapes(), CommandValue);
                Controller.Resume();
                Controller.Invalidate();
                break;
            }
        }