コード例 #1
0
        public double getArea()
        {
            double[,] array = new double[2, 2];
            array[0, 0]     = point1.getX() - point3.getX();
            array[0, 1]     = point1.getY() - point3.getY();
            array[1, 0]     = point2.getX() - point3.getX();
            array[1, 1]     = point2.getY() - point3.getY();

            return(Abs((array[0, 0] * array[1, 1]) - (array[0, 1] * array[1, 0])) / 2);;
        }
コード例 #2
0
        public void shiftX(double value)
        {
            point1.shiftX(value);
            point2.shiftX(value);
            point3.shiftX(value);
            point4.shiftX(value);

            if ((point1.getX() < 0 || point1.getX() > 500) || (point2.getX() < 0 || point2.getX() > 500) || (point3.getX() < 0 || point3.getX() > 500) || (point4.getX() < 0 || point4.getX() > 500))
            {
                point1.shiftX(-value);
                point2.shiftX(-value);
                point3.shiftX(-value);
                point4.shiftX(-value);
            }
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: GelyaTh/l222
        private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            double shiftvalue = SliderX.Value;

            if (rectangle != null)
            {
                shiftvalue -= rectangle.Left;
                rectangle.shiftX(shiftvalue);
                MainCanvas.Children.Clear();
                drawRectangle(rectangle);
                showRectangleInfo(rectangle);
            }

            if (triangle != null)
            {
                shiftvalue -= triangle.Left;
                triangle.shiftX(shiftvalue);
                MainCanvas.Children.Clear();
                drawTriangle(triangle);
                showTriangleInfo(triangle);
            }

            if (point != null)
            {
                shiftvalue -= point.getTrueX();
                point.shiftX(shiftvalue);
                MainCanvas.Children.Clear();
                drawPoint(point);
                pointX.Text = "X: " + point.getX().ToString("0.00");
            }
        }
コード例 #4
0
ファイル: Point2D.cs プロジェクト: Balkhanakovv/OOP_Lab2
 public bool equals(Point2D OtherPoint)
 {
     if ((x == OtherPoint.getX()) && y == OtherPoint.getY())
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: GelyaTh/l222
        private void drawLine(Point2D beginPoint, Point2D endPoint)
        {
            Line line = new Line();

            line.Stroke = Brushes.DarkBlue;
            line.X1     = beginPoint.getX();
            line.Y1     = beginPoint.getY();
            line.X2     = endPoint.getX();
            line.Y2     = endPoint.getY();
            MainCanvas.Children.Add(line);
        }
コード例 #6
0
        private void drawPoint(Point2D point)
        {
            Ellipse boldPoint = new Ellipse();

            boldPoint.Width           = 4;
            boldPoint.Height          = 4;
            boldPoint.StrokeThickness = 2;
            boldPoint.Stroke          = Brushes.Black;
            boldPoint.Margin          = new Thickness(point.getX() - 2, point.getY() - 2, 0, 0);

            MainCanvas.Children.Add(boldPoint);
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: GelyaTh/l222
        private void Point2DBt_Click(object sender, RoutedEventArgs e)
        {
            pointInfo.Visibility        = Visibility.Visible;
            triangleInfo.Visibility     = Visibility.Hidden;
            rectangleInfo.Visibility    = Visibility.Hidden;
            rectangleOptions.Visibility = Visibility.Hidden;

            MainCanvas.Children.Clear();
            rectangle = null;
            triangle  = null;
            point     = Generate.initPoint2D();


            drawPoint(point);

            pointX.Text = "X: " + point.getX().ToString("0.00");
            pointY.Text = "Y: " + point.getY().ToString("0.00");

            SliderX.Maximum = 500;
            SliderX.Value   = point.getX();
            SliderY.Maximum = 300;
            SliderY.Value   = point.getY();
        }
コード例 #8
0
        private void Point2DBt_Click(object sender, RoutedEventArgs e)
        {
            pointInfo.Visibility        = Visibility.Visible;
            triangleInfo.Visibility     = Visibility.Hidden;
            rectangleInfo.Visibility    = Visibility.Hidden;
            rectangleOptions.Visibility = Visibility.Hidden;

            MainCanvas.Children.Clear();
            this.point     = Generate.initPoint2D();
            this.rectangle = null;
            this.triangle  = null;

            drawPoint(this.point);

            pointX.Text = "X: " + point.getX().ToString("#.##");
            pointY.Text = "Y: " + point.getY().ToString("#.##");
        }
コード例 #9
0
ファイル: Point2D.cs プロジェクト: Balkhanakovv/OOP_Lab2
        public double getDistance(Point2D OtherPoint)
        {
            double distance = Sqrt(Pow((x - OtherPoint.getX()), 2) + Pow((y - OtherPoint.getY()), 2));

            return(distance);
        }
コード例 #10
0
        private void Window_KeyUp(object sender, KeyEventArgs e)
        {
            if (this.point != null)
            {
                if (e.Key == Key.Up)
                {
                    this.point.shiftY(-10);
                }
                if (e.Key == Key.Down)
                {
                    this.point.shiftY(10);
                }
                if (e.Key == Key.Right)
                {
                    this.point.shiftX(10);
                }
                if (e.Key == Key.Left)
                {
                    this.point.shiftX(-10);
                }

                MainCanvas.Children.Clear();

                drawPoint(this.point);

                pointX.Text = "X: " + point.getX().ToString("#.##");
                pointY.Text = "Y: " + point.getY().ToString("#.##");
            }

            if (this.triangle != null)
            {
                MainCanvas.Children.Clear();

                if (e.Key == Key.Up)
                {
                    this.triangle.shiftY(-10);
                }
                if (e.Key == Key.Down)
                {
                    this.triangle.shiftY(10);
                }
                if (e.Key == Key.Right)
                {
                    this.triangle.shiftX(10);
                }
                if (e.Key == Key.Left)
                {
                    this.triangle.shiftX(-10);
                }

                drawTriangle(this.triangle);
            }

            if (this.rectangle != null)
            {
                MainCanvas.Children.Clear();

                if (e.Key == Key.Up)
                {
                    this.rectangle.shiftY(-10);
                }
                if (e.Key == Key.Down)
                {
                    this.rectangle.shiftY(10);
                }
                if (e.Key == Key.Right)
                {
                    this.rectangle.shiftX(10);
                }
                if (e.Key == Key.Left)
                {
                    this.rectangle.shiftX(-10);
                }

                drawRectangle(this.rectangle);
            }
        }