private void BT_Go_Click(object sender, EventArgs e) { if (TB_Address.Text.Trim().Length <= 0) { return; } txtHTML.Text = ""; string sAddress = TB_Address.Text; if (sAddress.ToLower().StartsWith("http://") == false && sAddress.ToLower().StartsWith("https://") == false) { sAddress = "http://" + sAddress; } if (HTMLultility.RemoteFileExists(sAddress) == false) { MessageBox.Show("Link không tồn tại", "MVT - Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning); TB_Address.Focus(); return; } using (WebClient client = new WebClient()) { try { txtHTML.Text = client.DownloadString(sAddress); } catch (Exception ex) { throw new Exception(ex.Message); } } }
private void Btn_Load_Click(object sender, EventArgs e) { if (TB_Address.InvokeRequired) { TB_Address.BeginInvoke(new Action(() => { TB_Address.Text = Properties.Settings.Default.Config_Address; TB_UserID.Text = Properties.Settings.Default.Config_UserID; TB_Password.Text = Properties.Settings.Default.Config_Password; })); } else { TB_Address.Text = Properties.Settings.Default.Config_Address; TB_UserID.Text = Properties.Settings.Default.Config_UserID; TB_Password.Text = Properties.Settings.Default.Config_Password; } MsgWrite("저장된 데이터를 불러옵니다."); }
private void Btn_Save_Click(object sender, EventArgs e) { if (TB_Address.InvokeRequired) { TB_Address.BeginInvoke(new Action(() => { Properties.Settings.Default.Config_Address = TB_Address.Text; Properties.Settings.Default.Config_UserID = TB_UserID.Text; Properties.Settings.Default.Config_Password = TB_Password.Text; })); } else { Properties.Settings.Default.Config_Address = TB_Address.Text; Properties.Settings.Default.Config_UserID = TB_UserID.Text; Properties.Settings.Default.Config_Password = TB_Password.Text; } MsgWrite("저장하였습니다."); }
private void BT_Go_Click(object sender, EventArgs e) { if (TB_Address.Text.Trim().Length <= 0) { return; } List_Email.Items.Clear(); List_Link.Items.Clear(); //TB_HTML.Text = ""; iIndex = 0; string sAddress = TB_Address.Text; if (sAddress.ToLower().StartsWith("http://") == false && sAddress.ToLower().StartsWith("https://") == false) { sAddress = "http://" + sAddress; } if (HTMLultility.RemoteFileExists(sAddress) == false) { MessageBox.Show("Link không tồn tại", "MVT - Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning); TB_Address.Focus(); return; } sHostname = HTMLultility.GetHotName(sAddress); Pic_Loading.Visible = true; List_Link.Items.Add(sAddress); List_Link.SelectedIndex = iIndex; thrHTML = new Thread(new ThreadStart(GetHTML)); thrHTML.Start(); timer1.Enabled = true; TB_Address.Enabled = false; BT_Go.Enabled = false; BT_Stop.Enabled = true; BT_ExportEmail.Enabled = false; BT_ExportLink.Enabled = false; }
private void BTN_Connect_Click(object sender, EventArgs e) { if (!Connected) { if (CBX_Kit.SelectedIndex == -1) { MessageBox.Show("Please select a KIT Name.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (CBX_ComPorts.SelectedIndex == -1) { MessageBox.Show("Please select a valid COM Port", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // Initialize COM Port parameters c_Serial.PortName = CBX_ComPorts.Text; c_Serial.BaudRate = 115200; // Assign COM Port Baud Rate c_Serial.DataBits = 8; // Assign COM Port DataBits c_Serial.ReadTimeout = 500; // Assign COM Port ReadTimeout c_Serial.WriteTimeout = 500; // Assign COM Port WriteTimeout c_Serial.DataReceived += new SerialDataReceivedEventHandler(USB_DataReceived); // Assign COM Port Receive data Event try { c_Serial.Open(); // Open the serial port c_Serial.WriteLine(MKI[CBX_Kit.SelectedIndex].setdb + "\r\n"); // Send the "setdb" command to the microcontroller just to configure itself for the right sensor Thread.Sleep(50); // Wait 50ms between serial port writings c_Serial.WriteLine("*zoff\r\n"); // Send the "zoff" command GB_DirectCommunication.Enabled = true; CBX_Kit.Enabled = false; // Disable Combo Box Kit selection CBX_ComPorts.Enabled = false; // Disable Combo Box COM selection BTN_ComRefresh.Enabled = false; // Disable Button COM refresh // Define Default RadioButton Selected if (MKI[CBX_Kit.SelectedIndex].Name.Contains("MKI178V1")) { RB_Acc.Enabled = true; RB_Gyro.Enabled = true; RB_Mag.Enabled = false; RB_Prs.Enabled = false; RB_Acc.Checked = true; RB_Gyro.Checked = false; RB_Mag.Checked = false; RB_Prs.Checked = false; GB_DataOutput.Enabled = true; } else if (MKI[CBX_Kit.SelectedIndex].Name.Contains("MKI179V1")) { RB_Acc.Enabled = true; RB_Gyro.Enabled = false; RB_Mag.Enabled = false; RB_Prs.Enabled = false; RB_Acc.Checked = true; RB_Gyro.Checked = false; RB_Mag.Checked = false; RB_Prs.Checked = false; GB_DataOutput.Enabled = true; } else if (MKI[CBX_Kit.SelectedIndex].Name.Contains("MKI181V1")) { RB_Acc.Enabled = false; RB_Gyro.Enabled = false; RB_Mag.Enabled = true; RB_Prs.Enabled = false; RB_Acc.Checked = false; RB_Gyro.Checked = false; RB_Mag.Checked = true; RB_Prs.Checked = false; GB_DataOutput.Enabled = true; } else if (MKI[CBX_Kit.SelectedIndex].Name.Contains("MET001V1")) { RB_Acc.Enabled = false; RB_Gyro.Enabled = false; RB_Mag.Enabled = false; RB_Prs.Enabled = true; RB_Acc.Checked = false; RB_Gyro.Checked = false; RB_Mag.Checked = false; RB_Prs.Checked = true; GB_DataOutput.Enabled = false; // Only register read/write for Pressure sensor Case (X,Y,Z not existing) } Connected = true; BTN_Connect.Text = "Disconnect"; } catch { MessageBox.Show("Impossible to open the COM Port selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else { // Erase connection status Connected = false; BTN_Connect.Text = "Connect"; // Erase start status Start = false; BTN_Start.Text = "Start"; c_Serial.DataReceived -= USB_DataReceived; // Remove COM Port Receive data Event c_Serial.WriteLine("*stop\r\n"); // Send the "stop" command Thread.Sleep(10); // Wait 10ms between serial port writings c_Serial.WriteLine("*zon\r\n"); // Send the "zon" command Thread.Sleep(10); // Wait 10ms between serial port writings c_Serial.WriteLine("*dbreset\r\n"); // Send the "dbreset" command Thread thread = new Thread(new ThreadStart(CloseSerialPort)); // Close the serial port in different thread to avoid deadlock thread.Start(); CBX_Kit.Enabled = true; // Enable Combo Box Kit selection CBX_ComPorts.Enabled = true; // Enable Combo Box COM selection BTN_ComRefresh.Enabled = true; // Enable Button COM refresh RB_Acc.Enabled = false; // Disable Accelerometer RadioButton RB_Gyro.Enabled = false; // Disable Gyroscope RadioButton RB_Mag.Enabled = false; // Disable Magnetometer RadioButton RB_Prs.Enabled = false; // Disable Pressure RadioButton RB_Acc.Checked = false; // Uncheck Accelerometer RadioButton RB_Gyro.Checked = false; // Uncheck Gyroscope RadioButton RB_Mag.Checked = false; // Uncheck Magnetometer RadioButton RB_Prs.Checked = false; // Uncheck Pressure RadioButton GB_DirectCommunication.Enabled = false; // Disable Direct Communication Group Box GB_DataOutput.Enabled = false; // Disable Continuous Data Output Group Box TB_Address.Clear(); // Clear Address Text Box content TB_Value.Clear(); // Clear Value Text Box content TB_Val1.Clear(); // Clear Axis1 Text Box content TB_Val2.Clear(); // Clear Axis2 Text Box content TB_Val3.Clear(); // Clear Axis3 Text Box content } }
private void GetHTML_Load(object sender, EventArgs e) { this.Top = iTop; this.Left = iLeft; TB_Address.Focus(); }
private void Form1_Load(object sender, EventArgs e) { Pic_Loading.Visible = false; TB_Address.Focus(); }