-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainWindow.xaml.cs
30 lines (28 loc) · 1.32 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
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 System.Windows.Size(100, 50), false);
stencil.RegisterTool(itemTool);
DevExpress.Diagram.Core.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"]);
}
}
}
}