public static DialogResult Show(string title, string message, string info, MessageBoxButtons buttons) { DarkMessageBox dialog = new DarkMessageBox(); SetButtonsText(dialog, buttons); dialog.Text = title; dialog.lbInfo.Text = info; dialog.lbMessage.Text = message; return dialog.ShowDialog(); }
private void Form1_Load(object sender, EventArgs e) { oldClientSize = this.ClientSize; settings = new Settings(); renderManager = new RenderManager(); renderManager.CreateDefaultControl(); /* * if (!renderManager.CreateControl("MeshRenderer.SharpGL2.dll", new string[] { "SharpGL.dll" })) * { * renderManager.CreateDefaultControl(); * * if (frmLog == null) * { * frmLog = new FormLog(); * } * * frmLog.AddItem("Failed to initialize OpenGL.", true); * } */ var control = renderManager.RenderControl; if (control != null) { this.splitContainer1.Panel2.Controls.Add(control); // Initialize control control.BackColor = Color.Black; control.Dock = DockStyle.Fill; control.Font = new Font("Consolas", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); control.Location = new System.Drawing.Point(0, 0); control.Name = "renderControl1"; control.Size = new Size(703, 612); control.TabIndex = 0; control.Text = "meshRenderer1"; renderManager.Initialize(); } else { DarkMessageBox.Show("Ooops ...", "Failed to initialize renderer."); } renderData = new RenderData(); }
private void btnGenerate_Click(object sender, EventArgs e) { if (currentGenerator != null && InputGenerated != null) { try { var input = currentGenerator.Generate(sliderParam1.Value, sliderParam2.Value, sliderParam3.Value); InputGenerated(input, EventArgs.Empty); } catch (Exception ex) { DarkMessageBox.Show("Exception", ex.Message); } } }
private bool Open(string filename) { if (!FileProcessor.CanHandleFile(filename)) { // TODO: show message. } else { if (FileProcessor.ContainsMeshData(filename)) { if (DarkMessageBox.Show("Import mesh", Settings.ImportString, "Do you want to import the mesh?", MessageBoxButtons.YesNo) == DialogResult.OK) { input = null; mesh = FileProcessor.Import(filename); if (mesh != null) { statisticView.UpdateStatistic(mesh); // Update settings settings.CurrentFile = Path.GetFileName(filename); HandleMeshImport(); btnSmooth.Enabled = true; // TODO: Remove } // else Message return(true); } } input = FileProcessor.Read(filename); } if (input != null) { // Update settings settings.CurrentFile = Path.GetFileName(filename); HandleNewInput(); } // else Message return(true); }
private static void SetButtonsText(DarkMessageBox dialog, MessageBoxButtons buttons) { if (buttons == MessageBoxButtons.OKCancel) { dialog.btnOk.Text = "OK"; dialog.btnCancel.Text = "Cancel"; } else if (buttons == MessageBoxButtons.YesNo) { dialog.btnOk.Text = "Yes"; dialog.btnCancel.Text = "No"; } else { dialog.btnCancel.Text = "Close"; dialog.btnOk.Visible = false; dialog.btnOk.Enabled = false; } }
private void Refine() { if (mesh == null) { return; } Stopwatch sw = new Stopwatch(); double area = meshControlView.ParamMaxAreaValue; if (area > 0 && area < 1) { mesh.Behavior.MaxArea = area * statisticView.Statistic.LargestArea; } mesh.Behavior.MinAngle = meshControlView.ParamMinAngleValue; double maxAngle = meshControlView.ParamMaxAngleValue; if (maxAngle < 180) { mesh.Behavior.MaxAngle = maxAngle; } try { sw.Start(); mesh.Refine(); sw.Stop(); statisticView.UpdateStatistic(mesh); HandleMeshUpdate(); } catch (Exception ex) { LockOnException(); DarkMessageBox.Show("Exception - Refine", ex.Message, MessageBoxButtons.OK); } UpdateLog(); }
private void Refine() { if (mesh == null) { return; } double area = meshControlView.ParamMaxAreaValue; var quality = new QualityOptions(); if (area > 0 && area < 1) { quality.MaximumArea = area * statisticView.Statistic.LargestArea; } quality.MinimumAngle = meshControlView.ParamMinAngleValue; double maxAngle = meshControlView.ParamMaxAngleValue; if (maxAngle < 180) { quality.MaximumAngle = maxAngle; } try { mesh.Refine(quality, meshControlView.ParamConformDelChecked); statisticView.UpdateStatistic(mesh); HandleMeshUpdate(); } catch (Exception ex) { LockOnException(); DarkMessageBox.Show("Exception - Refine", ex.Message, MessageBoxButtons.OK); } UpdateLog(); }
private bool CreateVoronoi() { if (mesh == null) { return(false); } if (mesh.IsPolygon) { try { this.voronoi = new BoundedVoronoi(mesh); } catch (Exception ex) { if (!meshControlView.ParamConformDelChecked) { DarkMessageBox.Show("Exception - Bounded Voronoi", Settings.VoronoiString, MessageBoxButtons.OK); } else { DarkMessageBox.Show("Exception - Bounded Voronoi", ex.Message, MessageBoxButtons.OK); } return(false); } } else { this.voronoi = new StandardVoronoi(mesh); } // HACK: List<Vertex> -> ICollection<Point> ? Nope, no way. // Vertex[] -> ICollection<Point> ? Well, ok. renderManager.Set(voronoi.Vertices.ToArray(), voronoi.Edges, false); return(true); }
private void Form1_Load(object sender, EventArgs e) { oldClientSize = this.ClientSize; settings = new Settings(); renderManager = new RenderManager(); IRenderControl control = new TriangleNet.Rendering.GDI.RenderControl(); /* * if (!renderManager.TryCreateControl("Triangle.Rendering.SharpGL.dll", * new string[] { "SharpGL.dll" }, out control)) * { * control = new TriangleNet.Rendering.GDI.RenderControl(); * * if (frmLog == null) * { * frmLog = new FormLog(); * } * * frmLog.AddItem("Failed to initialize OpenGL.", true); * } * //*/ if (control != null) { InitializeRenderControl((Control)control); renderManager.Initialize(control); control.Refresh(); } else { DarkMessageBox.Show("Ooops ...", "Failed to initialize renderer."); } }
private void Triangulate() { if (input == null) { return; } var options = new ConstraintOptions(); var quality = new QualityOptions(); if (meshControlView.ParamConformDelChecked) { options.ConformingDelaunay = true; } if (meshControlView.ParamQualityChecked) { quality.MinimumAngle = meshControlView.ParamMinAngleValue; double maxAngle = meshControlView.ParamMaxAngleValue; if (maxAngle < 180) { quality.MaximumAngle = maxAngle; } // Ignore area constraints on initial triangulation. //double area = slMaxArea.Value * 0.01; //if (area > 0 && area < 1) //{ // var size = input.Bounds; // double min = Math.Min(size.Width, size.Height); // mesh.SetOption(Options.MaxArea, area * min); //} } if (meshControlView.ParamConvexChecked) { options.Convex = true; } try { if (meshControlView.ParamSweeplineChecked) { mesh = (Mesh)input.Triangulate(options, quality, new SweepLine()); } else { mesh = (Mesh)input.Triangulate(options, quality); } statisticView.UpdateStatistic(mesh); HandleMeshUpdate(); if (meshControlView.ParamQualityChecked) { settings.RefineMode = true; } } catch (Exception ex) { LockOnException(); DarkMessageBox.Show("Exception - Triangulate", ex.Message, MessageBoxButtons.OK); } UpdateLog(); }
private void Triangulate() { if (input == null) { return; } //Stopwatch sw = new Stopwatch(); mesh = new Mesh(); if (meshControlView.ParamConformDelChecked) { mesh.Behavior.ConformingDelaunay = true; } if (meshControlView.ParamSweeplineChecked) { mesh.Behavior.Algorithm = TriangulationAlgorithm.SweepLine; } if (meshControlView.ParamQualityChecked) { mesh.Behavior.Quality = true; mesh.Behavior.MinAngle = meshControlView.ParamMinAngleValue; double maxAngle = meshControlView.ParamMaxAngleValue; if (maxAngle < 180) { mesh.Behavior.MaxAngle = maxAngle; } // Ignore area constraints on initial triangulation. //double area = slMaxArea.Value * 0.01; //if (area > 0 && area < 1) //{ // var size = input.Bounds; // double min = Math.Min(size.Width, size.Height); // mesh.Behavior.MaxArea, area * min); //} } if (meshControlView.ParamConvexChecked) { mesh.Behavior.Convex = true; } try { //sw.Start(); mesh.Triangulate(input); //sw.Stop(); statisticView.UpdateStatistic(mesh); HandleMeshUpdate(); if (meshControlView.ParamQualityChecked) { settings.RefineMode = true; } } catch (Exception ex) { LockOnException(); DarkMessageBox.Show("Exception - Triangulate", ex.Message, MessageBoxButtons.OK); } UpdateLog(); }