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 bool Open(string filename) { if (FileProcessor.ContainsMeshData(filename)) { if (DarkMessageBox.Show("Import mesh", GUISettings.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 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(); }