// TODO: does this really belong here public void AcceptNewDataFrom(WaveFile copyFrom) { NumberOfSamples = copyFrom.NumberOfSamples; Header = new byte[WaveFile.HEADER_SIZE]; Data = new byte[NumberOfSamples]; // copy the header data for (int i = 0; i < WaveFile.HEADER_SIZE; i++) { Header[i] = copyFrom.Header[i]; } // copy the wave data for (int i = 0; i < NumberOfSamples; i++) { Data[i] = copyFrom.Data[i]; } }
public static WaveFile SaveAs(string fileName) { WaveFile file = GetActiveFile(); // remove the reference to the old file in the repo RemoveOpenFile(file); // save the new file file.SaveAs(fileName); // add a reference to the new file in the repo var newFile = new WaveFile(fileName); AddOpenFile(newFile); FireFileSaveAs(file, newFile); FireWindowSelected(newFile); return newFile; }
public static void Save(WaveFile file) { file.Save(); FireFileSaved(); }
public static void PasteFileData(WaveFile copiedFile) { if (ActiveFile != null) { ActiveFile.AcceptNewDataFrom(copiedFile); } }
public static WaveFile Load(string fileName) { var wave = new WaveFile(fileName); // this will add or update the file reference in the repository AddOpenFile(wave); return wave; }
public static void FireFileSaveAs(WaveFile oldFile, WaveFile newFile) { if (FileSaveAs != null) FileSaveAs.Invoke(oldFile, newFile); }
private static void RemoveOpenFile(WaveFile file) { if (file != null) { WaveFileRepository.RemoveFile(file.filePath); } ActiveFile = null; }
public static void AddOrUpdateFile(string fileName, WaveFile file) { _data[fileName] = file; }
private void RefreshMemoryCounter(WaveFile file) { _memoryMeter.Recalculate(); }
public void UndoChanges() { // copy all the data attributes from the old object over the new one Wave.fileName = _prevData.fileName; Wave.filePath = _prevData.filePath; Wave.NumberOfSamples = _prevData.NumberOfSamples; // we should be able to just copy over these references instead of each entry... Wave.Header = _prevData.Header; Wave.Data = _prevData.Data; // since we're just doing one-level on undo, kill the old object _prevData = null; // change notification so the window will reload WaveManagerBusiness.WaveManager.FireCurrentWindowModified(); }
public GraphView() { InitializeComponent(); RenderStrategy = RenderStyle.Standard; Wave = new WaveFile(); }
public void SaveCurrentState() { // this clones the current data and preserves it if (Wave != null) _prevData = ((WaveFile)Wave.Clone()); }
public static void FireWindowSelected(WaveFile file) { if (WindowSelected != null) WindowSelected.Invoke(file); }
public static void FireInvalidFileOpened(WaveFile file) { if (InvalidFileOpened != null) InvalidFileOpened.Invoke(file); }
public static void SetActiveFile(WaveFile file) { ActiveFile = file; }
// END of volume control private void UpdateFileCount(WaveFile file) { _wavesCount.Text = "Waves: "+ WaveManagerBusiness.WaveManager.GetOpenFilesCount().ToString(); }
private static void AddOpenFile(WaveFile file) { // not: even if it already exists, the reference will just be updated WaveFileRepository.AddOrUpdateFile(file.filePath, file); }
private void UpdateSampleCount(WaveFile file) { _samplesCount.Text = "Samples: " + WaveManagerBusiness.WaveManager.GetActiveFile().NumberOfSamples.ToString(); }
private void OnDragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); WaveFile f = new WaveFile(); foreach (string file in files) { f = WaveManagerBusiness.WaveManager.OpenFile(file); } }
public static bool IsValid(WaveFile file) { return file.IsValid(); }
public object Clone() { var copy = new WaveFile(); copy.fileName = fileName; copy.filePath = filePath; copy.NumberOfSamples = NumberOfSamples; copy.Header = new byte[WaveFile.HEADER_SIZE]; copy.Data = new byte[NumberOfSamples]; // copy the header data for (int i = 0; i < WaveFile.HEADER_SIZE; i++) { copy.Header[i] = this.Header[i]; } // copy the wave data for (int i = 0; i < NumberOfSamples; i++) { copy.Data[i] = this.Data[i]; } return copy; }
public static void FireFileClosed(WaveFile file) { if (FileClosed != null) FileClosed.Invoke(file); }