示例#1
0
 private void InsertString(PiMakerEditor e,string s)
 {
     int rstart = row;
     int cstart = col;
     int rend = selRow;
     int cend = selCol;
     if (row > selRow || (row == selRow && col > selCol))
     {
         rstart = selRow;
         cstart = selCol;
         rend = row;
         cend = col;
     }
     e._row = rstart;
     e._col = cstart;
     s = s.Replace("\r\n", "\n");
     s = s.Replace('\r', '\n');
     string[] la = s.Split('\n');
     string l = e.lines[e.row].text;
     if (e.col > l.Length) e.col = l.Length;
     la[0] = l.Substring(0, e.col) + la[0];
     int nc = la[la.Length - 1].Length;
     la[la.Length - 1] = la[la.Length - 1] + l.Substring(e.col);
     e.col = nc;
     e.lines[rstart] = new GCodeShort(la[0]);
     string[] la2 = new string[la.Length - 1];
     for (int i = 1; i < la.Length; i++)
     {
         la2[i - 1] = la[i];
     }
     if (la.Length > 1)
     {
         for (int j = 0; j < la2.Length; j++)
             e.lines.Insert(e.row + 1 + j, new GCodeShort(la2[j]));
     }
     e.row += la.Length - 1;
 }
示例#2
0
文件: Main.cs 项目: adambyram/pimaker
        public Main()
        {
            executeHostCall = new executeHostCommandDelegate(this.executeHostCommand);
            PiMakerKey = Custom.BaseKey; // Registry.CurrentUser.CreateSubKey("SOFTWARE\\PiMaker");
            PiMakerKey.SetValue("installPath", Application.StartupPath);
            if (Path.DirectorySeparatorChar != '\\' && IsRunningOnMac())
                IsMac = true;
            /*String[] parms = Environment.GetCommandLineArgs();
            string lastcom = "";
            foreach (string s in parms)
            {
                if (lastcom == "-home")
                {
                    PiMakerKey.SetValue("installPath",s);
                    lastcom = "";
                    continue;
                }
                if (s == "-macosx") IsMac = true;
                lastcom = s;
            }*/
            main = this;
            trans = new Trans(Application.StartupPath + Path.DirectorySeparatorChar + "data" + Path.DirectorySeparatorChar + "translations");
            SwitchButton.imageOffset = RegMemory.GetInt("onOffImageOffset", 0);
            generator = new GCodeGenerator();
            globalSettings = new GlobalSettings();
            conn = new PrinterConnection();
            printerSettings = new FormPrinterSettings();
            conn.analyzer.start();
            threeDSettings = new ThreeDSettings();
            InitializeComponent();
            editor = new PiMakerEditor();
            editor.Dock = DockStyle.Fill;
            tabGCode.Controls.Add(editor);
            updateShowFilament();
            RegMemory.RestoreWindowPos("mainWindow", this);
            if (WindowState == FormWindowState.Maximized)
                Application.DoEvents();
            splitLog.SplitterDistance = RegMemory.GetInt("logSplitterDistance", splitLog.SplitterDistance);
            splitInfoEdit.SplitterDistance = RegMemory.GetInt("infoEditSplitterDistance", Width - 470);
            if (IsMono)
            {
                if (!IsMac)
                {
                    foreach (ToolStripItem m in menu.Items)
                    {
                        m.Text = m.Text.Replace("&", null);
                    }
                }
                if (IsMac)
                {
                    /*Application.Events.Quit += delegate (object sender, ApplicationEventArgs e) {
                        Application.Quit ();
                        e.Handled = true;
                    };
 
                    ApplicationEvents.Reopen += delegate (object sender, ApplicationEventArgs e) {
                        WindowState = FormWindowState.Normal;
                        e.Handled = true;
                    };*/

                    MinimumSize = new Size(500, 640);
                    tab.MinimumSize = new Size(500, 500);
                    splitLog.Panel1MinSize = 520;
                    splitLog.Panel2MinSize = 100;
                    splitLog.IsSplitterFixed = true;
                    //splitContainerPrinterGraphic.SplitterDistance -= 52;
                    splitLog.SplitterDistance = splitLog.Height - 100;
                }
            }
            slicerToolStripMenuItem.Visible = false;
            splitLog.Panel2Collapsed = !RegMemory.GetBool("logShow", true);
            conn.eventConnectionChange += OnPrinterConnectionChange;
            conn.eventPrinterAction += OnPrinterAction;
            conn.eventJobProgress += OnJobProgress;
            stlComposer1 = new STLComposer();
            stlComposer1.Dock = DockStyle.Fill;
            tabModel.Controls.Add(stlComposer1);
            printPanel = new PrintPanel();
            printPanel.Dock = DockStyle.Fill;
            tabPrint.Controls.Add(printPanel);
            printerSettings.formToCon();
            logView = new LogView();
            logView.Dock = DockStyle.Fill;
            splitLog.Panel2.Controls.Add(logView);
            skeinforge = new Skeinforge();
            PrinterChanged(printerSettings.currentPrinterKey, true);
            printerSettings.eventPrinterChanged += PrinterChanged;
            // GCode print preview
            threedview = new ThreeDControl();
            threedview.Dock = DockStyle.Fill;
            tabPage3DView.Controls.Add(threedview);

            printPreview = new ThreeDView();
            // printPreview.Dock = DockStyle.Fill;
            //  splitContainerPrinterGraphic.Panel2.Controls.Add(printPreview);
            printPreview.SetEditor(false);
            printPreview.autoupdateable = true;
            printVisual = new GCodeVisual(conn.analyzer);
            printVisual.liveView = true;
            printPreview.models.AddLast(printVisual);
            basicTitle = Text;
            jobPreview = new ThreeDView();
            //   jobPreview.Dock = DockStyle.Fill;
            //   splitJob.Panel2.Controls.Add(jobPreview);
            jobPreview.SetEditor(false);
            jobPreview.models.AddLast(jobVisual);
            editor.contentChangedEvent += JobPreview;
            editor.commands = new Commands();
            editor.commands.Read("default", "en");
            UpdateHistory();
            UpdateConnections();
            Main.slic3r = new Slic3r();
            slicer = new Slicer();
            //toolShowLog_CheckedChanged(null, null);
            updateShowFilament();
            assign3DView();
            history = new TemperatureHistory();
            tempView = new TemperatureView();
            tempView.Dock = DockStyle.Fill;
            tabPageTemp.Controls.Add(tempView);
            if (IsMono)
                showWorkdirectoryToolStripMenuItem.Visible = false;
            new SoundConfig();
            stlComposer1.buttonSlice.Text = Trans.T1("L_SLICE_WITH", slicer.SlicerName);

            // Customizations

            if (Custom.GetBool("removeTestgenerator", false))
            {
                internalSlicingParameterToolStripMenuItem.Visible = false;
                testCaseGeneratorToolStripMenuItem.Visible = false;
            }
            string titleAdd = Custom.GetString("titleAddition", "");
            if (titleAdd.Length > 0)
            {
                int p = basicTitle.IndexOf(' ');
                basicTitle = basicTitle.Substring(0, p) + titleAdd + basicTitle.Substring(p);
                Text = basicTitle;
            }
            slicerPanel.UpdateSelection();
            if (Custom.GetBool("removeUpdates", false))
                checkForUpdatesToolStripMenuItem.Visible = false;
            else
                RHUpdater.checkForUpdates(true);
            UpdateToolbarSize();
            // Add languages
            foreach (Translation t in trans.translations.Values)
            {
                ToolStripMenuItem item = new ToolStripMenuItem(t.language, null, languageSelected);
                item.Tag = t;
                languageToolStripMenuItem.DropDownItems.Add(item);
            }
            languageChanged += translate;
            translate();
            toolAction.Text = Trans.T("L_IDLE");
            toolConnection.Text = Trans.T("L_DISCONNECTED");
        }
