public static void SaveToBinaryFile(BinaryWrapper bin, string path) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, bin); stream.Close(); }
public static BinaryWrapper ReadFromBinaryFile(string path) { IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryWrapper bin = (BinaryWrapper)formatter.Deserialize(stream); stream.Close(); return(bin); }
public void LoadSignal(object sender, RoutedEventArgs e) { string path = Serializer.FilePath(true); if (string.IsNullOrEmpty(path)) { return; } BinaryWrapper binaryWrapper = Serializer.ReadFromBinaryFile(path); Signal = binaryWrapper.DiscreteSignal; ReplotChartAndHistogram(); }
public void SaveSignal(object sender, RoutedEventArgs e) { string path = Serializer.FilePath(false); if (string.IsNullOrEmpty(path)) { return; } BinaryWrapper binaryWrapper = new BinaryWrapper { SelectedSignal = SelectedSignal, SignalParams = Params, DiscreteSignal = Signal }; Serializer.SaveToBinaryFile(binaryWrapper, path); }