コード例 #1
0
        private Atom AttachScripts(TexFormula formula, string value, ref int position, Atom atom)
        {
            SkipWhiteSpace(value, ref position);

            if (position == value.Length)
            {
                return(atom);
            }

            // Check for prime marks.
            var primesRowAtom = new RowAtom();
            var i             = position + 1;

            while (i < value.Length)
            {
                if (value[i] == primeChar)
                {
                    primesRowAtom.Add(SymbolAtom.GetAtom("prime"));
                }
                else if (!IsWhiteSpace(value[i]))
                {
                    break;
                }
                position++;
                i++;
            }

            // Attach prime marks as superscript, if any were found.
            if (primesRowAtom.Elements.Count > 0)
            {
                atom = new ScriptsAtom(atom, null, primesRowAtom);
            }

            TexFormula superscriptFormula = null;
            TexFormula subscriptFormula   = null;

            var ch = value[position];

            switch (ch)
            {
            case superScriptChar:
                // Attach superscript.
                position++;
                superscriptFormula = ReadScript(formula, value, ref position);

                SkipWhiteSpace(value, ref position);
                if (position < value.Length && value[position] == subScriptChar)
                {
                    // Attach subscript also.
                    position++;
                    subscriptFormula = ReadScript(formula, value, ref position);
                }
                break;

            case subScriptChar:
                // Add subscript.
                position++;
                subscriptFormula = ReadScript(formula, value, ref position);

                SkipWhiteSpace(value, ref position);
                if (position < value.Length && value[position] == superScriptChar)
                {
                    // Attach superscript also.
                    position++;
                    superscriptFormula = ReadScript(formula, value, ref position);
                }
                break;
            }

            if (superscriptFormula is null && subscriptFormula is null)
            {
                return(atom);
            }

            // Check whether to return Big Operator or Scripts.
            if (atom.GetRightType() == TexAtomType.BigOperator)
            {
                return(new BigOperatorAtom(atom, subscriptFormula?.RootAtom,
                                           superscriptFormula?.RootAtom));
            }
            return(new ScriptsAtom(atom, subscriptFormula?.RootAtom,
                                   superscriptFormula?.RootAtom));
        }
コード例 #2
0
ファイル: StyledAtom.cs プロジェクト: sanec38/MathCore.WPF
 public override TexAtomType GetLeftType() => RowAtom.GetLeftType();
コード例 #3
0
ファイル: StyledAtom.cs プロジェクト: sanec38/MathCore.WPF
 public override TexAtomType GetRightType() => RowAtom.GetRightType();
コード例 #4
0
ファイル: StyledAtom.cs プロジェクト: sanec38/MathCore.WPF
 public StyledAtom(Atom atom, Brush backgroundColor, Brush foregroundColor)
 {
     RowAtom    = new RowAtom(atom);
     Background = backgroundColor;
     Foreground = foregroundColor;
 }