コード例 #1
0
            private bool moveElement(bool up)
            {
                bool moved    = false;
                int  movement = up ? -1 : 1;

                var lineIndex = node.conversationLines.IndexOf(line);

                for (int i = 0; i < times; i++)
                {
                    if (lineIndex != -1 && lineIndex >= 0 - movement && lineIndex < node.conversationLines.Count - movement)
                    {
                        node.conversationNode.removeLine(lineIndex);
                        node.conversationNode.addLine(lineIndex + movement, line.getContent() as ConversationLine);
                        node.conversationLines.RemoveAt(lineIndex);
                        node.conversationLines.Insert(lineIndex + movement, line);
                        moved = true;

                        if (up)
                        {
                            node.lineMovedUp(lineIndex);
                        }
                        else
                        {
                            node.lineMovedDown(lineIndex);
                        }
                        lineIndex += movement;
                        node.Changed();
                    }
                }

                return(moved);
            }
コード例 #2
0
            private bool add()
            {
                bool added = false;

                if (!node.conversationLines.Contains(line))
                {
                    if (lineIndex >= 0 && lineIndex < node.conversationLines.Count)
                    {
                        node.conversationNode.addLine(lineIndex, line.getContent() as ConversationLine);
                        node.conversationLines.Insert(lineIndex, line);
                        node.lineAdded(lineIndex, data);
                    }
                    else
                    {
                        node.conversationNode.addLine(line.getContent() as ConversationLine);
                        node.conversationLines.Add(line);
                        node.lineAdded(node.conversationLines.Count - 1, data);
                    }

                    node.Changed();
                    added = true;
                }
                return(added);
            }