Esempio n. 1
0
        private bool CreateUndo(Map map, int position)
        {
            Map        mapBeforeEdit = map.CopyRegion();
            IMapObject obj;

            fillMapRects[position] = new Rectangle();
            switch (random.Next(3))
            {
            case 0:
                fillMapRects[position] = FillMapRandom(map);
                totalBackgroundCount++;
                // Sicherstellen, dass Änderungen gemacht wurden.
                if (fillMapRects[position].IsEmpty)
                {
                    return(false);
                }
                break;

            case 1:
                obj = FillMapObject(map);
                totalObjectCount++;
                break;

            case 2:
                FillMapCollisions(map);
                totalCollsionCount++;
                break;

            default:
                break;
            }


            UndoMap   undoMap            = new UndoMap(mapBeforeEdit, map, new UndoEventHandler(UndoEvent));
            int       listViewItemsCount = listView.Items.Count;
            Rectangle rectBeforeUndo     = TileDiffs(mapBeforeEdit, map);

            undoManager.Add(undoMap, listView.Items);

            // Sicherstellen, dass ein Eintrag im ListView gemacht wurde.
            if (listViewItemsCount + 1 != listView.Items.Count)
            {
                return(false);
            }

            // Rückgabewert ist true, falls das Skript bis hierhin gelaufen ist.
            return(true);
        }
Esempio n. 2
0
 private void UndoEvent(object sender, UndoEventArgs args)
 {
     UndoMap undoMap = sender as UndoMap;
 }