-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.vb
60 lines (49 loc) · 2.18 KB
/
MainWindow.xaml.vb
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
Imports DevExpress.Data.Filtering
Imports DevExpress.Diagram.Core
Imports System
Imports System.Windows
Namespace WpfApp13
Public Partial Class MainWindow
Inherits Window
Public Sub New()
Me.InitializeComponent()
CreateArcPoint.Register()
RegisterStencil()
End Sub
Private Sub RegisterStencil()
Dim customShapesDictionary As ResourceDictionary = New ResourceDictionary() With {.Source = New Uri("CustomShapes.xaml", UriKind.Relative)}
Dim stencil = DiagramStencil.Create("CustomStencil", "Custom Shapes", customShapesDictionary, Function(shapeName) shapeName)
DiagramToolboxRegistrator.RegisterStencil(stencil)
Me.diagramControl1.SelectedStencils = New StencilCollection() From {"CustomStencil"}
End Sub
End Class
Public Class CreateArcPoint
Implements ICustomFunctionOperator
Private Shared ReadOnly instance As CreateArcPoint = New CreateArcPoint()
Public Shared Sub Register()
CriteriaOperator.RegisterCustomFunction(instance)
End Sub
Public Shared Sub Unregister()
CriteriaOperator.UnregisterCustomFunction(instance)
End Sub
Public ReadOnly Property Name As String Implements ICustomFunctionOperator.Name
Get
Return NameOf(CreateArcPoint)
End Get
End Property
Public Function ResultType(ParamArray operands As Type()) As Type Implements ICustomFunctionOperator.ResultType
Return GetType(Double)
End Function
Public Function Evaluate(ParamArray operands As Object()) As Object Implements ICustomFunctionOperator.Evaluate
If operands.Length = 3 AndAlso TypeOf operands(0) Is Double AndAlso TypeOf operands(1) Is Double AndAlso TypeOf operands(2) Is String Then
Dim X = CDbl(operands(0))
Dim Y = CDbl(operands(1))
Dim axe = CStr(operands(2))
If axe Is "X" Then Return If(X > 0.5, X, 0.5)
Return If(X > 0.5, Y, 1)
Else
Return Nothing
End If
End Function
End Class
End Namespace