-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDiagramCommand.cs
61 lines (45 loc) · 1.04 KB
/
DiagramCommand.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
using UnityEngine;
using System.Collections.Generic;
public class DiagramCommand
{
private DiagramContext context;
public DiagramCommand (DiagramContext context)
{
this.context = context;
}
public void DeleteNode (DiagramNode node)
{
context.editor.GetRoot ().nodes.Remove (node);
context.GetSelection ().RemoveElement (node);
}
public void AddNode ()
{
DiagramNode newNode = new DiagramNode ();
Rect newRect = new Rect (newNode.rect);
List<DiagramNode> nodes = context.editor.GetRoot().nodes;
int size = nodes.Count;
if (0 < size) {
while (true) {
bool exist = false;
foreach (DiagramNode c in nodes) {
if (c.rect.x == newRect.x && c.rect.y == newRect.y) {
exist = true;
break;
}
}
if (exist) {
newRect.x += 20;
newRect.y += 20;
} else {
break;
}
}
}
newNode.rect = newRect;
nodes.Add (newNode);
}
public void AddAttribute(DiagramNode node){
Attribute attribute = new Attribute ();
node.attributes.Add(attribute );
}
}