public void Save(System.Windows.Forms.RichTextBox Contents, ContextFile context) { using (var FileOut = File.OpenWrite(context.CurrentFile)) { NoteDocument prep = new NoteDocument(); prep.EncodingData = StringEncodingData.PLAINTEXT | StringEncodingData.UNICODE_STRING; prep.CoreString = Contents.Text; prep.SaveToStream(FileOut); } }
public void Load(RichTextBox Contents, ContextFile context) { bool stringIsUnicode = false; bool rtf = false; using (var input = File.OpenRead(context.CurrentFile)) { NoteDocument Data = new NoteDocument(input); if (Data.EncodingData.HasFlag(StringEncodingData.ANSI_STRING) || (Data.EncodingData.HasFlag(StringEncodingData.UNICODE_STRING) == false)) { stringIsUnicode = false; } else { stringIsUnicode = true; } if (Data.EncodingData.HasFlag(StringEncodingData.PLAINTEXT) || (Data.EncodingData.HasFlag(StringEncodingData.RICHTEXT) == false)) { rtf = false; } else { rtf = true; } if (rtf) { Contents.Rtf = Data.CoreString; } else { Contents.Text = Data.CoreString; } } }