internal static void SaveEditor(string id, EditorCanvas canvas) { if (canvas.FocusManager.IsEditorFocused) { canvas.FocusManager.FocusedEditor.RequestFocusCommit(true); } var mem = canvas.SaveContent(new MemoModelSerializer()); //using (var stream = new MemoryStream()) //using (var writer = XmlDictionaryWriter.CreateBinaryWriter(stream)) { // var knownTypes = new [] { // typeof(Memo), // typeof(Dictionary<string, object>), // typeof(List<IMemento>), // typeof(System.Drawing.Rectangle), // typeof(Mkamo.Common.Forms.Descriptions.FontDescription), // }; // var ser = new DataContractSerializer(typeof(Memento), knownTypes, int.MaxValue, false, true, null); // ser.WriteObject(writer, mem); // var acc = MemopadApplication.Instance.MemoAccessor; // if (acc.IsMementoExists(id)) { // acc.UpdateMemento(id, stream.GetBuffer()); // } else { // acc.InsertMemento(id, stream.GetBuffer()); // } //} using (var stream = new MemoryStream()) { var formatter = new BinaryFormatter(); formatter.Serialize(stream, mem); //var serializer = new NetDataContractSerializer(); //serializer.Serialize(stream, mem); var acc = MemopadApplication.Instance.MemoAccessor; if (acc.IsMementoExists(id)) { acc.UpdateMemento(id, stream.GetBuffer()); } else { acc.InsertMemento(id, stream.GetBuffer()); } } }