-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm1.cs
More file actions
86 lines (79 loc) · 2.71 KB
/
Form1.cs
File metadata and controls
86 lines (79 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Globalization;
namespace P2_to_P3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
bool debug = false; //Ignore file already converted.
string csv = File.ReadAllText(textBox1.Text);
if (debug == !true)
{
if (!csv.Contains("P-GPS"))
{
csv = csv.Replace("GPS", "P-GPS");
}
else
{
MessageBox.Show("This log has already been converted");
goto End;
}
}
else
{
csv = csv.Replace("GPS", "P-GPS");
}
File.WriteAllText(textBox1.Text, csv);
Chilkat.Csv chcsv = new Chilkat.Csv();
bool load = chcsv.LoadFile(textBox1.Text);
if (load = !true)
{
MessageBox.Show("load failed!");
}
int lineCount = File.ReadLines(textBox1.Text).Count();
MessageBox.Show("There are " + lineCount + " lines");
progressBar1.Maximum = lineCount;
for (int i = 1; i <= lineCount-1; i++)
{
bool setcelltest = chcsv.SetCell(i, 50, "4");
string gettemp = chcsv.GetCell(i, 33);
string tempout = gettemp.Replace(',', '.');
double tempoutout = double.Parse(tempout, CultureInfo.InvariantCulture);
double kelvintemp = tempoutout*10 + 2732;
double kelvindone = kelvintemp - 0.5;
string kelvinstring = Convert.ToString(kelvindone);
string kelvincomplete = kelvinstring.Replace(",", ".");
bool settemptest = chcsv.SetCell(i, 33, kelvincomplete);
progressBar1.Value = i;
}
chcsv.SetCell(1, 52, textBox2.Text);
MessageBox.Show("Done converting! Upload to HealthyDrones and enjoy!");
bool savetest = chcsv.SaveFile(textBox1.Text);
End:;
}
}
}