コード例 #1
0
        public MathList(IMathList cloneMe, bool finalize) : this()
        {
            if (!finalize)
            {
                foreach (var atom in cloneMe.Atoms)
                {
                    var cloneAtom = AtomCloner.Clone(atom, finalize);
                    Add(cloneAtom);
                }
            }
            else
            {
                IMathAtom prevNode = null;
                foreach (var atom in cloneMe.Atoms)
                {
                    var newNode = AtomCloner.Clone(atom, finalize);
                    if (atom.IndexRange == Range.Zero)
                    {
                        int prevIndex = prevNode is null ? 0 : prevNode.IndexRange.Location + prevNode.IndexRange.Length;
                        newNode.IndexRange = new Range(prevIndex, 1);
                    }
                    switch (newNode.AtomType)
                    {
                    case MathAtomType.BinaryOperator:
                        switch (prevNode?.AtomType)
                        {
                        case null:
                        case MathAtomType.BinaryOperator:
                        case MathAtomType.Relation:
                        case MathAtomType.Open:
                        case MathAtomType.Punctuation:
                        case MathAtomType.LargeOperator:
                            newNode.AtomType = MathAtomType.UnaryOperator;
                            break;
                        }
                        break;

                    case MathAtomType.Relation:
                    case MathAtomType.Punctuation:
                    case MathAtomType.Close:
                        if (prevNode != null && prevNode.AtomType == MathAtomType.BinaryOperator)
                        {
                            prevNode.AtomType = MathAtomType.UnaryOperator;
                        }
                        break;

                    case MathAtomType.Number:
                        if (prevNode != null && prevNode.AtomType == MathAtomType.Number && prevNode.Subscript == null && prevNode.Superscript == null)
                        {
                            prevNode.Fuse(newNode);
                            continue; // do not add the new node; we fused it instead.
                        }
                        break;
                    }
                    Add(newNode);
                    prevNode = newNode;
                }
            }
        }
コード例 #2
0
 public Fraction(Fraction cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     Numerator      = AtomCloner.Clone(cloneMe.Numerator, finalize);
     Denominator    = AtomCloner.Clone(cloneMe.Denominator, finalize);
     LeftDelimiter  = cloneMe.LeftDelimiter;
     RightDelimiter = cloneMe.RightDelimiter;
     HasRule        = cloneMe.HasRule;
 }
コード例 #3
0
ファイル: MathAtoms.cs プロジェクト: johndpope/CSharpMath
 public static IMathAtom ForLatexSymbolName(string symbolName)
 {
     if (symbolName == null)
     {
         throw new ArgumentNullException(nameof(symbolName));
     }
     if (Aliases.ContainsKey(symbolName))
     {
         symbolName = Aliases[symbolName];
     }
     if (Commands.TryGetByFirst(symbolName, out var symbol))
     {
         return(AtomCloner.Clone(symbol, false));
     }
     return(null);
 }
コード例 #4
0
ファイル: Underline.cs プロジェクト: whitemike889/CSharpMath
 public Underline(Underline cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     this.InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize);
 }
コード例 #5
0
ファイル: Table.cs プロジェクト: whitemike889/CSharpMath
 /// <summary>
 /// Deep copy, finalized or not.
 /// </summary>
 public Table(Table cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     InterColumnSpacing        = cloneMe.InterColumnSpacing;
     InterRowAdditionalSpacing = cloneMe.InterRowAdditionalSpacing;
     Environment = cloneMe.Environment;
     Alignments  = cloneMe.Alignments.ToList();
     Cells       = new List <List <IMathList> >(cloneMe.Cells.Select(list =>
                                                                     new List <IMathList>(list.Select(sublist =>
                                                                                                      AtomCloner.Clone(sublist, finalize)))));
 }
コード例 #6
0
 public Accent(Accent cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize);
 }
コード例 #7
0
 public Group(Group cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     InnerList = AtomCloner.Clone(cloneMe.InnerList, finalize);
 }
コード例 #8
0
 public Radical(Radical cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     Radicand = AtomCloner.Clone(cloneMe.Radicand, finalize);
     Degree   = AtomCloner.Clone(cloneMe.Degree, finalize);
 }
コード例 #9
0
ファイル: Color.cs プロジェクト: whitemike889/CSharpMath
 public Color(Color cloneMe, bool finalize) : base(cloneMe, finalize)
 {
     InnerList   = AtomCloner.Clone(cloneMe.InnerList, finalize);
     ColorString = cloneMe.ColorString;
 }