예제 #1
0
 public override void ExecuteCommand(CommandType commandType, object data)
 {
     deleteable = null;
     if (ActiveChild.GetType() == typeof(TextEquation))
     {
         EquationBase newEquation = null;
         switch (commandType)
         {
             case CommandType.Composite:
                 newEquation = CompositeFactory.CreateEquation(this, (Position)data);
                 break;
             case CommandType.CompositeBig:
                 newEquation = BigCompositeFactory.CreateEquation(this, (Position)data);
                 break;
             case CommandType.Division:
                 newEquation = DivisionFactory.CreateEquation(this, (DivisionType)data);
                 break;
             case CommandType.SquareRoot:
                 newEquation = new SquareRoot(this);
                 break;
             case CommandType.nRoot:
                 newEquation = new nRoot(this);
                 break;
             case CommandType.LeftBracket:
                 newEquation = new LeftBracket(this, (BracketSignType)data);
                 break;
             case CommandType.RightBracket:
                 newEquation = new RightBracket(this, (BracketSignType)data);
                 break;
             case CommandType.LeftRightBracket:
                 newEquation = new LeftRightBracket(this, ((BracketSignType[])data)[0], ((BracketSignType[])data)[1]);
                 break;
             case CommandType.Sub:
                 newEquation = new Sub(this, (Position)data);
                 break;
             case CommandType.Super:
                 newEquation = new Super(this, (Position)data);
                 break;
             case CommandType.SubAndSuper:
                 newEquation = new SubAndSuper(this, (Position)data);
                 break;
             case CommandType.TopBracket:
                 newEquation = new TopBracket(this, (HorizontalBracketSignType)data);
                 break;
             case CommandType.BottomBracket:
                 newEquation = new BottomBracket(this, (HorizontalBracketSignType)data);
                 break;
             case CommandType.DoubleArrowBarBracket:
                 newEquation = new DoubleArrowBarBracket(this);
                 break;
             case CommandType.SignComposite:
                 newEquation = SignCompositeFactory.CreateEquation(this, (Position)(((object[])data)[0]), (SignCompositeSymbol)(((object[])data)[1]), UseItalicIntergalOnNew);
                 break;
             case CommandType.Decorated:
                 newEquation = new Decorated(this, (DecorationType)(((object[])data)[0]), (Position)(((object[])data)[1]));
                 break;
             case CommandType.Arrow:
                 newEquation = new Arrow(this, (ArrowType)(((object[])data)[0]), (Position)(((object[])data)[1]));
                 break;
             case CommandType.Box:
                 newEquation = new Box(this, (BoxType)data);
                 break;
             case CommandType.Matrix:
                 newEquation = new MatrixEquation(this, ((int[])data)[0], ((int[])data)[1]);
                 break;
             case CommandType.DecoratedCharacter:
                 if (((TextEquation)ActiveChild).CaretIndex > 0)
                 {
                     //newEquation = new DecoratedCharacter(this,
                     //                                     (TextEquation)ActiveChild,
                     //                                     (CharacterDecorationType)((object[])data)[0],
                     //                                     (Position)((object[])data)[1],
                     //                                     (string)((object[])data)[2]);
                     ((TextEquation)ActiveChild).AddDecoration((CharacterDecorationType)((object[])data)[0],
                                                               (Position)((object[])data)[1],
                                                               (string)((object[])data)[2]);
                     CalculateSize();
                 }
                 break;
         }
         if (newEquation != null)
         {
             EquationBase newText = ActiveChild.Split(this);
             int caretIndex = ((TextEquation)ActiveChild).TextLength;
             AddChild(newEquation);
             AddChild(newText);
             newEquation.CalculateSize();
             ActiveChild = newEquation;
             CalculateSize();
             UndoManager.AddUndoAction(new RowAction(this, ActiveChild, (TextEquation)newText, childEquations.IndexOf(ActiveChild), caretIndex));
         }
     }
     else if (ActiveChild != null)
     {
         ((EquationContainer)ActiveChild).ExecuteCommand(commandType, data);
         CalculateSize();
     }
 }