Exemple #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 TilePickerViewModel(AtlasViewModel atlas, TileViewModel tile)
 {
     Atlas = atlas;
     Tile  = tile;
 }