Example #1
0
        private void btnStart_Click(object sender, System.EventArgs e)
        {
            SaveSettings();
            if (!isLoaded)
            {
                if (!DoLoad())
                {
                    return;
                }
            }

            var exporter = new GCodeExporter(
                Int32.Parse(txtWidth.Text),
                Int32.Parse(txtHeight.Text),
                txtHeader.Text,
                txtFooter.Text,
                txtPenUp.Text,
                txtPenDown.Text);

            var pathLengthMm = exporter.ExportGCode(generator.Path, txtOutput.Text);

            lblPathLength.Text = $@"{pathLengthMm:n}";
        }
Example #2
0
 private void mnuFileGenerateGCode_Click(object sender, EventArgs e)
 {
     if (model.IsEmpty)
     {
         MessageBox.Show("Загрузите модель 3-D объекта!",
                         Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string    fileName      = saveFileDialog1.FileName;
         Model     scaledModel   = GetScaledModel();
         Vector2   modelPosition = new Vector2((float)edPositionX.Value, (float)edPositionY.Value);
         IExporter exporter      = new GCodeExporter(scaledModel, options, modelPosition)
         {
             Expander = new SimpleSliceExpander()
         };
         using (ProgressForm frm = new ProgressForm())
         {
             frm.Text     = "Генерация G-Code";
             frm.Exporter = exporter;
             frm.FileName = fileName;
             DialogResult result = frm.ShowDialog(this);
             if (result == DialogResult.OK)
             {
                 string estimatedTime = exporter.EstimatedTime.ToString(@"hh\:mm\:ss");
                 MessageBox.Show($"G-Code успешно записан в файл '{fileName}'!\nПримерное время печати {estimatedTime}.",
                                 Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else if (result == DialogResult.Abort)
             {
                 MessageBox.Show($"G-Code частично записан в файл '{fileName}'!",
                                 Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
     }
 }