svenhb / GRBL-Plotter

A GCode sender (not only for lasers or plotters) for up to two GRBL controller. SVG, DXF, HPGL import. 6 axis DRO.
https://grbl-plotter.de/
GNU General Public License v3.0
696 stars 176 forks source link

Insert or update text from same window. #300

Closed Makasudali closed 2 years ago

Makasudali commented 2 years ago

Hi, Friends User need to open another window to insert text instead of it can any option on same window to Insert or update text or any other controls. Can anybody guide me how to use existing code to make above changes.

Code from Create Gcode Btn Control. =========================public void CreateText() { PathBackground.Reset(); path = PathBackground; path.StartFigure();

        float x, y;
        x = (float)10;
        y = (float)10;
        GetOffset(x, y);

        path.AddLine(offsetX, offsetY, offsetX + x, offsetY);           // create background path
        path.AddLine(offsetX + x, offsetY, offsetX + x, offsetY + y);
        path.AddLine(offsetX + x, offsetY + y, offsetX, offsetY + y);
        path.AddLine(offsetX, offsetY + y, offsetX, offsetY);

        if (cBFont.SelectedIndex < 0)
        {   MessageBox.Show("Please select a font", "Error");
            return;
        }
        Logger.Trace(culture, " createText()    ");
        SaveSettings();
        GCodeFromFont.Reset();
        GCodeFromFont.GCText = tBText.Text;
        GCodeFromFont.GCFontName = cBFont.Items[cBFont.SelectedIndex].ToString();
        GCodeFromFont.GCHeight = (double)nUDFontSize.Value;
        GCodeFromFont.GCFontDistance = (double)nUDFontDistance.Value;
        GCodeFromFont.GCLineDistance = (double)(nUDFontLine.Value / nUDFontSize.Value);
        GCodeFromFont.GCSpacing = (double)(nUDFontLine.Value / nUDFontSize.Value) / 1.5;
        GCodeFromFont.GCPauseChar = cBPauseChar.Checked;
        GCodeFromFont.GCPauseWord = cBPauseWord.Checked;
        GCodeFromFont.GCPauseLine = cBPauseLine.Checked;
        GCodeFromFont.GCConnectLetter = cBConnectLetter.Checked;

        VisuGCode.pathBackground.Reset();
        Graphic.CleanUp();
        Graphic.Init(Graphic.SourceType.Text, "", null, null);
        Graphic.graphicInformation.OptionNodesOnly = false;
        Graphic.graphicInformation.OptionSortCode = false;
        Graphic.graphicInformation.OptionZFromWidth = false;

        Graphic.graphicInformation.FigureEnable = true;
        Graphic.graphicInformation.GroupEnable = true;
        Graphic.graphicInformation.GroupOption = Graphic.GroupOption.ByType;
        Graphic.SetType("Text");

        if (Properties.Settings.Default.createTextLineBreakEnable)
            GCodeFromFont.GetCode((double)nUDLineBreak.Value);      // do automatic page break
        else
            GCodeFromFont.GetCode(0);   // no page break

        if (RbAlign2.Checked)
            Graphic.AlignLines(1);      // 0=left, 1=center, 2=right
        else if (RbAlign3.Checked)
            Graphic.AlignLines(2);      // 0=left, 1=center, 2=right

        Graphic.CreateGCode();          // result is saved as stringbuilder in Graphic.GCode;
    }
svenhb commented 2 years ago

any option on same window to Insert...

image

Same here: image