-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
57 lines (47 loc) · 1.88 KB
/
Form1.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
using DevExpress.Data.Filtering;
using DevExpress.Diagram.Core;
using System;
using System.Reflection;
using System.Windows.Forms;
namespace WindowsFormsApp4 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
CreateArcPoint.Register();
RegisterStencil();
}
void RegisterStencil() {
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsApp4.CustomShapes.xml");
var stencil = DiagramStencil.Create("CustomStencil", "Custom Shapes", stream, 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;
}
}
}