Пример #1
0
    public void SaveCoins()
    {
        var _coin = (int)Time.timeSinceLevelLoad;

        currentCoins = (coinReward - _coin - Superscript.TilEmpty);
        Superscript.SaveInt(PlayerPrefs.GetInt("coins") + currentCoins);
    }
Пример #2
0
 public void Fuse(MathAtom otherAtom)
 {
     if (Subscript.IsNonEmpty())
     {
         throw new InvalidOperationException("Cannot fuse into an atom with a subscript");
     }
     if (Superscript.IsNonEmpty())
     {
         throw new InvalidOperationException("Cannot fuse into an atom with a superscript");
     }
     if (otherAtom.GetType() != GetType())
     {
         throw new InvalidOperationException("Cannot fuse atoms with different types");
     }
     FusedAtoms ??= new List <MathAtom> {
         Clone(false)
     };
     if (otherAtom.FusedAtoms != null)
     {
         FusedAtoms.AddRange(otherAtom.FusedAtoms);
     }
     else
     {
         FusedAtoms.Add(otherAtom);
     }
     Nucleus   += otherAtom.Nucleus;
     IndexRange = new Range(IndexRange.Location,
                            IndexRange.Length + otherAtom.IndexRange.Length);
     Subscript   = otherAtom.Subscript;
     Superscript = otherAtom.Superscript;
 }
Пример #3
0
 public bool EqualsAtom(MathAtom otherAtom) =>
 Nucleus == otherAtom.Nucleus &&
 GetType() == otherAtom.GetType() &&
 //IndexRange == otherAtom.IndexRange &&
 //FontStyle == otherAtom.FontStyle &&
 Superscript.NullCheckingStructuralEquality(otherAtom.Superscript) &&
 Subscript.NullCheckingStructuralEquality(otherAtom.Subscript);
        public void GetSuperscript(string latex, IList <Element> container, Marker marker)
        {
            if (marker.Position >= latex.Length)
            {
                return;
            }

            if (latex.Substring(marker.Position, 1) == "^")
            {
                marker.Position += 1;

                var subsection = GetSubsection(latex, container, marker);

                if (subsection != null)
                {
                    var superscript = new Superscript();
                    var line        = new MathematicsLine();

                    superscript.Element1 = container.Last();

                    if (subsection.Item2.Count() == 1)
                    {
                        superscript.Element2 = subsection.Item2.First();
                    }
                    else
                    {
                        line.Elements        = subsection.Item2;
                        superscript.Element2 = line;
                    }

                    container.Remove(container.Last());
                    container.Add(superscript);

                    marker.Position += subsection.Item1;
                }
                else
                {
                    var elements = new List <Element>();

                    GetGreekLetter(latex, elements, marker);
                    GetIdentifier(latex, elements, marker);
                    GetNumber(latex, elements, marker);
                    GetOperator(latex, elements, marker);
                    GetMathRoman(latex, elements, marker);
                    GetPunctuationMark(latex, elements, marker);

                    if (elements.Any())
                    {
                        var superscript = new Superscript();

                        superscript.Element1 = container.Last();
                        superscript.Element2 = elements.First();

                        container.Remove(container.Last());
                        container.Add(superscript);
                    }
                }
            }
        }
Пример #5
0
        protected override void OnMeasure(MeasureSpec widthSpec, MeasureSpec heightSpec, Graphics g, Font font, Style style)
        {
            bracketSize = HasBracket ? 5 : 0;

            Body.Measure(widthSpec, heightSpec, g, font, style);
            Superscript.Measure(widthSpec, heightSpec, g, font, style);

            SetDesiredSize(Body.DesiredWidth + Superscript.DesiredWidth + bracketSize * 2 + 1, Body.DesiredHeight + Superscript.DesiredHeight - 5);
        }
Пример #6
0
        protected override void OnDraw(Graphics g, Font font, Style style)
        {
            Body.Draw(g, font, style);
            Superscript.Draw(g, font, style);

            if (HasBracket)
            {
                VectorGraphics.DrawRoundBracket(new RectangleF(Left, Top, Width - Superscript.DesiredWidth, Height), g, Brushes.Black);
            }
        }
Пример #7
0
        public static Superscript Power(string bas, string power)
        {
            Superscript   superscript   = new Superscript();
            Base          b             = new Base(new Run(new Text(bas)));
            SuperArgument superArgument = new SuperArgument(new Run(new Text(power)));

            superscript.AppendChild(b);
            superscript.AppendChild(superArgument);
            return(superscript);
        }
Пример #8
0
        private SuperscriptToken processSupScript(Superscript s)
        {
            TokenList supBase  = new TokenList();
            TokenList argument = new TokenList();

            foreach (var child in s.Base)
            {
                supBase.Append(processElement(child));
            }

            foreach (var child in s.SuperArgument)
            {
                argument.Append(processElement(child));
            }

            return(new SuperscriptToken(supBase, argument));
        }
