本文整理汇总了C#中Shape.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Shape.ToString方法的具体用法?C# Shape.ToString怎么用?C# Shape.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToStringModelView
public static void ToStringModelView(Shape shape, int nest, ref StringBuilder sb)
{
if (shape is ShapeProxy)
{
((ShapeProxy)shape).ToStringModelView(nest, ref sb);
}
else if (shape is UnparsedShape)
{
((UnparsedShape)shape).ToStringModelView(nest, ref sb);
}
else if (shape is MorphShapeProxy)
{
((MorphShapeProxy)shape).ToStringModelView(nest, ref sb);
}
else if (shape is UnparsedMorphShape)
{
((UnparsedMorphShape)shape).ToStringModelView(nest, ref sb);
}
else
{
throw new Exception("*** ERROR: CAN'T DUMP: " + shape.ToString());
}
}
示例2: WriteShape
/// <summary>
/// Writes a shape to a String, in a format that can be read by {@link #readShape(String)}.
/// </summary>
/// <param name="shape"></param>
/// <returns></returns>
public virtual String WriteShape(Shape shape)
{
// TODO: Support Java's NumberFormat behavior
var point = shape as Point;
if (point != null)
{
return point.GetX().ToString("F6", CultureInfo.CreateSpecificCulture("en-US")) + " " +
point.GetY().ToString("F6", CultureInfo.CreateSpecificCulture("en-US"));
}
var rect = shape as Rectangle;
if (rect != null)
{
return rect.GetMinX().ToString("F6", CultureInfo.CreateSpecificCulture("en-US")) + " " +
rect.GetMinY().ToString("F6", CultureInfo.CreateSpecificCulture("en-US")) + " " +
rect.GetMaxX().ToString("F6", CultureInfo.CreateSpecificCulture("en-US")) + " " +
rect.GetMaxY().ToString("F6", CultureInfo.CreateSpecificCulture("en-US"));
}
var c = shape as Circle;
if (c != null)
{
return "Circle(" +
c.GetCenter().GetX().ToString("F6", CultureInfo.CreateSpecificCulture("en-US")) + " " +
c.GetCenter().GetY().ToString("F6", CultureInfo.CreateSpecificCulture("en-US")) + " " +
"d=" + c.GetRadius().ToString("F6", CultureInfo.CreateSpecificCulture("en-US")) +
")";
}
return shape.ToString();
}
示例3: ShapeToString
public static string ShapeToString(string attr, Shape shape) {
return attr + shape.ToString().ToLower();
}