public static DecoratedText Create(string text) { if (text.Contains("gk_")) { foreach (string greekLetter in Funcs.GetGreekLetters()) { text = text.Replace("gk_" + greekLetter, Funcs.GetGreekLetter(greekLetter)); } } if (text.StartsWith("#")) { return(new NormalText(MathyConstants.GetSymbol(text.Substring(1)))); } else if (text.IndexOf('_') == -1) { return(new NormalText(text)); } else if (text.IndexOf("__") == -1) { return(new SubscriptedText(text)); } else { return(new SuperscriptedText(text)); } }
protected string GetValueString(object value) { if (value == null) { return("空值"); } else if (value.GetType().IsArray) { return(string.Format("长度为{0}的数组", ((Array)value).Length)); } else if (value.Equals(double.PositiveInfinity)) { return(MathyConstants.GetSymbol("posinf")); } else if (value.Equals(double.NegativeInfinity)) { return(MathyConstants.GetSymbol("neginf")); } else if (value is Matrix) { Matrix m = value as Matrix; return(string.Format("{0}*{1}矩阵", m.RowCount, m.ColumnCount)); } else if (value is Bitmap) { return("图片"); } else if (value is VariableContextExpression) { return("表达式"); } else { return(value.ToString()); } }