-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
38 lines (36 loc) · 1.42 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
using System.Windows;
using DevExpress.Diagram.Core;
using DevExpress.Xpf.Diagram;
using System.ComponentModel;
namespace DXDiagram.CustomShapeProperties {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
RegisterStencil();
LoadData();
}
void LoadData() {
diagramControl.DocumentSource = "DiagramData.xml";
}
void RegisterStencil() {
var stencil = new DevExpress.Diagram.Core.DiagramStencil("CustomStencil", "Custom Shapes");
var itemTool = new FactoryItemTool(
"CustomShape",
() => "Custom Shape", diagram => {
DiagramShapeEx customShape = new DiagramShapeEx() { Width = 100, Height = 50 };
return customShape;
},
new Size(100, 50),
false
);
stencil.RegisterTool(itemTool);
DiagramToolboxRegistrator.RegisterStencil(stencil);
DiagramControl.ItemTypeRegistrator.Register(typeof(DiagramShapeEx));
}
private void diagramControl_CustomGetEditableItemProperties(object sender, DiagramCustomGetEditableItemPropertiesEventArgs e) {
if (e.Item is DiagramShapeEx) {
e.Properties.Add(TypeDescriptor.GetProperties(typeof(DiagramShapeEx))["Description"]);
}
}
}
}