Exemple #1
0
        private void inputButton1_Click(object sender, EventArgs e)
        {
            List <MyLine3D> newPolyhedron = new List <MyLine3D> {
            };
            string str = inputTextBox1.Text.ToString();

            try
            {
                string[] array = str.Split(new Char[] { '\r', ',', ' ', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                int      count = array.Length;
                if (count % 6 == 0)
                {
                    for (int i = 0; i < count / 6; i++)
                    {
                        float x1 = float.Parse(array[i * 6 + 0]);
                        float y1 = float.Parse(array[i * 6 + 1]);
                        float z1 = float.Parse(array[i * 6 + 2]);
                        float x2 = float.Parse(array[i * 6 + 3]);
                        float y2 = float.Parse(array[i * 6 + 4]);
                        float z2 = float.Parse(array[i * 6 + 5]);
                        newPolyhedron.Add(new MyLine3D(x1, y1, z1, x2, y2, z2, isParallel));
                    }
                    cube = new MyPolyhedron(newPolyhedron, isParallel, station);
                    pictureBoxUp.Refresh();
                    inputTextBox1.Visible = false;
                    inputButton1.Visible  = false;
                }
                else
                {
                    inputTextBox1.Text = "50 50 50 -50 50 50\r\n-50 -50 50 -50 50 50\r\n50 -50 50 -50 -50 50\r\n50 50 50 50 -50 50\r\n50 50 -50 -50 50 -50\r\n-50 -50 -50 -50 50 -50\r\n50 -50 -50 -50 -50 -50\r\n50 50 -50 50 -50 -50\r\n50 50 50 50 50 -50\r\n-50 50 50 -50 50 -50\r\n-50 -50 50 -50 -50 -50\r\n50 -50 50 50 -50 -50";

                    cube = new MyPolyhedron(new List <MyLine3D> {
                        new MyLine3D(x, x, x, -x, x, x, true),
                        new MyLine3D(-x, x, x, -x, -x, x, true),
                        new MyLine3D(-x, -x, x, x, -x, x, true),
                        new MyLine3D(x, -x, x, x, x, x, true),

                        new MyLine3D(x, x, -x, -x, x, -x, true),
                        new MyLine3D(-x, x, -x, -x, -x, -x, true),
                        new MyLine3D(-x, -x, -x, x, -x, -x, true),
                        new MyLine3D(x, -x, -x, x, x, -x, true),

                        new MyLine3D(x, x, -x, x, x, x, true),
                        new MyLine3D(-x, x, -x, -x, x, x, true),
                        new MyLine3D(-x, -x, -x, -x, -x, x, true),
                        new MyLine3D(x, -x, -x, x, -x, x, true)
                    },
                                            isParallel,
                                            station);
                    pictureBoxUp.Refresh();
                    throw new Exception();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("输入的不是合法的多面体数据,请确认输入是否合法。", "严重错误!");
                inputButton1.Visible  = false;
                inputTextBox1.Visible = false;
            }
        }
Exemple #2
0
        private void pictureBoxUp_Paint(object sender, PaintEventArgs e)
        {
            cube = new MyPolyhedron(cube.inList, isParallel, station);
            Graphics g = e.Graphics;
            Pen      pen = new Pen(Color.Black);
            int      width = pictureBoxDown.Width, height = pictureBoxDown.Height;

            cube.paintMyself(g, Color.Black, width / 2, height / 2);
        }