Beispiel #1
0
        public void MoveByID(int moveFrom, int moveTo)
        {
            if (moveFrom == moveTo)
            {
                return;
            }
            NodeEntity nf = FindByID(moveFrom);

            if (nf == null)
            {
                return;
            }
            NodeEntity pf = nf.GetParent();

            if (pf == null)
            {
                return;
            }
            NodeEntity pt = FindByID(moveTo).GetParent();

            if (pt == null)
            {
                return;
            }
            nf = nf.Clone();
            for (int j = 0; j < pf.GetChildren().Count; j++)
            {
                if (pf.GetChildren()[j].GetNodeID() == moveFrom)
                {
                    pf.GetChildren().RemoveAt(j);
                    break;
                }
            }
            for (int i = 0; i < pt.GetChildren().Count; i++)
            {
                if (pt.GetChildren()[i].GetNodeID() == moveTo)
                {
                    pt.GetChildren().Insert(i, nf);
                    break;
                }
            }
            Refresh();
        }