Пример #9
0
 protected TAtom ApplyCommonPropertiesOn <TAtom>(bool finalize, TAtom newAtom)
     where TAtom : MathAtom
 {
     if (string.IsNullOrEmpty(newAtom.Nucleus))
     {
         // newAtom.Nucleus may have already been initialized by newAtom's constructor
         newAtom.Nucleus = Nucleus;
     }
     if (FusedAtoms != null)
     {
         newAtom.FusedAtoms = new List <MathAtom>(FusedAtoms);
     }
     newAtom.Superscript = Superscript.Clone(finalize);
     newAtom.Subscript   = Subscript.Clone(finalize);
     newAtom.IndexRange  = IndexRange;
     newAtom.FontStyle   = FontStyle;
     return(newAtom);
 }
Пример #10
0
            private void HandleEscSeq1(PegNode node, StyleContext context, StructuralGlyph parent)
            {
                int posBeg    = node.match_.posBeg_;
                var childNode = node.child_;

                if (childNode == null)
                {
                    throw new ArgumentNullException("childNode");
                }

                string escHeader = _sourceText.Substring(posBeg, childNode.match_.posBeg_ - posBeg);

                switch (escHeader.ToLowerInvariant())
                {
                case @"\id(":
                {
                    const string DefPropertyHead = "$Property[\"";
                    const string DefPropertyTail = "\"]";

                    string s = GetText(childNode).Trim();
                    if (s == "$DI")
                    {
                        parent.Add(new DocumentIdentifier(context));
                    }
                    else if (s.StartsWith(DefPropertyHead) && s.EndsWith(DefPropertyTail))
                    {
                        string propertyName = s.Substring(DefPropertyHead.Length, s.Length - DefPropertyHead.Length - DefPropertyTail.Length);
                        if (!string.IsNullOrEmpty(propertyName))
                        {
                            parent.Add(new ValueOfProperty(context, propertyName));
                        }
                    }
                }
                break;

                case @"\g(":
                {
                    var newContext = context.Clone();
                    newContext.SetFont(context.FontId.WithFamily("Symbol"));
                    VisitNode(childNode, newContext, parent);
                }
                break;

                case @"\i(":
                {
                    var newContext = context.Clone();
                    newContext.MergeFontStyle(FontXStyle.Italic);
                    VisitNode(childNode, newContext, parent);
                }
                break;

                case @"\b(":
                {
                    var newContext = context.Clone();
                    newContext.MergeFontStyle(FontXStyle.Bold);
                    VisitNode(childNode, newContext, parent);
                }
                break;

                case @"\u(":
                {
                    var newContext = context.Clone();
                    newContext.MergeFontStyle(FontXStyle.Underline);
                    VisitNode(childNode, newContext, parent);
                }
                break;

                case @"\s(":
                {
                    var newContext = context.Clone();
                    newContext.MergeFontStyle(FontXStyle.Strikeout);
                    VisitNode(childNode, newContext, parent);
                }
                break;

                case @"\n(":
                {
                    var newContext = context.Clone();
                    newContext.SetFontStyle(FontXStyle.Regular);
                    VisitNode(childNode, newContext, parent);
                }
                break;

                case @"\+(":
                {
                    var newParent = new Superscript
                    {
                        Style = context
                    };
                    parent.Add(newParent);

                    var newContext = context.Clone();
                    newContext.ScaleFont(0.65);
                    VisitNode(childNode, newContext, newParent);
                }
                break;

                case @"\-(":
                {
                    var newParent = new Subscript
                    {
                        Style = context
                    };
                    parent.Add(newParent);

                    var newContext = context.Clone();
                    newContext.ScaleFont(0.65);
                    VisitNode(childNode, newContext, newParent);
                }
                break;

                case @"\l(":
                {
                    string s = GetText(childNode);
                    if (int.TryParse(s, out var plotNumber))
                    {
                        parent.Add(new PlotSymbol(context, plotNumber));
                    }
                }
                break;

                case @"\%(":
                {
                    string s = GetText(childNode);
                    if (int.TryParse(s, out var plotNumber))
                    {
                        parent.Add(new PlotName(context, plotNumber));
                    }
                }
                break;

                case @"\ad(":
                {
                    var newParent = new DotOverGlyph
                    {
                        Style = context
                    };
                    parent.Add(newParent);
                    VisitNode(childNode, context, newParent);
                }
                break;

                case @"\ab(":
                {
                    var newParent = new BarOverGlyph
                    {
                        Style = context
                    };
                    parent.Add(newParent);
                    VisitNode(childNode, context, newParent);
                }
                break;
                }
            }
Пример #11
0
 public override Superscript VisitSuperscript(Superscript superscript)
 {
     superscript = superscriptDelegate?.Invoke(superscript) ?? superscript;
     return(base.VisitSuperscript(superscript));
 }
