-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
59 lines (47 loc) · 1.9 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
using DevExpress.Data.Filtering;
using DevExpress.Diagram.Core;
using System;
using System.Windows;
namespace WpfApp13 {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
CreateArcPoint.Register();
RegisterStencil();
}
void RegisterStencil() {
ResourceDictionary customShapesDictionary = new ResourceDictionary() { Source = new Uri("CustomShapes.xaml", UriKind.Relative) };
var stencil = DiagramStencil.Create("CustomStencil", "Custom Shapes", customShapesDictionary, shapeName => shapeName);
DiagramToolboxRegistrator.RegisterStencil(stencil);
diagramControl1.SelectedStencils = new StencilCollection() { "CustomStencil" };
}
}
public class CreateArcPoint : ICustomFunctionOperator {
private static readonly CreateArcPoint instance = new CreateArcPoint();
public static void Register() {
CriteriaOperator.RegisterCustomFunction(instance);
}
public static void Unregister() {
CriteriaOperator.UnregisterCustomFunction(instance);
}
public string Name => nameof(CreateArcPoint);
public Type ResultType(params Type[] operands) {
return typeof(double);
}
public object Evaluate(params object[] operands) {
if (operands.Length == 3
&& operands[0] is double
&& operands[1] is double
&& operands[2] is string) {
var X = (double)operands[0];
var Y = (double)operands[1];
var axe = (string)operands[2];
if (axe is "X")
return X > 0.5 ? X : 0.5;
return X > 0.5 ? Y : 1;
}
else
return null;
}
}
}