Commit 5b162777 authored by Vincent's avatar Vincent 💩

Working on Dive Selector

parent 131b1ee7
......@@ -180,12 +180,14 @@ namespace divecomputer_test {
private void DivecomputerWorker_DoWork(object sender, DoWorkEventArgs e) {
SetReadProgress(0, true);
SetWriteProgress(0, true);
var writeAll = ReadAllRadio.Checked;
var args = currentTask;
args.ctx = CreateContext(args.logLevel);
IDiveWriter writer = null;
try {
var allDives = new List<Dive>();
writer = CreateWriter();
writer.OnProgres += (_, total, processed) => {
SetWriteProgress((int)((float)processed / total * 100), true);
......@@ -209,16 +211,28 @@ namespace divecomputer_test {
Dive lastDive = null;
args.device.OnDive += (data, size, fingerprint, fsize, udata) => {
lastDive = Dive.Parse(args.device, data, fingerprint);
writer.AddDive(lastDive);
allDives.Add(lastDive);
if (writeAll) {
writer.AddDive(lastDive);
}
};
args.device.Start();
SetReadProgress(100, true);
writer.End();
if (!writeAll) {
DiveSelector.Show();
DiveSelector.SetDives(allDives);
DiveSelector.OnDone += (source, a) => {
Console.WriteLine(a);
};
} else {
writer.End();
}
writer.Dispose();
SetState("Saved to file");
SetState("Finished");
} catch (Exception err) {
SetState("Error while reading device: " + err.Message, Color.Red);
if (writer != null) {
......
......@@ -19,9 +19,9 @@ namespace DiveLogUploader {
gridDives.DataSource = availableDives;
}
public void SetDives(Dive[] dives) {
public void SetDives(List<Dive> dives) {
availableDives.Clear();
availableDives.Capacity = dives.Length;
availableDives.Capacity = dives.Count;
foreach(var d in dives) {
availableDives.Add(new SelectedDive {
IsSelected = true,
......@@ -32,6 +32,7 @@ namespace DiveLogUploader {
private void ButtonDone_Click(object sender, EventArgs e) {
OnDone?.Invoke(this, new DoneEventArgs { dives = new Dive[] { } });
Close();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment