Пример #1
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();
            }
        }
Пример #2
0
        private void AddTileLocImage(RelTileLoc aTileLoc, double aShiftX)
        {
            if (aTileLoc == null || this.ViewModel.Image == null)
            {
                return;
            }

            PointCollection _baseTilePoints =
                StructureImage.GetBasePoints(aShiftX, StructureImage.TileHeight - this.ViewModel.Image.Height);
            int _xShift = aTileLoc.X - aTileLoc.Y;
            int _yShift = aTileLoc.X + aTileLoc.Y;

            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        = aTileLoc;
            _polygon.MouseDown += TileLoc_MouseDown;

            _polygon.Stroke =
                aTileLoc == this.ViewModel.SelectedTileLocData ? 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);
        }