Exemplo n.º 1
0
        private void ConnectHandler(object sender, EventArgs e)
        {
            ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;

            printerSettings.load(clickedItem.Text);
            printerSettings.formToCon();
            conn.open();
        }
Exemplo n.º 2
0
        public Main()
        {
            executeHostCall = new executeHostCommandDelegate(this.executeHostCommand);
            repetierKey     = Registry.CurrentUser.CreateSubKey("Software\\Repetier");
            repetierKey.SetValue("installPath", Application.StartupPath);
            if (Path.DirectorySeparatorChar != '\\' && IsRunningOnMac())
            {
                IsMac = true;
            }

            /*String[] parms = Environment.GetCommandLineArgs();
             * string lastcom = "";
             * foreach (string s in parms)
             * {
             *  if (lastcom == "-home")
             *  {
             *      repetierKey.SetValue("installPath",s);
             *      lastcom = "";
             *      continue;
             *  }
             *  if (s == "-macosx") IsMac = true;
             *  lastcom = s;
             * }*/
            main            = this;
            generator       = new GCodeGenerator();
            globalSettings  = new GlobalSettings();
            conn            = new PrinterConnection();
            printerSettings = new FormPrinterSettings();
            threeDSettings  = new ThreeDSettings();
            InitializeComponent();
            RegMemory.RestoreWindowPos("mainWindow", this);
            if (WindowState == FormWindowState.Maximized)
            {
                Application.DoEvents();
            }
            splitLog.SplitterDistance = RegMemory.GetInt("logSplitterDistance", splitLog.SplitterDistance);
            if (IsMono)
            {
                if (!IsMac)
                {
                    splitContainerPrinterGraphic.SplitterDistance += 52;
                    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;
                    splitJob.IsSplitterFixed = true;
                    //splitContainerPrinterGraphic.SplitterDistance -= 52;
                    splitLog.SplitterDistance = splitLog.Height - 100;
                }
            }
            toolShowLog.Checked         = RegMemory.GetBool("logShow", true);
            conn.eventConnectionChange += OnPrinterConnectionChange;
            conn.eventPrinterAction    += OnPrinterAction;
            conn.eventJobProgress      += OnJobProgress;
            printPanel      = new PrintPanel();
            printPanel.Dock = DockStyle.Fill;
            splitContainerPrinterGraphic.Panel1.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
            printPreview      = new ThreeDControl();
            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 ThreeDControl();
            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();
            if (IsMac)
            {
                tabGCode.Controls.Remove(splitJob);
                tabPrint.Controls.Remove(splitContainerPrinterGraphic);
            }
        }