private void LightColor_Click(object sender, EventArgs e) { ColorDialog dialog = new ColorDialog(); if (dialog.ShowDialog() == DialogResult.OK) { SelectedLight.Color = dialog.Color; using (FastBitmap fast = ((Bitmap)LightColor.Image).FastLock()) { fast.Clear(dialog.Color); } LightColor.Refresh(); } }
public Form1() { InitializeComponent(); bitmap = new Bitmap(Canvas.Width, Canvas.Height); Render.Clear(bitmap); Canvas.Image = bitmap; //Figures.Add(new Cuboid() { Center = new Point4(3, 0, 3) }); //Figures.Add(new Sphere() { Center = new Point4(-3, 0, -3) }); //Figures.Add(new Cone() { Center = new Point4(-3, 0, 3) }); //Figures.Add(new Cylinder() { Center = new Point4(3, 0, -3) }); FigureDataGrid.DataSource = Figures; SelectedCamera = new Camera(); Cameras.Add(SelectedCamera); CameraListBox.DataSource = Cameras; CameraListBox.DisplayMember = "DisplayName"; CameraListBox.SelectedIndex = 0; LightColor.Image = new Bitmap(LightColor.Width, LightColor.Height); LightColor.Refresh(); SelectedLight = new Light(); Lights.Add(SelectedLight); LightListBox.DataSource = Lights; LightListBox.DisplayMember = "DisplayName"; LightListBox.SelectedIndex = 0; RefreshTimer.Tick += RefreshTimer_Tick; RefreshTimer.Interval = 8; RefreshTimer.Start(); frametime = DateTime.Now; Render.ZBuffering = zbufferingToolStripMenuItem.Checked; Render.FillTriangles = fillTrianglesToolStripMenuItem.Checked; Render.BackfaceCulling = backfaceCullingToolStripMenuItem.Checked; CuboidColor.Image = new Bitmap(CuboidColor.Width, CuboidColor.Height); CuboidColor.Refresh(); SphereColor.Image = new Bitmap(SphereColor.Width, SphereColor.Height); SphereColor.Refresh(); CylinderColor.Image = new Bitmap(CylinderColor.Width, CylinderColor.Height); CylinderColor.Refresh(); ConeColor.Image = new Bitmap(ConeColor.Width, ConeColor.Height); ConeColor.Refresh(); }
private void LightListBox_SelectedIndexChanged(object sender, EventArgs e) { if (Lights.Count == 0 || LightListBox.SelectedIndex == -1) { return; } SelectedLight = Lights[LightListBox.SelectedIndex]; using (FastBitmap fast = ((Bitmap)LightColor.Image).FastLock()) { fast.Clear(SelectedLight.Color); } LightIntensity.Value = (decimal)SelectedLight.Intensity; LightRange.Value = (decimal)SelectedLight.Range; LightPosX.Value = (decimal)SelectedLight.Position.X; LightPosY.Value = (decimal)SelectedLight.Position.Y; LightPosZ.Value = (decimal)SelectedLight.Position.Z; LightColor.Refresh(); }