Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        private void TemperatureView_Paint(object sender, PaintEventArgs ev)
        {
            hist = Main.main.history;
            if (hist == null) return;
            Graphics g = ev.Graphics;
            SolidBrush backBrush = new SolidBrush(hist.backgroundColor);
            if (font == null)
            {
                font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular);

                SizeF sz = g.MeasureString("00:00", font);
                timeWidth = sz.Width;
                timeHeight = sz.Height;
                sz = g.MeasureString("000", font);
                tempWidth = sz.Width;
            }
            g.FillRectangle(backBrush, 0, 0, Width, Height);

            float height = Height;
            float width = Width;
            float fontLeft = tempWidth + tickExtra + spaceExtra + 5;
            float fontBottom = (timeHeight + tickExtra + 3);
            float marginTop = 5;
            double timespan = hist.CurrentZoomLevel * 60000.0;
            if (hist.Autoscroll)
                hist.xpos = 100.0;
            righttime = (hist.currentHistory.maxTime / 10000) - (3600000 - timespan) * 0.01 * (100.0 - hist.xpos);
            lefttime = righttime - timespan;
            Rectangle outputRect, tempRect;
            minTemp = 0; maxTemp = 300;
            bool hasTemp = false;
            foreach (TemperatureEntry e in hist.currentHistory.entries)
            {
                if (e.time/10000 < lefttime || e.time/10000 > righttime) continue;
                if (hist.ShowExtruder)
                {
                    { if (e.extruder >= 0) { if (!hasTemp) { minTemp = maxTemp = e.extruder; hasTemp = true; } else { minTemp = Math.Min(e.extruder, minTemp); maxTemp = Math.Max(e.extruder, maxTemp); } } }
                    if (hist.ShowAverage)
                    { if (e.avgExtruder >= 0) { if (!hasTemp) { minTemp = maxTemp = e.avgExtruder; hasTemp = true; } else { minTemp = Math.Min(e.avgExtruder, minTemp); maxTemp = Math.Max(e.avgExtruder, maxTemp); } } }
                    if (hist.ShowTarget)
                    { if (e.targetExtruder >= 0) { if (!hasTemp) { minTemp = maxTemp = e.targetExtruder; hasTemp = true; } else { minTemp = Math.Min(e.targetExtruder, minTemp); maxTemp = Math.Max(e.targetExtruder, maxTemp); } } }
                }
                if (hist.ShowBed)
                {
                    { if (e.bed >= 0) { if (!hasTemp) { minTemp = maxTemp = e.bed; hasTemp = true; } else { minTemp = Math.Min(e.bed, minTemp); maxTemp = Math.Max(e.bed, maxTemp); } } }
                    if (hist.ShowAverage)
                    { if (e.avgBed >= 0) { if (!hasTemp) { minTemp = maxTemp = e.avgBed; hasTemp = true; } else { minTemp = Math.Min(e.avgBed, minTemp); maxTemp = Math.Max(e.avgBed, maxTemp); } } }
                    if (hist.ShowTarget)
                    { if (e.targetBed >= 0) { if (!hasTemp) { minTemp = maxTemp = e.targetBed; hasTemp = true; } else { minTemp = Math.Min(e.targetBed, minTemp); maxTemp = Math.Max(e.targetBed, maxTemp); } } }
                }
            }
            maxTemp += 4;
            minTemp -= 4;
            maxTemp = Math.Ceiling(maxTemp / 10.0) * 10.0;
            minTemp = Math.Floor(minTemp / 10.0) * 10.0;
            if (minTemp < 0) minTemp = 0;
            int i;
            if (hist.ShowOutput && height > 4 * (fontBottom + marginTop))
            {
                double h1 = 0.75 * height;
                double h2 = 0.25 * height;
                tempRect = new Rectangle((int)fontLeft, (int)0, (int)(width - 2 * fontLeft), (int)(h1 - fontBottom - marginTop));
                outputRect = new Rectangle((int)fontLeft, (int)h1, (int)(width - 2 * fontLeft), (int)(h2 - fontBottom - marginTop));
                outScale = 255.0 / (h2 - fontBottom - marginTop);
            }
            else
            {
                tempRect = new Rectangle((int)fontLeft, (int)0, (int)(width - 2 * fontLeft), (int)(height - fontBottom - marginTop));
            }
            double theight = tempRect.Height;
            tempScale = theight / (maxTemp - minTemp);
            int best = 0;
            for (i = 0; i < 7; i++)
            {
                double dist = tempScale * tempTickSizes[i];
                if (dist > 20) best = i;
            }
            tempTick = tempTickSizes[best];
            best = 0;
            double twidth = tempRect.Width;
            timeScale = twidth / timespan;
            for (i = 0; i < 9; i++)
            {
                double dist = timeScale * timeTickSizes[i];
                if (dist > 40) best = i;
            }
            timeTick = timeTickSizes[best];
            drawGrid(tempRect, true, g);
            if (hist.ShowOutput && height > 4 * (fontBottom + marginTop))
            {
                double h1 = 0.75 * height;
                double h2 = 0.25 * height;
                outputRect = new Rectangle((int)fontLeft, (int)h1, (int)(width - 2 * fontLeft), (int)(h2 - fontBottom - marginTop));
                drawGrid(outputRect, false, g);
            }
        }