public void Load() { DataCapsule loaded = model.Deserialize(); NormalChartSeries[0].Values = loaded.GetValues(); SignalFrequencyTextBox.Text = loaded.SamplingFrequency.ToString(); }
private static void getData_OpenReadCompleted_Thumb(object sender, System.Net.OpenReadCompletedEventArgs e, ref int processed, int max, string thumbUrl) { try { var bitmap = e.Result.ConvertToBitmap(); if (bitmap == null) { throw new Exception(); } bitmap.Dispose(); DataCapsule.ThumbDownloadedSuccessfull(); } catch { PrintColoredTextOnce(@" Failed at: " + thumbUrl); } finally { processed++; if (processed >= max) { rsEvent.Set(); } } }
public void EditStudent() { DataCapsule getUser = new DataCapsule(); int editat = -1; for (int index = 0; index < ShowData.Count; ++index) { if (ShowData[index].SelectedIndex != -1) { editat = ShowData[index].SelectedIndex; break; } } if (editat != -1) { Form2 EditForm = new Form2(StoredData[editat]); if (EditForm.ShowDialog() == DialogResult.OK) { getUser = EditForm.capsule; getUser.id = editat + 1; StoredData[editat] = getUser; isadding = true; UpdateData(); } } else { MessageBox.Show("Seleccione un alumno para editar"); } }
public void AddStudent() { DataCapsule getUser = new DataCapsule(); Form2 addEntry = new Form2(); if (addEntry.ShowDialog() == DialogResult.OK) { getUser = addEntry.capsule; getUser.id = (totalindatabase + 1); ++totalindatabase; StoredData.Add(getUser); isadding = true; UpdateData(); } }
static bool TestDownloadRndPage() { Console.WriteLine(@"[Dl rnd pages]"); foreach (var parser in Scraper.InstanciatedScrapers) { var webClient = new WebDownload(); var capsule = new DataCapsule(); string link = parser.GetRandomPageUrl(); string html = string.Empty; try { html = webClient.DownloadString(link); //if (parser.SiteName == "Goodfon") // html = string.Empty; if (string.IsNullOrEmpty(html)) { throw new Exception(@" html string is null or zero in length at: " + parser.SiteName); } } catch (Exception ex) { PrintColoredTextOnce(@" Site: " + parser.SiteName); if (ex.Message.Length > 0) { PrintColoredTextOnce(@" " + ex.Message); } else { PrintColoredTextOnce(@" Failed to download random page"); } continue; } capsule.Scraper = parser; capsule.RndPageHtml = html; _capsuleList.Add(capsule); } return(true); }
internal static DataCapsule[] LoadFiles() { DataCapsule[] results = new DataCapsule[2]; OpenFileDialog ofd = new OpenFileDialog { Title = "Wczytaj wykres", Filter = "Binary files (*.bin)|*.bin" }; ofd.ShowDialog(); if (ofd.FileName != "") { IFormatter formatter = new BinaryFormatter(); using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { results[0] = (DataCapsule)formatter.Deserialize(stream); } } else { MessageBox.Show("Nie wybrałeś nazwy wczytywanego pliku.", "BŁĄD", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } ofd.FileName = ""; ofd.ShowDialog(); if (ofd.FileName != "") { IFormatter formatter = new BinaryFormatter(); using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { results[1] = (DataCapsule)formatter.Deserialize(stream); } } else { MessageBox.Show("Nie wybrałeś nazwy wczytywanego pliku.", "BŁĄD", MessageBoxButton.OK, MessageBoxImage.Error); return(null); } return(results); }
internal static void Serialize(DataCapsule capsule) { SaveFileDialog sfd = new SaveFileDialog { Title = "Zapisz wykres", Filter = "Binary files (*.bin)|*.bin" }; sfd.ShowDialog(); if (sfd.FileName != "") { IFormatter formatter = new BinaryFormatter(); using (var stream = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write, FileShare.None)) { formatter.Serialize(stream, capsule); } } else { MessageBox.Show("Nie wybrałeś nazwy zapisywanego pliku. Operacja zapisu zostaje anulowana.", "BŁĄD", MessageBoxButton.OK, MessageBoxImage.Error); } }
private static void getData_OpenReadCompleted_ResList(object sender, System.Net.OpenReadCompletedEventArgs e, ref int downloaded, int max, PictureData info, DataCapsule d) { try { var s = e.Result.ConvertToString(); d.ResPageHTMLList.Add(s); DataCapsule.ResPageDownloadedSuccessfull(); } catch { PrintColoredTextOnce(@" Failed at: " + new Uri(info.PageUrl).Host); } finally { downloaded++; if (downloaded >= max) { rsEvent.Set(); } } }
private static bool TestParseResList() { Console.WriteLine(@"[Parsing resolution pages for res links]"); int count = 0; foreach (var capsule in _capsuleList) { if (capsule.IsNotWorking) { PrintColoredTextOnce(@" " + capsule.Scraper.SiteName + @" isnt working.... move on"); continue; } foreach (var html in capsule.ResPageHTMLList) { var resList = capsule.Scraper.ExtractResolutions(html); if (resList.Count < 1) { PrintColoredTextOnce(@" Got none res info at: " + capsule.Scraper.SiteName); continue; } foreach (var l in resList) { if (!DataCapsule.IsRes(l.ResolutionValue)) { PrintColoredTextOnce(@" Res is not valid at: " + capsule.Scraper.SiteName + " value: " + l.ResolutionValue); } } capsule.ListOfResList.Add(resList); count += resList.Count; } } //or //int test = 0; //dataList.ForEach(a => a.ListOfResList.ForEach(b => test += b.Count)); Console.WriteLine(@" Parsed res: " + count); return(true); }
public void Generate() { DataCapsule signalBefore = sensorModel.Deserialize(); if (signalBefore == null) { return; } BeforeChartSeries[0].Values = signalBefore.GetValues(); DataCapsule signalAfter = sensorModel.GenerateSignalComeBack(signalBefore, SignalSpeedTextBox.GetValue(), ObjectDistanceTextBox.GetValue(), ObjectSpeedTextBox.GetValue(), MomentInTimeTextBox.GetValue()); if (signalAfter == null) { return; } AfterChartSeries[0].Values = signalAfter.GetValues(); DataCapsule signalCorrelation = signalBefore.WeaveCorrelation(signalAfter); CorrelationChartSeries[0].Values = signalCorrelation.GetValues(); ResultDistanceTextBox.Text = sensorModel.CalculateDistance(signalCorrelation.YValues, SignalSpeedTextBox.GetValue(), signalCorrelation.SamplingFrequency); }
public void Save() { DataCapsule capsule = new DataCapsule((ChartValues <ObservablePoint>)NormalChartSeries[0].Values, SignalFrequencyTextBox.GetValue()); model.Serialize(capsule); }