Пример #1
0
        private void surfaceButton1_Click(object sender, RoutedEventArgs e)
        {
            bool error = false;
            String information = surfaceTextBox1.Text;
            try
            {
                double x = Convert.ToDouble(surfaceTextBox2.Text);
                double y = Convert.ToDouble(surfaceTextBox3.Text);
                double radius = Convert.ToDouble(surfaceTextBox4.Text);

                Point p = Helper.adjustPoint(new Point(x + radius, y));

                HapticShape rect = new HapticCircle(p.X, p.Y, radius);
                rect.color(Helper.getBrush(_currentColor));
                rect.registerAction(new BasicAction(information));
                _grid.Children.Add(rect);
            }
            catch (FormatException fe)
            {
                error = true;
                surfaceButton1.Background = Brushes.Red;
            }

            if (!error)
                this.Close();
        }
Пример #2
0
        private void addTestObjects()
        {
            HapticShape rectangle = new HapticRectangle(700, 450, 100, 70);
            rectangle.color(Brushes.Brown);
            Container.Children.Add(rectangle);

            HapticShape circle = new HapticCircle(1050, 250, 50);
            circle.color(Brushes.Yellow);
            Container.Children.Add(circle);

            HapticShape circle1 = new HapticCircle(900, 750, 80);
            circle1.color(Brushes.Purple);
            Container.Children.Add(circle1);

            HapticShape link = new HapticLink(rectangle, circle, true);
            link.color(Brushes.White);
            Container.Children.Add(link);

            HapticShape link1 = new HapticLink(circle1, circle, false);
            link1.color(Brushes.White);
            link1.thickness(10);
            Container.Children.Add(link1);

            HapticShape rectangle1 = new HapticRectangle(500, 150, 200, 180);
            rectangle1.color(Brushes.LightCoral);
            rectangle1.registerAction(new BasicAction("This is a test - add any information you want"));
            Container.Children.Add(rectangle1);

            HapticShape rectangle2 = new HapticRectangle(200, 100, 150, 150);
            rectangle2.color(Brushes.LightCoral);
            rectangle2.registerAction(new BasicAction("Other information you can add"));
            Container.Children.Add(rectangle2);

            HapticShape link2 = new HapticLink(rectangle1, rectangle2, false);
            link2.color(Brushes.Orange);
            link2.thickness(15);
            Container.Children.Add(link2);

            HapticShape circle2 = new HapticCircle(450, 450, 100);
            circle2.color(Brushes.Linen);
            Container.Children.Add(circle2);


            //HapticShape line = new HapticLine(new Point(10, 30), new Point(100, 30));
            //line.color(Brushes.White);
            //Container.Children.Add(line);

            //List<Point> points = new List<Point>();
            //points.Add(new Point(10, 70));
            //points.Add(new Point(60, 130));
            //points.Add(new Point(60, 200));
            //points.Add(new Point(180, 380));
            //HapticShape polyline = new HapticPolyline(points);
            //polyline.color(Brushes.Yellow);
            //Container.Children.Add(polyline);
        }