本文整理汇总了C#中System.Windows.Vector.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.ToString方法的具体用法?C# Vector.ToString怎么用?C# Vector.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Vector
的用法示例。
在下文中一共展示了Vector.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowVars
// Displays the variables
public void ShowVars()
{
// Displays the values of the variables
Point p1 = new Point(15, 25);
Vector v1 = new Vector(15, 25);
Matrix m1 = new Matrix(5, 10, 15, 20, 25, 30);
Matrix m2 = new Matrix(2, 4, 6, 8, 10, 12);
Double s1 = 75;
// Sets the Text in the text objects. These are
// defined in the MainWindow.xaml file
txtPoint1.Text = p1.ToString();
txtVector1.Text = v1.ToString();
txtMatrix1.Text = m1.ToString();
txtMatrix2.Text = m2.ToString();
txtScalar1.Text = s1.ToString();
}
示例2: PerformOperation
// This method performs the Point operations
public void PerformOperation(object sender, RoutedEventArgs e)
{
RadioButton li = (sender as RadioButton);
// Strings used to display the results
String syntaxString, resultType, operationString;
// The local variables point1, point2, vector2, etc are defined in each
// case block for readability reasons. Each variable is contained within
// the scope of each case statement.
switch (li.Name)
{ //begin switch
case "rb1":
{
// Converts a String to a Point using a PointConverter
// Returns a Point.
PointConverter pConverter = new PointConverter();
Point pointResult = new Point();
string string1 = "10,20";
pointResult = (Point)pConverter.ConvertFromString(string1);
// pointResult is equal to (10, 20)
// Displaying Results
syntaxString = "pointResult = (Point)pConverter1.ConvertFromString(string1);";
resultType = "Point";
operationString = "Converting a String to a Point";
ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb2":
{
// Converts a String to a Vector using a VectorConverter
// Returns a Vector.
VectorConverter vConverter = new VectorConverter();
Vector vectorResult = new Vector();
string string1 = "10,20";
vectorResult = (Vector)vConverter.ConvertFromString(string1);
// vectorResult is equal to (10, 20)
// Displaying Results
syntaxString = "vectorResult = (Vector)vConverter.ConvertFromString(string1);";
resultType = "Vector";
operationString = "Converting a String into a Vector";
ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb3":
{
// Converts a String to a Matrix using a MatrixConverter
// Returns a Matrix.
MatrixConverter mConverter = new MatrixConverter();
Matrix matrixResult = new Matrix();
string string2 = "10,20,30,40,50,60";
matrixResult = (Matrix)mConverter.ConvertFromString(string2);
// matrixResult is equal to (10, 20, 30, 40, 50, 60)
// Displaying Results
syntaxString = "matrixResult = (Vector)mConverter.ConvertFromString(string2);";
resultType = "Matrix";
operationString = "Converting a String into a Matrix";
ShowResults(matrixResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb4":
{
// Converts a String to a Point3D using a Point3DConverter
// Returns a Point3D.
Point3DConverter p3DConverter = new Point3DConverter();
Point3D point3DResult = new Point3D();
string string3 = "10,20,30";
point3DResult = (Point3D)p3DConverter.ConvertFromString(string3);
// point3DResult is equal to (10, 20, 30)
// Displaying Results
syntaxString = "point3DResult = (Point3D)p3DConverter.ConvertFromString(string3);";
resultType = "Point3D";
operationString = "Converting a String into a Point3D";
ShowResults(point3DResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb5":
{
// Converts a String to a Vector3D using a Vector3DConverter
// Returns a Vector3D.
Vector3DConverter v3DConverter = new Vector3DConverter();
//.........这里部分代码省略.........
示例3: ToStringTest
public void ToStringTest ()
{
Vector v = new Vector (4, 5);
Assert.AreEqual ("4,5", v.ToString());
}
示例4: ShowVars
// Displays the variables
public void ShowVars()
{
// Displays the values of the variables
var p1 = new Point(15, 25);
var v1 = new Vector(15, 25);
var m1 = new System.Windows.Media.Matrix(5, 10, 15, 20, 25, 30);
var m2 = new System.Windows.Media.Matrix(2, 4, 6, 8, 10, 12);
double s1 = 75;
// Sets the Text in the text objects. These are
// defined in the Windows1.xaml file
txtPoint1.Text = p1.ToString();
txtVector1.Text = v1.ToString();
txtMatrix1.Text = m1.ToString();
txtMatrix2.Text = m2.ToString();
txtScalar1.Text = s1.ToString(CultureInfo.InvariantCulture);
}
示例5: DrawVector
private void DrawVector(Vector<double> vector, EllipseCreator creator)
{
var coords = TransformCoordinates(vector);
var toolTip = vector.ToString();
DrawEllipse(coords,toolTip,creator);
}
示例6: PerformOperation
public void PerformOperation(object sender, RoutedEventArgs e)
{
var li = sender as RadioButton;
// Strings used to display results
string syntaxString, resultType, operationString;
switch (li?.Name)
{
//begin switch
case "rb1":
{
// Translates a Point by a Vector using the overloaded + operator.
var point1 = new Point(10, 5);
var vector1 = new System.Windows.Vector(20, 30);
var pointResult = point1 + vector1;
// pointResult is equal to (-10,-25)
// Displaying Results
syntaxString = "pointResult = point1 + vector1;";
resultType = "Point";
operationString = "Translating a Point by a Vector";
ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb2":
{
// Adds a Vector to a Vector using the overloaded + operator.
var vector1 = new System.Windows.Vector(20, 30);
var vector2 = new System.Windows.Vector(45, 70);
// vectorResult is equal to (65,100)
var vectorResult = vector1 + vector2;
// Displaying Results
syntaxString = "vectorResult = vector1 + vector2;";
resultType = "Vector";
operationString = "Adding a Vector to a Vector";
ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb3":
{
// Adds a Vector to a Vector using the static Add method.
var vector1 = new System.Windows.Vector(20, 30);
var vector2 = new System.Windows.Vector(45, 70);
var vectorResult = System.Windows.Vector.Add(vector1, vector2);
// vectorResult is equal to (65,100)
// Displaying Results
syntaxString = "vectorResult = Vector.Add(vector1, vector2);";
resultType = "Vector";
operationString = "Adding a Vector to a Vector";
ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb4":
{
// Translates a Point by a Vector using the static Add method.
var vector1 = new System.Windows.Vector(20, 30);
var point1 = new Point(10, 5);
var pointResult = System.Windows.Vector.Add(vector1, point1);
// vectorResult is equal to (30,35)
// Displaying Results
syntaxString = "pointResult = Vector.Add(vector1, point1);";
resultType = "Point";
operationString = "Translating a Point by a Vector";
ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb5":
{
// Subtracts a Vector from a Vector using the overloaded - operator.
var vector1 = new System.Windows.Vector(20, 30);
var vector2 = new System.Windows.Vector(45, 70);
var vectorResult = vector1 - vector2;
// vector Result is equal to (-25, -40)
// Displaying Results
//.........这里部分代码省略.........
示例7: ShowVars
// Method to display the variables used in the operations
public void ShowVars()
{
// Displays the values of the variables
System.Windows.Point p1 = new System.Windows.Point(10, 5);
System.Windows.Point p2 = new System.Windows.Point(15, 40);
Vector v1 = new Vector(20, 30);
Vector v2 = new Vector(45, 70);
Matrix m1 = new Matrix(40, 50, 60, 70, 80, 90);
Double s1 = 75;
txtPoint1.Text = p1.ToString();
txtPoint2.Text = p2.ToString();
txtVector1.Text = v1.ToString();
txtVector2.Text = v2.ToString();
txtMatrix1.Text = m1.ToString();
txtScalar1.Text = s1.ToString();
}
示例8: ShowVars
// Displays the values of the variables
public void ShowVars()
{
Point p1 = new Point(10, 5);
Point p2 = new Point(15, 40);
Vector v1 = new Vector(20, 30);
Vector v2 = new Vector(45, 70);
Matrix m1 = new Matrix(40, 50, 60, 70, 80, 90);
// Displaying values in Text objects
txtPoint1.Text = p1.ToString();
txtPoint2.Text = p2.ToString();
txtVector1.Text = v1.ToString();
txtVector2.Text = v2.ToString();
txtMatrix1.Text = m1.ToString();
}
示例9: PerformOperation
// This method performs the Point operations
public void PerformOperation(object sender, RoutedEventArgs e)
{
RadioButton li = sender as RadioButton;
// Strings used to display the results
String syntaxString, resultType, operationString;
// The local variables point1, point2, vector2, etc are defined in each
// case block for readability reasons. Each variable is contained within
// the scope of each case statement.
switch (li.Name)
{ //begin switch
case "rb1":
{
// Translates a Point by a Vector using the overloaded + operator.
// Returns a Point.
Point point1 = new Point(10, 5);
Vector vector1 = new Vector(20, 30);
Point pointResult = new Point();
pointResult = point1 + vector1;
// pointResult is equal to (30, 35)
// Note: Adding a Point to a Point is not a legal operation
// Displaying Results
syntaxString = "pointResult = point1 + vector1;";
resultType = "Point";
operationString = "Adding a Point and Vector";
ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb2":
{
// Translates a Point by a Vector using the static Add method.
// Returns a Point.
Point point1 = new Point(10, 5);
Vector vector1 = new Vector(20, 30);
Point pointResult = new Point();
pointResult = Point.Add(point1, vector1);
// pointResult is equal to (30, 35)
// Displaying Results
syntaxString = "pointResult = Point.Add(point1, vector1);";
resultType = "Point";
operationString = "Adding a Point and Vector";
ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb3":
{
// Subtracts a Vector from a Point using the overloaded - operator.
// Returns a Point.
Point point1 = new Point(10, 5);
Vector vector1 = new Vector(20, 30);
Point pointResult = new Point();
pointResult = point1 - vector1;
// pointResult is equal to (-10, -25)
// Displaying Results
syntaxString = "pointResult = point1 - vector1;";
resultType = "Point";
operationString = "Subtracting a Vector from a Point";
ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb4":
{
// Subtracts a Vector from a Point using the static Subtract method.
// Returns a Point.
Point point1 = new Point(10, 5);
Vector vector1 = new Vector(20, 30);
Point pointResult = new Point();
pointResult = Point.Subtract(point1, vector1);
// pointResult is equal to (-10, -25)
// Displaying Results
syntaxString = "pointResult = Point.Subtract(point1, vector1);";
resultType = "Point";
operationString = "Subtracting a Vector from a Point";
ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
break;
}
case "rb5":
{
// Subtracts a Point from a Point using the overloaded - operator.
// Returns a Vector.
Point point1 = new Point(10, 5);
Point point2 = new Point(15, 40);
Vector vectorResult = new Vector();
//.........这里部分代码省略.........