Exemplo n.º 1
0
        private void AddTile(TileViewModel aTile)
        {
            GeometryModel3D _tileGeometry = new GeometryModel3D();

            _tileGeometry.Geometry     = new MeshGeometry3D();
            _tileGeometry.Material     = this.FTileMaterial;
            _tileGeometry.BackMaterial = this.FBackTileMaterial;

            TileGeometry _tile = new TileGeometry(
                aTile,
                _tileGeometry,
                null,
                this.ViewModel.Structure.IsHighDefenition,
                this.ViewModel.Center);

            this.FTiles.Add(_tile);

            int _tileSize   = JsdTile.GetProfileXSize(aTile.IsHighDefenition);
            int _tileBottom = aTile.TileIsOnRoof ? JsdTile.GetProfileZSize(aTile.IsHighDefenition) : 0;

            foreach (LayerCellViewModel _cell in aTile.ShapeViewModel.Cells)
            {
                if (_cell.LayerCellValue)
                {
                    _tile.AttachCube(_cell.X, _cell.Y, _cell.Z * 2, false, _tileSize, _tileBottom, false);
                }
            }

            //_tile.JoinCubeSides();

            _tile.UpdateTileGeometry();

            this.mgShape.Children.Add(_tileGeometry);
        }
Exemplo n.º 2
0
        void StructureViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == StructureViewModel.SelectedTilePropertyName)
            {
                TileViewModel _tile = (TileViewModel)this.dgTiles.SelectedItem;
                if (this.ViewModel.SelectedTile != _tile)
                {
                    this.dgTiles.SelectedItem = this.ViewModel.SelectedTile;
                    this.dgTiles.ScrollIntoView(this.ViewModel.SelectedTile);
                }

                this.SetTilesImage();

                if (this.ViewModel.SelectedTile != null)
                {
                    this.svShape.ViewModel = this.ViewModel.SelectedTile.ShapeViewModel;
                }
            }

            if (e.PropertyName == StructureViewModel.SelectedTileLocDataPropertyName)
            {
                RelTileLoc _tileLoc = (RelTileLoc)this.dgTileLocData.SelectedItem;
                if (this.ViewModel.SelectedTileLocData != _tileLoc)
                {
                    this.dgTileLocData.SelectedItem = this.ViewModel.SelectedTileLocData;
                    this.dgTileLocData.ScrollIntoView(this.ViewModel.SelectedTileLocData);
                }
                this.SetTilesLocImage();
            }
        }
Exemplo n.º 3
0
        public void AddJsdTile(JsdTile aTile)
        {
            this.FStructure.AddTile(aTile);
            TileViewModel _tileViewModel = new TileViewModel(aTile);

            this.Tiles.Add(_tileViewModel);
            this.SelectedTile = _tileViewModel;
        }
Exemplo n.º 4
0
        public void Execute(object parameter)
        {
            StructureViewModel _viewModel    = (StructureViewModel)parameter;
            TileViewModel      _selectedTile = _viewModel.SelectedTile;
            JsdTile            _rotatedTile  = _selectedTile.Tile.Clone();

            _rotatedTile.Rotate(false);
            _viewModel.AddJsdTile(_rotatedTile);
        }
Exemplo n.º 5
0
        public void Execute(object parameter)
        {
            StructureViewModel _viewModel = (StructureViewModel)parameter;
            JsdTile            _tile      = _viewModel.SelectedTile.Tile.Clone();

            _viewModel.Structure.AddTile(_tile);
            TileViewModel _tileViewModel = new TileViewModel(_tile);

            _viewModel.Tiles.Add(_tileViewModel);
            _viewModel.SelectedTile = _tileViewModel;
        }
Exemplo n.º 6
0
        public void Execute(object parameter)
        {
            StructureViewModel _viewModel = (StructureViewModel)parameter;
            JsdTile            _tile      = new JsdTile(_viewModel.IsHighDefenition);

            _viewModel.Structure.AddTile(_tile);
            TileViewModel _tileViewModel = new TileViewModel(_tile);

            _viewModel.Tiles.Add(_tileViewModel);
            _viewModel.SelectedTile = _tileViewModel;
        }
Exemplo n.º 7
0
 private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
 {
     if (e.AddedCells != null && e.AddedCells.Count > 0)
     {
         TileViewModel _tile = (TileViewModel)e.AddedCells[0].Item;
         if (this.ViewModel.SelectedTile != _tile)
         {
             this.ViewModel.SelectedTile = (TileViewModel)e.AddedCells[0].Item;
         }
     }
 }
