private void btnGetIP_Click(object sender, EventArgs e) { string actualIP = tboxEnterURL.Text.Trim(); try { IPAddress[] addresslist = Dns.GetHostAddresses(actualIP); tboxCasterIP.Text = ""; tboxCasterIP.Text = addresslist[0].ToString().Trim(); } catch (Exception) { mf.TimedMessageBox(1500, "No IP Located", "Can't Find: " + actualIP); } }
private void btnTemplate_Click(object sender, EventArgs e) { //create the dialog instance OpenFileDialog ofd = new OpenFileDialog { //the initial directory, fields, for the open dialog InitialDirectory = mf.fieldsDirectory, //When leaving dialog put windows back where it was RestoreDirectory = true, //set the filter to text files only Filter = "Field files (Field.txt)|Field.txt" }; //was a file selected if (ofd.ShowDialog() == DialogResult.Cancel) { isTemplateSet = false; mf.TimedMessageBox(1500, "Template Cancelled", "You can still start a new field"); return; } else { templateFileAndDirectory = ofd.FileName; isTemplateSet = true; lblTemplateChosen.Text = new DirectoryInfo(Path.GetDirectoryName(templateFileAndDirectory)).Name; } }
private void tboxAutoSteerIP_Validating(object sender, CancelEventArgs e) { if (!CheckIPValid(tboxAutoSteerIP.Text)) { tboxAutoSteerIP.Text = "127.0.0.1"; tboxAutoSteerIP.Focus(); mf.TimedMessageBox(2000, "Invalid IP Address", "Set to Default Local 127.0.0.1"); } }
private void FormABLine_Load(object sender, EventArgs e) { //different start based on AB line already set or not if (mf.ABLine.isABLineSet) { //AB line is on screen and set btnAPoint.Enabled = false; btnBPoint.Enabled = true; upDnHeading = Math.Round(glm.toDegrees(mf.ABLine.abHeading), 6); nudTramRepeats.Value = mf.ABLine.tramPassEvery; nudBasedOnPass.Value = mf.ABLine.passBasedOn; tboxHeading.Text = upDnHeading.ToString(CultureInfo.InvariantCulture); } else { //no AB line btnAPoint.Enabled = true; btnBPoint.Enabled = false; //btnABLineOk.Enabled = false; upDnHeading = Math.Round(glm.toDegrees(mf.fixHeading), 6); nudTramRepeats.Value = 0; nudBasedOnPass.Value = 0; mf.ABLine.tramPassEvery = 0; mf.ABLine.passBasedOn = 0; } //make sure at least a blank AB Line file exists string dirABLines = mf.ablinesDirectory; string directoryName = Path.GetDirectoryName(dirABLines).ToString(CultureInfo.InvariantCulture); if ((directoryName.Length > 0) && (!Directory.Exists(directoryName))) { Directory.CreateDirectory(directoryName); } filename = directoryName + "\\ABLines.txt"; if (!File.Exists(filename)) { using (StreamWriter writer = new StreamWriter(filename)) { writer.WriteLine("ABLine N S,0,0,0"); writer.WriteLine("ABLine E W,90,0,0"); } } //get the file of previous AB Lines if ((directoryName.Length > 0) && (!Directory.Exists(directoryName))) { Directory.CreateDirectory(directoryName); } filename = directoryName + "\\ABLines.txt"; if (!File.Exists(filename)) { mf.TimedMessageBox(2000, "File Error", "Missing AB Line File, Critical Error"); } else { using (StreamReader reader = new StreamReader(filename)) { try { string line; ListViewItem itm; //read all the lines while (!reader.EndOfStream) { line = reader.ReadLine(); string[] words = line.Split(','); //listboxLines.Items.Add(line); itm = new ListViewItem(words); lvLines.Items.Add(itm); //coords.easting = double.Parse(words[0], CultureInfo.InvariantCulture); //coords.northing = double.Parse(words[1], CultureInfo.InvariantCulture); //youFileList.Add(coords); } } catch (Exception er) { var form = new FormTimedMessage(4000, "ABLine File is Corrupt", "Please delete it!!!"); form.Show(); mf.WriteErrorLog("FieldOpen, Loading ABLine, Corrupt ABLine File" + er); } } // go to bottom of list - if there is a bottom if (lvLines.Items.Count > 0) { lvLines.Items[lvLines.Items.Count - 1].EnsureVisible(); } } }