protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (null == Mesh) { return; } e.Graphics.Clear(SystemColors.Control); e.Graphics.DrawLines(Pens.Black, new Point[] { new Point(1, 1), new Point(1, Height - 1), new Point(Width - 1, Height - 1), new Point(Width - 1, 1), new Point(1, 1) }); if (null == Mesh) { return; } var graphics3D = new Graphic3D(e.Graphics, ViewCamera.ViewProjection, Width, Height); var x = new Vertex(0.8, 0, 0); var y = new Vertex(0, 0.8, 0); var z = new Vertex(0, 0, 0.8); graphics3D.DrawLine(new Vertex(0, 0, 0), x, new Pen(Color.Red, 3)); graphics3D.DrawLine(new Vertex(0, 0, 0), y, new Pen(Color.Green, 3)); graphics3D.DrawLine(new Vertex(0, 0, 0), z, new Pen(Color.Blue, 3)); Mesh.Draw(graphics3D); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Graphic3D v = value as Graphic3D; if (v is null) { return(null); } return(new SolidColorBrush(Color.FromArgb(255, System.Convert.ToByte(v.ColorR * 255.0), System.Convert.ToByte(v.ColorG * 255), System.Convert.ToByte(v.ColorB * 255)))); }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { if (!SetStartState && !SetFinishState) { return; } Point3dNode p; float eX = (e.X - vpr.ox) / vpr.zoom; float eY = (e.Y - vpr.oy) / vpr.zoom; double sinPhiH = Graphic3D.sin(vpr.phiH); double cosPhiH = Graphic3D.cos(vpr.phiH); double sinPhiV = Graphic3D.sin(vpr.phiV); double cosPhiV = Graphic3D.cos(vpr.phiV); // // ex sinPhiH -cosPhiH // ey cosPhiH·cosPhiV sinPhiH·cosPhiV // double Det = sinPhiH * sinPhiH * cosPhiV + cosPhiH * cosPhiV * cosPhiH; double Dx = eX * sinPhiH * cosPhiV + eY * cosPhiH; double Dy = sinPhiH * eY - cosPhiH * cosPhiV * eX; p = new Point3dNode((float)(Dx / Det), (float)(Dy / Det), 0f); Cursor = Cursors.Default; if (SetStartState) { p.Region = 0; startPos = p; checkBoxStart.Checked = false; SetStartState = false; } if (SetFinishState) { p.Region = 4; finishPos = p; checkBoxFinish.Checked = false; SetFinishState = false; if (chkpntList != null) { chkpntList[3].Clear(); chkpntList[3].Add(finishPos); } } Refresh(); }
private void OpenGLControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (isMouseEnter) { if (isDrawMode && temp != null) { temp.Name += string.Format(".{0}.{1}", temp.Style.ToString(), DateTime.Now.ToShortTimeString()); drawmodel.ListObject.Add(temp); drawmodel.ResetDraw = true; isDrawMode = false; temp = null; } } }
public Form1() { InitializeComponent(); h = 6; a = 9; b = -8; c = 5; n = 5; v0 = 2f; textBoxA.Text = a.ToString("F1"); textBoxB.Text = b.ToString("F1"); textBoxC.Text = c.ToString("F1"); textBoxH.Text = h.ToString("F1"); textBoxV0.Text = v0.ToString("F1"); textBoxN.Text = n.ToString(); g3d = new Graphic3D(gorka, 0f, 20f, -20f, 20f, 5e-1f); vpr.phiH = 150f; vpr.phiV = 105f; vpr.zoom = 20; vpr.ox = pictureBox1.Width / 2f; vpr.oy = pictureBox1.Height / 2f; syncList = new List <Graphic3D>(); syncList.Add(g3d); SetupCheckpionts(); MakeGorkaShape(); lOpen = new List <Point3dNode>(); lClosed = new List <Point3dNode>(); path = new List <Point3dNode>(); penPath = new Pen(Color.OrangeRed, 1f / vpr.zoom); penBestPath = new Pen(Color.LimeGreen, 3f / vpr.zoom); penBestPath.LineJoin = LineJoin.Round; penGorka = new Pen(Color.Black, 1.5f / vpr.zoom); penGorka.LineJoin = LineJoin.Round; pictureBox1.Refresh(); measuringMethod = this.MeasureDist; searchMethod = this.BreadthFirstSearch; }
public GraphicPropertyVM(MainWindowViewModel vm) { mainVM = vm; ChoseColorCommand = new RelayCommand <string>( (i) => !string.IsNullOrEmpty(i), (i) => { switch (i) { case "Black": mainVM.SeletedGraphic.ColorR = mainVM.SeletedGraphic.ColorG = mainVM.SeletedGraphic.ColorB = 0.0; break; case "Red": mainVM.SeletedGraphic.ColorG = mainVM.SeletedGraphic.ColorB = 0.0; mainVM.SeletedGraphic.ColorR = 1.0; break; case "Yellow": mainVM.SeletedGraphic.ColorR = mainVM.SeletedGraphic.ColorG = 1.0; mainVM.SeletedGraphic.ColorB = 0.0; break; case "Green": mainVM.SeletedGraphic.ColorR = mainVM.SeletedGraphic.ColorB = 0.0; mainVM.SeletedGraphic.ColorG = 1.0; break; case "Cyan": mainVM.SeletedGraphic.ColorR = 0; mainVM.SeletedGraphic.ColorG = mainVM.SeletedGraphic.ColorB = 1.0; break; case "Blue": mainVM.SeletedGraphic.ColorR = mainVM.SeletedGraphic.ColorG = 0.0; mainVM.SeletedGraphic.ColorB = 1.0; break; case "Magenta": mainVM.SeletedGraphic.ColorR = mainVM.SeletedGraphic.ColorB = 1.0; mainVM.SeletedGraphic.ColorG = 0.0; break; case "Gray": mainVM.SeletedGraphic.ColorR = mainVM.SeletedGraphic.ColorG = mainVM.SeletedGraphic.ColorB = 0.5; break; default: mainVM.SeletedGraphic.ColorR = mainVM.SeletedGraphic.ColorG = mainVM.SeletedGraphic.ColorB = 1.0; break; } }); DeleteCommand = new RelayCommand(_ => { if (SelectedGraphic == null) { return; } if (System.Windows.MessageBox.Show(String.Format("Bạn có muốn xóa {0} không? ", SelectedGraphic.Name), "Xác nhận", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Warning) == System.Windows.MessageBoxResult.Yes) { Graphic3D x = SelectedGraphic; if (x != null) { ListObject.Remove(x); SelectedGraphic = null; OnPropertyChanged("SelectedGraphic"); } } }); }