private void EditCamera_Load(object sender, EventArgs e) { NameTextBox.Text = camera.Name; XTextBox.Text = Convert.ToString(camera.Position.X); YTextBox.Text = Convert.ToString(camera.Position.Y); ZTextBox.Text = Convert.ToString(camera.Position.Z); XTextBox2.Text = Convert.ToString(camera.Direction.X); YTextBox2.Text = Convert.ToString(camera.Direction.Y); ZTextBox2.Text = Convert.ToString(camera.Direction.Z); RadiansTextBox1.Text = Convert.ToString(camera.HorizontalFOV); DegreesTextBox1.Text = Convert.ToString(camera.HorizontalFOV * 180 / Math.PI); RadiansTextBox2.Text = Convert.ToString(camera.VerticalFOV); DegreesTextBox2.Text = Convert.ToString(camera.VerticalFOV * 180 / Math.PI); FieldInfo[] list = camera.GetType().GetFields(); for (int i = 0; i < list.GetLength(0) - 6; ++i) { FieldDisplay fd = new FieldDisplay(list[i], camera, CameraFieldsFlowLayoutPanel); CameraFieldsFlowLayoutPanel.Controls.Add(fd); } }
private void CameraListBox_SelectedIndexChanged(object sender, EventArgs e) { CameraFieldsFlowLayoutPanel.Controls.Clear(); switch (CameraListBox.SelectedItem) { case "Ray Tracing": cameraBuffer = new RaytracingCamera(); break; case "Projection": cameraBuffer = new ProjectionCamera(); break; } FieldInfo[] list = cameraBuffer.GetType().GetFields(); int offset = list.Length - 9; //Camera has 9 fields NameTextBox.Text = Convert.ToString(list[offset].GetValue(cameraBuffer)); Vector3 tempPos = (Vector3)list[offset + 1].GetValue(cameraBuffer); XTextBox.Text = Convert.ToString(tempPos.X); YTextBox.Text = Convert.ToString(tempPos.Y); ZTextBox.Text = Convert.ToString(tempPos.Z); Vector3 tempDir = (Vector3)list[offset + 2].GetValue(cameraBuffer); XTextBox2.Text = Convert.ToString(tempDir.X); YTextBox2.Text = Convert.ToString(tempDir.Y); ZTextBox2.Text = Convert.ToString(tempDir.Z); SensitivityTextBox.Text = Convert.ToString(list[offset + 3].GetValue(cameraBuffer)); RadiansTextBox1.Text = Convert.ToString(list[offset + 4].GetValue(cameraBuffer)); RadiansTextBox2.Text = Convert.ToString(list[offset + 5].GetValue(cameraBuffer)); HorizontalResolutionTextBox.Text = Convert.ToString(list[offset + 7].GetValue(cameraBuffer)); VerticalResolutionTextBox.Text = Convert.ToString(list[offset + 8].GetValue(cameraBuffer)); for (int i = 0; i < offset; ++i) { FieldDisplay fd = new FieldDisplay(list[i], cameraBuffer, CameraFieldsFlowLayoutPanel); CameraFieldsFlowLayoutPanel.Controls.Add(fd); } cameraBuffer.Dispose(); }