/
SetSortCode.cs
65 lines (51 loc) · 1.9 KB
/
SetSortCode.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
60
61
62
63
64
65
public class MultiLevelSortCode
{
[DeclareAction("SetSortCodeAction")]
public void SetSortCodeAction()
{
//Use a Command Line Interpreter to call the Action
CommandLineInterpreter CLI = new CommandLineInterpreter();
Eplan.EplApi.Base.Settings set = new Eplan.EplApi.Base.Settings();
if(!set.ExistSetting("USER.SCRIPTS.SORTCODE"))
{
bool bOk = set.AddNumericSetting("USER.SCRIPTS.SORTCODE", new int[] { 0 },
new Range[] { new Range { FromValue = 0, ToValue = 32768}}, "Sort code setting", new int[] { 0 },
ISettings.CreationFlag.Insert);
}
int index = set.GetNumericSetting("USER.SCRIPTS.SORTCODE", 0);
ActionCallingContext ctx1 = new ActionCallingContext();
ctx1.AddParameter("propertyID","20809"); //Sort code
ctx1.AddParameter("propertyIndex","0");
ctx1.AddParameter("propertyValue", index.ToString());
CLI.Execute("XEsSetPropertyAction", ctx1);
set.SetNumericSetting("USER.SCRIPTS.SORTCODE", ++index, 0);
return;
}
[DeclareMenu]
public void SetSortCodeMenuFunction()
{
Eplan.EplApi.Gui.Menu oMenu = new Eplan.EplApi.Gui.Menu();
oMenu.AddMenuItem("Set sort code", "SetSortCodeAction");
}
[DeclareAction("ResetSortCodeAction")]
public void ResetSortCodeAction()
{
//Use a Command Line Interpreter to call the Action
CommandLineInterpreter CLI = new CommandLineInterpreter();
Eplan.EplApi.Base.Settings set = new Eplan.EplApi.Base.Settings();
if(!set.ExistSetting("USER.SCRIPTS.SORTCODE"))
{
bool bOk = set.AddNumericSetting("USER.SCRIPTS.SORTCODE", new int[] { 0 },
new Range[] { new Range { FromValue = 0, ToValue = 32768}}, "Sort code setting", new int[] { 0 },
ISettings.CreationFlag.Insert);
}
set.SetNumericSetting("USER.SCRIPTS.SORTCODE", 0, 0);
return;
}
[DeclareMenu]
public void ResetSortCodeMenuFunction()
{
Eplan.EplApi.Gui.Menu oMenu = new Eplan.EplApi.Gui.Menu();
oMenu.AddMenuItem("Reset sort code", "ResetSortCodeAction");
}
}