-
Notifications
You must be signed in to change notification settings - Fork 1
/
DiagramStorageInitializer.cs
41 lines (40 loc) · 1.48 KB
/
DiagramStorageInitializer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using DevExpress.Diagram.Core;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using DevExpress.XtraDiagram;
namespace XtraDiagram.CustomDiagramStorage {
class DiagramStorageInitializer : DropCreateDatabaseIfModelChanges<DiagramStorage> {
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 DevExpress.Utils.PointFloat(200, 100 + i * 100),
Width = 100,
Height = 50,
Content = "Item " + (i + 1).ToString(),
});
if(i == 0)
continue;
diagram.SelectedStencils = new StencilCollection(new string[] {
DiagramToolboxRegistrator.Stencils.ElementAt(i).Id
});
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();
}
}
}