示例#3
0
 private void EndPos(PiMakerEditor e, string s,out int cpos,out int rpos)
 {
     int rstart = row;
     int cstart = col;
     int rend = selRow;
     int cend = selCol;
     if (row > selRow || (row == selRow && col > selCol))
     {
         rstart = selRow;
         cstart = selCol;
         rend = row;
         cend = col;
     }
     s = s.Replace("\r\n", "\n");
     s = s.Replace('\r', '\n');
     string[] la = s.Split('\n');
     string l = e.lines[rstart].text;
     if (cstart > l.Length) cstart = l.Length;
     la[0] = l.Substring(0, cstart) + la[0];
     int nc = la[la.Length - 1].Length;
     if (la.Length == 1) cpos = la[0].Length;
     else cpos = la[la.Length - 1].Length;
     rpos = rstart + la.Length - 1;
 }
示例#4
0
 public void UndoAction(PiMakerEditor e)
 {
     int rstart = row;
     int cstart = col;
     int rend = selRow;
     int cend = selCol;
     int ce, re;
     if (row > selRow || (row == selRow && col > selCol))
     {
         rstart = selRow;
         cstart = selCol;
         rend = row;
         cend = col;
     }
     EndPos(e, text, out ce, out re);
     DeleteSelection(e, cstart, rstart, ce, re);
     InsertString(e, oldtext);
     e.row = row;
     e.col = col;
     e.PositionShowCursor(true,false);
     e.Changed();
 }
示例#5
0
 public void RedoAction(PiMakerEditor e)
 {
     int rstart = row;
     int cstart = col;
     int rend = selRow;
     int cend = selCol;
     if (row > selRow || (row == selRow && col > selCol))
     {
         rstart = selRow;
         cstart = selCol;
         rend = row;
         cend = col;
     }
     e._row = row;
     e._col = col;
     e.selCol = selCol;
     e.selRow = selRow;
     DeleteSelection(e,cstart,rstart,cend,rend);
     InsertString(e, text);
     if (text.Length == 0)
     {
         e.row = rstart;
         e.col = cstart;
     }
     else
     {
         int ce, re;
         EndPos(e, text, out ce, out re);
         e.row = re;
         e.col = ce;
     }
     e.PositionShowCursor(true, false);
     e.Changed();
 }
示例#6
0
 public void DeleteSelection(PiMakerEditor e,int cstart,int rstart,int cend,int rend)
 {
     // start row = begin first + end last row
     e.lines[rstart] = new GCodeShort(e.lines[rstart].text.Substring(0, cstart) + e.lines[rend].text.Substring(cend));
     if (rend > rstart)
         e.lines.RemoveRange(rstart + 1, rend - rstart);
     e.row = e.selRow = rstart;
     e.col = e.selCol = cstart;
     if (e.lines.Count == 0) e.Clear();
 }
示例#7
0
 public Content(PiMakerEditor e, int tp, string _name)
 {
     name = _name;
     //Text = "";
     textArray = new List<GCodeShort>();
     textArray.Add(new GCodeShort(""));
     editor = e;
     etype = tp;
 }