/// <summary> ///loads the selected file into the GUI /// </summary> /// <param name="result">the file to load</param> public void LoadNewData(string result) { startingTimes = new List <double>(); endingTimes = new List <double>(); canGraph.ClearDatasets(); if (HideControlsThread != null) { HideControlsThread.CancelAsync(); } if (VideoProgressThread != null) { VideoProgressThread.CancelAsync(); } if (ShowControllsThread != null) { ShowControllsThread.CancelAsync(); } Thread.Sleep(25); mediaElement.Stop(); mediaElement.Source = null; Thread.Sleep(25); GraphDataset data = ImportData(result); if (data == null) { MessageBox.Show("invalid data"); return; } Thread.Sleep(25); canGraph.AddDataset(data); mediaElement.Play(); }
/// <summary> /// Generates a GraphDataset using SummariserNode points from the data stored in lines /// </summary> /// <param name="name">the name of the GraphDataset</param> /// <returns>the completed dataset</returns> public GraphDataset GenerateDataset(string name) { GraphDataset temp = new GraphDataset(name); foreach (string[] line in lines) { try { double per = double.Parse(line[0]) * 100; Brush col = PercentToProbabilityColour(per); SummariserNode node = new SummariserNode(double.Parse(line[1]), double.Parse(line[2]), line[3], col); temp.AddNode(node); } catch (Exception) { continue; } } return(temp); }
/// <summary> /// Loads the selected path into the mediaElement and returns the accompanying data /// </summary> /// <param name="path">the path to load</param> /// <returns>the meta-data for when activities happen</returns> private GraphDataset ImportData(string path) { GraphDataset csvDataset = null; using (ZipArchive archive = ZipFile.OpenRead(path)) { File.Delete("tempvideo.mp4"); File.Delete("tempfile.csv"); bool good = true; foreach (ZipArchiveEntry entry in archive.Entries) { string a = entry.FullName; if (a == "output.csv") { entry.ExtractToFile("tempfile.csv"); csvDataset = CSVToDataset("tempfile.csv", "left"); File.Delete("tempfile.csv"); if (csvDataset == null) { return(null); } } else if (entry.Name == "video.mp4" && good) { entry.ExtractToFile("tempvideo.mp4"); mediaElement.Source = new Uri("tempvideo.mp4", UriKind.Relative); } } if (!good) { return(null); } } return(csvDataset); }