/// <summary> /// Starts the post-processing /// </summary> private void RunButton_Click(object sender, EventArgs e) { try { #region File Read string[] gcode = FileManager.ReadGcode(BrowseInput.Text); #endregion #region Post processing // Inject midLayer code if (MidLayerCheck.Checked) { gcode = MidLayer.AddMidLayerCode(gcode, MidLayerText.Text); } // Add Pause in X layers if (PauseCheck.Checked) { gcode = Pause.AddPauseCode(gcode, Pauses); } // TODO: Add file merge #endregion #region File write // Opens the save file dialog SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Save Gcode"; saveDialog.DefaultExt = "gcode"; saveDialog.Filter = "gcode files (*.gcode)|*.gcode"; saveDialog.FilterIndex = 1; saveDialog.RestoreDirectory = true; if (saveDialog.ShowDialog() == DialogResult.OK) { // Saves file FileManager.WriteGcode(saveDialog.FileName, gcode); // Sends success message MessageBox.Show("File created", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } #endregion } catch (IOException exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Uses righthand rule public void RotateMidLayer(MidLayer midLayer, bool clockwise) { int[] indices; switch(midLayer) { case MidLayer.EQUATOR: indices = equatorIndices; break; case MidLayer.MIDDLE: indices = middleIndices; break; case MidLayer.STANDING: indices = standingIndices; break; default: indices = null; break; } Color[] layer = new Color[12]; for (int i = 0; i < 12; i++) { int index = indices[i]; layer[i] = m_model[index]; } if(clockwise) { layer = shiftRight(layer); } else { layer = shiftLeft(layer); } for (int i = 0; i < 12; i++) { int index = indices[i]; m_model[index] = layer[i]; } }