protected override bool PerformSave(string FullPath) { m_Charset.Name = DocumentInfo.DocumentFilename; m_Charset.UsedTiles = GR.Convert.ToU32(editCharactersFrom.Text); if (IsBinaryFile()) { // save binary only! GR.Memory.ByteBuffer charSet = new GR.Memory.ByteBuffer(); charSet.Reserve(m_Charset.TotalNumberOfCharacters * Lookup.NumBytesOfSingleCharacterBitmap(m_Charset.Mode)); for (int i = 0; i < m_Charset.TotalNumberOfCharacters; ++i) { charSet.Append(m_Charset.Characters[i].Tile.Data); } return(SaveDocumentData(FullPath, charSet)); } GR.Memory.ByteBuffer projectFile = SaveToBuffer(); return(SaveDocumentData(FullPath, projectFile)); }
private bool SaveProject(bool SaveAs) { string saveFilename = DocumentInfo.FullPath; if ((String.IsNullOrEmpty(DocumentInfo.DocumentFilename)) || (SaveAs)) { System.Windows.Forms.SaveFileDialog saveDlg = new System.Windows.Forms.SaveFileDialog(); saveDlg.Title = "Save Charset Project as"; saveDlg.Filter = "Charset Projects|*.charsetproject|All Files|*.*"; if (DocumentInfo.Project != null) { saveDlg.InitialDirectory = DocumentInfo.Project.Settings.BasePath; } if (saveDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } if (SaveAs) { saveFilename = saveDlg.FileName; } else { DocumentInfo.DocumentFilename = saveDlg.FileName; if (DocumentInfo.Element != null) { if (string.IsNullOrEmpty(DocumentInfo.Project.Settings.BasePath)) { DocumentInfo.DocumentFilename = saveDlg.FileName; } else { DocumentInfo.DocumentFilename = GR.Path.RelativePathTo(saveDlg.FileName, false, System.IO.Path.GetFullPath(DocumentInfo.Project.Settings.BasePath), true); } DocumentInfo.Element.Name = System.IO.Path.GetFileNameWithoutExtension(DocumentInfo.DocumentFilename); DocumentInfo.Element.Node.Text = System.IO.Path.GetFileName(DocumentInfo.DocumentFilename); DocumentInfo.Element.Filename = DocumentInfo.DocumentFilename; } saveFilename = DocumentInfo.FullPath; } } if (!SaveAs) { m_Charset.Name = DocumentInfo.DocumentFilename; m_Charset.UsedTiles = GR.Convert.ToU32(editCharactersFrom.Text); } if (IsBinaryFile()) { // save binary only! GR.Memory.ByteBuffer charSet = new GR.Memory.ByteBuffer(); charSet.Reserve(256 * 8); for (int i = 0; i < 256; ++i) { charSet.Append(m_Charset.Characters[i].Data); } DisableFileWatcher(); if (!GR.IO.File.WriteAllBytes(saveFilename, charSet)) { EnableFileWatcher(); return(false); } SetUnmodified(); EnableFileWatcher(); return(true); } GR.Memory.ByteBuffer projectFile = SaveToBuffer(); return(SaveDocumentData(saveFilename, projectFile, SaveAs)); }