예제 #1
0
        private void goGCode_Click(object sender, EventArgs e)
        {
            if (Path.GetExtension(__fileName) == ".svg")
            {
                GCodeFromImage.VectorToGcode codeCreator = new GCodeFromImage.VectorToGcode(__fileName);
                List <string> gcode = codeCreator.FinalGCode;

                TabPage loadGcodeTab = new TabPage(Path.GetFileNameWithoutExtension(__fileName) + " (Converted to GCode)");

                GCodeForm codeForm = new GCodeForm(__serialPort, __ownerTab, __fileName, gcode)
                {
                    Dock     = DockStyle.Fill,
                    TopLevel = false,
                    TopMost  = true
                };
                //Dodaj do nowej zakladki canvasForm
                loadGcodeTab.Controls.Add(codeForm);
                //Dodaj nowa zakladke do TabControl
                __ownerTab.Controls.Add(loadGcodeTab);
                //Wybierz ta zakladke
                __ownerTab.SelectedTab = loadGcodeTab;
                //Pokaz
                codeForm.Show();
            }
            else
            {
                RasterOptions rasterOptions = new RasterOptions(Path.GetFileName(__fileName));
                rasterOptions.ShowDialog();

                if (rasterOptions.Status)
                {
                    GCodeFromImage.RasterToGCode codeCreator = new GCodeFromImage.RasterToGCode(
                        rasterOptions.Feedrate,
                        rasterOptions.MinPower,
                        rasterOptions.MaxPower,
                        new Bitmap(__fileName),
                        GCodeFromImage.RasterToGCode.ParseStyle(rasterOptions.Style)
                        );
                    List <string> gcode = codeCreator.FinalGCode;

                    TabPage loadGcodeTab = new TabPage(Path.GetFileNameWithoutExtension(__fileName) + " (Converted to GCode)");

                    GCodeForm codeForm = new GCodeForm(__serialPort, __ownerTab, __fileName, gcode)
                    {
                        Dock     = DockStyle.Fill,
                        TopLevel = false,
                        TopMost  = true
                    };
                    //Dodaj do nowej zakladki canvasForm
                    loadGcodeTab.Controls.Add(codeForm);
                    //Dodaj nowa zakladke do TabControl
                    __ownerTab.Controls.Add(loadGcodeTab);
                    //Wybierz ta zakladke
                    __ownerTab.SelectedTab = loadGcodeTab;
                    //Pokaz
                    codeForm.Show();
                }
            }
        }
예제 #2
0
        public void goLoadGCode_Click(object sender, EventArgs e)
        {
            // Ładowanie pliku .nc, .gcode, .txt
            OpenFileDialog openFile = new OpenFileDialog();

            //Filtry dla OPF
            openFile.Filter = "Instrukcje GCode|*.nc|Instrukcje GCode|*.gcode|Pliki tekstowe (.txt)|*.txt|All files (*.*)|*.*";
            //Pokazuj najpierw instrukcje .nc
            openFile.FilterIndex = 1;

            //Czy wczytana jakas instrukcja?
            if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                addFileToWelcome(openFile.FileName);

                TabPage loadGcodeTab = new TabPage(Path.GetFileNameWithoutExtension(openFile.FileName) + " (GCode)");

                GCodeForm codeForm = new GCodeForm(serialPort, tabControl, openFile.FileName)
                {
                    Dock     = DockStyle.Fill,
                    TopLevel = false,
                    TopMost  = true
                };
                //Dodaj do nowej zakladki canvasForm
                loadGcodeTab.Controls.Add(codeForm);
                //Dodaj nowa zakladke do TabControl
                tabControl.Controls.Add(loadGcodeTab);
                //Wybierz ta zakladke
                tabControl.SelectedTab = loadGcodeTab;
                //Pokaz
                codeForm.Show();
            }
            else
            {
            }

            sidePanelHideAll();
            sidePanelCollapse();
        }