示例#1
0
        // 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];
            }
        }
示例#2
0
        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;
        }
示例#3
0
 public static void Save(WaveFile file)
 {
     file.Save();
     FireFileSaved();
 }
示例#4
0
 public static void PasteFileData(WaveFile copiedFile)
 {
     if (ActiveFile != null)
     {
         ActiveFile.AcceptNewDataFrom(copiedFile);
     }
 }
示例#5
0
        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;
        }
示例#6
0
 public static void FireFileSaveAs(WaveFile oldFile, WaveFile newFile)
 {
     if (FileSaveAs != null)
         FileSaveAs.Invoke(oldFile, newFile);
 }
示例#7
0
 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;
 }
示例#9
0
 private void RefreshMemoryCounter(WaveFile file)
 {
     _memoryMeter.Recalculate();
 }
示例#10
0
        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();
        }
示例#11
0
 public GraphView()
 {
     InitializeComponent();
     RenderStrategy = RenderStyle.Standard;
     Wave = new WaveFile();
 }
示例#12
0
 public void SaveCurrentState()
 {
     // this clones the current data and preserves it
     if (Wave != null)
         _prevData = ((WaveFile)Wave.Clone());
 }
示例#13
0
 public static void FireWindowSelected(WaveFile file)
 {
     if (WindowSelected != null)
         WindowSelected.Invoke(file);
 }
示例#14
0
 public static void FireInvalidFileOpened(WaveFile file)
 {
     if (InvalidFileOpened != null)
         InvalidFileOpened.Invoke(file);
 }
示例#15
0
 public static void SetActiveFile(WaveFile file)
 {
     ActiveFile = file;
 }
示例#16
0
 // END of volume control
 private void UpdateFileCount(WaveFile file)
 {
     _wavesCount.Text = "Waves: "+ WaveManagerBusiness.WaveManager.GetOpenFilesCount().ToString();
 }
示例#17
0
 private static void AddOpenFile(WaveFile file)
 {
     // not: even if it already exists, the reference will just be updated
     WaveFileRepository.AddOrUpdateFile(file.filePath, file);
 }
示例#18
0
 private void UpdateSampleCount(WaveFile file)
 {
     _samplesCount.Text = "Samples: " + WaveManagerBusiness.WaveManager.GetActiveFile().NumberOfSamples.ToString();
 }
示例#19
0
 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);
     }
 }
示例#20
0
 public static bool IsValid(WaveFile file)
 {
     return file.IsValid();
 }
示例#21
0
        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;
        }
示例#22
0
 public static void FireFileClosed(WaveFile file)
 {
     if (FileClosed != null)
         FileClosed.Invoke(file);
 }