//--------------------------------------------------------------------- // BASIC MENU FUNCTIONS //--------------------------------------------------------------------- /// <summary> /// Helper function to save a HAM file, with lots of dumb error handling that doesn't work probably. /// </summary> private void SaveHAMFile() { if (saveHandler == null) //No save handler, so can't actually save right now { //HACK: Just call the save as handler for now... This needs restructuring mnuSaveAs_Click(this, new EventArgs()); return; //and don't repeat the save code when we recall ourselves. } Stream stream = saveHandler.GetStream(); if (stream == null) { MessageBox.Show(this, string.Format("Error opening save file {0}:\r\n{1}", saveHandler.GetUIName(), saveHandler.GetErrorMsg())); } else { datafile.Write(stream); if (saveHandler.FinalizeStream()) { MessageBox.Show(this, string.Format("Error writing save file {0}:\r\n{1}", saveHandler.GetUIName(), saveHandler.GetErrorMsg())); } else { transactionManager.UnsavedFlag = false; } } }
private void SaveSNDFile() { if (saveHandler == null) //No save handler, so can't actually save right now { //HACK: Just call the save as handler for now... This needs restructuring SaveAsMenu_Click(this, new EventArgs()); return; //and don't repeat the save code when we recall ourselves. } Stream stream = saveHandler.GetStream(); if (stream == null) { MessageBox.Show(this, string.Format("Error opening save file {0}:\r\n{1}", saveHandler.GetUIName(), saveHandler.GetErrorMsg())); } else { //TODO: The source stream is closed, so cached data must be used for (int i = 0; i < datafile.Sounds.Count; i++) { datafile.Sounds[i].Data = cache.GetSound(i); } datafile.Write(stream); stream.Dispose(); if (saveHandler.FinalizeStream()) { MessageBox.Show(this, string.Format("Error writing save file {0}:\r\n{1}", saveHandler.GetUIName(), saveHandler.GetErrorMsg())); } else { transactionManager.UnsavedFlag = false; } } }