ToString() public method

public ToString ( ) : string
return string
示例#1
0
 public void DrawLine(System.Windows.Point start, System.Windows.Point end, double thickness)
 {
     m_writer.WriteStartElement("line");
     m_writer.WriteAttributeString("start", start.ToString(CultureInfo.InvariantCulture));
     m_writer.WriteAttributeString("end", end.ToString(CultureInfo.InvariantCulture));
     m_writer.WriteAttributeString("thickness", thickness.ToString());
     m_writer.WriteEndElement();
 }
示例#2
0
文件: PointTest.cs 项目: dfr0/moon
		public void Defaults ()
		{
			Point p = new Point ();
			Assert.AreEqual (0.0, p.X, "X");
			Assert.AreEqual (0.0, p.Y, "Y");
			Assert.AreEqual ("0,0", p.ToString (), "ToString");
			Compare (p);
		}
示例#3
0
 public void DrawRectangle(System.Windows.Point start, System.Windows.Size size, double thickness, bool fill = false)
 {
     m_writer.WriteStartElement("rect");
     m_writer.WriteAttributeString("start", start.ToString(CultureInfo.InvariantCulture));
     m_writer.WriteAttributeString("size", size.ToString(CultureInfo.InvariantCulture));
     m_writer.WriteAttributeString("thickness", thickness.ToString());
     m_writer.WriteAttributeString("fill", fill.ToString());
     m_writer.WriteEndElement();
 }
示例#4
0
文件: PointTest.cs 项目: dfr0/moon
		public void NegativeInfinity ()
		{
			Point p = new Point (Double.NegativeInfinity, Double.NegativeInfinity);
			Assert.IsTrue (Double.IsNegativeInfinity (p.X), "X");
			Assert.IsTrue (Double.IsNegativeInfinity (p.Y), "Y");
			Assert.AreEqual (String.Format ("{0},{0}",Double.NegativeInfinity,Double.NegativeInfinity), p.ToString ());
			//Assert.AreEqual ("-Infinity,-Infinity", p.ToString (), "ToString");
			Compare (p);
		}
        private FormattedText MakeFormattedString(Point point)
        {
            string testString = point.ToString();
            FormattedText formattedText = new FormattedText(testString,
            System.Globalization.CultureInfo.GetCultureInfo("ko-kr"),
            FlowDirection.LeftToRight,
            new Typeface("Verdana"), 16, Brushes.Black);

            return formattedText;
        }
示例#6
0
 public void DrawEllipse(System.Windows.Point centre, double radiusX, double radiusY, double thickness, bool fill = false)
 {
     m_writer.WriteStartElement("ellipse");
     m_writer.WriteAttributeString("centre", centre.ToString(CultureInfo.InvariantCulture));
     m_writer.WriteAttributeString("rx", radiusX.ToString(CultureInfo.InvariantCulture));
     m_writer.WriteAttributeString("ry", radiusY.ToString(CultureInfo.InvariantCulture));
     m_writer.WriteAttributeString("thickness", thickness.ToString());
     m_writer.WriteAttributeString("fill", fill.ToString());
     m_writer.WriteEndElement();
 }
示例#7
0
        ///<summary>根据planeviewbox和planecameraheight自动调整相机位置</summary>
        void planeAdjustCamera()
        {
            //计算相机位置
            System.Windows.Point pnt    = new System.Windows.Point(planeViewBox.Width / 2, planeViewBox.Height / 2);
            System.Windows.Point geopnt = geohelper.planeToGeo(pnt.ToString());
            VECTOR3D             vc     = MapHelper.JWHToPoint(geopnt.Y, geopnt.X, Para.LineHeight, earthpara);

            float tmp = 1.0f + planeCameraHeight / Para.Radius;

            earth.camera = new Camera(new Vector3(vc.x, vc.y, vc.z) * tmp, new Vector3(0, 0, 0), Vector3.Up, earth);
        }
 private void AddLines()
 {
     Point pt1 = new Point();
     Point pt2 = new Point();
     pt1.X = Convert.ToDouble(tbX1.Text);
     pt1.Y = Convert.ToDouble(tbY1.Text);
     pt2.X = Convert.ToDouble(tbX2.Text);
     pt2.Y = Convert.ToDouble(tbY2.Text);
     double length = 0.5 * Convert.ToDouble(tbLength.Text);
     line1 = new Line();
     line1.X1 = pt1.X;
     line1.Y1 = pt1.Y;
     line1.X2 = pt2.X;
     line1.Y2 = pt2.Y;
     line1.Stroke = Brushes.Gray;
     line1.StrokeThickness = 4;
     canvas1.Children.Add(line1);
     Canvas.SetLeft(tbPoint1, pt1.X);
     Canvas.SetTop(tbPoint1, pt1.Y);
     Canvas.SetLeft(tbPoint2, pt2.X);
     Canvas.SetTop(tbPoint2, pt2.Y);
     tbPoint1.Text = "Pt1(" + pt1.ToString() + ")";
     tbPoint2.Text = "Pt2(" + pt2.ToString() + ")";
     Vector v1 = pt1 - pt2;
     Matrix m1 = new Matrix();
     Point pt3 = new Point();
     Point pt4 = new Point();
     m1.Rotate(-90);
     v1.Normalize();
     v1 *= length;
     line2 = new Line();
     line2.Stroke = Brushes.Gray;
     line2.StrokeThickness = 4;
     line2.StrokeDashArray = DoubleCollection.Parse("3, 1");
     pt3 = pt2 + v1 * m1;
     m1 = new Matrix();
     m1.Rotate(90);
     pt4 = pt2 + v1 * m1;
     line2.X1 = pt3.X;
     line2.Y1 = pt3.Y;
     line2.X2 = pt4.X;
     line2.Y2 = pt4.Y;
     canvas1.Children.Add(line2);
     Canvas.SetLeft(tbPoint3, pt3.X);
     Canvas.SetTop(tbPoint3, pt3.Y);
     Canvas.SetLeft(tbPoint4, pt4.X);
     Canvas.SetTop(tbPoint4, pt4.Y);
     pt3.X = Math.Round(pt3.X, 0);
     pt3.Y = Math.Round(pt3.Y, 0);
     pt4.X = Math.Round(pt4.X, 0);
     pt4.Y = Math.Round(pt4.Y, 0);
     tbPoint3.Text = "Pt3(" + pt3.ToString() + ")";
     tbPoint4.Text = "Pt4(" + pt4.ToString() + ")";
 }
示例#9
0
文件: PointTest.cs 项目: dfr0/moon
		public void NaN ()
		{
			Point p = new Point (Double.NaN, Double.NaN);
			Assert.IsTrue (Double.IsNaN (p.X), "X");
			Assert.IsTrue (Double.IsNaN (p.Y), "Y");
			Assert.AreEqual ("NaN,NaN", p.ToString (), "ToString");

			// special reserved case
			Point p2 = p;
			Assert.IsFalse (p.Equals ((object) p2), "Equals(object)");
			Assert.IsFalse (p.Equals (p2), "Equals(Point)");
			Assert.IsFalse (p == p2, "==");
			Assert.IsTrue (p != p2, "!=");
		}
示例#10
0
 public void DrawText(System.Windows.Point anchor, TextAlignment alignment, IEnumerable <TextRun> textRuns)
 {
     m_writer.WriteStartElement("text");
     m_writer.WriteAttributeString("anchor", anchor.ToString(CultureInfo.InvariantCulture));
     m_writer.WriteAttributeString("alignment", alignment.ToString());
     foreach (var textRun in textRuns)
     {
         m_writer.WriteStartElement("run");
         m_writer.WriteAttributeString("size", textRun.Formatting.Size.ToString());
         m_writer.WriteAttributeString("formatting", textRun.Formatting.FormattingType.ToString());
         m_writer.WriteValue(textRun.Text);
         m_writer.WriteEndElement();
     }
     m_writer.WriteEndElement();
 }
示例#11
0
        // Displays the values of the variables
        public void ShowVars()
        {
            var p1 = new System.Windows.Point(10, 5);
            var p2 = new System.Windows.Point(15, 40);

            var v1 = new Vector(20, 30);
            var v2 = new Vector(45, 70);

            var 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();
        }
示例#12
0
        public void execute()
        {
            var ComposedScreenShot = CopyScreen().ComposedScreenshotImage;//bitmap screen shooted
            var bitstring          = BitmapToString(ComposedScreenShot);
            var replyMsg           = client.WriteLineAndGetReply(bitstring, TimeSpan.FromMilliseconds(500));

            Application.Current.Dispatcher.Invoke(() =>
            {
                if (window != null)
                {
                    System.Windows.Point pointToWindow = Mouse.GetPosition(window);
                    System.Windows.Point pointToScreen = PointToScreen(pointToWindow);

                    MousePos.Content = "Client Mouse Position :" + pointToScreen.ToString();
                }
            });
        }
示例#13
0
        private void Eyedropper_OnMouseMove(object sender, MouseEventArgs e)
        {
            if (!_mDown)
            {
                return;
            }

            var   elem = sender as UIElement;
            var   mPos = e.GetPosition(elem);
            Point sPos = elem.PointToScreen(mPos);

            Debug.WriteLine(sPos.ToString());
            Bitmap cap = Extensions.ScrCap(new Rectangle((int)sPos.X, (int)sPos.Y, 1, 1));

            System.Drawing.Color capCol = cap.GetPixel(0, 0);
            Color = Color.FromArgb(capCol.A, capCol.R, capCol.G, capCol.B);
        }
示例#14
0
文件: PointTest.cs 项目: nobled/mono
		public void ToStringTest ()
		{
			Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");
			Point p = new Point (4, 5);
			Assert.AreEqual ("4,5", p.ToString());
			Point p2 = new Point(4.1, 5.1);
			Assert.AreEqual("4.1,5.1",p2.ToString());
			Point p3 = new Point(0, 0);
			Assert.AreEqual("0,0", p3.ToString());

			Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de-de");
			Point p4 = new Point(4, 5);
			Assert.AreEqual("4;5", p4.ToString());
			Point p5 = new Point(4.1, 5.1);
			Assert.AreEqual("4,1;5,1", p5.ToString());
			Point p6 = new Point(0, 0);
			Assert.AreEqual("0;0", p6.ToString());
		}
示例#15
0
        // 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();
        }
示例#16
0
 private void canvas_MouseUp(object sender, MouseButtonEventArgs e)
 {
     //Release the mouse
     if (canvas.IsMouseCaptured)
     {
         canvas.ReleaseMouseCapture();
     }
     canvas.Cursor = Cursors.Arrow;
     Main.AddLog("User drew rectangle: Starting point: " + startDrag.ToString() + " Width: " + rectangle.Width + " Height:" + rectangle.Height);
     if (rectangle.Width < 10 || rectangle.Height < 10)   // box is smaller than 10x10 and thus will never be able to have any text. Also used as a failsave to prevent the program from crashing if the user makes a 0x0 sleection
     {
         Main.AddLog("User selected an area too small");
         Main.StatusUpdate("Please slecet a larger area to scan", 2);
         return;
     }
     tempImage = tempImage.Clone(new Rectangle((int)startDrag.X, (int)startDrag.Y, (int)rectangle.Width, (int)rectangle.Height), System.Drawing.Imaging.PixelFormat.DontCare);
     Task.Factory.StartNew(() => OCR.ProcessSnapIt(tempImage));
     Topmost = false;
     Hide();
 }
示例#17
0
        public static void SchnittpunktFinder_Tester()
        {
            Line lineA = new Line();

            lineA.X1 = lineA.Y2 = 0;
            lineA.X2 = lineA.Y1 = 50;

            Line lineB = new Line();

            lineB.X1 = lineB.Y1 = 0;
            lineB.X2 = lineB.Y2 = 50;

            Point interSectionPoint = new Point(0, 0);

            bool isIntersection = GetSingleLineIntersection(lineA, lineB, ref interSectionPoint);

            MessageBox.Show(isIntersection.ToString() + " at Point " + interSectionPoint.ToString());

            //lineA
        }
