private void NodeContextMenuCallback(object obj) { GraphContextCommand cmd = (GraphContextCommand)obj; switch (cmd) { case GraphContextCommand.Delete: if (contextMenuNode.NodeType == NodeType.Normal) { Flow.Nodes.Remove(contextMenuNode); } break; } }
private void LineContextMenuCallback(object obj) { GraphContextCommand cmd = (GraphContextCommand)obj; switch (cmd) { case GraphContextCommand.AddNode: { GraphNode node = new GraphNode(Flow); node.Label = "New Node"; node.Position = GetNormalizedPositionOnGraph(contextMenuPosition); Flow.Nodes.Add(node); break; } case GraphContextCommand.Delete: { if (Flow.Lines.Count > 1) { int lineIndex = Flow.Lines.IndexOf(contextMenuLine); Flow.Lines.RemoveAt(lineIndex); if (lineIndex == 0) { var replacementLine = Flow.Lines[0]; replacementLine.Position = 0; replacementLine.Length += contextMenuLine.Length; } else { var replacementLine = Flow.Lines[lineIndex - 1]; replacementLine.Length += contextMenuLine.Length; } } break; } case GraphContextCommand.SplitLine: { float position = GetNormalizedPositionOnGraph(contextMenuPosition); float originalLength = contextMenuLine.Length; int index = Flow.Lines.IndexOf(contextMenuLine); float totalLength = 0; for (int i = 0; i < index; i++) { totalLength += Flow.Lines[i].Length; } contextMenuLine.Length = position - totalLength; GraphLine newSegment = new GraphLine(Flow); foreach (var dungeonArchetype in contextMenuLine.DungeonArchetypes) { newSegment.DungeonArchetypes.Add(dungeonArchetype); } newSegment.Position = position; newSegment.Length = originalLength - contextMenuLine.Length; Flow.Lines.Insert(index + 1, newSegment); break; } } }