protected override void Seed(DiagramStorage storage) { base.Seed(storage); var diagram = new DiagramControl(); for (int i = 0; i < 5; i++) { diagram.Items.Add(new DiagramShape() { Position = new Point(200, 100 + i * 100), Width = 100, Height = 50, Content = "Item " + (i + 1).ToString(), }); if (i == 0) { continue; } using (var stream = new MemoryStream()) { diagram.SaveDocument(stream); var diagramData = new DiagramData() { Name = (i + 1).ToString() + " items", Data = stream.ToArray(), }; storage.DiagramData.Add(diagramData); } } storage.SaveChanges(); }
private void OnCustomSaveDocument(object sender, DevExpress.Xpf.Diagram.DiagramCustomSaveDocumentEventArgs e) { var storage = new DiagramStorage(); var diagramInfo = storage.DiagramData.FirstOrDefault(x => x.Name == (string)e.DocumentSource); if (diagramInfo == null) { diagramInfo = new DiagramData() { Name = (string)e.DocumentSource }; storage.DiagramData.Add(diagramInfo); } var stream = new MemoryStream(); diagram.SaveDocument(stream); diagramInfo.Data = stream.ToArray(); storage.SaveChanges(); e.Handled = true; }