예제 #1
0
        private void JoinButtonClick(object sender, RoutedEventArgs e)
        {
            if (ImagesListBox.SelectedItems.Count != 2)
            {
                return;
            }

            MyImage fst = (MyImage)ImagesListBox.SelectedItems[0];
            MyImage snd = (MyImage)ImagesListBox.SelectedItems[1];

            foreach (Models.Figure fig in snd.Figures)
            {
                fst.Add(fig);
            }

            Images.Remove(snd);

            myImage.RedrawAll();
            RefreshFiguresView();
            RefreshImagesListBox();
        }
예제 #2
0
        public MainWindow()
        {
            InitializeComponent();
            myImage = new MyImage(MainViewPort);
            Images.Add(myImage);

            foreach (MyImage im in Images)
            {
                ImagesListBox.Items.Add(im);
            }

            RefreshImagesListBox();



            string[] names = new string[]
            {
                "Circle",
                "EmptyCircle",
                "Ellipse",
                "Cone",
                "CuttedCone",
                "Point",
            };

            FiguresComboBox.ItemsSource = names;



            myImage.Add(new Circle()
            {
                Id         = 11,
                Position   = new Point3D(-2, 0, 0),
                Radius     = 3,
                Resolution = 30,
                LineWidth  = 0.05,
                Color      = Colors.Turquoise,
            });

            myImage.Add(new Circle()
            {
                Id         = 12,
                Position   = new Point3D(2, 0, 0),
                Radius     = 3,
                Resolution = 30,
                LineWidth  = 0.05,
                Color      = Colors.Turquoise,
            });



            /*
             * myImage.Add(new Models.Ellipse()
             * {
             *  Id = 0,
             *  Position = new Point3D(-2, 0, 0),
             *  Resolution = 30,
             *  A = 1,
             *  B = 2,
             *  Color = Colors.Red,
             * });
             *
             * myImage.Add(new Models.Ellipse()
             * {
             *  Id = 1,
             *  Position = new Point3D(2, 0, 0),
             *  Resolution = 30,
             *  A = 1,
             *  B = 2,
             *  Color = Colors.Red,
             * });
             *
             * myImage.Add(new Models.Ellipse()
             * {
             *  Id = 2,
             *  Position = new Point3D(0, 2, 0),
             *  Resolution = 30,
             *  A = 2,
             *  B = 1,
             *  Color = Colors.Red,
             * });
             *
             * myImage.Add(new Models.Ellipse()
             * {
             *  Id = 3,
             *  Position = new Point3D(0, -2, 0),
             *  Resolution = 30,
             *  A = 2,
             *  B = 1,
             *  Color = Colors.Red,
             * });
             *
             * myImage.Add(new Cone()
             * {
             *  Id = 10,
             *  Position = new Point3D(0, -5, -3),
             *  Radius = 3,
             *  Height = 6,
             *  Resolution = 30,
             *  Color = Colors.Fuchsia,
             * });
             *
             *
             * myImage.Add(new Circle()
             * {
             *  Id = 11,
             *  Position = new Point3D(-3, -4, -3),
             *  Radius = 2,
             *  Resolution = 30,
             *  LineWidth = 0.05,
             *  Color = Colors.Turquoise,
             * });
             *
             * myImage.Add(new Circle()
             * {
             *  Id = 12,
             *  Position = new Point3D(3, -4,-3),
             *  Radius = 2,
             *  Resolution = 30,
             *  LineWidth = 0.05,
             *  Color = Colors.Turquoise,
             * });
             *
             *
             * myImage.Add(new CuttedCone()
             * {
             *  Id = 4,
             *  Position = new Point3D(0, -6, -15),
             *  Radius = 10,
             *  SmallRadius = 8,
             *  Height = 10,
             *  Resolution = 50,
             *  Color = Colors.Gainsboro,
             * });
             *
             *
             * /*
             * myImage.Add(new EmptyCircle()
             * {
             *  Id = 1,
             *  Position = new Point3D(5, 0, 0),
             *  Radius = 2,
             *  Resolution = 30,
             *  LineWidth = 0.05,
             *  Color = Colors.Red,
             * });
             *
             * myImage.Add(new Models.Ellipse()
             * {
             *  Id = 2,
             *  Position = new Point3D(10, 0, 0),
             *  Resolution = 30,
             *  A = 1,
             *  B = 2,
             *  Color = Colors.Red,
             * });
             * myImage.Add(new Cone()
             * {
             *  Id = 3,
             *  Position = new Point3D(-5, 0, 0),
             *  Radius = 3,
             *  Height = 6,
             *  Resolution = 30,
             *  Color = Colors.Red,
             * });
             *
             * myImage.Add(new CuttedCone()
             * {
             *  Id = 4,
             *  Position = new Point3D(-10, 0, 0),
             *  Radius = 3,
             *  SmallRadius = 0.5,
             *  Height = 5,
             *  Resolution = 50,
             *  Color = Colors.Red,
             * });
             */



            RefreshFiguresView();
        }
예제 #3
0
        private void AddFigureButton_Click(object sender, RoutedEventArgs e)
        {
            Point3D center;
            double  R;
            double  r;
            double  H;
            double  width;
            int     resolution;
            Color   color;

            double a, b;


            try
            {
                center = new Point3D(
                    double.Parse(CenterXTextBox.Text),
                    double.Parse(CenterYTextBox.Text),
                    double.Parse(CenterZTextBox.Text)
                    );
                R          = double.Parse(BigRadiusTextBox.Text);
                r          = double.Parse(SmallRadiusTextBox.Text);
                H          = double.Parse(HeightTextBox.Text);
                width      = double.Parse(LineWidthTextBox.Text);
                resolution = int.Parse(ResolutionTextBox.Text);
                if (ColorsComboBox.SelectedIndex == -1)
                {
                    color = (Color)ColorsComboBox.Items[rand.Next(ColorsComboBox.Items.Count - 1)];
                }
                else
                {
                    color = (Color)ColorsComboBox.SelectedItem;
                }


                a = double.Parse(EllipseATextBox.Text);
                b = double.Parse(EllipseBTextBox.Text);
            }
            catch
            {
                MessageBox.Show("Sorry");
                return;
            }



            switch (FiguresComboBox.SelectedIndex)
            {
            case 0:
                myImage.Add(new Circle()
                {
                    Position   = center,
                    Radius     = R,
                    Resolution = resolution,
                    Color      = color
                });
                break;

            case 1:
                myImage.Add(new EmptyCircle()
                {
                    Position   = center,
                    Radius     = R,
                    Resolution = resolution,
                    LineWidth  = width,
                    Color      = color
                });
                break;

            case 2:
                myImage.Add(new Models.Ellipse()
                {
                    Position   = center,
                    Radius     = R,
                    Resolution = resolution,
                    A          = a,
                    B          = b,
                    Color      = color
                });
                break;

            case 3:
                myImage.Add(new Cone()
                {
                    Position   = center,
                    Radius     = R,
                    Height     = H,
                    Resolution = resolution,
                    Color      = color
                });
                break;

            case 4:
                myImage.Add(new CuttedCone()
                {
                    Position    = center,
                    Radius      = R,
                    SmallRadius = r,
                    Height      = H,
                    Resolution  = resolution,
                    Color       = color
                });
                break;

            case 5:
                myImage.Add(new Models.Point()
                {
                    Position = center,
                    Radius   = R,
                    Color    = color
                });
                break;
            }
            RefreshFiguresView();
        }