Пример #12
0
 public void TakeCoins()
 {
     Superscript.SaveInt(PlayerPrefs.GetInt("coins") - 100);
 }
Пример #13
0
 public void state()
 {
     Superscript.Switch();
 }
Пример #14
0
 protected override void OnLayout(float left, float top, float width, float height, Graphics g, Font font, Style style)
 {
     Body.Layout(this, bracketSize, 5, Body.DesiredWidth, Body.DesiredHeight, g, font, style);
     Superscript.Layout(this, Body.DesiredWidth + bracketSize * 2 + 1, 0, Body.DesiredWidth, Body.DesiredHeight, g, font, style);
 }
Пример #15
0
 protected bool Equals(Superscript other)
 {
     return(string.Equals(Text, other.Text) && Equals(Attributes, other.Attributes));
 }
Пример #16
0
			private void HandleEscSeq1(PegNode node, StyleContext context, StructuralGlyph parent)
			{
				int posBeg = node.match_.posBeg_;
				var childNode = node.child_;

				if (childNode == null)
					throw new ArgumentNullException("childNode");

				string escHeader = _sourceText.Substring(posBeg, childNode.match_.posBeg_ - posBeg);

				switch (escHeader.ToLowerInvariant())
				{
					case @"\id(":
						{
							const string DefPropertyHead = "$Property[\"";
							const string DefPropertyTail = "\"]";

							string s = GetText(childNode).Trim();
							if (s == "$DI")
							{
								parent.Add(new DocumentIdentifier(context));
							}
							else if (s.StartsWith(DefPropertyHead) && s.EndsWith(DefPropertyTail))
							{
								string propertyName = s.Substring(DefPropertyHead.Length, s.Length - DefPropertyHead.Length - DefPropertyTail.Length);
								if (!string.IsNullOrEmpty(propertyName))
									parent.Add(new ValueOfProperty(context, propertyName));
							}
						}
						break;

					case @"\g(":
						{
							var newContext = context.Clone();
							newContext.SetFont(context.FontId.WithFamily("Symbol"));
							VisitNode(childNode, newContext, parent);
						}
						break;

					case @"\i(":
						{
							var newContext = context.Clone();
							newContext.MergeFontStyle(FontXStyle.Italic);
							VisitNode(childNode, newContext, parent);
						}
						break;

					case @"\b(":
						{
							var newContext = context.Clone();
							newContext.MergeFontStyle(FontXStyle.Bold);
							VisitNode(childNode, newContext, parent);
						}
						break;

					case @"\u(":
						{
							var newContext = context.Clone();
							newContext.MergeFontStyle(FontXStyle.Underline);
							VisitNode(childNode, newContext, parent);
						}
						break;

					case @"\s(":
						{
							var newContext = context.Clone();
							newContext.MergeFontStyle(FontXStyle.Strikeout);
							VisitNode(childNode, newContext, parent);
						}
						break;

					case @"\n(":
						{
							var newContext = context.Clone();
							newContext.SetFontStyle(FontXStyle.Regular);
							VisitNode(childNode, newContext, parent);
						}
						break;

					case @"\+(":
						{
							var newParent = new Superscript();
							newParent.Style = context;
							parent.Add(newParent);

							var newContext = context.Clone();
							newContext.ScaleFont(0.65);
							VisitNode(childNode, newContext, newParent);
						}
						break;

					case @"\-(":
						{
							var newParent = new Subscript();
							newParent.Style = context;
							parent.Add(newParent);

							var newContext = context.Clone();
							newContext.ScaleFont(0.65);
							VisitNode(childNode, newContext, newParent);
						}
						break;

					case @"\l(":
						{
							string s = GetText(childNode);
							int plotNumber;
							if (int.TryParse(s, out plotNumber))
							{
								parent.Add(new PlotSymbol(context, plotNumber));
							}
						}
						break;

					case @"\%(":
						{
							string s = GetText(childNode);
							int plotNumber;
							if (int.TryParse(s, out plotNumber))
							{
								parent.Add(new PlotName(context, plotNumber));
							}
						}
						break;

					case @"\ad(":
						{
							var newParent = new DotOverGlyph();
							newParent.Style = context;
							parent.Add(newParent);
							VisitNode(childNode, context, newParent);
						}
						break;

					case @"\ab(":
						{
							var newParent = new BarOverGlyph();
							newParent.Style = context;
							parent.Add(newParent);
							VisitNode(childNode, context, newParent);
						}
						break;
				}
			}
Пример #17
0
 /// <summary>
 /// Determines whether the specified <see cref="Superscript" />, is equal to this instance.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns>true if equal; otherwise, false</returns>
 protected bool Equals(Superscript other) =>
 string.Equals(Text, other.Text) &&
 Equals(Attributes, other.Attributes);