Exemplo n.º 8
0
        private void AddTile(TileViewModel aTile)
        {
            GeometryModel3D _tileGeometry = new GeometryModel3D();

            _tileGeometry.Geometry = new MeshGeometry3D();

            GeometryModel3D _altTileGeometry = new GeometryModel3D();

            _altTileGeometry.Geometry = new MeshGeometry3D();

            if (aTile.IsSelected)
            {
                _tileGeometry.Material        = this.FSelectedTileMaterial;
                _tileGeometry.BackMaterial    = this.FSelectedBackTileMaterial;
                _altTileGeometry.Material     = this.FAltSelectedTileMaterial;
                _altTileGeometry.BackMaterial = this.FAltSelectedTileMaterial;
            }
            else
            {
                _tileGeometry.Material        = this.FTileMaterial;
                _tileGeometry.BackMaterial    = this.FBackTileMaterial;
                _altTileGeometry.Material     = this.FAltTileMaterial;
                _altTileGeometry.BackMaterial = this.FAltTileMaterial;
            }

            TileGeometry _tile = new TileGeometry(
                aTile,
                _tileGeometry,
                _altTileGeometry,
                this.ViewModel.Structure.IsHighDefenition,
                this.ViewModel.Center);

            this.FTiles.Add(_tile);

            int _tileSize   = JsdTile.GetProfileXSize(aTile.IsHighDefenition);
            int _tileBottom = aTile.TileIsOnRoof ? JsdTile.GetProfileZSize(aTile.IsHighDefenition) : 0;

            foreach (LayerCellViewModel _cell in aTile.ShapeViewModel.Cells)
            {
                if (_cell.LayerCellValue)
                {
                    _tile.AddCube(_cell.X, _cell.Y, _cell.Z, _tileSize, _tileBottom);
                    this.ViewModel.FilledPositionCount++;
                }
                _cell.AttachHandler(this, Cell_PropertyChanged);
            }

            _tile.UpdateTileGeometry();

            this.mgShape.Children.Add(_tileGeometry);
            this.mgShape.Children.Add(_altTileGeometry);
        }
Exemplo n.º 9
0
        void Tiles_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null && e.NewItems.Count > 0)
            {
                foreach (object _obj in e.NewItems)
                {
                    TileViewModel _tile = (TileViewModel)_obj;
                    _tile.AttachHandler(this, TileViewModel_PropertyChanged);
                }
            }

            this.SetTilesImage();
        }
Exemplo n.º 10
0
        public TileGeometry(TileViewModel aTile,
                            GeometryModel3D aTileGeometry,
                            GeometryModel3D aAltGeometry,
                            bool aIsHighDefenition,
                            Point3D aCenter)
        {
            this.FTile        = aTile;
            this.FGeometry    = aTileGeometry;
            this.FAltGeometry = aAltGeometry;

            this.FIsHighDefenition = aIsHighDefenition;
            this.FSides            = new List <CubeSide>();

            this.FCenter = aCenter;
        }
Exemplo n.º 11
0
        private void ProcessCell(LayerCellViewModel aCell, TileViewModel aTile)
        {
            TileGeometry _tile       = this.FTiles.Where(x => x.Tile == aTile).SingleOrDefault();
            int          _tileSize   = JsdTile.GetProfileXSize(aTile.IsHighDefenition);
            int          _tileBottom = aTile.TileIsOnRoof ? JsdTile.GetProfileZSize(aTile.IsHighDefenition) : 0;

            if (aCell.LayerCellValue)
            {
                _tile.AddCube(aCell.X, aCell.Y, aCell.Z, _tileSize, _tileBottom);
                this.ViewModel.FilledPositionCount++;
            }
            else
            {
                _tile.RemoveCube(aCell.X, aCell.Y, aCell.Z, _tileSize, _tileBottom);
                this.ViewModel.FilledPositionCount--;
            }

            _tile.UpdateTileGeometry();
        }
Exemplo n.º 12
0
        private void AddTileImage(TileViewModel aTileViewModel)
        {
            if (this.ViewModel.Image == null || aTileViewModel == null)
            {
                return;
            }

            PointCollection _baseTilePoints = StructureImage.GetBasePoints(
                (this.ViewModel.MinXPosRelToBase - 1) * StructureImage.TileWidth,
                (this.ViewModel.MinYPosRelToBase - 1) * StructureImage.TileHeight);

            if (this.ViewModel.Image != null)
            {
                _baseTilePoints = this.ViewModel.Image.BaseTilePoints;
            }
            int _xShift = aTileViewModel.XPosRelToBase - aTileViewModel.YPosRelToBase;
            int _yShift = aTileViewModel.XPosRelToBase + aTileViewModel.YPosRelToBase;

            Point _p0 = new Point(_baseTilePoints[0].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[0].Y + _yShift * StructureImage.TileHeight / 2);
            Point _p1 = new Point(_baseTilePoints[1].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[1].Y + _yShift * StructureImage.TileHeight / 2);
            Point _p2 = new Point(_baseTilePoints[2].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[2].Y + _yShift * StructureImage.TileHeight / 2);
            Point _p3 = new Point(_baseTilePoints[3].X + _xShift * StructureImage.TileWidth / 2,
                                  _baseTilePoints[3].Y + _yShift * StructureImage.TileHeight / 2);

            Polygon _polygon = new Polygon();

            _polygon.Tag        = aTileViewModel;
            _polygon.MouseDown += TileImage_MouseDown;

            _polygon.Stroke          = aTileViewModel == this.ViewModel.SelectedTile ? this.FImageSelectedTileBrush : this.FImageTileBrush;
            _polygon.StrokeThickness = 2;
            _polygon.Fill            = Brushes.Transparent;
            _polygon.Points          = new PointCollection(4);
            _polygon.Points.Add(_p0);
            _polygon.Points.Add(_p1);
            _polygon.Points.Add(_p2);
            _polygon.Points.Add(_p3);
            this.FImageTiles.Add(_polygon);
            this.cStructureImage.Children.Add(_polygon);
        }