//protected override CreateParams CreateParams //{ // get // { // CreateParams cp = base.CreateParams; // cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED // return cp; // } //} private void frmMain_Load(object sender, EventArgs e) { portaSerial = new PortaSerial(serialPort_DataReceived); lblStatus.ForeColor = System.Drawing.Color.Red; txtXStep.Text = Conkey.getConkey().xStep.ToString(); txtYStep.Text = Conkey.getConkey().yStep.ToString(); txtServoUp.Text = Conkey.getConkey().servoUp.ToString(); txtServoDown.Text = Conkey.getConkey().servoDown.ToString(); txtMaxCharPerLine.Text = Conkey.getConkey().maxCharLine.ToString(); chkDoubleDots.Checked = Conkey.getConkey().doubleDot; this.btnSetHome.Size = new System.Drawing.Size(207, 36); this.btnSetHome.AutoSize = false; this.btnGoHome.Size = new System.Drawing.Size(35, 36); this.btnGoHome.AutoSize = false; int margin = 10; int btnHeight = 80; int btnWidth = (this.Size.Width - (margin * 4)) / 3; this.btnConectar.Size = new System.Drawing.Size(btnWidth, btnHeight); this.btnConectar.AutoSize = false; this.btnEscolher.Size = new System.Drawing.Size(btnWidth, btnHeight); this.btnEscolher.AutoSize = false; this.btnImprimir.Size = new System.Drawing.Size(btnWidth, btnHeight); this.btnImprimir.AutoSize = false; this.btnConectar.Location = new Point(margin, margin); this.btnConectar.AutoSize = false; this.btnEscolher.Location = new Point(btnWidth + (margin * 2), margin); this.btnEscolher.AutoSize = false; this.btnImprimir.Location = new Point((btnWidth * 2) + (margin * 3), margin); this.btnImprimir.AutoSize = false; this.barProgress.Location = new Point(margin, btnHeight + (margin * 5)); this.barProgress.Size = new Size((Convert.ToInt16(this.Size.Width * 0.9)), 5); this.lblProgress.Location = new Point((margin * 2) + this.barProgress.Size.Width, btnHeight + (margin * 4)); this.lblStatusImpressoraLabel.ForeColor = Color.Black; this.lblStatusImpressora.ForeColor = Color.Black; this.lblStatusImpressora.Text = ""; btnConectar.PerformClick(); if (portaSerial.isOpen()) { materialTabControl1.SelectTab(0); } else { materialTabControl1.SelectTab(1); } }
private void btnConectar_Click(object sender, EventArgs e) { if (portaSerial.isOpen()) { portaSerial.getPort().Close(); } else { if (portaSerial.pegarPortasSeriais().Count == 1) { portaSerial.conectar(portaSerial.pegarPortasSeriais()[0].ToString()); } else { materialTabControl1.SelectTab(1); } } }