示例#18
0
        public void DrawPath(System.Windows.Point start, IList <IPathCommand> commands, double thickness, bool fill = false)
        {
            m_writer.WriteStartElement("path");
            m_writer.WriteAttributeString("start", start.ToString(CultureInfo.InvariantCulture));
            m_writer.WriteAttributeString("thickness", thickness.ToString());
            m_writer.WriteAttributeString("fill", fill.ToString());

            using (MemoryStream dataStream = new MemoryStream())
            {
                System.IO.BinaryWriter dataWriter = new System.IO.BinaryWriter(dataStream);
                dataWriter.Write(commands.Count);
                foreach (IPathCommand pathCommand in commands)
                {
                    dataWriter.Write((int)pathCommand.Type);
                    pathCommand.Write(dataWriter);
                }
                dataWriter.Flush();

                m_writer.WriteValue(Convert.ToBase64String(dataStream.ToArray()));
            }

            m_writer.WriteEndElement();
        }
示例#19
0
        private static void buttonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var element = sender as UIElement;

            var targetWindow = element.GetValue(LeftMouseButtonDrag) as Window;

            if (targetWindow != null)
            {
                //Added this to un-maximize on drag.
                if (targetWindow.WindowState == WindowState.Maximized)
                {
                    //targetWindow.Left = element.mouse
                    //All this to snap the window to the mouse cursor when it's moved.
                    //This gets the mouse position in proper coordinates.
                    Matrix transform = PresentationSource.FromVisual(targetWindow).CompositionTarget.TransformFromDevice;
                    System.Windows.Point mousePosition = transform.Transform(GetMousePosition());
                    Console.WriteLine("Mouse Location: " + mousePosition.ToString());

                    //Get the percentage of the window to move the cursor to.
                    double screenWidth      = targetWindow.ActualWidth;  //SystemParameters.PrimaryScreenWidth;
                    double screenHeight     = targetWindow.ActualHeight; //SystemParameters.PrimaryScreenHeight;
                    double relativeXPercent = screenWidth / mousePosition.X;
                    double relativeYPercent = screenHeight / mousePosition.Y;
                    Console.WriteLine("Relative Mouse X Percentage = " + relativeXPercent.ToString());
                    Console.WriteLine("Relative Mouse Y Percentage = " + relativeYPercent.ToString());

                    //Set window to normal mode
                    targetWindow.WindowState = WindowState.Normal;

                    //Move the window to the cursor.
                    targetWindow.Left = mousePosition.X - (targetWindow.Width / relativeXPercent);
                    targetWindow.Top  = mousePosition.Y - (targetWindow.Height / relativeYPercent);
                }
                targetWindow.DragMove();
            }
        }
示例#20
0
        /// <summary>
        /// Laden der Selektierten Koordinate in die TextBox, damit der Benutzer
        /// diese bearbeiten kann.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBoxKoordinaten_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Überprüfen, dass ein Item ausgewählt wurde.
            if (this.listBoxKoordinaten.SelectedItem != null)
            {
                // Den Punkt aus dem Item auslesen.
                string[] strEllipsenName = this.listBoxKoordinaten.SelectedItem.ToString().Trim().Split('-');
                string[] strPoint = strEllipsenName[1].Split(';');

                Point p = new Point(Convert.ToDouble(strPoint[0]), Convert.ToDouble(strPoint[1]));

                // Den Punkt in die TextBox laden.
                this.txtKoordinate.Text = p.ToString();

                // Das Label und die TextBox anzeigen.
                this.lblKoordinate.Visibility = System.Windows.Visibility.Visible;
                this.txtKoordinate.Visibility = System.Windows.Visibility.Visible;

                // Die Ellipse Selektieren.
                ////this.KoordinatenKennzeichnungsellipseHervorheben(this.m_clsLand.KoordinatenKennzeichnungsellipsen[strEllipsenName[0].Trim()]);

                // Der TextBox den Fokus zuweisen.
                FocusManager.SetFocusedElement(this, this.txtKoordinate);
            }
        }
