-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
71 lines (58 loc) · 2.24 KB
/
MainWindow.xaml.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using DevExpress.Diagram.Core;
using DevExpress.Xpf.Diagram;
using System.Windows;
using System.Windows.Media;
namespace WpfApp13 {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
RegisterStencil();
}
void RegisterStencil() {
var stencil = new DiagramStencil("CustomStencil", "Custom Shapes");
var itemTool = new FactoryItemTool("CustomShape1",
() => "Custom Shape 1",
diagram => CreateContainerShape1(),
new System.Windows.Size(200, 200),
false
);
stencil.RegisterTool(itemTool);
DiagramToolboxRegistrator.RegisterStencil(stencil);
diagramControl1.SelectedStencils = new StencilCollection() { "CustomStencil" };
}
public DiagramContainer CreateContainerShape1() {
var container = new DiagramContainer();
container.StrokeThickness = 0;
container.Background = Brushes.Transparent;
var innerShape1 = new DiagramShape() {
CanSelect = false,
CanChangeParent = false,
CanEdit = false,
CanCopyWithoutParent = false,
CanDeleteWithoutParent = false,
CanMove = false,
Shape = BasicShapes.Trapezoid,
Anchors = Sides.Top | Sides.Left | Sides.Right,
Height = 50,
Width = 200,
Content = "Custom text"
};
var innerShape2 = new DiagramShape() {
CanSelect = false,
CanChangeParent = false,
CanEdit = false,
CanCopyWithoutParent = false,
CanDeleteWithoutParent = false,
CanMove = false,
Shape = BasicShapes.Rectangle,
Anchors = Sides.All,
Height = 150,
Width = 200,
Position = new Point(0, 50),
};
container.Items.Add(innerShape1);
container.Items.Add(innerShape2);
return container;
}
}
}