Beispiel #1
0
        public MapViewModel(Map map)
        {
            // Set the model
            this.map = map;

            // Instantiate an atlas from the map.
            Atlas = new AtlasViewModel(map.Atlas);

            //Instantate the initial brush.
            brush = new BrushViewModel(this);

            // Instantiate the Tiles - Future tiles added should be done through the event
            tiles = new ObservableCollection <TileViewModel>();
            //map.Tiles.CollectionChanged += TilesCollectionChanged;

            foreach (Tile t in map.Tiles)
            {
                Tiles.Add(new TileViewModel(t));
                Tiles[Tiles.Count - 1].PropertyChanged += TileViewModel_PropertyChanged;
            }

            history = new History(map);

            // Add commands
            UndoAction = new RelayCommand(Command_UndoTilePlace);
            RedoAction = new RelayCommand(Command_RedoTilePlace);
            ClickMap   = new ParameterCommand(Command_ClickMap);
            DragMap    = new ParameterCommand(Command_DragMap);
        }
        public MapSettingsViewModel(MapViewModel map)
        {
            this.map = map;

            MapName   = map.Name;
            MapWidth  = map.Width;
            MapHeight = map.Height;

            ApplyChanges    = new RelayCommand(Command_ApplyChanges);
            SelectAtlasFile = new ParameterCommand(Command_SelectAtlasFile);

            Atlas    = new AtlasViewModel(new Atlas(map.Atlas.TileSheet, map.Atlas.TileWidth, map.Atlas.TileHeight));
            FillTile = new TileViewModel(Atlas, new Tile(0, 0));
        }
        public BrushViewModel(MapViewModel parentMap)
        {
            // Fields
            map     = parentMap;
            Rows    = 1;
            Columns = 1;

            // Tile Maps
            Tiles = new ObservableCollection <TileViewModel>();
            // Map has one tile by default
            TileViewModel newTile = new TileViewModel(map.Atlas, new Tile(0, 0));

            Tiles.Add(newTile);
            newTile.IsSelected = true;

            // Commands
            ChangeRows    = new ParameterCommand(Command_ChangeRows);
            ChangeColumns = new ParameterCommand(Command_ChangeColumns);
            SelectTile    = new ParameterCommand(Command_SelectTile);
        }