示例#21
0
        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 
                    syntaxString = "vectorResult = vector1 - vector2;";
                    resultType = "Vector";
                    operationString = "Subtracting a Vector from a Vector";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb6":
                {
                    // Subtracts a Vector from a Vector using the static Subtract method.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    var vectorResult = System.Windows.Vector.Subtract(vector1, vector2);

                    // vector Result is equal to (-25, -40)

                    // Displaying Results
                    syntaxString = "Vector.Subtract(vector1, vector2);";
                    resultType = "Vector";
                    operationString = "Subtracting a Vector from a Vector";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }
                case "rb7":
                {
                    // Multiplies a Vector by a Scalar using the overloaded * operator.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    double scalar1 = 75;

                    var vectorResult = vector1*scalar1;

                    // vectorResult is equal to (1500,2250)

                    // Displaying Results
                    syntaxString = "vectorResult = vector1 * scalar1;";
                    resultType = "Vector";
                    operationString = "Multiplies a Vector by a Scalar";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb8":
                {
                    // Multiplies a Scalar by a Vector using the overloaded * operator.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    double scalar1 = 75;

                    var vectorResult = scalar1*vector1;

                    // vectorResult is equal to (1500,2250)

                    // Displaying Results
                    syntaxString = "vectorResult = scalar1 * vector1;";
                    resultType = "Vector";
                    operationString = "Multiplies a Scalar by a Vector";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }
                case "rb9":
                {
                    // Multiplies a Vector by a Vector using the overloaded * operator.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    var doubleResult = vector1*vector2;

                    // doubleResult is equal to 3000

                    // Displaying Results
                    syntaxString = "doubleResult = vector1 * vector2;";
                    resultType = "Double";
                    operationString = "Multiplies a Vector by a Vector";
                    ShowResults(doubleResult.ToString(CultureInfo.InvariantCulture), syntaxString, resultType,
                        operationString);
                    break;
                }

                case "rb10":
                {
                    // Multiplies a Vector by a Matrix using the overloaded * operator.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    var matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                    var vectorResult = vector1*matrix1;

                    // vector Result is equal to (2600,3100)


                    // Displaying Results
                    syntaxString = "vectorResult = vector1 * matrix1;";
                    resultType = "Vector";
                    operationString = "Multiplies a Vector by a Matrix";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb11":
                {
                    // Multiplies a Vector by a Scalar using the static Multiply method.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    double scalar1 = 75;

                    var vectorResult = System.Windows.Vector.Multiply(vector1, scalar1);

                    // vectorResult is equal to (1500,2250)

                    // Displaying Results
                    syntaxString = "vectorResult = Vector.Multiply(vector1, scalar1);";
                    resultType = "Vector";
                    operationString = "Multiplies a Vector by a Scalar";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb12":
                {
                    // Multiplies a Scalar by a Vector using the static Multiply method.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    double scalar1 = 75;

                    var vectorResult = System.Windows.Vector.Multiply(scalar1, vector1);

                    // vectorResult is equal to (1500,2250)

                    // Displaying Results
                    syntaxString = "vectorResult = Vector.Multiply(scalar1, vector1);";
                    resultType = "Vector";
                    operationString = "Multiplies a Scalar by a Vector";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb13":
                {
                    // Multiplies a Vector by a Vector using the static Multiply method.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    var doubleResult = System.Windows.Vector.Multiply(vector1, vector2);

                    // doubleResult is equal to 3000

                    // Displaying Results
                    syntaxString = "DoubleResult = Vector.Multiply(vector1,vector2);";
                    resultType = "Double";
                    operationString = "Multiplies a Vector by a Vector";
                    ShowResults(doubleResult.ToString(CultureInfo.InvariantCulture), syntaxString, resultType,
                        operationString);
                    break;
                }

                case "rb14":
                {
                    // Multiplies a Vector by a Matrix using the static Multiply method.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    var matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                    var vectorResult = System.Windows.Vector.Multiply(vector1, matrix1);

                    // vector Result is equal to (2600,3100)


                    // Displaying Results
                    syntaxString = "vectorResult = Vector.Multiply(vector1,matrix1);";
                    resultType = "Vector";
                    operationString = "Multiplies a Vector by a Matrix";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb15":
                {
                    // Divides a Vector by a Scalar using the overloaded / operator.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    double scalar1 = 75;

                    var vectorResult = vector1/scalar1;

                    // vectorResult is approximately equal to (0.26667,0.4)

                    // Displaying Results
                    syntaxString = "vectorResult = vector1 / scalar1;";
                    resultType = "Vector";
                    operationString = "Dividing a Vector by a Scalar";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }
                case "rb16":
                {
                    // Divides a Vector by a Double using the static Divide method.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    double scalar1 = 75;

                    var vectorResult = System.Windows.Vector.Divide(vector1, scalar1);

                    // vectorResult is approximately equal to (0.26667,0.4)

                    // Displaying Results
                    syntaxString = "vectorResult = Vector.Divide(vector1, scalar1);";
                    resultType = "Vector";
                    operationString = "Dividing a Vector by a Scalar";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb17":
                {
                    // Gets the hashcode of a Vector structure

                    var vector1 = new System.Windows.Vector(20, 30);

                    var vectorHashCode = vector1.GetHashCode();

                    // Displaying Results
                    syntaxString = "vectorHashCode = vector1.GetHashCode();";
                    resultType = "int";
                    operationString = "Getting the hashcode of a Vector";
                    ShowResults(vectorHashCode.ToString(), syntaxString, resultType, operationString);
                    break;
                }


                case "rb18":
                {
                    // Gets the length of a Vector.  

                    var vector1 = new System.Windows.Vector(20, 30);

                    var length = vector1.Length;

                    // length is approximately equal to 36.0555


                    // Displaying Results
                    syntaxString = "length = vector1.Length();";
                    resultType = "Double";
                    operationString = "Getting the length of a Vector";
                    ShowResults(length.ToString(CultureInfo.InvariantCulture), syntaxString, resultType, operationString);
                    break;
                }

                case "rb19":
                {
                    // Gets the square of the length of a Vector.  

                    var vector1 = new System.Windows.Vector(20, 30);

                    var lengthSq = vector1.LengthSquared;

                    // lengthSq is equal to 1300

                    // Displaying Results
                    syntaxString = "lengthSq = vector1.LengthSquared;";
                    resultType = "Double";
                    operationString = "Getting the length square of a Vector";
                    ShowResults(lengthSq.ToString(CultureInfo.InvariantCulture), syntaxString, resultType,
                        operationString);
                    break;
                }
                case "rb20":
                {
                    // Normalizes a Vector using the Normalize method.  

                    var vector1 = new System.Windows.Vector(20, 30);

                    vector1.Normalize();

                    // vector1 is approximately equal to (0.5547,0.8321) 

                    // Displaying Results
                    syntaxString = "vector1.Normalize();";
                    resultType = "Vector";
                    operationString = "Normalizing a Vector";
                    ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb21":
                {
                    // Calculates the angle between two Vectors using the static AngleBetween method. 

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    var angleBetween = System.Windows.Vector.AngleBetween(vector1, vector2);

                    // angleBetween is approximately equal to 0.9548

                    // Displaying Results
                    syntaxString = "angleBetween = Vector.AngleBetween(vector1, vector2);";
                    resultType = "Double";
                    operationString = "Calculating the angle between two Vectors";
                    ShowResults(angleBetween.ToString(CultureInfo.InvariantCulture), syntaxString, resultType,
                        operationString);
                    break;
                }

                case "rb22":
                {
                    // Calculates the cross product of two Vectors using the static  CrossProduct method.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    var crossProduct = System.Windows.Vector.CrossProduct(vector1, vector2);

                    // crossProduct is equal to 50

                    // Displaying Results
                    syntaxString = "crossProduct = Vector.CrossProduct(vector1,vector2);";
                    resultType = "Double";
                    operationString = "Calculating the crossproduct of two Vectors";
                    ShowResults(crossProduct.ToString(CultureInfo.InvariantCulture), syntaxString, resultType,
                        operationString);
                    break;
                }


                case "rb23":
                {
                    // Calculates the determinant of two Vectors using the static Determinant method.  

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    var determinant = System.Windows.Vector.Determinant(vector1, vector2);

                    // determinant is equal to 50

                    // Displaying Results
                    syntaxString = "determinant = Vector.Determinant(vector1, vector2);";
                    resultType = "Double";
                    operationString = "Calculating the determinant of two Vectors";
                    ShowResults(determinant.ToString(CultureInfo.InvariantCulture), syntaxString, resultType,
                        operationString);
                    break;
                }


                case "rb24":
                {
                    // Checks if two Vectors are equal using the overloaded equality operator.

                    // Declaring vecto1 and initializing x,y values
                    var vector1 = new System.Windows.Vector(20, 30);

                    // Declaring vector2 without initializing x,y values
                    var vector2 = new System.Windows.Vector
                    {
                        X = 45,
                        Y = 70
                    };

                    // Boolean to hold the result of the comparison

                    // assigning values to vector2

                    // Comparing Vectors for equality
                    var areEqual = (vector1 == vector2);

                    // areEqual is False

                    // Displaying Results
                    syntaxString = "areEqual = (vector1 == vector2);";
                    resultType = "Boolean";
                    operationString = "Checking if two vectors are equal";
                    ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                    break;
                }


                case "rb25":
                {
                    // Checks if two Vectors are equal using the static Equals method.

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    var areEqual = System.Windows.Vector.Equals(vector1, vector2);

                    // areEqual is False    

                    // Displaying Results
                    syntaxString = "areEqual = Vector.Equals(vector1, vector2);";
                    resultType = "Boolean";
                    operationString = "Checking if two vectors are equal";
                    ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                    break;
                }
                case "rb26":
                {
                    // Compares an Object and a Vector for equality using the non-static Equals method.

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    var areEqual = vector1.Equals(vector2);

                    // areEqual is False    


                    // Displaying Results
                    syntaxString = "areEqual = vector1.Equals(vector2);";
                    resultType = "Boolean";
                    operationString = "Checking if two vectors are equal";
                    ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb27":
                {
                    // Converts a string representation of a vector into a Vector structure

                    var vectorResult = System.Windows.Vector.Parse("1,3");

                    // vectorResult is equal to (1,3)

                    // Displaying Results
                    syntaxString = "vectorResult = Vector.Parse(\"1,3\");";
                    resultType = "Vector";
                    operationString = "Converting a string into a Vector";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb28":
                {
                    // Checks if two Vectors are not equal using the overloaded inequality operator.

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    var areNotEqual = (vector1 != vector2);

                    // areNotEqual is True

                    // Displaying Results
                    syntaxString = "areNotEqual = (vector1 != vector2);";
                    resultType = "Boolean";
                    operationString = "Checking if two points are not equal";
                    ShowResults(areNotEqual.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb29":
                {
                    // Negates a Vector using the Negate method.

                    var vector1 = new System.Windows.Vector(20, 30);

                    vector1.Negate();

                    // vector1 is equal to (-20, -30)

                    // Displaying Results
                    syntaxString = "vector1.Negate();";
                    resultType = "void";
                    operationString = "Negating a vector";
                    ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb30":
                {
                    // Negates a Vector using the overloaded unary negation operator.

                    var vector1 = new System.Windows.Vector(20, 30);

                    var vectorResult = -vector1;

                    // vectorResult is equal to (-20, -30)

                    // Displaying Results
                    syntaxString = "vectorResult = -vector1;";
                    resultType = "Vector";
                    operationString = "Negating a vector";
                    ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb31":
                {
                    // Gets a String representation of a Vector structure

                    var vector1 = new System.Windows.Vector(20, 30);

                    var vectorString = vector1.ToString();

                    // vectorString is equal to 10,5

                    // Displaying Results
                    syntaxString = "vectorString = vector1.ToString();";
                    resultType = "String";
                    operationString = "Getting the string representation of a Vector";
                    ShowResults(vectorString, syntaxString, resultType, operationString);
                    break;
                }
                case "rb32":
                {
                    // Explicitly converts a Vector structure into a Size structure
                    // Returns a Size.

                    var vector1 = new System.Windows.Vector(20, 30);

                    var size1 = (Size) vector1;

                    // size1 has a width of 20 and a height of 30

                    // Displaying Results
                    syntaxString = "size1 = (Size)vector1;";
                    resultType = "Size";
                    operationString = "Expliciting casting a Vector into a Size";
                    ShowResults(size1.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                case "rb33":
                {
                    // Explicitly converts a Vector structure into a Point structure
                    // Returns a Point.

                    var vector1 = new System.Windows.Vector(20, 30);

                    var point1 = (Point) vector1;

                    // point1 is equal to (20, 30)

                    // Displaying Results
                    syntaxString = "point1 = (Point)vector1;";
                    resultType = "Point";
                    operationString = "Expliciting casting a Vector into a Point";
                    ShowResults(point1.ToString(), syntaxString, resultType, operationString);
                    break;
                }

                // task example.  this case statement is not referenced from the list of radio buttons
                case "rb40":
                {
                    // adds two vectors using Add and +

                    var vector1 = new System.Windows.Vector(20, 30);
                    var vector2 = new System.Windows.Vector(45, 70);

                    vector1 = vector1 + vector2;
                    // vector1 is now equal to (65, 100)

                    vector1 = System.Windows.Vector.Add(vector1, vector2);
                    // vector1 is now equal to (110, 170)

                    // Displaying Results
                    syntaxString = "vectorResult = Vector.Negate(vector1);";
                    resultType = "Vector";
                    operationString = "Negating a vector";
                    ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                    break;
                }
            } // end switch
        }
示例#22
0
        // 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();
        }
        // 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();
        }
示例#24
0
        public MyClass(string type, string name, System.Windows.Point pt, int speedX, int speedY, string tag)
        //construction function of creating new object with loading data.
        //All properties are used the same as the construction function above.
        {
            Random lucky        = new Random();
            int    lucky_number = lucky.Next(4);
            int    speed        = lucky.Next(3, 8);

            this.type   = type;
            this.Name   = name;
            this.speedX = speedX;
            this.speedY = speedY;
            this.pt     = pt;
            var uriSource = new Uri("./Resources/" + type + "_img.gif", UriKind.Relative);

            this.Source = new BitmapImage(uriSource);
            this.Width  = 60;
            this.Margin = new Thickness(pt.X, pt.Y, 0, 0);
            this.HorizontalAlignment = HorizontalAlignment.Left;
            this.VerticalAlignment   = VerticalAlignment.Top;
            this.Tag          = tag;
            this.Initialized += Timer_Start;
            this.context      = this.Name + ", X Speed:" + this.speedX.ToString() + ", Y Speed:" + this.speedY.ToString() + ", Location:" + pt.ToString() + ", Direction:" + this.Tag.ToString();
        }
示例#25
0
        // 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();

                        vectorResult = point1 - point2;
                        // vectorResult is equal to (-5, -35)

                        // Displaying Results
                        syntaxString = "vectorResult = point1 - point2;";
                        resultType = "Vector";
                        operationString = "Subtracting a Point from a Point";
                        ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb6":
                    {
                        // Subtracts a Point from a Point using the static Subtract method.
                        // Returns a Vector.
                        Point point1 = new Point(10, 5);
                        Point point2 = new Point(15, 40);
                        Vector vectorResult = new Vector();

                        vectorResult = Point.Subtract(point1, point2);
                        // vectorResult is equal to (-5, -35)

                        // Displaying Results
                        syntaxString = "vectorResult = Point.Subtract(point1, point2);";
                        resultType = "Vector";
                        operationString = "Subtracting a Point from a Point";
                        ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb7":
                    {
                        // Offsets the X and Y values of a Point.
                        Point point1 = new Point(10, 5);

                        point1.Offset(20, 30);
                        // point1 is equal to (30, 35)

                        // Note: This operation is equivalent to adding a point
                        // to vector with the corresponding X,Y values.

                        // Displaying Results
                        syntaxString = "point1.Offset(20,30);";
                        resultType = "Point";
                        operationString = "Offsetting a Point";
                        ShowResults(point1.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb8":
                    {
                        // Multiplies a Point by a Matrix.
                        // Returns a Point.
                        Point point1 = new Point(10, 5);
                        Point pointResult = new Point();
                        Matrix matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                        pointResult = point1 * matrix1;
                        // pointResult is equal to (780, 940)

                        // Displaying Results
                        resultType = "Point";
                        syntaxString = "pointResult = point1 * matrix1;";
                        operationString = "Multiplying a Point by a Matrix";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb9":
                    {
                        // Multiplies a Point by a Matrix.
                        // Returns a Point.
                        Point point1 = new Point(10, 5);
                        Point pointResult = new Point();
                        Matrix matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                        pointResult = Point.Multiply(point1, matrix1);
                        // pointResult is equal to (780, 940)

                        // Displaying Results
                        resultType = "Point";
                        syntaxString = "pointResult = Point.Multiply(point1, matrix1);";
                        operationString = "Multiplying a Point by a Matrix";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb10":
                    {
                        // Checks if two Points are equal using the overloaded equality operator.
                        Point point1 = new Point(10, 5);
                        Point point2 = new Point(15, 40);
                        Boolean areEqual;

                        areEqual = (point1 == point2);
                        // areEqual is False

                        // Displaying Results
                        syntaxString = "areEqual = (point1 == point2);";
                        resultType = "Boolean";
                        operationString = "Checking if two points are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb11":
                    {
                        // Checks if two Points are equal using the static Equals method.
                        Point point1 = new Point(10, 5);
                        Point point2 = new Point(15, 40);
                        Boolean areEqual;

                        areEqual = Point.Equals(point1, point2);
                        // areEqual is False

                        // Displaying Results
                        syntaxString = "areEqual = Point.Equals(point1, point2);";
                        resultType = "Boolean";
                        operationString = "Checking if two points are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb12":
                    {
                        // Compares an Object and a Point for equality using the non-static Equals method.
                        Point point1 = new Point(10, 5);
                        Point point2 = new Point(15, 40);
                        Boolean areEqual;

                        areEqual = point1.Equals(point2);
                        // areEqual is False

                        // Displaying Results
                        syntaxString = "areEqual = point1.Equals(point2);";
                        resultType = "Boolean";
                        operationString = "Checking if two points are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb13":
                    {
                        // Compares an Object and a Vector for equality using the non-static Equals method.
                        Vector vector1 = new Vector(20, 30);
                        Vector vector2 = new Vector(45, 70);
                        Boolean areEqual;

                        areEqual = vector1.Equals(vector2);
                        // areEqual is False

                        // Displaying Results
                        syntaxString = "areEqual = vector1.Equals(vector2);";
                        resultType = "Boolean";
                        operationString = "Checking if two vectors are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb14":
                    {
                        // Converts a string representation of a point into a Point structure
                        Point pointResult = new Point();

                        pointResult = Point.Parse("1,3");
                        // pointResult is equal to (1, 3)

                        // Displaying Results
                        syntaxString = "pointResult = Point.Parse(\"1,3\");";
                        resultType = "Matrix";
                        operationString = "Converts a string into a Point structure.";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb15":
                    {
                        // Gets a string representation of a Point structure
                        Point point1 = new Point(10, 5);
                        String pointString;

                        pointString = point1.ToString();
                        // pointString is equal to 10,5

                        // Displaying Results
                        syntaxString = "pointString = point1.ToString();";
                        resultType = "String";
                        operationString = "Getting the string representation of a Point";
                        ShowResults(pointString.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb16":
                    {
                        // Gets the hashcode of a Point structure

                        Point point1 = new Point(10, 5);
                        int pointHashCode;

                        pointHashCode = point1.GetHashCode();

                        // Displaying Results
                        syntaxString = "pointHashCode = point1.GetHashCode();";
                        resultType = "int";
                        operationString = "Getting the hashcode of Point";
                        ShowResults(pointHashCode.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb17":
                    {
                        // Explicitly converts a Point structure into a Size structure
                        // Returns a Size.

                        Point point1 = new Point(10, 5);
                        Size size1 = new Size();

                        size1 = (Size)point1;
                        // size1 has a width of 10 and a height of 5

                        // Displaying Results
                        syntaxString = "size1 = (Size)point1;";
                        resultType = "Size";
                        operationString = "Expliciting casting a Point into a Size";
                        ShowResults(size1.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb18":
                    {
                        // Explicitly converts a Point structure into a Vector structure
                        // Returns a Vector.

                        Point point1 = new Point(10, 5);
                        Vector vector1 = new Vector();

                        vector1 = (Vector)point1;
                        // vector1 is equal to (10,5)

                        // Displaying Results
                        syntaxString = "vector1 = (Vector)point1;";
                        resultType = "Vector";
                        operationString = "Expliciting casting a Point into a Vector";
                        ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                // task example.  Not accessed through radio buttons
                case "rb20":
                    {
                        // Checks if two Points are not equal using the overloaded inequality operator.

                        // Declaring point1 and initializing x,y values
                        Point point1 = new Point(10, 5);

                        // Declaring point2 without initializing x,y values
                        Point point2 = new Point();

                        // Boolean to hold the result of the comparison
                        Boolean areNotEqual;

                        // assigning values to point2
                        point2.X = 15;
                        point2.Y = 40;

                        // checking for inequality
                        areNotEqual = (point1 != point2);

                        // areNotEqual is True

                        // Displaying Results
                        syntaxString = "areNotEqual = (point1 != point2);";
                        resultType = "Boolean";
                        operationString = "Checking if two points are not equal";
                        ShowResults(areNotEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                default:
                    break;

            } //end switch
        }
示例#26
0
        // This method performs the Point operations
        public void PerformOperation(object sender, RoutedEventArgs e)
        {
            var 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.
                var point1  = new System.Windows.Point(10, 5);
                var vector1 = new Vector(20, 30);

                var 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.
                var point1  = new System.Windows.Point(10, 5);
                var vector1 = new Vector(20, 30);

                var pointResult = System.Windows.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.
                var point1  = new System.Windows.Point(10, 5);
                var vector1 = new Vector(20, 30);

                var 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.
                var point1  = new System.Windows.Point(10, 5);
                var vector1 = new Vector(20, 30);

                var pointResult = System.Windows.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.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var vectorResult = point1 - point2;
                // vectorResult is equal to (-5, -35)

                // Displaying Results
                syntaxString    = "vectorResult = point1 - point2;";
                resultType      = "Vector";
                operationString = "Subtracting a Point from a Point";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb6":
            {
                // Subtracts a Point from a Point using the static Subtract method.
                // Returns a Vector.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var vectorResult = System.Windows.Point.Subtract(point1, point2);
                // vectorResult is equal to (-5, -35)

                // Displaying Results
                syntaxString    = "vectorResult = Point.Subtract(point1, point2);";
                resultType      = "Vector";
                operationString = "Subtracting a Point from a Point";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb7":
            {
                // Offsets the X and Y values of a Point.
                var point1 = new System.Windows.Point(10, 5);

                point1.Offset(20, 30);
                // point1 is equal to (30, 35)

                // Note: This operation is equivalent to adding a point
                // to vector with the corresponding X,Y values.

                // Displaying Results
                syntaxString    = "point1.Offset(20,30);";
                resultType      = "Point";
                operationString = "Offsetting a Point";
                ShowResults(point1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb8":
            {
                // Multiplies a Point by a Matrix.
                // Returns a Point.
                var point1  = new System.Windows.Point(10, 5);
                var matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                var pointResult = point1 * matrix1;
                // pointResult is equal to (780, 940)

                // Displaying Results
                resultType      = "Point";
                syntaxString    = "pointResult = point1 * matrix1;";
                operationString = "Multiplying a Point by a Matrix";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb9":
            {
                // Multiplies a Point by a Matrix.
                // Returns a Point.
                var point1  = new System.Windows.Point(10, 5);
                var matrix1 = new Matrix(40, 50, 60, 70, 80, 90);

                var pointResult = System.Windows.Point.Multiply(point1, matrix1);
                // pointResult is equal to (780, 940)

                // Displaying Results
                resultType      = "Point";
                syntaxString    = "pointResult = Point.Multiply(point1, matrix1);";
                operationString = "Multiplying a Point by a Matrix";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb10":
            {
                // Checks if two Points are equal using the overloaded equality operator.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var areEqual = (point1 == point2);
                // areEqual is False

                // Displaying Results
                syntaxString    = "areEqual = (point1 == point2);";
                resultType      = "Boolean";
                operationString = "Checking if two points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }


            case "rb11":
            {
                // Checks if two Points are equal using the static Equals method.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var areEqual = System.Windows.Point.Equals(point1, point2);
                // areEqual is False

                // Displaying Results
                syntaxString    = "areEqual = Point.Equals(point1, point2);";
                resultType      = "Boolean";
                operationString = "Checking if two points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb12":
            {
                // Compares an Object and a Point for equality using the non-static Equals method.
                var point1 = new System.Windows.Point(10, 5);
                var point2 = new System.Windows.Point(15, 40);

                var areEqual = point1.Equals(point2);
                // areEqual is False


                // Displaying Results
                syntaxString    = "areEqual = point1.Equals(point2);";
                resultType      = "Boolean";
                operationString = "Checking if two points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb13":
            {
                // Compares an Object and a Vector for equality using the non-static Equals method.
                var vector1 = new Vector(20, 30);
                var vector2 = new Vector(45, 70);

                var areEqual = vector1.Equals(vector2);
                // areEqual is False


                // Displaying Results
                syntaxString    = "areEqual = vector1.Equals(vector2);";
                resultType      = "Boolean";
                operationString = "Checking if two vectors are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb14":
            {
                // Converts a string representation of a point into a Point structure

                var pointResult = System.Windows.Point.Parse("1,3");
                // pointResult is equal to (1, 3)

                // Displaying Results
                syntaxString    = "pointResult = Point.Parse(\"1,3\");";
                resultType      = "Matrix";
                operationString = "Converts a string into a Point structure.";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb15":
            {
                // Gets a string representation of a Point structure
                var point1 = new System.Windows.Point(10, 5);

                var pointString = point1.ToString();
                // pointString is equal to 10,5

                // Displaying Results
                syntaxString    = "pointString = point1.ToString();";
                resultType      = "String";
                operationString = "Getting the string representation of a Point";
                ShowResults(pointString, syntaxString, resultType, operationString);
                break;
            }

            case "rb16":
            {
                // Gets the hashcode of a Point structure

                var point1 = new System.Windows.Point(10, 5);

                var pointHashCode = point1.GetHashCode();

                // Displaying Results
                syntaxString    = "pointHashCode = point1.GetHashCode();";
                resultType      = "int";
                operationString = "Getting the hashcode of Point";
                ShowResults(pointHashCode.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb17":
            {
                // Explicitly converts a Point structure into a Size structure
                // Returns a Size.

                var point1 = new System.Windows.Point(10, 5);

                var size1 = (Size)point1;
                // size1 has a width of 10 and a height of 5

                // Displaying Results
                syntaxString    = "size1 = (Size)point1;";
                resultType      = "Size";
                operationString = "Expliciting casting a Point into a Size";
                ShowResults(size1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb18":
            {
                // Explicitly converts a Point structure into a Vector structure
                // Returns a Vector.

                var point1 = new System.Windows.Point(10, 5);

                var vector1 = (Vector)point1;
                // vector1 is equal to (10,5)

                // Displaying Results
                syntaxString    = "vector1 = (Vector)point1;";
                resultType      = "Vector";
                operationString = "Expliciting casting a Point into a Vector";
                ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            // task example.  Not accessed through radio buttons
            case "rb20":
            {
                // Checks if two Points are not equal using the overloaded inequality operator.

                // Declaring point1 and initializing x,y values
                var point1 = new System.Windows.Point(10, 5);

                // Declaring point2 without initializing x,y values
                var point2 = new System.Windows.Point
                {
                    X = 15,
                    Y = 40
                };

                // Boolean to hold the result of the comparison

                // assigning values to point2

                // checking for inequality
                var areNotEqual = (point1 != point2);

                // areNotEqual is True

                // Displaying Results
                syntaxString    = "areNotEqual = (point1 != point2);";
                resultType      = "Boolean";
                operationString = "Checking if two points are not equal";
                ShowResults(areNotEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }
            } //end switch
        }
        public void MoveTo(Point NewPosition)
        {
            if (NewPosition.X < TopLeft.X + orientedWidth(displayOrientation))
                NewPosition.X = TopLeft.X;
            if (NewPosition.X > BottomRight.X - orientedWidth(displayOrientation))
                NewPosition.X = BottomRight.X - orientedWidth(displayOrientation);

            if (NewPosition.Y < TopLeft.Y + orientedHeight(displayOrientation))
                NewPosition.Y = TopLeft.Y ;
            if (NewPosition.Y > BottomRight.Y - orientedHeight(displayOrientation))
                NewPosition.Y = BottomRight.Y - orientedHeight(displayOrientation);
            Debugger.Log(0, "", "\nMove to " + NewPosition.ToString() + " between " + TopLeft.ToString() + " and " + BottomRight.ToString() + "\n");
            me.From = Position;
            me.To = NewPosition;
            me.Duration = 500;
            me.Speed = 1;
            me.Transform = ThisTransform;
            me.Mode = EasingMode.EaseOut;
            me.EasingFunction = new CircleEase();
            me.Start(this);
            me.Completed += (s, e) =>
            {
                Position = NewPosition;
            };
        }
示例#28
0
        /// <summary>
        /// Gets the bitmap to display
        /// </summary>


        /// <summary>
        /// Gets or sets the current status text to display
        /// </summary>
        private unsafe void TextGenerate(ushort* ProcessData)
        {
            int VerticalCheckDistance = 150;
            int HorizontalCheckDistance = 150;
            int HorizontalError = 0;
            int VerticalError = 0;
            Point roop = new Point();
            if (!colorFrameStreamWriterIsSet)
            {
                fileName = System.IO.Path.Combine(@"V:\EnglishPaperPresentation\", "Color" + "Measure" + this.FileNameTextbox.GetLineText(0) + ".dat");
                writingColor = new System.IO.StreamWriter(fileName, false, System.Text.Encoding.GetEncoding("shift_jis"));
                colorFrameStreamWriterIsSet = true;

            }

            if (cursol_locked)
            {
                if (WritingFlag)
                {
                    writeFullFrameToArray(ProcessData);
                    writeColorFrameToFile(colorBufferArray);
                    Array.Clear(colorBufferArray, 0,colorBufferArray.Length - 1);
                    writeDownedCounter++;
                    if (writeDownedCounter == RECORD_SIZE)
                    {
                        WritingFlag = false;
                        writeToText(measureDepthArray, centerDepthArray, "Depth");
                        ButtonWriteDown.IsEnabled = true;
                    }
                }

                else
                {
                    TimeStampFrag = false;
                }
                targetPosition = getLockPosition();
                if (targetPosition.X == 256 && targetPosition.Y == 212 && !WritingFlag)
                {
                    for (int indexValueX = -1; indexValueX < 2; indexValueX++)
                    {
                        for (int indexValueY = -1; indexValueY < 2; indexValueY++)
                        {
                            roop.X = targetPosition.X + HorizontalCheckDistance * indexValueX;
                            roop.Y = targetPosition.Y + VerticalCheckDistance * indexValueY;
                            this.ValueLabels[(indexValueX + 1) + 3 * (indexValueY + 1)].Content = roop.ToString() + "\r\n" + shiburinkawaiiyoo(ProcessData, roop.X,roop.Y);
                            HorizontalError = (shiburinkawaiiyoo(ProcessData, targetPosition.X - HorizontalCheckDistance, targetPosition.Y) - shiburinkawaiiyoo(ProcessData, targetPosition.X + HorizontalCheckDistance, targetPosition.Y));
                            VerticalError = (shiburinkawaiiyoo(ProcessData, targetPosition.X, targetPosition.Y - VerticalCheckDistance) - shiburinkawaiiyoo(ProcessData, targetPosition.X, targetPosition.Y + VerticalCheckDistance));

                        }
                    }
                }
                this.filenameLabel.Content = "X error " + HorizontalError.ToString() + "\r\nY error " + VerticalError.ToString();
                this.StatusText = targetPosition.X + " " + targetPosition.Y + " " + shiburinkawaiiyoo(DepthGlobalArray, targetPosition.X, targetPosition.Y) + " Writing is " + WritingFlag + " Writed sample number =" + writeDownedCounter.ToString();
            }
            else
            {
                this.StatusText = "unlocked";
            }
        }
示例#29
0
        public void PerformOperation(object sender, RoutedEventArgs e)
        {
            RadioButton li = sender as RadioButton;
            String syntaxString, resultType, operationString;
            String[,] varArray = new String[5,2];

            ///The local variable point1, vector1, matrix1, 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":
                    {
                        // Multiplies a Matrix by a Matrix using the overloaded * operator
                        // Returns a Matrix
                        Matrix matrix1 = new Matrix(5,10,15,20,25,30);
                        Boolean isInvertible;

                        isInvertible = matrix1.HasInverse;
                        // isInvertible is equal to True

                        // Displaying Results
                        syntaxString = "isInvertible = matrix1.HasInverse;";
                        resultType = "Boolean";
                        operationString = "Checking if matrix1 is invertible";
                        ShowResults(isInvertible.ToString(), syntaxString, resultType, operationString);

                        break;
                    }
                case "rb2":
                    {
                        // Translates a Matrix
                        // Returns a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrixResult = new Matrix();
                        Double offsetX = 15;
                        Double offsetY = 25;

                        matrix1.Translate(offsetX, offsetY);
                        // matrix1 is not equal to

                        //Displaying Results
                        syntaxString = "matrix1.Translate(offsetX, offsetY);";
                        resultType = "Void";
                        operationString = "Translating a Matrix by a Point";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);

                        break;
                    }
                case "rb3":
                    {
                        // Prepend a Tranlsation to a Matrix
                        // Returns a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrixResult = new Matrix();
                        Double offsetX = 15;
                        Double offsetY = 25;

                        matrix1.TranslatePrepend(offsetX, offsetY);
                        // matrix1 is not equal to

                        //Displaying Results
                        syntaxString = " matrix1.TranslatePrepend(offsetX, offsetY);";
                        resultType = "Void";
                        operationString = "Prepending Translating a matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);

                        break;
                    }
                case "rb4":
                    {
                        // Sets a Matrix to an identity matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);

                        matrix1.SetIdentity();
                        // matrix1 is now equal to (1,0,0,1,0,0)

                        //Displaying Results
                        syntaxString = "matrix1.SetIdentity();";
                        resultType = "Void";
                        operationString = "Setting a matrix to an identity matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);

                        break;
                    }
                case "rb5":
                    {

                        // Checks if a Matrix is an identity matrix

                        // Creates a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Boolean isIdentityMatrix;

                        // Sets matrix1 into an identity matrix
                        matrix1.SetIdentity();

                        isIdentityMatrix = matrix1.IsIdentity;
                        // isIdentityMatrix is equal to True

                        //Displaying Results
                        syntaxString = "isIdentityMatrix = matrix1.IsIdentity;";
                        resultType = "Boolean";
                        operationString = "Determining if a Matrix is an identity matrix";
                        ShowResults(isIdentityMatrix.ToString(), syntaxString, resultType, operationString);

                        break;
                    }

                case "rb6":
                    {
                        // Changes a Matrix into an identity matrix

                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);

                        matrix1 = Matrix.Identity;
                        // matrix1 is now equal to (1,0,0,1,0,0)

                        //Displaying Results
                        syntaxString = "matrix1 = Matrix.Identity;";
                        resultType = "Matrix";
                        operationString = "Gets an identity Matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);

                        break;
                    }
                case "rb7":
                    {
                        // Converts a string representation of a matrix into a Matrix structure
                        Matrix matrixResult = new Matrix();

                        matrixResult = Matrix.Parse("1,2,3,4,5,6");
                        // matrixResult is equal to (1,2,3,4,5,6)

                        //Displaying Results
                        syntaxString = "matrixResult = Matrix.Parse(\"1,2,3,4,5,6\");";
                        resultType = "Matrix";
                        operationString = "Convert a string into a Matrix structure";
                        ShowResults(matrixResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb8":
                    {
                        // Checks if two Matrixes are equal using the static Equals method
                        // Returns a Boolean.
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);
                        Boolean areEqual;

                        areEqual = Matrix.Equals(matrix1, matrix2);
                        // areEqual is equal to False

                        //Displaying Results
                        syntaxString = "areEqual = Matrix.Equals(matrix1, matrix2);";
                        resultType = "Boolean";
                        operationString = "Checking if the matrices are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);

                        break;
                    }
                case "rb8b":
                    {
                        // Checks if an Object is equal to a Matrix using the static Equals method
                        // Returns a Boolean.
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);
                        Boolean areEqual;

                        areEqual = matrix1.Equals(matrix2);
                        // areEqual is equal to False

                        //Displaying Results
                        syntaxString = "areEqual = Matrix.Equals(matrix1, matrix2);";
                        resultType = "Boolean";
                        operationString = "Checking if the matrices are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);

                        break;
                    }

                case "rb9":
                    {
                        // Checks if two Matrixes are equal using the overloaded == operator
                        // Returns a Boolean.
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);
                        Boolean areEqual;

                        areEqual = matrix1 == matrix2;
                        // areEqual is equal to False

                        //Displaying Results
                        syntaxString = "areEqual = matrix1 == matrix2;";
                        resultType = "Boolean";
                        operationString = "Checking if the matrices are equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb10":
                    {
                        // Checks if two Matrixes are not equal using the overloaded != operator
                        // Returns a Boolean.
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);
                        Boolean areEqual;

                        areEqual = matrix1 != matrix2;
                        // areEqual is equal to False

                        //Displaying Results
                        syntaxString = "areEqual = matrix1 != matrix2;";
                        resultType = "Boolean";
                        operationString = "Checking if the matrices are not equal";
                        ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb11":
                    {
                        // Inverts a Matrix

                        // Creating a Matrix structure
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);

                        // Checking if matrix1 is invertible
                        if (matrix1.HasInverse)
                        {

                            // Inverting matrix1
                            matrix1.Invert();

                            // matrix1 is equal to (-0.04, 0.2 , 0.3, -0.1, 1, -2)
                        }

                        //Displaying Results
                        syntaxString = "matrix1.Invert();";
                        resultType = "Void";
                        operationString = "Inverting a matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;
                    }
                case "rb12":
                    {
                        // Prepends a Matrix to another Matrix.
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);

                        matrix1.Prepend(matrix2);
                        // matrix1 is equal to (70,100,150,220,255,370)

                        //Displaying Results
                        syntaxString = "matrix1.Prepend(matrix2);";
                        resultType = "Void";
                        operationString = "Prepending a Matrix to another Matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }
                case "rb13":
                    {
                        // Appends a Matrix to another Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);

                        matrix1.Append(matrix2);
                        // matrix1 is equal to (70,100,150,220,240,352)

                        //Displaying Results
                        syntaxString = "matrix1.Append(matrix2);";
                        resultType = "Void";
                        operationString = "Appending a Matrix to another Matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }
                case "rb14":
                    {
                        // Rotates a Matrix by a specified angle
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Double rotateAngle = 90;

                        matrix1.Rotate(rotateAngle);
                        // matrix1 is equal to (-10,5,-20,15,-30,25)

                        //Displaying Results
                        syntaxString = "matrix1.Rotate(rotateAngle);";
                        resultType = "Void";
                        operationString = "Rotating a Matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb15":
                    {
                        // Rotates a Matrix by a specified angle at a specific point
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);

                        matrix1.RotateAt(90, 2, 4);
                        // matrix1 is equal to (-10,5,-20,15,-24,27)

                        //Displaying Results
                        syntaxString = "matrix1.RotateAt(rotateAngle, rotateCenterX, rotateCenterY);";
                        resultType = "Void";
                        operationString = "Rotating a Matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }

                case "rb16":
                    {
                        // Prepends a Rotation to a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Double rotateAngle = 90;

                        matrix1.RotatePrepend(rotateAngle);
                        // matrix1 is equal to (15,20,-5,-10,25,30)

                        //Displaying Results
                        syntaxString = "matrix1.RotatePrepend(rotateAngle);";
                        resultType = "Void";
                        operationString = "Rotating a Matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }

                case "rb17":
                    {
                        // Prepends a Rotation at a specific point to a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Double rotateAngle = 90;

                        matrix1.RotateAtPrepend(90, 2, 4);
                        // matrix1 is equal to  (15,20,-5,-10,85,130)

                        //Displaying Results
                        syntaxString = "matrix1.RotateAtPrepend(rotateAngle, rotateCenterX, rotateCenterY);";
                        resultType = "Void";
                        operationString = "Rotating a Matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }

                case "rb18":
                    {
                        // Scales a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Double scaleX = (1);
                        Double scaleY = (2);

                        matrix1.Scale(scaleX, scaleY);
                        // matrix1 is equal to

                        //Displaying Results
                        syntaxString = "matrix1.Scale(scaleX, scaleY);";
                        resultType = "Void";
                        operationString = "Scaling a Matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }
                case "rb19":
                    {
                        // Multiplies a Matrix by another Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);
                        Matrix matrixResult = new Matrix();

                        matrixResult = Matrix.Multiply(matrix2, matrix1);
                        // matrixResult is equal to (70, 100, 150, 220, 255, 370)

                        //Displaying Results
                        syntaxString = "matrixResult = Matrix.Multiply(matrix2, matrix1);";
                        resultType = "Matrix";
                        operationString = "Multiplying matrix1 and matrix2";
                        ShowResults(matrixResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb20":
                    {
                        // Multiplies a Matrix by another Matrix using the overloaded * operator
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);
                        Matrix matrixResult = new Matrix();

                        matrixResult = matrix1 * matrix2;
                        // matrixResult is equal to (70, 100, 150, 220, 240, 352)

                        //Displaying Results
                        syntaxString = " matrixResult = matrix1 * matrix2;";
                        resultType = "Matrix";
                        operationString = "Multiplying matrix1 and matrix2";
                        ShowResults(matrixResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb21":
                    {
                        // Appends a skew to a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Double skewAngleX = 45;
                        Double skewAngleY = 180;

                        matrix1.Skew(skewAngleX, skewAngleY);
                        // matrix1 is equal to (15, 10, 35, 20, 55, 30)

                        //Displaying Results
                        syntaxString = "matrix1.Skew(skewAngleX, skewAngleY);";
                        resultType = "Void";
                        operationString = "Multiplying matrix2 and matrix1";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }

                case "rb22":
                    {
                        // Prepends a skew to a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Double skewAngleX = 45;
                        Double skewAngleY = 180;

                        matrix1.SkewPrepend(skewAngleX, skewAngleY);
                        // matrix1 is equal to (5, 10, 20, 30, 25, 30)

                        //Displaying Results
                        syntaxString = "matrix1.SkewPrepend(skewAngleX, skewAngleY);";
                        resultType = "Void";
                        operationString = "Multiplying matrix2 and matrix1";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }

                case "rb23":
                    {
                        // Appends a scale to a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Double scaleFactorX = 2;
                        Double scaleFactorY = 4;

                        matrix1.Scale(scaleFactorX, scaleFactorY);
                        // matrix1 is equal to (10, 40, 30, 80, 50, 120)

                        //Displaying Results
                        syntaxString = "matrix1.Scale(scaleFactorX, scaleFactorY);";
                        resultType = "Void";
                        operationString = "Appending a scale to a matrix";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }
                case "rb24":
                    {
                        // Appends a scale at a specific point to a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);

                        matrix1.ScaleAt(2, 4, 5, 10);
                        // matrix1 is equal to (10, 40, 30, 80, 45, 90)

                        //Displaying Results
                        syntaxString = " matrix1.ScaleAt(scaleFactorX, scaleFactorY, scaleCenterX, scaleCenterY);";
                        resultType = "Void";
                        operationString = "Appends a scale at a specific point to matrix1";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }
                case "rb25":
                    {
                        // Prepends a scale to a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Double scaleFactorX = 2;
                        Double scaleFactorY = 4;

                        matrix1.ScalePrepend(scaleFactorX, scaleFactorY);
                        // matrix1 is equal to (10, 20, 60, 80, 25, 30)

                        //Displaying Results
                        syntaxString = "matrix1.ScalePrepend(scaleFactorX, scaleFactorY);";
                        resultType = "Void";
                        operationString = "Prepending a scale to matrix1";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }
                case "rb26":
                    {
                        // Prepends a scale at a specific point to a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);

                        matrix1.ScaleAtPrepend(2, 4, 5, 10);
                        // matrix1 is equal to (10, 20, 60, 80, -450, -620)

                        //Displaying Results
                        syntaxString = "matrix1.ScalePrependAt(scaleFactorX, scaleFactorY, centerPointX, centerPointY);";
                        resultType = "Void";
                        operationString = "Prepending a scale at a specific point to matrix1";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;

                    }

                case "rb29":
                    {
                        // Transform a point by a matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Point point1 = new Point(15, 25);
                        Point pointResult = new Point();

                        pointResult = matrix1.Transform(point1);
                        // pointResult is equal to (475, 680)

                        //Displaying Results
                        syntaxString = "pointResult = matrix1.Transform(point1)";
                        resultType = "Point";
                        operationString = "Transforming a point1 by matrix1";
                        ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                        break;

                    }
                case "rb30":
                    {
                        // Transform a Vector by a Matrix
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Vector vector1 = new Vector(15, 25);
                        Vector vectorResult = new Vector();

                        vectorResult = matrix1.Transform(vector1);
                        // vectorResult is equal to (450, 650)

                        //Displaying Results
                        syntaxString = "vectorResult = matrix1.Transform(vector1);";
                        resultType = "Vector";
                        operationString = "Multiplying matrix2 and matrix1";
                        ShowResults(matrix1.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb31":
                    {
                        // Transform an array of Points by a Matrix

                        // Creating a Matrix and an array of Pointers
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Point[] pointArray = new Point[2];

                        // Setting the Point's X and Y values
                        pointArray[0].X = 15;
                        pointArray[0].Y = 25;
                        pointArray[1].X = 30;
                        pointArray[1].Y = 35;

                        // Transforming the Points in pointArry by matrix1
                        matrix1.Transform(pointArray);

                        // pointArray[0] is equal to (475, 680)
                        // pointArray[1] is equal to (700, 1030)

                        //Displaying Results
                        syntaxString = "matrix1.Transform(pointArray);";
                        resultType = "void";
                        operationString = "Transforming an array of Points by matrix1";
                        ShowResults(pointArray[1].ToString(), syntaxString, resultType, operationString);
                        break;

                    }
                case "rb32":
                    {
                        // Transform an array of Vectors by a Matrix

                        // Creating  a Matrix and an array of Vectors
                        Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
                        Vector[] vectorArray = new Vector[2];

                        // Setting the Vector's X and Y values
                        vectorArray[0].X = 15;
                        vectorArray[0].Y = 25;
                        vectorArray[1].X = 30;
                        vectorArray[1].Y = 35;

                        // Transforming the Vectors in vectorArray by matrix1
                        matrix1.Transform(vectorArray);

                        // VectorArray[0] is equal to (450, 650)
                        // VectorArray[1] is equal to (675, 1000)

                        //Displaying Results
                        syntaxString = " matrix1.Transform(vectorArray);";
                        resultType = "Void";
                        operationString = "Multiplying matrix2 and matrix1";
                        ShowResults(vectorArray[0].ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                default:
                        break;
            }// end switch
        }
示例#30
0
        ///<summary>增加线段或多边形控制点</summary>
        private void btnAddDot_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            EDDot dot;

            if (editobj is pPowerLine)
            {
                pPowerLine lin    = editobj as pPowerLine;
                int        idx    = assobj.order;
                int        idx2   = lin.VecPoints.Count() - 1 == idx ? idx - 1 : idx + 1;
                int        idxmin = Math.Min(idx, idx2);                 //这一点及以前的序号不变
                foreach (PowerBasicObject item in elayer.pModels.Values) //所有后点序号+1
                {
                    if (item is EDDot)
                    {
                        dot = item as EDDot;
                        if (dot.order > idxmin)
                        {
                            dot.order = dot.order + 1;
                        }
                    }
                }

                VECTOR3D np = new VECTOR3D((lin.VecPoints[idx].x + lin.VecPoints[idx2].x) / 2, (lin.VecPoints[idx].y + lin.VecPoints[idx2].y) / 2, (lin.VecPoints[idx].z + lin.VecPoints[idx2].z) / 2);

                lin.VecPoints.Insert(idxmin + 1, np);
                lin.sendChangedLocation();

                System.Windows.Media.Media3D.Point3D p3d = new System.Windows.Media.Media3D.Point3D(np.x, np.y, np.z);
                System.Windows.Media.Media3D.Point3D jwh = Helpler.PointToJWH(p3d, distnet.scene.earthManager.earthpara);
                System.Windows.Point pnt = new System.Windows.Point(jwh.Y, jwh.X);
                if (distnet.scene.coordinateManager.Enable)
                {
                    pnt = distnet.scene.coordinateManager.transToOuter(pnt);                                          //若启用了坐标转换,转换为外部坐标
                }
                dot = new EDDot(elayer)
                {
                    id       = MyClassLibrary.helper.getGUID(),
                    location = pnt.ToString(),
                };
                dot.order  = idxmin + 1;
                dot.scaleX = dot.scaleY = dot.scaleZ = distnet.UnitMeasure * 5;
                elayer.AddObject(dot);
            }
            else if (editobj is pArea)
            {
                pArea lin    = editobj as pArea;
                int   idx    = assobj.order;
                int   idx2   = lin.VecPoints.Count() - 1 == idx ? idx - 1 : idx + 1;
                int   idxmin = Math.Min(idx, idx2);                      //这一点及以前的序号不变
                foreach (PowerBasicObject item in elayer.pModels.Values) //所有后点序号+1
                {
                    if (item is EDDot)
                    {
                        dot = item as EDDot;
                        if (dot.order > idxmin)
                        {
                            dot.order = dot.order + 1;
                        }
                    }
                }

                VECTOR3D np = new VECTOR3D((lin.VecPoints[idx].x + lin.VecPoints[idx2].x) / 2, (lin.VecPoints[idx].y + lin.VecPoints[idx2].y) / 2, (lin.VecPoints[idx].z + lin.VecPoints[idx2].z) / 2);

                lin.VecPoints.Insert(idxmin + 1, np);
                lin.sendChangedLocation();

                System.Windows.Media.Media3D.Point3D p3d = new System.Windows.Media.Media3D.Point3D(np.x, np.y, np.z);
                System.Windows.Media.Media3D.Point3D jwh = Helpler.PointToJWH(p3d, distnet.scene.earthManager.earthpara);
                System.Windows.Point pnt = new System.Windows.Point(jwh.Y, jwh.X);
                if (distnet.scene.coordinateManager.Enable)
                {
                    pnt = distnet.scene.coordinateManager.transToOuter(pnt);                                          //若启用了坐标转换,转换为外部坐标
                }
                dot = new EDDot(elayer)
                {
                    id       = MyClassLibrary.helper.getGUID(),
                    location = pnt.ToString(),
                };
                dot.order  = idxmin + 1;
                dot.scaleX = dot.scaleY = dot.scaleZ = distnet.UnitMeasure * 5;
                elayer.AddObject(dot);
            }

            distnet.scene.UpdateModel();
        }
        private Point getDisplayPosition(Joint joint)
        {
            float depthX, depthY;
            nui.SkeletonEngine.SkeletonToDepthImage(joint.Position, out depthX, out depthY);
            depthX = Math.Max(0, Math.Min(depthX * 320, 320));  //convert to 320, 240 space
            depthY = Math.Max(0, Math.Min(depthY * 240, 240));  //convert to 320, 240 space
            int colorX, colorY;
            ImageViewArea iv = new ImageViewArea();
            // only ImageResolution.Resolution640x480 is supported at this point
            nui.NuiCamera.GetColorPixelCoordinatesFromDepthPixel(ImageResolution.Resolution640x480, iv, (int)depthX, (int)depthY, (short)0, out colorX, out colorY);

            // map back to skeleton.Width & skeleton.Height
            Point p = new Point((int)(skeleton.Width * colorX / 640.0), (int)(skeleton.Height * colorY / 480));
            if (p.X < 10 && p.Y < 10)
            {

                System.Diagnostics.Debug.WriteLine("Point: " + p.ToString());
            }
            return p;
        }
 public void singleClick(object sender, TouchContactEventArgs e)
 {
     Console.WriteLine("This only happends when the single click event is satisfied");
     Point point = new Point();
     point = ((TouchContactEventArgs)e).TouchContact.GetPosition((InteractiveBorder)sender);
     Console.WriteLine(point.ToString());
     Get_Region_For_Single_Click(point);
 }
示例#33
0
        // Method to display the variables used in the operations
        public void ShowVars()
        {
            // Displays the values of the variables
            var p1 = new Point(10, 5);
            var p2 = new Point(15, 40);

            var v1 = new System.Windows.Vector(20, 30);
            var v2 = new System.Windows.Vector(45, 70);

            var 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(CultureInfo.InvariantCulture);
        }
        private void Crown_Unchecked(object sender, RoutedEventArgs e)
        {
            try
            {
                crown_points = drawHost.getPoints()[0];
                MessageBox.Show(crown_points.ToString());
            }
            catch
            {

            }
            drawHost.CurrentEditor = null;
        }
示例#35
0
        internal void TS_CreatePoint(ref TextPatternRange range, Rect[] boundRects, out Point screenLocation, BoundingRectangleLocation boundRectLoc, CheckType checkType)
        {
            int rectIdx = 0;
            Rect autoElementRect = new Rect();
            Rect[] tempRects = new Rect[0];
            TextPatternRange documentRange = Pattern_DocumentRange(CheckType.Verification);

            screenLocation = new Point();

            // Sanity check
            Library.ValidateArgumentNonNull(range, "range argument cannot be null");

            if ((boundRects.Length == 0) && (boundRectLoc != BoundingRectangleLocation.OutsideAutomationElement))
            {
                throw new ArgumentException("TS_CreatePoint requires non-empty array of bounding rectangles");
            }

            // Finally, generate the point!
            switch (boundRectLoc)
            {
                case BoundingRectangleLocation.InsideTopLeft:
                    rectIdx = 0;
                    screenLocation.X = boundRects[rectIdx].Left + 1;
                    screenLocation.Y = boundRects[rectIdx].Top + 1;
                    break;
                case BoundingRectangleLocation.Middle:
                    screenLocation.X = (boundRects[rectIdx].Left + boundRects[rectIdx].Right) / 2;
                    screenLocation.Y = (boundRects[rectIdx].Top + boundRects[rectIdx].Bottom) / 2;
                    break;
                case BoundingRectangleLocation.InsideBottomRight:
                    rectIdx = boundRects.Length - 1;
                    screenLocation.X = boundRects[rectIdx].Right - 1;
                    screenLocation.Y = boundRects[rectIdx].Bottom - 1;
                    break;
                case BoundingRectangleLocation.OutsideBottomRight:
                    rectIdx = boundRects.Length - 1;
                    screenLocation.X = boundRects[rectIdx].Right + 1;
                    screenLocation.Y = boundRects[rectIdx].Bottom + 1;
                    break;
                case BoundingRectangleLocation.OutsideTopLeft:
                    rectIdx = 0;
                    screenLocation.X = boundRects[rectIdx].Left - 1;
                    screenLocation.Y = boundRects[rectIdx].Top - 1;
                    break;
                case BoundingRectangleLocation.OutsideAutomationElement:
                    // Get automation element bounding rectangle
                    GetAutomationElementBoundingRectangle(out autoElementRect);
                    screenLocation.X = autoElementRect.Left - 1;
                    screenLocation.Y = autoElementRect.Top - 1;
                    break;
                case BoundingRectangleLocation.FirstChar:
                    tempRects = null;
                    Range_GetBoundingRectangles(documentRange, ref tempRects, null, checkType);
                    if (tempRects.Length == 0)
                        ThrowMe(checkType, "TS_CreatePoint expects non-empy bounding rectangles array for document");
                    screenLocation.X = tempRects[0].Left + 1; // essentially top-left of first rect
                    screenLocation.Y = tempRects[0].Top + 1;
                    break;
                case BoundingRectangleLocation.FirstCharInRange:
                    rectIdx = 0;
                    screenLocation.X = boundRects[0].Left + 1; // essentially top-left of first rect
                    screenLocation.Y = boundRects[0].Top + 1;
                    break;
                case BoundingRectangleLocation.LastCharInRange:
                    rectIdx = boundRects.Length - 1;
                    screenLocation.X = boundRects[rectIdx].Right - 1;   // essentially bottom-right of last rect
                    screenLocation.Y = boundRects[rectIdx].Bottom - 1;
                    break;
                default:
                    throw new ArgumentException("TS_CreatePoint() has no support for " + ParseType(boundRectLoc));
            }

            Comment("Created Point (" + screenLocation.ToString(CultureInfo.InvariantCulture) + ") at " +
                    Parse(boundRectLoc) +
                    " relative to boundRect " +
                    (boundRectLoc != BoundingRectangleLocation.OutsideAutomationElement ?
                        boundRects[rectIdx].ToString(CultureInfo.InvariantCulture) :
                        autoElementRect.ToString(CultureInfo.InvariantCulture)));
            m_TestStep++;

        }
示例#36
0
文件: PointTest.cs 项目: dfr0/moon
		public void ToStringIFormatProvider ()
		{
			Point p = new Point (1, 2);
			PointFormatter.CallCount = 0;
			Assert.AreEqual ("1,2", p.ToString (null), "null");
			Assert.AreEqual (0, PointFormatter.CallCount, "CallCount-a");
			Assert.AreEqual ("[1]#[2]", p.ToString (new PointFormatter ()), "PointFormatter");
			// 3 times: one per double (2) and 1 for ','
			Assert.AreEqual (3, PointFormatter.CallCount, "CallCount");
		}
示例#37
0
        public void PerformOperation(object sender, RoutedEventArgs e)
        {
            RadioButton li = sender as RadioButton;

            // Strings used to display 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.

                System.Windows.Point point1 = new System.Windows.Point(10, 5);
                Vector vector1 = new Vector(20, 30);
                System.Windows.Point pointResult = new System.Windows.Point();

                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":
            {
                //<Snippet10>
                // Adds a Vector to a Vector using the overloaded + operator.

                Vector vector1      = new Vector(20, 30);
                Vector vector2      = new Vector(45, 70);
                Vector vectorResult = new Vector();


                // vectorResult is equal to (65,100)
                vectorResult = vector1 + vector2;
                //</Snippet10>



                // 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.

                Vector vector1      = new Vector(20, 30);
                Vector vector2      = new Vector(45, 70);
                Vector vectorResult = new Vector();

                vectorResult = 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.

                Vector vector1 = new Vector(20, 30);
                System.Windows.Point point1      = new System.Windows.Point(10, 5);
                System.Windows.Point pointResult = new System.Windows.Point();

                pointResult = 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.

                Vector vector1      = new Vector(20, 30);
                Vector vector2      = new Vector(45, 70);
                Vector vectorResult = new Vector();

                vectorResult = vector1 - vector2;

                // vector Result is equal to (-25, -40)

                // Displaying Results
                syntaxString    = "vectorResult = vector1 - vector2;";
                resultType      = "Vector";
                operationString = "Subtracting a Vector from a Vector";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb6":
            {
                // Subtracts a Vector from a Vector using the static Subtract method.

                Vector vector1      = new Vector(20, 30);
                Vector vector2      = new Vector(45, 70);
                Vector vectorResult = new Vector();

                vectorResult = Vector.Subtract(vector1, vector2);

                // vector Result is equal to (-25, -40)

                // Displaying Results
                syntaxString    = "Vector.Subtract(vector1, vector2);";
                resultType      = "Vector";
                operationString = "Subtracting a Vector from a Vector";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb7":
            {
                // Multiplies a Vector by a Scalar using the overloaded * operator.

                Vector vector1      = new Vector(20, 30);
                Double scalar1      = 75;
                Vector vectorResult = new Vector();

                vectorResult = vector1 * scalar1;

                // vectorResult is equal to (1500,2250)

                // Displaying Results
                syntaxString    = "vectorResult = vector1 * scalar1;";
                resultType      = "Vector";
                operationString = "Multiplies a Vector by a Scalar";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb8":
            {
                // Multiplies a Scalar by a Vector using the overloaded * operator.

                Vector vector1      = new Vector(20, 30);
                Double scalar1      = 75;
                Vector vectorResult = new Vector();

                vectorResult = scalar1 * vector1;

                // vectorResult is equal to (1500,2250)

                // Displaying Results
                syntaxString    = "vectorResult = scalar1 * vector1;";
                resultType      = "Vector";
                operationString = "Multiplies a Scalar by a Vector";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb9":
            {
                // Multiplies a Vector by a Vector using the overloaded * operator.

                Vector vector1 = new Vector(20, 30);
                Vector vector2 = new Vector(45, 70);
                Double doubleResult;

                doubleResult = vector1 * vector2;

                // doubleResult is equal to 3000

                // Displaying Results
                syntaxString    = "doubleResult = vector1 * vector2;";
                resultType      = "Double";
                operationString = "Multiplies a Vector by a Vector";
                ShowResults(doubleResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb10":
            {
                // Multiplies a Vector by a Matrix using the overloaded * operator.

                Vector vector1      = new Vector(20, 30);
                Matrix matrix1      = new Matrix(40, 50, 60, 70, 80, 90);
                Vector vectorResult = new Vector();

                vectorResult = vector1 * matrix1;

                // vector Result is equal to (2600,3100)


                // Displaying Results
                syntaxString    = "vectorResult = vector1 * matrix1;";
                resultType      = "Vector";
                operationString = "Multiplies a Vector by a Matrix";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb11":
            {
                // Multiplies a Vector by a Scalar using the static Multiply method.

                Vector vector1      = new Vector(20, 30);
                Double scalar1      = 75;
                Vector vectorResult = new Vector();

                vectorResult = Vector.Multiply(vector1, scalar1);

                // vectorResult is equal to (1500,2250)

                // Displaying Results
                syntaxString    = "vectorResult = Vector.Multiply(vector1, scalar1);";
                resultType      = "Vector";
                operationString = "Multiplies a Vector by a Scalar";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb12":
            {
                // Multiplies a Scalar by a Vector using the static Multiply method.

                Vector vector1      = new Vector(20, 30);
                Double scalar1      = 75;
                Vector vectorResult = new Vector();

                vectorResult = Vector.Multiply(scalar1, vector1);

                // vectorResult is equal to (1500,2250)

                // Displaying Results
                syntaxString    = "vectorResult = Vector.Multiply(scalar1, vector1);";
                resultType      = "Vector";
                operationString = "Multiplies a Scalar by a Vector";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb13":
            {
                // Multiplies a Vector by a Vector using the static Multiply method.

                Vector vector1 = new Vector(20, 30);
                Vector vector2 = new Vector(45, 70);
                Double doubleResult;

                doubleResult = Vector.Multiply(vector1, vector2);

                // doubleResult is equal to 3000

                // Displaying Results
                syntaxString    = "DoubleResult = Vector.Multiply(vector1,vector2);";
                resultType      = "Double";
                operationString = "Multiplies a Vector by a Vector";
                ShowResults(doubleResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb14":
            {
                // Multiplies a Vector by a Matrix using the static Multiply method.

                Vector vector1      = new Vector(20, 30);
                Matrix matrix1      = new Matrix(40, 50, 60, 70, 80, 90);
                Vector vectorResult = new Vector();

                vectorResult = Vector.Multiply(vector1, matrix1);

                // vector Result is equal to (2600,3100)


                // Displaying Results
                syntaxString    = "vectorResult = Vector.Multiply(vector1,matrix1);";
                resultType      = "Vector";
                operationString = "Multiplies a Vector by a Matrix";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb15":
            {
                // Divides a Vector by a Scalar using the overloaded / operator.

                Vector vector1      = new Vector(20, 30);
                Vector vectorResult = new Vector();
                Double scalar1      = 75;

                vectorResult = vector1 / scalar1;

                // vectorResult is approximately equal to (0.26667,0.4)

                // Displaying Results
                syntaxString    = "vectorResult = vector1 / scalar1;";
                resultType      = "Vector";
                operationString = "Dividing a Vector by a Scalar";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb16":
            {
                // Divides a Vector by a Double using the static Divide method.

                Vector vector1      = new Vector(20, 30);
                Vector vectorResult = new Vector();
                Double scalar1      = 75;

                vectorResult = Vector.Divide(vector1, scalar1);

                // vectorResult is approximately equal to (0.26667,0.4)

                // Displaying Results
                syntaxString    = "vectorResult = Vector.Divide(vector1, scalar1);";
                resultType      = "Vector";
                operationString = "Dividing a Vector by a Scalar";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb17":
            {
                // Gets the hashcode of a Vector structure

                Vector vector1 = new Vector(20, 30);
                int    vectorHashCode;

                vectorHashCode = vector1.GetHashCode();

                // Displaying Results
                syntaxString    = "vectorHashCode = vector1.GetHashCode();";
                resultType      = "int";
                operationString = "Getting the hashcode of a Vector";
                ShowResults(vectorHashCode.ToString(), syntaxString, resultType, operationString);
                break;
            }


            case "rb18":
            {
                // Gets the length of a Vector.

                Vector vector1 = new Vector(20, 30);
                Double length;

                length = vector1.Length;

                // length is approximately equal to 36.0555


                // Displaying Results
                syntaxString    = "length = vector1.Length();";
                resultType      = "Double";
                operationString = "Getting the length of a Vector";
                ShowResults(length.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb19":
            {
                // Gets the square of the length of a Vector.

                Vector vector1 = new Vector(20, 30);
                Double lengthSq;

                lengthSq = vector1.LengthSquared;

                // lengthSq is equal to 1300

                // Displaying Results
                syntaxString    = "lengthSq = vector1.LengthSquared;";
                resultType      = "Double";
                operationString = "Getting the length square of a Vector";
                ShowResults(lengthSq.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb20":
            {
                // Normalizes a Vector using the Normalize method.

                Vector vector1 = new Vector(20, 30);

                vector1.Normalize();

                // vector1 is approximately equal to (0.5547,0.8321)

                // Displaying Results
                syntaxString    = "vector1.Normalize();";
                resultType      = "Vector";
                operationString = "Normalizing a Vector";
                ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb21":
            {
                // Calculates the angle between two Vectors using the static AngleBetween method.

                Vector vector1 = new Vector(20, 30);
                Vector vector2 = new Vector(45, 70);
                Double angleBetween;

                angleBetween = Vector.AngleBetween(vector1, vector2);

                // angleBetween is approximately equal to 0.9548

                // Displaying Results
                syntaxString    = "angleBetween = Vector.AngleBetween(vector1, vector2);";
                resultType      = "Double";
                operationString = "Calculating the angle between two Vectors";
                ShowResults(angleBetween.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb22":
            {
                // Calculates the cross product of two Vectors using the static  CrossProduct method.

                Vector vector1 = new Vector(20, 30);
                Vector vector2 = new Vector(45, 70);
                Double crossProduct;

                crossProduct = Vector.CrossProduct(vector1, vector2);

                // crossProduct is equal to 50

                // Displaying Results
                syntaxString    = "crossProduct = Vector.CrossProduct(vector1,vector2);";
                resultType      = "Double";
                operationString = "Calculating the crossproduct of two Vectors";
                ShowResults(crossProduct.ToString(), syntaxString, resultType, operationString);
                break;
            }



            case "rb23":
            {
                // Calculates the determinant of two Vectors using the static Determinant method.

                Vector vector1 = new Vector(20, 30);
                Vector vector2 = new Vector(45, 70);
                Double determinant;

                determinant = Vector.Determinant(vector1, vector2);

                // determinant is equal to 50

                // Displaying Results
                syntaxString    = "determinant = Vector.Determinant(vector1, vector2);";
                resultType      = "Double";
                operationString = "Calculating the determinant of two Vectors";
                ShowResults(determinant.ToString(), syntaxString, resultType, operationString);
                break;
            }


            case "rb24":
            {
                // Checks if two Vectors are equal using the overloaded equality operator.

                // Declaring vecto1 and initializing x,y values
                Vector vector1 = new Vector(20, 30);

                // Declaring vector2 without initializing x,y values
                Vector vector2 = new Vector();

                // Boolean to hold the result of the comparison
                Boolean areEqual;

                // assigning values to vector2
                vector2.X = 45;
                vector2.Y = 70;

                // Comparing Vectors for equality
                areEqual = (vector1 == vector2);

                // areEqual is False

                // Displaying Results
                syntaxString    = "areEqual = (vector1 == vector2);";
                resultType      = "Boolean";
                operationString = "Checking if two vectors are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }


            case "rb25":
            {
                // Checks if two Vectors are equal using the static Equals method.

                Vector  vector1 = new Vector(20, 30);
                Vector  vector2 = new Vector(45, 70);
                Boolean areEqual;

                areEqual = Vector.Equals(vector1, vector2);

                // areEqual is False

                // Displaying Results
                syntaxString    = "areEqual = Vector.Equals(vector1, vector2);";
                resultType      = "Boolean";
                operationString = "Checking if two vectors are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb26":
            {
                // Compares an Object and a Vector for equality using the non-static Equals method.

                Vector  vector1 = new Vector(20, 30);
                Vector  vector2 = new Vector(45, 70);
                Boolean areEqual;

                areEqual = vector1.Equals(vector2);

                // areEqual is False


                // Displaying Results
                syntaxString    = "areEqual = vector1.Equals(vector2);";
                resultType      = "Boolean";
                operationString = "Checking if two vectors are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb27":
            {
                // Converts a string representation of a vector into a Vector structure

                Vector vectorResult = new Vector();

                vectorResult = Vector.Parse("1,3");

                // vectorResult is equal to (1,3)

                // Displaying Results
                syntaxString    = "vectorResult = Vector.Parse(\"1,3\");";
                resultType      = "Vector";
                operationString = "Converting a string into a Vector";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb28":
            {
                // Checks if two Vectors are not equal using the overloaded inequality operator.

                Vector  vector1 = new Vector(20, 30);
                Vector  vector2 = new Vector(45, 70);
                Boolean areNotEqual;

                areNotEqual = (vector1 != vector2);

                // areNotEqual is True

                // Displaying Results
                syntaxString    = "areNotEqual = (vector1 != vector2);";
                resultType      = "Boolean";
                operationString = "Checking if two points are not equal";
                ShowResults(areNotEqual.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb29":
            {
                // Negates a Vector using the Negate method.

                Vector vector1      = new Vector(20, 30);
                Vector vectorResult = new Vector();

                vector1.Negate();

                // vector1 is equal to (-20, -30)

                // Displaying Results
                syntaxString    = "vector1.Negate();";
                resultType      = "void";
                operationString = "Negating a vector";
                ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb30":
            {
                // Negates a Vector using the overloaded unary negation operator.

                Vector vector1      = new Vector(20, 30);
                Vector vectorResult = new Vector();

                vectorResult = -vector1;

                // vectorResult is equal to (-20, -30)

                // Displaying Results
                syntaxString    = "vectorResult = -vector1;";
                resultType      = "Vector";
                operationString = "Negating a vector";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb31":
            {
                // Gets a String representation of a Vector structure

                Vector vector1 = new Vector(20, 30);
                String vectorString;

                vectorString = vector1.ToString();

                // vectorString is equal to 10,5

                // Displaying Results
                syntaxString    = "vectorString = vector1.ToString();";
                resultType      = "String";
                operationString = "Getting the string representation of a Vector";
                ShowResults(vectorString.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb32":
            {
                // Explicitly converts a Vector structure into a Size structure
                // Returns a Size.

                Vector vector1            = new Vector(20, 30);
                System.Windows.Size size1 = new System.Windows.Size();

                size1 = (System.Windows.Size)vector1;

                // size1 has a width of 20 and a height of 30

                // Displaying Results
                syntaxString    = "size1 = (Size)vector1;";
                resultType      = "Size";
                operationString = "Expliciting casting a Vector into a Size";
                ShowResults(size1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            case "rb33":
            {
                // Explicitly converts a Vector structure into a Point structure
                // Returns a Point.

                Vector vector1 = new Vector(20, 30);
                System.Windows.Point point1 = new System.Windows.Point();

                point1 = (System.Windows.Point)vector1;

                // point1 is equal to (20, 30)

                // Displaying Results
                syntaxString    = "point1 = (Point)vector1;";
                resultType      = "Point";
                operationString = "Expliciting casting a Vector into a Point";
                ShowResults(point1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            // task example.  this case statement is not referenced from the list of radio buttons
            case "rb40":
            {
                // adds two vectors using Add and +

                Vector vector1 = new Vector(20, 30);
                Vector vector2 = new Vector(45, 70);

                vector1 = vector1 + vector2;
                // vector1 is now equal to (65, 100)

                vector1 = Vector.Add(vector1, vector2);
                // vector1 is now equal to (110, 170)

                // Displaying Results
                syntaxString    = "vectorResult = Vector.Negate(vector1);";
                resultType      = "Vector";
                operationString = "Negating a vector";
                ShowResults(vector1.ToString(), syntaxString, resultType, operationString);
                break;
            }

            default:
                break;
            }   // end switch
        }
示例#38
0
文件: PointTest.cs 项目: dfr0/moon
		public void PositiveInfinityToString ()
		{
			Point p = new Point (Double.PositiveInfinity, Double.PositiveInfinity);
			Assert.AreEqual (String.Format ("{0},{0}",Double.PositiveInfinity,Double.PositiveInfinity), p.ToString (), "compare ToString to ToString");
			Assert.AreEqual ("Infinity,Infinity", p.ToString (), "is ToString Infinity or \u221e");
		}
示例#39
0
        // 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);
        }
示例#40
0
        public MainWindow()
        {
            InitializeComponent();

            myFlag = 0;
            //  BitmapImage img = new BitmapImage();
            //   BitmapImage imgPopl = new BitmapImage();
            //  BitmapImage imgVosk = new BitmapImage();

            Rectangle rect = new Rectangle();

            System.Drawing.Rectangle myrect = new System.Drawing.Rectangle();
            System.Drawing.Size      size   = new System.Drawing.Size(200, 200);

            this.Loaded += delegate
            {
                System.Timers.Timer timer = new System.Timers.Timer();
                timer.Elapsed += delegate
                {
                    if (myFlag == 1)
                    {
                        this.Dispatcher.Invoke(new Action(delegate
                        {
                            Mouse.Capture(this);
                            System.Windows.Point pointToWindow = Mouse.GetPosition(this);
                            System.Windows.Point pointToScreen = PointToScreen(pointToWindow);
                            LbPos.Content = pointToScreen.ToString();
                            Mouse.Capture(null);

                            rect.RadiusX  = pointToScreen.X;
                            rect.RadiusY  = pointToScreen.Y;
                            myrect.X      = Convert.ToInt32(pointToScreen.X);
                            myrect.Y      = Convert.ToInt32(pointToScreen.Y);
                            myrect.Height = 200;
                            myrect.Width  = 200;
                            myrect.Size   = size;

                            img                       = CaptureRect(myrect, ImageFormat.Png);
                            imgPlane.Source           = img;
                            imgPlane.StretchDirection = StretchDirection.Both;

                            if (f1flag == 1)
                            {
                                imgPopl = img;
                                //   myFlag = 0;
                                imagePoplavok.Source = img;
                                f1flag = 0;
                                //    btnStart.Content = "Start";
                            }
                            if (f2flag == 1)
                            {
                                imgVosk = img;
                                //    myFlag = 0;
                                imageVoskl.Source = img;
                                f2flag            = 0;
                                //    btnStart.Content = "Start";
                            }
                        }));
                    }
                };
                timer.Interval = 100;
                timer.Start();
            };
        }
示例#41
0
        // 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();
        }
示例#42
0
        public string context;          //A string sentence for the object list.

        public MyClass(string type, string name, Point pt)
        {
            //construction function of creating new object without loading data.
            //This class is a subclass of Image Controls Class.

            //Decide a animal type and name by random
            Random lucky        = new Random();
            int    lucky_number = lucky.Next(4);

            this.type = type;
            this.Name = name;

            //Decide initial moving speed
            int speed = lucky.Next(3, 8);

            this.speedX = speed;
            this.speedY = speed;
            this.pt     = pt;

            //Setting image for Image Control base on the type.
            var uriSource = new Uri("./Resources/" + type + "_img.gif", UriKind.Relative);

            this.Source = new BitmapImage(uriSource);

            this.Width  = 60;
            this.Margin = new Thickness(pt.X - 20, pt.Y - 20, 0, 0);

            //Setting alignment for match the location of the scene.
            this.HorizontalAlignment = HorizontalAlignment.Left;
            this.VerticalAlignment   = VerticalAlignment.Top;

            //Decide initial moving direction base on random.
            string[] direction_Array = new string[] { "RightUp", "RightDown", "LeftUp", "LeftDown" };
            this.Tag          = direction_Array[lucky_number]; //This property is for moving strategy
            this.Initialized += Timer_Start;                   //Setting initial event to a timer method.
            this.context      = this.Name + ", X Speed:" + this.speedX.ToString() + ", Y Speed:" + this.speedY.ToString() + ", Location:" + pt.ToString() + ", Direction:" + this.Tag.ToString();
        }
示例#43
0
文件: PointTest.cs 项目: dfr0/moon
		public void PositiveInfinity ()
		{
			Point p = new Point (Double.PositiveInfinity, Double.PositiveInfinity);
			Assert.IsTrue (Double.IsPositiveInfinity (p.X), "X");
			Assert.IsTrue (Double.IsPositiveInfinity (p.Y), "Y");
			Assert.AreEqual (String.Format ("{0},{0}",Double.PositiveInfinity,Double.PositiveInfinity), p.ToString ());

			Compare (p);
		}
示例#44
0
        bool InvokeSimulatedMouseEvent(string eventName, Point pos)
        {
            bool bCancelled = false;
            try
            {
                System.Diagnostics.Debug.WriteLine("Simulating " + eventName + " to position: " + pos.ToString());

                string strCancelled = _browser.InvokeScript("onNativeMouseEvent", new string[] { eventName, pos.X.ToString(), pos.Y.ToString() }) as string;
                if (bool.TryParse(strCancelled, out bCancelled))
                {
                    return bCancelled;
                }
            }
            catch (Exception)
            {
                // script error
            }

            return bCancelled;
        }
        // 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();
                        Vector3D vector3DResult = new Vector3D();
                        string string3 = "10,20,30";

                        vector3DResult = (Vector3D)v3DConverter.ConvertFromString(string3);
                        // vector3DResult is equal to (10, 20, 30)

                        // Displaying Results
                        syntaxString = "vector3DResult = (Vector3D)v3DConverter.ConvertFromString(string3);";
                        resultType = "Vector3D";
                        operationString = "Converting a String into a Vector3D";
                        ShowResults(vector3DResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb6":
                    {
                        // Converts a String to a Size3D using a Size3DConverter
                        // Returns a Size3D.

                        Size3DConverter s3DConverter = new Size3DConverter();
                        Size3D size3DResult = new Size3D();
                        string string3 = "10,20,30";

                        size3DResult = (Size3D)s3DConverter.ConvertFromString(string3);
                        // size3DResult is equal to (10, 20, 30)

                        // Displaying Results
                        syntaxString = "size3DResult = (Size3D)v3DConverter.ConvertFromString(string3);";
                        resultType = "Size3D";
                        operationString = "Converting a String into a Size3D";
                        ShowResults(size3DResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                case "rb7":
                    {
                        // Converts a String to a Point4D using a Point4DConverter
                        // Returns a Point4D.

                        Point4DConverter p4DConverter = new Point4DConverter();
                        Point4D point4DResult = new Point4D();
                        string string4 = "10,20,30,40";

                        point4DResult = (Point4D)p4DConverter.ConvertFromString(string4);
                        // point4DResult is equal to (10, 20, 30)

                        // Displaying Results
                        syntaxString = "point4DResult = (Point4D)v3DConverter.ConvertFromString(string3);";
                        resultType = "Point4D";
                        operationString = "Converting a String into a Point4D";
                        ShowResults(point4DResult.ToString(), syntaxString, resultType, operationString);
                        break;
                    }

                    default:
                    break;

            } //end switch
        }
示例#46
0
        // Displays the values of the variables
        public void ShowVars()
        {
            var p1 = new System.Windows.Point(10, 5);
            var p2 = new System.Windows.Point(15, 40);

            var v1 = new Vector(20, 30);
            var v2 = new Vector(45, 70);

            var 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();
        }